PluginProbe
Cooked – Recipe Management / 1.9.1
Cooked – Recipe Management v1.9.1
1.16.1 1.16.0 1.15.0 trunk 1.10.0 1.11.0 1.11.1 1.11.2 1.11.3 1.11.4 1.12.0 1.13.0 1.14.0 1.7.10 1.7.11 1.7.12 1.7.13 1.7.15.1 1.7.15.3 1.7.15.4 1.8.0 1.8.1 1.8.2 1.8.3 1.8.4 All 37 releases
cooked / assets / admin / js / selectize / selectize.dragdrop.js

selectize.dragdrop.js in Cooked – Recipe Management 1.9.1, at assets/admin/js/selectize/selectize.dragdrop.js

74 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Plugin: "drag_drop" (selectize.js)
3 * Copyright (c) 2013 Brian Reavis & contributors
4 * Copyright (c) 2020-2022 Selectize Team & contributors*
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
7 * file except in compliance with the License. You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software distributed under
11 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
12 * ANY KIND, either express or implied. See the License for the specific language
13 * governing permissions and limitations under the License.
14 *
15 * @author Brian Reavis <brian@thirdroute.com>
16 */
17
18 Selectize.define('drag_drop', function(options) {
19 if (!$.fn.sortable) throw new Error('The "drag_drop" plugin requires jQuery UI "sortable".');
20 if (this.settings.mode !== 'multi') return;
21 var self = this;
22
23 self.lock = (function() {
24 var original = self.lock;
25 return function() {
26 var sortable = self.$control.data('sortable');
27 if (sortable) sortable.disable();
28 return original.apply(self, arguments);
29 };
30 })();
31
32 self.unlock = (function() {
33 var original = self.unlock;
34 return function() {
35 var sortable = self.$control.data('sortable');
36 if (sortable) sortable.enable();
37 return original.apply(self, arguments);
38 };
39 })();
40
41 self.setup = (function() {
42 var original = self.setup;
43 return function() {
44 original.apply(this, arguments);
45
46 var $control = self.$control.sortable({
47 items: '[data-value]',
48 forcePlaceholderSize: true,
49 disabled: self.isLocked,
50 start: function(e, ui) {
51 ui.placeholder.css('width', ui.helper.css('width'));
52 // $control.css({overflow: 'visible'});
53 $control.addClass('dragging');
54 },
55 stop: function() {
56 // $control.css({overflow: 'hidden'});
57 $control.removeClass('dragging');
58 var active = self.$activeItems ? self.$activeItems.slice() : null;
59 var values = [];
60 $control.children('[data-value]').each(function() {
61 values.push($(this).attr('data-value'));
62 });
63 self.isFocused = false;
64 self.setValue(values);
65 self.isFocused = true;
66 self.setActiveItem(active);
67 self.positionDropdown();
68 }
69 });
70 };
71 })();
72
73 });
74