HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/buyercall_new/buyercall/buyercall/static/js/pages/uiIcons.js
/*
 *  Document   : uiIcons.js
 *  Author     : pixelcave
 *  Description: Custom javascript code used in Icons page
 */

var UiIcons = function() {
    var $searchItems, $searchValue;

    return {
        init: function() {
            var titleAttr;

            // When an icon button is clicked
            $('#page-content .btn').click(function(){
                // Get the icon class from the button attribute (data-original-title is created by tooltip)
                titleAttr = $(this).attr('data-original-title');

                // Set the content of the input and select it
                $('#icon-gen-input')
                    .val( '<i class="' + titleAttr + '"></i>' )
                    .select();

                // Animate scrolling to the icon generator
                $('html,body')
                    .animate({ scrollTop: $('#icon-gen').offset().top - 15 });

                return false;
            });

            // Search functionality
            $searchItems = $('.js-icon-list a');

            $('.js-icon-search').on('keyup', function(){ // When user types
                $searchValue = $(this).val().toLowerCase();

                if ($searchValue.length > 2) { // If more than 2 characters, search the icons
                    $searchItems.hide();

                    $searchItems
                        .each(function(){
                            if ($('i', this).attr('class').match($searchValue)) {
                                $(this).show();
                            }
                        });
                } else if ($searchValue.length === 0) { // If text deleted show all icons
                    $searchItems.show();
                }
            });
        }
    };
}();