be_ui_icons.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Document : be_ui_icons.js
  3. * Author : pixelcave
  4. * Description: Custom JS code used in Icons Page
  5. */
  6. var BeUIIcons = function() {
  7. // Icon search functionality
  8. var initIconSearch = function(){
  9. // Set variables
  10. var searchItems = jQuery('.js-icon-list > div');
  11. var searchValue = '';
  12. // When user types
  13. jQuery('.js-icon-search').on('keyup', function(){
  14. searchValue = jQuery(this).val().toLowerCase();
  15. if (searchValue.length > 2) { // If more than 2 characters, search the icons
  16. searchItems.hide();
  17. jQuery('code', searchItems)
  18. .each(function(){
  19. if (jQuery(this).text().match(searchValue)) {
  20. jQuery(this).parent('div').fadeIn(300);
  21. }
  22. });
  23. } else if (searchValue.length === 0) { // If text deleted show all icons
  24. searchItems.show();
  25. }
  26. });
  27. };
  28. return {
  29. init: function() {
  30. // Init icon search
  31. initIconSearch();
  32. }
  33. };
  34. }();
  35. // Initialize when page loads
  36. jQuery(function(){ BeUIIcons.init(); });