diff options
Diffstat (limited to 'themes/luci-theme-rosy/htdocs/luci-static/rosy/js')
-rw-r--r-- | themes/luci-theme-rosy/htdocs/luci-static/rosy/js/ScrollY.js | 1 | ||||
-rwxr-xr-x | themes/luci-theme-rosy/htdocs/luci-static/rosy/js/script.js | 152 |
2 files changed, 72 insertions, 81 deletions
diff --git a/themes/luci-theme-rosy/htdocs/luci-static/rosy/js/ScrollY.js b/themes/luci-theme-rosy/htdocs/luci-static/rosy/js/ScrollY.js new file mode 100644 index 0000000000..38d82d103e --- /dev/null +++ b/themes/luci-theme-rosy/htdocs/luci-static/rosy/js/ScrollY.js @@ -0,0 +1 @@ +!function(win,dom){function MyScrollBar(o){this.init(o)}function getStyle(obj,name){return win.getComputedStyle?getComputedStyle(obj,null)[name]:obj.currentStyle[name]}function setStyle(obj,oStyle){for(var i in oStyle)obj.style[i]=oStyle[i]}function getOffsetSize(obj){var sDisplay=getStyle(obj,"display"),res={};if("none"!=sDisplay)res.width=obj.offsetWidth,res.height=obj.offsetHeight;else{var oldStyle={position:getStyle(obj,"position"),visibility:getStyle(obj,"visibility"),display:sDisplay},newStyle;setStyle(obj,{position:"absolute",visibility:"hidden",display:"inline-block"}),res.width=obj.offsetWidth,res.height=obj.offsetHeight,setStyle(obj,oldStyle)}return res}function getClientSize(obj){var iTopW=parseInt(getStyle(obj,"borderTopWidth")),iRightW=parseInt(getStyle(obj,"borderRightWidth")),iBottomW=parseInt(getStyle(obj,"borderBottomWidth")),iLeftW=parseInt(getStyle(obj,"borderLeftWidth")),oOffset=getOffsetSize(obj);return{width:oOffset.width<=0?oOffset.width:oOffset.width-iLeftW-iRightW,height:oOffset.height<=0?oOffset.height:oOffset.height-iTopW-iBottomW}}function canSelectText(bCan){bCan?(dom.body.style.mozUserSelect="text",dom.body.style.webkitUserSelect="text",dom.body.style.msUserSelect="text",dom.body.style.khtmlUserSelect="text",dom.body.style.userSelect="text"):(dom.body.style.mozUserSelect="none",dom.body.style.webkitUserSelect="none",dom.body.style.msUserSelect="none",dom.body.style.khtmlUserSelect="none",dom.body.style.userSelect="none")}function getPosition(obj,goal){var oPos={top:obj.offsetTop,left:obj.offsetLeft};if(obj.parentNode==goal)return oPos;var obj=getPosition(obj.parentNode,goal);oPos.top+=obj.top,oPos.left+=obj.left}MyScrollBar.prototype.init=function(o){this.bYBar=!1,this.iScrollTop=0,this.iScrollLeft=0,this.bYShow=!1,this.oWrapper=dom.getElementById(o.selId),this.oScroll=this.oWrapper.firstElementChild,this.setParam(o),this.addScrollBar(),this.initState(),this.initEvent()},MyScrollBar.prototype.initState=function(){var sWPosition;"static"==getStyle(this.oWrapper,"position")&&setStyle(this.oWrapper,{position:"relative"}),setStyle(this.oScroll,{position:"relative"}),this.bYBar&&(setStyle(this.oYBox,{display:this.enterShow?"none":"block",position:"absolute",top:0,right:0,zIndex:10,width:this.width+"px",height:"100%",backgroundColor:this.bgColor}),setStyle(this.oYBar,{position:"absolute",top:0,left:0,width:"100%",backgroundColor:this.barColor,borderRadius:this.borderRadius+"px",transition:"all "+this.time+"ms"})),this.setSize()},MyScrollBar.prototype.initEvent=function(){var _this=this,sUserAgent;-1!=win.navigator.userAgent.toLowerCase().indexOf("firefox")?this.oWrapper.addEventListener("DOMMouseScroll",function(e){_this.bYBar&&_this.bYShow&&(e.preventDefault(),_this.iScrollTop+=e.detail>0?60:-60,_this.iScrollTop=_this.iScrollTop<=0?0:_this.iScrollTop>=_this.iScrollH-_this.iWrapperH?_this.iScrollH-_this.iWrapperH:_this.iScrollTop,_this.setTransLate(),_this.setYTop(_this.iScrollTop/_this.iScrollH*_this.iYBoxH))}):this.oWrapper.onmousewheel=function(evt){if(_this.bYBar&&_this.bYShow){var e=evt||win.event;evt?e.preventDefault():e.returnValue=!1,_this.iScrollTop+=e.wheelDelta<0?60:-60,_this.iScrollTop=_this.iScrollTop<=0?0:_this.iScrollTop>=_this.iScrollH-_this.iWrapperH?_this.iScrollH-_this.iWrapperH:_this.iScrollTop,_this.setTransLate(),_this.setYTop(_this.iScrollTop/_this.iScrollH*_this.iYBoxH)}};var isInWrapper=!1;this.oWrapper.onmouseenter=function(){isInWrapper=!0,_this.enterShow&&_this.bYBar&&_this.bYShow&&setStyle(_this.oYBox,{display:"block"})},this.oWrapper.onmouseleave=function(){isInWrapper=!1,_this.enterShow&&_this.bYBar&&!bYDown&&_this.bYShow&&setStyle(_this.oYBox,{display:"none"})};var bYDown=!1,bYLeave=!0,iDownPageY=0,iYBarTop=0;this.bYBar&&(this.enterColor&&(this.oYBar.onmouseenter=function(){bYLeave=!1,setStyle(this,{backgroundColor:_this.enterColor})},this.oYBar.onmouseleave=function(){bYLeave=!0,bYDown||setStyle(this,{backgroundColor:_this.barColor})}),this.oYBar.onmousedown=function(e){_this.bYShow&&(bYDown=!0,iDownPageY=e.clientY+dom.documentElement.scrollTop||dom.body.scrollTop,iYBarTop=parseInt(getStyle(this,"top")),_this.setYTime(0),canSelectText(!1))},dom.addEventListener("mouseup",function(){bYDown&&_this.bYShow&&(bYDown=!1,_this.setYTime(_this.time),canSelectText(!0),!isInWrapper&&_this.enterShow&&setStyle(_this.oYBox,{display:"none"})),!bYDown&&bYLeave&&setStyle(_this.oYBar,{backgroundColor:_this.barColor})}),dom.addEventListener("mousemove",function(e){if(bYDown&&_this.bYShow){var iNowPageY=e.clientY+dom.documentElement.scrollTop||dom.body.scrollTop,iNowTop=iYBarTop+iNowPageY-iDownPageY;iNowTop=iNowTop<=0?0:iNowTop>=_this.iYBoxH-_this.iYBarH?_this.iYBoxH-_this.iYBarH:iNowTop,_this.iScrollTop=iNowTop/_this.iYBoxH*_this.iScrollH,_this.setTransLate(),_this.setYTop(iNowTop)}}),this.oYBar.ondrag=function(e){var e=evt||win.event;evt?e.preventDefault():e.returnValue=!1})},MyScrollBar.prototype.setParam=function(o){this.width=o.width?o.width:10,this.bgColor=o.bgColor?o.bgColor:"#eaeaea",this.barColor=o.barColor?o.barColor:"#ccc",this.enterColor=o.enterColor||!1,this.enterShow=!1!==o.enterShow,this.hasY=!1!==o.hasY,this.borderRadius=o.borderRadius>=0?o.borderRadius:this.width/2,this.time=o.time||0},MyScrollBar.prototype.addScrollBar=function(){this.getSize(),this.hasY&&(this.bYBar=!0,this.oYBox=dom.createElement("div"),this.oYBar=dom.createElement("div"),this.oYBox.appendChild(this.oYBar),this.oWrapper.insertBefore(this.oYBox,this.oScroll))},MyScrollBar.prototype.getSize=function(){var oWrapperSize=getClientSize(this.oWrapper),oScrollSize=getClientSize(this.oScroll);this.iWrapperClientH=oWrapperSize.height,this.iPaddingT=parseInt(getStyle(this.oWrapper,"paddingTop")),this.iPaddingR=parseInt(getStyle(this.oWrapper,"paddingRight")),this.iPaddingB=parseInt(getStyle(this.oWrapper,"paddingBottom")),this.iPaddingL=parseInt(getStyle(this.oWrapper,"paddingLeft")),this.iWrapperH=oWrapperSize.height-this.iPaddingT-this.iPaddingB,this.iScrollH=oScrollSize.height,this.bYBar&&(this.iYBoxH=oWrapperSize.height,this.iYBarH=this.iWrapperH/this.iScrollH*this.iYBoxH)},MyScrollBar.prototype.setSize=function(time){var _this=this;time=time||100,setTimeout(function(){_this.getSize(),_this.iScrollTop>=_this.iScrollH-_this.iWrapperH&&(_this.iScrollTop=_this.iScrollH-_this.iWrapperH),_this.bYBar&&(_this.iWrapperH>=_this.iScrollH?(setStyle(_this.oYBox,{display:"none"}),_this.bYShow=!1):(_this.enterShow||setStyle(_this.oYBox,{display:"block"}),setStyle(_this.oYBar,{height:_this.iYBarH+"px",top:_this.iScrollTop/_this.iScrollH*_this.iYBoxH+"px"},0),_this.bYShow=!0))},time)},MyScrollBar.prototype.setTransLate=function(iTime){var sTranslate="translate(-"+this.iScrollLeft+"px, -"+this.iScrollTop+"px)";setStyle(this.oScroll,{transition:"all "+(iTime>=0?iTime:this.time)+"ms",transform:sTranslate,msTransform:sTranslate,mozTransform:sTranslate,webkitTransform:sTranslate,oTransform:sTranslate})},MyScrollBar.prototype.setYTime=function(iTime){setStyle(this.oYBar,{transition:"all "+(iTime>=0?iTime:this.time)+"ms"})},MyScrollBar.prototype.setYTop=function(iTop){setStyle(this.oYBar,{top:iTop+"px"})},MyScrollBar.prototype.jump=function(o){o=o||{};var oPos={top:0,left:0},iTop=0,iBottome=this.iScrollH-this.iWrapperClientH+this.iPaddingT+this.iPaddingB>0?this.iScrollH-this.iWrapperClientH+this.iPaddingT+this.iPaddingB:0,iLeft=0,iRight=this.iScrollW-this.iWrapperClientW+this.iPaddingL+this.iPaddingR>0?this.iScrollW-this.iWrapperClientW+this.iPaddingL+this.iPaddingR:0,obj;if(o.id)oPos=getPosition(document.getElementById(o.id),this.oScroll),this.bYBar&&(oPos.top+=this.iPaddingT);else if(o.pos)if("string"==typeof o.pos)switch(o.pos){case"top":oPos.top=0;break;case"bottom":oPos.top=iBottome;break;case"left":oPos.left=0;break;case"right":oPos.left=iRight}else"object"==typeof o.pos&&(oPos=o.pos);oPos.top=oPos.top>iBottome?iBottome:oPos.top>=0?oPos.top:0,this.iScrollTop=oPos.top,this.setTransLate(o.time),this.bYBar&&(this.setYTime(o.time),this.setYTop(this.iScrollTop/this.iScrollH*this.iYBoxH))},"function"==typeof define&&define.amd&&define([],function(){return MyScrollBar}),win.MyScrollBar=MyScrollBar}(window,document);
\ No newline at end of file diff --git a/themes/luci-theme-rosy/htdocs/luci-static/rosy/js/script.js b/themes/luci-theme-rosy/htdocs/luci-static/rosy/js/script.js index 76ee383ccb..886e175cc4 100755 --- a/themes/luci-theme-rosy/htdocs/luci-static/rosy/js/script.js +++ b/themes/luci-theme-rosy/htdocs/luci-static/rosy/js/script.js @@ -16,8 +16,8 @@ * Licensed to the public under the Apache License 2.0 */ -(function ($) { - $(".main > .loading").fadeOut(); +(function (win, $) { + $(".loading").fadeOut(); /** * trim text, Remove spaces, wrap @@ -33,16 +33,17 @@ var mainNodeName = undefined; var nodeUrl = ""; - (function(node){ - if (node[0] == "admin"){ + (function (node) { + var luciLocation; + if (node[0] == "admin") { luciLocation = [node[1], node[2]]; - }else{ + } else { luciLocation = node; } - for(var i in luciLocation){ + for (var i in luciLocation) { nodeUrl += luciLocation[i]; - if (i != luciLocation.length - 1){ + if (i != luciLocation.length - 1) { nodeUrl += "/"; } } @@ -59,7 +60,7 @@ return true; } - $(".main > .main-left .nav > .slide > .menu").each(function () { + $(".main-left .nav > .slide > .menu").each(function () { var ulNode = $(this); ulNode.next().find("a").each(function () { var that = $(this); @@ -81,7 +82,17 @@ /** * menu click */ - $(".main > .main-left .nav > .slide > .menu").click(function () { + if ($('.nav').length > 0 && $(window).width() > 992) { + var oScroll = new MyScrollBar({ + selId: 'navBox', + time: 100, + bgColor: 'transprent', + barColor: '#839dd67a', + enterColor: '#839dd6cc', + enterShow: false + }); + } + $(".main-left .nav > .slide > .menu").click(function () { var ul = $(this).next(".slide-menu"); var menu = $(this); if (!ul.is(":visible")) { @@ -94,28 +105,35 @@ ul.removeClass("active"); }); } + if ($('.nav').length > 0 && $(window).width() > 992) { + oScroll.setSize(200); + } + setInterval(function () { + if ($('.nav').height() < $('.navbar-container').height()) { + $('.nav').css('transform', 'translate(0px, 0px)'); + } + }, 300); return false; }); - /** * hook menu click and add the hash */ - $(".main > .main-left .nav > .slide > .slide-menu > li > a").click(function () { + $(".main-left .nav > .slide > .slide-menu > li > a").click(function () { if (lastNode != undefined) lastNode.removeClass("active"); $(this).parent().addClass("active"); - $(".main > .loading").fadeIn("fast"); + $(".loading").fadeIn("fast"); return true; }); /** * fix menu click */ - $(".main > .main-left .nav > .slide > .slide-menu > li").click(function () { + $(".main-left .nav > .slide > .slide-menu > li").click(function () { if (lastNode != undefined) lastNode.removeClass("active"); $(this).addClass("active"); - $(".main > .loading").fadeIn("fast"); - window.location = $($(this).find("a")[0]).attr("href"); + $(".loading").fadeIn("fast"); + win.location = $($(this).find("a")[0]).attr("href"); return false; }); @@ -141,7 +159,7 @@ that.click(function () { var href = that.attr("href"); if (href.indexOf("#") == -1) { - $(".main > .loading").fadeIn("fast"); + $(".loading").fadeIn("fast"); return true; } }); @@ -154,52 +172,49 @@ var showSide = false; $(".showSide").click(function () { if (showSide) { - $(".main-left").stop(true).animate({ - right: '100%' - }, "fast"); - $(".main-right").css("overflow-y", "auto"); + $(".darkMask").stop(true).fadeOut("fast"); + $(".main-left").stop(true).fadeOut("fast"); + $(".main-right").css("overflow-y", "visible"); showSide = false; } else { + $(".darkMask").stop(true).fadeIn("fast"); $(".main-left").stop(true).animate({ - right: '0' - }, "fast"); + width: "100%" + }, "fast").fadeIn("fast"); $(".main-right").css("overflow-y", "hidden"); showSide = true; } }); + if($(win).width() <= 992){ + $(".main-left").click(function(e) { + e.preventDefault(); + $(".main-left").stop(true).fadeOut("fast"); + showSide = false; + }); + } - $(".logged-in .main-left").click(function () { + $(".darkMask").click(function () { if (showSide) { showSide = false; - - $(this).stop(true).fadeOut("fast"); + $(".darkMask").stop(true).fadeOut("fast"); $(".main-left").stop(true).animate({ - right: '100%' + width: "0" }, "fast"); - $(".main-right").css("overflow-y", "auto"); - } - }); - - $(".logged-in .main-left > *").click(function () { - event.stopPropagation(); - if ((navigator.userAgent.indexOf('MSIE') >= 0)&& (navigator.userAgent.indexOf('Opera') < 0)){ - event.cancelBubble = true; - }else{ - event.stopPropagation(); + $(".main-right").css("overflow-y", "visible"); } }); - $(window).resize(function () { - if ($(window).width() > 921) { + $('.login .main-right').css('min-height', $(win).height()); + $(win).resize(function () { + if ($(win).width() > 921) { $(".main-left").css("width", ""); $(".darkMask").stop(true); $(".darkMask").css("display", "none"); showSide = false; } - if( $(window).width() > 992 ){ - $('.logged-in .main-right').width( $(window).width() - $('.logged-in .main-left').width() - 50 ); - } + + $('.login .main-right').css('min-height', $(win).height()); }); /** @@ -212,7 +227,7 @@ $(".cbi-section-table-titles, .cbi-section-table-descr, .cbi-section-descr").each(function () { var that = $(this); - if (that.text().trim() == ""){ + if (that.text().trim() == "") { that.css("display", "none"); } }); @@ -244,48 +259,23 @@ } } - $('<div class="iconpwd"></div>').appendTo($('.node-main-login form .cbi-value input[type="password"]').parent()[0]); - - $('<div class="iconuser"></div>').appendTo($('.node-main-login form .cbi-value input[type="text"]').parent()[0]); - - $('<div class="iconeye"></div>').appendTo($('.node-main-login form .cbi-value input[type="password"]').parent()[0]); + $('.lang_enInterfaces .ifacebox-head').each(function () { + $(this).next().css('border-color', $(this).css('background-color')); + }); - var num = true; - $('.cbi-value-field .iconeye').click(function(){ - if(num){ - $('.node-main-login form .cbi-value-last input[type="password"]').prop('type', 'text'); - $('.node-main-login form .cbi-value-field .iconeye').removeClass('opeye').addClass('cleye'); - num = false; + $('<div>').appendTo('.login > .main .cbi-value-last .cbi-value-field'); + $('.login > .main .cbi-value-last .cbi-value-field > div').click(function(){ + var thisParent = $(this).parent(); + if( thisParent.attr('class').indexOf('op-eye') == (-1) ){ + thisParent.addClass('op-eye'); + $(this).prev().attr('type', 'text'); }else { - $('.node-main-login form .cbi-value-last input[type="text"]').prop('type', 'password'); - $('.node-main-login form .cbi-value-field .iconeye').removeClass('cleye').addClass('opeye'); - num = true - } - - }) - - $('body.logged-in').css('min-height', $(window).height()); - - $(function(){ - if( $(window).width() > 992 ){ - $('.logged-in .main-right').outerWidth( $(window).width() - $('.logged-in .main-left').width() - 50 ); + thisParent.removeClass('op-eye'); + $(this).prev().attr('type', 'password'); } - $('.cbi-section .table').each(function(){ - var thisTr = $(this).children('.tr').get(0); - var td = $(thisTr).children('.td').get(0); - var th = $(thisTr).children('.th').get(0) - var a = window.getComputedStyle(thisTr, ':before').getPropertyValue('content'); - console.log(td, th); - - if( th && a != 'none' ){ - $(th).css('border-top-left-radius', '0'); - }else if( td && a != 'none' ){ - $(td).css('border-top-left-radius', '0'); - } - }); }); - $('.lang_enNetwork #cbi-samba-sambashare .table').wrap('<div class="table-container"></div>'); - -})(jQuery); + $('#cbi-network-switch_vlan .table').wrap('#vlan_table'); + +})(window, jQuery); |