From 593cb1ffeffb981961804b7b1c13adcbf92618c7 Mon Sep 17 00:00:00 2001 From: Paul Bakaus Date: Sun, 8 Jun 2008 11:00:47 +0000 Subject: [PATCH] core: cancel checks for type string before it's used draggable-test: changed cancel: true test: this should cancel on all elements, but simply do nothing, since true is a unsupported value. --- tests/draggable.js | 5 ----- ui/ui.core.js | 2 +- ui/ui.sortable.js | 6 +++--- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/tests/draggable.js b/tests/draggable.js index 45b907d78..d428a21ff 100644 --- a/tests/draggable.js +++ b/tests/draggable.js @@ -225,11 +225,6 @@ test("{ cancel: ? }, unexpected", function() { el = $("#draggable2").draggable({ cancel: val }); drag(el, 50, 50); var expected = [50, 50]; - switch(key) { - case "true": - expected = [0, 0] - break; - } moved(expected[0], expected[1], "cancel: " + key); el.draggable("destroy"); }) diff --git a/ui/ui.core.js b/ui/ui.core.js index d7a28c967..b20e492e4 100644 --- a/ui/ui.core.js +++ b/ui/ui.core.js @@ -198,7 +198,7 @@ $.ui.mouse = { var self = this, btnIsLeft = (e.which == 1), - elIsCancel = ($(e.target).is(this.options.cancel)); + elIsCancel = (typeof this.options.cancel == "string" ? $(e.target).is(this.options.cancel) : false); if (!btnIsLeft || elIsCancel) { return true; } diff --git a/ui/ui.sortable.js b/ui/ui.sortable.js index 84eb0df93..9718dd1bc 100644 --- a/ui/ui.sortable.js +++ b/ui/ui.sortable.js @@ -65,9 +65,7 @@ $.widget("ui.sortable", $.extend($.ui.mouse, { if(!noPropagation) this.element.triggerHandler(n == "sort" ? n : "sort"+n, [e, this.ui(inst)], this.options[n]); }, serialize: function(o) { - - - + var items = ($.isFunction(this.options.items) ? this.options.items.call(this.element) : $(this.options.items, this.element)).not('.ui-sortable-helper'); //Only the items of the sortable itself var str = []; o = o || {}; @@ -80,11 +78,13 @@ $.widget("ui.sortable", $.extend($.ui.mouse, { }, toArray: function(attr) { + var items = ($.isFunction(this.options.items) ? this.options.items.call(this.element) : $(this.options.items, this.element)).not('.ui-sortable-helper'); //Only the items of the sortable itself var ret = []; items.each(function() { ret.push($(this).attr(attr || 'id')); }); return ret; + }, /* Be careful with the following core functions */ intersectsWith: function(item) { -- 2.39.5