PageSourceSearch

https://www.vieuxboucau-surflodge.com/wp-content/plugins/dopbsp/li…/js/jquery.dop.Select.js?ver=2.9.9.5.9

js vieuxboucau-surflodge.com collected 2026-10-10 02:03:41 UTC 10,667 bytes, 213 lines download raw bytes

1
2/*
3* Title                   : DOP Select (jQuery Plugin)
4* Version                 : 1.2
5* File                    : jquery.dop.Select.js
6* File Version            : 1.1
7* Created / Last Modified : 21 October 2014
8* Copyright               : © 2014 Dot on Paper
9* Website                 : http://www.dotonpaper.net
10* Description             : DOP Select jQuery plugin.
11*/
12
13(function($){
14    $.fn.DOPSelect = function(options){
15        /*
16         * Private variables.
17         */
18        var Data = {},
19        Container = this,
20        
21        ID = '',
22        id = '',
23        name = '',
24        classes = '',
25        onChange = '',
26        isDisabled = false,
27        isMultiple = false,
28        thisItem = '',
29        values = new Array(),
30        labels = new Array(),
31        selectedOption = 0,
32        
33        firstClick = false,
34        wasChanged = false,
35
36        methods = {            
37                    init:function(){
38                    /*
39                     * Initialize jQuery plugin.
40                     */ 
41                        return this.each(function(){
42                            if (options){
43                                $.extend(Data, options);
44                            }
45                            methods.parse();
46                        });
47                    },
48                    parse:function(){
49                    /*
50                     * Parse select options.
51                     */ 
52                        id = $(Container).attr('id') !== undefined ? $(Container).attr('id'):'';
53                        name = $(Container).attr('name') !== undefined ? $(Container).attr('name'):'';
54                        classes = $(Container).attr('class') !== undefined ? $(Container).attr('class'):'';
55                        onChange = $(Container).attr('onchange') !== undefined ? $(Container).attr('onchange'):'';
56                        isDisabled = $(Container).attr('disabled') !== undefined ? true:false;
57                        thisItem = id !== '' ? '#'+id:'select[name*="'+name+'"]';
58                        isMultiple = $(thisItem+'[multiple]').length ? true:false;
59                        ID = id !== '' ? id:name;
60                        
61                        $(thisItem+' option').each(function(){
62                            values.push($(this).attr('value'));
63                            labels.push($(this).html());
64                            
65                            if ($(this).is(':selected')){
66                                selectedOption = values.length-1;
67                            }
68                        });
69                        
70                        methods.display();
71                    },
72                    display:function(){
73                    /*
74                     * Display select component.
75                     */
76                        var HTML = new Array(), 
77                        i;
78                        
79                        HTML.push('<div id="DOPSelect-'+ID+'" class="DOPSelect '+(isMultiple ? 'dopselect-multiple':'dopselect-single')+' '+(isDisabled ? 'dopselect-disabled':'')+' '+classes+'">');
80                        HTML.push(' <input type="hidden" id="'+ID+'" name="'+name+'" value="'+(isMultiple ? '':values[selectedOption])+'">');
81                        
82                        /*
83                         * Display "selected" component only on single select.
84                         */
85                        if (!isMultiple){
86                            HTML.push(' <div class="dopselect-select">');
87                            HTML.push('     <div class="dopselect-selection">'+(values.length !== 0 ? labels[selectedOption]:'')+'</div>');
88                            HTML.push('     <div class="dopselect-icon">&#x25BE;</div>');
89                            HTML.push(' </div>');
90                        }
91                        HTML.push(' <ul>');
92                        
93                        for (i=0; i<values.length; i++){
94                            if (!isMultiple){
95                            /*
96                             * Single select options.
97                             */
98                                HTML.push('     <li id="DOPSelect-'+ID+'-'+values[i]+'"'+(selectedOption === i ? ' class="dopselect-selected"':'')+'>'+labels[i]+'</li>');
99                            }
100                            else{
101                            /*
102                             * Multiple select options.
103                             */
104                                HTML.push('     <li>');
105                                HTML.push('         <input type="checkbox" name="DOPSelect-'+ID+'-'+values[i]+'" id="DOPSelect-'+ID+'-'+values[i]+'"'+(isDisabled ? ' disabled="disabled"':'')+' '+(selectedOption === i && selectedOption !== 0 ? ' checked="checked"':'')+'/>');
106                                HTML.push('         <label for="DOPSelect-'+ID+'-'+values[i]+'">'+labels[i]+'</label>');
107                                HTML.push('     </li>');
108                            }
109                        }
110                        HTML.push(' </ul>');
111                        // HTML.push(' <div class="option-extension"></div>');
112                        HTML.push('</div>');
113                        
114                        $(Container).replaceWith(HTML.join(''));
115                        
116                        if (!isDisabled){
117                            methods.events();
118                        }
119                    },
120                    events:function(){
121                    /*
122                     * Initialize select component events.
123                     */
124                        if (isMultiple){
125                        /*
126                         * Multiple select events.
127                         */
128                            $('#DOPSelect-'+ID+' ul li').unbind('click');
129                            $('#DOPSelect-'+ID+' ul li').bind('click', function(){
130                                var selected = new Array(),
131                                id;
132                                
133                                $('#DOPSelect-'+ID+' ul li input[type=checkbox]').each(function(){
134                                    if ($(this).is(':checked')){
135                                        id = $(this).attr('id').split('DOPSelect-'+ID+'-')[1];
136                                        selected.push(id);
137                                    }
138                                });
139                                
140                                $('#'+ID).val(selected)
141                                         .trigger('change');
142
143                                if (onChange !== ''){
144                                    eval(onChange.replace(/this.value/g, selected));
145                                }
146                            });
147                        }
148                        else{
149                        /*
150                         * Single select events.
151                         */ 
152                            $(document).mousedown(function(event){
153                                if ($(event.target).parents('#DOPSelect-'+ID).length === 0){
154                                    $('#DOPSelect-'+ID+' ul').css('display', 'none')
155                                                             .scrollTop(0);
156                                }
157                            });
158                            
159                            $('#DOPSelect-'+ID+' .dopselect-select').unbind('click');
160                            $('#DOPSelect-'+ID+' .dopselect-select').bind('click', function(){
161                                if ($('#DOPSelect-'+ID+' ul').css('display') === 'block'){
162                                    $('#DOPSelect-'+ID+' ul').css('display', 'none')
163                                                             .scrollTop(0);
164                                }
165                                else{
166                                    var scrollTo;
167                                    
168                                    $('.DOPSelect.dopselect-single ul').css('display', 'none');
169                                    $('#DOPSelect-'+ID+' ul').css('display', 'block');
170                                    
171                                    /*
172                                     * Duplicate scrollTo action for the right position.
173                                     */
174                                    scrollTo = $('#DOPSelect-'+ID+' ul li.dopselect-selected').position().top-$('#DOPSelect-'+ID+' ul li.dopselect-selected').height();
175                                    $('#DOPSelect-'+ID+' ul').scrollTop(scrollTo);
176                                    
177                                    if (wasChanged 
178                                            || firstClick){
179                                        scrollTo = $('#DOPSelect-'+ID+' ul li.dopselect-selected').position().top-$('#DOPSelect-'+ID+' ul li.dopselect-selected').height();
180                                        $('#DOPSelect-'+ID+' ul').scrollTop(scrollTo);
181                                    }
182                                    
183                                    if (!firstClick){
184                                        firstClick = true;
185                                    }
186                                }
187                            });
188
189                            $('#DOPSelect-'+ID+' ul li').unbind('click');
190                            $('#DOPSelect-'+ID+' ul li').bind('click', function(){
191                                if (!$(this).hasClass('dopselect-selected')){
192                                    wasChanged = true; 
193                                    
194                                    $('#DOPSelect-'+ID+' ul li').removeClass('dopselect-selected');
195                                    $(this).addClass('dopselect-selected');
196                                    $('#DOPSelect-'+ID+' .dopselect-selection').html($(this).html());
197                                    $('#'+ID).val($(this).attr('id').split('DOPSelect-'+ID+'-')[1])
198                                             .trigger('change');
199
200                                    if (onChange !== ''){
201                                        eval(onChange.replace(/this.value/g, "'"+$(this).attr('id').split('DOPSelect-'+ID+'-')[1]+"'"));
202                                    }
203                                }
204                                $('#DOPSelect-'+ID+' ul').css('display', 'none')
205                                                         .scrollTop(0);
206                            });
207                        }
208                    }
209                  };
210
211        return methods.init.apply(this);
212    };
213})(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.