]> source.dussan.org Git - jquery-ui.git/commitdiff
Selectable: modified _mouseStart function to unselect event.target if the Ctrl/Cmd...
authorJack Hsu <jack.hsu@gmail.com>
Wed, 12 May 2010 14:51:13 +0000 (22:51 +0800)
committerRichard D. Worth <rdworth@gmail.com>
Wed, 12 May 2010 15:49:15 +0000 (23:49 +0800)
ui/jquery.ui.selectable.js

index a14f720b781d556dc8e6e878856cc94053d1b995..d679d10185a584833d65e5f11cfd8946bad66d6f 100644 (file)
@@ -121,12 +121,15 @@ $.widget("ui.selectable", $.ui.mouse, {
                $(event.target).parents().andSelf().each(function() {
                        var selectee = $.data(this, "selectable-item");
                        if (selectee) {
-                               selectee.$element.removeClass("ui-unselecting").addClass('ui-selecting');
-                               selectee.unselecting = false;
-                               selectee.selecting = true;
-                               selectee.selected = true;
-                               // selectable SELECTING callback
-                               self._trigger("selecting", event, {
+                               var doSelect = !event.metaKey || !selectee.$element.hasClass('ui-selected');
+                               selectee.$element
+                                       .removeClass(doSelect ? "ui-unselecting" : "ui-selected")
+                                       .addClass(doSelect ? "ui-selecting" : "ui-unselecting");
+                               selectee.unselecting = !doSelect;
+                               selectee.selecting = doSelect;
+                               selectee.selected = doSelect;
+                               // selectable UNSELECTING callback
+                               self._trigger(doSelect ? "selecting" : "unselecting", event, {
                                        selecting: selectee.element
                                });
                                return false;