2013-11-17 06:02:13 +08:00
|
|
|
/*! RainLoop Webmail Main Module (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
2013-12-21 00:15:29 +08:00
|
|
|
!function(a,b,c,d,e,f,g,h){"use strict";function i(){this.sBase="#/",this.sCdnStaticDomain=Bb.settingsGet("CdnStaticDomain"),this.sVersion=Bb.settingsGet("Version"),this.sSpecSuffix=Bb.settingsGet("AuthAccountHash")||"0",this.sServer=(Bb.settingsGet("IndexFile")||"./")+"?",this.sCdnStaticDomain=""===this.sCdnStaticDomain?this.sCdnStaticDomain:"/"===this.sCdnStaticDomain.substr(-1)?this.sCdnStaticDomain:this.sCdnStaticDomain+"/"}function j(a,c,d,e){var f={DisableHtml:!1,onSwitch:!1,LangSwitcherConferm:"EDITOR_TEXT_SWITCHER_CONFIRM",LangSwitcherTextLabel:"EDITOR_SWITCHER_TEXT_LABEL",LangSwitcherHtmlLabel:"EDITOR_SWITCHER_HTML_LABEL"};this.bIe=!!/msie/.test(navigator.userAgent.toLowerCase()),e=b.extend(f,pb.isUnd(e)?{}:e),this.oOptions=e,this.bOnlyPlain=!!this.oOptions.DisableHtml,this.fOnSwitch=this.oOptions.onSwitch,this.textarea=b(a).empty().addClass("editorTextArea"),this.htmlarea=b(c).empty().addClass("editorHtmlArea").prop("contentEditable","true"),this.toolbar=b(d).empty().addClass("editorToolbar"),j.htmlInitEditor.apply(this),j.htmlInitToolbar.apply(this),j.htmlAttachEditorEvents.apply(this),this.bOnlyPlain&&this.toolbar.hide()}function k(a,b,c,d,e){this.list=a,this.selectedItem=b,this.selectedItem.extend({toggleSubscribe:[null,function(a){a&&a.selected(!1)},function(a){a&&a.selected(!0)}]}),this.oContentVisible=null,this.oContentScrollable=null,this.sItemSelector=c,this.sItemSelectedSelector=d,this.sItemCheckedSelector=e,this.sLastUid="",this.oCallbacks={},this.iSelectTimer=0,this.bUseKeyboard=!0,this.emptyFunction=function(){},this.useItemSelectCallback=!0,this.throttleSelection=!1,this.selectedItem.subscribe(function(a){this.useItemSelectCallback&&(this.throttleSelection?(this.throttleSelection=!1,this.selectItemCallbacksThrottle(a)):this.selectItemCallbacks(a))},this);var f=this,g=[],i=null;this.list.subscribe(function(){var a=this,b=this.list();pb.isArray(b)&&h.each(b,function(b){b.checked()&&g.push(a.getItemUid(b)),null===i&&b.selected()&&(i=a.getItemUid(b))})},this,"beforeChange"),this.list.subscribe(function(a){if(this.useItemSelectCallback=!1,this.selectedItem(null),pb.isArray(a)){var b=this,c=g.length;h.each(a,function(a){c>0&&-1<pb.inArray(b.getItemUid(a),g)&&(a.checked(!0),c--),null!==i&&i===b.getItemUid(a)&&(a.selected(!0),i=null,b.selectedItem(a))})}this.useItemSelectCallback=!0,g=[],i=null},this),this.list.setSelectedByUid=function(a){f.selectByUid(a,!1)},this.selectItemCallbacksThrottle=h.debounce(this.selectItemCallbacks,300)}function l(){}function m(){}function n(){var a=[m,l],b=h.find(a,function(a){return a.supported()});b&&(b=b,this.oDriver=new b)}function o(){}function p(a,b){this.sPosition=pb.pString(a),this.sTemplate=pb.pString(b),this.viewModelName="",this.viewModelVisibility=c.observable(!1),"Popups"===this.sPosition&&(this.modalVisibility=c.observable(!1)),this.viewModelDom=null}function q(a,b){this.sScreenName=a,this.aViewModels=pb.isArray(b)?b:[]}function r(){this.sDefaultScreenName="",this.oScreens={},this.oBoot=null,this.oCurrentScreen=null,this.popupVisibility=c.observable(!1),this.popupVisibility.subscribe(function(a){Bb&&Bb.popupVisibility(a)})}function s(a,b){this.email=a||"",this.name=b||"",this.privateType=null,this.clearDuplicateName()}function t(){this.idContact=0,this.idContactStr="",this.display="",this.properties=[],this.readOnly=!1,this.scopeType=nb.ContactScopeType.Default,this.checked=c.observable(!1),this.selected=c.observable(!1),this.deleted=c.observable(!1),this.shared=c.observable(!1)}function u(a,b,d,e){this.type=c.observable(pb.isUnd(a)?nb.ContactPropertyType.Unknown:a),this.focused=c.observable(pb.isUnd(d)?!1:!!d),this.value=c.observable(pb.pString(b)),this.placeholder=c.observable(e||""),this.placeholderValue=c.computed(function(){var a=this.placeholder();return a?pb.i18n(a):""},this)}function v(){this.mimeType="",this.fileName="",this.estimatedSize=0,this.friendlySize="",this.isInline=!1,this.isLinked=!1,this.cid="",this.cidWithOutTags="",this.contentLocation="",this.download="",this.folder="",this.uid="",this.mimeIndex=""}function w(a,b,d,e,f,g,h){this.id=a,thi
|
|
|
|
}function O(){M.call(this),r.constructorEnd(this)}function P(){p.call(this,"Left","MailFolderList"),this.folderList=Bb.data().folderList,this.folderListSystem=Bb.data().folderListSystem,this.iDropOverTimer=0,this.allowContacts=!!Bb.settingsGet("ContactsIsAllowed"),r.constructorEnd(this)}function Q(){p.call(this,"Right","MailMessageList"),this.sLastUid=null,this.emptySubjectValue="";var a=Bb.data();this.popupVisibility=Bb.popupVisibility,this.messageList=a.messageList,this.currentMessage=a.currentMessage,this.isMessageSelected=a.isMessageSelected,this.messageListSearch=a.messageListSearch,this.messageListError=a.messageListError,this.folderMenuForMove=a.folderMenuForMove,this.useCheckboxesInList=a.useCheckboxesInList,this.mainMessageListSearch=a.mainMessageListSearch,this.messageListEndFolder=a.messageListEndFolder,this.messageListChecked=a.messageListChecked,this.messageListCheckedOrSelected=a.messageListCheckedOrSelected,this.messageListCheckedOrSelectedUidsWithSubMails=a.messageListCheckedOrSelectedUidsWithSubMails,this.messageListCompleteLoadingThrottle=a.messageListCompleteLoadingThrottle,pb.initOnStartOrLangChange(function(){this.emptySubjectValue=pb.i18n("MESSAGE_LIST/EMPTY_SUBJECT_TEXT")},this),this.userQuota=a.userQuota,this.userUsageSize=a.userUsageSize,this.userUsageProc=a.userUsageProc,this.dragOver=c.observable(!1).extend({throttle:1}),this.dragOverEnter=c.observable(!1).extend({throttle:1}),this.dragOverArea=c.observable(null),this.dragOverBodyArea=c.observable(null),this.messageListItemTemplate=c.computed(function(){return a.usePreviewPane()?"MailMessageListItem":"MailMessageListItemNoPreviewPane"}),this.messageListSearchDesc=c.computed(function(){var b=a.messageListEndSearch();return""===b?"":pb.i18n("MESSAGE_LIST/SEARCH_RESULT_FOR",{SEARCH:b})}),this.messageListPagenator=c.computed(pb.computedPagenatorHelper(a.messageListPage,a.messageListPageCount)),this.checkAll=c.computed({read:function(){return 0<Bb.data().messageListCheckedOrSelected().length},write:function(a){a=!!a,h.each(Bb.data().messageList(),function(b){b.checked(a)}),a||Bb.data().message(null)}}),this.inputMessageListSearchFocus=c.observable(!1),this.sLastSearchValue="",this.inputProxyMessageListSearch=c.computed({read:this.mainMessageListSearch,write:function(a){this.sLastSearchValue=a},owner:this}),this.isIncompleteChecked=c.computed(function(){var a=Bb.data().messageList().length,b=Bb.data().messageListCheckedOrSelected().length;return a>0&&b>0&&a>b},this),this.hasMessages=c.computed(function(){return 0<this.messageList().length},this),this.hasCheckedLines=c.computed(function(){return 0<this.messageListChecked().length},this),this.hasCheckedOrSelectedLines=c.computed(function(){return 0<this.messageListCheckedOrSelected().length},this),this.isSpamFolder=c.computed(function(){return Bb.data().spamFolder()===this.messageListEndFolder()},this),this.isSpamDisabled=c.computed(function(){return mb.Values.UnuseOptionValue===Bb.data().spamFolder()},this),this.isTrashFolder=c.computed(function(){return Bb.data().trashFolder()===this.messageListEndFolder()},this),this.canBeMoved=this.hasCheckedOrSelectedLines,this.clearCommand=pb.createCommand(this,function(){ub.showScreenPopup(B,[Bb.data().currentFolder()])}),this.multyForwardCommand=pb.createCommand(this,function(){ub.showScreenPopup(E,[nb.ComposeType.ForwardAsAttachment,Bb.data().messageListCheckedOrSelected()])},this.canBeMoved),this.deleteWithoutMoveCommand=pb.createCommand(this,function(){this.deleteSelectedMessageFromCurrentFolder(nb.FolderType.Trash,!1)},this.canBeMoved),this.deleteCommand=pb.createCommand(this,function(){this.deleteSelectedMessageFromCurrentFolder(nb.FolderType.Trash,!0)},this.canBeMoved),this.spamCommand=pb.createCommand(this,function(){this.deleteSelectedMessageFromCurrentFolder(nb.FolderType.Spam,!0)},this.canBeMoved),this.moveCommand=pb.createCommand(this,pb.emptyFunction,this.canBeMoved),this.setCommand=pb.createCommand(this,pb.emptyFunction,this.hasCheckedLines),this.checkCommand=pb.createCommand(this,pb.emptyFunction,this.hasCheckedLines),this.reloadCommand=pb.create
|
|
|
|
},pb.i18nToNode=function(a){h.defer(function(){b(".i18n",a).each(function(){var a=b(this),c="";c=a.data("i18n-text"),c?a.text(pb.i18n(c)):(c=a.data("i18n-html"),c&&a.html(pb.i18n(c)),c=a.data("i18n-placeholder"),c&&a.attr("placeholder",pb.i18n(c)))})})},pb.i18nToDoc=function(){a.rainloopI18N&&(wb=a.rainloopI18N||{},pb.i18nToNode(zb),sb.langChangeTrigger(!sb.langChangeTrigger())),a.rainloopI18N={}},pb.initOnStartOrLangChange=function(a,b,c){a&&a.call(b),c?sb.langChangeTrigger.subscribe(function(){a&&a.call(b),c.call(b)}):a&&sb.langChangeTrigger.subscribe(a,b)},pb.inFocus=function(){var a=document.activeElement;return a&&("INPUT"===a.tagName||"TEXTAREA"===a.tagName||"IFRAME"===a.tagName||"DIV"===a.tagName&&"editorHtmlArea"===a.className&&a.contentEditable)},pb.removeInFocus=function(){if(document&&document.activeElement&&document.activeElement.blur){var a=b(document.activeElement);(a.is("input")||a.is("textarea"))&&document.activeElement.blur()}},pb.removeSelection=function(){if(a&&a.getSelection){var b=a.getSelection();b&&b.removeAllRanges&&b.removeAllRanges()}else document&&document.selection&&document.selection.empty&&document.selection.empty()},pb.replySubjectAdd=function(b,c,d){var e=null,f=pb.trim(c);return null===(e=new a.RegExp("^"+b+"[\\s]?\\:(.*)$","gi").exec(c))||pb.isUnd(e[1])?null===(e=new a.RegExp("^("+b+"[\\s]?[\\[\\(]?)([\\d]+)([\\]\\)]?[\\s]?\\:.*)$","gi").exec(c))||pb.isUnd(e[1])||pb.isUnd(e[2])||pb.isUnd(e[3])?f=b+": "+c:(f=e[1]+(pb.pInt(e[2])+1)+e[3],f=e[1]+(pb.pInt(e[2])+1)+e[3]):f=b+"[2]: "+e[1],f=f.replace(/[\s]+/g," "),(pb.isUnd(d)?!0:d)?pb.fixLongSubject(f):f},pb.fixLongSubject=function(a){var b=0,c=null;a=pb.trim(a.replace(/[\s]+/," "));do c=/^Re(\[([\d]+)\]|):[\s]{0,3}Re(\[([\d]+)\]|):/gi.exec(a),(!c||pb.isUnd(c[0]))&&(c=null),c&&(b=0,b+=pb.isUnd(c[2])?1:0+pb.pInt(c[2]),b+=pb.isUnd(c[4])?1:0+pb.pInt(c[4]),a=a.replace(/^Re(\[[\d]+\]|):[\s]{0,3}Re(\[[\d]+\]|):/gi,"Re"+(b>0?"["+b+"]":"")+":"));while(c);return a=a.replace(/[\s]+/," ")},pb.roundNumber=function(a,b){return Math.round(a*Math.pow(10,b))/Math.pow(10,b)},pb.friendlySize=function(a){return a=pb.pInt(a),a>=1073741824?pb.roundNumber(a/1073741824,1)+"GB":a>=1048576?pb.roundNumber(a/1048576,1)+"MB":a>=1024?pb.roundNumber(a/1024,0)+"KB":a+"B"},pb.log=function(b){a.console&&a.console.log&&a.console.log(b)},pb.getNotification=function(a){return a=pb.pInt(a),pb.isUnd(ob[a])?"":ob[a]},pb.initNotificationLanguage=function(){ob[nb.Notification.InvalidToken]=pb.i18n("NOTIFICATIONS/INVALID_TOKEN"),ob[nb.Notification.AuthError]=pb.i18n("NOTIFICATIONS/AUTH_ERROR"),ob[nb.Notification.AccessError]=pb.i18n("NOTIFICATIONS/ACCESS_ERROR"),ob[nb.Notification.ConnectionError]=pb.i18n("NOTIFICATIONS/CONNECTION_ERROR"),ob[nb.Notification.CaptchaError]=pb.i18n("NOTIFICATIONS/CAPTCHA_ERROR"),ob[nb.Notification.SocialFacebookLoginAccessDisable]=pb.i18n("NOTIFICATIONS/SOCIAL_FACEBOOK_LOGIN_ACCESS_DISABLE"),ob[nb.Notification.SocialTwitterLoginAccessDisable]=pb.i18n("NOTIFICATIONS/SOCIAL_TWITTER_LOGIN_ACCESS_DISABLE"),ob[nb.Notification.SocialGoogleLoginAccessDisable]=pb.i18n("NOTIFICATIONS/SOCIAL_GOOGLE_LOGIN_ACCESS_DISABLE"),ob[nb.Notification.DomainNotAllowed]=pb.i18n("NOTIFICATIONS/DOMAIN_NOT_ALLOWED"),ob[nb.Notification.AccountNotAllowed]=pb.i18n("NOTIFICATIONS/ACCOUNT_NOT_ALLOWED"),ob[nb.Notification.CantGetMessageList]=pb.i18n("NOTIFICATIONS/CANT_GET_MESSAGE_LIST"),ob[nb.Notification.CantGetMessage]=pb.i18n("NOTIFICATIONS/CANT_GET_MESSAGE"),ob[nb.Notification.CantDeleteMessage]=pb.i18n("NOTIFICATIONS/CANT_DELETE_MESSAGE"),ob[nb.Notification.CantMoveMessage]=pb.i18n("NOTIFICATIONS/CANT_MOVE_MESSAGE"),ob[nb.Notification.CantCopyMessage]=pb.i18n("NOTIFICATIONS/CANT_MOVE_MESSAGE"),ob[nb.Notification.CantSaveMessage]=pb.i18n("NOTIFICATIONS/CANT_SAVE_MESSAGE"),ob[nb.Notification.CantSendMessage]=pb.i18n("NOTIFICATIONS/CANT_SEND_MESSAGE"),ob[nb.Notification.InvalidRecipients]=pb.i18n("NOTIFICATIONS/INVALID_RECIPIENTS"),ob[nb.Notification.CantCreateFolder]=pb.i18n("NOTIFICATIONS/CANT_CREATE_FOLDER"),ob[nb.Notification.CantRenameFolder]=pb.i18n("NOTIFICATIONS/CANT_RENAME
|
|
|
|
},j.prototype.getTextFromHtml=function(a){var b="",c="> ",d=function(){if(arguments&&1<arguments.length){var a=pb.trim(arguments[1]).replace(/__bq__start__([\s\S\n\r]*)__bq__end__/gm,d);return a="\n"+c+pb.trim(a).replace(/\n/gm,"\n"+c)+"\n>\n",a.replace(/\n([> ]+)/gm,function(){return arguments&&1<arguments.length?"\n"+pb.trim(arguments[1].replace(/[\s]/,""))+" ":""})}return""},e=function(){if(arguments&&1<arguments.length){var a=pb.trim(arguments[1]);return 0<a.length&&(a=a.replace(/<div[^>]*>([\s\S]*)<\/div>/gim,e),a="\n"+pb.trim(a)+"\n"),a}return""},f=function(){if(arguments&&1<arguments.length){var a=pb.trim(arguments[1]);return a}return""};return a=pb.isUnd(a)?!0:!!a,b=this.toHtmlString().replace(/[\s]+/gm," ").replace(/<br\s?\/?>/gim,"\n").replace(/<\/h\d>/gi,"\n").replace(/<\/p>/gi,"\n\n").replace(/<\/li>/gi,"\n").replace(/<\/td>/gi,"\n").replace(/<\/tr>/gi,"\n").replace(/<hr[^>]*>/gim,"\n_______________________________\n\n").replace(/<img [^>]*>/gim,"").replace(/<div[^>]*>([\s\S]*)<\/div>/gim,e).replace(/<blockquote[^>]*>/gim,"\n__bq__start__\n").replace(/<\/blockquote>/gim,"\n__bq__end__\n").replace(/<a [^>]*>([\s\S]*?)<\/a>/gim,f).replace(/ /gi," ").replace(/<[^>]*>/gm,"").replace(/>/gi,">").replace(/</gi,"<").replace(/&/gi,"&").replace(/&\w{2,6};/gi,""),(a?pb.splitPlainText(b):b).replace(/\n[ \t]+/gm,"\n").replace(/[\n]{3,}/gm,"\n\n").replace(/__bq__start__([\s\S]*)__bq__end__/gm,d).replace(/__bq__start__/gm,"").replace(/__bq__end__/gm,"")},j.prototype.getHtmlFromText=function(){return pb.convertPlainTextToHtml(this.textarea.val())},j.prototype.switchToggle=function(){this.isHtml()?this.switchToPlain():this.switchToHtml()},j.prototype.switchToPlain=function(c){c=pb.isUnd(c)?!0:c;var d=this.getTextFromHtml(),e=h.bind(function(a){a&&(this.toolbar.addClass("editorHideToolbar"),b(".editorSwitcher",this.toolbar).text(this.switcherLinkText(!1)),this.textarea.val(d),this.textarea.show(),this.htmlarea.hide(),this.fOnSwitch&&this.fOnSwitch(!1))},this);c&&0!==pb.trim(d).length?e(a.confirm(this.oOptions.LangSwitcherConferm)):e(!0)},j.prototype.switcherLinkText=function(a){return a?this.oOptions.LangSwitcherTextLabel:this.oOptions.LangSwitcherHtmlLabel},j.prototype.switchToHtml=function(){this.toolbar.removeClass("editorHideToolbar"),b(".editorSwitcher",this.toolbar).text(this.switcherLinkText(!0)),this.textarea.val(this.getHtmlFromText()),this.updateHtmlArea(),this.textarea.hide(),this.htmlarea.show(),this.fOnSwitch&&this.fOnSwitch(!0)},j.prototype.addButton=function(c,d){var e=this;b("<div />").addClass("editorToolbarButtom").append(b('<a tabindex="-1" href="javascript:void(0);"></a>').addClass(c)).attr("title",d).click(function(d){pb.isUnd(j.htmlFunctions[c])?a.alert(c):j.htmlFunctions[c].apply(e,[b(this),d])}).appendTo(this.toolbar)},j.htmlInitToolbar=function(){this.bOnlyPlain||(this.addButton("bold","Bold"),this.addButton("italic","Italic"),this.addButton("underline","Underline"),this.addButton("strikethrough","Strikethrough"),this.addButton("removeformat","removeformat"),this.addButton("justifyleft","justifyleft"),this.addButton("justifycenter","justifycenter"),this.addButton("justifyright","justifyright"),this.addButton("horizontalrule","horizontalrule"),this.addButton("orderedlist","orderedlist"),this.addButton("unorderedlist","unorderedlist"),this.addButton("indent","indent"),this.addButton("outdent","outdent"),this.addButton("forecolor","forecolor"),function(a,b){a("<span />").addClass("editorSwitcher").text(b.switcherLinkText(!0)).click(function(){b.switchToggle()}).appendTo(b.toolbar)}(b,this))},j.htmlInitEditor=function(){this.editor=this.htmlarea[0],this.editor.innerHTML=this.textarea.val()},j.htmlAttachEditorEvents=function(){var b=this,c=function(a){return a&&a.type&&0===a.type.indexOf("image/")},d=function(d){if(d=(d&&d.originalEvent?d.originalEvent:d)||a.event){d.stopPropagation(),d.preventDefault();var e=null,f=null,g=d.files||(d.dataTransfer?d.dataTransfer.files:null);g&&1===g.length&&c(g[0])&&(f=g[0],e=new a.FileReader,e.onload=function(a){return function(c){b.insertImage(c.target.res
|
|
|
|
},x.prototype.replyEmails=function(a){var b=[],c=pb.isUnd(a)?{}:a;return x.replyHelper(this.replyTo,c,b),0===b.length&&x.replyHelper(this.from,c,b),b},x.prototype.replyAllEmails=function(a){var b=[],c=[],d=pb.isUnd(a)?{}:a;return x.replyHelper(this.replyTo,d,b),0===b.length&&x.replyHelper(this.from,d,b),x.replyHelper(this.to,d,b),x.replyHelper(this.cc,d,c),[b,c]},x.prototype.textBodyToString=function(){return this.body?this.body.html():""},x.prototype.attachmentsToStringLine=function(){var a=h.map(this.attachments(),function(a){return a.fileName+" ("+a.friendlySize+")"});return a&&0<a.length?a.join(", "):""},x.prototype.getDataForWindowPopup=function(){return{popupFrom:this.fromToLine(!1),popupTo:this.toToLine(!1),popupCc:this.ccToLine(!1),popupBcc:this.bccToLine(!1),popupSubject:this.subject(),popupDate:this.fullFormatDateValue(),popupAttachments:this.attachmentsToStringLine(),popupBody:this.textBodyToString()}},x.prototype.viewPopupMessage=function(c){pb.windowPopupKnockout(this.getDataForWindowPopup(),"PopupsWindowSimpleMessage",this.subject(),function(d){d&&d.document&&d.document.body&&(b("img.lazy",d.document.body).each(function(a,c){var d=b(c),e=d.data("original"),f=d.attr("src");a>=0&&e&&!f&&d.attr("src",e)}),c&&a.setTimeout(function(){d.print()},100))})},x.prototype.printMessage=function(){this.viewPopupMessage(!0)},x.prototype.generateUid=function(){return this.folderFullNameRaw+"/"+this.uid},x.prototype.populateByMessageListItem=function(a){return this.folderFullNameRaw=a.folderFullNameRaw,this.uid=a.uid,this.requestHash=a.requestHash,this.subject(a.subject()),this.size(a.size()),this.dateTimeStampInUTC(a.dateTimeStampInUTC()),this.priority(a.priority()),this.fromEmailString(a.fromEmailString()),this.toEmailsString(a.toEmailsString()),this.emails=a.emails,this.from=a.from,this.to=a.to,this.cc=a.cc,this.bcc=a.bcc,this.replyTo=a.replyTo,this.unseen(a.unseen()),this.flagged(a.flagged()),this.answered(a.answered()),this.forwarded(a.forwarded()),this.selected(a.selected()),this.checked(a.checked()),this.hasAttachments(a.hasAttachments()),this.attachmentsMainType(a.attachmentsMainType()),this.moment(a.moment()),this.body=null,this.priority(nb.MessagePriority.Normal),this.aDraftInfo=[],this.sMessageId="",this.sInReplyTo="",this.sReferences="",this.parentUid(a.parentUid()),this.threads(a.threads()),this.threadsLen(a.threadsLen()),this.computeSenderEmail(),this},x.prototype.showExternalImages=function(a){this.body&&this.body.data("rl-has-images")&&(a=pb.isUnd(a)?!1:a,this.hasImages(!1),this.body.data("rl-has-images",!1),b("[data-x-src]",this.body).each(function(){a&&b(this).is("img")?b(this).addClass("lazy").attr("data-original",b(this).attr("data-x-src")).removeAttr("data-x-src"):b(this).attr("src",b(this).attr("data-x-src")).removeAttr("data-x-src")}),b("[data-x-style-url]",this.body).each(function(){var a=pb.trim(b(this).attr("style"));a=""===a?"":";"===a.substr(-1)?a+" ":a+"; ",b(this).attr("style",a+b(this).attr("data-x-style-url")).removeAttr("data-x-style-url")}),a&&(b("img.lazy",this.body).addClass("lazy-inited").lazyload({threshold:400,effect:"fadeIn",skip_invisible:!1,container:b(".RL-MailMessageView .messageView .messageItem .content")[0]}),yb.resize()),pb.windowResize(500))},x.prototype.showInternalImages=function(a){if(this.body&&!this.body.data("rl-init-internal-images")){a=pb.isUnd(a)?!1:a;var c=this;this.body.data("rl-init-internal-images",!0),b("[data-x-src-cid]",this.body).each(function(){var d=c.findAttachmentByCid(b(this).attr("data-x-src-cid"));d&&d.download&&(a&&b(this).is("img")?b(this).addClass("lazy").attr("data-original",d.linkPreview()):b(this).attr("src",d.linkPreview()))}),b("[data-x-src-location]",this.body).each(function(){var d=c.findAttachmentByContentLocation(b(this).attr("data-x-src-location"));d||(d=c.findAttachmentByCid(b(this).attr("data-x-src-location"))),d&&d.download&&(a&&b(this).is("img")?b(this).addClass("lazy").attr("data-original",d.linkPreview()):b(this).attr("src",d.linkPreview()))}),b("[data-x-style-cid]",this.body).each(function(){var a="",d="",e=c.findAttachmentByCid(b(
|
|
|
|
},L.prototype.onBuild=function(){var c=this,d=Bb.settingsGet("JsHash"),e=function(a){a=pb.pInt(a),0===a?(c.submitRequest(!0),Bb.loginAndLogoutReload()):c.submitError(pb.getNotification(a))};switch(this.facebookLoginEnabled(!!Bb.settingsGet("AllowFacebookSocial")),this.twitterLoginEnabled(!!Bb.settingsGet("AllowTwitterSocial")),this.googleLoginEnabled(!!Bb.settingsGet("AllowGoogleSocial")),(Bb.settingsGet("SignMe")||"unused").toLowerCase()){case nb.LoginSignMeTypeAsString.DefaultOff:this.signMeType(nb.LoginSignMeType.DefaultOff);break;case nb.LoginSignMeTypeAsString.DefaultOn:this.signMeType(nb.LoginSignMeType.DefaultOn);break;default:case nb.LoginSignMeTypeAsString.Unused:this.signMeType(nb.LoginSignMeType.Unused)}this.email(Bb.data().devEmail),this.login(Bb.data().devLogin),this.password(Bb.data().devPassword),this.googleLoginEnabled()&&(a["rl_"+d+"_google_login_service"]=e),this.facebookLoginEnabled()&&(a["rl_"+d+"_facebook_login_service"]=e),this.twitterLoginEnabled()&&(a["rl_"+d+"_twitter_login_service"]=e),h.delay(function(){Bb.data().language.subscribe(function(a){c.langRequest(!0),b.ajax({url:Bb.link().langLink(a),dataType:"script",cache:!0}).done(function(){c.bSendLanguage=!0,pb.i18nToDoc(),b.cookie("rllang",Bb.data().language(),{expires:30})}).always(function(){c.langRequest(!1)})})},50)},L.prototype.selectLanguage=function(){ub.showScreenPopup(J)},h.extend(M.prototype,p.prototype),M.prototype.accountClick=function(a,b){if(a&&b&&!pb.isUnd(b.which)&&1===b.which){var c=this;this.accountsLoading(!0),h.delay(function(){c.accountsLoading(!1)},1e3)}return!0},M.prototype.emailTitle=function(){return Bb.data().accountEmail()},M.prototype.settingsClick=function(){ub.setHash(Bb.link().settings())},M.prototype.addAccountClick=function(){this.allowAddAccount&&ub.showScreenPopup(H)},M.prototype.logoutClick=function(){Bb.remote().logout(function(){a.__rlah_clear&&a.__rlah_clear(),Bb.loginAndLogoutReload(!0,Bb.settingsGet("ParentEmail")&&0<Bb.settingsGet("ParentEmail").length)})},pb.extendAsViewModel("MailBoxSystemDropDownViewModel",N,M),pb.extendAsViewModel("SettingsSystemDropDownViewModel",O,M),pb.extendAsViewModel("MailBoxFolderListViewModel",P),P.prototype.onBuild=function(a){a.on("click",".b-folders .e-item .e-link .e-collapsed-sign",function(a){var b=c.dataFor(this),d=!1;b&&a&&(d=b.collapsed(),pb.setExpandedFolder(b.fullNameHash,d),b.collapsed(!d),a.preventDefault(),a.stopPropagation())}).on("click",".b-folders .e-item .e-link.selectable",function(a){a.preventDefault();var b=c.dataFor(this);b&&(Bb.data().usePreviewPane()||Bb.data().message(null),b.fullNameRaw===Bb.data().currentFolderFullNameRaw()&&Bb.cache().setFolderHash(b.fullNameRaw,""),ub.setHash(Bb.link().mailBox(b.fullNameHash)))})},P.prototype.messagesDropOver=function(b){a.clearTimeout(this.iDropOverTimer),b&&b.collapsed()&&(this.iDropOverTimer=a.setTimeout(function(){b.collapsed(!1),pb.setExpandedFolder(b.fullNameHash,!0),pb.windowResize()},500))},P.prototype.messagesDropOut=function(){a.clearTimeout(this.iDropOverTimer)},P.prototype.messagesDrop=function(a,b){if(a&&b&&b.helper){var c=b.helper.data("rl-folder"),d="1"===b.helper.data("rl-copy"),e=b.helper.data("rl-uids");Q&&Q.__vm&&pb.isNormal(c)&&pb.isArray(e)&&Q.__vm.moveMessagesToFolder(c,e,a.fullNameRaw,d)}},P.prototype.composeClick=function(){ub.showScreenPopup(E)},P.prototype.contactsClick=function(){this.allowContacts&&ub.showScreenPopup(F)},pb.extendAsViewModel("MailBoxMessageListViewModel",Q),Q.prototype.emptySubjectValue="",Q.prototype.searchEnterAction=function(){this.mainMessageListSearch(this.sLastSearchValue),this.inputMessageListSearchFocus(!1)},Q.prototype.cancelSearch=function(){this.mainMessageListSearch(""),this.inputMessageListSearchFocus(!1)},Q.prototype.removeMessagesFromList=function(a,b,c,d){c=pb.isNormal(c)?c:"",d=pb.isUnd(d)?!1:!!d;var e=0,f=Bb.data(),g=Bb.cache().getFolderFromCacheList(a),i=""===c?null:Bb.cache().getFolderFromCacheList(c||""),j=f.currentFolderFullNameRaw(),k=f.message(),l=j===a?h.filter(f.messageList(),function(a){return a&&-1<pb.inArray(a.uid,b)}):[];h.each(l,functio
|
|
|
|
},bb.prototype.setMessageList=function(a,b){if(a&&a.Result&&"Collection/MessageCollection"===a.Result["@Object"]&&a.Result["@Collection"]&&pb.isArray(a.Result["@Collection"])){var c=Bb.data(),d=Bb.cache(),e=null,g=0,h=0,i=0,j=0,k=[],l=f().unix(),m=c.staticMessageList,n=null,o=null,p=null,q=0,r=!1;for(i=pb.pInt(a.Result.MessageResultCount),j=pb.pInt(a.Result.Offset),pb.isNonEmptyArray(a.Result.LastCollapsedThreadUids)&&(e=a.Result.LastCollapsedThreadUids),p=Bb.cache().getFolderFromCacheList(pb.isNormal(a.Result.Folder)?a.Result.Folder:""),p&&!b&&(p.interval=l,Bb.cache().setFolderHash(a.Result.Folder,a.Result.FolderHash),pb.isNormal(a.Result.MessageCount)&&p.messageCountAll(a.Result.MessageCount),pb.isNormal(a.Result.MessageUnseenCount)&&(pb.pInt(p.messageCountUnread())!==pb.pInt(a.Result.MessageUnseenCount)&&(r=!0),p.messageCountUnread(a.Result.MessageUnseenCount)),this.initUidNextAndNewMessages(p.fullNameRaw,a.Result.UidNext,a.Result.NewMessages)),r&&p&&Bb.cache().clearMessageFlagsFromCacheByFolder(p.fullNameRaw),g=0,h=a.Result["@Collection"].length;h>g;g++)n=a.Result["@Collection"][g],n&&"Object/Message"===n["@Object"]&&(o=m[g],o&&o.initByJson(n)||(o=x.newInstanceFromJson(n)),o&&(d.hasNewMessageAndRemoveFromCache(o.folderFullNameRaw,o.uid)&&5>=q&&(q++,o.newForAnimation(!0)),o.deleted(!1),b?Bb.cache().initMessageFlagsFromCache(o):Bb.cache().storeMessageFlagsToCache(o),o.lastInCollapsedThread(e&&-1<pb.inArray(pb.pInt(o.uid),e)?!0:!1),k.push(o)));c.messageListCount(i),c.messageListSearch(pb.isNormal(a.Result.Search)?a.Result.Search:""),c.messageListEndSearch(pb.isNormal(a.Result.Search)?a.Result.Search:""),c.messageListEndFolder(pb.isNormal(a.Result.Folder)?a.Result.Folder:""),c.messageListPage(Math.ceil(j/c.messagesPerPage()+1)),c.messageList(k),c.messageListIsNotCompleted(!1),o=c.message(),o&&c.messageList.setSelectedByUid&&c.messageList.setSelectedByUid(o.generateUid()),m.length<k.length&&(c.staticMessageList=k),d.clearNewMessageCache(),p&&(b||r||Bb.data().useThreads())&&Bb.folderInformation(p.fullNameRaw,k)}else Bb.data().messageListCount(0),Bb.data().messageList([]),Bb.data().messageListError(pb.getNotification(a&&a.ErrorCode?a.ErrorCode:nb.Notification.CantGetMessageList))},cb.prototype.oRequests={},cb.prototype.defaultResponse=function(b,c,d,e,f,g){var i=function(){nb.StorageResultType.Success!==d&&sb.bUnload&&(d=nb.StorageResultType.Unload),nb.StorageResultType.Success===d&&e&&!e.Result?(e&&-1<pb.inArray(e.ErrorCode,[nb.Notification.AuthError,nb.Notification.AccessError,nb.Notification.ConnectionError,nb.Notification.DomainNotAllowed,nb.Notification.AccountNotAllowed,nb.Notification.MailServerError,nb.Notification.UnknownNotification,nb.Notification.UnknownError])&&sb.iAjaxErrorCount++,e&&nb.Notification.InvalidToken===e.ErrorCode&&sb.iTokenErrorCount++,mb.Values.TokenErrorLimit<sb.iTokenErrorCount&&Bb.loginAndLogoutReload(!0),(e.Logout||mb.Values.AjaxErrorLimit<sb.iAjaxErrorCount)&&(a.__rlah_clear&&a.__rlah_clear(),Bb.loginAndLogoutReload(!0))):nb.StorageResultType.Success===d&&e&&e.Result&&(sb.iAjaxErrorCount=0,sb.iTokenErrorCount=0),b&&(qb.runHook("ajax-default-response",[c,nb.StorageResultType.Success===d?e:null,d,f,g]),b(d,nb.StorageResultType.Success===d?e:null,f,c,g))};switch(d){case"success":d=nb.StorageResultType.Success;break;case"abort":d=nb.StorageResultType.Abort;break;default:d=nb.StorageResultType.Error}nb.StorageResultType.Error===d?h.delay(i,300):i()},cb.prototype.ajaxRequest=function(c,d,e,f,g){var i=this,j=""===f,k={},l=(new a.Date).getTime(),m=null,n="";return d=d||{},e=pb.isNormal(e)?e:2e4,f=pb.isUnd(f)?"":pb.pString(f),g=pb.isArray(g)?g:[],n=d.Action||"",n&&0<g.length&&h.each(g,function(a){i.oRequests[a]&&(i.oRequests[a].__aborted=!0,i.oRequests[a].abort&&i.oRequests[a].abort(),i.oRequests[a]=null)}),j&&(d.XToken=Bb.settingsGet("Token")),m=b.ajax({type:j?"POST":"GET",url:Bb.link().ajax(f),async:!0,dataType:"json",data:j?d:{},headers:k,timeout:e,global:!0}),m.always(function(b,e){var f=!1;b&&b.Time&&(f=pb.pInt(b.Time)>(new a.Date).getTime()-l),n&&i.oRequests[n]&&(i.oRequests[n].__aborted&&(e="
|
2013-12-19 08:53:42 +08:00
|
|
|
},this),a.SimplePace&&(a.SimplePace.set(70),a.SimplePace.sleep()),Bb.settingsGet("Auth")?(this.setTitle(pb.i18n("TITLES/LOADING")),this.folders(h.bind(function(c){ub.hideLoading(),c?(ub.startScreens([ib,jb]),zb.on("mousedown","#rl-center a",function(a){return!(a&&3!==a.which&&Bb.mailToHelper(b(this).attr("href")))}),(e||f||g)&&Bb.socialUsers(!0),Bb.sub("interval.2m",function(){Bb.folderInformation("INBOX")}),Bb.sub("interval.2m",function(){var a=Bb.data().currentFolderFullNameRaw();"INBOX"!==a&&Bb.folderInformation(a)}),Bb.sub("interval.3m",function(){Bb.folderInformationMultiply()}),Bb.sub("interval.5m",function(){Bb.quota()}),h.delay(function(){Bb.folderInformationMultiply(!0)},500),h.delay(function(){Bb.emailsPicsHashes(),Bb.remote().servicesPics(function(a,b){nb.StorageResultType.Success===a&&b&&b.Result&&Bb.cache().setServicesData(b.Result)})},2e3),qb.runHook("rl-start-user-screens")):(ub.startScreens([hb]),qb.runHook("rl-start-login-screens")),a.SimplePace&&a.SimplePace.set(100),sb.bMobileDevice||h.defer(function(){pb.initLayoutResizer("#rl-top-resizer-left","#rl-top-resizer-right","#rl-center",120,300,200,600,nb.ClientSideKeyName.FolderListSize)})},this))):(c=pb.pString(Bb.settingsGet("CustomLoginLink")),c?(ub.routeOff(),ub.setHash(Bb.link().root(),!0),ub.routeOff(),h.defer(function(){a.location.href=c})):(ub.hideLoading(),ub.startScreens([hb]),qb.runHook("rl-start-login-screens"),a.SimplePace&&a.SimplePace.set(100))),e&&(a["rl_"+d+"_google_service"]=function(){Bb.data().googleActions(!0),Bb.socialUsers()}),f&&(a["rl_"+d+"_facebook_service"]=function(){Bb.data().facebookActions(!0),Bb.socialUsers()}),g&&(a["rl_"+d+"_twitter_service"]=function(){Bb.data().twitterActions(!0),Bb.socialUsers()}),Bb.sub("interval.1m",function(){sb.momentTrigger(!sb.momentTrigger())}),qb.runHook("rl-start-screens")},Bb=new lb,xb.addClass(sb.bMobileDevice?"mobile":"no-mobile"),yb.keydown(pb.killCtrlAandS).keyup(pb.killCtrlAandS),yb.unload(function(){sb.bUnload=!0}),a.rl=a.rl||{},a.rl.addHook=qb.addHook,a.rl.settingsGet=qb.mainSettingsGet,a.rl.remoteRequest=qb.remoteRequest,a.rl.pluginSettingsGet=qb.settingsGet,a.rl.addSettingsViewModel=pb.addSettingsViewModel,a.rl.createCommand=pb.createCommand,a.rl.EmailModel=s,a.rl.Enums=nb,a.__RLBOOT=function(c){b(function(){a.rainloopTEMPLATES&&a.rainloopTEMPLATES[0]?(b("#rl-templates").html(a.rainloopTEMPLATES[0]),h.delay(function(){a.rainloopAppData={},a.rainloopI18N={},a.rainloopTEMPLATES={},ub.setBoot(Bb).bootstart(),xb.addClass("rl-started")},50)):c(!1),a.__RLBOOT=null})},a.SimplePace&&a.SimplePace.add(10)}(window,jQuery,ko,crossroads,hasher,moment,Jua,_);
|