ablanco/yith-library-web-client

View on GitHub
yithwebclient/static/js/prod/yith-1.1.1.min.js

Summary

Maintainability
A
0 mins
Test Coverage
/* yith-library-web-client 2014-08-30 - AGPLv3 License */

window.Yith=Ember.Application.create(),function(a,b){"use strict";a.deferReadiness(),a.Router.map(function(){this.resource("passwords",{path:"/"},function(){this.route("new"),this.route("edit",{path:":password_id"})})}),a.PasswordsIndexRoute=b.Route.extend({model:function(){return this.store.find("password")},setupController:function(a,b){a.set("model",b),a.initMasterModal()}}),a.PasswordsNewRoute=b.Route.extend({model:function(){return this.store.createRecord("password")},setupController:function(a,b){a.set("model",b),a.initMasterModal()}}),a.PasswordsEditRoute=b.Route.extend({model:function(a){return this.store.find("password",a.password_id)},setupController:function(a,b){a.set("model",b),a.set("modifySecret",!1),a.initMasterModal()}}),b.$(document).ready(function(){var c,d;d=function(a){b.$("#loading .progress .bar").css("width",a+"%")},b.$.ajax("/token",{success:function(c){window.yithAccessCode=c.access_code,d(100),a.advanceReadiness(),b.$("#loading").remove()},error:function(){b.$("#error").find(".access").removeClass("hide"),b.$("#error").modal({keyboard:!1,backdrop:"static"}),setTimeout(function(){window.open("/","_self")},4e3)}}),c=b.$("#credits"),c.modal({show:!1}),b.$("#creditsButton").click(function(){c.modal("show")}),d(60)})}(Yith,Ember),function(a,b){"use strict";a.SettingsObject=b.Object.extend({disableCountdown:!1,rememberMaster:!1,masterPassword:void 0,showAdvancedOptions:!1,passGenUseSymbols:!0,passGenUseNumbers:!0,passGenUseChars:!0,passGenLength:20,passGenCharset:b.computed("passGenUseChars","passGenUseNumbers","passGenUseSymbols",function(){var a,b="";for(a=33;127>a;a+=1)a>=33&&48>a&&this.passGenUseSymbols?b+=String.fromCharCode(a):a>=48&&58>a&&this.passGenUseNumbers?b+=String.fromCharCode(a):a>=58&&65>a&&this.passGenUseSymbols?b+=String.fromCharCode(a):a>=65&&91>a&&this.passGenUseChars?b+=String.fromCharCode(a):a>=91&&97>a&&this.passGenUseSymbols?b+=String.fromCharCode(a):a>=97&&123>a&&this.passGenUseChars?b+=String.fromCharCode(a):a>=123&&127>a&&this.passGenUseSymbols&&(b+=String.fromCharCode(a));return b})}),a.settings=a.SettingsObject.create()}(Yith,Ember),function(a,b,c,d,e){"use strict";a.Password=c.Model.extend({account:c.attr(),creation:c.attr(),expiration:c.attr(),lastModification:c.attr(),notes:c.attr(),owner:c.attr(),secret:c.attr(),service:c.attr(),tags:c.attr()}),a.PasswordAdapter=c.RESTAdapter.extend({host:d,ajax:function(a,b,c){return a+="?client_id="+e,void 0===c&&(c={}),c.headers={Authorization:"Bearer "+yithAccessCode},this._super(a,b,c)},didError:function(){b.$("#error").modal({keyboard:!1,backdrop:"static"}),b.$("#error").find(".failure").removeClass("hide"),setTimeout(function(){window.open("/list","_self")},4e3),this._super.apply(this,arguments)}})}(Yith,Ember,DS,yithServerHost,yithClientId),function(a,b){"use strict";a.ControllersUtils={oneDayInMilliseconds:864e5,daysLeft:function(b,c){var d=(new Date).getTime(),e=d-b,f=Math.round(e/a.ControllersUtils.oneDayInMilliseconds);return c-f}},a.PasswordInListController=b.ObjectController.extend({daysLeft:b.computed("creation","expiration",function(){return a.ControllersUtils.daysLeft(this.get("creation"),this.get("expiration"))}),expirationClass:b.computed("daysLeft",function(){var a="badge ",b=this.get("daysLeft");return a+=b>30?"badge-success":b>7?"badge-warning":"badge-important"})}),a.PasswordsIndexController=b.ArrayController.extend({activeFilters:[],masterModalView:null,changeMasterModalView:null,initMasterModal:function(){this.set("masterModalView",a.MasterModal.create()),this.set("changeMasterModalView",a.MasterModal.extend({ident:"change-master",isChangeForm:!0}).create())},processedPasswordList:b.computed("@each","activeFilters.@each",function(){var b,c=this.activeFilters,d=this;return b=this.toArray().sort(function(a,b){var c=a.get("service"),d=b.get("service"),e=0;return c?d?(c=c.toLowerCase(),d=d.toLowerCase(),c>d?e=1:d>c&&(e=-1),e):1:-1}),c.length>0&&(b=b.filter(function(a){var b=a.get("tags");return b=b||[],c.every(function(a){return b.some(function(b){return a.trim()===b.trim()})})})),b.map(function(b){var c=a.PasswordInListController.create();return c.set("model",b),c.set("container",d.container),c.set("list_controller",d),c})}),allTags:b.computed("@each.tags",function(){var a=new b.Set;return this.forEach(function(b){var c=b.get("tags");void 0!==c&&null!==c&&a.addEach(c)}),a=a.toArray().sort(function(a,b){return a.localeCompare(b)})}),activateFilter:function(a){var c=new b.Set(this.activeFilters);c.push(a),this.set("activeFilters",c.toArray())},deactivateFilter:function(a){var c=new b.Set(this.activeFilters);c.remove(a),this.set("activeFilters",c.toArray())},isCountdownActive:b.computed("Yith.settings.disableCountdown",function(){return a.settings.get("disableCountdown")}),isRememberMasterActive:b.computed("Yith.settings.rememberMaster",function(){return a.settings.get("rememberMaster")}),showAdvancedOptions:b.computed("Yith.settings.showAdvancedOptions",function(){return a.settings.get("showAdvancedOptions")}),actions:{toggleCountdown:function(){a.settings.set("disableCountdown",!a.settings.get("disableCountdown"))},toggleRememberMaster:function(){var b=!a.settings.get("rememberMaster");a.settings.set("rememberMaster",b),b||a.settings.set("masterPassword",void 0)},toggleAdvancedOptions:function(){a.settings.set("showAdvancedOptions",!a.settings.get("showAdvancedOptions"))}}})}(Yith,Ember),function(a,b){"use strict";a.PasswordsNewController=b.ObjectController.extend({modifySecret:!0,expirationActive:!1,provisionalTags:[],savingEvent:"didCreate",needs:["passwordsIndex"],masterModalView:null,initMasterModal:function(){this.set("masterModalView",a.MasterModal.create())},init:function(){var a,c;this._super(),a=function(a){a.get("expiration")>0?a.set("expirationActive",!0):a.set("expirationActive",!1)},this.addObserver("expiration",this,a),c=function(a){var c=new b.Set(a.get("tags"));a.set("provisionalTags",c.toArray())},this.addObserver("tags",this,c)},expirationDisabled:b.computed("expirationActive",function(){return!this.get("expirationActive")}),addProvisionalTags:function(a){var c=new b.Set(this.get("provisionalTags"));a=a.map(function(a){return a.trim()}),c.addEach(a.filter(function(a){return a.length>0})),this.set("provisionalTags",c.toArray())},validateSecretChecker:function(a){var b=a.find("#edit-secret1"),c=b.parents("#secret-group"),d=b.val()===a.find("#edit-secret2").val(),e=""!==b.val();return c.removeClass("error"),e?c.find(".help-block.req").hide():c.addClass("error").find(".help-block.req").show(),d?c.find(".help-block.match").hide():c.addClass("error").find(".help-block.match").show(),d&&e},validateRequired:function(a){return""!==a.val()?(a.parents(".control-group").removeClass("error"),a.next().hide(),!0):(a.parents(".control-group").addClass("error"),a.next().show(),!1)},validate:function(a){var b=this.validateRequired(a.find("#edit-service"));return this.get("modifySecret")&&(b=this.validateSecretChecker(a)&&b),b},_calculateExpiration:function(b,c,d){return b=parseInt(b,10),b*=a.ControllersUtils.oneDayInMilliseconds,b=b+d.getTime()-c,b=Math.round(b/a.ControllersUtils.oneDayInMilliseconds)},getFormData:function(a,b){var c=a.find("#edit-enable-expiration:checked").length>0,d=new Date,e={creation:b,expiration:0};return e.service=a.find("#edit-service").val(),e.account=a.find("#edit-account").val().trim(),e.lastModification=d.getTime(),c&&(e.expiration=this._calculateExpiration(a.find("#edit-expiration").val(),b,d)),e.notes=a.find("#edit-notes").val().trim(),""===e.notes&&delete e.notes,e.tags=this.get("provisionalTags"),this.get("modifySecret")&&(e.secret=a.find("#edit-secret1").val()),e},saveData:function(a){var b=this.get("model");b.one(this.get("savingEvent"),this,function(){this.transitionToRoute("/")}),b.setProperties(a),b.save()},save:function(c){if(this.validate(c)){var d,e,f=this.getFormData(c,(new Date).getTime()),g=this;e=function(a){delete f.secret,a&&(f.secret=a),g.saveData(f),f=null},b.isNone(f.secret)?e():(d=this.get("masterModalView"),d.show(function(b){var c;try{c=a.ViewsUtils.cipher(b,f.secret,d,g.get("controllers.passwordsIndex"))}catch(h){return!1}return f.secret=null,e(c),!0}))}},actions:{checkEmptiness:function(){this.validateRequired(b.$("#edit-service"))},expirationToggle:function(){this.set("expirationActive",!this.get("expirationActive"))},removeTag:function(a){var c=new b.Set(this.get("provisionalTags"));c.remove(a),this.set("provisionalTags",c.toArray())},cancelNewPassword:function(){this.get("model").deleteRecord(),this.transitionToRoute("/")}}}),a.PasswordsEditController=a.PasswordsNewController.extend({modifySecret:!1,savingEvent:"didUpdate",daysLeft:b.computed("creation","expiration",function(){var b="";return this.get("expirationActive")&&(b=a.ControllersUtils.daysLeft(this.get("creation"),this.get("expiration"))),b}),actions:{deletePassword:function(){var a=this,c=b.$("#confirm-modal");return c.modal({show:!1}),c.find("#confirm-delete").off("click").on("click",function(b){b.preventDefault(),b.stopPropagation();var d=a.get("model");d.one("didDelete",a,function(){this.transitionToRoute("/")}),d.deleteRecord(),d.save(),c.modal("hide")}),c.modal("show"),!1}}})}(Yith,Ember),function(a,b,c,d){"use strict";a.ViewsUtils={cipher:function(a,d,e,f,g){var h,i=f.get("model");if(!i.get("isLoaded"))throw e.hide(),b.$("#error").modal({keyboard:!1,backdrop:"static"}),b.$("#error").find(".failure").removeClass("hide"),setTimeout(function(){window.open("/list","_self")},4e3),"The model isn't loaded";return i.get("firstObject")&&i.get("firstObject.id")&&!g&&c.decrypt(a,i.get("firstObject.secret")),h=c.encrypt(a,d),a=null,h},decipher:function(a,d){var e=null;return b.isNone(d)||(e=c.decrypt(a,d)),a=null,e}},a.MasterModal=b.View.extend({templateName:"master-modal",ident:"master",isChangeForm:!1,$root:null,callback:null,initModal:b.on("didInsertElement",function(){var a=this.$("#"+this.get("ident")).modal({show:!1}),b=this;a.on("shown",function(){b.cleanup(),b.$("input").first().focus()}),a.on("hidden",function(){b.cleanup(),b.set("callback",null)}),this.set("$root",a)}),hide:function(){this.get("$root").modal("hide")},cleanup:function(){this.$(".alert-error").hide(),this.$("input").val("")},show:function(c){this.set("callback",c),this.get("isChangeForm")||!a.settings.get("rememberMaster")||b.isNone(a.settings.get("masterPassword"))?this.get("$root").modal("show"):this.done(a.settings.get("masterPassword"))},done:function(c){var d,e=[];b.isNone(c)?this.$("input").each(function(a,c){e[a]=b.$(c).val()}):e.push(c),d=this.get("callback").apply(window,e),d?(a.settings.get("rememberMaster")&&b.isNone(c)&&""!==e[0]&&(a.settings.set("masterPassword",e[0]),setTimeout(function(){a.settings.set("masterPassword",void 0)},3e5)),this.get("$root").modal("hide")):(this.$(".alert-error").show(),this.$("input").first().focus().select()),e=null},keyPress:function(a){var b=a.keyCode||a.which;this.$(a.target).is(".main")&&this.$(".alert-error").hide(),13===b&&(a.preventDefault(),this.done())},click:function(a){a.preventDefault(),a.stopPropagation(),this.$(a.target).is(".done")&&this.done()}}),a.ServerPreferencesButton=b.View.extend({tagName:"button",classNames:["btn","pull-right"],click:function(){window.open(d+"/preferences","_blank")}}),a.ChangeMasterButton=b.View.extend({tagName:"button",classNames:["btn"],click:function(b){b.preventDefault(),b.stopPropagation();var c,d=this.get("controller");d.get("firstObject")&&(c=d.get("changeMasterModalView"),c.show(function(b,e){try{a.ViewsUtils.decipher(b,d.get("firstObject.secret"))}catch(f){return!1}return d.forEach(function(f){var g=a.ViewsUtils.decipher(b,f.get("secret"));g=a.ViewsUtils.cipher(e,g,c,d,!0),f.set("secret",g),g=null,f.save()}),b=null,e=null,!0},!0))}}),a.PasswordLengthInput=b.View.extend({tagName:"input",attributeBindings:["type","min","step","value"],type:"number",min:0,step:1,value:20,classNames:["span2"],change:function(c){a.settings.set("passGenLength",parseInt(b.$(c.target).val(),10))}})}(Yith,Ember,sjcl,yithServerHost),function(a,b){"use strict";a.ServiceButton=b.View.extend({tagName:"button",classNames:["btn btn-info"],getUIElems:function(a){var b={$node:a.parents("tr")};return b.$input=b.$node.find("td:first-child input"),b.$countdown=b.$node.find("td:first-child span"),b.$close=b.$countdown.next(),b},showCloseButton:function(a){a.$close.off("click"),a.$close.click(function(){a.$input.hide().attr("value",""),a.$close.hide()}),a.$close.show()},showCountDown:function(a){var b;a.$countdown.text("5"),a.$countdown.show(),b=setInterval(function(){a.$countdown.text(parseInt(a.$countdown.text(),10)-1)},1e3),setTimeout(function(){clearInterval(b),a.$input.hide().attr("value",""),a.$countdown.hide()},5500)},click:function(c){var d=this;this.get("controller.list_controller.masterModalView").show(function(e){var f,g=d.get("controller.secret");try{g=a.ViewsUtils.decipher(e,g)}catch(h){return!1}return e=null,f=d.getUIElems(b.$(c.target)),f.$input.val(g).show().focus().select(),g=null,a.settings.get("disableCountdown")?d.showCloseButton(f):d.showCountDown(f),!0})}}),a.TagButton=b.View.extend({tagName:"span",classNames:["label","pointer"],click:function(){var a=this.get("controller");a.activateFilter||(a=a.get("list_controller")),a.activateFilter(this.$().text().trim())}}),a.FilterButton=a.TagButton.extend({click:function(){this.get("controller").deactivateFilter(this.$().text().trim())}}),a.NotesButton=b.View.extend({tagName:"button",classNames:["btn","notes"],didInsertElement:function(){var a=this.get("controller").get("notes");a?this.$().popover({placement:"left",title:"Notes",content:a}):this.$().addClass("disabled")}})}(Yith,Ember),function(a,b){"use strict";a.SecretGroup=b.View.extend({templateName:"secret-group",checkerList:[],validateSecret:function(){for(var a=this.$().parents("form"),b=this;this.get("checkerList").length>0;)clearTimeout(this.get("checkerList").pop());this.get("checkerList").push(setTimeout(function(){b.get("controller").validateSecretChecker(a)},500))},initStrengthMeter:function(a){var b=this.$().find("#edit-secret1"),c=this;b.length>0?b.pwstrength({ui:{viewports:{progress:this.$().find("#strength-meter .progressbar"),verdict:this.$().find("#strength-meter .verdict")},bootstrap2:!0}}):a&&setTimeout(function(){c.initStrengthMeter(!0)},100)},bindValidation:function(a){var b=this.$().find(".edit-secret"),c=this;b.length>0?b.on("keyup",function(){c.validateSecret()}):a&&setTimeout(function(){c.bindValidation(!0)},100)},didInsertElement:function(){var a=this;this.initStrengthMeter(!1),this.bindValidation(!1),this.$().find("#show-secret-group").on("click",function(b){b.preventDefault(),b.stopPropagation(),a.get("controller").set("modifySecret",!0),a.bindValidation(!0),a.initStrengthMeter(!0)})}}),a.GenerateSecretButton=b.View.extend({tagName:"button",classNames:["btn"],click:function(b){b.preventDefault(),b.stopPropagation();var c,d,e="",f=a.settings.get("passGenCharset"),g=a.settings.get("passGenLength");for(d=0;g>d;d+=1)c=Math.floor(Math.random()*f.length),e+=f.charAt(c);this.$().parent().find("#edit-secret2").val(e).end().find("#edit-secret1").val(e).trigger("keyup"),e=null}}),a.TagsInput=b.View.extend({templateName:"tags-input",addTag:function(){var a=this.$().find("input").val().split(",");this.get("controller").addProvisionalTags(a),this.$().find("input").val("")},didInsertElement:function(){var a=this;this.$().find("input").typeahead({items:3,source:function(){return a.get("controller.controllers.passwordsIndex.allTags")}}),this.$().find("button").on("click",function(b){b.preventDefault(),b.stopPropagation(),a.addTag()})}}),a.SaveButton=b.View.extend({tagName:"button",classNames:["btn","btn-primary"],click:function(a){a.preventDefault(),a.stopPropagation(),this.get("controller").save(this.$().parents("form"))}})}(Yith,Ember);
//# sourceMappingURL=yith-1.1.1.min.map