CoreFiles by mySites.guru
multiselect-uncompressed.js43 lines, 1,360 bytes, from Joomla_3.6.0-Stable-Full_Package.zip
Raw History Compare with 3.5.1
md5
903201939527465324b94fc53872abf4
sha1
7fb838b7ddfc20302b696b4124873e7261c28f73
sha256
15ac4f56870c9642ee1806e87fd788e0e0c51c482f51a9af527a77ccde450dfd
/**
 * @copyright   Copyright (C) 2005 - 2016 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 = window.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 29 releases, Joomla 3.5.0-beta2 to 3.7.0-alpha1. See them all, or every version of this file.