CoreFiles by mySites.guru
multiselect.js38 lines, 1,154 bytes, from Joomla_1.6.2-Stable-Full_Package.zip
Raw History Compare with 1.6.1
md5
faeb7d11af9714d07d836490347c10d3
sha1
d3796526ca222e9bf45bd1607e0eb0ba334a909c
sha256
ebc5fa88a917263f908504362353c22c39f656acf863ec7ad2d412901945a325
/**
 * @version		$Id: multiselect.js 20196 2011-01-09 02:40:25Z ian $
 * @copyright	Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */

/**
 * JavaScript behavior to allow shift select in administrator grids
 */
(function() {
	Joomla = Joomla || {};

	Joomla.JMultiSelect = new Class({
		initialize : function(table) {
			this.table = document.id(table);
			this.boxes = table.getElements('input[type=checkbox]');
			this.boxes.addEvent('click', this.doselect.bindWithEvent(this));
		},
		doselect: function(e) {
			var current = document.id(e.target);
			if(e.shift && $type(this.last) !== false){
				var checked = current.getProperty('checked')  ? 'checked' : '';
				var range = [this.boxes.indexOf(current), this.boxes.indexOf(this.last)].sort();
				for(var i=range[0]; i <= range[1]; i++){
					this.boxes[i].setProperty('checked', checked);
				}
			}
			this.last = current;
		}
	});

	window.addEvent('domready', function() {
		var adminForm = document.id('adminForm');
		if (adminForm) {
			new Joomla.JMultiSelect(adminForm);
		}
	});
})();

The same content is in 7 releases, Joomla 1.6.0 to 1.6.6. See them all, or every version of this file.