Difference between revisions of "MediaWiki:Common.js"

From Beyond Social
 
(46 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
/* Any JavaScript here will be loaded for all users on every page load. */
 
/* Any JavaScript here will be loaded for all users on every page load. */
  
 +
 +
 +
/* for edit pages */
 +
 +
// if ( ( mw.config.get('wgPageName') ).indexOf('Special:UploadWizard') !== -1 ){ 
  
 
$(document).ready(
 
$(document).ready(
function(){ console.log('hello js');}
+
function(){
)
+
//hide UploadWizard licensing text
 +
$('div#mwe-upwiz-deeds').css('display','none', 'important');
 +
})
 +
//}
 +
 
 +
/* for Editorial_selection Form */
 +
 
 +
if ( (mw.config.get('wgPageName') ).indexOf('Special:FormEdit/Editorial_selection/') !== -1 ){ 
 +
 
 +
var allarticles = $('label[class*=issue_]'); //label elements with class contains issue_*
 +
var checkboxesSpan =$('.checkboxesSpan'); // TODO: make specific for articles NOT issues
 +
 
  
  
/* for Editorial_selection Form */
+
$(document).ready(
 +
    function(){
 +
        allarticles.css('display','none');
 +
        $('td').css('vertical-align', 'top');
 +
        $('.checkboxSwitches').css('color','red', 'important');
 +
    }
 +
)
  
//hide
 
var allarticles = $("lable[class^=issue_]"); //lable elements whose class starts with issue_
 
allarticles.css('display','none');
 
  
 
//get issue check boxes
 
//get issue check boxes
var checkboxes = $('input.createboxInput[value*="Issue"]');
+
var issueboxes = $('input.createboxInput[value*="Issue"]');
 
var clickedbox ;
 
var clickedbox ;
 
var checked;
 
var checked;
 
var boxval
 
var boxval
 
checkboxes.click(
 
function(){
 
console.log('click');
 
clickedbox = $(this);
 
checked = clickedbox.prop('checked');
 
boxval = clickedbox.val();
 
  
console.log( clickedbox, checked, boxval );
+
issueboxes.click(
 +
    function(){
 +
        console.log('click');
 +
        clickedbox = $(this);
 +
        checked = clickedbox.prop('checked');
 +
        issuenum = clickedbox.val();
 +
        var issue_articles = $('label[class*=issue_'+ ( issuenum.replace('Issue_','')) +']');
  
// if checked == true -> show articles within baxval category
+
        if (checked == true){
// if checked == false -> hide articles within baxval category
+
            issue_articles.css('display','block');
 +
        }else {
 +
            $('.issue_' + (issuenum.replace('Issue_','')) + ' > input.createboxInput').prop('checked',false);  // parent .issue_2
 +
            issue_articles.css('display','none');
 +
        }
 +
    } )
  
 
}
 
}
)
 

Latest revision as of 20:08, 9 February 2017

/* Any JavaScript here will be loaded for all users on every page load. */



/* for edit pages */

// if ( ( mw.config.get('wgPageName') ).indexOf('Special:UploadWizard') !== -1 ){  

$(document).ready(
function(){
//hide UploadWizard licensing text
$('div#mwe-upwiz-deeds').css('display','none', 'important');
})
//}

/* for Editorial_selection Form */

if ( (mw.config.get('wgPageName') ).indexOf('Special:FormEdit/Editorial_selection/') !== -1 ){  

var allarticles = $('label[class*=issue_]'); //label elements with class contains issue_*
var checkboxesSpan =$('.checkboxesSpan'); // TODO: make specific for articles NOT issues



$(document).ready(
    function(){
        allarticles.css('display','none');
        $('td').css('vertical-align', 'top');
        $('.checkboxSwitches').css('color','red', 'important');
    }
)


//get issue check boxes
var issueboxes = $('input.createboxInput[value*="Issue"]');
var clickedbox ;
var checked;
var boxval

issueboxes.click(
    function(){
        console.log('click');
        clickedbox = $(this);
        checked = clickedbox.prop('checked');
        issuenum = clickedbox.val();
        var issue_articles = $('label[class*=issue_'+ ( issuenum.replace('Issue_','')) +']');

        if (checked == true){
            issue_articles.css('display','block');
        }else {
            $('.issue_' + (issuenum.replace('Issue_','')) + ' > input.createboxInput').prop('checked',false);  // parent .issue_2
            issue_articles.css('display','none');
        }
    } )

}