www-thermferm/jqwidgets/jqxnavbar.js

Sun, 07 Jul 2019 14:31:10 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 07 Jul 2019 14:31:10 +0200
branch
stable
changeset 603
fcff55324b84
parent 511
2d1d43c3a2c2
child 617
b216f9d4b917
permissions
-rw-r--r--

Merged fix from default

/*
jQWidgets v4.5.2 (2017-May)
Copyright (c) 2011-2017 jQWidgets.
License: http://jqwidgets.com/license/
*/
!function(a){a.jqx.jqxWidget("jqxNavBar","",{}),a.extend(a.jqx._jqxNavBar.prototype,{defineInstance:function(){var b={height:"auto",minimizedHeight:30,popupAnimationDelay:250,minimizeButtonPosition:"left",width:"100%",selectedItem:0,selection:!0,disabled:!1,rtl:!1,minimized:!1,columns:null,minimizedTitle:"",orientation:"horizontal",events:["change"]};return this===a.jqx._jqxNavBar.prototype?b:(a.extend(!0,this,b),b)},createInstance:function(a){this.render()},render:function(){var b=this;b.ul&&b.ul.parent()[0]!==b.element&&(b.ul.detach(),b.host.children().remove(),b.host.append(b.ul),b.popup&&b.popup.remove(),b.host.height(null),b.host.removeClass(b.toThemeProperty("jqx-widget-header")),b.host.removeClass(b.toThemeProperty("jqx-navbar-minimized"))),b.ul=b.host.children(),b._items=b.ul.children(),a.each(b._items,function(){a(this).removeClass()}),null!==this.width&&(this.width.toString().indexOf("%")>=0||this.width.toString().indexOf("px")>=0)?this.element.style.width=this.width:this.element.style.width=this.width+"px",b._layoutItems(),b._addClasses(),b._addHandlers(),b._handleMinimize(),a.jqx.utilities.resize(this.host,function(){b._resizePopup()})},_layoutItems:function(){var b=this,c=1,d=0,e=null===this.height||"auto"===this.height;if("horizontal"===b.orientation){if(b._items.length>5){var f="50%";b._items.css("width",f);var g=b.height;if(c=Math.ceil(b._items.length/2),!e){var h,i=!1;g.toString().indexOf("%")>=0?(h=parseInt(g)/c,h+="%",i=!0):h=parseInt(g)/c,d=2,i?(b._items.css("height",h),b._items.css("line-height",b._items.height()+"px")):(b._items.height(h),b._items.css("line-height",h+"px"))}}else{var f=b.host.width/2,j=b._items.length,f=100/j+"%";b._items.css("width",f),e||(b.height.toString().indexOf("%")>=0?(b._items.css("height",h),b._items.css("line-height",b.height)):(b._items.height(b.height),b._items.css("line-height",parseInt(b.height)+"px"))),d=j}if(b.columns){for(var g=b.height,k=0,l=0;l<b._items.length;l++){var m=b._items[l];a(m).css("width",b.columns[k]),k++,k>=b.columns.length&&(k=0,b.columns.length!==b._items.length&&c++)}var h,i=!1;g.toString().indexOf("%")>=0?(h=parseInt(g)/c,h+="%",i=!0):h=parseInt(g)/c,e||(i?(b._items.css("height",h),b._items.css("line-height",b._items.height()+"px")):(b._items.height(h),b._items.css("line-height",h+"px"))),d=b.columns.length}}else{for(var g=b.height,k=0,l=0;l<b._items.length;l++){var m=b._items[l];a(m).css("width","100%")}if(c=b._items.length,!e){var h,i=!1;g.toString().indexOf("%")>=0?(h=parseInt(g)/c,h+="%",i=!0):h=parseInt(g)/c,i?(b._items.css("height",h),b._items.css("line-height",b._items.height()+"px")):(b._items.height(h),b._items.css("line-height",h+"px"))}d=1}if(b.selection){var n=0,o=b._items.length/d,p=!1;o<c&&(p=!0);for(var l=0;l<c;l++)for(var q=0;q<d;q++){if(q<d-1){var r=b.rtl?"left":"right";a(b._items[n]).css("border-"+r+"-width","1px"),a(b._items[n]).css("border-"+r+"-style","solid")}c>1&&l>0&&(a(b._items[n]).css("border-top-width","1px"),a(b._items[n]).css("border-top-style","solid")),p&&l===c-2&&q===d-1&&(a(b._items[n]).css("border-bottom-width","1px"),a(b._items[n]).css("border-bottom-style","solid")),n++}}a.jqx.browser.msie&&a.jqx.browser.version<8&&(b._items.css("padding-left","0px"),b._items.css("padding-right","0px"),a.each(b._items,function(){a(this).css("border-left-width","0px"),a(this).css("border-right-width","0px"),a(this).css("position","relative"),a(this).css("margin-left","-1px")}),b.host.css("border","none"))},_handlePopupHeight:function(){var a=this;if(a.minimized){var b,c=!1;a.height.toString().indexOf("%")>=0&&(a.host.css("height",a.height),b=a.host.height()-a.minimizedHeight-1,c=!0),c&&(a.popup.height(b),a.ul.height(b),a.host.height(a.minimizedHeight),a._layoutItems())}},_handleMinimize:function(){var b=this;if(b.minimized){var c=b.host;c.height(b.minimizedHeight),c.css("box-sizing","border-box"),c.addClass(b.toThemeProperty("jqx-widget-header")),c.addClass(b.toThemeProperty("jqx-navbar-minimized"));var d=a('<div style="cursor: pointer; height: 100%; margin:0px; margin-left: 5px; margin-right:5px;"></div>');c.append(d),d.css("float",b.minimizeButtonPosition);var e=a('<div style="height: 100%; margin:0px; margin-left: 5px; margin-right:5px;"></div>');e.append(b.minimizedTitle),e.css("float","left"===b.minimizeButtonPosition?"right":"left"),"auto"!==b.minimizedHeight&&(b.minimizedHeight.toString().indexOf("%")>=0?e.css("line-height",b.minimizedHeight):e.css("line-height",parseInt(b.minimizedHeight)+"px")),c.append(e),d.addClass(b.toThemeProperty("jqx-menu-minimized-button")),c.removeClass(b.toThemeProperty("jqx-widget-content")),b.ul.detach();var f=a("<div style='box-sizing: border-box; z-index: 999999; display: none; position: absolute;'></div>");f.addClass(b.toThemeProperty("jqx-widget jqx-widget-content jqx-popup jqx-navbar jqx-navbar-popup")),f.append(b.ul),b.popup=f,a(document.body).append(f),b.opened=!1,d.click(function(){b.opened?b.close():b.open()}),b.button=d}},close:function(){var a=this;a.popup.fadeOut(a.popupAnimationDelay),a.opened=!1},open:function(){var a=this;a.popup.fadeIn(a.popupAnimationDelay),a.popup.css("top",parseInt(a.host.coord().top)+a.host.outerHeight()-1),a.popup.width(a.host.width());var b=a.host.coord().left;a.popup.css("left",b),b.toString().indexOf(".5")>=0&&a.popup.width(a.host.width()-.5),a._handlePopupHeight(),a.opened=!0},_resizePopup:function(){var a=this;if(a.minimized&&a.popup){a.popup.width(a.host.width());var b=a.host.coord().left;a.popup.css("left",b),b.toString().indexOf(".5")>=0&&a.popup.width(a.host.width()-.5),a.popup.css("top",parseInt(a.host.coord().top)+a.host.outerHeight()-1),a._handlePopupHeight()}},selectAt:function(b){var c=this;if(c.selection){a(c._items[c.selectedItem]).removeClass(c.toThemeProperty("jqx-fill-state-pressed")),a(c._items[b]).addClass(c.toThemeProperty("jqx-fill-state-pressed"));var d=c.selectedItem;c.selectedItem=b,c._raiseEvent("0",{selectedItem:b,oldSelectedItem:d})}},getSelectedIndex:function(){return this.selectedItem},destroy:function(){var a=this;a._removeHandlers(),a.host.remove()},propertyChangedHandler:function(a,b,c,d){a.render()},_raiseEvent:function(b,c){var d=this,e=d.events[b],f=new a.Event(e);f.owner=d,f.args=c;try{var g=d.host.trigger(f)}catch(a){}return g},_removeHandlers:function(){var a=this;a.removeHandler(a._items,"click.navbar"+a.element.id),a.removeHandler(a._items,"mouseenter.navbar"+a.element.id),a.removeHandler(a._items,"mouseleave.navbar"+a.element.id)},_addClasses:function(){var b=this;b.host.addClass(b.toThemeProperty("jqx-navbar")),b.disabled&&b.host.addClass(b.toThemeProperty("jqx-fill-state-disabled")),b._items.addClass(b.toThemeProperty("jqx-navbar-block")),b.selection?(b.host.addClass(b.toThemeProperty("jqx-widget")),b.host.addClass(b.toThemeProperty("jqx-widget-content")),b.host.addClass(b.toThemeProperty("jqx-fill-state-normal")),b._items.addClass(b.toThemeProperty("jqx-fill-state-normal")),b._items.addClass(b.toThemeProperty("jqx-button")),b.selectedItem!==-1&&a(b._items[b.selectedItem]).addClass(b.toThemeProperty("jqx-fill-state-pressed"))):this.host.css("border","none"),b.rtl&&b._items.addClass(b.toThemeProperty("jqx-navbar-block-rtl"))},_addHandlers:function(){var b=this;b.addHandler(b._items,"click.navbar"+b.element.id,function(c){if(!b.disabled&&b.selection){var d=a(b._items).index(this);b.selectAt(d)}}),b.addHandler(b._items,"mouseenter.navbar"+b.element.id,function(c){!b.disabled&&b.selection&&a(c.target).addClass(b.toThemeProperty("jqx-fill-state-hover"))}),b.addHandler(b._items,"mouseleave.navbar"+b.element.id,function(c){!b.disabled&&b.selection&&a(c.target).removeClass(b.toThemeProperty("jqx-fill-state-hover"))})}})}(jqxBaseFramework);

mercurial