Skip to content

Commit

Permalink
Fix: remove 'singleClose' from 'remove_plugin' assumed now by 'clear_…
Browse files Browse the repository at this point in the history
…button'
  • Loading branch information
fabienwnklr committed Oct 6, 2022
1 parent 6952310 commit a63c449
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 60 deletions.
54 changes: 1 addition & 53 deletions src/plugins/remove_button/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,53 +23,6 @@ Selectize.define('remove_button', function(options) {
append : true
}, options);

var singleClose = function(thisRef, options) {

options.className = 'remove-single';

var self = thisRef;
var html = '<a href="javascript:void(0)" class="' + options.className + '" tabindex="-1" title="' + escape_html(options.title) + '">' + options.label + '</a>';

/**
* Appends an element as a child (with raw HTML).
*
* @param {string} html_container
* @param {string} html_element
* @return {string}
*/
var append = function(html_container, html_element) {
return $('<span>').append(html_container)
.append(html_element);
};

thisRef.setup = (function() {
var original = self.setup;
return function() {
// override the item rendering method to add the button to each
if (options.append) {
var id = $(self.$input.context).attr('id');
var selectizer = $('#'+id);

var render_item = self.settings.render.item;
self.settings.render.item = function(data) {
return append(render_item.apply(thisRef, arguments), html);
};
}

original.apply(thisRef, arguments);

// add event listener
thisRef.$control.on('click', '.' + options.className, function(e) {
e.preventDefault();
if (self.isLocked) return;

self.clear();
});

};
})();
};

var multiClose = function(thisRef, options) {

var self = thisRef;
Expand Down Expand Up @@ -117,10 +70,5 @@ Selectize.define('remove_button', function(options) {
})();
};

if (this.settings.mode === 'single') {
singleClose(this, options);
return;
} else {
multiClose(this, options);
}
multiClose(this, options);
});
7 changes: 0 additions & 7 deletions src/plugins/remove_button/plugin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,4 @@
$select-lighten-disabled-item-border
);
}

.remove-single {
position: absolute;
right: 0;
top: 0;
font-size: 23px;
}
}

0 comments on commit a63c449

Please sign in to comment.