PageSourceSearch

https://www.tarragona.cat/bootstrap/js/clear-button.js

js tarragona.cat collected 2026-09-24 08:51:53 UTC 2,062 bytes, 85 lines download raw bytes

1(function($) {
2
3    $.fn.jQueryClearButton = function(options){
4
5        if (!this.is(':visible')) {
6            return this;
7        }
8
9        var obj = this;
10        var obj_id = obj.attr('id');
11        var btn_class_name = 'clear-input';
12
13        //option
14        var defaults = {
15            'always': false, //clear button always display
16            'zindex': 10,
17        };
18        var setting = $.extend(defaults, options); //merge
19
20        //IE override
21        $('body').append('<style> input::-ms-clear { visibility:hidden; } </style>');
22
23        //make button
24        var btn = $('<span class="' + btn_class_name + '"><i class="fas fa-times"></i></span>');
25        this.after(btn);
26
27        //button style
28        btn.css({
29            'z-index': setting.zindex,
30        });
31
32        btn.click( function() {
33            //clear
34            obj.val('').focus();
35            !setting.always && btn.hide();
36        } );
37
38        obj.on('input', function() {
39            if (obj.val()) {
40                btn.fadeIn();
41            }
42            else {
43                !setting.always && btn.hide();
44            }
45        });
46
47        if (setting.always) {
48            btn.fadeIn();
49        }
50        else {
51            obj.focus( function() {
52                obj.val() && btn.fadeIn();
53            });
54
55            obj.blur( function() {
56                $('.' + btn_class_name).fadeOut();
57            });
58        }
59
60        // prevent enter no data
61        obj.keydown( function(e) {
62            if(e.keyCode == 13 && obj.val().trim() == '' ) {
63                e.preventDefault();
64                return false;
65            }
66        });
67
68        return (this);
69    };
70
71    // bootstrap controls..
72    if($('#toggle-desagregar')) {
73        $('#toggle-desagregar').prop('checked', false);
74        $("#toggle-desagregar").change(function(){
75            if($(this).prop("checked") == true) {
76                $(".hide-desagregar").show();
77
78            } else {
79                $(".hide-desagregar").hide();
80            }
81        });
82        
83    }
84
85})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.