Difference between revisions of "MediaWiki:Common.js"

From Beyond Social
Line 4: Line 4:
  
  
/* for Editorial_selection Form */
+
/* for Editorial_selection Form "Special:FormEdit/Editorial_selection/" */
 +
 
 +
 
 +
 
 +
if ( mw.config.get( 'wgPageName' ) ).indexOf('Special:FormEdit/Editorial_selection/') !== -1 ){
  
 
var allarticles = $('label[class*=issue_]'); //label elements with class contains issue_*
 
var allarticles = $('label[class*=issue_]'); //label elements with class contains issue_*
 
var checkboxesSpan =$('.checkboxesSpan'); // TODO: make specific for articles NOT issues
 
var checkboxesSpan =$('.checkboxesSpan'); // TODO: make specific for articles NOT issues
  
$(document).ready(
+
allarticles.css('display','none'); //hide all articles boxes
    function(){
 
        // checkboxesSpan.css('display','none'); //hide on load
 
        allarticles.css('display','none');
 
    }
 
)
 
 
 
  
//get issue check boxes
+
// issue check boxes when clicked
 
var issueboxes = $('input.createboxInput[value*="Issue"]');
 
var issueboxes = $('input.createboxInput[value*="Issue"]');
 
var clickedbox ;
 
var clickedbox ;
 
var checked;
 
var checked;
var boxval
+
var boxval;
 
 
 
 
  
 
issueboxes.click(
 
issueboxes.click(
 
     function(){
 
     function(){
        console.log('click');
 
 
         clickedbox = $(this);
 
         clickedbox = $(this);
 
         checked = clickedbox.prop('checked');
 
         checked = clickedbox.prop('checked');
Line 39: Line 34:
 
             issue_articles.css('display','none');
 
             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 21:39, 18 December 2016

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




/* for Editorial_selection Form  "Special:FormEdit/Editorial_selection/" */



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

allarticles.css('display','none'); //hide all articles boxes

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

issueboxes.click(
    function(){
        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');
        }
    }
)

}