From 3387e0a3bf6c304f9e295a996e19924fdda78763 Mon Sep 17 00:00:00 2001 From: Greg Franko Date: Fri, 22 Mar 2013 22:41:48 -0400 Subject: [PATCH] Fixed disabled and enabled bugs --- src/javascripts/jquery.selectBoxIt.disable.js | 6 ++--- src/javascripts/jquery.selectBoxIt.enable.js | 10 ++++---- src/javascripts/jquery.selectBoxIt.js | 23 ++++++++++--------- src/javascripts/jquery.selectBoxIt.min.js | 4 ++-- .../jquery.selectBoxIt.selectOption.js | 7 +++--- 5 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/javascripts/jquery.selectBoxIt.disable.js b/src/javascripts/jquery.selectBoxIt.disable.js index a32842d..09e85b9 100755 --- a/src/javascripts/jquery.selectBoxIt.disable.js +++ b/src/javascripts/jquery.selectBoxIt.disable.js @@ -22,7 +22,7 @@ self.dropdown.removeAttr("tabindex"). // Enabled styling for disabled state - addClass("selectboxit-disabled"); + addClass(self.theme["disabled"]); // Calls the jQueryUI Widget Factory disable method to make sure all options are correctly synced $.Widget.prototype.disable.call(self); @@ -46,10 +46,10 @@ selectBoxIt.disableOption = function(index, callback) { - var self = this, currentSelectBoxOption, hasNextEnabled, hasPreviousEnabled; + var self = this, currentSelectBoxOption, hasNextEnabled, hasPreviousEnabled, type = $.type(index); // If an index is passed to target an indropdownidual drop down option - if((typeof index).toLowerCase() === "number") { + if(type === "number") { // Makes sure the dropdown list is closed self.close(); diff --git a/src/javascripts/jquery.selectBoxIt.enable.js b/src/javascripts/jquery.selectBoxIt.enable.js index 2ee6ee8..6c6cc33 100755 --- a/src/javascripts/jquery.selectBoxIt.enable.js +++ b/src/javascripts/jquery.selectBoxIt.enable.js @@ -22,8 +22,8 @@ self.dropdown.attr("tabindex", 0). // Disable styling for disabled state - removeClass(self.disabledClasses); - + removeClass(self.theme["disabled"]); + $.Widget.prototype.enable.call(self); // Provide callback function support @@ -42,10 +42,10 @@ selectBoxIt.enableOption = function(index, callback) { - var self = this, currentSelectBoxOption, currentIndex = 0, hasNextEnabled, hasPreviousEnabled; + var self = this, currentSelectBoxOption, currentIndex = 0, hasNextEnabled, hasPreviousEnabled, type = $.type(index); // If an index is passed to target an indropdownidual drop down option - if((typeof index).toLowerCase() === "number") { + if(type === "number") { // The select box option being targeted currentSelectBoxOption = self.selectBox.find("option").eq(index); @@ -60,7 +60,7 @@ self.listItems.eq(index).attr("data-disabled", "false"). // Applies disabled styling for the drop down option - removeClass(self.disabledClasses); + removeClass(self.theme["disabled"]); } diff --git a/src/javascripts/jquery.selectBoxIt.js b/src/javascripts/jquery.selectBoxIt.js index 87ca555..13ddd79 100755 --- a/src/javascripts/jquery.selectBoxIt.js +++ b/src/javascripts/jquery.selectBoxIt.js @@ -1944,7 +1944,7 @@ self.dropdown.removeAttr("tabindex"). // Enabled styling for disabled state - addClass("selectboxit-disabled"); + addClass(self.theme["disabled"]); // Calls the jQueryUI Widget Factory disable method to make sure all options are correctly synced $.Widget.prototype.disable.call(self); @@ -1968,10 +1968,10 @@ selectBoxIt.disableOption = function(index, callback) { - var self = this, currentSelectBoxOption, hasNextEnabled, hasPreviousEnabled; + var self = this, currentSelectBoxOption, hasNextEnabled, hasPreviousEnabled, type = $.type(index); // If an index is passed to target an indropdownidual drop down option - if((typeof index).toLowerCase() === "number") { + if(type === "number") { // Makes sure the dropdown list is closed self.close(); @@ -2168,8 +2168,8 @@ self.dropdown.attr("tabindex", 0). // Disable styling for disabled state - removeClass(self.disabledClasses); - + removeClass(self.theme["disabled"]); + $.Widget.prototype.enable.call(self); // Provide callback function support @@ -2188,10 +2188,10 @@ selectBoxIt.enableOption = function(index, callback) { - var self = this, currentSelectBoxOption, currentIndex = 0, hasNextEnabled, hasPreviousEnabled; + var self = this, currentSelectBoxOption, currentIndex = 0, hasNextEnabled, hasPreviousEnabled, type = $.type(index); // If an index is passed to target an indropdownidual drop down option - if((typeof index).toLowerCase() === "number") { + if(type === "number") { // The select box option being targeted currentSelectBoxOption = self.selectBox.find("option").eq(index); @@ -2206,7 +2206,7 @@ self.listItems.eq(index).attr("data-disabled", "false"). // Applies disabled styling for the drop down option - removeClass(self.disabledClasses); + removeClass(self.theme["disabled"]); } @@ -2670,17 +2670,18 @@ selectBoxIt.selectOption = function(val, callback) { // Stores the plugin context inside of the self variable - var self = this; + var self = this, + type = $.type(val); // Makes sure the passed in position is a number - if((typeof val).toLowerCase() === "number") { + if(type === "number") { // Set's the original select box value and triggers the change event (which SelectBoxIt listens for) self.selectBox.val(self.selectBox.find("option").eq(val).val()).change(); } - else if((typeof val).toLowerCase() === "string") { + else if(type === "string") { // Set's the original select box value and triggers the change event (which SelectBoxIt listens for) self.selectBox.val(val).change(); diff --git a/src/javascripts/jquery.selectBoxIt.min.js b/src/javascripts/jquery.selectBoxIt.min.js index 712d2ae..0a57385 100755 --- a/src/javascripts/jquery.selectBoxIt.min.js +++ b/src/javascripts/jquery.selectBoxIt.min.js @@ -1,4 +1,4 @@ -/*! jquery Selectboxit - v3.3.0 - 2013-03-19 +/*! jquery Selectboxit - v3.3.0 - 2013-03-22 * http://www.selectboxit.com * Copyright (c) 2013 Greg Franko; Licensed MIT */ -(function(e){"use strict";e(window.jQuery,window,document)})(function(e,t,n,r){"use strict";e.widget("selectBox.selectBoxIt",{VERSION:"3.3.0",options:{showEffect:"none",showEffectOptions:{},showEffectSpeed:"medium",hideEffect:"none",hideEffectOptions:{},hideEffectSpeed:"medium",showFirstOption:!0,defaultText:"",defaultIcon:"",downArrowIcon:"",theme:"default",keydownOpen:!0,isMobile:function(){var e=navigator.userAgent||navigator.vendor||t.opera;return/iPhone|iPod|iPad|Android|BlackBerry|Opera Mini|IEMobile/.test(e)},"native":!1,aggressiveChange:!1,selectWhenHidden:!0,viewport:e(t),similarSearch:!1,copyAttributes:["title","rel"],copyClasses:"button",nativeMousedown:!1,customShowHideEvent:!1,autoWidth:!0,html:!0},getThemes:function(){var t=this,n=e(t.element).attr("data-theme")||"c";return{bootstrap:{focus:"active",hover:"",disabled:"disabled",arrow:"caret",button:"btn",list:"dropdown-menu",container:"bootstrap",open:"open"},jqueryui:{focus:"ui-state-focus",hover:"ui-state-hover",disabled:"ui-state-disabled",arrow:"ui-icon ui-icon-triangle-1-s",button:"ui-widget ui-state-default",list:"ui-widget ui-widget-content",container:"jqueryui",open:"selectboxit-open"},jquerymobile:{focus:"ui-btn-down-"+n,hover:"ui-btn-hover-"+n,disabled:"ui-disabled",arrow:"ui-icon ui-icon-arrow-d ui-icon-shadow",button:"ui-btn ui-btn-icon-right ui-btn-corner-all ui-shadow ui-btn-up-"+n,list:"ui-btn ui-btn-icon-right ui-btn-corner-all ui-shadow ui-btn-up-"+n,container:"jquerymobile",open:"selectboxit-open"},"default":{focus:"selectboxit-focus",hover:"selectboxit-hover",disabled:"selectboxit-disabled",arrow:"selectboxit-default-arrow",button:"selectboxit-btn",list:"selectboxit-list",container:"selectboxit-container",open:"selectboxit-open"}}},_create:function(){var t=this;if(!t.element.is("select"))return;return t.element.hide(),t.originalElem=t.element[0],t.selectBox=t.element,t.selectItems=t.element.find("option"),t.firstSelectItem=t.selectItems.slice(0,1),t.documentHeight=e(n).height(),t.theme=t.getThemes()[t.options.theme]||t.getThemes()["default"],t.currentFocus=0,t.blur=!0,t.textArray=[],t.currentIndex=0,t.currentText="",t.flipped=!1,t._createDropdownButton()._createUnorderedList()._copyAttributes()._replaceSelectBox()._addClasses(t.theme)._eventHandlers(),t.originalElem.disabled&&t.disable&&t.disable(),t._ariaAccessibility&&t._ariaAccessibility(),t._mobile&&t._mobile(),t.options["native"]&&this._applyNativeSelect(),t.triggerEvent("create"),t},_createDropdownButton:function(){var t=this,n=t.originalElem.id||"",r=t.options.copyClasses,i=t.selectBox.attr("class")||"";return t.dropdownText=e("",{id:n&&n+"SelectBoxItText","class":"selectboxit-text",unselectable:"on",text:t.firstSelectItem.text()}).attr("data-val",t.originalElem.value),t.dropdownImageContainer=e("",{"class":"selectboxit-option-icon-container"}),t.dropdownImage=e("",{id:n&&n+"SelectBoxItDefaultIcon","class":"selectboxit-default-icon",unselectable:"on"}),t.dropdown=e("",{id:n&&n+"SelectBoxIt","class":"selectboxit "+(r==="button"?i:""),name:t.originalElem.name,tabindex:t.selectBox.attr("tabindex")||"0",unselectable:"on"}).append(t.dropdownImageContainer.append(t.dropdownImage)).append(t.dropdownText),t.dropdownContainer=e("",{id:n&&n+"SelectBoxItContainer","class":"selectboxit-container "+(r==="container"?i:"")}).append(t.dropdown),t},_createUnorderedList:function(){var t=this,n,r,i,s,o,u,a,f="",l=t.originalElem.id||"",c=e("
    ",{id:l&&l+"SelectBoxItOptions","class":"selectboxit-options",tabindex:-1}),h,p;t.options.showFirstOption||(t.selectItems=t.selectBox.find("option").slice(1)),t.selectItems.each(function(l){r="",i="",n=e(this).prop("disabled"),s=e(this).data("icon")||"",o=e(this).data("iconurl")||"",u=o?"selectboxit-option-icon-url":"",a=o?"style=\"background-image:url('"+o+"');\"":"",h=e(this).attr("data-text"),p=h?h:e(this).text(),e(this).parent().is("optgroup")&&(r="selectboxit-optgroup-option",e(this).index()===0&&(i=''+e(this).parent().first().attr("label")+"")),f+=i+'
  • "+(t.options.html?p:t.htmlEscape(p))+"
  • ",t.textArray[l]=n?"":p,this.selected&&(t._setText(t.dropdownText,p),t.currentFocus=l)});if((t.options.defaultText||t.selectBox.data("text"))&&!t.selectBox.find("option[selected]").length){var d=t.options.defaultText||t.selectBox.data("text");t._setText(t.dropdownText,d),t.options.defaultText=d}return c.append(f),t.list=c,t.dropdownContainer.append(t.list),t.listItems=t.list.find("li"),t.listItems.first().addClass("selectboxit-option-first"),t.listItems.last().addClass("selectboxit-option-last"),t.list.find("li[data-disabled='true']").not(".optgroupHeader").addClass(t.theme.disabled),t.dropdownImage.addClass(t.selectBox.data("icon")||t.options.defaultIcon||t.listItems.eq(t.currentFocus).find("i").attr("class")),t.dropdownImage.attr("style",t.listItems.eq(t.currentFocus).find("i").attr("style")),t},_replaceSelectBox:function(){var t=this,n,r=t.originalElem.id||"";return t.selectBox.css("display","none").after(t.dropdownContainer),n=t.dropdown.height(),t.downArrow=e("",{id:r&&r+"SelectBoxItArrow","class":"selectboxit-arrow",unselectable:"on"}),t.downArrowContainer=e("",{id:r&&r+"SelectBoxItArrowContainer","class":"selectboxit-arrow-container",unselectable:"on"}).append(t.downArrow),t.dropdown.append(t.downArrowContainer),t.listItems.removeClass("selectboxit-selected").eq(t.currentFocus).addClass("selectboxit-selected"),t.dropdownImageContainer.width()||t.dropdownImageContainer.remove(),t.options.autoWidth&&t.dropdown.css({width:"auto"}).css({width:t.list.outerWidth(!0)+t.downArrowContainer.outerWidth(!0)+t.dropdownImage.outerWidth(!0)}),t.dropdownText.css({"max-width":t.dropdownContainer.width()-(t.downArrowContainer.outerWidth(!0)+t.dropdownImage.outerWidth(!0))}),t},_scrollToView:function(e){var t=this,n=t.listItems.eq(t.currentFocus),r=t.list.scrollTop(),i=n.height(),s=n.position().top,o=Math.abs(s),u=t.list.height(),a;return e==="search"?u-s/g,">")},triggerEvent:function(e){var t=this,n=t.options.showFirstOption?t.currentFocus:t.currentFocus-1>=0?t.currentFocus:0;return t.selectBox.trigger(e,{elem:t.selectBox.eq(n),"dropdown-elem":t.listItems.eq(t.currentFocus)}),t},_copyAttributes:function(){var e=this;return e._addSelectBoxAttributes&&e._addSelectBoxAttributes(),e}});var i=e.selectBox.selectBoxIt.prototype;i._ariaAccessibility=function(){var t=this;return t.dropdown.attr({role:"combobox","aria-autocomplete":"list","aria-expanded":"false","aria-owns":t.list.attr("id"),"aria-activedescendant":t.listItems.eq(t.currentFocus).attr("id"),"aria-label":e("label[for='"+t.originalElem.id+"']").text()||"","aria-live":"assertive"}).bind({"disable.selectBoxIt":function(){t.dropdown.attr("aria-disabled","true")},"enable.selectBoxIt":function(){t.dropdown.attr("aria-disabled","false")}}),t.list.attr({role:"listbox","aria-hidden":"true"}),t.listItems.attr({role:"option"}),t.selectBox.bind({"change.selectBoxIt":function(){t.dropdownText.attr("aria-label",t.originalElem.value)},"open.selectBoxIt":function(){t.list.attr("aria-hidden","false"),t.dropdown.attr("aria-expanded","true")},"close.selectBoxIt":function(){t.list.attr("aria-hidden","true"),t.dropdown.attr("aria-expanded","false")}}),t},i._addSelectBoxAttributes=function(){var t=this;return t._addAttributes(t.selectBox.prop("attributes"),t.dropdown),t.selectItems.each(function(n){t._addAttributes(e(this).prop("attributes"),t.listItems.eq(n))}),t},e.selectBox.selectBoxIt.prototype._addAttributes=function(t,n){var r=this,i=r.options.copyAttributes;return t.length&&e.each(t,function(t,r){var s=r.name.toLowerCase(),o=r.value;o!=="null"&&(e.inArray(s,i)!==-1||s.indexOf("data")!==-1)&&n.attr(s,o)}),r},i.destroy=function(t){var n=this;return n._destroySelectBoxIt(),e.Widget.prototype.destroy.call(n),n._callbackSupport(t),n},i._destroySelectBoxIt=function(){var t=this;return t.dropdown.unbind(".selectBoxIt").undelegate(".selectBoxIt"),e.contains(t.dropdownContainer[0],t.originalElem)&&t.dropdownContainer.before(t.selectBox),t.dropdownContainer.remove(),t.selectBox.removeAttr("style").show(),t.triggerEvent("destroy"),t},i.disable=function(t){var n=this;return n.options.disabled||(n.close(),n.selectBox.attr("disabled","disabled"),n.dropdown.removeAttr("tabindex").addClass("selectboxit-disabled"),e.Widget.prototype.disable.call(n),n.triggerEvent("disable")),n._callbackSupport(t),n},i.disableOption=function(e,t){var n=this,r,i,s;return(typeof e).toLowerCase()==="number"&&(n.close(),r=n.selectBox.find("option").eq(e),n.triggerEvent("disable-option"),r.attr("disabled","disabled"),n.listItems.eq(e).attr("data-disabled","true").addClass(n.theme.disabled),n.currentFocus===e&&(i=n.listItems.eq(n.currentFocus).nextAll("li").not("[data-disabled='true']").first().length,s=n.listItems.eq(n.currentFocus).prevAll("li").not("[data-disabled='true']").first().length,i?n.moveDown():s?n.moveUp():n.disable())),n._callbackSupport(t),n},i._isDisabled=function(e){var t=this;return t.originalElem.disabled&&t.disable(),t},i._dynamicPositioning=function(){var t=this,n=t.dropdown.offset().top,r=t.list.data("max-height")||t.list.outerHeight(),i=t.dropdown.outerHeight(),s=t.options.viewport,o=s.height(),u=e.isWindow(s.get(0))?s.scrollTop():s.offset().top,a=n+i+r<=o+u,f=!a;t.list.data("max-height")||t.list.data("max-height",t.list.outerHeight());if(!f)t.list.css("max-height",r),t.list.css("top","auto");else if(t.dropdown.offset().top-u>=r)t.list.css("max-height",r),t.list.css("top",t.dropdown.position().top-t.list.outerHeight());else{var l=Math.abs(n+i+r-(o+u)),c=Math.abs(t.dropdown.offset().top-u-r);l",{id:n&&n+"SelectBoxItText","class":"selectboxit-text",unselectable:"on",text:t.firstSelectItem.text()}).attr("data-val",t.originalElem.value),t.dropdownImageContainer=e("",{"class":"selectboxit-option-icon-container"}),t.dropdownImage=e("",{id:n&&n+"SelectBoxItDefaultIcon","class":"selectboxit-default-icon",unselectable:"on"}),t.dropdown=e("",{id:n&&n+"SelectBoxIt","class":"selectboxit "+(r==="button"?i:""),name:t.originalElem.name,tabindex:t.selectBox.attr("tabindex")||"0",unselectable:"on"}).append(t.dropdownImageContainer.append(t.dropdownImage)).append(t.dropdownText),t.dropdownContainer=e("",{id:n&&n+"SelectBoxItContainer","class":"selectboxit-container "+(r==="container"?i:"")}).append(t.dropdown),t},_createUnorderedList:function(){var t=this,n,r,i,s,o,u,a,f="",l=t.originalElem.id||"",c=e("
      ",{id:l&&l+"SelectBoxItOptions","class":"selectboxit-options",tabindex:-1}),h,p;t.options.showFirstOption||(t.selectItems=t.selectBox.find("option").slice(1)),t.selectItems.each(function(l){r="",i="",n=e(this).prop("disabled"),s=e(this).data("icon")||"",o=e(this).data("iconurl")||"",u=o?"selectboxit-option-icon-url":"",a=o?"style=\"background-image:url('"+o+"');\"":"",h=e(this).attr("data-text"),p=h?h:e(this).text(),e(this).parent().is("optgroup")&&(r="selectboxit-optgroup-option",e(this).index()===0&&(i=''+e(this).parent().first().attr("label")+"")),f+=i+'
    • "+(t.options.html?p:t.htmlEscape(p))+"
    • ",t.textArray[l]=n?"":p,this.selected&&(t._setText(t.dropdownText,p),t.currentFocus=l)});if((t.options.defaultText||t.selectBox.data("text"))&&!t.selectBox.find("option[selected]").length){var d=t.options.defaultText||t.selectBox.data("text");t._setText(t.dropdownText,d),t.options.defaultText=d}return c.append(f),t.list=c,t.dropdownContainer.append(t.list),t.listItems=t.list.find("li"),t.listItems.first().addClass("selectboxit-option-first"),t.listItems.last().addClass("selectboxit-option-last"),t.list.find("li[data-disabled='true']").not(".optgroupHeader").addClass(t.theme.disabled),t.dropdownImage.addClass(t.selectBox.data("icon")||t.options.defaultIcon||t.listItems.eq(t.currentFocus).find("i").attr("class")),t.dropdownImage.attr("style",t.listItems.eq(t.currentFocus).find("i").attr("style")),t},_replaceSelectBox:function(){var t=this,n,r=t.originalElem.id||"";return t.selectBox.css("display","none").after(t.dropdownContainer),n=t.dropdown.height(),t.downArrow=e("",{id:r&&r+"SelectBoxItArrow","class":"selectboxit-arrow",unselectable:"on"}),t.downArrowContainer=e("",{id:r&&r+"SelectBoxItArrowContainer","class":"selectboxit-arrow-container",unselectable:"on"}).append(t.downArrow),t.dropdown.append(t.downArrowContainer),t.listItems.removeClass("selectboxit-selected").eq(t.currentFocus).addClass("selectboxit-selected"),t.dropdownImageContainer.width()||t.dropdownImageContainer.remove(),t.options.autoWidth&&t.dropdown.css({width:"auto"}).css({width:t.list.outerWidth(!0)+t.downArrowContainer.outerWidth(!0)+t.dropdownImage.outerWidth(!0)}),t.dropdownText.css({"max-width":t.dropdownContainer.width()-(t.downArrowContainer.outerWidth(!0)+t.dropdownImage.outerWidth(!0))}),t},_scrollToView:function(e){var t=this,n=t.listItems.eq(t.currentFocus),r=t.list.scrollTop(),i=n.height(),s=n.position().top,o=Math.abs(s),u=t.list.height(),a;return e==="search"?u-s/g,">")},triggerEvent:function(e){var t=this,n=t.options.showFirstOption?t.currentFocus:t.currentFocus-1>=0?t.currentFocus:0;return t.selectBox.trigger(e,{elem:t.selectBox.eq(n),"dropdown-elem":t.listItems.eq(t.currentFocus)}),t},_copyAttributes:function(){var e=this;return e._addSelectBoxAttributes&&e._addSelectBoxAttributes(),e}});var i=e.selectBox.selectBoxIt.prototype;i._ariaAccessibility=function(){var t=this;return t.dropdown.attr({role:"combobox","aria-autocomplete":"list","aria-expanded":"false","aria-owns":t.list.attr("id"),"aria-activedescendant":t.listItems.eq(t.currentFocus).attr("id"),"aria-label":e("label[for='"+t.originalElem.id+"']").text()||"","aria-live":"assertive"}).bind({"disable.selectBoxIt":function(){t.dropdown.attr("aria-disabled","true")},"enable.selectBoxIt":function(){t.dropdown.attr("aria-disabled","false")}}),t.list.attr({role:"listbox","aria-hidden":"true"}),t.listItems.attr({role:"option"}),t.selectBox.bind({"change.selectBoxIt":function(){t.dropdownText.attr("aria-label",t.originalElem.value)},"open.selectBoxIt":function(){t.list.attr("aria-hidden","false"),t.dropdown.attr("aria-expanded","true")},"close.selectBoxIt":function(){t.list.attr("aria-hidden","true"),t.dropdown.attr("aria-expanded","false")}}),t},i._addSelectBoxAttributes=function(){var t=this;return t._addAttributes(t.selectBox.prop("attributes"),t.dropdown),t.selectItems.each(function(n){t._addAttributes(e(this).prop("attributes"),t.listItems.eq(n))}),t},e.selectBox.selectBoxIt.prototype._addAttributes=function(t,n){var r=this,i=r.options.copyAttributes;return t.length&&e.each(t,function(t,r){var s=r.name.toLowerCase(),o=r.value;o!=="null"&&(e.inArray(s,i)!==-1||s.indexOf("data")!==-1)&&n.attr(s,o)}),r},i.destroy=function(t){var n=this;return n._destroySelectBoxIt(),e.Widget.prototype.destroy.call(n),n._callbackSupport(t),n},i._destroySelectBoxIt=function(){var t=this;return t.dropdown.unbind(".selectBoxIt").undelegate(".selectBoxIt"),e.contains(t.dropdownContainer[0],t.originalElem)&&t.dropdownContainer.before(t.selectBox),t.dropdownContainer.remove(),t.selectBox.removeAttr("style").show(),t.triggerEvent("destroy"),t},i.disable=function(t){var n=this;return n.options.disabled||(n.close(),n.selectBox.attr("disabled","disabled"),n.dropdown.removeAttr("tabindex").addClass(n.theme.disabled),e.Widget.prototype.disable.call(n),n.triggerEvent("disable")),n._callbackSupport(t),n},i.disableOption=function(t,n){var r=this,i,s,o,u=e.type(t);return u==="number"&&(r.close(),i=r.selectBox.find("option").eq(t),r.triggerEvent("disable-option"),i.attr("disabled","disabled"),r.listItems.eq(t).attr("data-disabled","true").addClass(r.theme.disabled),r.currentFocus===t&&(s=r.listItems.eq(r.currentFocus).nextAll("li").not("[data-disabled='true']").first().length,o=r.listItems.eq(r.currentFocus).prevAll("li").not("[data-disabled='true']").first().length,s?r.moveDown():o?r.moveUp():r.disable())),r._callbackSupport(n),r},i._isDisabled=function(e){var t=this;return t.originalElem.disabled&&t.disable(),t},i._dynamicPositioning=function(){var t=this,n=t.dropdown.offset().top,r=t.list.data("max-height")||t.list.outerHeight(),i=t.dropdown.outerHeight(),s=t.options.viewport,o=s.height(),u=e.isWindow(s.get(0))?s.scrollTop():s.offset().top,a=n+i+r<=o+u,f=!a;t.list.data("max-height")||t.list.data("max-height",t.list.outerHeight());if(!f)t.list.css("max-height",r),t.list.css("top","auto");else if(t.dropdown.offset().top-u>=r)t.list.css("max-height",r),t.list.css("top",t.dropdown.position().top-t.list.outerHeight());else{var l=Math.abs(n+i+r-(o+u)),c=Math.abs(t.dropdown.offset().top-u-r);l