PageSourceSearch

https://www.onefm.ch/wp-content/plugins/photo-gallery/js/jquery.sumoselect.min.js?ver=3.0.3

js onefm.ch collected 2026-09-24 09:25:11 UTC 27,551 bytes, 765 lines download raw bytes

1/*
2 * jquery.sumoselect - v3.0.3
3 * http://hemantnegi.github.io/jquery.sumoselect
4 * 2016-12-12
5 *
6 * Copyright 2015 Hemant Negi
7 * Email : [email protected]
8 * Compressor http://refresh-sf.com/
9 */
10
11(function(factory) {
12  'use strict';
13  if (typeof define === 'function' && define.amd) {
14    define(['jquery'], factory);
15  } else if (typeof exports !== 'undefined') {
16    module.exports = factory(require('jquery'));
17  } else {
18    factory(jQuery);
19  }
20
21})(function ($) {
22
23  'namespace sumo';
24  $.fn.SumoSelect = function (options) {
25
26    /* This is the easiest way to have default options.*/
27    var settings = $.extend({
28      placeholder: 'Select Here',   /* Dont change it here.*/
29      csvDispCount: 3,              /* display no. of items in multiselect. 0 to display all.*/
30      captionFormat:'{0} Selected', /* format of caption text. you can set your locale.*/
31      captionFormatAllSelected:'{0} all selected!', /* format of caption text when all elements are selected. set null to use captionFormat. It will not work if there are disabled elements in select.*/
32      floatWidth: 400,              /* Screen width of device at which the list is rendered in floating popup fashion.*/
33      forceCustomRendering: false,  /* force the custom modal on all devices below floatWidth resolution.*/
34      nativeOnDevice: ['Android', 'BlackBerry', 'iPhone', 'iPad', 'iPod', 'Opera Mini', 'IEMobile', 'Silk'],
35      outputAsCSV: false,           /* true to POST data as csv ( false for Html control array ie. default select )*/
36      csvSepChar: ',',              /* separation char in csv mode*/
37      okCancelInMulti: false,       /* display ok cancel buttons in desktop mode multiselect also.*/
38      isClickAwayOk: false,         /* for okCancelInMulti=true. sets whether click outside will trigger Ok or Cancel (default is cancel).*/
39      triggerChangeCombined: true,  /* im multi select mode whether to trigger change event on individual selection or combined selection.*/
40      selectAll: false,             /* to display select all button in multiselect mode.|| also select all will not be available on mobile devices.*/
41      search: false,                /* to display input for filtering content. selectAlltext will be input text placeholder*/
42      searchText: 'Search...',      /* placeholder for search input*/
43      noMatch: 'No matches for "{0}"',
44      prefix: '',                   /* some prefix usually the field name. eg. '<b>Hello</b>'*/
45      locale: ['OK', 'Cancel', 'Select All'],  /* all text that is used. don't change the index.*/
46      up: false,                    /* set true to open upside.*/
47      showTitle: true               /* set to false to prevent title (tooltip) from appearing*/
48    }, options);
49
50    var ret = this.each(function () {
51      var selObj = this; /* the original select object.*/
52      if (this.sumo || !$(this).is('select')) return; /* already initialized*/
53
54      this.sumo = {
55        E: $(selObj), /* the jquery object of original select element.*/
56        is_multi: $(selObj).attr('multiple'),  /* if its a multiple select*/
57        select: '',
58        caption: '',
59        placeholder: '',
60        optDiv: '',
61        CaptionCont: '',
62        ul:'',
63        is_floating: false,
64        is_opened: false,
65        /* backdrop: '', */
66        mob:false, /* if to open device default select */
67        Pstate: [],
68
69        createElems: function () {
70          var O = this;
71          O.E.wrap('<div class="SumoSelect" tabindex="0" role="button" aria-expanded="false">');
72          O.select = O.E.parent();
73          O.caption = $('<span>');
74          O.CaptionCont = $('<p class="CaptionCont SelectBox" ><label><i></i></label></p>')
75            .attr('style', O.E.attr('style'))
76            .prepend(O.caption);
77          O.select.append(O.CaptionCont);
78
79          /* default turn off if no multiselect */
80          if(!O.is_multi)settings.okCancelInMulti = false
81
82          if(O.E.attr('disabled'))
83            O.select.addClass('disabled').removeAttr('tabindex');
84
85          /* if output as csv and is a multiselect.*/
86          if (settings.outputAsCSV && O.is_multi && O.E.attr('name')) {
87            /* create a hidden field to store csv value.*/
88            O.select.append($('<input class="HEMANT123" type="hidden" />').attr('name', O.E.attr('name')).val(O.getSelStr()));
89
90            /* so it can not post the original select.*/
91            O.E.removeAttr('name');
92          }
93
94          /* break for mobile rendring.. if forceCustomRendering is false*/
95          if (O.isMobile() && !settings.forceCustomRendering) {
96            O.setNativeMobile();
97            return;
98          }
99
100          /* if there is a name attr in select add a class to container div*/
101          if(O.E.attr('name')) O.select.addClass('sumo_'+O.E.attr('name').replace(/\[\]/, ''))
102
103          /* hide original select */
104          O.E.addClass('SumoUnder').attr('tabindex','-1');
105
106          /* Creating the list... */
107          O.optDiv = $('<div class="optWrapper '+ (settings.up?'up':'') +'">');
108
109          /* branch for floating list in low res devices.*/
110          O.floatingList();
111
112          /* Creating the markup for the available options*/
113          O.ul = $('<ul class="options">');
114          O.optDiv.append(O.ul);
115
116          /* Select all functionality*/
117          if(settings.selectAll && O.is_multi) O.SelAll();
118
119          /* search functionality*/
120          if(settings.search) O.Search();
121
122          O.ul.append(O.prepItems(O.E.children()));
123
124          /* if multiple then add the class multiple and add OK / CANCEL button */
125          if (O.is_multi) O.multiSelelect();
126
127          O.select.append(O.optDiv);
128          O.basicEvents();
129          O.selAllState();
130        },
131
132        prepItems: function(opts, d){
133          var lis = [], O=this;
134          $(opts).each(function (i, opt) { /* parsing options to li */
135            opt = $(opt);
136            lis.push(opt.is('optgroup')?
137              $('<li class="group '+ (opt[0].disabled?'disabled':'') +'"><label>' + opt.attr('label') +'</label><ul></ul></li>')
138                .find('ul')
139                .append(O.prepItems(opt.children(), opt[0].disabled))
140                .end()
141              :
142              O.createLi(opt, d)
143            );
144          });
145          return lis;
146        },
147
148        /* Creates a LI element from a given option and binds events to it*/
149        /*returns the jquery instance of li (not inserted in dom)*/
150        createLi: function (opt, d) {
151          var O = this;
152
153          if(!opt.attr('value'))opt.attr('value',opt.val());
154          var li = $('<li class="opt"><label>' + opt.text() + '</label></li>');
155
156          li.data('opt', opt); /* store a direct reference to option.*/
157          opt.data('li', li); /* store a direct reference to list item.*/
158          if (O.is_multi) li.prepend('<span><i></i></span>');
159
160          if (opt[0].disabled || d)
161            li = li.addClass('disabled');
162
163          O.onOptClick(li);
164
165          if (opt[0].selected)
166            li.addClass('selected');
167
168          if (opt.attr('class'))
169            li.addClass(opt.attr('class'));
170
171          if (opt.attr('title'))
172            li.attr('title', opt.attr('title'));
173
174          return li;
175        },
176
177        /* Returns the selected items as string in a Multiselect.*/
178        getSelStr: function () {
179          /* get the pre selected items.*/
180          sopt = [];
181          this.E.find('option:selected').each(function () { sopt.push($(this).val()); });
182          return sopt.join(settings.csvSepChar);
183        },
184
185        /* THOSE OK/CANCEL BUTTONS ON MULTIPLE SELECT.*/
186        multiSelelect: function () {
187          var O = this;
188          O.optDiv.addClass('multiple');
189          O.okbtn = $('<p tabindex="0" class="btnOk">'+settings.locale[0]+'</p>').click(function () {
190            /* if combined change event is set.*/
191            O._okbtn();
192            O.hideOpts();
193          });
194          O.cancelBtn = $('<p tabindex="0" class="btnCancel">'+settings.locale[1]+'</p>').click(function () {
195            O._cnbtn();
196            O.hideOpts();
197          });
198          var btns = O.okbtn.add(O.cancelBtn);
199          O.optDiv.append($('<div class="MultiControls">').append(btns));
200
201          /* handling keyboard navigation on ok cancel buttons. */
202          btns.on('keydown.sumo', function (e) {
203            var el = $(this);
204            switch (e.which) {
205              case 32: /* space */
206              case 13: /* enter */
207                el.trigger('click');
208                break;
209
210              case 9:  /* tab */
211                if(el.hasClass('btnOk'))return;
212              case 27: /* esc */
213                O._cnbtn();
214                O.hideOpts();
215                return;
216            }
217            e.stopPropagation();
218            e.preventDefault();
219          });
220        },
221
222        _okbtn:function(){
223          var O = this, cg = 0;
224          /* if combined change event is set. */
225          if (settings.triggerChangeCombined) {
226            /* check for a change in the selection. */
227            if (O.E.find('option:selected').length != O.Pstate.length) {
228              cg = 1;
229            }
230            else {
231              O.E.find('option').each(function (i,e) {
232                if(e.selected && O.Pstate.indexOf(i) < 0) cg = 1;
233              });
234            }
235
236            if (cg) {
237              O.callChange();
238              O.setText();
239            }
240          }
241        },
242        _cnbtn:function(){
243          var O = this;
244          /* remove all selections */
245          O.E.find('option:selected').each(function () { this.selected = false; });
246          O.optDiv.find('li.selected').removeClass('selected')
247
248          /* restore selections from saved state. */
249          for(var i = 0; i < O.Pstate.length; i++) {
250            O.E.find('option')[O.Pstate[i]].selected = true;
251            O.ul.find('li.opt').eq(O.Pstate[i]).addClass('selected');
252          }
253          O.selAllState();
254        },
255
256        SelAll:function(){
257          var O = this;
258          if(!O.is_multi)return;
259          O.selAll = $('<p class="select-all"><span><i></i></span><label>' + settings.locale[2] + '</label></p>');
260          O.optDiv.addClass('selall');
261          O.selAll.on('click',function(){
262            O.selAll.toggleClass('selected');
263            O.toggSelAll(O.selAll.hasClass('selected'), 1);
264            //O.selAllState();
265          });
266
267          O.optDiv.prepend(O.selAll);
268        },
269
270        /* search module (can be removed if not required.) */
271        Search: function(){
272          var O = this,
273            cc = O.CaptionCont.addClass('search'),
274            P = $('<p class="no-match">');
275
276          O.ftxt = $('<input type="text" class="search-txt" value="" placeholder="' + settings.searchText + '">')
277            .on('click', function(e){
278              e.stopPropagation();
279            });
280          cc.append(O.ftxt);
281          O.optDiv.children('ul').after(P);
282
283          O.ftxt.on('keyup.sumo',function(){
284            var hid = O.optDiv.find('ul.options li.opt').each(function(ix,e){
285              var e = $(e),
286                opt = e.data('opt')[0];
287              opt.hidden = e.text().toLowerCase().indexOf(O.ftxt.val().toLowerCase()) < 0;
288              e.toggleClass('hidden', opt.hidden);
289            }).not('.hidden');
290
291            P.html(settings.noMatch.replace(/\{0\}/g, '<em></em>')).toggle(!hid.length);
292            P.find('em').text(O.ftxt.val());
293            O.selAllState();
294          });
295        },
296
297        selAllState: function () {
298          var O = this;
299          if (settings.selectAll && O.is_multi) {
300            var sc = 0, vc = 0;
301            O.optDiv.find('li.opt').not('.hidden').each(function (ix, e) {
302              if ($(e).hasClass('selected')) sc++;
303              if (!$(e).hasClass('disabled')) vc++;
304            });
305            /* select all checkbox state change. */
306            if (sc == vc) O.selAll.removeClass('partial').addClass('selected');
307            else if (sc == 0) O.selAll.removeClass('selected partial');
308            else O.selAll.addClass('partial') /* .removeClass('selected'); */
309          }
310        },
311
312        showOpts: function () {
313          var O = this;
314          if (O.E.attr('disabled')) return; /* if select is disabled then retrun */
315          O.E.trigger('sumo:opening', O);
316          O.is_opened = true;
317          O.select.addClass('open').attr('aria-expanded', 'true');
318          O.E.trigger('sumo:opened', O);
319
320          if(O.ftxt)O.ftxt.focus();
321          else O.select.focus();
322
323          /* hide options on click outside.*/
324          $(document).on('click.sumo', function (e) {
325            if (!O.select.is(e.target)                  /* if the target of the click isn't the container... */
326              && O.select.has(e.target).length === 0){ /* ... nor a descendant of the container */
327              if(!O.is_opened)return;
328              O.hideOpts();
329              if (settings.okCancelInMulti){
330                if(settings.isClickAwayOk)
331                  O._okbtn();
332                else
333                  O._cnbtn();
334              }
335            }
336          });
337
338          if (O.is_floating) {
339            H = O.optDiv.children('ul').outerHeight() + 2;  /* +2 is clear fix*/
340            if (O.is_multi) H = H + parseInt(O.optDiv.css('padding-bottom'));
341            O.optDiv.css('height', H);
342            $('body').addClass('sumoStopScroll');
343          }
344
345          O.setPstate();
346        },
347
348        /* maintain state when ok/cancel buttons are available storing the indexes. */
349        setPstate: function(){
350          var O = this;
351          if (O.is_multi && (O.is_floating || settings.okCancelInMulti)){
352            O.Pstate = [];
353            /* assuming that find returns elements in tree order */
354            O.E.find('option').each(function (i, e){if(e.selected) O.Pstate.push(i);});
355          }
356        },
357
358        callChange:function(){
359          this.E.trigger('change').trigger('click');
360        },
361
362        hideOpts: function () {
363          var O = this;
364          if(O.is_opened){
365            O.E.trigger('sumo:closing', O);
366            O.is_opened = false;
367            O.select.removeClass('open').attr('aria-expanded', 'true').find('ul li.sel').removeClass('sel');
368            O.E.trigger('sumo:closed', O);
369            $(document).off('click.sumo');
370            O.select.focus();
371            $('body').removeClass('sumoStopScroll');
372
373            /* clear the search */
374            if(settings.search){
375              O.ftxt.val('');
376              O.ftxt.trigger('keyup.sumo');
377            }
378          }
379        },
380        setOnOpen: function () {
381          var O = this,
382            li = O.optDiv.find('li.opt:not(.hidden)').eq(settings.search?0:O.E[
3820].selectedIndex);
383          if(li.hasClass('disabled')){
384            li = li.next(':not(disabled)')
385            if(!li.length) return;
386          }
387          O.optDiv.find('li.sel').removeClass('sel');
388          li.addClass('sel');
389          O.showOpts();
390        },
391        nav: function (up) {
392          var O = this, c,
393            s=O.ul.find('li.opt:not(.disabled, .hidden)'),
394            sel = O.ul.find('li.opt.sel:not(.hidden)'),
395            idx = s.index(sel);
396          if (O.is_opened && sel.length) {
397
398            if (up && idx > 0)
399              c = s.eq(idx-1);
400            else if(!up && idx < s.length-1 && idx > -1)
401              c = s.eq(idx+1);
402            else return; /* if no items before or after*/
403
404            sel.removeClass('sel');
405            sel = c.addClass('sel');
406
407            /* setting sel item to visible view. */
408            var ul = O.ul,
409              st = ul.scrollTop(),
410              t = sel.position().top + st;
411            if(t >= st + ul.height()-sel.outerHeight())
412              ul.scrollTop(t - ul.height() + sel.outerHeight());
413            if(t<st)
414              ul.scrollTop(t);
415
416          }
417          else
418            O.setOnOpen();
419        },
420
421        basicEvents: function () {
422          var O = this;
423          O.CaptionCont.click(function (evt) {
424            O.E.trigger('click');
425            if (O.is_opened) O.hideOpts(); else O.showOpts();
426            evt.stopPropagation();
427          });
428
429          O.select.on('keydown.sumo', function (e) {
430            switch (e.which) {
431              case 38: /* up */
432                O.nav(true);
433                break;
434
435              case 40: /* down */
436                O.nav(false);
437                break;
438
439              case 65: /* shortcut ctrl + a to select all and ctrl + shift + a to unselect all.*/
440                if (O.is_multi && e.ctrlKey){
441                  O.toggSelAll(!e.shiftKey, 1);
442                  break;
443                }
444                else
445                  return;
446
447              case 32: /* space*/
448                if(settings.search && O.ftxt.is(e.target))return;
449              case 13: /* enter*/
450                if (O.is_opened)
451                  O.optDiv.find('ul li.sel').trigger('click');
452                else
453                  O.setOnOpen();
454                break;
455              case 9:	 /* tab*/
456                if(!settings.okCancelInMulti)
457                  O.hideOpts();
458                return;
459              case 27: /* esc*/
460                if(settings.okCancelInMulti)O._cnbtn();
461                O.hideOpts();
462                return;
463
464              default:
465                return; /* exit this handler for other keys */
466            }
467            e.preventDefault(); /* prevent the default action (scroll / move caret) */
468          });
469
470          $(window).on('resize.sumo', function () {
471            O.floatingList();
472          });
473        },
474
475        onOptClick: function (li) {
476          var O = this;
477          li.click(function () {
478            var li = $(this);
479            if(li.hasClass('disabled'))return;
480            var txt = "";
481            if (O.is_multi) {
482              li.toggleClass('selected');
483              li.data('opt')[0].selected = li.hasClass('selected');
484              O.selAllState();
485            }
486            else {
487              li.parent().find('li.selected').removeClass('selected'); //if not multiselect then remove all selections from this list
488              li.toggleClass('selected');
489              li.data('opt')[0].selected = true;
490            }
491
492            //branch for combined change event.
493            if (!(O.is_multi && settings.triggerChangeCombined && (O.is_floating || settings.okCancelInMulti))) {
494              O.setText();
495              O.callChange();
496            }
497
498            if (!O.is_multi) O.hideOpts(); //if its not a multiselect then hide on single select.
499          });
500        },
501
502        setText: function () {
503          var O = this;
504          O.placeholder = "";
505          if (O.is_multi) {
506            sels = O.E.find(':selected').not(':disabled'); //selected options.
507
508            for (i = 0; i < sels.length; i++) {
509              if (i + 1 >
509= settings.csvDispCount && settings.csvDispCount) {
510                if (sels.length == O.E.find('option').length && settings.captionFormatAllSelected) {
511                  O.placeholder = settings.captionFormatAllSelected.replace(/\{0\}/g, sels.length)+',';
512                } else {
513                  O.placeholder = settings.captionFormat.replace(/\{0\}/g, sels.length)+',';
514                }
515
516                break;
517              }
518              else O.placeholder += $(sels[i]).text() + ", ";
519            }
520            O.placeholder = O.placeholder.replace(/,([^,]*)$/, '$1'); //remove unexpected "," from last.
521          }
522          else {
523            O.placeholder = O.E.find(':selected').not(':disabled').text();
524          }
525
526          var is_placeholder = false;
527
528          if (!O.placeholder) {
529
530            is_placeholder = true;
531
532            O.placeholder = O.E.attr('placeholder');
533            if (!O.placeholder)                  //if placeholder is there then set it
534              O.placeholder = O.E.find('option:disabled:selected').text();
535          }
536
537          O.placeholder = O.placeholder ? (settings.prefix + ' ' + O.placeholder) : settings.placeholder
538
539          //set display text
540          O.caption.html(O.placeholder);
541          if (settings.showTitle) O.CaptionCont.attr('title', O.placeholder);
542
543          //set the hidden field if post as csv is true.
544          var csvField = O.select.find('input.HEMANT123');
545          if (csvField.length) csvField.val(O.getSelStr());
546
547          //add class placeholder if its a placeholder text.
548          if (is_placeholder) O.caption.addClass('placeholder'); else O.caption.removeClass('placeholder');
549          return O.placeholder;
550        },
551
552        isMobile: function () {
553
554          /* Adapted from http://www.detectmobilebrowsers.com */
555          var ua = navigator.userAgent || navigator.vendor || window.opera;
556
557          /* Checks for iOs, Android, Blackberry, Opera Mini, and Windows mobile devices */
558          for (var i = 0; i < settings.nativeOnDevice.length; i++) if (ua.toString().toLowerCase().indexOf(settings.nativeOnDevice[i].toLowerCase()) > 0) return settings.nativeOnDevice[i];
559          return false;
560        },
561
562        setNativeMobile: function () {
563          var O = this;
564          O.E.addClass('SelectClass'); /* .css('height', O.select.outerHeight()); */
565          O.mob = true;
566          O.E.change(function () {
567            O.setText();
568          });
569        },
570
571        floatingList: function () {
572          var O = this;
573          /*called on init and also on resize.*/
574          /*O.is_floating = true if window width is < specified float width*/
575          O.is_floating = $(window).width() <= settings.floatWidth;
576
577          /*set class isFloating*/
578          O.optDiv.toggleClass('isFloating', O.is_floating);
579
580          /*remove height if not floating*/
581          if (!O.is_floating) O.optDiv.css('height', '');
582
583          /*toggle class according to okCancelInMulti flag only when it is not floating*/
584          O.optDiv.toggleClass('okCancelInMulti', settings.okCancelInMulti && !O.is_floating);
585        },
586
587        /* HELPERS FOR OUTSIDERS*/
588        /* validates range of given item operations*/
589        vRange: function (i) {
590          var O = this;
591          var opts = O.E.find('option');
592          if (opts.length <= i || i < 0) throw "index out of bounds"
593          return O;
594        },
595
596        /*toggles selection on c as boolean.*/
597        toggSel: function (c, i) {
598          var O = this;
599          var opt;
600          if (typeof(i) === "number"){
601            O.vRange(i);
602            opt = O.E.find('option')[i];
603          }
604          else{
605            opt = O.E.find('option[value="'+i+'"]')[0]||0;
606          }
607          if (!opt || opt.disabled)
608            return;
609
610          if(opt.selected != c){
611            opt.selected = c;
612            if(!O.mob) $(opt).data('li').toggleClass('selected',c);
613
614            O.callChange();
615            O.setPstate();
616            O.setText();
617            O.selAllState();
618          }
619        },
620
621        /*toggles disabled on c as boolean.*/
622        toggDis: function (c, i) {
623          var O = this.vRange(i);
624          O.E.find('option')[i].disabled = c;
625          if(c)O.E.find('option')[i].selected = false;
626          if(!O.mob)O.optDiv.find('ul.options li').eq(i).toggleClass('disabled', c).removeClass('selected');
627          O.setText();
628        },
629
630        /* toggle disable/enable on complete select control*/
631        toggSumo: function(val) {
632          var O = this;
633          O.enabled = val;
634          O.select.toggleClass('disabled', val);
635
636          if (val) {
637            O.E.attr('disabled', 'disabled');
638            O.select.removeAttr('tabindex');
639          }
640          else{
641            O.E.removeAttr('disabled');
642            O.select.attr('tabindex','0');
643          }
644
645          return O;
646        },
647
648        /* toggles all option on c as boolean.*/
649        /* set direct=false/0 bypasses okCancelInMulti behaviour.*/
650        toggSelAll: function (c, direct) {
651          var O = this;
652          O.E.find('option:not(:disabled,:hidden)')
653           .each(function(ix,e){
654             var is_selected=e.selected,
655               e = $(e).data('li');
656             if(e.hasClass('hidden'))return;
657             if(!!c){
658               if(!is_selected)e.trigger('click');
659             }
660             else{
661               if(is_selected)e.trigger('click');
662             }
663           });
664
665          if(!direct){
666            if(!O.mob && O.selAll)O.selAll.removeClass('partial').toggleClass('selected',!!c);
667            O.callChange();
668            O.setText();
669            O.setPstate();
670          }
671        },
672
673        /* outside accessibility options
674         which can be accessed from the element instance.
675         */
676        reload:function(){
677          var elm = this.unload();
678          return $(elm).SumoSelect(settings);
679        },
680
681        unload: function () {
682          var O = this;
683          O.select.before(O.E);
684          O.E.show();
685
686          if (settings.outputAsCSV && O.is_multi && O.select.find('input.HEMANT123').length) {
687            O.E.attr('name', O.select.find('input.HEMANT123').attr('name')); /* restore the name; */
688          }
689          O.select.remove();
690          delete selObj.sumo;
691          return selObj;
692        },
693
694        /* add a new option to select at a given index.*/
695        add: function (val, txt, i) {
696          if (typeof val == "undefined") throw "No value to add"
697
698          var O = this;
699          opts=O.E.find('option')
700          if (typeof txt == "number") { i = txt; txt = val; }
701          if (typeof txt == "undefined") { txt = val; }
702
703          opt = $("<option></option>").val(val).html(txt);
704
705          if (opts.length < i) throw "index out of bounds"
706
707          if (typeof i == "undefined" || opts.length == i) { /* add it to the last if given index is last no or no index provides.*/
708            O.E.append(opt);
709            if(!O.mob)O.ul.append(O.createLi(opt));
710          }
711          else {
712            opts.eq(i).before(opt);
713            if(!O.mob)O.ul.find('li.opt').eq(i).before(O.createLi(opt));
714          }
715
716          return selObj;
717        },
718
719        /* removes an item at a given index. */
720        remove: function (i) {
721          var O = this.vRange(i);
722          O.E.find('option').eq(i).remove();
723          if(!O.mob)O.optDiv.find('ul.options li').eq(i).remove();
724          O.setText();
725        },
726
727        /* Select an item at a given index.*/
728        selectItem: function (i) { this.toggSel(true, i); },
729
730        /* UnSelect an iten at a given index.*/
731        unSelectItem: function (i) { this.toggSel(false, i); },
732
733        /* Select all items  of the select.*/
734        selectAll: function () { this.toggSelAll(true); },
735
736        /* UnSelect all items of the select.*/
737        unSelectAll: function () { this.toggSelAll(false); },
738
739        /* Disable an iten at a given index.*/
740        disableItem: function (i) { this.toggDis(true, i) },
741
742        /* Removes disabled an iten at a given index.*/
743        enableItem: function (i) { this.toggDis(false, i) },
744
745        /* New simple methods as getter and setter are not working fine in ie8-*/
746        /* variable to check state of control if enabled or disabled.*/
747        enabled : true,
748        /* Enables the control*/
749        enable: function(){return this.toggSumo(false)},
750
751        /* Disables the control*/
752        disable: function(){return this.toggSumo(true)},
753        init: function () {
754          var O = this;
755          O.createElems();
756          O.setText();
757          return O
758        }
759      };
760      selObj.sumo.init();
761    });
762
763    return ret.length == 1 ? ret[0] : ret;
764  };
765});

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.