2013-05-02 20:12:33 -04:00
|
|
|
$(function() {
|
2015-01-21 12:09:39 -06:00
|
|
|
var ads = [
|
2015-01-22 11:36:55 -06:00
|
|
|
{ quote: "Take your icon game to the next level.", content: "ad_1_next_level"},
|
|
|
|
{ quote: "Subset your icons, add your own, and serve up from a CDN.", content: "ad_2_all_value_add"},
|
|
|
|
{ quote: "Make your icons load 10x faster!", content: "ad_3_faster_loading"},
|
|
|
|
{ quote: "Looking for other great icon sets?", content: "ad_4_more_icons"},
|
|
|
|
{ quote: "Need a custom icon in Font Awesome?", content: "ad_5_custom_icons"}
|
2015-01-21 12:09:39 -06:00
|
|
|
];
|
|
|
|
|
|
|
|
selectFonticonsAd();
|
2015-01-21 11:51:10 -05:00
|
|
|
|
2013-05-02 20:12:33 -04:00
|
|
|
// start the icon carousel
|
2013-10-05 15:40:57 -04:00
|
|
|
$('#icon-carousel').carousel({
|
2013-05-02 20:12:33 -04:00
|
|
|
interval: 5000
|
|
|
|
});
|
2013-11-19 13:24:23 -06:00
|
|
|
|
2014-10-25 03:38:27 +02:00
|
|
|
var $filter_by = $('#filter-by');
|
|
|
|
|
2013-11-19 13:24:23 -06:00
|
|
|
// Filter icons
|
2014-10-25 03:38:27 +02:00
|
|
|
if($filter_by.length) {
|
2013-11-19 13:24:23 -06:00
|
|
|
var $filter_val = $('#filter-val');
|
|
|
|
var $filter = $('#filter');
|
2015-01-20 12:56:00 -05:00
|
|
|
var $other = $('#new, #web-application, #transportation, #gender, #form-control, #medical, #currency, #text-editor, #directional, #video-player, #brand, #file-type, #spinner, #payment, #chart');
|
2013-11-19 13:24:23 -06:00
|
|
|
var $clear = $('#filter-clear');
|
2014-10-21 01:28:17 +02:00
|
|
|
var $no_results = $('#no-search-results');
|
2013-11-19 13:24:23 -06:00
|
|
|
|
|
|
|
var $icons = $('.filter-icon', $filter);
|
|
|
|
|
2014-11-01 23:45:08 +01:00
|
|
|
// Add tab completion
|
|
|
|
$filter_by.tabcomplete(filterSet, {
|
|
|
|
arrowKeys: true
|
|
|
|
});
|
|
|
|
|
2014-12-09 19:17:31 +01:00
|
|
|
$clear.on('click', function(e) {
|
2013-11-19 13:24:23 -06:00
|
|
|
e.preventDefault();
|
2014-12-09 19:17:31 +01:00
|
|
|
$filter_by
|
|
|
|
.val('')
|
|
|
|
.trigger('input')
|
|
|
|
.trigger('keyup')
|
|
|
|
.focus();
|
|
|
|
|
2015-01-20 12:56:00 -05:00
|
|
|
$clear.addClass('hide'); // Hide clear button
|
2013-11-19 13:24:23 -06:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2014-12-09 19:17:31 +01:00
|
|
|
$filter_by.on('keyup', function() {
|
2013-11-19 13:24:23 -06:00
|
|
|
var $this = $(this);
|
2014-11-01 23:45:08 +01:00
|
|
|
var val = $this.val().toLowerCase();
|
2013-11-19 13:24:23 -06:00
|
|
|
$filter.toggle(!!val);
|
|
|
|
$other.toggle(!val);
|
2015-01-20 12:56:00 -05:00
|
|
|
$clear.toggleClass('hide', !val);
|
2013-11-19 13:24:23 -06:00
|
|
|
$filter_val.text(val);
|
|
|
|
|
|
|
|
if(!val) return;
|
|
|
|
|
2014-10-21 01:28:17 +02:00
|
|
|
var resultsCount = 0;
|
2013-11-19 13:24:23 -06:00
|
|
|
$icons.each(function() {
|
2014-10-21 01:53:52 +02:00
|
|
|
var filter = $(this).attr('data-filter').split('|');
|
|
|
|
var show = inFilter(val, filter);
|
2014-10-21 01:47:07 +02:00
|
|
|
if (!show) {
|
|
|
|
if (val.slice(-1) === 's') {
|
|
|
|
// Try to be smart. Make plural terms singular.
|
2014-10-21 01:53:52 +02:00
|
|
|
show = inFilter(val.slice(0, -1), filter);
|
2014-10-21 01:47:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (show) resultsCount++;
|
2013-11-19 13:24:23 -06:00
|
|
|
$(this).toggle(!!show);
|
|
|
|
});
|
2014-10-21 01:28:17 +02:00
|
|
|
|
|
|
|
if( resultsCount == 0 && val.length != 0 ) {
|
|
|
|
$no_results.find('span').text(val);
|
|
|
|
$no_results.show();
|
|
|
|
} else {
|
|
|
|
$no_results.hide();
|
|
|
|
}
|
2014-12-09 19:17:31 +01:00
|
|
|
});
|
2013-11-19 13:24:23 -06:00
|
|
|
}
|
|
|
|
|
2014-10-21 01:53:52 +02:00
|
|
|
function inFilter(val, filter) {
|
|
|
|
for (var i = 0; i < filter.length; i++) {
|
2014-10-21 01:59:35 +02:00
|
|
|
if (filter[i].match(val)) return true;
|
2014-10-21 01:53:52 +02:00
|
|
|
}
|
2014-10-21 01:59:35 +02:00
|
|
|
return false;
|
2014-10-21 01:53:52 +02:00
|
|
|
}
|
2015-01-15 16:54:32 -05:00
|
|
|
|
|
|
|
$filter_by
|
|
|
|
.val('')
|
|
|
|
.trigger('input')
|
2015-01-20 12:56:00 -05:00
|
|
|
.trigger('keyup');
|
2015-01-15 16:54:32 -05:00
|
|
|
|
2015-01-21 11:54:29 -05:00
|
|
|
if ($clear) {
|
|
|
|
$clear.addClass('hide'); // Hide clear button
|
|
|
|
}
|
2015-01-15 16:54:32 -05:00
|
|
|
|
2015-01-21 12:09:39 -06:00
|
|
|
function selectFonticonsAd() {
|
|
|
|
random_number = Math.floor( Math.random() * ads.length );
|
|
|
|
random_ad = ads[random_number];
|
2015-01-21 12:05:34 -05:00
|
|
|
|
2015-01-21 12:09:39 -06:00
|
|
|
$('#rotating-message').html(random_ad.quote);
|
2015-01-22 11:36:55 -06:00
|
|
|
$('#rotating-url').attr("href", "https://fonticons.com/?utm_source=font_awesome_homepage&utm_medium=display&utm_content=" + random_ad.content + "&utm_campaign=promo_4.3_update");
|
2015-01-21 12:09:39 -06:00
|
|
|
}
|
2013-05-02 20:12:33 -04:00
|
|
|
});
|