PageSourceSearch

https://www.taedp.org.tw/sites/all/modules/civicrm/packages/jquery/plugins/checkboxselect.js

js taedp.org.tw collected 2026-10-02 11:36:13 UTC 2,889 bytes, 81 lines download raw bytes

1/*
2 * select / unselect checkboxes plugin for jQuery
3 *########################################
4 *# Logic to select/unselect checkboxes  #
5 *########################################
6 * Last Action   Current Status	     Result
7 *	         ( of the checkbox 
8 *		   you selected )
9 *
10 * Checked       Checked             Uncheck the all checkboxes between the two
11 * Checked       UnChecked	     Check the all checkboxes between the two
12 * UnChecked     Checked	     Uncheck the all checkboxes between the two
13 * UnChecked     UnChecked 	     Check the all checkboxes between the two
14 */
15
16(function($){
17
18var lastChecked = null;
19
20$(document).ready(function() {
21    $('.form-checkbox').click(function(event) {
22	//class selector is present?
23	var isSelector = $(this).parent().parent().parent().parent().attr('class');
24	//if not donot allow
25	if (isSelector != 'selector' ) {
26	    return;
27	}
28	if ( !lastChecked ) {
29	    lastChecked = this;
30	    return;
31	}
32	if ( event.shiftKey ) {
33	    var start = $('.form-checkbox').index(this);
34	    var end   = $('.form-checkbox').index(lastChecked);
35	    if ( start == end ) {
36		return;
37	    }
38	    var validLastcheck = $(lastChecked).parent().parent().attr('class');
39	    var validthischeck = $(this).parent().parent().attr('class');
40	    //don't allow the select/unslect other than search result e.g.(search form)
41	    //TODO: once all headers are sticky( under development), we can remove the columnheader check	    
42	    var params = new Array( "listing-box", "columnheader", "sticky", "" );
43	    for ( i = 0; i < params.length; i++ ) {		
44		if ( params[i] == validLastcheck || params[i] == validthischeck ) {
45		    return;
46		}
47	    }
48	    var min   = Math.min( start, end );
49	    var max   = Math.max( start, end );
50	    if ( lastChecked.checked && this.checked ) {
51		lastChecked.checked = true;
52	    } else if ( lastChecked.checked  && !this.checked ) {
53	    	lastChecked.checked = false;
54	    } else if ( !lastChecked.checked && this.checked  ) {
55	    	lastChecked.checked = true;
56	    } else if (! lastChecked.checked && !this.checked ) {
57		lastChecked.checked = false;
58	    } 
59	    for ( i = min; i <= max; i++ ) {
60		//check the checkboxes between the two chech boxes
61		$('.form-checkbox')[i].checked = lastChecked.checked;
62	    }
63	    //add class for tr and remove if it unchecked
64	    $('.selector tbody tr td:first-child input:checkbox').each( function() {
65		var oldClass = $(this).parent().parent().attr('class');
66		if ( this.checked ) {
67		    $(this).parent().parent().removeClass().addClass('row-selected '+ oldClass);
68		} else {
69		    var lastClass = $(this).parent().parent().attr('class');
70		    var str       = lastClass.toString().substring(12);
71		    if ( lastClass.substring(0,12) == "row-selected" ) {
72			$(this).parent().parent().removeClass().addClass(str);
73		    }
74		}	
75	    });	    
76	}
77	lastChecked = this;
78    });
79});
80
81})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.