plumes
Version:
Flying-fast Metro future vision components
3 lines (2 loc) • 2.75 kB
JavaScript
!function(){"use strict";window.Ractive.controller("pl-grouped-buttons",function(t,o,e,n,i){function c(t){t.on("showNotification",function(o){var e=parseInt($(t.el).attr("data-index"),10);d.once("positionsChanged",function(){d.set("compactPositionsTop["+e+"]",0),d.set("compactPositions["+e+"]",0),d.get("mode")==s.COMPACT&&d.set("compactButtonPosition",-100)}),d.set("buttons["+e+"].width",o.width+5)}),t.on("hideNotification",function(){var o=parseInt($(t.el).attr("data-index"),10);d.set("buttons["+o+"].width",50),d.get("mode")==s.COMPACT&&d.set("compactButtonPosition",-15)})}function a(t){d.require().then(function(){for(var o=d.get("orientation"),e=d.get("buttons"),n=d.get("positions"),i=d.get("compactPositionsTop"),a=d.get("compactPositions"),s=d.get("compactOpened"),p=d.get("hidden"),m=$(window).width(),u=0,r=20,f=0,g=60,h=e.length-1;h>=0;h--){var P=e[h],C=d.findChild("data-index",h);if(p?(n[h]=-100,a[h]=-100):(n[h]=u-("right"==o&&"indicator"==P.type?5:0),s?a[h]=r:a[h]=-100),i[h]=f,!C)return;P.isReady||(P.isReady=!0,P.width=50,"indicator"==P.type&&c(C,P,h),P.ready&&P.ready(C)),u+=P.width||0,r+=P.width||0,!p&&r>m&&(g+=50,f+=50,r=20,i[h]=f,s&&(a[h]=r))}d.set("positions",n),d.set("compactPositionsTop",i),d.set("compactPositions",a),setTimeout(function(){d.fire("positionsChanged")}),t&&t({compactHeight:g})})}var s={DEFAULT:"default",COMPACT:"compact"},d=t({plName:"pl-grouped-buttons",data:$.extend(!0,{mode:s.DEFAULT,hidden:!0,orientation:"left",buttons:[],positions:[],compactPositionsTop:[],compactPositions:[],compactButtonPosition:-100,compactOpened:!1,compactHeight:0,action:function(t,o){if(o){var e=parseInt($(o.el).attr("data-index"),10),n=d.get("buttons["+e+"]"),o=d.findChild("data-index",e);d.fire("beforeAction",{event:t,button:n,component:o}),d.get("mode")==s.COMPACT&&d.get("compactOpened")&&d.fire("compactAction"),n&&n.action&&n.action(t,o),d.fire("action",{event:t,button:n,component:o})}}},o),hide:function(){d.get("hidden")||(d.set("hidden",!0),d.set("compactButtonPosition",-100),a())},show:function(){d.get("hidden")&&(d.set("hidden",!1),d.get("mode")==s.COMPACT&&d.set("compactButtonPosition",-15),a())},compactMode:function(){d.get("mode")!=s.COMPACT&&(d.set("mode",s.COMPACT),d.set("compactButtonPosition",-15))},defaultMode:function(){d.get("mode")!=s.DEFAULT&&(d.get("compactOpened")&&d.fire("compactAction"),d.set("mode",s.DEFAULT),d.set("compactButtonPosition",-100))}});d.on("compactAction",function(){var t=!d.get("compactOpened");d.fire("beforeCompact",{button:d,opened:t}),d.set("compactOpened",t),a(function(o){t&&d.set("compactHeight",o.compactHeight),d.fire("compact",{button:d,opened:t})})}),d.observe("buttons",function(){a()}),a(),i()})}();
//# sourceMappingURL=pl-grouped-buttons.min.js.map