Fixed memory leak with icon picker + optimizations

This commit is contained in:
Djamil Legato
2018-01-09 14:37:25 -08:00
parent 6dd262c22d
commit e54547cb81

View File

@@ -229,6 +229,18 @@ class QL_Icon_Picker {
.addClass(preview); .addClass(preview);
$preview.find('a').show(); $preview.find('a').show();
} }
}
/* Grav */
// extend $ with 3rd party QL Icon Picker
$.fn.qlIconPicker = function(options) {
this.each(function() {
if (!$.data(this, 'plugin_qlIconPicker')) {
$.data(this, 'plugin_qlIconPicker', new QL_Icon_Picker(this, options));
}
});
return this;
}; };
export default class IconpickerField { export default class IconpickerField {
@@ -256,17 +268,7 @@ export default class IconpickerField {
addItem(element) { addItem(element) {
element = $(element); element = $(element);
this.items = this.items.add(element); this.items = this.items.add(element);
element.find('.icon-picker').qlIconPicker({
$.fn.qlIconPicker = function(options) {
this.each(function() {
if (!$.data(this, 'plugin_qlIconPicker')) {
$.data(this, 'plugin_qlIconPicker', new QL_Icon_Picker(this, options));
}
});
return this;
};
$('.icon-picker').qlIconPicker({
'save': 'class' 'save': 'class'
}); });
} }