Browse code

Add tom select npm package

Benjamin Roth authored on02/02/2023 12:00:30
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,70 @@
1
+/**
2
+* Tom Select v2.2.2
3
+* Licensed under the Apache License, Version 2.0 (the "License");
4
+*/
5
+
6
+(function (global, factory) {
7
+	typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
8
+	typeof define === 'function' && define.amd ? define(factory) :
9
+	(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.drag_drop = factory());
10
+})(this, (function () { 'use strict';
11
+
12
+	/**
13
+	 * Plugin: "drag_drop" (Tom Select)
14
+	 * Copyright (c) contributors
15
+	 *
16
+	 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
17
+	 * file except in compliance with the License. You may obtain a copy of the License at:
18
+	 * http://www.apache.org/licenses/LICENSE-2.0
19
+	 *
20
+	 * Unless required by applicable law or agreed to in writing, software distributed under
21
+	 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
22
+	 * ANY KIND, either express or implied. See the License for the specific language
23
+	 * governing permissions and limitations under the License.
24
+	 *
25
+	 */
26
+	function plugin () {
27
+	  var self = this;
28
+	  if (!$.fn.sortable) throw new Error('The "drag_drop" plugin requires jQuery UI "sortable".');
29
+	  if (self.settings.mode !== 'multi') return;
30
+	  var orig_lock = self.lock;
31
+	  var orig_unlock = self.unlock;
32
+	  self.hook('instead', 'lock', () => {
33
+	    var sortable = $(self.control).data('sortable');
34
+	    if (sortable) sortable.disable();
35
+	    return orig_lock.call(self);
36
+	  });
37
+	  self.hook('instead', 'unlock', () => {
38
+	    var sortable = $(self.control).data('sortable');
39
+	    if (sortable) sortable.enable();
40
+	    return orig_unlock.call(self);
41
+	  });
42
+	  self.on('initialize', () => {
43
+	    var $control = $(self.control).sortable({
44
+	      items: '[data-value]',
45
+	      forcePlaceholderSize: true,
46
+	      disabled: self.isLocked,
47
+	      start: (e, ui) => {
48
+	        ui.placeholder.css('width', ui.helper.css('width'));
49
+	        $control.css({
50
+	          overflow: 'visible'
51
+	        });
52
+	      },
53
+	      stop: () => {
54
+	        $control.css({
55
+	          overflow: 'hidden'
56
+	        });
57
+	        var values = [];
58
+	        $control.children('[data-value]').each(function () {
59
+	          if (this.dataset.value) values.push(this.dataset.value);
60
+	        });
61
+	        self.setValue(values);
62
+	      }
63
+	    });
64
+	  });
65
+	}
66
+
67
+	return plugin;
68
+
69
+}));
70
+//# sourceMappingURL=drag_drop.js.map