Difference between revisions of "MediaWiki:Common.js"

From Beyond Social
Line 5: Line 5:
  
 
/* for Editorial_selection Form */
 
/* for Editorial_selection Form */
 +
( (mw.config.get( 'wgPageName' )).indexOf('Special:FormEdit/Editorial_selection/') !== -1 ){
  
if ( (mw.config.get( 'wgPageName' )).indexOf('Special:FormEdit/Editorial_selection/') !== -1 ){  alert('Form');}
+
var allarticles = $('label[class*=issue_]'); //label elements with class contains issue_*                                                                               
 +
var checkboxesSpan =$('.checkboxesSpan'); // TODO: make specific for articles NOT issues                                                                               
  
var allarticles = $('label[class*=issue_]'); //label elements with class contains issue_*
+
$(document).ready(
var checkboxesSpan =$('.checkboxesSpan'); // TODO: make specific for articles NOT issues
+
    function(){
 +
        // checkboxesSpan.css('display','none'); //hide on load               
 +
                                                                                         
 +
        allarticles.css('display','none');
 +
    }
 +
)
  
$(document).ready(
+
//get issue check boxes             
    function(){
+
                                                                                                                         
        // checkboxesSpan.css('display','none'); //hide on load
+
var issueboxes = $('input.createboxInput[value*="Issue"]');
        allarticles.css('display','none');
+
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_','')) +']');
  
//get issue check boxes
+
        if (checked == true){
var issueboxes = $('input.createboxInput[value*="Issue"]');
+
            issue_articles.css('display','block');
var clickedbox ;
+
        }else {
var checked;
+
            $('.issue_' + (issuenum.replace('Issue_','')) + ' > input.createboxInput').prop('checked',false); // parent .issue_2
var boxval
+
            issue_articles.css('display','none');
 +
        }
  
 
+
    }
 
+
  )
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');
 
        }
 
 
 
 
 
        console.log( clickedbox, checked, issuenum );
 
        console.log('Addressing', issue_articles);
 
 
 
        // if checked == true -> show articles within baxval category
 
        // if checked == false -> hide articles within baxval category
 
 
 
    }
 
)
 

Revision as of 17:13, 19 December 2016

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




/* for Editorial_selection Form */
( (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(){
         // checkboxesSpan.css('display','none'); //hide on load                
                                                                                          
         allarticles.css('display','none');
     }
 )

 //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');
         }

     }
 )
}