fontawesome-iconpicker
Advanced tools
Comparing version 2.0.1 to 3.0.0
@@ -28,9 +28,21 @@ 'use strict'; | ||
if (style.startsWith('brand')) { | ||
targetJSON.icons.push('fab ' + icon); | ||
targetJSON.icons.push({ | ||
title: 'fab ' + icon, | ||
searchTerms: ele.search.terms | ||
}); | ||
} else if (style.startsWith('solid')) { | ||
targetJSON.icons.push('fas ' + icon); | ||
targetJSON.icons.push({ | ||
title: 'fas ' + icon, | ||
searchTerms: ele.search.terms | ||
}); | ||
} else if (style.startsWith('regular')) { | ||
targetJSON.icons.push('far ' + icon); | ||
targetJSON.icons.push({ | ||
title: 'far ' + icon, | ||
searchTerms: ele.search.terms | ||
}); | ||
} else if (style.startsWith('light')) { | ||
targetJSON.icons.push('fal ' + icon); | ||
targetJSON.icons.push({ | ||
title: 'fal ' + icon, | ||
searchTerms: ele.search.terms | ||
}); | ||
} | ||
@@ -93,6 +105,8 @@ }); | ||
compress: {}, | ||
beautify: false | ||
beautify: false, | ||
preserveComments: 'some' | ||
}, | ||
files: { | ||
'dist/js/fontawesome-iconpicker.min.js': [ | ||
'src/js/license.js', | ||
'src/js/jquery.ui.pos.js', | ||
@@ -106,6 +120,8 @@ parsedIconPicker | ||
compress: false, | ||
beautify: true | ||
beautify: true, | ||
preserveComments: 'some' | ||
}, | ||
files: { | ||
'dist/js/fontawesome-iconpicker.js': [ | ||
'src/js/license.js', | ||
'src/js/jquery.ui.pos.js', | ||
@@ -112,0 +128,0 @@ parsedIconPicker |
{ | ||
"name": "fontawesome-iconpicker", | ||
"version": "2.0.1", | ||
"version": "3.0.0", | ||
"description": "Font Awesome Icon Picker plugin for Twitter Bootstrap", | ||
@@ -5,0 +5,0 @@ "homepage": "https://farbelous.github.io/fontawesome-iconpicker/", |
@@ -92,3 +92,3 @@ fontawesome-iconpicker | ||
```javascript | ||
var defaults = { | ||
var options = { | ||
title: false, // Popover title (optional) only if specified in the template | ||
@@ -106,3 +106,3 @@ selected: false, // use this value as the current item and ignore the original | ||
selectedCustomClass: 'bg-primary', // Appends this class when to the selected item | ||
icons: [], // list of icon classes (declared at the bottom of this script for maintainability) | ||
icons: [], // list of icon objects [{title:String, searchTerms:String}]. By default, all Font Awesome icons are included. | ||
fullClassFormatter: function(val) { | ||
@@ -109,0 +109,0 @@ return 'fa ' + val; |
@@ -1,2 +0,2 @@ | ||
/*! | ||
/* | ||
* Font Awesome Icon Picker | ||
@@ -49,3 +49,5 @@ * https://farbelous.github.io/fontawesome-iconpicker/ | ||
this.element = $(element).addClass('iconpicker-element'); | ||
this._trigger('iconpickerCreate'); | ||
this._trigger('iconpickerCreate', { | ||
iconpickerValue: this.iconpickerValue | ||
}); | ||
this.options = $.extend({}, Iconpicker.defaultOptions, this.element.data(), options); | ||
@@ -66,6 +68,2 @@ this.options.templates = $.extend({}, Iconpicker.defaultOptions.templates, this.options.templates); | ||
if (this.isDropdownMenu()) { | ||
// if you try to click the dropdown, it is closed, because of that | ||
// we'll hide some picker controls | ||
this.options.templates.search = false; | ||
this.options.templates.buttons = false; | ||
this.options.placement = 'inline'; | ||
@@ -118,3 +116,5 @@ } | ||
this._trigger('iconpickerCreated'); | ||
this._trigger('iconpickerCreated', { | ||
iconpickerValue: this.iconpickerValue | ||
}); | ||
}; | ||
@@ -243,15 +243,23 @@ | ||
} | ||
e.preventDefault(); | ||
return false; | ||
}; | ||
for (var i in this.options.icons) { | ||
if (typeof this.options.icons[i] === 'string') { | ||
if (typeof this.options.icons[i].title === 'string') { | ||
var itemElement = $(this.options.templates.iconpickerItem); | ||
itemElement.find('i') | ||
.addClass(this.options.fullClassFormatter(this.options.icons[i])); | ||
itemElement.data('iconpickerValue', this.options.icons[i]) | ||
.addClass(this.options.fullClassFormatter(this.options.icons[i].title)); | ||
itemElement.data('iconpickerValue', this.options.icons[i].title) | ||
.on('click.iconpicker', itemClickFn); | ||
this.iconpicker.find('.iconpicker-items').append(itemElement | ||
.attr('title', '.' + this.options.icons[i])); | ||
.attr('title', '.' + this.options.icons[i].title)); | ||
if (this.options.icons[i].searchTerms.length > 0) { | ||
var searchTerms = ''; | ||
for (var j = 0; j < this.options.icons[i].searchTerms.length; j++) { | ||
searchTerms = searchTerms + this.options.icons[i].searchTerms[j] + ' '; | ||
} | ||
this.iconpicker.find('.iconpicker-items').append(itemElement | ||
.attr('data-search-terms', searchTerms)); | ||
} | ||
} | ||
@@ -266,3 +274,3 @@ } | ||
var _t = $(e.target); | ||
if ((!_t.hasClass('iconpicker-element') || | ||
if ((!_t.hasClass('iconpicker-element') || | ||
(_t.hasClass('iconpicker-element') && !_t.is(this.element))) && | ||
@@ -347,9 +355,4 @@ (_t.parents('.iconpicker-popover').length === 0)) { | ||
} | ||
e.stopPropagation(); | ||
e.preventDefault(); | ||
return false; | ||
}); | ||
} | ||
return false; | ||
}, | ||
@@ -598,4 +601,11 @@ _unbindElementEvents: function() { | ||
val = $.trim(val); | ||
var e = false; | ||
for (var i = 0; i < this.options.icons.length; i++) { | ||
if (this.options.icons[i].title === val) { | ||
e = true; | ||
break; | ||
}; | ||
} | ||
if (_helpers.inArray(val, this.options.icons) || isEmpty) { | ||
if (e || isEmpty) { | ||
return val; | ||
@@ -706,5 +716,7 @@ } | ||
var text = $this.attr('title').toLowerCase(); | ||
var searchTerms = $this.attr('data-search-terms') ? $this.attr('data-search-terms').toLowerCase() : ''; | ||
text = text + ' ' + searchTerms; | ||
var regex = false; | ||
try { | ||
regex = new RegExp(filterText, 'g'); | ||
regex = new RegExp('(^|\\W)' + filterText, 'g'); | ||
} catch (e) { | ||
@@ -730,3 +742,5 @@ regex = false; | ||
this._trigger('iconpickerShow'); | ||
this._trigger('iconpickerShow', { | ||
iconpickerValue: this.iconpickerValue | ||
}); | ||
this.updatePlacement(); | ||
@@ -736,3 +750,5 @@ this.popover.addClass('in'); | ||
this.popover.css('display', this.isInline() ? '' : 'block'); | ||
this._trigger('iconpickerShown'); | ||
this._trigger('iconpickerShown', { | ||
iconpickerValue: this.iconpickerValue | ||
}); | ||
}, this), this.options.animation ? 300 : 1); // animation duration | ||
@@ -744,3 +760,5 @@ }, | ||
} | ||
this._trigger('iconpickerHide'); | ||
this._trigger('iconpickerHide', { | ||
iconpickerValue: this.iconpickerValue | ||
}); | ||
this.popover.removeClass('in'); | ||
@@ -751,3 +769,5 @@ setTimeout($.proxy(function() { | ||
this.filter(''); // clear filter | ||
this._trigger('iconpickerHidden'); | ||
this._trigger('iconpickerHidden', { | ||
iconpickerValue: this.iconpickerValue | ||
}); | ||
}, this), this.options.animation ? 300 : 1); | ||
@@ -763,6 +783,8 @@ }, | ||
update: function(val, updateOnlyInternal) { | ||
val = (val ? val : this.getSourceValue(this.iconpickerValue)); | ||
val = (val ? val : this.getSourceValue(this.iconpickerValue)); | ||
// reads the input or element value again and tries to update the plugin | ||
// fallback to the current selected item value | ||
this._trigger('iconpickerUpdate'); | ||
this._trigger('iconpickerUpdate', { | ||
iconpickerValue: this.iconpickerValue | ||
}); | ||
@@ -780,7 +802,11 @@ if (updateOnlyInternal === true) { | ||
this._trigger('iconpickerUpdated'); | ||
this._trigger('iconpickerUpdated', { | ||
iconpickerValue: this.iconpickerValue | ||
}); | ||
return val; | ||
}, | ||
destroy: function() { | ||
this._trigger('iconpickerDestroy'); | ||
this._trigger('iconpickerDestroy', { | ||
iconpickerValue: this.iconpickerValue | ||
}); | ||
@@ -796,3 +822,5 @@ // unbinds events and resets everything to the initial state, | ||
this._trigger('iconpickerDestroyed'); | ||
this._trigger('iconpickerDestroyed', { | ||
iconpickerValue: this.iconpickerValue | ||
}); | ||
}, | ||
@@ -838,3 +866,6 @@ disable: function() { | ||
// List of all Font Awesome icons without class prefix | ||
Iconpicker.defaultOptions = $.extend(Iconpicker.defaultOptions, //###REPLACE-WITH-FONT-AWESOME-5-FONTS###); | ||
})); | ||
Iconpicker.defaultOptions = $.extend( | ||
Iconpicker.defaultOptions, | ||
//###REPLACE-WITH-FONT-AWESOME-5-FONTS### | ||
); | ||
})); |
@@ -1,6 +0,1 @@ | ||
/*! jQuery UI - v1.12.1 - 2017-08-12 | ||
* http://jqueryui.com | ||
* Includes: position.js | ||
* Copyright jQuery Foundation and other contributors; Licensed MIT */ | ||
(function(factory) { | ||
@@ -7,0 +2,0 @@ if (typeof define === "function" && define.amd) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5701
350588
22
1
80