Software: Apache. PHP/5.6.40-67+ubuntu20.04.1+deb.sury.org+1 uname -a: Linux hosting1.erectacloud.it 5.4.0-182-generic #202-Ubuntu SMP Fri Apr 26 12:29:36 UTC uid=5229(web473) gid=5117(client172) groups=5117(client172),5002(sshusers) Safe-mode: OFF (not secure) /var/www/clients/client172/web473/web/aps/xcrud/plugins/select2-develop/src/js/select2/selection/ drwxr-xr-x |
Viewing file: allowClear.js (3 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) | define([ 'jquery', '../keys', '../utils' ], function ($, KEYS, Utils) { function AllowClear () { } AllowClear.prototype.bind = function (decorated, container, $container) { var self = this; decorated.call(this, container, $container); if (this.placeholder == null) { if (this.options.get('debug') && window.console && console.error) { console.error( 'Select2: The `allowClear` option should be used in combination ' + 'with the `placeholder` option.' ); } } this.$selection.on('mousedown', '.select2-selection__clear', function (evt) { self._handleClear(evt); }); container.on('keypress', function (evt) { self._handleKeyboardClear(evt, container); }); }; AllowClear.prototype._handleClear = function (_, evt) { // Ignore the event if it is disabled if (this.isDisabled()) { return; } var $clear = this.$selection.find('.select2-selection__clear'); // Ignore the event if nothing has been selected if ($clear.length === 0) { return; } evt.stopPropagation(); var data = Utils.GetData($clear[0], 'data'); var previousVal = this.$element.val(); this.$element.val(this.placeholder.id); var unselectData = { data: data }; this.trigger('clear', unselectData); if (unselectData.prevented) { this.$element.val(previousVal); return; } for (var d = 0; d < data.length; d++) { unselectData = { data: data[d] }; // Trigger the `unselect` event, so people can prevent it from being // cleared. this.trigger('unselect', unselectData); // If the event was prevented, don't clear it out. if (unselectData.prevented) { this.$element.val(previousVal); return; } } this.$element.trigger('input').trigger('change'); this.trigger('toggle', {}); }; AllowClear.prototype._handleKeyboardClear = function (_, evt, container) { if (container.isOpen()) { return; } if (evt.which == KEYS.DELETE || evt.which == KEYS.BACKSPACE) { this._handleClear(evt); } }; AllowClear.prototype.update = function (decorated, data) { decorated.call(this, data); this.$selection.find('.select2-selection__clear').remove(); if (this.$selection.find('.select2-selection__placeholder').length > 0 || data.length === 0) { return; } var selectionId = this.$selection.find('.select2-selection__rendered') .attr('id'); var removeAll = this.options.get('translations').get('removeAllItems'); var $remove = $( '<button type="button" class="select2-selection__clear" tabindex="-1">' + '<span aria-hidden="true">×</span>' + '</button>' ); $remove.attr('title', removeAll()); $remove.attr('aria-label', removeAll()); $remove.attr('aria-describedby', selectionId); Utils.StoreData($remove[0], 'data', data); this.$selection.prepend($remove); }; return AllowClear; }); |
:: Command execute :: | |
--[ c99shell v.2.1 [PHP 7 Update] [1.12.2019] maintained by KaizenLouie and updated by cermmik | C99Shell Github (MySQL update) | Generation time: 0.0153 ]-- |