Declare local variables
authorThierry Florac <thierry.florac@onf.fr>
Fri, 29 Jun 2018 18:13:34 +0200
changeset 360 d82289cc9a9b
parent 359 ee9714b446b0
child 361 7f7972056161
Declare local variables
src/pyams_skin/resources/js/ext/jquery-select2-sortable.js
src/pyams_skin/resources/js/ext/jquery-select2-sortable.min.js
--- a/src/pyams_skin/resources/js/ext/jquery-select2-sortable.js	Thu Jun 28 08:37:52 2018 +0200
+++ b/src/pyams_skin/resources/js/ext/jquery-select2-sortable.js	Fri Jun 29 18:13:34 2018 +0200
@@ -81,7 +81,7 @@
 
 		select2Sortable: function () {
 			var args = Array.prototype.slice.call(arguments, 0);
-			$this = this.filter('[multiple]'),
+			var $this = this.filter('[multiple]'),
 				validMethods = ['destroy'];
 
 			if (args.length === 0 || typeof (args[0]) === 'object') {
--- a/src/pyams_skin/resources/js/ext/jquery-select2-sortable.min.js	Thu Jun 28 08:37:52 2018 +0200
+++ b/src/pyams_skin/resources/js/ext/jquery-select2-sortable.min.js	Fri Jun 29 18:13:34 2018 +0200
@@ -1,1 +1,1 @@
-(function(a){a.fn.extend({select2SortableOrder:function(){var b=this.filter("[multiple]");b.each(function(){var g=a(this);if(typeof(g.data("select2"))!=="object"){return false}var f=g.siblings(".select2-container");var e;if(g.attr("type")==="hidden"){var h=f.data("select2");var i=h.opts.separator;var d=[];a.each(h.data(),function(){d.push(this.id)});g.val(d.join(i))}else{var c=[];g.find("optgroup").each(function(j,k){c.push(k)});g.find("option").each(function(k,l){var m=a(this).parent("optgroup").prop("label");var j=this;if(m===undefined){if(this.value!==""&&!this.selected){c.push(j)}}});e=a(f.find('.select2-choices li[class!="select2-search-field"]').map(function(){if(!this){return undefined}var j=a(this).data("select2Data").id;return g.find('option[value="'+j+'"]')[0]}));e.push.apply(e,c);g.children().remove();g.append(e)}});return b},select2Sortable:function(){var d=Array.prototype.slice.call(arguments,0);$this=this.filter("[multiple]"),validMethods=["destroy"];if(d.length===0||typeof(d[0])==="object"){var b={bindOrder:"formSubmit",sortableOptions:{placeholder:"ui-state-highlight",items:"li:not(.select2-search-field)",tolerance:"pointer"}};var c=a.extend(b,d[0]);if(typeof($this.data("select2"))!=="object"){$this.select2()}$this.each(function(){var e=a(this);var f=e.siblings(".select2-container").find(".select2-choices");f.sortable(c.sortableOptions);switch(c.bindOrder){case"sortableStop":f.on("sortstop.select2sortable",function(g,h){e.select2SortableOrder()});e.on("change",function(g){a(this).select2SortableOrder()});break;default:e.closest("form").unbind("submit.select2sortable").on("submit.select2sortable",function(){e.select2SortableOrder()});break}})}else{if(typeof(d[0]==="string")){if(a.inArray(d[0],validMethods)==-1){throw"Unknown method: "+d[0]}if(d[0]==="destroy"){$this.select2SortableDestroy()}}}return $this},select2SortableDestroy:function(){var b=this.filter("[multiple]");b.each(function(){var c=a(this);var d=c.parent().find(".select2-choices");c.closest("form").unbind("submit.select2sortable");d.unbind("sortstop.select2sortable");d.sortable("destroy")});return b}})}(jQuery));
\ No newline at end of file
+!function(e){e.fn.extend({select2SortableOrder:function(){var t=this.filter("[multiple]");return t.each(function(){var t=e(this);if("object"!=typeof t.data("select2"))return!1;var s,r=t.siblings(".select2-container");if("hidden"===t.attr("type")){var i=r.data("select2"),o=i.opts.separator,l=[];e.each(i.data(),function(){l.push(this.id)}),t.val(l.join(o))}else{var n=[];t.find("optgroup").each(function(e,t){n.push(t)}),t.find("option").each(function(t,s){var r=this;void 0===e(this).parent("optgroup").prop("label")&&(""===this.value||this.selected||n.push(r))}),(s=e(r.find('.select2-choices li[class!="select2-search-field"]').map(function(){if(this){var s=e(this).data("select2Data").id;return t.find('option[value="'+s+'"]')[0]}}))).push.apply(s,n),t.children().remove(),t.append(s)}}),t},select2Sortable:function(){var t=Array.prototype.slice.call(arguments,0),s=this.filter("[multiple]");if(0===t.length||"object"==typeof t[0]){var r=e.extend({bindOrder:"formSubmit",sortableOptions:{placeholder:"ui-state-highlight",items:"li:not(.select2-search-field)",tolerance:"pointer"}},t[0]);"object"!=typeof s.data("select2")&&s.select2(),s.each(function(){var t=e(this),s=t.siblings(".select2-container").find(".select2-choices");switch(s.sortable(r.sortableOptions),r.bindOrder){case"sortableStop":s.on("sortstop.select2sortable",function(e,s){t.select2SortableOrder()}),t.on("change",function(t){e(this).select2SortableOrder()});break;default:t.closest("form").unbind("submit.select2sortable").on("submit.select2sortable",function(){t.select2SortableOrder()})}})}else if(t[0],!0){if(-1==e.inArray(t[0],["destroy"]))throw"Unknown method: "+t[0];"destroy"===t[0]&&s.select2SortableDestroy()}return s},select2SortableDestroy:function(){var t=this.filter("[multiple]");return t.each(function(){var t=e(this),s=t.parent().find(".select2-choices");t.closest("form").unbind("submit.select2sortable"),s.unbind("sortstop.select2sortable"),s.sortable("destroy")}),t}})}(jQuery);