2013-11-17 06:02:13 +08:00
|
|
|
/*! RainLoop Webmail Admin Module (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
2013-12-30 05:13:35 +08:00
|
|
|
!function(a,b,c,d,e,f){"use strict";function g(){this.sBase="#/",this.sCdnStaticDomain=eb.settingsGet("CdnStaticDomain"),this.sVersion=eb.settingsGet("Version"),this.sSpecSuffix=eb.settingsGet("AuthAccountHash")||"0",this.sServer=(eb.settingsGet("IndexFile")||"./")+"?",this.sCdnStaticDomain=""===this.sCdnStaticDomain?this.sCdnStaticDomain:"/"===this.sCdnStaticDomain.substr(-1)?this.sCdnStaticDomain:this.sCdnStaticDomain+"/"}function h(){}function i(){}function j(){var a=[i,h],b=f.find(a,function(a){return a.supported()});b&&(b=b,this.oDriver=new b)}function k(){}function l(a,b){this.sPosition=U.pString(a),this.sTemplate=U.pString(b),this.viewModelName="",this.viewModelVisibility=c.observable(!1),"Popups"===this.sPosition&&(this.modalVisibility=c.observable(!1)),this.viewModelDom=null}function m(a,b){this.sScreenName=a,this.aViewModels=U.isArray(b)?b:[]}function n(){this.sDefaultScreenName="",this.oScreens={},this.oBoot=null,this.oCurrentScreen=null,this.popupVisibility=c.observable(!1),this.popupVisibility.subscribe(function(a){eb&&eb.popupVisibility(a)})}function o(a,b){this.email=a||"",this.name=b||"",this.privateType=null,this.clearDuplicateName()}function p(){l.call(this,"Popups","PopupsDomain"),this.edit=c.observable(!1),this.saving=c.observable(!1),this.savingError=c.observable(""),this.whiteListPage=c.observable(!1),this.testing=c.observable(!1),this.testingDone=c.observable(!1),this.testingImapError=c.observable(!1),this.testingSmtpError=c.observable(!1),this.imapServerFocus=c.observable(!1),this.smtpServerFocus=c.observable(!1),this.name=c.observable(""),this.imapServer=c.observable(""),this.imapPort=c.observable(R.Values.ImapDefaulPort),this.imapSecure=c.observable(S.ServerSecure.None),this.imapShortLogin=c.observable(!1),this.smtpServer=c.observable(""),this.smtpPort=c.observable(R.Values.SmtpDefaulPort),this.smtpSecure=c.observable(S.ServerSecure.None),this.smtpShortLogin=c.observable(!1),this.smtpAuth=c.observable(!0),this.whiteList=c.observable(""),this.imapServerFocus.subscribe(function(a){a&&""!==this.name()&&""===this.imapServer()&&this.imapServer(this.name())},this),this.smtpServerFocus.subscribe(function(a){a&&""!==this.imapServer()&&""===this.smtpServer()&&this.smtpServer(this.imapServer())},this),this.headerText=c.computed(function(){var a=this.name();return this.edit()?'Edit Domain "'+a+'"':"Add Domain"+(""===a?"":' "'+a+'"')},this),this.domainIsComputed=c.computed(function(){return""!==this.name()&&""!==this.imapServer()&&""!==this.imapPort()&&""!==this.smtpServer()&&""!==this.smtpPort()},this),this.canBeTested=c.computed(function(){return!this.testing()&&this.domainIsComputed()},this),this.canBeSaved=c.computed(function(){return!this.saving()&&this.domainIsComputed()},this),this.createOrAddCommand=U.createCommand(this,function(){this.saving(!0),eb.remote().createOrUpdateDomain(f.bind(this.onDomainCreateOrSaveResponse,this),!this.edit(),this.name(),this.imapServer(),this.imapPort(),this.imapSecure(),this.imapShortLogin(),this.smtpServer(),this.smtpPort(),this.smtpSecure(),this.smtpShortLogin(),this.smtpAuth(),this.whiteList())},this.canBeSaved),this.testConnectionCommand=U.createCommand(this,function(){this.whiteListPage(!1),this.testingDone(!1),this.testingImapError(!1),this.testingSmtpError(!1),this.testing(!0),eb.remote().testConnectionForDomain(f.bind(this.onTestConnectionResponse,this),this.imapServer(),this.imapPort(),this.imapSecure(),this.smtpServer(),this.smtpPort(),this.smtpSecure(),this.smtpAuth())},this.canBeTested),this.whiteListCommand=U.createCommand(this,function(){this.whiteListPage(!this.whiteListPage())}),n.constructorEnd(this)}function q(){l.call(this,"Popups","PopupsPlugin");var a=this;this.onPluginSettingsUpdateResponse=f.bind(this.onPluginSettingsUpdateResponse,this),this.saveError=c.observable(""),this.name=c.observable(""),this.readme=c.observable(""),this.configures=c.observableArray([]),this.hasReadme=c.computed(function(){return""!==this.readme()},this),this.hasConfiguration=c.computed(function(){return 0<this.configures().length},this),this.readmePopoverConf={placement
|
2014-01-03 21:32:25 +08:00
|
|
|
break;case S.InterfaceAnimation.Normal:ab.removeClass("no-rl-anim rl-anim-full").addClass("rl-anim"),X.sAnimationType=a}}),b.interfaceAnimation.valueHasMutated(),b.desktopNotificationsPermisions=c.computed(function(){b.desktopNotifications();var c=S.DesktopNotifications.NotSupported;if(db&&db.permission)switch(db.permission.toLowerCase()){case"granted":c=S.DesktopNotifications.Allowed;break;case"denied":c=S.DesktopNotifications.Denied;break;case"default":c=S.DesktopNotifications.NotAllowed}else a.webkitNotifications&&a.webkitNotifications.checkPermission&&(c=a.webkitNotifications.checkPermission());return c}),b.useDesktopNotifications=c.computed({read:function(){return b.desktopNotifications()&&S.DesktopNotifications.Allowed===b.desktopNotificationsPermisions()},write:function(a){if(a){var c=b.desktopNotificationsPermisions();S.DesktopNotifications.Allowed===c?b.desktopNotifications(!0):S.DesktopNotifications.NotAllowed===c?db.requestPermission(function(){b.desktopNotifications.valueHasMutated(),S.DesktopNotifications.Allowed===b.desktopNotificationsPermisions()?b.desktopNotifications()?b.desktopNotifications.valueHasMutated():b.desktopNotifications(!0):b.desktopNotifications()?b.desktopNotifications(!1):b.desktopNotifications.valueHasMutated()}):b.desktopNotifications(!1)}else b.desktopNotifications(!1)}}),b.language=c.observable(""),b.languages=c.observableArray([]),b.mainLanguage=c.computed({read:b.language,write:function(a){a!==b.language()?-1<U.inArray(a,b.languages())?b.language(a):0<b.languages().length&&b.language(b.languages()[0]):b.language.valueHasMutated()}}),b.theme=c.observable(""),b.themes=c.observableArray([]),b.mainTheme=c.computed({read:b.theme,write:function(a){if(a!==b.theme()){var c=b.themes();-1<U.inArray(a,c)?b.theme(a):0<c.length&&b.theme(c[0])}else b.theme.valueHasMutated()}}),b.allowCustomTheme=c.observable(!1),b.allowAdditionalAccounts=c.observable(!1),b.allowIdentities=c.observable(!1),b.determineUserLanguage=c.observable(!1),b.messagesPerPage=c.observable(R.Defaults.MessagesPerPage),b.mainMessagesPerPage=b.messagesPerPage,b.mainMessagesPerPage=c.computed({read:b.messagesPerPage,write:function(a){-1<U.inArray(U.pInt(a),R.Defaults.MessagesPerPageArray)?a!==b.messagesPerPage()&&b.messagesPerPage(a):b.messagesPerPage.valueHasMutated()}}),b.facebookEnable=c.observable(!1),b.facebookAppID=c.observable(""),b.facebookAppSecret=c.observable(""),b.twitterEnable=c.observable(!1),b.twitterConsumerKey=c.observable(""),b.twitterConsumerSecret=c.observable(""),b.googleEnable=c.observable(!1),b.googleClientID=c.observable(""),b.googleClientSecret=c.observable(""),b.dropboxEnable=c.observable(!1),b.dropboxApiKey=c.observable(""),b.contactsIsAllowed=c.observable(!1)},U.createMomentDate=function(a){return U.isUnd(a.moment)&&(a.moment=c.observable(moment())),c.computed(function(){return X.momentTrigger(),this.moment().fromNow()},a)},U.createMomentShortDate=function(a){return c.computed(function(){var a="",b=moment(),c=this.moment(),d=this.momentDate();return a=4>=b.diff(c,"hours")?d:b.format("L")===c.format("L")?U.i18n("MESSAGE_LIST/TODAY_AT",{TIME:c.format("LT")}):b.clone().subtract("days",1).format("L")===c.format("L")?U.i18n("MESSAGE_LIST/YESTERDAY_IN",{TIME:c.format("LT")}):b.year()===c.year()?c.format("D MMM."):c.format("LL")},a)},U.isFolderExpanded=function(a){var b=eb.local().get(S.ClientSideKeyName.ExpandedFolders);return f.isArray(b)&&-1!==f.indexOf(b,a)},U.setExpandedFolder=function(a,b){var c=eb.local().get(S.ClientSideKeyName.ExpandedFolders);f.isArray(c)||(c=[]),b?(c.push(a),c=f.uniq(c)):c=f.without(c,a),eb.local().set(S.ClientSideKeyName.ExpandedFolders,c)},U.initLayoutResizer=function(a,c,d){var e=b(a),f=b(c),g=eb.local().get(d)||null,h=function(a,b){b&&b.size&&b.size.width&&(eb.local().set(d,b.size.width),f.css({left:""+b.size.width+"px"}))};null!==g&&(e.css({width:""+g+"px"}),f.css({left:""+g+"px"})),e.resizable({helper:"ui-resizable-helper",minWidth:120,maxWidth:400,handles:"e",stop:h})},U.initBlockquoteSwitcher=function(a){if(a){var c=b("blockquote:not(.rl-bq-switcher)",a).filter(function(){r
|
|
|
|
bb.on("keydown",function(b){var c=!0;return b&&S.EventKeyCode.Esc===b.keyCode&&a.modalVisibility()&&(U.delegateRun(a,"cancelCommand"),c=!1),c})},p.prototype.clearForm=function(){this.edit(!1),this.whiteListPage(!1),this.savingError(""),this.name(""),this.imapServer(""),this.imapPort(R.Values.ImapDefaulPort),this.imapSecure(S.ServerSecure.None),this.imapShortLogin(!1),this.smtpServer(""),this.smtpPort(R.Values.SmtpDefaulPort),this.smtpSecure(S.ServerSecure.None),this.smtpShortLogin(!1),this.smtpAuth(!0),this.whiteList("")},U.extendAsViewModel("PopupsPluginViewModel",q),q.prototype.onPluginSettingsUpdateResponse=function(a,b){S.StorageResultType.Success===a&&b&&b.Result?this.cancelCommand():(this.saveError(""),b&&b.ErrorCode?this.saveError(U.getNotification(b.ErrorCode)):this.saveError(U.getNotification(S.Notification.CantSavePluginSettings)))},q.prototype.onShow=function(a){if(this.name(),this.readme(),this.configures([]),a){this.name(a.Name),this.readme(a.Readme);var b=a.Config;U.isNonEmptyArray(b)&&this.configures(f.map(b,function(a){return{value:c.observable(a[0]),Name:a[1],Type:a[2],Label:a[3],Default:a[4],Desc:a[5]}}))}},q.prototype.tryToClosePopup=function(){var a=this;Z.showScreenPopup(t,[U.i18n("POPUPS_ASK/DESC_WANT_CLOSE_THIS_WINDOW"),function(){a.modalVisibility()&&U.delegateRun(a,"cancelCommand")}])},q.prototype.onBuild=function(){var a=this;bb.on("keydown",function(b){var c=!0;return b&&S.EventKeyCode.Esc===b.keyCode&&a.modalVisibility()&&(a.tryToClosePopup(),c=!1),c})},U.extendAsViewModel("PopupsActivateViewModel",r),r.prototype.onShow=function(){this.domain(eb.settingsGet("AdminDomain")),this.activateProcess()||(this.key(""),this.activateText(""),this.activateText.isError(!1),this.activationSuccessed(!1))},r.prototype.onFocus=function(){this.activateProcess()||this.key.focus(!0)},r.prototype.validateSubscriptionKey=function(){var a=this.key();return""===a||!!/^RL[\d]+-[A-Z0-9\-]+Z$/.test(U.trim(a))},U.extendAsViewModel("PopupsLanguagesViewModel",s),s.prototype.languageEnName=function(a){return U.convertLangName(a,!0)},s.prototype.resetMainLanguage=function(){var a=eb.data().mainLanguage();f.each(this.languages(),function(b){b.selected(b.key===a)})},s.prototype.onShow=function(){this.exp(!0),this.resetMainLanguage()},s.prototype.onHide=function(){this.exp(!1)},s.prototype.onBuild=function(){var a=this;bb.on("keydown",function(b){var c=!0;return b&&S.EventKeyCode.Esc===b.keyCode&&a.modalVisibility()&&(U.delegateRun(a,"cancelCommand"),c=!1),c})},s.prototype.changeLanguage=function(a){eb.data().mainLanguage(a),this.cancelCommand()},U.extendAsViewModel("PopupsAskViewModel",t),t.prototype.clearPopup=function(){this.askDesc(""),this.yesButton(U.i18n("POPUPS_ASK/BUTTON_YES")),this.noButton(U.i18n("POPUPS_ASK/BUTTON_NO")),this.yesFocus(!1),this.noFocus(!1),this.fYesAction=null,this.fNoAction=null},t.prototype.yesClick=function(){U.isFunc(this.fYesAction)&&this.fYesAction.call(null),this.cancelCommand()},t.prototype.noClick=function(){U.isFunc(this.fNoAction)&&this.fNoAction.call(null),this.cancelCommand()},t.prototype.onShow=function(a,b,c,d,e){this.clearPopup(),this.fYesAction=b||null,this.fNoAction=c||null,this.askDesc(a||""),d&&this.yesButton(d),d&&this.yesButton(e)},t.prototype.onFocus=function(){this.yesFocus(!0)},t.prototype.onHide=function(){},t.prototype.onBuild=function(){var a=this;bb.on("keydown",function(b){var c=!0;return b&&a.modalVisibility()&&(S.EventKeyCode.Tab===b.keyCode||S.EventKeyCode.Right===b.keyCode||S.EventKeyCode.Left===b.keyCode)&&(a.yesFocus()?a.noFocus(!0):a.yesFocus(!0),c=!1),c})},U.extendAsViewModel("AdminLoginViewModel",u),u.prototype.onShow=function(){Z.routeOff(),f.delay(f.bind(function(){this.loginFocus(!0)},this),100)},u.prototype.onHide=function(){this.loginFocus(!1)},U.extendAsViewModel("AdminMenuViewModel",v),v.prototype.link=function(a){return"#/"+a},U.extendAsViewModel("AdminPaneViewModel",w),w.prototype.logoutClick=function(){eb.remote().adminLogout(function(){eb.loginAndLogoutReload()})},U.addSettingsViewModel(x,"AdminSettingsGeneral","General","general",!0),x.prototype.onB
|