Skip to content

Commit 7013e17

Browse files
committed
shift_select_self_implement
1 parent e31be67 commit 7013e17

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

jquery.filters.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,28 @@
987987
return (-1 < $.inArray(item, array))
988988
}
989989

990+
$.fn.shiftSelectable = function() {
991+
var lastChecked,
992+
$boxes = this;
993+
994+
$boxes.click(function(evt) {
995+
if(!lastChecked) {
996+
lastChecked = this;
997+
return;
998+
}
999+
1000+
if(evt.shiftKey) {
1001+
var start = $boxes.index(this),
1002+
end = $boxes.index(lastChecked);
1003+
$boxes.slice(Math.min(start, end), Math.max(start, end) + 1)
1004+
.attr('checked', lastChecked.checked)
1005+
.trigger('change');
1006+
}
1007+
1008+
lastChecked = this;
1009+
});
1010+
};
1011+
9901012
/////////////// Events Binding end ////////////////////
9911013

9921014
}( jQuery ));

0 commit comments

Comments
 (0)