CoreFiles by mySites.guru
multiselect-uncompressed.js43 lines, 1,353 bytes, from Joomla_3.2.2-Stable-Full_Package.zip
Raw History Compare with 3.2.1
md5
0bb000386f869988b5b7c3e9ad7930a2
sha1
f2ac4ca16fda78972112455fba7d391317cc733d
sha256
9194eabafaacb9ec5ae7b5ee36dfc3a4f57000212db1e4e0c72b393d764d1c04
/**
 * @copyright   Copyright (C) 2005 - 2014 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 || {};
    var $boxes;
    Joomla.JMultiSelect = function(table) {
        var $last,
        
        initialize = function(table) {
            $boxes = $('#' + table).find('input[type=checkbox]');
            $boxes.on('click', function(e) {
                doselect(e)
            });
        },
        
        doselect = function(e) {
            var $current = $(e.target), isChecked, lastIndex, currentIndex, swap;
            if (e.shiftKey && $last.length) {
                isChecked = $current.is(':checked');
                lastIndex = $boxes.index($last);
                currentIndex = $boxes.index($current);
                if (currentIndex < lastIndex) {
                    // handle selection from bottom up
                    swap = lastIndex;
                    lastIndex = currentIndex;
                    currentIndex = swap;
                }
                $boxes.slice(lastIndex, currentIndex + 1).attr('checked', isChecked);
            }

            $last = $current;
        }
        initialize(table);
    }

})(jQuery);

The same content is in 13 releases, Joomla 3.2.2 to 3.3.6. See them all, or every version of this file.