jquery.liveFilter.js
4 years ago
jquery.liveFilter.min.js
4 years ago
jquery.widgetopts.beaver.js
4 years ago
jquery.widgetopts.beaver.min.js
4 years ago
select2-settings.js
4 years ago
select2-settings.min.js
4 years ago
select2.min.js
4 years ago
settings.js
4 years ago
settings.min.js
4 years ago
widgets.js
4 years ago
widgets.min.js
4 years ago
wpWidgetOpts.js
4 years ago
wpWidgetOpts.min.js
4 years ago
select2-settings.js
62 lines
| 1 | (function($){ |
| 2 | |
| 3 | WidgetOptsSelect2 = { |
| 4 | _init: function() |
| 5 | { |
| 6 | $('select.widgetopts-select2').each(function() { |
| 7 | $(this).select2({ |
| 8 | width: '100%', |
| 9 | allowClear: true, |
| 10 | placeholder: ' ' |
| 11 | }).on('change', $.proxy(WidgetOptsSelect2._maybePreview, this.context)) |
| 12 | .on('select2:unselecting', function(e) { |
| 13 | $(this).data('unselecting', true); |
| 14 | }).on('select2:open', function(e) { // note the open event is important |
| 15 | if ($(this).data('unselecting')) { |
| 16 | $(this).removeData('unselecting'); // you need to unset this before close |
| 17 | $(this).select2('close'); |
| 18 | } |
| 19 | }).on('select2:unselect', function(e) { // note the open event is important |
| 20 | if( !$(this).val() ){ |
| 21 | $(this).val("").trigger('change'); |
| 22 | } |
| 23 | }); |
| 24 | |
| 25 | if($(this).attr('multiple')) { |
| 26 | var ul = $(this).siblings('.select2-container').first('ul.select2-selection__rendered'); |
| 27 | ul.sortable({ |
| 28 | placeholder : 'ui-state-highlight', |
| 29 | forcePlaceholderSize: true, |
| 30 | items : 'li:not(.select2-search__field)', |
| 31 | tolerance : 'pointer', |
| 32 | stop: function() { |
| 33 | $($(ul).find('.select2-selection__choice').get().reverse()).each(function() { |
| 34 | var id = $(this).data('data').id; |
| 35 | var option = $(this).find('option[value="' + id + '"]')[0]; |
| 36 | $(this).prepend(option); |
| 37 | }); |
| 38 | } |
| 39 | }); |
| 40 | } |
| 41 | }); |
| 42 | }, |
| 43 | |
| 44 | _maybePreview: function() { |
| 45 | var e = { |
| 46 | target: this |
| 47 | }; |
| 48 | |
| 49 | var field = $(this).closest('.fl-field'); |
| 50 | var previewType = field.data('preview'); |
| 51 | |
| 52 | if ('refresh' == previewType.type) { |
| 53 | FLBuilder.preview.delayPreview(e); |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | FLBuilder.addHook('settings-form-init', function() { |
| 59 | WidgetOptsSelect2._init(); |
| 60 | }); |
| 61 | |
| 62 | })(jQuery); |