UNPKG

8.35 kBJavaScriptView Raw
1!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>=C.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()&&s(),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>=C.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()&&s(),O.right.defaultMode()),w.set("screen","screen-tablet")):t>=C.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()&&c(),O.right.compactMode()),w.set("screen","screen-mobile")));var i=E.contentTemplate.outerWidth();i>=C.DESKTOP?w.set("contentMedia","media-desktop"):i>=C.TABLET?w.set("contentMedia","media-tablet"):i>=C.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":!1}function u(e,t){var n=w.findChild("data-pl-name","context-"+e);n.close(null,t)}function f(){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 c(){var e=f();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 s(){var e=f();if(!(0>e)){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()&&c()}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("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){n.find(".pl-group").removeClass("opened"),o.addClass("opened");var l=o.attr("data-title");"true"==o.attr("data-no-title")?(w.set("context"+e+"usetitle",!1),w.set("context"+e+"title",null)):"undefined"!=typeof l&&(w.set("context"+e+"usetitle",!0),w.set("context"+e+"title",l)),w.fire("groupOpened",{orientation:e,context:t,$group:o,userBehavior:i}),t.open(null,i)}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)return l.hasClass("opened")?o.open(null,e.userBehavior):void t(o,l,e.userBehavior,function(){o.isOpened()?o.closeContent(function(){p(n,o,i,l,e.userBehavior)},e.userBehavior):p(n,o,i,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 C={DESKTOP:1e3,TABLET:450,MOBILE:0},b=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}}),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?!1:!0,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){b&&b.selectApp(e,t,n)},w.addApp=function(e,t){b&&b.addTitle(e,t)},w.removeApp=function(e){b&&b.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")),b=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(),b&&(b.on("open",function(e){w.fire("titleOpen",e)}),b.on("close",function(e){w.fire("titleClose",e)}),b.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)}),b.fireSelected()),i(),setTimeout(function(){E.platform.find(".pl-layout-mask").remove()})})})})})}();
2//# sourceMappingURL=pl-layout-platform.min.js.map