diff options
author | Jack Hsu <jack.hsu@gmail.com> | 2010-05-12 22:51:13 +0800 |
---|---|---|
committer | Richard D. Worth <rdworth@gmail.com> | 2010-05-12 23:49:15 +0800 |
commit | 5b4c04acb5cff032afae437c343239ee9bf4e04f (patch) | |
tree | 1cf0c26ccc02947aece9d286921dc8d6557feff8 /ui/jquery.ui.selectable.js | |
parent | 114c001aba3406e35e4fa1343501de7518257519 (diff) | |
download | jquery-ui-5b4c04acb5cff032afae437c343239ee9bf4e04f.tar.gz jquery-ui-5b4c04acb5cff032afae437c343239ee9bf4e04f.zip |
Selectable: modified _mouseStart function to unselect event.target if the Ctrl/Cmd key is pressed, and target is selected. Fixed #4293 - Ctrl + Click on selected list item does not deselect
Diffstat (limited to 'ui/jquery.ui.selectable.js')
-rw-r--r-- | ui/jquery.ui.selectable.js | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/ui/jquery.ui.selectable.js b/ui/jquery.ui.selectable.js index a14f720b7..d679d1018 100644 --- a/ui/jquery.ui.selectable.js +++ b/ui/jquery.ui.selectable.js @@ -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; |