diff options
Diffstat (limited to 'chimere/static/bsmSelect/js')
3 files changed, 40 insertions, 31 deletions
diff --git a/chimere/static/bsmSelect/js/jquery.bsmselect.compatibility.js b/chimere/static/bsmSelect/js/jquery.bsmselect.compatibility.js index a743a07..683d865 100644 --- a/chimere/static/bsmSelect/js/jquery.bsmselect.compatibility.js +++ b/chimere/static/bsmSelect/js/jquery.bsmselect.compatibility.js @@ -1,17 +1,17 @@ /* * Better Select Multiple Compatibility Plugin - jQuery Plugin * - * Copyright (c) 2010 by Victor Berchet - http://www.github.com/vicb + * Copyright (c) 2010-2011 by Victor Berchet - http://www.github.com/vicb * * Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses. * - * version: v1.0.0 - 2010-09-05 + * version: v1.0.1 - 2011-11-14 */ (function($) { $.bsmSelect.plugins.compatibility = function() { - if (!(this instanceof arguments.callee)) { - return new arguments.callee(); + if (!(this instanceof $.bsmSelect.plugins.compatibility)) { + return new $.bsmSelect.plugins.compatibility(); } } @@ -31,7 +31,7 @@ o.showEffect = $.bsmSelect.effects[o.animate.add]; } else { o.showEffect = $.bsmSelect.effects.show; - } + } if ($.isFunction(o.animate.drop)) { o.hideEffect = o.animate.drop; diff --git a/chimere/static/bsmSelect/js/jquery.bsmselect.js b/chimere/static/bsmSelect/js/jquery.bsmselect.js index 25527c6..7751418 100644 --- a/chimere/static/bsmSelect/js/jquery.bsmselect.js +++ b/chimere/static/bsmSelect/js/jquery.bsmselect.js @@ -4,11 +4,11 @@ * based on Alternate Select Multiple (asmSelect) 1.0.4a beta (http://www.ryancramer.com/projects/asmselect/) * * Copyright (c) 2009 by Ryan Cramer - http://www.ryancramer.com - * Copyright (c) 2010 by Victor Berchet - http://www.github.com/vicb + * Copyright (c) 2010-2013 by Victor Berchet - http://www.github.com/vicb * * Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses. * - * bsmSelect version: v1.4.3 - 2011-05-05 + * bsmSelect version: v1.4.7 - 2013-12-19 */ (function($) { @@ -39,7 +39,7 @@ if (o.addItemTarget === 'original') { $('option', this.$original).each(function(i, o) { - if ($(o).data('bsm-order') === null) { $(o).data('bsm-order', i); } + if ($(o).data('bsm-order') === undefined) { $(o).data('bsm-order', i); } }); } @@ -47,7 +47,6 @@ this.$select = $('<select>', { 'class': o.selectClass, - name: o.selectClass + this.uid, id: o.selectClass + this.uid, change: $.proxy(this.selectChangeEvent, this), click: $.proxy(this.selectClickEvent, this) @@ -69,7 +68,7 @@ if (!this.$list.parent().length) { this.$original.before(this.$list); } if (this.$original.attr('id')) { - $('label[for=' + this.$original.attr('id') + ']').attr('for', this.$select.attr('id')); + $("label[for='" + this.$original.attr('id') + "']").attr('for', this.$select.attr('id')); } // set up remove event (may be a link, or the list item itself) @@ -86,11 +85,12 @@ * Check to make sure it's not an IE screwup, and add it to the list */ selectChangeEvent: function() { - if ($.browser.msie && $.browser.version < 7 && !this.ieClick) { return; } + if ($.browser && $.browser.msie && $.browser.version < 7 && !this.ieClick) { return; } var bsmOpt = $('option:selected:eq(0)', this.$select); if (bsmOpt.data('orig-option')) { - this.addListItem(bsmOpt); - this.triggerOriginalChange(bsmOpt.data('orig-option'), 'add'); + if (this.triggerOriginalChange(bsmOpt.data('orig-option'), 'add') == false) { + this.addListItem(bsmOpt); + } } this.ieClick = false; }, @@ -115,7 +115,7 @@ this.buildSelect(); // opera has an issue where it needs a force redraw, otherwise // the items won't appear until something else forces a redraw - if ($.browser.opera) { this.$list.hide().show(); } + if ($.browser && $.browser.opera) { this.$list.hide().show(); } } }, @@ -198,7 +198,7 @@ .removeAttr('selected') .attr('disabled', 'disabled') .toggle(!this.options.hideWhenAdded); - if ($.browser.msie && $.browser.version < 8) { this.$select.hide().show(); } // this forces IE to update display + if ($.browser && $.browser.msie && $.browser.version < 8) { this.$select.hide().show(); } // this forces IE to update display }, /** @@ -210,7 +210,7 @@ $bsmOpt.removeClass(this.options.optionDisabledClass) .removeAttr('disabled') .toggle(!this.options.hideWhenAdded); - if ($.browser.msie && $.browser.version < 8) { this.$select.hide().show(); } // this forces IE to update display + if ($.browser && $.browser.msie && $.browser.version < 8) { this.$select.hide().show(); } // this forces IE to update display }, /** @@ -243,7 +243,7 @@ break; case 'original': var order = $origOpt.data('bsm-order'), inserted = false; - $('.' + o.listItemClass, this.$list).each(function() { + this.$list.children().each(function() { if (order < $(this).data('bsm-option').data('orig-option').data('bsm-order')) { $item.hide().insertBefore(this); inserted = true; @@ -268,15 +268,16 @@ /** * Remove an item from the list of selection * - * @param {jQuey} $item A list item + * @param {jQuery} $item A list item */ dropListItem: function($item) { var $bsmOpt = $item.data('bsm-option'), o = this.options; - $bsmOpt.removeData('item').data('orig-option').removeAttr('selected'); - (this.buildingSelect ? $.bsmSelect.effects.remove : o.hideEffect)($item); - this.enableSelectOption($bsmOpt); - o.highlightEffect(this.$select, $item, o.highlightRemovedLabel, o); - this.triggerOriginalChange($bsmOpt.data('orig-option'), 'drop'); + if (this.triggerOriginalChange($bsmOpt.data('orig-option'), 'drop') == false) { + $bsmOpt.removeData('item').data('orig-option').removeAttr('selected'); + (this.buildingSelect ? $.bsmSelect.effects.remove : o.hideEffect)($item); + this.enableSelectOption($bsmOpt); + o.highlightEffect(this.$select, $item, o.highlightRemovedLabel, o); + } }, /** @@ -285,15 +286,19 @@ * * @param {jQuery} $origOpt The option from the original select * @param {String} type Event type + * + * @return Whether the event default is prevented */ triggerOriginalChange: function($origOpt, type) { + var event = $.Event('change'); this.ignoreOriginalChangeEvent = true; - this.$original.trigger('change', [{ + this.$original.trigger(event, [{ option: $origOpt, value: $origOpt.val(), item: $origOpt.data('bsm-option').data('item'), type: type }]); + return event.isDefaultPrevented(); } }; diff --git a/chimere/static/bsmSelect/js/jquery.bsmselect.sortable.js b/chimere/static/bsmSelect/js/jquery.bsmselect.sortable.js index 3e4b9f8..cd79028 100644 --- a/chimere/static/bsmSelect/js/jquery.bsmselect.sortable.js +++ b/chimere/static/bsmSelect/js/jquery.bsmselect.sortable.js @@ -1,17 +1,17 @@ /* * Better Select Multiple Sortable Plugin * - * Copyright (c) 2010 by Victor Berchet - http://www.github.com/vicb + * Copyright (c) 2010-2012 by Victor Berchet - http://www.github.com/vicb * * Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses. * - * version: v1.1.1 - 2010-11-17 + * version: v1.4.4 - 2012-01-19 */ (function($) { $.bsmSelect.plugins.sortable = function(sortConfig, options) { - if (!(this instanceof arguments.callee)) { - return new arguments.callee(sortConfig, options); + if (!(this instanceof $.bsmSelect.plugins.sortable)) { + return new $.bsmSelect.plugins.sortable(sortConfig, options); } this.sortConfig = sortConfig; this.options = $.extend({}, this.defaultOpt, options || {}); @@ -27,13 +27,18 @@ config = $.extend({}, this.sortConfig, { items: '.' + o.listItemClass }), self = this; bsm.$list.addClass(o.listSortableClass).sortable(config); + // Fix a bug when the 'html' element has an overflow set to either 'scroll' or 'auto' on FF. + // See issue #21 (https://github.com/vicb/bsmSelect/issues/21) + if ($.inArray($('html').css('overflow-x'), ['auto', 'scroll']) > -1 || $.inArray($('html').css('overflow-y'), ['auto', 'scroll']) > -1) { + $('.' + o.listSortableClass).addClass('bsmScrollWorkaround'); + } bsm.$original.bind('change', function(e, info) { self.onChange.call(self, bsm, e, info); } ); bsm.$list.bind('sortupdate', function(e, ui) { self.onSort.call(self, bsm, e, ui); } ); }, onChange: function(bsm, e, info) { - if (info && info.type == 'add' && !bsm.buildingSelect) { - info.option.detach()[bsm.options.addItemTarget == 'top' ? 'prependTo' : 'appendTo'](bsm.$original); + if (info && info.type === 'add' && !bsm.buildingSelect) { + info.option.detach()[bsm.options.addItemTarget === 'top' ? 'prependTo' : 'appendTo'](bsm.$original); bsm.$list.sortable('refresh'); } }, @@ -46,4 +51,3 @@ } }); })(jQuery); - |
