UNPKG

plumes

Version:

Flying-fast Metro future vision components

3 lines (2 loc) 6.45 kB
!function(){"use strict";window.Ractive.controller("pl-login",function(e,s,o,t,r){function n(){var e=f.message.outerHeight(!0);m.set("height",f.window.height()-(40+e+30)),f.forgotTexts.length&&m.set("helpTop",f.forgototTexts.position().top)}function a(){f.login.find(".name").focus()}function i(e,s,o,t,r){m.set("inModal",!0),m.set("message",e),m.set("messageType",s),m.set("storyboardMessage","sb-message-1"),setTimeout(function(){o&&m.set("username",""),t&&m.set("userpassword",""),"success"==s&&(m.set("texts.usernamePlaceholder",m.get("texts.username")),m.set("texts.userpasswordPlaceholder",m.get("texts.userpassword"))),m.set("storyboardMessage","sb-message-2"),setTimeout(function(){m.set("storyboardMessage","sb-message-3"),setTimeout(function(){m.set("storyboardMessage","sb-message-4"),setTimeout(function(){m.set("storyboardError",null),m.set("inModal",!1),r&&r()},350)},250)},3e3)},250)}function d(e,s,o,t){i(e,"error",s,o,t)}function u(e,s){i(e,"success",!0,!0,s)}function g(){m.get("inForgotPassword")?m.fire("forgotPassword",{password:m.get("username"),confirmPassword:m.get("userpassword")}):m.get("inForgotCode")?m.fire("forgotCode",{code:m.get("username")}):m.get("inForgot")?m.fire("forgot",{username:m.get("username")}):m.fire("login",{username:m.get("username"),userpassword:m.get("userpassword")})}function l(){m.fire("closed"),m&&!m.shouldDestroy&&m.teardown()}function c(){if(m){var e=m.get("storyboard");("sb-show-2"==e||"sb-show-3"==e||"sb-show-4"==e)&&n()}}s.avatar=s.avatar?s.avatar:"null";var m=e({plName:"pl-login",data:$.extend(!0,{show:!1,top:0,inForgot:!1,texts:{username:"Name",code:"Code",userpassword:"Password",userpasswordconfirm:"Confirm password",forgotlink:"I forgot my password",login:"Back to login",forgottext:'Submit your email and press <span class="key">ENTER</span> to receive a validation code in your mailbox.',forgotcodetext:'Use your <strong>validation code</strong> and press <span class="key">ENTER</span> to get the possibility to change your password.',forgotpasswordtext:'Enter your new password twice (to confirm) and press <span class="key">ENTER</span> to change your password.',forgotpasswordhelp:["When creating your password, remember the following:","<ol>","<li>It must not contain your name.</li>","<li>It must contain one or more digits.</li>","<li>It is recommended to mix lowercase and uppercase characters.</li>","<li>It should be long over 7 characters.</li>","</ol>"].join("")}},s)}),f={window:$(window),login:$(m.el),forgotTexts:$(m.el).find(".pl-login-forgot-texts")};window.Ractive.Plumes.bindUses(m,["forgot"]),window.Ractive.Plumes.bindTexts(m),m.observe("texts.username",function(e){m.set("texts.usernamePlaceholder",e)}),m.observe("texts.userpassword",function(e){m.set("texts.userpasswordPlaceholder",e)}),f.login.find(".pl-login-form-content .input").keypress(function(e){13==e.which&&(g(),e.preventDefault(),e.stopPropagation())});var w=new Date;m.observe("username",function(){if(!m.get("inForgotCode")&&!m.get("inForgotPassword")){w=new Date;var e=m.get("username");setTimeout(function(){(new Date).getTime()-w.getTime()>=1e3&&m.fire("username",{username:e})},1e3)}}),m.observe("avatar",function(e,s){s!=e&&(e||(e="null",m.set("avatar",e),"null"!=s))&&(m.set("oldAvatar",s),setTimeout(function(){m.set("oldAvatar",null)},650))}),m.on("teardown",function(){m=null,f.window.off("resize",c)}),m.on("logged",function(e){var s=m.findChild("name","pl-screen-message");s.fire("closeTitle"),m.set("storyboard","sb-hide-1"),setTimeout(function(){m.set("storyboard","sb-hide-2"),setTimeout(function(){m.set("storyboard","sb-hide-3"),setTimeout(function(){e?s.fire("play",{message:e,done:function(){l()}}):l()},150)},400)},350)}),m.on("close",l),m.on("error",function(e){e=$.extend(!0,{message:"You have an error in your credentials.",clearUsername:!1,clearUserpassword:!0},e||{}),d(e.message,e.clearUsername,e.clearUserpassword,a)}),m.on("displayForgot",function(){n(),m.set("inForgot",!0),m.fire("enterForgot"),setTimeout(a)}),m.on("openHelp",function(){m.set("inHelp",!0),setTimeout(a)}),m.on("displayLogin",function(){var e=m.get("inForgot"),s=m.get("inForgotCode"),o=m.get("inForgotPassword");(s||o)&&(m.set("username",""),m.set("userpassword","")),m.set("inHelp",!1),m.set("inForgot",!1),m.set("inForgotCode",!1),m.set("inForgotPassword",!1),m.set("texts.usernamePlaceholder",m.get("texts.username")),m.set("texts.userpasswordPlaceholder",m.get("texts.userpassword")),s&&m.fire("exitForgotCode"),o&&m.fire("exitForgotPassword"),e&&m.fire("exitForgot"),setTimeout(a)}),m.on("forgotSuccess",function(){m.set("inForgotCode",!0),m.set("username",""),m.set("texts.usernamePlaceholder",m.get("texts.code")),m.fire("enterForgotCode"),setTimeout(a)}),m.on("forgotError",function(e){e=$.extend(!0,{message:"This email address doesn't exist.",clearUsername:!1,clearUserpassword:!1},e||{}),d(e.message,e.clearUsername,e.clearUserpassword,a)}),m.on("forgotCodeSuccess",function(){m.set("inForgotCode",!1),m.set("inForgotPassword",!0),m.set("username",""),m.set("texts.usernamePlaceholder",m.get("texts.userpassword")),m.set("userpassword",""),m.set("texts.userpasswordPlaceholder",m.get("texts.userpasswordconfirm")),m.fire("enterForgotPassword"),setTimeout(a)}),m.on("forgotCodeError",function(e){e=$.extend(!0,{message:"Code invalid.",clearUsername:!0,clearUserpassword:!1},e||{}),d(e.message,e.clearUsername,e.clearUserpassword,a)}),m.on("forgotPasswordSuccess",function(e){e=$.extend(!0,{message:"New password registered."},e||{}),u(e.message,function(){m.fire("displayLogin")})}),m.on("forgotPasswordError",function(e){e=$.extend(!0,{message:"Passwords are invalid.",clearUsername:!0,clearUserpassword:!0},e||{}),d(e.message,e.clearUsername,e.clearUserpassword,a)}),f.window.resize(c),m.require().then(function(){var e=m.findChild("name","pl-screen-message"),o=m.get("texts.question");o=o||""===o?o:"Who are you?",e.fire("play",{message:o,lastLineToTitle:!0,displayTextTime:350,done:function(){f.message=$(e.el).find(".pl-screen-messages-message");var o=f.message.outerHeight(!0);m.set("top",f.message.offset().top+o-1),m.set("height",1),m.set("storyboard","sb-show-1"),setTimeout(function(){m.set("storyboard","sb-show-2"),m.set("top",40+o),n(),setTimeout(function(){m.set("storyboard","sb-show-3"),setTimeout(function(){f.login.find(s.username?".password":".name").focus(),m.set("storyboard","sb-show-4")},450)},450)},650)}}),r()})})}(); //# sourceMappingURL=pl-login.min.js.map