PageSourceSearch

https://www.chestnet.org/Scripts/ecommerce/vendor/jquery.heapbox-0.9.4.js

js chestnet.org collected 2026-09-24 08:36:33 UTC 33,577 bytes, 1,023 lines download raw bytes

1/*
2HeapBox 0.9.4
3(c) 2013 Filip Bartos
4*/
5
6/*
7	!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
8		Modified from original:
9		10/29 - Added the original <select>'s classes to the rendered heapbox div.
10		10/31 - Gave the heapbox's Holder and Handle a -1 tabindex in order to skip it when tabbing through fields.
11                Only focus on the parent div, not the handler inside _setHeapboxFocus function.
12	!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
13*/
14
15; (function ($, window, document, undefined) {
16
17    var pluginName = "heapbox",
18        defaults = {
19            effect: {
20                "type": "slide",
21                "speed": "slow"
22            },
23            insert: "before",
24            heapsize: undefined,
25            emptyMessage: 'Empty',
26            tabindex: 'undefined',
27            title: undefined,
28            showFirst: true,
29            inheritVisibility: true,
30            openStart: function () { },
31            openComplete: function () { },
32            closeStart: function () { },
33            closeComplete: function () { },
34            onChange: function () { }
35        };
36
37    function Plugin(element, options) {
38
39        /* Settings */
40        this.element = element;
41        this.options = $.extend({}, defaults, options);
42        this._defaults = defaults;
43        this._name = pluginName;
44        this.instance;
45        this.callbackManager = new Array();
46        this.elem_isVisible = '';
47        this.init();
48    }
49
50    Plugin.prototype = {
51
52        /*
53         * Heapbox init
54        */
55        init: function () {
56            this._hideSourceElement();
57            this._isSourceSelectbox();
58            this.instance = this.createInstance();
59            this._createElements();
60            this._setDefaultValues();
61        },
62
63        /*
64        *  Generate new ID for selectbox
65        */
66        createInstance: function () {
67
68            return {
69                heapId: $(this.element).attr('id') || Math.round(Math.random() * 99999999),
70                state: false
71            };
72        },
73
74        /*
75         * Set events
76        */
77        _setEvents: function () {
78            var self = this;
79            this._setControlsEvents();
80
81            $(document).on("click", "html", function (e) { e.stopPropagation(); self._closeheap(true, function () { }, function () { }); });
82        },
83
84        _setSliderEvents: function () {
85
86            var self = this;
87            this.scrollingStatus = false;
88
89            heap = $("#heapbox_" + this.instance.heapId + " .heap");
90
91            // Slider Down
92            heap.find(".sliderDown").click(function (e) { e.preventDefault(); e.stopPropagation(); self._setHeapboxFocus(); });
93
94            heap.find(".sliderDown").mousedown(function (e) {
95                self.scrollingStatus = true;
96                self._keyArrowHandler($("#heapbox_" + self.instance.heapId), "down");
97                self.interval = setInterval(function () { self._keyArrowHandler($("#heapbox_" + self.instance.heapId), "down"); }, 300);
98            }).mouseup(function (e) {
99                clearInterval(self.interval);
100                self.scrollingStatus = false;
101            }).mouseout(function (e) {
102                clearInterval(self.interval);
103                self.scrollingStatus = false;
104            });
105
106            // Slider Up
107            heap.find(".sliderUp").click(function (e) { e.preventDefault(); e.stopPropagation(); self._setHeapboxFocus(); });
108
109            heap.find(".sliderUp").mousedown(function (e) {
110                self.scrollingStatus = true;
111                self._keyArrowHandler($("#heapbox_" + self.instance.heapId), "up");
112                self.interval = setInterval(function () { self._keyArrowHandler($("#heapbox_" + self.instance.heapId), "up"); }, 300);
113            }).mouseup(function (e) {
114                clearInterval(self.interval);
115                self.scrollingStatus = false;
116            }).mouseout(function (e) {
117                clearInterval(self.interval);
118                self.scrollingStatus = false;
119            });
120
121        },
122
123        _setViewPosition: function (heapbox) {
124
125            heap = $("div#heapbox_" + this.instance.heapId + " .heap");
126            heap.show();
127            var self = this;
128            selected = heapbox.find(".heapOptions li a.selected");
129            firstTop = heapbox.find(".heapOptions li a").first().offset().top;
130            actTop = $(selected).offset().top;
131            newTop = firstTop - actTop + this.sliderUpHeight;
132            heapHeight = $("div#heapbox_" + this.instance.heapId + " .heapOptions").height();
133            maxPosition = heapHeight - parseInt(this.options.heapsize, 10) + this.sliderDownHeight;
134            minPosition = 0 + this.sliderUpHeight;
135
136            if ((-1 * newTop) > maxPosition) newTop = -1 * (maxPosition);
137            heapbox.find(".heapOptions").css("top", newTop);
138
139            if (!this.instance.state) heap.hide();
140        },
141
142        _setKeyboardEvents: function () {
143
144            var self = this;
145
146            heapbox = $("#heapbox_" + this.instance.heapId);
147
148            heapbox.keydown(function (e) {
149
150                switch (e.which) {
151                    case 13: self._handlerClicked();
152                        return false;
153                        break;
154                    case 27: self._closeheap();
155                        break;
156                    case 37: self._keyArrowHandler($("#heapbox_" + self.instance.heapId), "up");
157                        e.preventDefault();
158                        break;
159                    case 39: self._keyArrowHandler($("#heapbox_" + self.instance.heapId), "down");
160                        e.preventDefault();
161                        break;
162                    case 38: self._keyArrowHandler($("#heapbox_" + self.instance.heapId), "up");
163                        e.preventDefault();
164                        break;
165                    case 40: self._keyArrowHandler($("#heapbox_" + self.instance.heapId), "down");
166                        e.preventDefault();
167                        break;
168                }
169            });
170
171        },
172
173        /*
174         *	Adds mouse wheel events
175         *	@require	jquery-mousewheel
176         *	@see 		https://github.com/brandonaaron/jquery-mousewheel
177         */
178        _setMouseWheelEvents: function () {
179
180            var self = this,
181                heapBoxEl = $("div#heapbox_" + this.instance.heapId + " .handler"),
182                heap = heapBoxEl.find('div.heap');
183
184            heapBoxEl.on('mousewheel', function (event, delta) {
185
186                event.preventDefault();
187                if (delta == -1) {
188                    heap.find(".sliderDown")
189                        .mousedown()
190                        .mouseup();
191                } else {
192                    heap.find(".sliderUp")
193                        .mousedown()
194                        .mouseup();
195                }
196
197            });
198        },
199
200        _keyArrowHandler: function (heapboxEl, direction) {
201            var self = this;
202            var selected = false;
203
204            heapboxEl.find("div.heap ul li").each(function () {
205                if (($(this).find("a").hasClass("selected"))) {
206                    selected = true;
207
208                    selectItem = direction == "down" ? self._findNext($(this)) : self._findPrev($(this));
209
210                    if (selectItem) {
211                        self._heapChanged(self, selectItem, true);
212                        return false;
213                    }
214                }
215            });
216
217            if (selected == false) {
218                selectItem = $("div#heapbox_" + self.instance.heapId + " .heapOptions .heapOption").first().find("a").addClass("selected");
219                self._heapChanged(self, selectItem, true);
220            }
221
222            self._setViewPosition($("#heapbox_" + self.instance.heapId));
223        },
224
225        /*
226         *	Adds mouse wheel events
227         *	@require	jquery-mousewheel
228         *	@see 		https://github.com/brandonaaron/jquery-mousewheel
229         */
230        _setMouseWheelEvents: function () {
231            var self = this,
232                heapBoxEl = $("div#heapbox_" + this.instance.heapId),
233                heap = heapBoxEl.find('div.heap');
234
235            heapBoxEl.on('mousewheel', function (event, delta) {
236                event.preventDefault();
237                if (delta == -1) {
238                    heap.find(".sliderDown")
239                        .mousedown()
240                        .mouseup();
241                } else {
242                    heap.find(".sliderUp")
243                        .mousedown()
244                        .mouseup();
245                }
246
247            });
248        },
249
250        /*
251         * Find prev selectable heapbox option (ignore disabled)
252         */
253        _findPrev: function (startItem) {
254            if (startItem.prev().length > 0) {
255                if (!startItem.prev().find("a").hasClass("disabled")) {
256                    return startItem.prev().find("a");
257                } else {
258                    return this._findPrev(startItem.prev());
259                }
260            }
261        },
262
263        /*
264         * Find next selectable heapbox option (ignore disabled)
265         */
266        _findNext: function (startItem) {
267            if (startItem.next().length > 0) {
268                if (!startItem.next().find("a").hasClass("disabled")) {
269                    return startItem.next().find("a");
270                } else {
271                    return this._findNext(startItem.next());
272                }
273            }
274        },
275        /*
276         * Create heapbox html structure
277        */
278        _createElements: function () {
279
280            var self = this;
281            heapBoxEl = $('<div/>', {
282                id: 'heapbox_' + this.instance.heapId,
283                'class': 'heapBox ' + this.element.className,
284                data: { 'sourceElement': this.element }
285            });
286
287            // Set visibility according to original <select> element
288            if (self.options.inheritVisibility == true && self.elem_isVisible == false) {
289                heapBoxEl.css('display', 'none');
290            }
291
292            heapBoxHolderEl = $('<a/>', {
293                href: '',
294                'class': 'holder'
295            });
296
297            heapBoxHandlerEl = $('<a/>', {
298                href: '',
299                'class': 'handler'
300            });
301
302            heapBoxheapEl = $('<div/>', {
303                'class': 'heap'
304            });
305
306            heapBoxEl.append(heapBoxHolderEl);
307            heapBoxEl.append(heapBoxHandlerEl);
308
309            heapBoxEl.append(heapBoxheapEl);
310            this.heapBoxEl = heapBoxEl;
311            this._insertHeapbox(this.heapBoxEl);
312
313        },
314
315        /*
316         * Insert heapbox
317        */
318        _insertHeapbox: function (heapbox) {
319
320            if (this.isSourceElementSelect && this.options.insert == "inside")
321                this.options.insert = "before";
322
323            switch (this.options.insert) {
324
325                case "before":
326                    $(this.element).before(heapbox);
327                    break;
328                case "after":
329                    $(this.element).after(heapbox);
330                    break;
331                case "inside":
332                    $(this.element).html(heapbox);
333                    this._showSourceElement();
334                    break;
335                default:
336                    $(this.element).before(heapbox);
337                    break;
338            }
339        },
340
341        /*
342         * Fill heapbox with init data
343         */
344        _setDefaultValues: function () {
345            this._initHeap();
346
347            this._initView(heapBoxEl);
348            this._setHolderTitle();
349            this._setTabindex();
350            this._setEvents();
351            this._handleFirst();
352        },
353
354        _setHeapboxFocus: function () {
355            heapboxHandler = $("div#heapbox_" + this.instance.heapId);
356
357            heapboxHandler.focus();
358        },
359
360        _setHeapSize: function () {
361            if (this.options.heapsize) {
362                if (heapBoxheapEl.height() < parseInt(this.options.heapsize, 10)) {
363                    delete this.options.heapsize;
364                    return;
365                } else {
366                    heapBoxheapEl.css("height", this.options.heapsize);
367                }
368            }
369
370        },
371
372        /*
373         * Fill heapbox with init data
374         */
375        _initHeap: function () {
376
377            var initData;
378
379            if (this.isSourceElementSelect) {
380                initData = this._optionsToJson();
381                this._setData(initData);
382            }
383        },
384
385        /*
386         * Init view with right position
387         */
388        _initView: function (heapbox) {
389
390            if (this._isHeapEmpty()) {
391                return;
392            } else {
393                this._setViewPosition(heapbox);
394            }
395        },
396
397        /*
398         * Show or hide first option?
399         */
400        _handleFirst: function () {
401
402            if (!this.options.showFirst) {
403                $("div#heapbox_" + this.instance.heapId + " .heapOptions .heapOption").first().remove();
404            }
405        },
406
407        /*
408         * Set title of holder
409         */
410        _setHolderTitle: function () {
411            var self = this;
412
413            holderEl = $("#heapbox_" + this.instance.heapId).find(".holder");
414            selectedEl = $("#heapbox_" + this.instance.heapId).find(".heap ul li a.selected").last();
415
416            if (selectedEl.length != 0) {
417                if (this.options.title) {
418                    holderEl.text(this.options.title);
419                } else {
420                    holderEl.text(selectedEl.text());
421                }
422
423                holderEl.attr("rel", selectedEl.attr("rel"));
424
425                if (selectedEl.attr("data-icon-src")) {
426                    iconEl = this._createIconElement(selectedEl.attr("data-icon-src"));
427                    holderEl.append(iconEl);
428                }
429            }
430            else {
431                holderEl.text(this.options.emptyMessage);
432                this._removeHeapboxHolderEvents();
433                this._removeHeapboxHandlerEvents();
434            }
435        },
436
437        /*
438         * Set tabindex to heapbox element
439         */
440        _setTabindex: function () {
441            var tabindex;
442
443            tabindex = this.options.tabindex != "undefined" ? this.options.tabindex : $(this.element).attr("tabindex");
444
445            if (tabindex != "undefined") {
446                $("#heapbox_" + this.instance.heapId).attr("tabindex", tabindex);
447                $("#heapbox_" + this.instance.heapId + " .holder").attr("tabindex", -1);
448                $("#heapbox_" + this.instance.heapId + " .handler").attr("tabindex", -1);
449            }
450        },
451
452        /*
453         * Set data to heap
454         */
455        _setData: function (data) {
456            var self = this;
457            var _data = jQuery.parseJSON(data);
458            var selected = false;
459
460
461            // No need to refresh the Select box
462            // if(this.isSourceElementSelect) this._refreshSourceSelectbox(_data);
463
464            heapBoxheapOptionsEl = $('<ul/>', {
465                'class': 'heapOptions'
466            });
467
468            $.each(_data, function () {
469
470                if (this.selected) { selected = true; }
471                heapBoxOptionLiEl = $('<li/>', {
472                    'class': 'heapOption'
473                });
474
475                heapBoxheapOptionAEl = $('<a/>', {
476                    href: '',
477                    rel: this.value,
478                    title: this.text,
479                    text: this.text,
480                    'class': this.selected ? 'selected' : '',
481                    click: function (e) {
482                        e.preventDefault();
483                        e.stopPropagation();
484                        self._heapChanged(self, this);
485                    }
486                });
487
488                if (this.disabled) {
489                    heapBoxheapOptionAEl.unbind("click");
490                    heapBoxheapOptionAEl.addClass("disabled");
491                    heapBoxheapOptionAEl.click(function (e) {
492                        e.preventDefault();
493                        e.stopPropagation();
494                    });
495                }
496
497                if (this.icon) {
498                    heapBoxheapOptionAEl.attr('data-icon-src', this.icon);
499                    heapBoxOptionIcon = self._createIconElement(this.icon);
500
501                    heapBoxheapOptionAEl.append(heapBoxOptionIcon);
502                }
503
504                heapBoxOptionLiEl.append(heapBoxheapOptionAEl);
505                heapBoxheapOptionsEl.append(heapBoxOptionLiEl);
506            });
507
508            $("div#heapbox_" + this.instance.heapId + " .heap ul").remove();
509            $("div#heapbox_" + this.instance.heapId + " .heap").append(heapBoxheapOptionsEl);
510
511
512
513            this._setHeapSize();
514
515            if (this._isHeapsizeSet()) {
516                this._createSliderUpElement();
517                this._createSliderDownElement();
518            }
519
520            if (selected != true) {
521                $("div#heapbox_" + this.instance.heapId + " .heap ul li a").first().addClass("selected");
522            }
523
524        },
525
526        /*
527          * Create sliderUp element 
528          */
529        _createSliderUpElement: function () {
530
531            slideUp = $('<a/>', {
532                'class': 'sliderUp',
533                'href': ''
534            });
535
536            $("div#heapbox_" + this.instance.heapId + " .heap .heapOptions").before(slideUp);
537
538            sliderUp = $("#heapbox_" + this.instance.heapId + " .sliderUp");
539            this.sliderUpHeight = parseInt(sliderUp.css("height"), 10) + parseInt(sliderUp.css("border-top-width"), 10) + parseInt(sliderUp.css("border-bottom-width"), 10);
540
541            $("#heapbox_" + this.instance.heapId + " .heapOptions").css("top", this.sliderUpHeight);
542
543        },
544
545        /*
546         * Create sliderDown element 
547         */
548        _createSliderDownElement: function () {
549
550            slideDown = $('<a/>', {
551                'class': 'sliderDown',
552                'href': ''
553            });
554
555            $("div#heapbox_" + this.instance.heapId + " .heap .heapOptions").after(slideDown);
556
557            sliderDown = $("#heapbox_" + this.instance.heapId + " .sliderDown");
558            this.sliderDownHeight = parseInt(sliderDown.css("height"), 10) + parseInt(sliderDown.css("border-top-width")) + parseInt(sliderDown.css("border-bottom-width"));
559        },
560
561        /*
562         * Creat img element for icon
563         */
564        _createIconElement: function (iconSrc) {
565
566            heapBoxOptionIcon = $('<img/>', {
567                src: iconSrc,
568                alt: iconSrc
569            });
570
571            return heapBoxOptionIcon;
572        },
573
574        /*
575         * If source element is <select>, get options as json
576         */
577
578        _optionsToJson: function () {
579
580            var options = [];
581
582            $(this.element).find("option").each(function () {
583
584                options.push({
585                    'value': $(this).attr("value"),
586                    'text': $(this).text(),
587                    'icon': $(this).attr("data-icon-src"),
588                    'disabled': $(this).attr("disabled"),
589                    'selected': $(this).is(":selected") ? "selected" : ''
590                });
591
592            });
593
594            var jsonText = JSON.stringify(options);
595
596            return jsonText;
597        },
598
599        /*
600         * Get actual heapbox state as json
601         */
602        _heapboxToJson: function () {
603            var options = [];
604
605            $("div#heapbox_" + this.instance.heapId + " .heap ul li a").each(function () {
606
607                options.push({
608                    'value': $(this).attr("rel"),
609                    'text': $(this).text(),
610                    'selected': $(this).is(":selected") ? "selected" : ''
611                });
612            });
613
614            var jsonText = JSON.stringify(options);
615            return jsonText;
616        },
617        /*
618         * Check if heap is empty
619        */
620        _isHeapEmpty: function () {
621            var length = $("div#heapbox_" + this.instance.heapId + " .heap ul li").length;
622
623            return length == 0;
624        },
625
626        /*
627         * Set events for heapbox controls
628        */
629        _setControlsEvents: function () {
630
631            if (!this._isHeapEmpty()) {
632                this._setHeapboxHolderEvents();
633                this._setHeapboxHandlerEvents();
634                this._setKeyboardEvents();
635                this._setSliderEvents();
636
637                // Mouse Wheel events
638                if (typeof ($.event.special.mousewheel) == 'object') {
639                    this._setMouseWheelEvents();
640                }
641            }
642        },
643        /*
644         * Check if source element is selectbox
645         */
646        _isSourceSelectbox: function () {
647            this.isSourceElementSelect = $(this.element).is("select");
648        },
649
650        /*
651         * Check if user defined heap size
652         */
653        _isHeapsizeSet: function () {
654            return this.options.heapsize ? true : false;
655        },
656
657        /*
658         * Refresh source selectbox
659         */
660        _refreshSourceSelectbox: function (data) {
661            var self = this;
662            var selected = false;
663
664            $(this.element).find("option").remove();
665
666            $.each(data, function () {
667
668                option = $('<option/>', {
669                    value: this.value,
670                    text: this.text,
671                });
672
673                if (this.selected) {
674                    option.attr("selected", "selected");
675                    selected = true;
676                }
677
678                $(self.element).append(option);
679            });
680
681            if (selected != true) $(self.element).find("option").first().attr("selected", "selected");
682        },
683
684        /*
685         * Change selected option 
686         */
687        _setSelectedOption: function (value) {
688            var self = this;
689            this._deselectSelectedOptions();
690
691            $(this.element).val(value);
692            $(this.element).find("option[value='" + value + "']").attr("selected", "selected");
693
694        },
695
696        /*
697         * Remove selected attribute from all options in source selectbox
698         */
699        _deselectSelectedOptions: function () {
700            select = $(this.element).find("option");
701
702            select.each(function () {
703                $(this).removeAttr("selected");
704            });
705        },
706
707        /*
708         * Set events to heapbox holder control
709        */
710        _setHeapboxHolderEvents: function () {
711
712            var self = this;
713            heapBoxEl = $("div#heapbox_" + this.instance.heapId);
714
715            heapBoxEl.find(".holder").click(function (e) {
716                e.preventDefault();
717                e.stopPropagation();
718                self._setHeapboxFocus();
719                self._handlerClicked();
720            });
721        },
722
723        /*
724         * Set events to heapbox handler control
725        */
726        _setHeapboxHandlerEvents: function () {
727
728            var self = this;
729            heapBoxEl = $("div#heapbox_" + this.instance.heapId);
730
731            heapBoxEl.find(".handler").click(function (e) {
732                e.preventDefault();
733                e.stopPropagation();
734                //$(this).focus();
735                self._setHeapboxFocus();
736                self._handlerClicked();
737            });
738        },
739
740        /*
741         * Remove events from heapbox holder control
742        */
743        _removeHeapboxHolderEvents: function () {
744
745            var self = this;
746            heapBoxEl = $("div#heapbox_" + this.instance.heapId);
747
748            heapBoxEl.find(".holder").unbind('click');
749            heapBoxEl.find(".holder").click(function (e) { e.preventDefault(); })
750            heapBoxEl.unbind("keydown");
751
752        },
753
754        /*
755         * Remove events from heapbox handler control
756        */
757        _removeHeapboxHandlerEvents: function () {
758
759            var self = this;
760            heapBoxEl = $("div#heapbox_" + this.instance.heapId);
761
762            heapBoxEl.find(".handler").unbind('click');
763            heapBoxEl.find(".handler").click(function (e) { e.preventDefault(); })
764        },
765
766        /*
767         * Selectbox open-close handler
768        */
769        _handlerClicked: function (stageReady) {
770
771            if (this.instance.state) {
772                this._closeheap();
773            }
774            else {
775                if (!stageReady)
776                    this._closeOthers();
777                else this._openheap();
778            }
779        },
780
781        /*
782         * Selectbox change handler
783        */
784        _heapChanged: function (self, clickedEl, keepOpened) {
785
786            if (!keepOpened) this._closeheap(true, function () { }, function () { });
787            this._setSelected($(clickedEl));
788            this._setHolderTitle();
789            this._setHeapboxFocus();
790            this._setSelectedOption($(clickedEl).attr("rel"));
791
792            this.options.onChange($(clickedEl).attr("rel"), $(this.element));
793
794        },
795
796
797        /*
798         * Add class "selected" to selected option in heapbox
799         */
800        _setSelected: function (selectedEl) {
801            this._deselectAll();
802            selectedEl.addClass("selected");
803        },
804
805        _deselectAll: function (self) {
806            heapLinks = $("#heapbox_" + this.instance.heapId).find(".heap ul li a");
807            heapLinks.each(function () {
808                $(this).removeClass("selected");
809            });
810        },
811
812        /*
813         * Close opened selectbox
814        */
815        _closeheap: function (internal, closeStartEvent, closeCompleteEvent) {
816
817            heapEl = $("#heapbox_" + this.instance.heapId).removeClass('open').find(".heap");
818            if (heapEl.is(":animated") && !internal) return false;
819            this.instance.state = false;
820
821            if (internal) {
822                closeStartEvent = closeStartEvent;
823                closeCompleteEvent = closeCompleteEvent;
824            } else {
825                closeStartEvent = this.options.closeStart;
826                closeCompleteEvent = this.options.closeComplete;
827            }
828
829            closeStartEvent.call();
830
831            switch (this.options.effect.type) {
832
833                case "fade":
834                    heapEl.fadeOut(this.options.effect.speed, closeCompleteEvent);
835                    break;
836                case "slide":
837
838                    heapEl.slideUp(this.options.effect.speed, closeCompleteEvent);
839                    break;
840                case "standard":
841                    heapEl.css("display", "none");
842                    closeCompleteEvent.call();
843                    break;
844                default:
845                    heapEl.slideUp(this.options.effect.speed, closeCompleteEvent);
846                    break;
847
848            }
849        },
850
851        /*
852         * Open selectbox
853        */
854        _openheap: function () {
855
856            if (this._isHeapsizeSet()) {
857                this._setViewPosition($("div#heapbox_" + this.instance.heapId));
858            }
859
860            heapEl = $("#heapbox_" + this.instance.heapId).addClass('open').find(".heap");
861            if (heapEl.is(":animated")) return false;
862            this.instance.state = true;
863
864            this.options.openStart.call();
865
866            switch (this.options.effect.type) {
867
868                case "fade":
869                    heapEl.fadeIn(this.options.effect.speed, this.options.openComplete);
870                    break;
871                case "slide":
872                    heapEl.slideDown(this.options.effect.speed, this.options.openComplete);
873                    break;
874                case "standard":
875                    heapEl.css("display", "block");
876                    this.options.openComplete.call();
877                    break;
878                default:
879                    heapEl.slideDown(this.options.effect.speed, this.options.openComplete);
880                    break;
881            }
882        },
883
884        /*
885         * Close other selectboxes
886        */
887        _closeOthers: function () {
888
889            var self = this;
890
891            $('div[id^=heapbox_]').each(function (index) {
892
893                el = $("div#" + $(this).attr("id"));
894
895                if (el.data("sourceElement")) {
896                    sourceEl = $.data(this, "sourceElement");
897                    heapBoxInst = $.data(sourceEl, "plugin_" + pluginName);
898
899                    if (self.instance.heapId != heapBoxInst.instance.heapId) {
900                        if (heapBoxInst.instance.state) {
901                            self._callbackManager('change', '_closeOthers', true);
902                            heapBoxInst._closeheap(true, function () { }, function () { self._callbackManager('change', '_closeOthers', false); });
903                        }
904                    }
905                }
906            });
907
908            self._callbackManager('test', '_closeOthers');
909        },
910
911        /*
912         * Manager of callback queue
913        */
914        _callbackManager: function (type, identificator, state) {
915            if (!this.callbackManager[identificator])
916                this.callbackManager[identificator] = 0;
917
918            if (type == "change") {
919                state ? this.callbackManager[identificator]++ : this.callbackManager[identificator]--;
920                this._callbackManager('test', identificator);
921
922            } else if (type == "test") {
923                if (this.callbackManager[identificator] == 0) this._handlerClicked(true);
924            }
925        },
926
927        /*
928         * Set own data to heap 
929         */
930        set: function (data) {
931            this._setData(data);
932            this._setHolderTitle();
933            this._setEvents();
934        },
935
936        select: function (value) {
937            heapBoxEl = $("div#heapbox_" + this.instance.heapId);
938            this._heapChanged(this, heapBoxEl.find('.heapOptions [rel="' + value + '"]'));
939        },
940        update: function () {
941            this._setDefaultValues();
942        },
943        _hideSourceElement: function () {
944
945            // preserve original visibility of the element
946            this.elem_isVisible = $(this.element).is(':visible');
947            $(this.element).css("display", "none");
948        },
949        _showSourceElement: function () {
950            $(this.element).css("display", "block");
951        },
952        hide: function () {
953            $("div#heapbox_" + this.instance.heapId).css("visibility", "hidden");
954        },
955        show: function () {
956            $("div#heapbox_" + this.instance.heapId).css("visibility", "visible");
957        },
958        disable: function () {
959            heapBoxEl = $("div#heapbox_" + this.instance.heapId);
960            heapBoxEl.addClass("disabled");
961
962            this._removeHeapboxHandlerEvents();
963            this._removeHeapboxHolderEvents();
964
965            return this;
966        },
967        enable: function () {
968            heapBoxEl = $("div#heapbox_" + this.instance.heapId);
969            heapBoxEl.removeClass("disabled");
970            this._setEvents();
971
972            return this;
973        },
974        _remove: function () {
975            heapBoxEl = $("div#heapbox_" + this.instance.heapId);
976            heapBoxEl.remove();
977
978            this._showSourceElement();
979        }
980    };
981
982    $.fn[pluginName] = function (options, optional) {
983
984        return this.each(function () {
985
986            if (!$.data(this, "plugin_" + pluginName)) {
987                $.data(this, "plugin_" + pluginName, new Plugin(this, options));
988            }
989            else {
990                heapBoxInst = $.data(this, "plugin_" + pluginName);
991
992                switch (options) {
993                    case "select":
994                        heapBoxInst.select(optional);
995                        break;
996                    case "update":
997                        heapBoxInst.update();
998                        break;
999                    case "set":
1000                        heapBoxInst.set(optional);
1001                        break;
1002                    case "hide":
1003                        heapBoxInst.hide();
1004                        break;
1005                    case "show":
1006                        heapBoxInst.show();
1007                        break;
1008                    case "disable":
1009                        heapBoxInst.disable();
1010                        break;
1011                    case "enable":
1012                        heapBoxInst.enable();
1013                        break;
1014                    case "remove":
1015                        heapBoxInst._remove();
1016                        break;
1017                }
1018
1019            }
1020        });
1021    };
1022
1023})(jQuery, window, document);

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.