UNPKG

plumes

Version:

Flying-fast Metro future vision components

3 lines (2 loc) 9.26 kB
!function(){"use strict";window.Ractive.controller("pl-layout-platform",function(e,t,n,o,i){function l(e){var t=E.window.width(),n=w.get("screen"),o=w.get("contentMedia");t>=b.DESKTOP?(w.set("leftContextWidth",w.get("leftContextOpened")?"25%":0),w.set("rightContextWidth",w.get("rightContextOpened")?"25%":0),w.set("contentLeft",w.get("leftContextOpened")?"25%":0),w.set("contentRight",w.get("rightContextOpened")?"25%":0),O.left&&O.left.defaultMode(),O.right&&("mobile"==r()&&c(),O.right.defaultMode()),w.set("screen","screen-desktop")):("left"==e&&w.get("rightContextOpened")?(v.right.close(null,!1),w.set("rightContextOpened",!1)):"right"==e&&w.get("leftContextOpened")?(v.left.close(null,!1),w.set("leftContextOpened",!1)):w.get("leftContextOpened")&&w.get("rightContextOpened")&&(v.right.close(null,!1),w.set("rightContextOpened",!1)),t>=b.TABLET?(w.set("leftContextWidth",w.get("leftContextOpened")?"75%":0),w.set("rightContextWidth",w.get("rightContextOpened")?"75%":0),w.set("contentLeft",w.get("leftContextOpened")?"75%":w.get("rightContextOpened")?"-75%":0),w.set("contentRight",w.get("rightContextOpened")?"75%":w.get("leftContextOpened")?"-75%":0),O.left&&O.left.defaultMode(),O.right&&("mobile"==r()&&c(),O.right.defaultMode()),w.set("screen","screen-tablet")):t>=b.MOBILE&&(w.set("leftContextWidth",w.get("leftContextOpened")?"100%":0),w.set("rightContextWidth",w.get("rightContextOpened")?"100%":0),w.set("contentLeft",0),w.set("contentRight",0),O.left&&O.left.compactMode(),O.right&&("mobile"==r()&&f(),O.right.compactMode()),w.set("screen","screen-mobile")));var i=E.contentTemplate.outerWidth();i>=b.DESKTOP?w.set("contentMedia","media-desktop"):i>=b.TABLET?w.set("contentMedia","media-tablet"):i>=b.MOBILE&&w.set("contentMedia","media-mobile"),m(),n!=w.get("screen")&&(w.fire("screen",{screen:w.get("screen")}),setTimeout(function(){w.fire("afterScreen",{screen:w.get("screen")})},250)),o!=w.get("contentMedia")&&(w.fire("contentMedia",{contentMedia:w.get("contentMedia")}),setTimeout(function(){w.fire("afterContentMedia",{contentMedia:w.get("contentMedia")})},250)),w.fire("resize"),setTimeout(function(){w.fire("afterResize")},250)}function r(){var e=w.get("usefullscreen");e="undefined"==typeof e||"true"==e||e===!0||!1;var t=w.get("usefullscreendesktop");return t="true"==t||t===!0||!1,e&&t?"desktop":!(!e||t)&&"mobile"}function u(e,t){var n=w.findChild("data-pl-name","context-"+e);n.close(null,t)}function s(){for(var e=w.get("buttonsright")||[],t=-1,n=0;n<e.length;n++)if(e[n]["pl-layout-name"]&&"fullscreen"==e[n]["pl-layout-name"]){t=n;break}return t}function f(){var e=s();if(!(e>-1)){var t=w.get("buttonsright")||[];t.unshift({"pl-layout-name":"fullscreen",icon:document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement?"fa fa-compress":"fa fa-expand",action:function(e){var t=$(e.node).find("i");document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement?(document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen(),t[0].className="fa fa-expand",w.fire("fullscreen",{fullscreen:!1})):(document.body.requestFullscreen?document.body.requestFullscreen():document.body.webkitRequestFullscreen?document.body.webkitRequestFullscreen():document.body.mozRequestFullScreen?document.body.mozRequestFullScreen():document.body.msRequestFullscreen&&document.body.msRequestFullscreen(),t[0].className="fa fa-compress",w.fire("fullscreen",{fullscreen:!0}))}}),w.update("buttonsright")}}function c(){var e=s();if(!(e<0)){var t=w.get("buttonsright")||[];t.splice(e,1),w.update("buttonsright")}}function d(e,t){O[e]=t,t.on("beforeAction",g),t.on("beforeCompact",h),l(),O[e].show(),"right"==e&&"desktop"==r()&&f()}function a(e,t){v[e]=t,t.on("beforeOpen",function(n){w.set(e+"ContextOpened",!0),w.fire(e+"ContextOpened",{opened:!0,component:t,userBehavior:n.userBehavior}),l(e)}),t.on("beforeCloseContent",function(){var n=$(t.el).find(".pl-group.opened").attr("data-group");if(n){for(var o=w.get("buttons"+e)||[],i=w[e+"GroupedButtons"]().childrenRequire,l=null,r=0;r<o.length;r++)if(o[r].group==n){l=r;break}if(!(null===l||i.length<=l))for(var r=0;r<i.length;r++)if($(i[r].el).attr("data-index")==l){i[r].set("selected",!1);break}}}),t.on("beforeClose",function(){$(t.el).find(".pl-group").removeClass("opened")}),t.on("close",function(n){w.set(e+"ContextOpened",!1),w.fire(e+"ContextOpened",{opened:!1,component:t,userBehavior:n.userBehavior}),l()}),t.on("closeIfGroupOpened",function(e){e&&e.$group&&e.$group.removeClass("opened")})}function p(e,t,n,o,i,l){n.find(".pl-group").removeClass("opened"),i.addClass("opened");var r=i.attr("data-title");"true"==i.attr("data-no-title")?(w.set("context"+e+"usetitle",!1),w.set("context"+e+"title",null)):"undefined"!=typeof r&&(w.set("context"+e+"usetitle",!0),w.set("context"+e+"title",r)),w.fire("groupOpened",{orientation:e,context:t,group:o,$group:i,userBehavior:l}),t.open(null,l,o)}function g(e){if(e&&e.button&&(e.button.context||e.button.group))if(e.button.group){var t=e.button.beforeGroup||function(e,t,n,o){o()};["left","right"].forEach(function(n){var o=v[n],i=$(o.el),l=i.find('[data-group="'+e.button.group+'"]');if(l.length){if(l.hasClass("opened"))return e.userBehavior?o.close(null,!0):(e.component.set("selected",!0),o.open(null,e.userBehavior,e.button.group));e.component.set("selected",!0),e.component.set("loading",!0),t(o,l,e.userBehavior,function(){return e.component.set("loading",!1),l.hasClass("opened")?p(n,o,i,e.button.group,l,e.userBehavior):void(o.isOpened()?o.closeContent(function(){p(n,o,i,e.button.group,l,e.userBehavior)},e.userBehavior):p(n,o,i,e.button.group,l,e.userBehavior))})}})}else if(e.button.context){var n=v[e.button.context];if(!n)return;var o=e.button.beforeContext||function(e,t){t()};o(n,function(){n.open(null,e.userBehavior)})}}function h(e){e&&e.button&&(e.button==O.left?O.right[e.opened?"hide":"show"]():e.button==O.right&&O.left[e.opened?"hide":"show"]())}function m(){if(E.titleText){var e=E.titleText.outerWidth(),t=w.get("screen");w.set("titleEmpty",!e),w.set("titleLeft","screen-desktop"==t?50+(w.get("leftContextOpened")?12.5:0)-(w.get("rightContextOpened")?12.5:0):50),w.set("titleLeftOffset",e?-(e/2):-8)}}function x(e,t){if(w.set("titleOpened",t),t){var n=E.title.outerWidth()+40;w.set("titleBgLeftOffset",n/2),w.set("titleBgWidth",n),w.set("titleBgHeight",e+30)}else w.set("titleBgLeftOffset",0),w.set("titleBgWidth",0)}var b={DESKTOP:1e3,TABLET:450,MOBILE:0},C=null,O={left:null,right:null},v={left:null,right:null},w=e({plName:"pl-layout-platform",data:$.extend(!0,{loaded:!1,titleShowed:!0,titleLeft:50,titleLeftOffset:-80,titleBgLeftOffset:0,titleBgWidth:0,titleBgHeight:0,buttonsleft:[],buttonsright:[],contextlefttitle:"",contextrighttitle:"",contextleftusetitle:!0,contextrightusetitle:!0,leftContextWidth:0,rightContextWidth:0,leftContextOpened:!1,rightContextOpened:!1,contentLeft:0,contentRight:0,contentMedia:"",crossleftcontext:function(){u("left",!0)},crossrightcontext:function(){u("right",!0)}},t),leftGroupedButtons:function(){return O.left},rightGroupedButtons:function(){return O.right},leftContext:function(){return v.left},rightContext:function(){return v.right},closeOnNotDesktop:function(e){e="string"==typeof e?[e]:e,"screen-desktop"!=w.get("screen")&&e.forEach(function(e){w.leftContext().closeIfGroupOpened(e),w.rightContext().closeIfGroupOpened(e)})}}),B=w.parentRequire,E={window:$(window),platform:$(w.el),content:$(w.el).find(".pl-layout-platform-content"),contentTemplate:$(w.el).find(".pl-layout-platform-content-template")};window.Ractive.Plumes.bindUses(w,["mask"]),w.observe("title-showed",function(e){e=e!==!1&&"false"!=e,w.set("titleShowed",e)}),E.window.resize(l),w.on("teardown",function(){E.window.off("resize",l)}),l(),w.on("titleOpen",function(e){x(e.height,!0)}),w.on("titleClose",function(e){x(e.height,!1),setTimeout(m,550)}),w.selectApp=function(e,t,n){C&&C.selectApp(e,t,n)},w.addApp=function(e,t){C&&C.addTitle(e,t)},w.removeApp=function(e){C&&C.removeTitle(e)},setTimeout(function(){t.onloaded&&t.onloaded(w),w.set("loaded",!0);var e=t.beforerequire||function(e,t){t()};e(w,function(){w.set("beforerequire",null),t.beforerequire=null,w.set("start",!0),w.require().then(function(){d("left",w.findChild("data-pl-name","buttons-left")),d("right",w.findChild("data-pl-name","buttons-right")),a("left",w.findChild("data-pl-name","context-left")),a("right",w.findChild("data-pl-name","context-right")),C=w.findChild("name","pl-dropdown-title"),E.title=E.platform.find(".pl-layout-title"),E.titleText=E.platform.find(".pl-layout-title h2 span"),m(),C&&(C.on("open",function(e){w.fire("titleOpen",e)}),C.on("close",function(e){w.fire("titleClose",e)}),C.on("titleSelected",function(e){var t=B.get("cls")||[];t=t.filter(function(e){return 0!==e.indexOf("app-")}),t.push("app-"+e.title.name.toLowerCase().replace(/[^a-z0-9]/gi,"")),B.set("cls",t)}),C.fireSelected()),i(),setTimeout(function(){E.platform.find(".pl-layout-mask").remove()})})})})})}(); //# sourceMappingURL=pl-layout-platform.min.js.map