eslint (additional rules)

This commit is contained in:
RainLoop Team 2016-06-30 03:02:45 +03:00
parent 77a1d3f3df
commit 8e8a041032
150 changed files with 21911 additions and 23106 deletions

168
.eslintrc
View file

@ -1,168 +0,0 @@
{
"ecmaFeatures": {
"modules": true
},
"env": {
"node": true,
"commonjs": true,
"es6": true,
"browser": true
},
"globals": {
"RL_COMMUNITY" : true,
"ko" : true,
"ssm" : true,
"moment" : true,
"ifvisible" : true,
"crossroads" : true,
"hasher" : true,
"key" : true,
"Jua" : true,
"_" : true,
"$" : true,
"Dropbox" : true
},
"rules": {
"comma-dangle": [2, "never"],
"no-cond-assign": 2,
"no-console": 2,
"no-constant-condition": 2,
"no-control-regex": 2,
"no-debugger": 2,
"no-dupe-keys": 2,
"no-empty": 2,
"no-empty-character-class": 2,
"no-ex-assign": 2,
"no-extra-boolean-cast": 2,
"no-extra-parens": 0,
"no-extra-semi": 2,
"no-func-assign": 2,
"no-inner-declarations": 2,
"no-invalid-regexp": 2,
"no-irregular-whitespace": 2,
"no-negated-in-lhs": 2,
"no-obj-calls": 2,
"no-regex-spaces": 2,
"no-reserved-keys": 0,
"no-sparse-arrays": 2,
"no-unreachable": 2,
"use-isnan": 2,
"valid-jsdoc": 0,
"valid-typeof": 2,
// Best Practices
"block-scoped-var": 2,
"complexity": 0,
"consistent-return": 2,
"curly": 2,
// "default-case": 2,
"dot-notation": 2,
"eqeqeq": 2,
"guard-for-in": 2,
"no-alert": 2,
"no-caller": 2,
"no-div-regex": 2,
"no-else-return": 2,
"no-eq-null": 2,
"no-eval": 2,
"no-extend-native": 2,
"no-extra-bind": 2,
"no-fallthrough": 2,
"no-floating-decimal": 2,
"no-implied-eval": 2,
"no-iterator": 2,
"no-labels": 2,
"no-lone-blocks": 2,
"no-loop-func": 2,
"no-multi-spaces": 2,
"no-multi-str": 0,
"no-native-reassign": 2,
"no-new": 2,
"no-new-func": 2,
"no-new-wrappers": 2,
"no-octal": 2,
"no-octal-escape": 2,
"no-process-env": 2,
"no-proto": 2,
"no-redeclare": 2,
"no-return-assign": 2,
"no-script-url": 2,
"no-self-compare": 2,
"no-sequences": 2,
"no-unused-expressions": 2,
"no-void": 0,
"no-warning-comments": 2,
"no-with": 2,
"radix": 2,
"vars-on-top": 0,
"wrap-iife": 2,
"yoda": 0,
// Strict Mode
"strict": 0,
// Variables
"no-catch-shadow": 2,
"no-delete-var": 2,
"no-label-var": 2,
"no-shadow": 2,
"no-shadow-restricted-names": 2,
"no-undef": 2,
"no-undef-init": 2,
"no-undefined": 2,
"no-unused-vars": 2,
"no-use-before-define": 2,
// Stylistic Issues
// "indent": [2, "tab", {
// "SwitchCase": 1,
// "VariableDeclarator": 1
// }],
"camelcase": 0,
"comma-spacing": 2,
"comma-style": 2,
"consistent-this": 0,
"eol-last": 2,
"func-names": 0,
"func-style": 0,
"key-spacing": [2, {
"beforeColon": false,
"afterColon": true
}],
"max-nested-callbacks": 0,
"new-cap": 2,
"new-parens": 2,
"no-array-constructor": 2,
"no-inline-comments": 0,
// "no-lonely-if": 2,
"no-mixed-spaces-and-tabs": 2,
// "no-nested-ternary": 2,
"no-new-object": 2,
"semi-spacing": [2, {
"before": false,
"after": true
}],
"no-spaced-func": 2,
"no-ternary": 0,
"no-trailing-spaces": 2,
"no-multiple-empty-lines": 2,
"no-underscore-dangle": 0,
"one-var": 0,
"operator-assignment": [2, "always"],
"padded-blocks": 0,
"quotes": [2, "single"],
"quote-props": 0,
"semi": [2, "always"],
// "sort-vars": [2, {"ignoreCase": true}],
"space-before-blocks": 2,
"object-curly-spacing": [2, "never"],
"array-bracket-spacing": [2, "never"],
"space-in-parens": 2,
"space-infix-ops": 2,
"space-unary-ops": 2,
"spaced-comment": 2,
"wrap-regex": 0,
"max-depth": 0,
"max-len": [2, 200],
"max-params": 0,
"max-statements": 0,
"no-plusplus": 0
}
}

237
.eslintrc.js Normal file
View file

@ -0,0 +1,237 @@
module.exports = {
"extends": "eslint:recommended",
"ecmaFeatures": {
"modules": true
},
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"env": {
"node": true,
"commonjs": true,
"es6": true,
"browser": true
},
"globals": {
"RL_COMMUNITY": true,
"ko": true,
"ssm": true,
"moment": true,
"ifvisible": true,
"crossroads": true,
"hasher": true,
"key": true,
"Jua": true,
"_": true,
"$": true,
"Dropbox": true
},
"rules": {
"strict": 2, // require or disallow strict mode directives
// errors
"comma-dangle": [2, "never"], // disallow or enforce trailing commas
"no-cond-assign": [2, "always"], // disallow assignment in conditional expressions
"no-console": 1, // disallow use of console (off by default in the node environment)
"no-constant-condition": 2, // disallow use of constant expressions in conditions
"no-control-regex": 2, // disallow control characters in regular expressions
"no-debugger": 2, // disallow use of debugger
"no-dupe-args": 2, // disallow duplicate arguments in functions
"no-dupe-keys": 2, // disallow duplicate keys when creating object literals
"no-duplicate-case": 2, // disallow a duplicate case label.
"no-empty": 2, // disallow empty statements
"no-empty-character-class": 2, // disallow the use of empty character classes in regular expressions
"no-ex-assign": 2, // disallow assigning to the exception in a catch block
"no-extra-boolean-cast": 2, // disallow double-negation boolean casts in a boolean context
"no-extra-parens": 0, // disallow unnecessary parentheses (off by default)
"no-extra-semi": 2, // disallow unnecessary semicolons
"no-func-assign": 2, // disallow overwriting functions written as function declarations
"no-inner-declarations": 2, // disallow function or variable declarations in nested blocks
"no-invalid-regexp": 2, // disallow invalid regular expression strings in the RegExp constructor
"no-irregular-whitespace": 2, // disallow irregular whitespace outside of strings and comments
"no-negated-in-lhs": 2, // disallow negation of the left operand of an in expression
"no-obj-calls": 2, // disallow the use of object properties of the global object (Math and JSON) as functions
"no-regex-spaces": 2, // disallow multiple spaces in a regular expression literal
"no-sparse-arrays": 2, // disallow sparse arrays
"no-unexpected-multiline": 2, // disallow confusing multiline expressions
"no-unreachable": 2, // disallow unreachable statements after a return, throw, continue, or break statement
"use-isnan": 2, // disallow comparisons with the value NaN
"valid-typeof": 2, // Ensure that the results of typeof are compared against a valid string
// "valid-jsdoc": [2, { // Ensure JSDoc comments are valid (off by default)
// "requireParamDescription": false,
// "requireReturnDescription": false
// }],
// best practices
"accessor-pairs": 2, // enforce getter and setter pairs in objects
"block-scoped-var": 2, // treat var statements as if they were block scoped (off by default). 0: deep destructuring is not compatible https://github.com/eslint/eslint/issues/1863
// "complexity": 0, // specify the maximum cyclomatic complexity allowed in a program (off by default)
"consistent-return": 2, // require return statements to either always or never specify values
"curly": 2, // specify curly brace conventions for all control statements
"default-case": 2, // require default case in switch statements (off by default)
"dot-location": [2, "property"], // enforce consistent newlines before and after dots
"dot-notation": 2, // encourages use of dot notation whenever possible
"eqeqeq": 2, // require the use of === and !==
"guard-for-in": 2, // make sure for-in loops have an if statement (off by default)
"no-alert": 2, // disallow the use of alert, confirm, and prompt
"no-caller": 2, // disallow use of arguments.caller or arguments.callee
"no-div-regex": 2, // disallow division operators explicitly at beginning of regular expression (off by default)
"no-else-return": 2, // disallow else after a return in an if (off by default)
"no-empty-label": 2, // disallow use of labels for anything other then loops and switches
"no-eq-null": 2, // disallow comparisons to null without a type-checking operator (off by default)
"no-eval": 2, // disallow use of eval()
"no-extend-native": 2, // disallow adding to native types
"no-extra-bind": 2, // disallow unnecessary function binding
"no-fallthrough": 2, // disallow fallthrough of case statements
"no-floating-decimal": 2, // disallow the use of leading or trailing decimal points in numeric literals (off by default)
"no-implied-eval": 2, // disallow use of eval()-like methods
"no-iterator": 2, // disallow usage of __iterator__ property
"no-labels": 2, // disallow use of labeled statements
"no-lone-blocks": 2, // disallow unnecessary nested blocks
"no-loop-func": 2, // disallow creation of functions within loops
"no-multi-spaces": 2, // disallow use of multiple spaces
"no-multi-str": 2, // disallow use of multiline strings
"no-native-reassign": 2, // disallow reassignments of native objects
"no-new": 2, // disallow use of new operator when not part of the assignment or comparison
"no-new-func": 2, // disallow use of new operator for Function object
"no-new-wrappers": 2, // disallows creating new instances of String,Number, and Boolean
"no-octal": 2, // disallow use of octal literals
"no-octal-escape": 2, // disallow use of octal escape sequences in string literals, such as var foo = "Copyright \251";
// "no-param-reassign": 2, // disallow reassignment of function parameters (off by default)
"no-process-env": 2, // disallow use of process.env (off by default)
"no-proto": 2, // disallow usage of __proto__ property
"no-redeclare": 2, // disallow declaring the same variable more then once
"no-return-assign": 2, // disallow use of assignment in return statement
"no-script-url": 2, // disallow use of javascript: urls.
"no-self-compare": 2, // disallow comparisons where both sides are exactly the same (off by default)
"no-sequences": 2, // disallow use of comma operator
"no-throw-literal": 2, // restrict what can be thrown as an exception (off by default)
"no-unused-expressions": 2, // disallow usage of expressions in statement position
"no-void": 2, // disallow use of void operator (off by default)
"no-warning-comments": 1, // disallow usage of configurable warning terms in comments": 2, // e.g. TODO or FIXME (off by default)
"no-with": 2, // disallow use of the with statement
"radix": 2, // require use of the second argument for parseInt() (off by default)
// "vars-on-top": 2, // requires to declare all vars on top of their containing scope (off by default)
"wrap-iife": 2, // require immediate function invocation to be wrapped in parentheses (off by default)
"yoda": [2, "always"], // require or disallow Yoda conditions
// variables
"no-catch-shadow": 2, // disallow the catch clause parameter name being the same as a variable in the outer scope (off by default in the node environment)
"no-delete-var": 2, // disallow deletion of variables
"no-label-var": 2, // disallow labels that share a name with a variable
"no-shadow": 2, // disallow declaration of variables already declared in the outer scope
"no-shadow-restricted-names": 2, // disallow shadowing of names such as arguments
"no-undef": 2, // disallow use of undeclared variables unless mentioned in a /*global */ block
"no-undef-init": 2, // disallow use of undefined when initializing variables
"no-undefined": 2, // disallow use of undefined variable (off by default)
"no-unused-vars": 2, // disallow declaration of variables that are not used in the code
"no-use-before-define": 2, // disallow use of variables before they are defined
// stylistic issues
"array-bracket-spacing": 1, // enforce consistent spacing inside array brackets
"block-spacing": [1, "never"], // enforce consistent spacing inside single-line blocks
// "brace-style": [1, "1tbs"], // enforce consistent brace style for blocks
// "camelcase": 1, // enforce camelcase naming convention
"comma-spacing": 1, // enforce consistent spacing before and after commas
"comma-style": 1, // enforce consistent comma style
"computed-property-spacing": 1, // enforce consistent spacing inside computed property brackets
"consistent-this": [1, "self"], // enforce consistent naming when capturing the current execution context
"eol-last": 1, // enforce at least one newline at the end of files
"id-match": 1, // require identifiers to match a specified regular expression
"indent": [1, "tab", { // enforce consistent indentation
"SwitchCase": 1,
"VariableDeclarator": {
"var": 1,
"let": 1,
"const": 1
}
}],
"key-spacing": 1, // enforce consistent spacing between keys and values in object literal properties
"linebreak-style": [1, "windows"], // enforce consistent linebreak style
"lines-around-comment": 0, // require empty lines around comments
"max-depth": 0, // enforce a maximum depth that blocks can be nested
"max-len": [1, 200], // enforce a maximum line length
"max-lines": 0, // enforce a maximum file length
"max-nested-callbacks": [1, 5], // enforce a maximum depth that callbacks can be nested
"max-params": 0, // enforce a maximum number of parameters in function definitions
"max-statements": 0, // enforce a maximum number of statements allowed in function blocks
"max-statements-per-line": 0, // enforce a maximum number of statements allowed per line
"new-cap": 1, // require constructor function names to begin with a capital letter
"new-parens": 1, // require parentheses when invoking a constructor with no arguments
"newline-after-var": 0, // require or disallow an empty line after var declarations
"newline-before-return": 0, // require an empty line before return statements
"newline-per-chained-call": 0, // require a newline after each call in a method chain
"no-array-constructor": 1, // disallow Array constructors
"no-bitwise": 1, // disallow bitwise operators
"no-continue": 1, // disallow continue statements
"no-inline-comments": 0, // disallow inline comments after code
"no-lonely-if": 0, // disallow if statements as the only statement in else blocks
"no-mixed-operators": 0, // disallow mixes of different operators
"no-mixed-spaces-and-tabs": 2, // disallow mixed spaces and tabs for indentation
"no-multiple-empty-lines": 2, // disallow multiple empty lines
"no-negated-condition": 0, // disallow negated conditions
"no-nested-ternary": 0, // disallow nested ternary expressions
"no-new-object": 2, // disallow Object constructors
"no-plusplus": [1, { // disallow the unary operators ++ and --
"allowForLoopAfterthoughts": true
}],
"no-restricted-syntax": 1, // disallow specified syntax
"no-spaced-func": 1, // disallow spacing between function identifiers and their applications
"no-ternary": 0, // disallow ternary operators
"no-trailing-spaces": 1, // disallow trailing whitespace at the end of lines
"no-underscore-dangle": 0, // disallow dangling underscores in identifiers
"no-unneeded-ternary": 1, // disallow ternary operators when simpler alternatives exist
"no-whitespace-before-property": 0, // disallow whitespace before properties
"object-curly-newline": 0, // enforce consistent line breaks inside braces
"object-curly-spacing": [1, "never"], // enforce consistent spacing inside braces
"object-property-newline": [0, { // enforce placing object properties on separate lines
"allowMultiplePropertiesPerLine": false
}],
// "one-var": [2, { // enforce variables to be declared either together or separately in functions
// "var": "always",
// "let": "always",
// "const": "never"
// }],
"one-var-declaration-per-line": [0, "always"], // require or disallow newlines around var declarations
"operator-assignment": 1, // require or disallow assignment operator shorthand where possible
"operator-linebreak": [1, "after"], // enforce consistent linebreak style for operators
"padded-blocks": [0, "never"], // require or disallow padding within blocks
"quote-props": [0, "as-needed"], // require quotes around object literal property names
"quotes": [2, "single"], // enforce the consistent use of either backticks, double, or single quotes
"require-jsdoc": 1, // require JSDoc comments
"semi": [1, "always"], // require or disallow semicolons instead of ASI
"semi-spacing": 1, // enforce consistent spacing before and after semicolons
"sort-vars": 0, // require variables within the same declaration block to be sorted
"space-before-blocks": 1, // enforce consistent spacing before blocks
"space-before-function-paren": [1, "never"], // enforce consistent spacing before function definition opening parenthesis
"space-in-parens": 1, // enforce consistent spacing inside parentheses
"space-infix-ops": 1, // require spacing around operators
"space-unary-ops": 1, // enforce consistent spacing before or after unary operators
"spaced-comment": 1, // enforce consistent spacing after the // or /* in a comment
// "unicode-bom": [1, "never"], // require or disallow the Unicode BOM
"wrap-regex": 1, // require parenthesis around regex literals
// es6
"constructor-super": 2, // require super() calls in constructors
"no-class-assign": 2, // disallow reassigning class members
"no-const-assign": 2, // disallow reassigning const variables
"no-dupe-class-members": 2, // disallow duplicate class members
"no-this-before-super": 2, // disallow this/super before calling super() in constructors
"prefer-const": 2 // require const declarations for variables that are never reassigned after declared
}
};

View file

@ -19,6 +19,7 @@ import {AbstractBoot} from 'Knoin/AbstractBoot';
class AbstractApp extends AbstractBoot class AbstractApp extends AbstractBoot
{ {
/** /**
* @constructor
* @param {RemoteStorage|AdminRemoteStorage} Remote * @param {RemoteStorage|AdminRemoteStorage} Remote
*/ */
constructor(Remote) constructor(Remote)
@ -58,16 +59,15 @@ class AbstractApp extends AbstractBoot
} }
}); });
$win.on('resize', function () { $win.on('resize', function() {
Events.pub('window.resize'); Events.pub('window.resize');
}); });
Events.sub('window.resize', _.throttle(function () { Events.sub('window.resize', _.throttle(function() {
var var
iH = $win.height(), iH = $win.height(),
iW = $win.height() iW = $win.height();
;
if ($win.__sizes[0] !== iH || $win.__sizes[1] !== iW) if ($win.__sizes[0] !== iH || $win.__sizes[1] !== iW)
{ {
@ -81,31 +81,31 @@ class AbstractApp extends AbstractBoot
// DEBUG // DEBUG
// Events.sub({ // Events.sub({
// 'window.resize': function () { // 'window.resize': function() {
// window.console.log('window.resize'); // window.console.log('window.resize');
// }, // },
// 'window.resize.real': function () { // 'window.resize.real': function() {
// window.console.log('window.resize.real'); // window.console.log('window.resize.real');
// } // }
// }); // });
$doc.on('keydown', function (oEvent) { $doc.on('keydown', function(oEvent) {
if (oEvent && oEvent.ctrlKey) if (oEvent && oEvent.ctrlKey)
{ {
$html.addClass('rl-ctrl-key-pressed'); $html.addClass('rl-ctrl-key-pressed');
} }
}).on('keyup', function (oEvent) { }).on('keyup', function(oEvent) {
if (oEvent && !oEvent.ctrlKey) if (oEvent && !oEvent.ctrlKey)
{ {
$html.removeClass('rl-ctrl-key-pressed'); $html.removeClass('rl-ctrl-key-pressed');
} }
}); });
$doc.on('mousemove keypress click', _.debounce(function () { $doc.on('mousemove keypress click', _.debounce(function() {
Events.pub('rl.auto-logout-refresh'); Events.pub('rl.auto-logout-refresh');
}, 5000)); }, 5000));
key('esc, enter', KeyState.All, _.bind(function () { key('esc, enter', KeyState.All, _.bind(function() {
detectDropdownVisibility(); detectDropdownVisibility();
}, this)); }, this));
} }
@ -124,11 +124,11 @@ class AbstractApp extends AbstractBoot
/** /**
* @param {string} link * @param {string} link
* @return {boolean} * @returns {boolean}
*/ */
download(link) { download(link) {
if (sUserAgent && (sUserAgent.indexOf('chrome') > -1 || sUserAgent.indexOf('chrome') > -1)) if (sUserAgent && (-1 < sUserAgent.indexOf('chrome') || -1 < sUserAgent.indexOf('chrome')))
{ {
const oLink = window.document.createElement('a'); const oLink = window.document.createElement('a');
oLink.href = link; oLink.href = link;
@ -160,7 +160,7 @@ class AbstractApp extends AbstractBoot
} }
/** /**
* @return {boolean} * @returns {boolean}
*/ */
googlePreviewSupported() { googlePreviewSupported() {
if (null === this.googlePreviewSupportedCache) if (null === this.googlePreviewSupportedCache)
@ -220,8 +220,7 @@ class AbstractApp extends AbstractBoot
const const
kn = require('Knoin/Knoin'), kn = require('Knoin/Knoin'),
mobile = Settings.appSettingsGet('mobile'), mobile = Settings.appSettingsGet('mobile'),
inIframe = !!Settings.appSettingsGet('inIframe') inIframe = !!Settings.appSettingsGet('inIframe');
;
let customLogoutLink = pString(Settings.appSettingsGet('customLogoutLink')); let customLogoutLink = pString(Settings.appSettingsGet('customLogoutLink'));
@ -282,8 +281,7 @@ class AbstractApp extends AbstractBoot
const const
mobile = Settings.appSettingsGet('mobile'), mobile = Settings.appSettingsGet('mobile'),
ssm = require('ssm'), ssm = require('ssm'),
ko = require('ko') ko = require('ko');
;
ko.components.register('SaveTrigger', require('Component/SaveTrigger')); ko.components.register('SaveTrigger', require('Component/SaveTrigger'));
ko.components.register('Input', require('Component/Input')); ko.components.register('Input', require('Component/Input'));

View file

@ -78,10 +78,8 @@ class AdminApp extends AbstractApp
PackageStore.packagesReal(!!data.Result.Real); PackageStore.packagesReal(!!data.Result.Real);
PackageStore.packagesMainUpdatable(!!data.Result.MainUpdatable); PackageStore.packagesMainUpdatable(!!data.Result.MainUpdatable);
let let list = [];
list = [], const loading = {};
loading = {}
;
_.each(PackageStore.packages(), (item) => { _.each(PackageStore.packages(), (item) => {
if (item && item.loading()) if (item && item.loading())

View file

@ -110,8 +110,7 @@ class AppUser extends AbstractApp
centeredX: true, centeredX: true,
centeredY: true centeredY: true
}) })
.removeAttr('style') .removeAttr('style');
;
}, 1000); }, 1000);
} }
@ -147,8 +146,7 @@ class AppUser extends AbstractApp
reloadMessageList(bDropPagePosition = false, bDropCurrenFolderCache = false) { reloadMessageList(bDropPagePosition = false, bDropCurrenFolderCache = false) {
let let
iOffset = (MessageStore.messageListPage() - 1) * SettingsStore.messagesPerPage() iOffset = (MessageStore.messageListPage() - 1) * SettingsStore.messagesPerPage();
;
if (bDropCurrenFolderCache) if (bDropCurrenFolderCache)
{ {
@ -203,7 +201,7 @@ class AppUser extends AbstractApp
/** /**
* @param {Function} fResultFunc * @param {Function} fResultFunc
* @return {boolean} * @returns {boolean}
*/ */
contactsSync(fResultFunc) { contactsSync(fResultFunc) {
@ -232,16 +230,14 @@ class AppUser extends AbstractApp
const const
sTrashFolder = FolderStore.trashFolder(), sTrashFolder = FolderStore.trashFolder(),
sSpamFolder = FolderStore.spamFolder() sSpamFolder = FolderStore.spamFolder();
;
_.each(this.moveCache, (oItem) => { _.each(this.moveCache, (oItem) => {
var var
bSpam = sSpamFolder === oItem.To, bSpam = sSpamFolder === oItem.To,
bTrash = sTrashFolder === oItem.To, bTrash = sTrashFolder === oItem.To,
bHam = !bSpam && sSpamFolder === oItem.From && Cache.getFolderInboxName() === oItem.To bHam = !bSpam && sSpamFolder === oItem.From && Cache.getFolderInboxName() === oItem.To;
;
Remote.messagesMove(this.moveOrDeleteResponseHelper, oItem.From, oItem.To, oItem.Uid, Remote.messagesMove(this.moveOrDeleteResponseHelper, oItem.From, oItem.To, oItem.Uid,
bSpam ? 'SPAM' : (bHam ? 'HAM' : ''), bSpam || bTrash); bSpam ? 'SPAM' : (bHam ? 'HAM' : ''), bSpam || bTrash);
@ -326,8 +322,7 @@ class AppUser extends AbstractApp
let let
oMoveFolder = null, oMoveFolder = null,
nSetSystemFoldersNotification = null nSetSystemFoldersNotification = null;
;
switch (iDeleteType) switch (iDeleteType)
{ {
@ -346,6 +341,7 @@ class AppUser extends AbstractApp
oMoveFolder = Cache.getFolderFromCacheList(FolderStore.archiveFolder()); oMoveFolder = Cache.getFolderFromCacheList(FolderStore.archiveFolder());
nSetSystemFoldersNotification = SetSystemFoldersNotification.Archive; nSetSystemFoldersNotification = SetSystemFoldersNotification.Archive;
break; break;
// no default
} }
bUseFolder = isUnd(bUseFolder) ? true : !!bUseFolder; bUseFolder = isUnd(bUseFolder) ? true : !!bUseFolder;
@ -390,8 +386,7 @@ class AppUser extends AbstractApp
{ {
const const
oFromFolder = Cache.getFolderFromCacheList(sFromFolderFullNameRaw), oFromFolder = Cache.getFolderFromCacheList(sFromFolderFullNameRaw),
oToFolder = Cache.getFolderFromCacheList(sToFolderFullNameRaw) oToFolder = Cache.getFolderFromCacheList(sToFolderFullNameRaw);
;
if (oFromFolder && oToFolder) if (oFromFolder && oToFolder)
{ {
@ -441,8 +436,7 @@ class AppUser extends AbstractApp
}, (errorCode) => { }, (errorCode) => {
FolderStore.folderList.error(getNotification(errorCode, '', errorDefCode)); FolderStore.folderList.error(getNotification(errorCode, '', errorDefCode));
Promises.foldersReloadWithTimeout(FolderStore.foldersLoading); Promises.foldersReloadWithTimeout(FolderStore.foldersLoading);
}) });
;
} }
reloadOpenPgpKeys() { reloadOpenPgpKeys() {
@ -453,8 +447,7 @@ class AppUser extends AbstractApp
aKeys = [], aKeys = [],
oEmail = new EmailModel(), oEmail = new EmailModel(),
oOpenpgpKeyring = PgpStore.openpgpKeyring, oOpenpgpKeyring = PgpStore.openpgpKeyring,
oOpenpgpKeys = oOpenpgpKeyring ? oOpenpgpKeyring.getAllKeys() : [] oOpenpgpKeys = oOpenpgpKeyring ? oOpenpgpKeyring.getAllKeys() : [];
;
_.each(oOpenpgpKeys, (oItem, iIndex) => { _.each(oOpenpgpKeys, (oItem, iIndex) => {
if (oItem && oItem.primaryKey) if (oItem && oItem.primaryKey)
@ -463,9 +456,8 @@ class AppUser extends AbstractApp
aEmails = [], aEmails = [],
aUsers = [], aUsers = [],
oPrimaryUser = oItem.getPrimaryUser(), oPrimaryUser = oItem.getPrimaryUser(),
sUser = (oPrimaryUser && oPrimaryUser.user) ? oPrimaryUser.user.userId.userid sUser = (oPrimaryUser && oPrimaryUser.user) ? oPrimaryUser.user.userId.userid :
: (oItem.users && oItem.users[0] ? oItem.users[0].userId.userid : '') (oItem.users && oItem.users[0] ? oItem.users[0].userId.userid : '');
;
if (oItem.users) if (oItem.users)
{ {
@ -550,8 +542,7 @@ class AppUser extends AbstractApp
var var
aCounts = {}, aCounts = {},
sParentEmail = Settings.settingsGet('ParentEmail'), sParentEmail = Settings.settingsGet('ParentEmail'),
sAccountEmail = AccountStore.email() sAccountEmail = AccountStore.email();
;
sParentEmail = '' === sParentEmail ? sAccountEmail : sParentEmail; sParentEmail = '' === sParentEmail ? sAccountEmail : sParentEmail;
@ -582,8 +573,7 @@ class AppUser extends AbstractApp
const const
sId = pString(oIdentityData.Id), sId = pString(oIdentityData.Id),
sEmail = pString(oIdentityData.Email), sEmail = pString(oIdentityData.Email),
oIdentity = new IdentityModel(sId, sEmail) oIdentity = new IdentityModel(sId, sEmail);
;
oIdentity.name(pString(oIdentityData.Name)); oIdentity.name(pString(oIdentityData.Name));
oIdentity.replyTo(pString(oIdentityData.ReplyTo)); oIdentity.replyTo(pString(oIdentityData.ReplyTo));
@ -646,8 +636,7 @@ class AppUser extends AbstractApp
let let
uid = '', uid = '',
check = false, check = false,
unreadCountChange = false unreadCountChange = false;
;
const folderFromCache = Cache.getFolderFromCacheList(data.Result.Folder); const folderFromCache = Cache.getFolderFromCacheList(data.Result.Folder);
if (folderFromCache) if (folderFromCache)
@ -739,8 +728,7 @@ class AppUser extends AbstractApp
var var
sHash = Cache.getFolderHash(oItem.Folder), sHash = Cache.getFolderHash(oItem.Folder),
oFolder = Cache.getFolderFromCacheList(oItem.Folder), oFolder = Cache.getFolderFromCacheList(oItem.Folder),
bUnreadCountChange = false bUnreadCountChange = false;
;
if (oFolder) if (oFolder)
{ {
@ -813,8 +801,7 @@ class AppUser extends AbstractApp
var var
oFolder = null, oFolder = null,
aRootUids = [], aRootUids = [],
iAlreadyUnread = 0 iAlreadyUnread = 0;
;
if (isUnd(aMessages)) if (isUnd(aMessages))
{ {
@ -825,7 +812,8 @@ class AppUser extends AbstractApp
if ('' !== sFolderFullNameRaw && 0 < aRootUids.length) if ('' !== sFolderFullNameRaw && 0 < aRootUids.length)
{ {
switch (iSetAction) { switch (iSetAction)
{
case MessageSetAction.SetSeen: case MessageSetAction.SetSeen:
_.each(aRootUids, (sSubUid) => { _.each(aRootUids, (sSubUid) => {
@ -877,6 +865,7 @@ class AppUser extends AbstractApp
Remote.messageSetFlagged(noop, sFolderFullNameRaw, aRootUids, false); Remote.messageSetFlagged(noop, sFolderFullNameRaw, aRootUids, false);
break; break;
// no default
} }
this.reloadFlagsCurrentMessageListAndMessageFromCache(); this.reloadFlagsCurrentMessageListAndMessageFromCache();
@ -1019,8 +1008,7 @@ class AppUser extends AbstractApp
}) })
.on('mouseup', () => { .on('mouseup', () => {
$html.removeClass('rl-resizer'); $html.removeClass('rl-resizer');
}) });
;
} }
}, },
@ -1062,8 +1050,7 @@ class AppUser extends AbstractApp
{ {
oTop oTop
.resizable('destroy') .resizable('destroy')
.removeAttr('style') .removeAttr('style');
;
} }
if (oBottom) if (oBottom)
@ -1084,8 +1071,7 @@ class AppUser extends AbstractApp
const iHeight = pInt(Local.get(sClientSideKeyName)) || 300; const iHeight = pInt(Local.get(sClientSideKeyName)) || 300;
fSetHeight(iHeight > iMinHeight ? iHeight : iMinHeight); fSetHeight(iHeight > iMinHeight ? iHeight : iMinHeight);
} }
} };
;
fDisable(false); fDisable(false);
@ -1144,8 +1130,7 @@ class AppUser extends AbstractApp
}) })
.on('mouseup', () => { .on('mouseup', () => {
$html.removeClass('rl-resizer'); $html.removeClass('rl-resizer');
}) });
;
} }
}, },
fResizeResizeFunction = _.debounce(() => { fResizeResizeFunction = _.debounce(() => {
@ -1173,8 +1158,7 @@ class AppUser extends AbstractApp
height: '' height: ''
}); });
} }
} };
;
if (null !== mLeftWidth) if (null !== mLeftWidth)
{ {
@ -1236,7 +1220,7 @@ class AppUser extends AbstractApp
kn.setHash(Links.root(), true); kn.setHash(Links.root(), true);
kn.routeOff(); kn.routeOff();
_.defer(function () { _.defer(function() {
window.location.href = customLoginLink; window.location.href = customLoginLink;
}); });
} }
@ -1271,8 +1255,7 @@ class AppUser extends AbstractApp
iContactsSyncInterval = pInt(Settings.settingsGet('ContactsSyncInterval')), iContactsSyncInterval = pInt(Settings.settingsGet('ContactsSyncInterval')),
bGoogle = Settings.settingsGet('AllowGoogleSocial'), bGoogle = Settings.settingsGet('AllowGoogleSocial'),
bFacebook = Settings.settingsGet('AllowFacebookSocial'), bFacebook = Settings.settingsGet('AllowFacebookSocial'),
bTwitter = Settings.settingsGet('AllowTwitterSocial') bTwitter = Settings.settingsGet('AllowTwitterSocial');
;
if (progressJs) if (progressJs)
{ {
@ -1423,7 +1406,8 @@ class AppUser extends AbstractApp
window.navigator.registerProtocolHandler('mailto', window.navigator.registerProtocolHandler('mailto',
window.location.protocol + '//' + window.location.host + window.location.pathname + '?mailto&to=%s', window.location.protocol + '//' + window.location.host + window.location.pathname + '?mailto&to=%s',
'' + (Settings.settingsGet('Title') || 'RainLoop')); '' + (Settings.settingsGet('Title') || 'RainLoop'));
} catch (e) {/* eslint-disable-line no-empty */} }
catch (e) {/* eslint-disable-line no-empty */}
if (Settings.settingsGet('MailToEmail')) if (Settings.settingsGet('MailToEmail'))
{ {

View file

@ -17,8 +17,7 @@ const Base64 = {
let let
output = '', output = '',
chr1, chr2, chr3, enc1, enc2, enc3, enc4, chr1, chr2, chr3, enc1, enc2, enc3, enc4,
i = 0 i = 0;
;
input = Base64._utf8_encode(input); input = Base64._utf8_encode(input);
@ -56,8 +55,7 @@ const Base64 = {
let let
output = '', output = '',
chr1, chr2, chr3, enc1, enc2, enc3, enc4, chr1, chr2, chr3, enc1, enc2, enc3, enc4,
i = 0 i = 0;
;
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ''); input = input.replace(/[^A-Za-z0-9\+\/\=]/g, '');
@ -97,8 +95,7 @@ const Base64 = {
utftext = '', utftext = '',
n = 0, n = 0,
l = string.length, l = string.length,
c = 0 c = 0;
;
for (; n < l; n++) { for (; n < l; n++) {
@ -132,8 +129,7 @@ const Base64 = {
i = 0, i = 0,
c = 0, c = 0,
c2 = 0, c2 = 0,
c3 = 0 c3 = 0;
;
while ( i < utftext.length ) while ( i < utftext.length )
{ {

View file

@ -14,6 +14,11 @@ window.__rlah_set = () => setHash();
window.__rlah_clear = () => clearHash(); window.__rlah_clear = () => clearHash();
window.__rlah_data = () => RL_APP_DATA_STORAGE; window.__rlah_data = () => RL_APP_DATA_STORAGE;
/**
* @param {string} id
* @param {string} name
* @returns {string}
*/
function getComputedStyle(id, name) function getComputedStyle(id, name)
{ {
var element = window.document.getElementById(id); var element = window.document.getElementById(id);
@ -21,16 +26,27 @@ function getComputedStyle(id, name)
(window.getComputedStyle ? window.getComputedStyle(element, null).getPropertyValue(name) : null); (window.getComputedStyle ? window.getComputedStyle(element, null).getPropertyValue(name) : null);
} }
/**
* @param {string} styles
* @returns {void}
*/
function includeStyle(styles) function includeStyle(styles)
{ {
window.document.write(unescape('%3Csty' + 'le%3E' + styles + '"%3E%3C/' + 'sty' + 'le%3E')); window.document.write(unescape('%3Csty' + 'le%3E' + styles + '"%3E%3C/' + 'sty' + 'le%3E'));
} }
/**
* @param {string} src
* @returns {void}
*/
function includeScr(src) function includeScr(src)
{ {
window.document.write(unescape('%3Csc' + 'ript type="text/jav' + 'ascr' + 'ipt" data-cfasync="false" sr' + 'c="' + src + '"%3E%3C/' + 'scr' + 'ipt%3E')); window.document.write(unescape('%3Csc' + 'ript type="text/jav' + 'ascr' + 'ipt" data-cfasync="false" sr' + 'c="' + src + '"%3E%3C/' + 'scr' + 'ipt%3E'));
} }
/**
* @returns {boolean}
*/
function includeLayout() function includeLayout()
{ {
const app = window.document.getElementById('rl-app'); const app = window.document.getElementById('rl-app');
@ -49,18 +65,25 @@ function includeLayout()
return false; return false;
} }
function includeAppScr(data = {}) /**
* @param {mixed} data
* @returns {void}
*/
function includeAppScr({admin = false, mobile = false, mobileDevice = false})
{ {
let src = './?/'; let src = './?/';
src += data.admin ? 'Admin' : ''; src += admin ? 'Admin' : '';
src += 'AppData@'; src += 'AppData@';
src += data.mobile ? 'mobile' : 'no-mobile'; src += mobile ? 'mobile' : 'no-mobile';
src += data.mobileDevice ? '-1' : '-0'; src += mobileDevice ? '-1' : '-0';
src += '/'; src += '/';
includeScr(src + (window.__rlah ? window.__rlah() || '0' : '0') + '/' + window.Math.random().toString().substr(2) + '/'); includeScr(src + (window.__rlah ? window.__rlah() || '0' : '0') + '/' + window.Math.random().toString().substr(2) + '/');
} }
/**
* @returns {object}
*/
function getRainloopBootData() function getRainloopBootData()
{ {
let result = {}; let result = {};
@ -74,13 +97,16 @@ function getRainloopBootData()
return result; return result;
} }
/**
* @param {string} additionalError
* @returns {void}
*/
function showError(additionalError) function showError(additionalError)
{ {
const const
oR = window.document.getElementById('rl-loading'), oR = window.document.getElementById('rl-loading'),
oL = window.document.getElementById('rl-loading-error'), oL = window.document.getElementById('rl-loading-error'),
oLA = window.document.getElementById('rl-loading-error-additional') oLA = window.document.getElementById('rl-loading-error-additional');
;
if (oR) if (oR)
{ {
@ -104,12 +130,15 @@ function showError(additionalError)
} }
} }
/**
* @param {string} description
* @returns {void}
*/
function showDescriptionAndLoading(description) function showDescriptionAndLoading(description)
{ {
const const
oE = window.document.getElementById('rl-loading'), oE = window.document.getElementById('rl-loading'),
oElDesc = window.document.getElementById('rl-loading-desc') oElDesc = window.document.getElementById('rl-loading-desc');
;
if (oElDesc && description) if (oElDesc && description)
{ {
@ -125,6 +154,11 @@ function showDescriptionAndLoading(description)
} }
} }
/**
* @param {boolean} withError
* @param {string} additionalError
* @returns {void}
*/
function runMainBoot(withError, additionalError) function runMainBoot(withError, additionalError)
{ {
if (window.__APP_BOOT && !withError) if (window.__APP_BOOT && !withError)
@ -139,6 +173,9 @@ function runMainBoot(withError, additionalError)
} }
} }
/**
* @returns {void}
*/
function runApp() function runApp()
{ {
const appData = window.__rlah_data(); const appData = window.__rlah_data();
@ -162,16 +199,14 @@ function runApp()
window.$('#rl-bg').attr('style', 'background-image: none !important;') window.$('#rl-bg').attr('style', 'background-image: none !important;')
.backstretch(appData.IncludeBackground.replace('{{USER}}', .backstretch(appData.IncludeBackground.replace('{{USER}}',
(window.__rlah ? (window.__rlah() || '0') : '0')), {fade: 100, centeredX: true, centeredY: true}) (window.__rlah ? (window.__rlah() || '0') : '0')), {fade: 100, centeredX: true, centeredY: true})
.removeAttr('style') .removeAttr('style');
;
} }
} }
}), }),
common = window.Promise.all([ common = window.Promise.all([
window.jassl(appData.TemplatesLink), window.jassl(appData.TemplatesLink),
window.jassl(appData.LangLink) window.jassl(appData.LangLink)
]) ]);
;
window.Promise.all([libs, common]) window.Promise.all([libs, common])
.then(() => { .then(() => {
@ -193,8 +228,7 @@ function runApp()
window.__initEditor(); window.__initEditor();
window.__initEditor = null; window.__initEditor = null;
} }
}) });
;
} }
else else
{ {
@ -202,6 +236,10 @@ function runApp()
} }
} }
/**
* @param {mixed} data
* @returns {void}
*/
window.__initAppData = function(data) { window.__initAppData = function(data) {
RL_APP_DATA_STORAGE = data; RL_APP_DATA_STORAGE = data;
@ -226,6 +264,9 @@ window.__initAppData = function(data) {
runApp(); runApp();
}; };
/**
* @returns {void}
*/
window.__runBoot = function() { window.__runBoot = function() {
if (!window.navigator || !window.navigator.cookieEnabled) if (!window.navigator || !window.navigator.cookieEnabled)

View file

@ -5,18 +5,20 @@ import {trim, pInt, isArray} from 'Common/Utils';
import * as Links from 'Common/Links'; import * as Links from 'Common/Links';
import * as Settings from 'Storage/Settings'; import * as Settings from 'Storage/Settings';
let FOLDERS_CACHE = {}; let FOLDERS_CACHE = {},
let FOLDERS_NAME_CACHE = {}; FOLDERS_NAME_CACHE = {},
let FOLDERS_HASH_CACHE = {}; FOLDERS_HASH_CACHE = {},
let FOLDERS_UID_NEXT_CACHE = {}; FOLDERS_UID_NEXT_CACHE = {},
let MESSAGE_FLAGS_CACHE = {}; MESSAGE_FLAGS_CACHE = {},
NEW_MESSAGE_CACHE = {},
inboxFolderName = '';
let NEW_MESSAGE_CACHE = {}; const REQUESTED_MESSAGE_CACHE = {},
let REQUESTED_MESSAGE_CACHE = {}; capaGravatar = Settings.capa(Capa.Gravatar);
const capaGravatar = Settings.capa(Capa.Gravatar);
let inboxFolderName = '';
/**
* @returns {void}
*/
export function clear() export function clear()
{ {
FOLDERS_CACHE = {}; FOLDERS_CACHE = {};
@ -29,7 +31,7 @@ export function clear()
/** /**
* @param {string} email * @param {string} email
* @param {Function} callback * @param {Function} callback
* @return {string} * @returns {string}
*/ */
export function getUserPic(email, callback) export function getUserPic(email, callback)
{ {
@ -40,7 +42,7 @@ export function getUserPic(email, callback)
/** /**
* @param {string} folderFullNameRaw * @param {string} folderFullNameRaw
* @param {string} uid * @param {string} uid
* @return {string} * @returns {string}
*/ */
export function getMessageKey(folderFullNameRaw, uid) export function getMessageKey(folderFullNameRaw, uid)
{ {
@ -59,7 +61,7 @@ export function addRequestedMessage(folder, uid)
/** /**
* @param {string} folder * @param {string} folder
* @param {string} uid * @param {string} uid
* @return {boolean} * @returns {boolean}
*/ */
export function hasRequestedMessage(folder, uid) export function hasRequestedMessage(folder, uid)
{ {
@ -89,13 +91,16 @@ export function hasNewMessageAndRemoveFromCache(folderFullNameRaw, uid)
return false; return false;
} }
/**
* @returns {void}
*/
export function clearNewMessageCache() export function clearNewMessageCache()
{ {
NEW_MESSAGE_CACHE = {}; NEW_MESSAGE_CACHE = {};
} }
/** /**
* @return {string} * @returns {string}
*/ */
export function getFolderInboxName() export function getFolderInboxName()
{ {
@ -104,7 +109,7 @@ export function getFolderInboxName()
/** /**
* @param {string} folderHash * @param {string} folderHash
* @return {string} * @returns {string}
*/ */
export function getFolderFullNameRaw(folderHash) export function getFolderFullNameRaw(folderHash)
{ {
@ -126,7 +131,7 @@ export function setFolderFullNameRaw(folderHash, folderFullNameRaw)
/** /**
* @param {string} folderFullNameRaw * @param {string} folderFullNameRaw
* @return {string} * @returns {string}
*/ */
export function getFolderHash(folderFullNameRaw) export function getFolderHash(folderFullNameRaw)
{ {
@ -147,7 +152,7 @@ export function setFolderHash(folderFullNameRaw, folderHash)
/** /**
* @param {string} folderFullNameRaw * @param {string} folderFullNameRaw
* @return {string} * @returns {string}
*/ */
export function getFolderUidNext(folderFullNameRaw) export function getFolderUidNext(folderFullNameRaw)
{ {
@ -165,7 +170,7 @@ export function setFolderUidNext(folderFullNameRaw, uidNext)
/** /**
* @param {string} folderFullNameRaw * @param {string} folderFullNameRaw
* @return {?FolderModel} * @returns {?FolderModel}
*/ */
export function getFolderFromCacheList(folderFullNameRaw) export function getFolderFromCacheList(folderFullNameRaw)
{ {
@ -192,7 +197,7 @@ export function removeFolderFromCacheList(folderFullNameRaw)
/** /**
* @param {string} folderFullName * @param {string} folderFullName
* @param {string} uid * @param {string} uid
* @return {?Array} * @returns {?Array}
*/ */
export function getMessageFlagsFromCache(folderFullName, uid) export function getMessageFlagsFromCache(folderFullName, uid)
{ {
@ -233,14 +238,13 @@ export function initMessageFlagsFromCache(message)
{ {
const const
uid = message.uid, uid = message.uid,
flags = getMessageFlagsFromCache(message.folderFullNameRaw, uid) flags = getMessageFlagsFromCache(message.folderFullNameRaw, uid);
;
if (flags && 0 < flags.length) if (flags && 0 < flags.length)
{ {
message.flagged(!!flags[1]); message.flagged(!!flags[1]);
if (!message.__simple_message__) if (!message.isSimpleMessage)
{ {
message.unseen(!!flags[0]); message.unseen(!!flags[0]);
message.answered(!!flags[2]); message.answered(!!flags[2]);
@ -334,6 +338,7 @@ export function storeMessageFlagsToCacheBySetAction(folder, uid, setAction)
case MessageSetAction.UnsetFlag: case MessageSetAction.UnsetFlag:
flags[1] = false; flags[1] = false;
break; break;
// no default
} }
setMessageFlagsToCache(folder, uid, flags); setMessageFlagsToCache(folder, uid, flags);

View file

@ -8,14 +8,13 @@ class CookieDriver
/** /**
* @param {string} key * @param {string} key
* @param {*} data * @param {*} data
* @return {boolean} * @returns {boolean}
*/ */
set(key, data) { set(key, data) {
let let
result = false, result = false,
storageResult = null storageResult = null;
;
try try
{ {
@ -41,7 +40,7 @@ class CookieDriver
/** /**
* @param {string} key * @param {string} key
* @return {*} * @returns {*}
*/ */
get(key) { get(key) {
@ -51,8 +50,7 @@ class CookieDriver
{ {
const const
storageValue = $.cookie(CLIENT_SIDE_STORAGE_INDEX_NAME), storageValue = $.cookie(CLIENT_SIDE_STORAGE_INDEX_NAME),
storageResult = null === storageValue ? null : JSON.parse(storageValue) storageResult = null === storageValue ? null : JSON.parse(storageValue);
;
result = (storageResult && !isUnd(storageResult[key])) ? storageResult[key] : null; result = (storageResult && !isUnd(storageResult[key])) ? storageResult[key] : null;
} }
@ -62,7 +60,7 @@ class CookieDriver
} }
/** /**
* @return {boolean} * @returns {boolean}
*/ */
static supported() { static supported() {
return !!(window.navigator && window.navigator.cookieEnabled); return !!(window.navigator && window.navigator.cookieEnabled);

View file

@ -8,14 +8,13 @@ class LocalStorageDriver
/** /**
* @param {string} key * @param {string} key
* @param {*} data * @param {*} data
* @return {boolean} * @returns {boolean}
*/ */
set(key, data) { set(key, data) {
let let
result = false, result = false,
storageResult = null storageResult = null;
;
try try
{ {
@ -38,7 +37,7 @@ class LocalStorageDriver
/** /**
* @param {string} key * @param {string} key
* @return {*} * @returns {*}
*/ */
get(key) { get(key) {
@ -48,8 +47,7 @@ class LocalStorageDriver
{ {
const const
storageValue = window.localStorage[CLIENT_SIDE_STORAGE_INDEX_NAME] || null, storageValue = window.localStorage[CLIENT_SIDE_STORAGE_INDEX_NAME] || null,
storageResult = null === storageValue ? null : JSON.parse(storageValue) storageResult = null === storageValue ? null : JSON.parse(storageValue);
;
result = (storageResult && !isUnd(storageResult[key])) ? storageResult[key] : null; result = (storageResult && !isUnd(storageResult[key])) ? storageResult[key] : null;
} }
@ -59,7 +57,7 @@ class LocalStorageDriver
} }
/** /**
* @return {boolean} * @returns {boolean}
*/ */
static supported() { static supported() {
return !!window.localStorage; return !!window.localStorage;

View file

@ -43,41 +43,37 @@ export const sUserAgent = 'navigator' in window && 'userAgent' in window.navigat
/** /**
* @type {boolean} * @type {boolean}
*/ */
export const bIE = sUserAgent.indexOf('msie') > -1; export const bIE = -1 < sUserAgent.indexOf('msie');
/** /**
* @type {boolean} * @type {boolean}
*/ */
export const bChrome = sUserAgent.indexOf('chrome') > -1; export const bChrome = -1 < sUserAgent.indexOf('chrome');
/** /**
* @type {boolean} * @type {boolean}
*/ */
export const bSafari = !bChrome && sUserAgent.indexOf('safari') > -1; export const bSafari = !bChrome && -1 < sUserAgent.indexOf('safari');
/** /**
* @type {boolean} * @type {boolean}
*/ */
export const bMobileDevice = export const bMobileDevice =
/android/i.test(sUserAgent) || (/android/i).test(sUserAgent) ||
/iphone/i.test(sUserAgent) || (/iphone/i).test(sUserAgent) ||
/ipod/i.test(sUserAgent) || (/ipod/i).test(sUserAgent) ||
/ipad/i.test(sUserAgent) || (/ipad/i).test(sUserAgent) ||
/blackberry/i.test(sUserAgent) (/blackberry/i).test(sUserAgent);
;
/** /**
* @type {boolean} * @type {boolean}
*/ */
export let bDisableNanoScroll = bMobileDevice; export const bDisableNanoScroll = bMobileDevice;
/** /**
* @type {boolean} * @type {boolean}
*/ */
export let bAnimationSupported = !bMobileDevice && export const bAnimationSupported = !bMobileDevice && $html.hasClass('csstransitions') && $html.hasClass('cssanimations');
$html.hasClass('csstransitions') &&
$html.hasClass('cssanimations')
;
/** /**
* @type {boolean} * @type {boolean}
@ -161,13 +157,13 @@ let bAllowPdfPreview = !bMobileDevice;
if (bAllowPdfPreview && window.navigator && window.navigator.mimeTypes) if (bAllowPdfPreview && window.navigator && window.navigator.mimeTypes)
{ {
bAllowPdfPreview = !!_.find(window.navigator.mimeTypes, function (oType) { bAllowPdfPreview = !!_.find(window.navigator.mimeTypes, function(oType) {
return oType && 'application/pdf' === oType.type; return oType && 'application/pdf' === oType.type;
}); });
if (!bAllowPdfPreview) if (!bAllowPdfPreview)
{ {
bAllowPdfPreview = (typeof window.navigator.mimeTypes['application/pdf'] !== 'undefined'); bAllowPdfPreview = 'undefined' !== typeof window.navigator.mimeTypes['application/pdf'];
} }
} }
@ -203,32 +199,31 @@ export const keyScope = ko.computed({
read: () => { read: () => {
return keyScopeFake(); return keyScopeFake();
}, },
write: function (sValue) { write: function(sValue) {
if (KeyState.Menu !== sValue) if (KeyState.Menu !== sValue)
{ {
if (KeyState.Compose === sValue) if (KeyState.Compose === sValue)
{ {
// disableKeyFilter // disableKeyFilter
key.filter = function () { key.filter = function() {
return useKeyboardShortcuts(); return useKeyboardShortcuts();
}; };
} }
else else
{ {
// restoreKeyFilter // restoreKeyFilter
key.filter = function (event) { key.filter = function(event) {
if (useKeyboardShortcuts()) if (useKeyboardShortcuts())
{ {
var var
oElement = event.target || event.srcElement, oElement = event.target || event.srcElement,
sTagName = oElement ? oElement.tagName : '' sTagName = oElement ? oElement.tagName : '';
;
sTagName = sTagName.toUpperCase(); sTagName = sTagName.toUpperCase();
return !(sTagName === 'INPUT' || sTagName === 'SELECT' || sTagName === 'TEXTAREA' || return !('INPUT' === sTagName || 'SELECT' === sTagName || 'TEXTAREA' === sTagName ||
(oElement && sTagName === 'DIV' && ('editorHtmlArea' === oElement.className || 'true' === '' + oElement.contentEditable)) (oElement && 'DIV' === sTagName && ('editorHtmlArea' === oElement.className || 'true' === '' + oElement.contentEditable))
); );
} }
@ -247,12 +242,12 @@ export const keyScope = ko.computed({
} }
}); });
keyScopeReal.subscribe(function (sValue) { keyScopeReal.subscribe(function(sValue) {
// window.console.log('keyScope=' + sValue); // DEBUG // window.console.log('keyScope=' + sValue); // DEBUG
key.setScope(sValue); key.setScope(sValue);
}); });
dropdownVisibility.subscribe(function (bValue) { dropdownVisibility.subscribe(function(bValue) {
if (bValue) if (bValue)
{ {
keyScope(KeyState.Menu); keyScope(KeyState.Menu);

View file

@ -6,6 +6,7 @@ import * as Settings from 'Storage/Settings';
class HtmlEditor class HtmlEditor
{ {
/** /**
* @constructor
* @param {Object} element * @param {Object} element
* @param {Function=} onBlur * @param {Function=} onBlur
* @param {Function=} onReady * @param {Function=} onReady
@ -47,7 +48,7 @@ class HtmlEditor
} }
/** /**
* @return {boolean} * @returns {boolean}
*/ */
isHtml() { isHtml() {
return this.editor ? 'wysiwyg' === this.editor.mode : false; return this.editor ? 'wysiwyg' === this.editor.mode : false;
@ -70,7 +71,7 @@ class HtmlEditor
} }
/** /**
* @return {boolean} * @returns {boolean}
*/ */
checkDirty() { checkDirty() {
return this.editor ? this.editor.checkDirty() : false; return this.editor ? this.editor.checkDirty() : false;
@ -85,7 +86,7 @@ class HtmlEditor
/** /**
* @param {string} text * @param {string} text
* @return {string} * @returns {string}
*/ */
clearSignatureSigns(text) { clearSignatureSigns(text) {
return text.replace(/(\u200C|\u0002)/g, ''); return text.replace(/(\u200C|\u0002)/g, '');
@ -94,7 +95,7 @@ class HtmlEditor
/** /**
* @param {boolean=} wrapIsHtml = false * @param {boolean=} wrapIsHtml = false
* @param {boolean=} clearSignatureSigns = false * @param {boolean=} clearSignatureSigns = false
* @return {string} * @returns {string}
*/ */
getData(wrapIsHtml = false, clearSignatureSigns = false) { getData(wrapIsHtml = false, clearSignatureSigns = false) {
@ -113,7 +114,8 @@ class HtmlEditor
'<div data-html-editor-font-wrapper="true" style="font-family: arial, sans-serif; font-size: 13px;">' + '<div data-html-editor-font-wrapper="true" style="font-family: arial, sans-serif; font-size: 13px;">' +
this.editor.getData() + '</div>' : this.editor.getData(); this.editor.getData() + '</div>' : this.editor.getData();
} }
} catch (e) {/* eslint-disable-line no-empty */} }
catch (e) {/* eslint-disable-line no-empty */}
if (clearSignatureSigns) if (clearSignatureSigns)
{ {
@ -127,7 +129,7 @@ class HtmlEditor
/** /**
* @param {boolean=} wrapIsHtml = false * @param {boolean=} wrapIsHtml = false
* @param {boolean=} clearSignatureSigns = false * @param {boolean=} clearSignatureSigns = false
* @return {string} * @returns {string}
*/ */
getDataWithHtmlMark(wrapIsHtml = false, clearSignatureSigns = false) { getDataWithHtmlMark(wrapIsHtml = false, clearSignatureSigns = false) {
return (this.isHtml() ? ':HTML:' : '') + this.getData(wrapIsHtml, clearSignatureSigns); return (this.isHtml() ? ':HTML:' : '') + this.getData(wrapIsHtml, clearSignatureSigns);
@ -151,7 +153,8 @@ class HtmlEditor
this.editor.setMode('plain'); this.editor.setMode('plain');
} }
} }
} catch (e) {/* eslint-disable-line no-empty */} }
catch (e) {/* eslint-disable-line no-empty */}
if (resize) if (resize)
{ {
@ -180,7 +183,8 @@ class HtmlEditor
try { try {
this.editor.setData(html); this.editor.setData(html);
} catch (e) {/* eslint-disable-line no-empty */} }
catch (e) {/* eslint-disable-line no-empty */}
if (focus) if (focus)
{ {
@ -195,7 +199,8 @@ class HtmlEditor
try { try {
this.editor.setData( this.editor.setData(
this.editor.getData().replace(find, replaceHtml)); this.editor.getData().replace(find, replaceHtml));
} catch (e) {/* eslint-disable-line no-empty */} }
catch (e) {/* eslint-disable-line no-empty */}
} }
} }
@ -211,7 +216,8 @@ class HtmlEditor
{ {
try { try {
this.editor.setData(plain); this.editor.setData(plain);
} catch (e) {/* eslint-disable-line no-empty */} }
catch (e) {/* eslint-disable-line no-empty */}
} }
if (focus) if (focus)
@ -231,8 +237,7 @@ class HtmlEditor
config = oHtmlEditorDefaultConfig, config = oHtmlEditorDefaultConfig,
language = Settings.settingsGet('Language'), language = Settings.settingsGet('Language'),
allowSource = !!Settings.appSettingsGet('allowHtmlEditorSourceButton'), allowSource = !!Settings.appSettingsGet('allowHtmlEditorSourceButton'),
biti = !!Settings.appSettingsGet('allowHtmlEditorBitiButtons') biti = !!Settings.appSettingsGet('allowHtmlEditorBitiButtons');
;
if ((allowSource || !biti) && !config.toolbarGroups.__cfgInited) if ((allowSource || !biti) && !config.toolbarGroups.__cfgInited)
{ {
@ -295,8 +300,7 @@ class HtmlEditor
var var
id = event.data.dataTransfer.id, id = event.data.dataTransfer.id,
imageId = `[img=${id}]`, imageId = `[img=${id}]`,
reader = new window.FileReader() reader = new window.FileReader();
;
reader.onloadend = () => { reader.onloadend = () => {
if (reader.result) if (reader.result)
@ -333,8 +337,7 @@ class HtmlEditor
} }
}); });
} };
;
if (window.CKEDITOR) if (window.CKEDITOR)
{ {
@ -352,7 +355,8 @@ class HtmlEditor
{ {
try { try {
this.editor.focus(); this.editor.focus();
} catch (e) {/* eslint-disable-line no-empty */} }
catch (e) {/* eslint-disable-line no-empty */}
} }
} }
@ -361,7 +365,8 @@ class HtmlEditor
{ {
try { try {
return !!this.editor.focusManager.hasFocus; return !!this.editor.focusManager.hasFocus;
} catch (e) {/* eslint-disable-line no-empty */} }
catch (e) {/* eslint-disable-line no-empty */}
} }
return false; return false;
@ -372,7 +377,8 @@ class HtmlEditor
{ {
try { try {
this.editor.focusManager.blur(true); this.editor.focusManager.blur(true);
} catch (e) {/* eslint-disable-line no-empty */} }
catch (e) {/* eslint-disable-line no-empty */}
} }
} }
@ -381,7 +387,8 @@ class HtmlEditor
{ {
try { try {
this.editor.resize(this.$element.width(), this.$element.innerHeight()); this.editor.resize(this.$element.width(), this.$element.innerHeight());
} catch (e) {/* eslint-disable-line no-empty */} }
catch (e) {/* eslint-disable-line no-empty */}
} }
} }
@ -390,7 +397,8 @@ class HtmlEditor
{ {
try { try {
this.editor.setReadOnly(!!value); this.editor.setReadOnly(!!value);
} catch (e) {/* eslint-disable-line no-empty */} }
catch (e) {/* eslint-disable-line no-empty */}
} }
} }

View file

@ -3,29 +3,33 @@ import {window} from 'common';
import {pString, pInt, isUnd, isNormal, trim, encodeURIComponent} from 'Common/Utils'; import {pString, pInt, isUnd, isNormal, trim, encodeURIComponent} from 'Common/Utils';
import * as Settings from 'Storage/Settings'; import * as Settings from 'Storage/Settings';
const ROOT = './'; const
const HASH_PREFIX = '#/'; ROOT = './',
const SERVER_PREFIX = './?'; HASH_PREFIX = '#/',
const SUB_QUERY_PREFIX = '&q[]='; SERVER_PREFIX = './?',
SUB_QUERY_PREFIX = '&q[]=',
const VERSION = Settings.appSettingsGet('version'); VERSION = Settings.appSettingsGet('version'),
const WEB_PREFIX = Settings.appSettingsGet('webPath') || ''; WEB_PREFIX = Settings.appSettingsGet('webPath') || '',
const VERSION_PREFIX = Settings.appSettingsGet('webVersionPath') || 'rainloop/v/' + VERSION + '/'; VERSION_PREFIX = Settings.appSettingsGet('webVersionPath') || 'rainloop/v/' + VERSION + '/',
const STATIC_PREFIX = VERSION_PREFIX + 'static/'; STATIC_PREFIX = VERSION_PREFIX + 'static/',
const ADMIN_HOST_USE = !!Settings.appSettingsGet('adminHostUse'); ADMIN_HOST_USE = !!Settings.appSettingsGet('adminHostUse'),
const ADMIN_PATH = Settings.appSettingsGet('adminPath') || 'admin'; ADMIN_PATH = Settings.appSettingsGet('adminPath') || 'admin';
let AUTH_PREFIX = Settings.settingsGet('AuthAccountHash') || '0'; let AUTH_PREFIX = Settings.settingsGet('AuthAccountHash') || '0';
/**
* @returns {void}
*/
export function populateAuthSuffix() export function populateAuthSuffix()
{ {
AUTH_PREFIX = Settings.settingsGet('AuthAccountHash') || '0'; AUTH_PREFIX = Settings.settingsGet('AuthAccountHash') || '0';
} }
/** /**
* @return {string} * @returns {string}
*/ */
export function subQueryPrefix() export function subQueryPrefix()
{ {
@ -34,7 +38,7 @@ export function subQueryPrefix()
/** /**
* @param {string=} startupUrl * @param {string=} startupUrl
* @return {string} * @returns {string}
*/ */
export function root(startupUrl = '') export function root(startupUrl = '')
{ {
@ -42,7 +46,7 @@ export function root(startupUrl = '')
} }
/** /**
* @return {string} * @returns {string}
*/ */
export function rootAdmin() export function rootAdmin()
{ {
@ -51,7 +55,7 @@ export function rootAdmin()
/** /**
* @param {boolean=} mobile = false * @param {boolean=} mobile = false
* @return {string} * @returns {string}
*/ */
export function rootUser(mobile = false) export function rootUser(mobile = false)
{ {
@ -62,7 +66,7 @@ export function rootUser(mobile = false)
* @param {string} type * @param {string} type
* @param {string} download * @param {string} download
* @param {string=} customSpecSuffix * @param {string=} customSpecSuffix
* @return {string} * @returns {string}
*/ */
export function attachmentRaw(type, download, customSpecSuffix) export function attachmentRaw(type, download, customSpecSuffix)
{ {
@ -73,7 +77,7 @@ export function attachmentRaw(type, download, customSpecSuffix)
/** /**
* @param {string} download * @param {string} download
* @param {string=} customSpecSuffix * @param {string=} customSpecSuffix
* @return {string} * @returns {string}
*/ */
export function attachmentDownload(download, customSpecSuffix) export function attachmentDownload(download, customSpecSuffix)
{ {
@ -83,7 +87,7 @@ export function attachmentDownload(download, customSpecSuffix)
/** /**
* @param {string} download * @param {string} download
* @param {string=} customSpecSuffix * @param {string=} customSpecSuffix
* @return {string} * @returns {string}
*/ */
export function attachmentPreview(download, customSpecSuffix) export function attachmentPreview(download, customSpecSuffix)
{ {
@ -93,7 +97,7 @@ export function attachmentPreview(download, customSpecSuffix)
/** /**
* @param {string} download * @param {string} download
* @param {string=} customSpecSuffix * @param {string=} customSpecSuffix
* @return {string} * @returns {string}
*/ */
export function attachmentThumbnailPreview(download, customSpecSuffix) export function attachmentThumbnailPreview(download, customSpecSuffix)
{ {
@ -103,7 +107,7 @@ export function attachmentThumbnailPreview(download, customSpecSuffix)
/** /**
* @param {string} download * @param {string} download
* @param {string=} customSpecSuffix * @param {string=} customSpecSuffix
* @return {string} * @returns {string}
*/ */
export function attachmentPreviewAsPlain(download, customSpecSuffix) export function attachmentPreviewAsPlain(download, customSpecSuffix)
{ {
@ -113,7 +117,7 @@ export function attachmentPreviewAsPlain(download, customSpecSuffix)
/** /**
* @param {string} download * @param {string} download
* @param {string=} customSpecSuffix * @param {string=} customSpecSuffix
* @return {string} * @returns {string}
*/ */
export function attachmentFramed(download, customSpecSuffix) export function attachmentFramed(download, customSpecSuffix)
{ {
@ -122,7 +126,7 @@ export function attachmentFramed(download, customSpecSuffix)
/** /**
* @param {string} type * @param {string} type
* @return {string} * @returns {string}
*/ */
export function serverRequest(type) export function serverRequest(type)
{ {
@ -130,7 +134,7 @@ export function serverRequest(type)
} }
/** /**
* @return {string} * @returns {string}
*/ */
export function upload() export function upload()
{ {
@ -138,7 +142,7 @@ export function upload()
} }
/** /**
* @return {string} * @returns {string}
*/ */
export function uploadContacts() export function uploadContacts()
{ {
@ -146,7 +150,7 @@ export function uploadContacts()
} }
/** /**
* @return {string} * @returns {string}
*/ */
export function uploadBackground() export function uploadBackground()
{ {
@ -154,7 +158,7 @@ export function uploadBackground()
} }
/** /**
* @return {string} * @returns {string}
*/ */
export function append() export function append()
{ {
@ -163,7 +167,7 @@ export function append()
/** /**
* @param {string} email * @param {string} email
* @return {string} * @returns {string}
*/ */
export function change(email) export function change(email)
{ {
@ -172,7 +176,7 @@ export function change(email)
/** /**
* @param {string} add * @param {string} add
* @return {string} * @returns {string}
*/ */
export function ajax(add) export function ajax(add)
{ {
@ -181,7 +185,7 @@ export function ajax(add)
/** /**
* @param {string} requestHash * @param {string} requestHash
* @return {string} * @returns {string}
*/ */
export function messageViewLink(requestHash) export function messageViewLink(requestHash)
{ {
@ -190,7 +194,7 @@ export function messageViewLink(requestHash)
/** /**
* @param {string} requestHash * @param {string} requestHash
* @return {string} * @returns {string}
*/ */
export function messageDownloadLink(requestHash) export function messageDownloadLink(requestHash)
{ {
@ -199,7 +203,7 @@ export function messageDownloadLink(requestHash)
/** /**
* @param {string} email * @param {string} email
* @return {string} * @returns {string}
*/ */
export function avatarLink(email) export function avatarLink(email)
{ {
@ -208,7 +212,7 @@ export function avatarLink(email)
/** /**
* @param {string} hash * @param {string} hash
* @return {string} * @returns {string}
*/ */
export function publicLink(hash) export function publicLink(hash)
{ {
@ -217,7 +221,7 @@ export function publicLink(hash)
/** /**
* @param {string} hash * @param {string} hash
* @return {string} * @returns {string}
*/ */
export function userBackground(hash) export function userBackground(hash)
{ {
@ -225,7 +229,7 @@ export function userBackground(hash)
} }
/** /**
* @return {string} * @returns {string}
*/ */
export function phpInfo() export function phpInfo()
{ {
@ -235,7 +239,7 @@ export function phpInfo()
/** /**
* @param {string} lang * @param {string} lang
* @param {boolean} isAdmin * @param {boolean} isAdmin
* @return {string} * @returns {string}
*/ */
export function langLink(lang, isAdmin) export function langLink(lang, isAdmin)
{ {
@ -243,7 +247,7 @@ export function langLink(lang, isAdmin)
} }
/** /**
* @return {string} * @returns {string}
*/ */
export function exportContactsVcf() export function exportContactsVcf()
{ {
@ -251,7 +255,7 @@ export function exportContactsVcf()
} }
/** /**
* @return {string} * @returns {string}
*/ */
export function exportContactsCsv() export function exportContactsCsv()
{ {
@ -260,7 +264,7 @@ export function exportContactsCsv()
/** /**
* @param {boolean} xauth = false * @param {boolean} xauth = false
* @return {string} * @returns {string}
*/ */
export function socialGoogle(xauth = false) export function socialGoogle(xauth = false)
{ {
@ -269,7 +273,7 @@ export function socialGoogle(xauth = false)
} }
/** /**
* @return {string} * @returns {string}
*/ */
export function socialTwitter() export function socialTwitter()
{ {
@ -278,7 +282,7 @@ export function socialTwitter()
} }
/** /**
* @return {string} * @returns {string}
*/ */
export function socialFacebook() export function socialFacebook()
{ {
@ -288,7 +292,7 @@ export function socialFacebook()
/** /**
* @param {string} path * @param {string} path
* @return {string} * @returns {string}
*/ */
export function staticPrefix(path) export function staticPrefix(path)
{ {
@ -296,7 +300,7 @@ export function staticPrefix(path)
} }
/** /**
* @return {string} * @returns {string}
*/ */
export function emptyContactPic() export function emptyContactPic()
{ {
@ -305,7 +309,7 @@ export function emptyContactPic()
/** /**
* @param {string} fileName * @param {string} fileName
* @return {string} * @returns {string}
*/ */
export function sound(fileName) export function sound(fileName)
{ {
@ -313,7 +317,7 @@ export function sound(fileName)
} }
/** /**
* @return {string} * @returns {string}
*/ */
export function notificationMailIcon() export function notificationMailIcon()
{ {
@ -321,7 +325,7 @@ export function notificationMailIcon()
} }
/** /**
* @return {string} * @returns {string}
*/ */
export function openPgpJs() export function openPgpJs()
{ {
@ -329,7 +333,7 @@ export function openPgpJs()
} }
/** /**
* @return {string} * @returns {string}
*/ */
export function openPgpWorkerJs() export function openPgpWorkerJs()
{ {
@ -337,7 +341,7 @@ export function openPgpWorkerJs()
} }
/** /**
* @return {string} * @returns {string}
*/ */
export function openPgpWorkerPath() export function openPgpWorkerPath()
{ {
@ -346,7 +350,7 @@ export function openPgpWorkerPath()
/** /**
* @param {string} theme * @param {string} theme
* @return {string} * @returns {string}
*/ */
export function themePreviewLink(theme) export function themePreviewLink(theme)
{ {
@ -362,7 +366,7 @@ export function themePreviewLink(theme)
/** /**
* @param {string} inboxFolderName = 'INBOX' * @param {string} inboxFolderName = 'INBOX'
* @return {string} * @returns {string}
*/ */
export function inbox(inboxFolderName = 'INBOX') export function inbox(inboxFolderName = 'INBOX')
{ {
@ -371,7 +375,7 @@ export function inbox(inboxFolderName = 'INBOX')
/** /**
* @param {string=} screenName = '' * @param {string=} screenName = ''
* @return {string} * @returns {string}
*/ */
export function settings(screenName = '') export function settings(screenName = '')
{ {
@ -379,7 +383,7 @@ export function settings(screenName = '')
} }
/** /**
* @return {string} * @returns {string}
*/ */
export function about() export function about()
{ {
@ -388,12 +392,13 @@ export function about()
/** /**
* @param {string} screenName * @param {string} screenName
* @return {string} * @returns {string}
*/ */
export function admin(screenName) export function admin(screenName)
{ {
let result = HASH_PREFIX; let result = HASH_PREFIX;
switch (screenName) { switch (screenName)
{
case 'AdminDomains': case 'AdminDomains':
result += 'domains'; result += 'domains';
break; break;
@ -403,6 +408,7 @@ export function admin(screenName)
case 'AdminLicensing': case 'AdminLicensing':
result += 'licensing'; result += 'licensing';
break; break;
// no default
} }
return result; return result;
@ -413,7 +419,7 @@ export function admin(screenName)
* @param {number=} page = 1 * @param {number=} page = 1
* @param {string=} search = '' * @param {string=} search = ''
* @param {string=} threadUid = '' * @param {string=} threadUid = ''
* @return {string} * @returns {string}
*/ */
export function mailBox(folder, page = 1, search = '', threadUid = '') export function mailBox(folder, page = 1, search = '', threadUid = '')
{ {

View file

@ -13,12 +13,18 @@ const updateMomentNowUnix = _.debounce(() => {
_momentNow = moment().unix(); _momentNow = moment().unix();
}, 500, true); }, 500, true);
/**
* @returns {moment}
*/
export function momentNow() export function momentNow()
{ {
updateMomentNow(); updateMomentNow();
return _moment || moment(); return _moment || moment();
} }
/**
* @returns {number}
*/
export function momentNowUnix() export function momentNowUnix()
{ {
updateMomentNowUnix(); updateMomentNowUnix();
@ -27,7 +33,7 @@ export function momentNowUnix()
/** /**
* @param {number} date * @param {number} date
* @return {string} * @returns {string}
*/ */
export function searchSubtractFormatDateHelper(date) export function searchSubtractFormatDateHelper(date)
{ {
@ -36,14 +42,14 @@ export function searchSubtractFormatDateHelper(date)
/** /**
* @param {Object} m * @param {Object} m
* @return {string} * @returns {string}
*/ */
function formatCustomShortDate(m) function formatCustomShortDate(m)
{ {
const now = momentNow(); const now = momentNow();
if (m && now) if (m && now)
{ {
switch(true) switch (true)
{ {
case 4 >= now.diff(m, 'hours'): case 4 >= now.diff(m, 'hours'):
return m.fromNow(); return m.fromNow();
@ -57,6 +63,7 @@ function formatCustomShortDate(m)
}); });
case now.year() === m.year(): case now.year() === m.year():
return m.format('D MMM.'); return m.format('D MMM.');
// no default
} }
} }
@ -66,15 +73,14 @@ function formatCustomShortDate(m)
/** /**
* @param {number} timeStampInUTC * @param {number} timeStampInUTC
* @param {string} formatStr * @param {string} formatStr
* @return {string} * @returns {string}
*/ */
export function format(timeStampInUTC, formatStr) export function format(timeStampInUTC, formatStr)
{ {
let let
m = null, m = null,
result = '' result = '';
;
const now = momentNowUnix(); const now = momentNowUnix();
@ -112,14 +118,14 @@ export function format(timeStampInUTC, formatStr)
/** /**
* @param {Object} element * @param {Object} element
* @returns {void}
*/ */
export function momentToNode(element) export function momentToNode(element)
{ {
var var
key = '', key = '',
time = 0, time = 0,
$el = $(element) $el = $(element);
;
time = $el.data('moment-time'); time = $el.data('moment-time');
if (time) if (time)
@ -138,6 +144,9 @@ export function momentToNode(element)
} }
} }
/**
* @returns {void}
*/
export function reload() export function reload()
{ {
_.defer(() => { _.defer(() => {

View file

@ -41,7 +41,7 @@ export function runHook(name, args = [])
/** /**
* @param {string} name * @param {string} name
* @return {?} * @returns {?}
*/ */
export function mainSettingsGet(name) export function mainSettingsGet(name)
{ {
@ -98,7 +98,7 @@ export function runSettingsViewModelHooks(admin)
/** /**
* @param {string} pluginSection * @param {string} pluginSection
* @param {string} name * @param {string} name
* @return {?} * @returns {?}
*/ */
export function settingsGet(pluginSection, name) export function settingsGet(pluginSection, name)
{ {

View file

@ -129,8 +129,7 @@ class Selector
aCache = [], aCache = [],
aCheckedCache = [], aCheckedCache = [],
mFocused = null, mFocused = null,
mSelected = null mSelected = null;
;
this.list.subscribe((items) => { this.list.subscribe((items) => {
@ -168,8 +167,7 @@ class Selector
mNextFocused = mFocused, mNextFocused = mFocused,
bChecked = false, bChecked = false,
bSelected = false, bSelected = false,
iLen = 0 iLen = 0;
;
this.selectedItemUseCallback = false; this.selectedItemUseCallback = false;
@ -195,7 +193,7 @@ class Selector
{ {
bChecked = true; bChecked = true;
oItem.checked(true); oItem.checked(true);
iLen--; iLen -= 1;
} }
if (!bChecked && null !== mSelected && mSelected === sUid) if (!bChecked && null !== mSelected && mSelected === sUid)
@ -350,8 +348,7 @@ class Selector
item.checked(!item.checked()); item.checked(!item.checked());
} }
} }
}) });
;
key('enter', keyScope, () => { key('enter', keyScope, () => {
if (this.focusedItem() && !this.focusedItem().selected()) if (this.focusedItem() && !this.focusedItem().selected())
@ -397,6 +394,7 @@ class Selector
case 'pagedown': case 'pagedown':
eventKey = EventKeyCode.PageDown; eventKey = EventKeyCode.PageDown;
break; break;
// no default
} }
if (0 < eventKey) if (0 < eventKey)
@ -410,7 +408,7 @@ class Selector
} }
/** /**
* @return {boolean} * @returns {boolean}
*/ */
autoSelect() { autoSelect() {
return !!(this.oCallbacks.onAutoSelect || noopTrue)(); return !!(this.oCallbacks.onAutoSelect || noopTrue)();
@ -425,7 +423,7 @@ class Selector
/** /**
* @param {Object} oItem * @param {Object} oItem
* @return {string} * @returns {string}
*/ */
getItemUid(item) { getItemUid(item) {
@ -455,8 +453,7 @@ class Selector
oResult = null, oResult = null,
aList = this.list(), aList = this.list(),
iListLen = aList ? aList.length : 0, iListLen = aList ? aList.length : 0,
oFocused = this.focusedItem() oFocused = this.focusedItem();
;
if (0 < iListLen) if (0 < iListLen)
{ {
@ -482,7 +479,8 @@ class Selector
_.each(aList, (item) => { _.each(aList, (item) => {
if (!bStop) if (!bStop)
{ {
switch (iEventKeyCode) { switch (iEventKeyCode)
{
case EventKeyCode.Up: case EventKeyCode.Up:
if (oFocused === item) if (oFocused === item)
{ {
@ -505,6 +503,7 @@ class Selector
bNext = true; bNext = true;
} }
break; break;
// no default
} }
} }
}); });
@ -540,7 +539,7 @@ class Selector
} }
else if (EventKeyCode.PageUp === iEventKeyCode) else if (EventKeyCode.PageUp === iEventKeyCode)
{ {
for (iIndex = iListLen; iIndex >= 0; iIndex--) for (iIndex = iListLen; 0 <= iIndex; iIndex--)
{ {
if (oFocused === aList[iIndex]) if (oFocused === aList[iIndex])
{ {
@ -597,7 +596,7 @@ class Selector
} }
/** /**
* @return {boolean} * @returns {boolean}
*/ */
scrollToFocused() { scrollToFocused() {
@ -612,17 +611,16 @@ class Selector
$focused = $(this.sItemFocusedSelector, this.oContentScrollable), $focused = $(this.sItemFocusedSelector, this.oContentScrollable),
pos = $focused.position(), pos = $focused.position(),
visibleHeight = this.oContentVisible.height(), visibleHeight = this.oContentVisible.height(),
focusedHeight = $focused.outerHeight() focusedHeight = $focused.outerHeight();
;
if (list && list[0] && list[0].focused()) if (list && list[0] && list[0].focused())
{ {
this.oContentScrollable.scrollTop(0); this.oContentScrollable.scrollTop(0);
return true; return true;
} }
else if (pos && (pos.top < 0 || pos.top + focusedHeight > visibleHeight)) else if (pos && (0 > pos.top || pos.top + focusedHeight > visibleHeight))
{ {
this.oContentScrollable.scrollTop(pos.top < 0 ? this.oContentScrollable.scrollTop(0 > pos.top ?
this.oContentScrollable.scrollTop() + pos.top - offset : this.oContentScrollable.scrollTop() + pos.top - offset :
this.oContentScrollable.scrollTop() + pos.top - visibleHeight + focusedHeight + offset this.oContentScrollable.scrollTop() + pos.top - visibleHeight + focusedHeight + offset
); );
@ -635,7 +633,7 @@ class Selector
/** /**
* @param {boolean=} fast = false * @param {boolean=} fast = false
* @return {boolean} * @returns {boolean}
*/ */
scrollToTop(fast = false) { scrollToTop(fast = false) {
@ -666,8 +664,7 @@ class Selector
list = [], list = [],
checked = false, checked = false,
listItem = null, listItem = null,
lineUid = '' lineUid = '';
;
const uid = this.getItemUid(item); const uid = this.getItemUid(item);
if (event && event.shiftKey) if (event && event.shiftKey)

View file

@ -88,14 +88,13 @@ export const trigger = ko.observable(false);
* @param {string} key * @param {string} key
* @param {Object=} valueList * @param {Object=} valueList
* @param {string=} defaulValue * @param {string=} defaulValue
* @return {string} * @returns {string}
*/ */
export function i18n(key, valueList, defaulValue) export function i18n(key, valueList, defaulValue)
{ {
let let
valueName = '', valueName = '',
result = I18N_DATA[key] result = I18N_DATA[key];
;
if (isUnd(result)) if (isUnd(result))
{ {
@ -120,8 +119,7 @@ const i18nToNode = (element) => {
const const
$el = $(element), $el = $(element),
key = $el.data('i18n') key = $el.data('i18n');
;
if (key) if (key)
{ {
@ -138,6 +136,7 @@ const i18nToNode = (element) => {
case '[title': case '[title':
$el.attr('title', i18n(key.substr(7))); $el.attr('title', i18n(key.substr(7)));
break; break;
// no default
} }
} }
else else
@ -187,6 +186,9 @@ const reloadData = () => {
window.rainloopI18N = null; window.rainloopI18N = null;
}; };
/**
* @returns {void}
*/
export function initNotificationLanguage() export function initNotificationLanguage()
{ {
I18N_NOTIFICATION_MAP.forEach((item) => { I18N_NOTIFICATION_MAP.forEach((item) => {
@ -227,7 +229,7 @@ export function initOnStartOrLangChange(callback, scope, langCallback = null)
* @param {number} code * @param {number} code
* @param {*=} message = '' * @param {*=} message = ''
* @param {*=} defCode = null * @param {*=} defCode = null
* @return {string} * @returns {string}
*/ */
export function getNotification(code, message = '', defCode = null) export function getNotification(code, message = '', defCode = null)
{ {
@ -246,7 +248,7 @@ export function getNotification(code, message = '', defCode = null)
/** /**
* @param {object} response * @param {object} response
* @param {number} defCode = Notification.UnknownNotification * @param {number} defCode = Notification.UnknownNotification
* @return {string} * @returns {string}
*/ */
export function getNotificationFromResponse(response, defCode = Notification.UnknownNotification) export function getNotificationFromResponse(response, defCode = Notification.UnknownNotification)
{ {
@ -256,7 +258,7 @@ export function getNotificationFromResponse(response, defCode = Notification.Unk
/** /**
* @param {*} code * @param {*} code
* @return {string} * @returns {string}
*/ */
export function getUploadErrorDescByCode(code) export function getUploadErrorDescByCode(code)
{ {
@ -314,9 +316,8 @@ export function reload(admin, language)
$html $html
.removeClass('rl-changing-language') .removeClass('rl-changing-language')
.removeClass('rl-rtl rl-ltr') .removeClass('rl-rtl rl-ltr')
.addClass(isRtl ? 'rl-rtl' : 'rl-ltr')
// .attr('dir', isRtl ? 'rtl' : 'ltr') // .attr('dir', isRtl ? 'rtl' : 'ltr')
; .addClass(isRtl ? 'rl-rtl' : 'rl-ltr');
resolve(); resolve();

View file

@ -32,12 +32,13 @@ export function silentTryCatch(callback)
{ {
try { try {
callback(); callback();
} catch (e) {/* eslint-disable-line no-empty */} }
catch (e) {/* eslint-disable-line no-empty */}
} }
/** /**
* @param {*} value * @param {*} value
* @return {boolean} * @returns {boolean}
*/ */
export function isNormal(value) export function isNormal(value)
{ {
@ -47,7 +48,7 @@ export function isNormal(value)
/** /**
* @param {(string|number)} value * @param {(string|number)} value
* @param {boolean=} includeZero = true * @param {boolean=} includeZero = true
* @return {boolean} * @returns {boolean}
*/ */
export function isPosNumeric(value, includeZero = true) export function isPosNumeric(value, includeZero = true)
{ {
@ -58,7 +59,7 @@ export function isPosNumeric(value, includeZero = true)
/** /**
* @param {*} value * @param {*} value
* @param {number=} defaultValur = 0 * @param {number=} defaultValur = 0
* @return {number} * @returns {number}
*/ */
export function pInt(value, defaultValur = 0) export function pInt(value, defaultValur = 0)
{ {
@ -68,7 +69,7 @@ export function pInt(value, defaultValur = 0)
/** /**
* @param {*} value * @param {*} value
* @return {string} * @returns {string}
*/ */
export function pString(value) export function pString(value)
{ {
@ -77,7 +78,7 @@ export function pString(value)
/** /**
* @param {*} value * @param {*} value
* @return {boolean} * @returns {boolean}
*/ */
export function pBool(value) export function pBool(value)
{ {
@ -86,7 +87,7 @@ export function pBool(value)
/** /**
* @param {*} values * @param {*} values
* @return {boolean} * @returns {boolean}
*/ */
export function isNonEmptyArray(values) export function isNonEmptyArray(values)
{ {
@ -95,7 +96,7 @@ export function isNonEmptyArray(values)
/** /**
* @param {string} component * @param {string} component
* @return {string} * @returns {string}
*/ */
export function encodeURIComponent(component) export function encodeURIComponent(component)
{ {
@ -104,7 +105,7 @@ export function encodeURIComponent(component)
/** /**
* @param {string} component * @param {string} component
* @return {string} * @returns {string}
*/ */
export function decodeURIComponent(component) export function decodeURIComponent(component)
{ {
@ -113,20 +114,17 @@ export function decodeURIComponent(component)
/** /**
* @param {string} queryString * @param {string} queryString
* @return {Object} * @returns {Object}
*/ */
export function simpleQueryParser(queryString) export function simpleQueryParser(queryString)
{ {
let let index = 0, len = 0, temp = null;
params = {},
queries = [],
temp = [],
index = 0,
len = 0
;
queries = queryString.split('&'); const
for (index = 0, len = queries.length; index < len; index++) queries = queryString.split('&'),
params = {};
for (len = queries.length; index < len; index++)
{ {
temp = queries[index].split('='); temp = queries[index].split('=');
params[decodeURIComponent(temp[0])] = decodeURIComponent(temp[1]); params[decodeURIComponent(temp[0])] = decodeURIComponent(temp[1]);
@ -137,14 +135,13 @@ export function simpleQueryParser(queryString)
/** /**
* @param {number=} len = 32 * @param {number=} len = 32
* @return {string} * @returns {string}
*/ */
export function fakeMd5(len = 32) export function fakeMd5(len = 32)
{ {
const const
line = '0123456789abcdefghijklmnopqrstuvwxyz', line = '0123456789abcdefghijklmnopqrstuvwxyz',
lineLen = line.length lineLen = line.length;
;
len = pInt(len); len = pInt(len);
@ -162,7 +159,7 @@ let encryptObject = null;
/** /**
* @param {constructor} JSEncryptClass * @param {constructor} JSEncryptClass
* @param {string} publicKey * @param {string} publicKey
* @return {JSEncrypt|boolean} * @returns {JSEncrypt|boolean}
*/ */
const rsaObject = (JSEncryptClass, publicKey) => { const rsaObject = (JSEncryptClass, publicKey) => {
@ -184,16 +181,14 @@ const rsaObject = (JSEncryptClass, publicKey) => {
/** /**
* @param {string} value * @param {string} value
* @param {string} publicKey * @param {string} publicKey
* @return {string} * @returns {string}
*/ */
const rsaEncode = (value, publicKey) => { const rsaEncode = (value, publicKey) => {
if (window.crypto && window.crypto.getRandomValues && publicKey) if (window.crypto && window.crypto.getRandomValues && publicKey)
{ {
let let resultValue = false;
resultValue = false, const encrypt = rsaObject(JSEncrypt, publicKey);
encrypt = rsaObject(JSEncrypt, publicKey)
;
if (encrypt) if (encrypt)
{ {
@ -214,7 +209,7 @@ export {rsaEncode};
/** /**
* @param {string} text * @param {string} text
* @return {string} * @returns {string}
*/ */
export function encodeHtml(text) export function encodeHtml(text)
{ {
@ -224,7 +219,7 @@ export function encodeHtml(text)
/** /**
* @param {string} text * @param {string} text
* @param {number=} iLen = 100 * @param {number=} iLen = 100
* @return {string} * @returns {string}
*/ */
export function splitPlainText(text, len = 100) export function splitPlainText(text, len = 100)
{ {
@ -233,8 +228,7 @@ export function splitPlainText(text, len = 100)
subText = '', subText = '',
result = text, result = text,
spacePos = 0, spacePos = 0,
newLinePos = 0 newLinePos = 0;
;
while (result.length > len) while (result.length > len)
{ {
@ -259,8 +253,8 @@ export function splitPlainText(text, len = 100)
return prefix + result; return prefix + result;
} }
const timeOutAction = (function () { const timeOutAction = (function() {
let timeOuts = {}; const timeOuts = {};
return (action, fFunction, timeOut) => { return (action, fFunction, timeOut) => {
timeOuts[action] = isUnd(timeOuts[action]) ? 0 : timeOuts[action]; timeOuts[action] = isUnd(timeOuts[action]) ? 0 : timeOuts[action];
window.clearTimeout(timeOuts[action]); window.clearTimeout(timeOuts[action]);
@ -268,8 +262,8 @@ const timeOutAction = (function () {
}; };
}()); }());
const timeOutActionSecond = (function () { const timeOutActionSecond = (function() {
let timeOuts = {}; const timeOuts = {};
return (action, fFunction, timeOut) => { return (action, fFunction, timeOut) => {
if (!timeOuts[action]) if (!timeOuts[action])
{ {
@ -284,7 +278,7 @@ const timeOutActionSecond = (function () {
export {timeOutAction, timeOutActionSecond}; export {timeOutAction, timeOutActionSecond};
/** /**
* @return {boolean} * @returns {boolean}
*/ */
export function inFocus() export function inFocus()
{ {
@ -301,6 +295,10 @@ export function inFocus()
return false; return false;
} }
/**
* @param {boolean} force
* @returns {void}
*/
export function removeInFocus(force) export function removeInFocus(force)
{ {
if (window.document && window.document.activeElement && window.document.activeElement.blur) if (window.document && window.document.activeElement && window.document.activeElement.blur)
@ -315,10 +313,14 @@ export function removeInFocus(force)
{ {
window.document.activeElement.blur(); window.document.activeElement.blur();
} }
} catch (e) {/* eslint-disable-line no-empty */} }
catch (e) {/* eslint-disable-line no-empty */}
} }
} }
/**
* @returns {void}
*/
export function removeSelection() export function removeSelection()
{ {
try { try {
@ -334,41 +336,42 @@ export function removeSelection()
{ {
window.document.selection.empty(); window.document.selection.empty();
} }
} catch (e) {/* eslint-disable-line no-empty */} }
catch (e) {/* eslint-disable-line no-empty */}
} }
/** /**
* @param {string} prefix * @param {string} prefix
* @param {string} subject * @param {string} subject
* @return {string} * @returns {string}
*/ */
export function replySubjectAdd(prefix, subject) export function replySubjectAdd(prefix, subject)
{ {
prefix = trim(prefix.toUpperCase()); prefix = trim(prefix.toUpperCase());
subject = trim(subject.replace(/[\s]+/g, ' ')); subject = trim(subject.replace(/[\s]+/g, ' '));
let let drop = false,
drop = false,
parts = [],
re = 'RE' === prefix, re = 'RE' === prefix,
fwd = 'FWD' === prefix, fwd = 'FWD' === prefix;
prefixIsRe = !fwd
; const
parts = [],
prefixIsRe = !fwd;
if ('' !== subject) if ('' !== subject)
{ {
_.each(subject.split(':'), (part) => { _.each(subject.split(':'), (part) => {
const trimmedPart = trim(part); const trimmedPart = trim(part);
if (!drop && (/^(RE|FWD)$/i.test(trimmedPart) || /^(RE|FWD)[\[\(][\d]+[\]\)]$/i.test(trimmedPart))) if (!drop && ((/^(RE|FWD)$/i).test(trimmedPart) || (/^(RE|FWD)[\[\(][\d]+[\]\)]$/i).test(trimmedPart)))
{ {
if (!re) if (!re)
{ {
re = !!(/^RE/i.test(trimmedPart)); re = !!(/^RE/i).test(trimmedPart);
} }
if (!fwd) if (!fwd)
{ {
fwd = !!(/^FWD/i.test(trimmedPart)); fwd = !!(/^FWD/i).test(trimmedPart);
} }
} }
else else
@ -399,7 +402,7 @@ export function replySubjectAdd(prefix, subject)
/** /**
* @param {number} num * @param {number} num
* @param {number} dec * @param {number} dec
* @return {number} * @returns {number}
*/ */
export function roundNumber(num, dec) export function roundNumber(num, dec)
{ {
@ -408,23 +411,21 @@ export function roundNumber(num, dec)
/** /**
* @param {(number|string)} sizeInBytes * @param {(number|string)} sizeInBytes
* @return {string} * @returns {string}
*/ */
export function friendlySize(sizeInBytes) export function friendlySize(sizeInBytes)
{ {
sizeInBytes = pInt(sizeInBytes); sizeInBytes = pInt(sizeInBytes);
if (sizeInBytes >= 1073741824) switch (true)
{ {
case 1073741824 <= sizeInBytes:
return roundNumber(sizeInBytes / 1073741824, 1) + 'GB'; return roundNumber(sizeInBytes / 1073741824, 1) + 'GB';
} case 1048576 <= sizeInBytes:
else if (sizeInBytes >= 1048576)
{
return roundNumber(sizeInBytes / 1048576, 1) + 'MB'; return roundNumber(sizeInBytes / 1048576, 1) + 'MB';
} case 1024 <= sizeInBytes:
else if (sizeInBytes >= 1024)
{
return roundNumber(sizeInBytes / 1024, 0) + 'KB'; return roundNumber(sizeInBytes / 1024, 0) + 'KB';
// no default
} }
return sizeInBytes + 'B'; return sizeInBytes + 'B';
@ -506,21 +507,19 @@ export function kill_CtrlA_CtrlS(event)
* @param {(Object|null|undefined)} context * @param {(Object|null|undefined)} context
* @param {Function} fExecute * @param {Function} fExecute
* @param {(Function|boolean|null)=} fCanExecute = true * @param {(Function|boolean|null)=} fCanExecute = true
* @return {Function} * @returns {Function}
*/ */
export function createCommand(context, fExecute, fCanExecute = true) export function createCommand(context, fExecute, fCanExecute = true)
{ {
let let fResult = null;
fResult = null, const fNonEmpty = (...args) => {
fNonEmpty = (...args) => {
if (fResult && fResult.canExecute && fResult.canExecute()) if (fResult && fResult.canExecute && fResult.canExecute())
{ {
fExecute.apply(context, args); fExecute.apply(context, args);
} }
return false; return false;
} };
;
fResult = fExecute ? fNonEmpty : noop; fResult = fExecute ? fNonEmpty : noop;
fResult.enabled = ko.observable(true); fResult.enabled = ko.observable(true);
@ -543,7 +542,7 @@ export function createCommand(context, fExecute, fCanExecute = true)
/** /**
* @param {string} theme * @param {string} theme
* @return {string} * @returns {string}
*/ */
export const convertThemeName = _.memoize((theme) => { export const convertThemeName = _.memoize((theme) => {
@ -557,7 +556,7 @@ export const convertThemeName = _.memoize((theme) => {
/** /**
* @param {string} name * @param {string} name
* @return {string} * @returns {string}
*/ */
export function quoteName(name) export function quoteName(name)
{ {
@ -565,7 +564,7 @@ export function quoteName(name)
} }
/** /**
* @return {number} * @returns {number}
*/ */
export function microtime() export function microtime()
{ {
@ -573,7 +572,7 @@ export function microtime()
} }
/** /**
* @return {number} * @returns {number}
*/ */
export function timestamp() export function timestamp()
{ {
@ -584,7 +583,7 @@ export function timestamp()
* *
* @param {string} language * @param {string} language
* @param {boolean=} isEng = false * @param {boolean=} isEng = false
* @return {string} * @returns {string}
*/ */
export function convertLangName(language, isEng = false) export function convertLangName(language, isEng = false)
{ {
@ -592,6 +591,9 @@ export function convertLangName(language, isEng = false)
language.toUpperCase().replace(/[^a-zA-Z0-9]+/g, '_'), null, language); language.toUpperCase().replace(/[^a-zA-Z0-9]+/g, '_'), null, language);
} }
/**
* @returns {object}
*/
export function draggablePlace() export function draggablePlace()
{ {
return $('<div class="draggablePlace">' + return $('<div class="draggablePlace">' +
@ -602,14 +604,18 @@ export function draggablePlace()
).appendTo('#rl-hidden'); ).appendTo('#rl-hidden');
} }
export function defautOptionsAfterRender(domOption, item) /**
* @param {object} domOption
* @param {object} item
* @returns {void}
*/
export function defautOptionsAfterRender(domItem, item)
{ {
if (item && !isUnd(item.disabled) && domOption) if (item && !isUnd(item.disabled) && domItem)
{ {
$(domOption) $(domItem)
.toggleClass('disabled', item.disabled) .toggleClass('disabled', item.disabled)
.prop('disabled', item.disabled) .prop('disabled', item.disabled);
;
} }
} }
@ -638,8 +644,7 @@ export function previewMessage(title, body, isHtml, print)
win = window.open(''), win = window.open(''),
doc = win.document, doc = win.document,
bodyClone = body.clone(), bodyClone = body.clone(),
bodyClass = isHtml ? 'html' : 'plain' bodyClass = isHtml ? 'html' : 'plain';
;
clearBqSwitcher(bodyClone); clearBqSwitcher(bodyClone);
@ -734,7 +739,7 @@ body.plain blockquote blockquote blockquote {
* @param {?} koTrigger * @param {?} koTrigger
* @param {?} context = null * @param {?} context = null
* @param {number=} timer = 1000 * @param {number=} timer = 1000
* @return {Function} * @returns {Function}
*/ */
export function settingsSaveHelperFunction(fCallback, koTrigger, context = null, timer = 1000) export function settingsSaveHelperFunction(fCallback, koTrigger, context = null, timer = 1000)
{ {
@ -751,11 +756,23 @@ export function settingsSaveHelperFunction(fCallback, koTrigger, context = null,
}; };
} }
/**
* @param {object} koTrigger
* @param {mixed} context
* @returns {mixed}
*/
export function settingsSaveHelperSimpleFunction(koTrigger, context) export function settingsSaveHelperSimpleFunction(koTrigger, context)
{ {
return settingsSaveHelperFunction(null, koTrigger, context, 1000); return settingsSaveHelperFunction(null, koTrigger, context, 1000);
} }
/**
* @param {object} remote
* @param {string} settingName
* @param {string} type
* @param {function} fTriggerFunction
* @returns {function}
*/
export function settingsSaveHelperSubscribeFunction(remote, settingName, type, fTriggerFunction) export function settingsSaveHelperSubscribeFunction(remote, settingName, type, fTriggerFunction)
{ {
return (value) => { return (value) => {
@ -764,9 +781,6 @@ export function settingsSaveHelperSubscribeFunction(remote, settingName, type, f
{ {
switch (type) switch (type)
{ {
default:
value = pString(value);
break;
case 'bool': case 'bool':
case 'boolean': case 'boolean':
value = value ? '1' : '0'; value = value ? '1' : '0';
@ -779,9 +793,12 @@ export function settingsSaveHelperSubscribeFunction(remote, settingName, type, f
case 'trim': case 'trim':
value = trim(value); value = trim(value);
break; break;
default:
value = pString(value);
break;
} }
let data = {}; const data = {};
data[settingName] = value; data[settingName] = value;
if (remote.saveAdminConfig) if (remote.saveAdminConfig)
@ -798,7 +815,7 @@ export function settingsSaveHelperSubscribeFunction(remote, settingName, type, f
/** /**
* @param {string} html * @param {string} html
* @return {string} * @returns {string}
*/ */
export function findEmailAndLinks(html) export function findEmailAndLinks(html)
{ {
@ -809,7 +826,7 @@ export function findEmailAndLinks(html)
urls: true, urls: true,
email: true, email: true,
twitter: false, twitter: false,
replaceFn: function (autolinker, match) { replaceFn: function(autolinker, match) {
return !(autolinker && match && 'url' === match.getType() && match.matchedText && 0 !== match.matchedText.indexOf('http')); return !(autolinker && match && 'url' === match.getType() && match.matchedText && 0 !== match.matchedText.indexOf('http'));
} }
}); });
@ -817,7 +834,7 @@ export function findEmailAndLinks(html)
/** /**
* @param {string} html * @param {string} html
* @return {string} * @returns {string}
*/ */
export function htmlToPlain(html) export function htmlToPlain(html)
{ {
@ -828,8 +845,7 @@ export function htmlToPlain(html)
iP2 = 0, iP2 = 0,
iP3 = 0, iP3 = 0,
text = '' text = '';
;
const const
@ -867,8 +883,7 @@ export function htmlToPlain(html)
convertLinks = (...args) => { convertLinks = (...args) => {
return (args && 1 < args.length) ? trim(args[1]) : ''; return (args && 1 < args.length) ? trim(args[1]) : '';
} };
;
text = html text = html
.replace(/\u0002([\s\S]*)\u0002/gm, '\u200C$1\u200C') .replace(/\u0002([\s\S]*)\u0002/gm, '\u200C$1\u200C')
@ -893,8 +908,7 @@ export function htmlToPlain(html)
.replace(/<\/div>/gi, '\n') .replace(/<\/div>/gi, '\n')
.replace(/&nbsp;/gi, ' ') .replace(/&nbsp;/gi, ' ')
.replace(/&quot;/gi, '"') .replace(/&quot;/gi, '"')
.replace(/<[^>]*>/gm, '') .replace(/<[^>]*>/gm, '');
;
text = $div.html(text).text(); text = $div.html(text).text();
@ -903,8 +917,7 @@ export function htmlToPlain(html)
.replace(/[\n]{3,}/gm, '\n\n') .replace(/[\n]{3,}/gm, '\n\n')
.replace(/&gt;/gi, '>') .replace(/&gt;/gi, '>')
.replace(/&lt;/gi, '<') .replace(/&lt;/gi, '<')
.replace(/&amp;/gi, '&') .replace(/&amp;/gi, '&');
;
text = splitPlainText(trim(text)); text = splitPlainText(trim(text));
@ -913,7 +926,7 @@ export function htmlToPlain(html)
while (0 < limit) while (0 < limit)
{ {
limit--; limit -= 1;
iP1 = text.indexOf('__bq__start__', pos); iP1 = text.indexOf('__bq__start__', pos);
if (-1 < iP1) if (-1 < iP1)
{ {
@ -945,8 +958,7 @@ export function htmlToPlain(html)
text = text text = text
.replace(/__bq__start__/gm, '') .replace(/__bq__start__/gm, '')
.replace(/__bq__end__/gm, '') .replace(/__bq__end__/gm, '');
;
return text; return text;
} }
@ -954,7 +966,7 @@ export function htmlToPlain(html)
/** /**
* @param {string} plain * @param {string} plain
* @param {boolean} findEmailAndLinksInText = false * @param {boolean} findEmailAndLinksInText = false
* @return {string} * @returns {string}
*/ */
export function plainToHtml(plain, findEmailAndLinksInText = false) export function plainToHtml(plain, findEmailAndLinksInText = false)
{ {
@ -971,8 +983,7 @@ export function plainToHtml(plain, findEmailAndLinksInText = false)
aNextText = [], aNextText = [],
sLine = '', sLine = '',
iIndex = 0, iIndex = 0,
aText = plain.split('\n') aText = plain.split('\n');
;
do do
{ {
@ -1031,8 +1042,7 @@ export function plainToHtml(plain, findEmailAndLinksInText = false)
.replace(/~~~blockquote~~~[\s]*/g, '<blockquote>') .replace(/~~~blockquote~~~[\s]*/g, '<blockquote>')
.replace(/[\s]*~~~\/blockquote~~~/g, '</blockquote>') .replace(/[\s]*~~~\/blockquote~~~/g, '</blockquote>')
.replace(/\u200C([\s\S]*)\u200C/g, '\u0002$1\u0002') .replace(/\u200C([\s\S]*)\u200C/g, '\u0002$1\u0002')
.replace(/\n/g, '<br />') .replace(/\n/g, '<br />');
;
return findEmailAndLinksInText ? findEmailAndLinks(plain) : plain; return findEmailAndLinksInText ? findEmailAndLinks(plain) : plain;
} }
@ -1051,7 +1061,7 @@ window.rainloop_Utils_plainToHtml = plainToHtml;
* @param {Function=} fRenameCallback * @param {Function=} fRenameCallback
* @param {boolean=} bSystem * @param {boolean=} bSystem
* @param {boolean=} bBuildUnvisible * @param {boolean=} bBuildUnvisible
* @return {Array} * @returns {Array}
*/ */
export function folderListOptionsBuilder(aSystem, aList, aDisabled, aHeaderLines, export function folderListOptionsBuilder(aSystem, aList, aDisabled, aHeaderLines,
iUnDeep, fDisableCallback, fVisibleCallback, fRenameCallback, bSystem, bBuildUnvisible) iUnDeep, fDisableCallback, fVisibleCallback, fRenameCallback, bSystem, bBuildUnvisible)
@ -1064,9 +1074,9 @@ export function folderListOptionsBuilder(aSystem, aList, aDisabled, aHeaderLines
bSep = false, bSep = false,
iIndex = 0, iIndex = 0,
iLen = 0, iLen = 0,
sDeepPrefix = '\u00A0\u00A0\u00A0', aResult = [];
aResult = []
; const sDeepPrefix = '\u00A0\u00A0\u00A0';
bBuildUnvisible = isUnd(bBuildUnvisible) ? false : !!bBuildUnvisible; bBuildUnvisible = isUnd(bBuildUnvisible) ? false : !!bBuildUnvisible;
bSystem = !isNormal(bSystem) ? 0 < aSystem.length : bSystem; bSystem = !isNormal(bSystem) ? 0 < aSystem.length : bSystem;
@ -1171,6 +1181,10 @@ export function folderListOptionsBuilder(aSystem, aList, aDisabled, aHeaderLines
return aResult; return aResult;
} }
/**
* @param {object} element
* @returns {void}
*/
export function selectElement(element) export function selectElement(element)
{ {
let sel, range; let sel, range;
@ -1215,26 +1229,26 @@ export function triggerAutocompleteInputChange(delay = false) {
} }
} }
let configurationScriptTagCache = {}; const configurationScriptTagCache = {};
/** /**
* @param {string} configuration * @param {string} configuration
* @return {object} * @returns {object}
*/ */
export function getConfigurationFromScriptTag(configuration) export function getConfigurationFromScriptTag(configuration)
{ {
let result = {};
if (!configurationScriptTagCache[configuration]) if (!configurationScriptTagCache[configuration])
{ {
configurationScriptTagCache[configuration] = $('script[type="application/json"][data-configuration="' + configuration + '"]'); configurationScriptTagCache[configuration] = $('script[type="application/json"][data-configuration="' + configuration + '"]');
} }
try { try
result = JSON.parse(configurationScriptTagCache[configuration].text()); {
} catch (e) {/* eslint-disable-line no-empty */} return JSON.parse(configurationScriptTagCache[configuration].text());
}
catch (e) {/* eslint-disable-line no-empty */}
return result; return {};
} }
/** /**
@ -1244,7 +1258,7 @@ export function getConfigurationFromScriptTag(configuration)
export function disposeOne(propOrValue, value) export function disposeOne(propOrValue, value)
{ {
const disposable = value || propOrValue; const disposable = value || propOrValue;
if (disposable && typeof disposable.dispose === 'function') if (disposable && 'function' === typeof disposable.dispose)
{ {
disposable.dispose(); disposable.dispose();
} }
@ -1268,6 +1282,7 @@ export function disposeObject(object)
/** /**
* @param {Object|Array} objectOrObjects * @param {Object|Array} objectOrObjects
* @returns {void}
*/ */
export function delegateRunOnDestroy(objectOrObjects) export function delegateRunOnDestroy(objectOrObjects)
{ {
@ -1286,6 +1301,11 @@ export function delegateRunOnDestroy(objectOrObjects)
} }
} }
/**
* @param {object} $styleTag
* @param {string} css
* @returns {boolean}
*/
export function appendStyles($styleTag, css) export function appendStyles($styleTag, css)
{ {
if ($styleTag && $styleTag[0]) if ($styleTag && $styleTag[0])
@ -1307,20 +1327,25 @@ export function appendStyles($styleTag, css)
let let
__themeTimer = 0, __themeTimer = 0,
__themeAjax = null __themeAjax = null;
;
/**
* @param {string} value
* @param {function} themeTrigger
* @returns {void}
*/
export function changeTheme(value, themeTrigger) export function changeTheme(value, themeTrigger)
{ {
let const
themeLink = $('#app-theme-link'), themeLink = $('#app-theme-link'),
themeStyle = $('#app-theme-style'),
url = themeLink.attr('href'),
clearTimer = () => { clearTimer = () => {
__themeTimer = window.setTimeout(() => themeTrigger(SaveSettingsStep.Idle), 1000); __themeTimer = window.setTimeout(() => themeTrigger(SaveSettingsStep.Idle), 1000);
__themeAjax = null; __themeAjax = null;
} };
;
let
themeStyle = $('#app-theme-style'),
url = themeLink.attr('href');
if (!url) if (!url)
{ {
@ -1375,6 +1400,9 @@ export function changeTheme(value, themeTrigger)
} }
} }
/**
* @returns {function}
*/
export function computedPagenatorHelper(koCurrentPage, koPageCount) export function computedPagenatorHelper(koCurrentPage, koPageCount)
{ {
return () => { return () => {
@ -1388,7 +1416,7 @@ export function computedPagenatorHelper(koCurrentPage, koPageCount)
const data = { const data = {
current: index === currentPage, current: index === currentPage,
name: '' === customName ? index.toString() : customName.toString(), name: '' === customName ? index.toString() : customName.toString(),
custom: '' === customName ? false : true, custom: '' !== customName,
title: '' === customName ? '' : index.toString(), title: '' === customName ? '' : index.toString(),
value: index.toString() value: index.toString()
}; };
@ -1401,14 +1429,12 @@ export function computedPagenatorHelper(koCurrentPage, koPageCount)
{ {
result.unshift(data); result.unshift(data);
} }
} };
;
let let
prev = 0, prev = 0,
next = 0, next = 0,
limit = 2 limit = 2;
;
if (1 < pageCount || (0 < pageCount && pageCount < currentPage)) if (1 < pageCount || (0 < pageCount && pageCount < currentPage))
{ {
@ -1438,13 +1464,13 @@ export function computedPagenatorHelper(koCurrentPage, koPageCount)
if (0 < prev) if (0 < prev)
{ {
fAdd(prev, false); fAdd(prev, false);
limit--; limit -= 1;
} }
if (pageCount >= next) if (pageCount >= next)
{ {
fAdd(next, true); fAdd(next, true);
limit--; limit -= 1;
} }
else if (0 >= prev) else if (0 >= prev)
{ {
@ -1488,7 +1514,7 @@ export function computedPagenatorHelper(koCurrentPage, koPageCount)
/** /**
* @param {string} fileName * @param {string} fileName
* @return {string} * @returns {string}
*/ */
export function getFileExtension(fileName) export function getFileExtension(fileName)
{ {
@ -1500,14 +1526,13 @@ export function getFileExtension(fileName)
/** /**
* @param {string} fileName * @param {string} fileName
* @return {string} * @returns {string}
*/ */
export function mimeContentType(fileName) export function mimeContentType(fileName)
{ {
let let
ext = '', ext = '',
result = 'application/octet-stream' result = 'application/octet-stream';
;
fileName = trim(fileName).toLowerCase(); fileName = trim(fileName).toLowerCase();
@ -1536,13 +1561,11 @@ export function resizeAndCrop(url, value, fCallback)
img.onload = function() { img.onload = function() {
let let
diff = [0, 0] diff = [0, 0];
;
const const
canvas = window.document.createElement('canvas'), canvas = window.document.createElement('canvas'),
ctx = canvas.getContext('2d') ctx = canvas.getContext('2d');
;
canvas.width = value; canvas.width = value;
canvas.height = value; canvas.height = value;
@ -1569,7 +1592,7 @@ export function resizeAndCrop(url, value, fCallback)
/** /**
* @param {string} mailToUrl * @param {string} mailToUrl
* @param {Function} PopupComposeVoreModel * @param {Function} PopupComposeVoreModel
* @return {boolean} * @returns {boolean}
*/ */
export function mailToHelper(mailToUrl, PopupComposeVoreModel) export function mailToHelper(mailToUrl, PopupComposeVoreModel)
{ {
@ -1586,22 +1609,22 @@ export function mailToHelper(mailToUrl, PopupComposeVoreModel)
to = [], to = [],
cc = null, cc = null,
bcc = null, bcc = null,
params = {}, params = {};
EmailModel = require('Model/Email'),
const
email = mailToUrl.replace(/\?.+$/, ''), email = mailToUrl.replace(/\?.+$/, ''),
queryString = mailToUrl.replace(/^[^\?]*\?/, ''), query = mailToUrl.replace(/^[^\?]*\?/, ''),
EmailModel = require('Model/Email'),
fParseEmailLine = (line) => { fParseEmailLine = (line) => {
return line ? _.compact(_.map(decodeURIComponent(line).split(/[,]/), (item) => { return line ? _.compact(_.map(decodeURIComponent(line).split(/[,]/), (item) => {
const emailObj = new EmailModel(); const emailObj = new EmailModel();
emailObj.mailsoParse(item); emailObj.mailsoParse(item);
return '' !== emailObj.email ? emailObj : null; return '' !== emailObj.email ? emailObj : null;
})) : null; })) : null;
} };
;
to = fParseEmailLine(email); to = fParseEmailLine(email);
params = simpleQueryParser(query);
params = simpleQueryParser(queryString);
if (!isUnd(params.cc)) if (!isUnd(params.cc))
{ {
@ -1638,16 +1661,19 @@ export const windowResize = _.debounce((timeout) => {
} }
}, 50); }, 50);
/**
* @returns {void}
*/
export function windowResizeCallback() export function windowResizeCallback()
{ {
windowResize(); windowResize();
} }
let substr = window.String.substr; let substr = window.String.substr;
if ('ab'.substr(-1) !== 'b') if ('b' !== 'ab'.substr(-1))
{ {
substr = (str, start, length) => { substr = (str, start, length) => {
start = start < 0 ? str.length + start : start; start = 0 > start ? str.length + start : start;
return str.substr(start, length); return str.substr(start, length);
}; };

View file

@ -6,6 +6,7 @@ import {AbstractComponent} from 'Component/Abstract';
class AbstracCheckbox extends AbstractComponent class AbstracCheckbox extends AbstractComponent
{ {
/** /**
* @constructor
* @param {Object} params = {} * @param {Object} params = {}
*/ */
constructor(params = {}) { constructor(params = {}) {

View file

@ -7,6 +7,7 @@ import {AbstractComponent} from 'Component/Abstract';
class AbstracRadio extends AbstractComponent class AbstracRadio extends AbstractComponent
{ {
/** /**
* @constructor
* @param {Object} params * @param {Object} params
*/ */
constructor(params) { constructor(params) {

View file

@ -22,7 +22,7 @@ class AbstractComponent
/** /**
* @param {*} ClassObject * @param {*} ClassObject
* @param {string} templateID = '' * @param {string} templateID = ''
* @return {Object} * @returns {Object}
*/ */
const componentExportHelper = (ClassObject, templateID = '') => { const componentExportHelper = (ClassObject, templateID = '') => {
return { return {

View file

@ -7,6 +7,7 @@ import {AbstractComponent} from 'Component/Abstract';
class AbstractInput extends AbstractComponent class AbstractInput extends AbstractComponent
{ {
/** /**
* @constructor
* @param {Object} params * @param {Object} params
*/ */
constructor(params) { constructor(params) {
@ -32,10 +33,9 @@ class AbstractInput extends AbstractComponent
var var
size = ko.unwrap(this.size), size = ko.unwrap(this.size),
suffixValue = this.trigger ? suffixValue = this.trigger ?
' ' + trim('settings-saved-trigger-input ' + this.classForTrigger()) : '' ' ' + trim('settings-saved-trigger-input ' + this.classForTrigger()) : '';
;
return (size > 0 ? 'span' + size : '') + suffixValue; return (0 < size ? 'span' + size : '') + suffixValue;
}, this); }, this);

View file

@ -7,6 +7,7 @@ import {AbstracCheckbox} from 'Component/AbstracCheckbox';
class CheckboxMaterialDesignComponent extends AbstracCheckbox class CheckboxMaterialDesignComponent extends AbstracCheckbox
{ {
/** /**
* @constructor
* @param {Object} params * @param {Object} params
*/ */
constructor(params) { constructor(params) {
@ -38,7 +39,8 @@ class CheckboxMaterialDesignComponent extends AbstracCheckbox
if (box) { if (box) {
this.animationBoxSetTrue(); this.animationBoxSetTrue();
_.delay(this.animationCheckmarkSetTrue, 200); _.delay(this.animationCheckmarkSetTrue, 200);
} else { }
else {
this.animationCheckmarkSetTrue(); this.animationCheckmarkSetTrue();
_.delay(this.animationBoxSetTrue, 200); _.delay(this.animationBoxSetTrue, 200);
} }

View file

@ -6,6 +6,7 @@ import {AbstractComponent, componentExportHelper} from 'Component/Abstract';
class SaveTriggerComponent extends AbstractComponent class SaveTriggerComponent extends AbstractComponent
{ {
/** /**
* @constructor
* @param {Object} params * @param {Object} params
*/ */
constructor(params) { constructor(params) {
@ -47,30 +48,26 @@ class SaveTriggerComponent extends AbstractComponent
this.element this.element
.find('.animated,.error').hide().removeClass('visible') .find('.animated,.error').hide().removeClass('visible')
.end() .end()
.find('.success').show().addClass('visible') .find('.success').show().addClass('visible');
;
break; break;
case SaveSettingsStep.FalseResult: case SaveSettingsStep.FalseResult:
this.element this.element
.find('.animated,.success').hide().removeClass('visible') .find('.animated,.success').hide().removeClass('visible')
.end() .end()
.find('.error').show().addClass('visible') .find('.error').show().addClass('visible');
;
break; break;
case SaveSettingsStep.Animate: case SaveSettingsStep.Animate:
this.element this.element
.find('.error,.success').hide().removeClass('visible') .find('.error,.success').hide().removeClass('visible')
.end() .end()
.find('.animated').show().addClass('visible') .find('.animated').show().addClass('visible');
;
break; break;
default:
case SaveSettingsStep.Idle: case SaveSettingsStep.Idle:
default:
this.element this.element
.find('.animated').hide() .find('.animated').hide()
.end() .end()
.find('.error,.success').removeClass('visible') .find('.error,.success').removeClass('visible');
;
break; break;
} }
} }

View file

@ -5,6 +5,7 @@ import {AbstractComponent, componentExportHelper} from 'Component/Abstract';
class ScriptComponent extends AbstractComponent class ScriptComponent extends AbstractComponent
{ {
/** /**
* @constructor
* @param {Object} params * @param {Object} params
*/ */
constructor(params) { constructor(params) {
@ -17,8 +18,7 @@ class ScriptComponent extends AbstractComponent
let script = params.element[0].outerHTML; let script = params.element[0].outerHTML;
script = !script ? '' : script script = !script ? '' : script
.replace(/<x-script/i, '<script') .replace(/<x-script/i, '<script')
.replace(/<b><\/b><\/x-script>/i, '</script>') .replace(/<b><\/b><\/x-script>/i, '</script>');
;
if (script) if (script)
{ {

View file

@ -7,6 +7,7 @@ import {AbstractInput} from 'Component/AbstractInput';
class SelectComponent extends AbstractInput class SelectComponent extends AbstractInput
{ {
/** /**
* @constructor
* @param {Object} params * @param {Object} params
*/ */
constructor(params) { constructor(params) {

View file

@ -1,9 +1,8 @@
import {$} from 'common'; import {$} from 'common';
let let cachedUrl = null;
cachedUrl = null, const getUrl = () => {
getUtl = () => {
if (!cachedUrl) if (!cachedUrl)
{ {
const version = $('#rlAppVersion').attr('content') || '0.0.0'; const version = $('#rlAppVersion').attr('content') || '0.0.0';
@ -11,18 +10,16 @@ let
} }
return cachedUrl; return cachedUrl;
} };
;
module.exports = { module.exports = {
template: '<b></b>', template: '<b></b>',
viewModel: { viewModel: {
createViewModel: (params, componentInfo) => { createViewModel: ({icon = 'null'}, componentInfo) => {
if (componentInfo && componentInfo.element) if (componentInfo && componentInfo.element)
{ {
const icon = params.icon || 'null';
$(componentInfo.element).replaceWith( $(componentInfo.element).replaceWith(
`<svg class="svg-icon svg-icon-${icon}"><use xlink:href="${getUtl()}#svg-icon-${icon}"></use></svg>` `<svg class="svg-icon svg-icon-${icon}"><use xlink:href="${getUrl()}#svg-icon-${icon}"></use></svg>`
); );
} }
} }

View file

@ -6,6 +6,7 @@ import {AbstractInput} from 'Component/AbstractInput';
class TextAreaComponent extends AbstractInput class TextAreaComponent extends AbstractInput
{ {
/** /**
* @constructor
* @param {Object} params * @param {Object} params
*/ */
constructor(params) { constructor(params) {

View file

@ -1,14 +1,9 @@
(function () { var
'use strict';
var
window = require('window'), window = require('window'),
Opentip = window.Opentip Opentip = window.Opentip;
;
Opentip.styles.rainloop = { Opentip.styles.rainloop = {
'extends': 'standard', 'extends': 'standard',
@ -33,19 +28,17 @@
'borderColor': '#999', 'borderColor': '#999',
'borderRadius': 2, 'borderRadius': 2,
'borderWidth': 1 'borderWidth': 1
}; };
Opentip.styles.rainloopTip = { Opentip.styles.rainloopTip = {
'extends': 'rainloop', 'extends': 'rainloop',
'delay': 0.4, 'delay': 0.4,
'group': 'rainloopTips' 'group': 'rainloopTips'
}; };
Opentip.styles.rainloopErrorTip = { Opentip.styles.rainloopErrorTip = {
'extends': 'rainloop', 'extends': 'rainloop',
'className': 'rainloopErrorTip' 'className': 'rainloopErrorTip'
}; };
module.exports = Opentip; module.exports = Opentip;
}());

573
dev/External/ko.js vendored

File diff suppressed because it is too large Load diff

View file

@ -4,25 +4,25 @@ import EmailModel from 'Model/Email';
class MessageHelper class MessageHelper
{ {
/**
* @constructor
*/
constructor() {} constructor() {}
/** /**
* @param {Array.<EmailModel>} emails * @param {Array.<EmailModel>} emails
* @param {boolean=} friendlyView = false * @param {boolean=} friendlyView = false
* @param {boolean=} wrapWithLink = false * @param {boolean=} wrapWithLink = false
* @return {string} * @returns {string}
*/ */
emailArrayToString(emails, friendlyView = false, wrapWithLink = false) { emailArrayToString(emails, friendlyView = false, wrapWithLink = false) {
let let index = 0, len = 0;
result = [], const result = [];
index = 0,
len = 0
;
if (isNonEmptyArray(emails)) if (isNonEmptyArray(emails))
{ {
for (index = 0, len = emails.length; index < len; index++) for (len = emails.length; index < len; index++)
{ {
result.push(emails[index].toLine(friendlyView, wrapWithLink)); result.push(emails[index].toLine(friendlyView, wrapWithLink));
} }
@ -33,19 +33,16 @@ class MessageHelper
/** /**
* @param {Array.<EmailModel>} emails * @param {Array.<EmailModel>} emails
* @return {string} * @returns {string}
*/ */
emailArrayToStringClear(emails) { emailArrayToStringClear(emails) {
let let index = 0, len = 0;
result = [], const result = [];
index = 0,
len = 0
;
if (isNonEmptyArray(emails)) if (isNonEmptyArray(emails))
{ {
for (index = 0, len = emails.length; index < len; index++) for (len = emails.length; index < len; index++)
{ {
if (emails[index] && emails[index].email && '' !== emails[index].name) if (emails[index] && emails[index].email && '' !== emails[index].name)
{ {
@ -59,16 +56,12 @@ class MessageHelper
/** /**
* @param {?Array} json * @param {?Array} json
* @return {Array.<EmailModel>} * @returns {Array.<EmailModel>}
*/ */
emailArrayFromJson(json) { emailArrayFromJson(json) {
let let index = 0, len = 0, email = null;
index = 0, const result = [];
len = 0,
email = null,
result = []
;
if (isNonEmptyArray(json)) if (isNonEmptyArray(json))
{ {

View file

@ -1,33 +1,28 @@
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
Utils = require('Common/Utils') Utils = require('Common/Utils');
;
/** /**
* @constructor * @constructor
* *
* @param {string} sModelName * @param {string} sModelName
*/ */
function AbstractModel(sModelName) function AbstractModel(sModelName)
{ {
this.sModelName = sModelName || ''; this.sModelName = sModelName || '';
this.disposables = []; this.disposables = [];
} }
/** /**
* @param {Array|Object} mInputValue * @param {Array|Object} mInputValue
*/ */
AbstractModel.prototype.regDisposables = function (mInputValue) AbstractModel.prototype.regDisposables = function(mInputValue)
{ {
if (Utils.isArray(mInputValue)) if (Utils.isArray(mInputValue))
{ {
_.each(mInputValue, function (mValue) { _.each(mInputValue, function(mValue) {
this.disposables.push(mValue); this.disposables.push(mValue);
}, this); }, this);
} }
@ -36,13 +31,11 @@
this.disposables.push(mInputValue); this.disposables.push(mInputValue);
} }
}; };
AbstractModel.prototype.onDestroy = function () AbstractModel.prototype.onDestroy = function()
{ {
Utils.disposeObject(this); Utils.disposeObject(this);
}; };
module.exports = AbstractModel; module.exports = AbstractModel;
}());

View file

@ -1,91 +1,83 @@
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
crossroads = require('crossroads'), crossroads = require('crossroads'),
Utils = require('Common/Utils') Utils = require('Common/Utils');
;
/** /**
* @param {string} sScreenName * @param {string} sScreenName
* @param {?=} aViewModels = [] * @param {?=} aViewModels = []
* @constructor * @constructor
*/ */
function AbstractScreen(sScreenName, aViewModels) function AbstractScreen(sScreenName, aViewModels)
{ {
this.sScreenName = sScreenName; this.sScreenName = sScreenName;
this.aViewModels = Utils.isArray(aViewModels) ? aViewModels : []; this.aViewModels = Utils.isArray(aViewModels) ? aViewModels : [];
} }
/** /**
* @type {Array} * @type {Array}
*/ */
AbstractScreen.prototype.oCross = null; AbstractScreen.prototype.oCross = null;
/** /**
* @type {string} * @type {string}
*/ */
AbstractScreen.prototype.sScreenName = ''; AbstractScreen.prototype.sScreenName = '';
/** /**
* @type {Array} * @type {Array}
*/ */
AbstractScreen.prototype.aViewModels = []; AbstractScreen.prototype.aViewModels = [];
/** /**
* @return {Array} * @returns {Array}
*/ */
AbstractScreen.prototype.viewModels = function () AbstractScreen.prototype.viewModels = function()
{ {
return this.aViewModels; return this.aViewModels;
}; };
/** /**
* @return {string} * @returns {string}
*/ */
AbstractScreen.prototype.screenName = function () AbstractScreen.prototype.screenName = function()
{ {
return this.sScreenName; return this.sScreenName;
}; };
AbstractScreen.prototype.routes = function () AbstractScreen.prototype.routes = function()
{ {
return null; return null;
}; };
/** /**
* @return {?Object} * @returns {?Object}
*/ */
AbstractScreen.prototype.__cross = function () AbstractScreen.prototype.__cross = function()
{ {
return this.oCross; return this.oCross;
}; };
AbstractScreen.prototype.__start = function () AbstractScreen.prototype.__start = function()
{ {
var var
aRoutes = this.routes(), aRoutes = this.routes(),
oRoute = null, oRoute = null,
fMatcher = null fMatcher = null;
;
if (Utils.isNonEmptyArray(aRoutes)) if (Utils.isNonEmptyArray(aRoutes))
{ {
fMatcher = _.bind(this.onRoute || Utils.noop, this); fMatcher = _.bind(this.onRoute || Utils.noop, this);
oRoute = crossroads.create(); oRoute = crossroads.create();
_.each(aRoutes, function (aItem) { _.each(aRoutes, function(aItem) {
oRoute.addRoute(aItem[0], fMatcher).rules = aItem[1]; oRoute.addRoute(aItem[0], fMatcher).rules = aItem[1];
}); });
this.oCross = oRoute; this.oCross = oRoute;
} }
}; };
module.exports = AbstractScreen; module.exports = AbstractScreen;
}());

View file

@ -1,23 +1,18 @@
(function () { var
'use strict';
var
ko = require('ko'), ko = require('ko'),
Enums = require('Common/Enums'), Enums = require('Common/Enums'),
Utils = require('Common/Utils'), Utils = require('Common/Utils'),
Globals = require('Common/Globals') Globals = require('Common/Globals');
;
/** /**
* @constructor * @constructor
* @param {string=} sPosition = '' * @param {string=} sPosition = ''
* @param {string=} sTemplate = '' * @param {string=} sTemplate = ''
*/ */
function AbstractView(sPosition, sTemplate) function AbstractView(sPosition, sTemplate)
{ {
this.bDisabeCloseOnEsc = false; this.bDisabeCloseOnEsc = false;
this.sPosition = Utils.pString(sPosition); this.sPosition = Utils.pString(sPosition);
this.sTemplate = Utils.pString(sTemplate); this.sTemplate = Utils.pString(sTemplate);
@ -31,83 +26,83 @@
this.viewModelName = ''; this.viewModelName = '';
this.viewModelNames = []; this.viewModelNames = [];
this.viewModelDom = null; this.viewModelDom = null;
} }
/** /**
* @type {boolean} * @type {boolean}
*/ */
AbstractView.prototype.bDisabeCloseOnEsc = false; AbstractView.prototype.bDisabeCloseOnEsc = false;
/** /**
* @type {string} * @type {string}
*/ */
AbstractView.prototype.sPosition = ''; AbstractView.prototype.sPosition = '';
/** /**
* @type {string} * @type {string}
*/ */
AbstractView.prototype.sTemplate = ''; AbstractView.prototype.sTemplate = '';
/** /**
* @type {string} * @type {string}
*/ */
AbstractView.prototype.sDefaultKeyScope = Enums.KeyState.None; AbstractView.prototype.sDefaultKeyScope = Enums.KeyState.None;
/** /**
* @type {string} * @type {string}
*/ */
AbstractView.prototype.sCurrentKeyScope = Enums.KeyState.None; AbstractView.prototype.sCurrentKeyScope = Enums.KeyState.None;
/** /**
* @type {string} * @type {string}
*/ */
AbstractView.prototype.viewModelName = ''; AbstractView.prototype.viewModelName = '';
/** /**
* @type {Array} * @type {Array}
*/ */
AbstractView.prototype.viewModelNames = []; AbstractView.prototype.viewModelNames = [];
/** /**
* @type {?} * @type {?}
*/ */
AbstractView.prototype.viewModelDom = null; AbstractView.prototype.viewModelDom = null;
/** /**
* @return {string} * @returns {string}
*/ */
AbstractView.prototype.viewModelTemplate = function () AbstractView.prototype.viewModelTemplate = function()
{ {
return this.sTemplate; return this.sTemplate;
}; };
/** /**
* @return {string} * @returns {string}
*/ */
AbstractView.prototype.viewModelPosition = function () AbstractView.prototype.viewModelPosition = function()
{ {
return this.sPosition; return this.sPosition;
}; };
AbstractView.prototype.cancelCommand = function () {}; AbstractView.prototype.cancelCommand = function() {};
AbstractView.prototype.closeCommand = function () {}; AbstractView.prototype.closeCommand = function() {};
AbstractView.prototype.storeAndSetKeyScope = function () AbstractView.prototype.storeAndSetKeyScope = function()
{ {
this.sCurrentKeyScope = Globals.keyScope(); this.sCurrentKeyScope = Globals.keyScope();
Globals.keyScope(this.sDefaultKeyScope); Globals.keyScope(this.sDefaultKeyScope);
}; };
AbstractView.prototype.restoreKeyScope = function () AbstractView.prototype.restoreKeyScope = function()
{ {
Globals.keyScope(this.sCurrentKeyScope); Globals.keyScope(this.sCurrentKeyScope);
}; };
AbstractView.prototype.registerPopupKeyDown = function () AbstractView.prototype.registerPopupKeyDown = function()
{ {
var self = this; var self = this;
Globals.$win.on('keydown', function (oEvent) { Globals.$win.on('keydown', function(oEvent) {
if (oEvent && self.modalVisibility && self.modalVisibility()) if (oEvent && self.modalVisibility && self.modalVisibility())
{ {
if (!this.bDisabeCloseOnEsc && Enums.EventKeyCode.Esc === oEvent.keyCode) if (!this.bDisabeCloseOnEsc && Enums.EventKeyCode.Esc === oEvent.keyCode)
@ -123,8 +118,6 @@
return true; return true;
}); });
}; };
module.exports = AbstractView; module.exports = AbstractView;
}());

View file

@ -1,9 +1,5 @@
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
$ = require('$'), $ = require('$'),
ko = require('ko'), ko = require('ko'),
@ -12,46 +8,45 @@
Globals = require('Common/Globals'), Globals = require('Common/Globals'),
Plugins = require('Common/Plugins'), Plugins = require('Common/Plugins'),
Utils = require('Common/Utils') Utils = require('Common/Utils');
;
/** /**
* @constructor * @constructor
*/ */
function Knoin() function Knoin()
{ {
this.oScreens = {}; this.oScreens = {};
this.sDefaultScreenName = ''; this.sDefaultScreenName = '';
this.oCurrentScreen = null; this.oCurrentScreen = null;
} }
Knoin.prototype.oScreens = {}; Knoin.prototype.oScreens = {};
Knoin.prototype.sDefaultScreenName = ''; Knoin.prototype.sDefaultScreenName = '';
Knoin.prototype.oCurrentScreen = null; Knoin.prototype.oCurrentScreen = null;
Knoin.prototype.hideLoading = function () Knoin.prototype.hideLoading = function()
{ {
$('#rl-content').addClass('rl-content-show'); $('#rl-content').addClass('rl-content-show');
$('#rl-loading').hide().remove(); $('#rl-loading').hide().remove();
}; };
/** /**
* @param {Object} context * @param {Object} context
*/ */
Knoin.prototype.constructorEnd = function (context) Knoin.prototype.constructorEnd = function(context)
{ {
if (Utils.isFunc(context.__constructor_end)) if (Utils.isFunc(context.__constructor_end))
{ {
context.__constructor_end.call(context); context.__constructor_end.call(context);
} }
}; };
/** /**
* @param {string|Array} mName * @param {string|Array} mName
* @param {Function} ViewModelClass * @param {Function} ViewModelClass
*/ */
Knoin.prototype.extendAsViewModel = function (mName, ViewModelClass) Knoin.prototype.extendAsViewModel = function(mName, ViewModelClass)
{ {
if (ViewModelClass) if (ViewModelClass)
{ {
if (Utils.isArray(mName)) if (Utils.isArray(mName))
@ -65,17 +60,17 @@
ViewModelClass.__name = ViewModelClass.__names[0]; ViewModelClass.__name = ViewModelClass.__names[0];
} }
}; };
/** /**
* @param {Function} SettingsViewModelClass * @param {Function} SettingsViewModelClass
* @param {string} sLabelName * @param {string} sLabelName
* @param {string} sTemplate * @param {string} sTemplate
* @param {string} sRoute * @param {string} sRoute
* @param {boolean=} bDefault * @param {boolean=} bDefault
*/ */
Knoin.prototype.addSettingsViewModel = function (SettingsViewModelClass, sTemplate, sLabelName, sRoute, bDefault) Knoin.prototype.addSettingsViewModel = function(SettingsViewModelClass, sTemplate, sLabelName, sRoute, bDefault)
{ {
SettingsViewModelClass.__rlSettingsData = { SettingsViewModelClass.__rlSettingsData = {
Label: sLabelName, Label: sLabelName,
Template: sTemplate, Template: sTemplate,
@ -84,58 +79,56 @@
}; };
Globals.aViewModels.settings.push(SettingsViewModelClass); Globals.aViewModels.settings.push(SettingsViewModelClass);
}; };
/** /**
* @param {Function} SettingsViewModelClass * @param {Function} SettingsViewModelClass
*/ */
Knoin.prototype.removeSettingsViewModel = function (SettingsViewModelClass) Knoin.prototype.removeSettingsViewModel = function(SettingsViewModelClass)
{ {
Globals.aViewModels['settings-removed'].push(SettingsViewModelClass); Globals.aViewModels['settings-removed'].push(SettingsViewModelClass);
}; };
/** /**
* @param {Function} SettingsViewModelClass * @param {Function} SettingsViewModelClass
*/ */
Knoin.prototype.disableSettingsViewModel = function (SettingsViewModelClass) Knoin.prototype.disableSettingsViewModel = function(SettingsViewModelClass)
{ {
Globals.aViewModels['settings-disabled'].push(SettingsViewModelClass); Globals.aViewModels['settings-disabled'].push(SettingsViewModelClass);
}; };
Knoin.prototype.routeOff = function () Knoin.prototype.routeOff = function()
{ {
hasher.changed.active = false; hasher.changed.active = false;
}; };
Knoin.prototype.routeOn = function () Knoin.prototype.routeOn = function()
{ {
hasher.changed.active = true; hasher.changed.active = true;
}; };
/** /**
* @param {string} sScreenName * @param {string} sScreenName
* @return {?Object} * @returns {?Object}
*/ */
Knoin.prototype.screen = function (sScreenName) Knoin.prototype.screen = function(sScreenName)
{ {
return ('' !== sScreenName && !Utils.isUnd(this.oScreens[sScreenName])) ? this.oScreens[sScreenName] : null; return ('' !== sScreenName && !Utils.isUnd(this.oScreens[sScreenName])) ? this.oScreens[sScreenName] : null;
}; };
/** /**
* @param {Function} ViewModelClass * @param {Function} ViewModelClass
* @param {Object=} oScreen * @param {Object=} oScreen
*/ */
Knoin.prototype.buildViewModel = function (ViewModelClass, oScreen) Knoin.prototype.buildViewModel = function(ViewModelClass, oScreen)
{ {
if (ViewModelClass && !ViewModelClass.__builded) if (ViewModelClass && !ViewModelClass.__builded)
{ {
var var
kn = this,
oViewModel = new ViewModelClass(oScreen), oViewModel = new ViewModelClass(oScreen),
sPosition = oViewModel.viewModelPosition(), sPosition = oViewModel.viewModelPosition(),
oViewModelPlace = $('#rl-content #rl-' + sPosition.toLowerCase()), oViewModelPlace = $('#rl-content #rl-' + sPosition.toLowerCase()),
oViewModelDom = null oViewModelDom = null;
;
ViewModelClass.__builded = true; ViewModelClass.__builded = true;
ViewModelClass.__vm = oViewModel; ViewModelClass.__vm = oViewModel;
@ -156,11 +149,11 @@
if ('Popups' === sPosition) if ('Popups' === sPosition)
{ {
oViewModel.cancelCommand = oViewModel.closeCommand = Utils.createCommand(oViewModel, function () { oViewModel.cancelCommand = oViewModel.closeCommand = Utils.createCommand(oViewModel, _.bind(function() {
kn.hideScreenPopup(ViewModelClass); this.hideScreenPopup(ViewModelClass);
}); }, this));
oViewModel.modalVisibility.subscribe(function (bValue) { oViewModel.modalVisibility.subscribe(function(bValue) {
var self = this; var self = this;
if (bValue) if (bValue)
@ -190,14 +183,14 @@
this.restoreKeyScope(); this.restoreKeyScope();
_.each(this.viewModelNames, function (sName) { _.each(this.viewModelNames, function(sName) {
Plugins.runHook('view-model-on-hide', [sName, self]); Plugins.runHook('view-model-on-hide', [sName, self]);
}); });
Globals.popupVisibilityNames.remove(this.viewModelName); Globals.popupVisibilityNames.remove(this.viewModelName);
oViewModel.viewModelDom.css('z-index', 2000); oViewModel.viewModelDom.css('z-index', 2000);
_.delay(function () { _.delay(function() {
self.viewModelDom.hide(); self.viewModelDom.hide();
}, 300); }, 300);
} }
@ -205,13 +198,17 @@
}, oViewModel); }, oViewModel);
} }
_.each(ViewModelClass.__names, function (sName) { _.each(ViewModelClass.__names, function(sName) {
Plugins.runHook('view-model-pre-build', [sName, oViewModel, oViewModelDom]); Plugins.runHook('view-model-pre-build', [sName, oViewModel, oViewModelDom]);
}); });
ko.applyBindingAccessorsToNode(oViewModelDom[0], { ko.applyBindingAccessorsToNode(oViewModelDom[0], {
'translatorInit': true, translatorInit: true,
'template': function () { return {'name': oViewModel.viewModelTemplate()};} template: function() {
return {
name: oViewModel.viewModelTemplate()
};
}
}, oViewModel); }, oViewModel);
Utils.delegateRun(oViewModel, 'onBuild', [oViewModelDom]); Utils.delegateRun(oViewModel, 'onBuild', [oViewModelDom]);
@ -220,7 +217,7 @@
oViewModel.registerPopupKeyDown(); oViewModel.registerPopupKeyDown();
} }
_.each(ViewModelClass.__names, function (sName) { _.each(ViewModelClass.__names, function(sName) {
Plugins.runHook('view-model-post-build', [sName, oViewModel, oViewModelDom]); Plugins.runHook('view-model-post-build', [sName, oViewModel, oViewModelDom]);
}); });
} }
@ -231,25 +228,25 @@
} }
return ViewModelClass ? ViewModelClass.__vm : null; return ViewModelClass ? ViewModelClass.__vm : null;
}; };
/** /**
* @param {Function} ViewModelClassToHide * @param {Function} ViewModelClassToHide
*/ */
Knoin.prototype.hideScreenPopup = function (ViewModelClassToHide) Knoin.prototype.hideScreenPopup = function(ViewModelClassToHide)
{ {
if (ViewModelClassToHide && ViewModelClassToHide.__vm && ViewModelClassToHide.__dom) if (ViewModelClassToHide && ViewModelClassToHide.__vm && ViewModelClassToHide.__dom)
{ {
ViewModelClassToHide.__vm.modalVisibility(false); ViewModelClassToHide.__vm.modalVisibility(false);
} }
}; };
/** /**
* @param {Function} ViewModelClassToShow * @param {Function} ViewModelClassToShow
* @param {Array=} aParameters * @param {Array=} aParameters
*/ */
Knoin.prototype.showScreenPopup = function (ViewModelClassToShow, aParameters) Knoin.prototype.showScreenPopup = function(ViewModelClassToShow, aParameters)
{ {
if (ViewModelClassToShow) if (ViewModelClassToShow)
{ {
this.buildViewModel(ViewModelClassToShow); this.buildViewModel(ViewModelClassToShow);
@ -262,34 +259,33 @@
Utils.delegateRun(ViewModelClassToShow.__vm, 'onShow', aParameters || []); Utils.delegateRun(ViewModelClassToShow.__vm, 'onShow', aParameters || []);
_.each(ViewModelClassToShow.__names, function (sName) { _.each(ViewModelClassToShow.__names, function(sName) {
Plugins.runHook('view-model-on-show', [sName, ViewModelClassToShow.__vm, aParameters || []]); Plugins.runHook('view-model-on-show', [sName, ViewModelClassToShow.__vm, aParameters || []]);
}); });
} }
} }
}; };
/** /**
* @param {Function} ViewModelClassToShow * @param {Function} ViewModelClassToShow
* @return {boolean} * @returns {boolean}
*/ */
Knoin.prototype.isPopupVisible = function (ViewModelClassToShow) Knoin.prototype.isPopupVisible = function(ViewModelClassToShow)
{ {
return ViewModelClassToShow && ViewModelClassToShow.__vm ? ViewModelClassToShow.__vm.modalVisibility() : false; return ViewModelClassToShow && ViewModelClassToShow.__vm ? ViewModelClassToShow.__vm.modalVisibility() : false;
}; };
/** /**
* @param {string} sScreenName * @param {string} sScreenName
* @param {string} sSubPart * @param {string} sSubPart
*/ */
Knoin.prototype.screenOnRoute = function (sScreenName, sSubPart) Knoin.prototype.screenOnRoute = function(sScreenName, sSubPart)
{ {
var var
self = this, self = this,
oScreen = null, oScreen = null,
bSameScreen = false, bSameScreen = false,
oCross = null oCross = null;
;
if ('' === Utils.pString(sScreenName)) if ('' === Utils.pString(sScreenName))
{ {
@ -319,7 +315,7 @@
if (Utils.isNonEmptyArray(oScreen.viewModels())) if (Utils.isNonEmptyArray(oScreen.viewModels()))
{ {
_.each(oScreen.viewModels(), function (ViewModelClass) { _.each(oScreen.viewModels(), function(ViewModelClass) {
this.buildViewModel(ViewModelClass, oScreen); this.buildViewModel(ViewModelClass, oScreen);
}, this); }, this);
} }
@ -327,7 +323,7 @@
Utils.delegateRun(oScreen, 'onBuild'); Utils.delegateRun(oScreen, 'onBuild');
} }
_.defer(function () { _.defer(function() {
// hide screen // hide screen
if (self.oCurrentScreen && !bSameScreen) if (self.oCurrentScreen && !bSameScreen)
@ -342,7 +338,7 @@
if (Utils.isNonEmptyArray(self.oCurrentScreen.viewModels())) if (Utils.isNonEmptyArray(self.oCurrentScreen.viewModels()))
{ {
_.each(self.oCurrentScreen.viewModels(), function (ViewModelClass) { _.each(self.oCurrentScreen.viewModels(), function(ViewModelClass) {
if (ViewModelClass.__vm && ViewModelClass.__dom && if (ViewModelClass.__vm && ViewModelClass.__dom &&
'Popups' !== ViewModelClass.__vm.viewModelPosition()) 'Popups' !== ViewModelClass.__vm.viewModelPosition())
@ -379,7 +375,7 @@
if (Utils.isNonEmptyArray(self.oCurrentScreen.viewModels())) if (Utils.isNonEmptyArray(self.oCurrentScreen.viewModels()))
{ {
_.each(self.oCurrentScreen.viewModels(), function (ViewModelClass) { _.each(self.oCurrentScreen.viewModels(), function(ViewModelClass) {
if (ViewModelClass.__vm && ViewModelClass.__dom && if (ViewModelClass.__vm && ViewModelClass.__dom &&
'Popups' !== ViewModelClass.__vm.viewModelPosition()) 'Popups' !== ViewModelClass.__vm.viewModelPosition())
@ -397,7 +393,7 @@
Utils.delegateRun(ViewModelClass.__vm, 'onShowWithDelay', [], 200); Utils.delegateRun(ViewModelClass.__vm, 'onShowWithDelay', [], 200);
_.each(ViewModelClass.__names, function (sName) { _.each(ViewModelClass.__names, function(sName) {
Plugins.runHook('view-model-on-show', [sName, ViewModelClass.__vm]); Plugins.runHook('view-model-on-show', [sName, ViewModelClass.__vm]);
}); });
} }
@ -415,25 +411,20 @@
}); });
} }
} }
}; };
/** /**
* @param {Array} aScreensClasses * @param {Array} aScreensClasses
*/ */
Knoin.prototype.startScreens = function (aScreensClasses) Knoin.prototype.startScreens = function(aScreensClasses)
{ {
// $('#rl-content').css({ _.each(aScreensClasses, function(CScreen) {
// 'visibility': 'hidden'
// });
_.each(aScreensClasses, function (CScreen) {
if (CScreen) if (CScreen)
{ {
var var
oScreen = new CScreen(), oScreen = new CScreen(),
sScreenName = oScreen ? oScreen.screenName() : '' sScreenName = oScreen ? oScreen.screenName() : '';
;
if (oScreen && '' !== sScreenName) if (oScreen && '' !== sScreenName)
{ {
@ -449,7 +440,7 @@
}, this); }, this);
_.each(this.oScreens, function (oScreen) { _.each(this.oScreens, function(oScreen) {
if (oScreen && !oScreen.__started && oScreen.__start) if (oScreen && !oScreen.__started && oScreen.__start)
{ {
oScreen.__started = true; oScreen.__started = true;
@ -468,26 +459,22 @@
hasher.changed.add(oCross.parse, oCross); hasher.changed.add(oCross.parse, oCross);
hasher.init(); hasher.init();
// $('#rl-content').css({ _.delay(function() {
// 'visibility': 'visible'
// });
_.delay(function () {
Globals.$html.removeClass('rl-started-trigger').addClass('rl-started'); Globals.$html.removeClass('rl-started-trigger').addClass('rl-started');
}, 100); }, 100);
_.delay(function () { _.delay(function() {
Globals.$html.addClass('rl-started-delay'); Globals.$html.addClass('rl-started-delay');
}, 200); }, 200);
}; };
/** /**
* @param {string} sHash * @param {string} sHash
* @param {boolean=} bSilence = false * @param {boolean=} bSilence = false
* @param {boolean=} bReplace = false * @param {boolean=} bReplace = false
*/ */
Knoin.prototype.setHash = function (sHash, bSilence, bReplace) Knoin.prototype.setHash = function(sHash, bSilence, bReplace)
{ {
sHash = '#' === sHash.substr(0, 1) ? sHash.substr(1) : sHash; sHash = '#' === sHash.substr(0, 1) ? sHash.substr(1) : sHash;
sHash = '/' === sHash.substr(0, 1) ? sHash.substr(1) : sHash; sHash = '/' === sHash.substr(0, 1) ? sHash.substr(1) : sHash;
@ -505,8 +492,6 @@
hasher[bReplace ? 'replaceHash' : 'setHash'](sHash); hasher[bReplace ? 'replaceHash' : 'setHash'](sHash);
hasher.setHash(sHash); hasher.setHash(sHash);
} }
}; };
module.exports = new Knoin(); module.exports = new Knoin();
}());

View file

@ -1,26 +1,21 @@
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
ko = require('ko'), ko = require('ko'),
Utils = require('Common/Utils'), Utils = require('Common/Utils'),
AbstractModel = require('Knoin/AbstractModel') AbstractModel = require('Knoin/AbstractModel');
;
/** /**
* @constructor * @constructor
* *
* @param {string} sEmail * @param {string} sEmail
* @param {boolean=} bCanBeDelete = true * @param {boolean=} bCanBeDelete = true
* @param {number=} iCount = 0 * @param {number=} iCount = 0
*/ */
function AccountModel(sEmail, bCanBeDelete, iCount) function AccountModel(sEmail, bCanBeDelete, iCount)
{ {
AbstractModel.call(this, 'AccountModel'); AbstractModel.call(this, 'AccountModel');
this.email = sEmail; this.email = sEmail;
@ -30,23 +25,21 @@
this.deleteAccess = ko.observable(false); this.deleteAccess = ko.observable(false);
this.canBeDeleted = ko.observable(Utils.isUnd(bCanBeDelete) ? true : !!bCanBeDelete); this.canBeDeleted = ko.observable(Utils.isUnd(bCanBeDelete) ? true : !!bCanBeDelete);
this.canBeEdit = this.canBeDeleted; this.canBeEdit = this.canBeDeleted;
} }
_.extend(AccountModel.prototype, AbstractModel.prototype); _.extend(AccountModel.prototype, AbstractModel.prototype);
/** /**
* @type {string} * @type {string}
*/ */
AccountModel.prototype.email = ''; AccountModel.prototype.email = '';
/** /**
* @return {string} * @returns {string}
*/ */
AccountModel.prototype.changeAccountLink = function () AccountModel.prototype.changeAccountLink = function()
{ {
return require('Common/Links').change(this.email); return require('Common/Links').change(this.email);
}; };
module.exports = AccountModel; module.exports = AccountModel;
}());

View file

@ -1,9 +1,5 @@
(function () { var
'use strict';
var
window = require('window'), window = require('window'),
_ = require('_'), _ = require('_'),
ko = require('ko'), ko = require('ko'),
@ -14,14 +10,13 @@
Links = require('Common/Links'), Links = require('Common/Links'),
Audio = require('Common/Audio'), Audio = require('Common/Audio'),
AbstractModel = require('Knoin/AbstractModel') AbstractModel = require('Knoin/AbstractModel');
;
/** /**
* @constructor * @constructor
*/ */
function AttachmentModel() function AttachmentModel()
{ {
AbstractModel.call(this, 'AttachmentModel'); AbstractModel.call(this, 'AttachmentModel');
this.checked = ko.observable(false); this.checked = ko.observable(false);
@ -43,44 +38,44 @@
this.uid = ''; this.uid = '';
this.mimeIndex = ''; this.mimeIndex = '';
this.framed = false; this.framed = false;
} }
_.extend(AttachmentModel.prototype, AbstractModel.prototype); _.extend(AttachmentModel.prototype, AbstractModel.prototype);
/** /**
* @static * @static
* @param {AjaxJsonAttachment} oJsonAttachment * @param {AjaxJsonAttachment} oJsonAttachment
* @return {?AttachmentModel} * @returns {?AttachmentModel}
*/ */
AttachmentModel.newInstanceFromJson = function (oJsonAttachment) AttachmentModel.newInstanceFromJson = function(oJsonAttachment)
{ {
var oAttachmentModel = new AttachmentModel(); var oAttachmentModel = new AttachmentModel();
return oAttachmentModel.initByJson(oJsonAttachment) ? oAttachmentModel : null; return oAttachmentModel.initByJson(oJsonAttachment) ? oAttachmentModel : null;
}; };
AttachmentModel.prototype.mimeType = ''; AttachmentModel.prototype.mimeType = '';
AttachmentModel.prototype.fileName = ''; AttachmentModel.prototype.fileName = '';
AttachmentModel.prototype.fileType = ''; AttachmentModel.prototype.fileType = '';
AttachmentModel.prototype.fileNameExt = ''; AttachmentModel.prototype.fileNameExt = '';
AttachmentModel.prototype.estimatedSize = 0; AttachmentModel.prototype.estimatedSize = 0;
AttachmentModel.prototype.friendlySize = ''; AttachmentModel.prototype.friendlySize = '';
AttachmentModel.prototype.isInline = false; AttachmentModel.prototype.isInline = false;
AttachmentModel.prototype.isLinked = false; AttachmentModel.prototype.isLinked = false;
AttachmentModel.prototype.isThumbnail = false; AttachmentModel.prototype.isThumbnail = false;
AttachmentModel.prototype.cid = ''; AttachmentModel.prototype.cid = '';
AttachmentModel.prototype.cidWithOutTags = ''; AttachmentModel.prototype.cidWithOutTags = '';
AttachmentModel.prototype.contentLocation = ''; AttachmentModel.prototype.contentLocation = '';
AttachmentModel.prototype.download = ''; AttachmentModel.prototype.download = '';
AttachmentModel.prototype.folder = ''; AttachmentModel.prototype.folder = '';
AttachmentModel.prototype.uid = ''; AttachmentModel.prototype.uid = '';
AttachmentModel.prototype.mimeIndex = ''; AttachmentModel.prototype.mimeIndex = '';
AttachmentModel.prototype.framed = false; AttachmentModel.prototype.framed = false;
/** /**
* @param {AjaxJsonAttachment} oJsonAttachment * @param {AjaxJsonAttachment} oJsonAttachment
*/ */
AttachmentModel.prototype.initByJson = function (oJsonAttachment) AttachmentModel.prototype.initByJson = function(oJsonAttachment)
{ {
var bResult = false; var bResult = false;
if (oJsonAttachment && 'Object/Attachment' === oJsonAttachment['@Object']) if (oJsonAttachment && 'Object/Attachment' === oJsonAttachment['@Object'])
{ {
@ -109,155 +104,153 @@
} }
return bResult; return bResult;
}; };
/** /**
* @return {boolean} * @returns {boolean}
*/ */
AttachmentModel.prototype.isImage = function () AttachmentModel.prototype.isImage = function()
{ {
return Enums.FileType.Image === this.fileType; return Enums.FileType.Image === this.fileType;
}; };
/** /**
* @return {boolean} * @returns {boolean}
*/ */
AttachmentModel.prototype.isMp3 = function () AttachmentModel.prototype.isMp3 = function()
{ {
return Enums.FileType.Audio === this.fileType && return Enums.FileType.Audio === this.fileType &&
'mp3' === this.fileNameExt; 'mp3' === this.fileNameExt;
}; };
/** /**
* @return {boolean} * @returns {boolean}
*/ */
AttachmentModel.prototype.isOgg = function () AttachmentModel.prototype.isOgg = function()
{ {
return Enums.FileType.Audio === this.fileType && return Enums.FileType.Audio === this.fileType &&
('oga' === this.fileNameExt || 'ogg' === this.fileNameExt); ('oga' === this.fileNameExt || 'ogg' === this.fileNameExt);
}; };
/** /**
* @return {boolean} * @returns {boolean}
*/ */
AttachmentModel.prototype.isWav = function () AttachmentModel.prototype.isWav = function()
{ {
return Enums.FileType.Audio === this.fileType && return Enums.FileType.Audio === this.fileType &&
'wav' === this.fileNameExt; 'wav' === this.fileNameExt;
}; };
/** /**
* @return {boolean} * @returns {boolean}
*/ */
AttachmentModel.prototype.hasThumbnail = function () AttachmentModel.prototype.hasThumbnail = function()
{ {
return this.isThumbnail; return this.isThumbnail;
}; };
/** /**
* @return {boolean} * @returns {boolean}
*/ */
AttachmentModel.prototype.isText = function () AttachmentModel.prototype.isText = function()
{ {
return Enums.FileType.Text === this.fileType || return Enums.FileType.Text === this.fileType ||
Enums.FileType.Eml === this.fileType || Enums.FileType.Eml === this.fileType ||
Enums.FileType.Certificate === this.fileType || Enums.FileType.Certificate === this.fileType ||
Enums.FileType.Html === this.fileType || Enums.FileType.Html === this.fileType ||
Enums.FileType.Code === this.fileType Enums.FileType.Code === this.fileType;
; };
};
/** /**
* @return {boolean} * @returns {boolean}
*/ */
AttachmentModel.prototype.isPdf = function () AttachmentModel.prototype.isPdf = function()
{ {
return Enums.FileType.Pdf === this.fileType; return Enums.FileType.Pdf === this.fileType;
}; };
/** /**
* @return {boolean} * @returns {boolean}
*/ */
AttachmentModel.prototype.isFramed = function () AttachmentModel.prototype.isFramed = function()
{ {
return this.framed && (Globals.data.__APP__ && Globals.data.__APP__.googlePreviewSupported()) && return this.framed && (Globals.data.__APP__ && Globals.data.__APP__.googlePreviewSupported()) &&
!(this.isPdf() && Globals.bAllowPdfPreview) && !this.isText() && !this.isImage(); !(this.isPdf() && Globals.bAllowPdfPreview) && !this.isText() && !this.isImage();
}; };
/** /**
* @return {boolean} * @returns {boolean}
*/ */
AttachmentModel.prototype.hasPreview = function () AttachmentModel.prototype.hasPreview = function()
{ {
return this.isImage() || (this.isPdf() && Globals.bAllowPdfPreview) || return this.isImage() || (this.isPdf() && Globals.bAllowPdfPreview) ||
this.isText() || this.isFramed(); this.isText() || this.isFramed();
}; };
/** /**
* @return {boolean} * @returns {boolean}
*/ */
AttachmentModel.prototype.hasPreplay = function () AttachmentModel.prototype.hasPreplay = function()
{ {
return (Audio.supportedMp3 && this.isMp3()) || return (Audio.supportedMp3 && this.isMp3()) ||
(Audio.supportedOgg && this.isOgg()) || (Audio.supportedOgg && this.isOgg()) ||
(Audio.supportedWav && this.isWav()) (Audio.supportedWav && this.isWav());
; };
};
/** /**
* @return {string} * @returns {string}
*/ */
AttachmentModel.prototype.linkDownload = function () AttachmentModel.prototype.linkDownload = function()
{ {
return Links.attachmentDownload(this.download); return Links.attachmentDownload(this.download);
}; };
/** /**
* @return {string} * @returns {string}
*/ */
AttachmentModel.prototype.linkPreview = function () AttachmentModel.prototype.linkPreview = function()
{ {
return Links.attachmentPreview(this.download); return Links.attachmentPreview(this.download);
}; };
/** /**
* @return {string} * @returns {string}
*/ */
AttachmentModel.prototype.linkThumbnail = function () AttachmentModel.prototype.linkThumbnail = function()
{ {
return this.hasThumbnail() ? Links.attachmentThumbnailPreview(this.download) : ''; return this.hasThumbnail() ? Links.attachmentThumbnailPreview(this.download) : '';
}; };
/** /**
* @return {string} * @returns {string}
*/ */
AttachmentModel.prototype.linkThumbnailPreviewStyle = function () AttachmentModel.prototype.linkThumbnailPreviewStyle = function()
{ {
var sLink = this.linkThumbnail(); var sLink = this.linkThumbnail();
return '' === sLink ? '' : 'background:url(' + sLink + ')'; return '' === sLink ? '' : 'background:url(' + sLink + ')';
}; };
/** /**
* @return {string} * @returns {string}
*/ */
AttachmentModel.prototype.linkFramed = function () AttachmentModel.prototype.linkFramed = function()
{ {
return Links.attachmentFramed(this.download); return Links.attachmentFramed(this.download);
}; };
/** /**
* @return {string} * @returns {string}
*/ */
AttachmentModel.prototype.linkPreviewAsPlain = function () AttachmentModel.prototype.linkPreviewAsPlain = function()
{ {
return Links.attachmentPreviewAsPlain(this.download); return Links.attachmentPreviewAsPlain(this.download);
}; };
/** /**
* @return {string} * @returns {string}
*/ */
AttachmentModel.prototype.linkPreviewMain = function () AttachmentModel.prototype.linkPreviewMain = function()
{ {
var sResult = ''; var sResult = '';
switch (true) switch (true)
{ {
@ -271,16 +264,17 @@
case this.isFramed(): case this.isFramed():
sResult = this.linkFramed(); sResult = this.linkFramed();
break; break;
// no default
} }
return sResult; return sResult;
}; };
/** /**
* @return {string} * @returns {string}
*/ */
AttachmentModel.prototype.generateTransferDownloadUrl = function () AttachmentModel.prototype.generateTransferDownloadUrl = function()
{ {
var sLink = this.linkDownload(); var sLink = this.linkDownload();
if ('http' !== sLink.substr(0, 4)) if ('http' !== sLink.substr(0, 4))
{ {
@ -288,15 +282,15 @@
} }
return this.mimeType + ':' + this.fileName + ':' + sLink; return this.mimeType + ':' + this.fileName + ':' + sLink;
}; };
/** /**
* @param {AttachmentModel} oAttachment * @param {AttachmentModel} oAttachment
* @param {*} oEvent * @param {*} oEvent
* @return {boolean} * @returns {boolean}
*/ */
AttachmentModel.prototype.eventDragStart = function (oAttachment, oEvent) AttachmentModel.prototype.eventDragStart = function(oAttachment, oEvent)
{ {
var oLocalEvent = oEvent.originalEvent || oEvent; var oLocalEvent = oEvent.originalEvent || oEvent;
if (oAttachment && oLocalEvent && oLocalEvent.dataTransfer && oLocalEvent.dataTransfer.setData) if (oAttachment && oLocalEvent && oLocalEvent.dataTransfer && oLocalEvent.dataTransfer.setData)
{ {
@ -304,22 +298,21 @@
} }
return true; return true;
}; };
/** /**
* @param {string} sExt * @param {string} sExt
* @param {string} sMimeType * @param {string} sMimeType
* @return {string} * @returns {string}
*/ */
AttachmentModel.staticFileType = _.memoize(function (sExt, sMimeType) AttachmentModel.staticFileType = _.memoize(function(sExt, sMimeType)
{ {
sExt = Utils.trim(sExt).toLowerCase(); sExt = Utils.trim(sExt).toLowerCase();
sMimeType = Utils.trim(sMimeType).toLowerCase(); sMimeType = Utils.trim(sMimeType).toLowerCase();
var var
sResult = Enums.FileType.Unknown, sResult = Enums.FileType.Unknown,
aMimeTypeParts = sMimeType.split('/') aMimeTypeParts = sMimeType.split('/');
;
switch (true) switch (true)
{ {
@ -413,21 +406,21 @@
]): ]):
sResult = Enums.FileType.Presentation; sResult = Enums.FileType.Presentation;
break; break;
// no default
} }
return sResult; return sResult;
}); });
/** /**
* @param {string} sFileType * @param {string} sFileType
* @return {string} * @returns {string}
*/ */
AttachmentModel.staticIconClass = _.memoize(function (sFileType) AttachmentModel.staticIconClass = _.memoize(function(sFileType)
{ {
var var
sText = '', sText = '',
sClass = 'icon-file' sClass = 'icon-file';
;
switch (sFileType) switch (sFileType)
{ {
@ -466,27 +459,27 @@
sText = 'pdf'; sText = 'pdf';
sClass = 'icon-none'; sClass = 'icon-none';
break; break;
// no default
} }
return [sClass, sText]; return [sClass, sText];
}); });
/** /**
* @param {string} sFileType * @param {string} sFileType
* @return {string} * @returns {string}
*/ */
AttachmentModel.staticCombinedIconClass = function (aData) AttachmentModel.staticCombinedIconClass = function(aData)
{ {
var var
sClass = '', sClass = '',
aTypes = [] aTypes = [];
;
if (Utils.isNonEmptyArray(aData)) if (Utils.isNonEmptyArray(aData))
{ {
sClass = 'icon-attachment'; sClass = 'icon-attachment';
aTypes = _.uniq(_.compact(_.map(aData, function (aItem) { aTypes = _.uniq(_.compact(_.map(aData, function(aItem) {
return aItem ? AttachmentModel.staticFileType( return aItem ? AttachmentModel.staticFileType(
Utils.getFileExtension(aItem[0]), aItem[1]) : ''; Utils.getFileExtension(aItem[0]), aItem[1]) : '';
}))); })));
@ -525,29 +518,28 @@
case Enums.FileType.Presentation: case Enums.FileType.Presentation:
sClass = 'icon-file-chart-graph'; sClass = 'icon-file-chart-graph';
break; break;
// no default
} }
} }
} }
return sClass; return sClass;
}; };
/** /**
* @return {string} * @returns {string}
*/ */
AttachmentModel.prototype.iconClass = function () AttachmentModel.prototype.iconClass = function()
{ {
return AttachmentModel.staticIconClass(this.fileType)[0]; return AttachmentModel.staticIconClass(this.fileType)[0];
}; };
/** /**
* @return {string} * @returns {string}
*/ */
AttachmentModel.prototype.iconText = function () AttachmentModel.prototype.iconText = function()
{ {
return AttachmentModel.staticIconClass(this.fileType)[1]; return AttachmentModel.staticIconClass(this.fileType)[1];
}; };
module.exports = AttachmentModel; module.exports = AttachmentModel;
}());

View file

@ -1,9 +1,5 @@
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
ko = require('ko'), ko = require('ko'),
@ -11,10 +7,9 @@
AttachmentModel = require('Model/Attachment'), AttachmentModel = require('Model/Attachment'),
AbstractModel = require('Knoin/AbstractModel') AbstractModel = require('Knoin/AbstractModel');
;
/** /**
* @constructor * @constructor
* @param {string} sId * @param {string} sId
* @param {string} sFileName * @param {string} sFileName
@ -24,8 +19,8 @@
* @param {string=} sCID * @param {string=} sCID
* @param {string=} sContentLocation * @param {string=} sContentLocation
*/ */
function ComposeAttachmentModel(sId, sFileName, nSize, bInline, bLinked, sCID, sContentLocation) function ComposeAttachmentModel(sId, sFileName, nSize, bInline, bLinked, sCID, sContentLocation)
{ {
AbstractModel.call(this, 'ComposeAttachmentModel'); AbstractModel.call(this, 'ComposeAttachmentModel');
this.id = sId; this.id = sId;
@ -46,53 +41,53 @@
this.enabled = ko.observable(true); this.enabled = ko.observable(true);
this.complete = ko.observable(false); this.complete = ko.observable(false);
this.progressText = ko.computed(function () { this.progressText = ko.computed(function() {
var iP = this.progress(); var iP = this.progress();
return 0 === iP ? '' : '' + (98 < iP ? 100 : iP) + '%'; return 0 === iP ? '' : '' + (98 < iP ? 100 : iP) + '%';
}, this); }, this);
this.progressStyle = ko.computed(function () { this.progressStyle = ko.computed(function() {
var iP = this.progress(); var iP = this.progress();
return 0 === iP ? '' : 'width:' + (98 < iP ? 100 : iP) + '%'; return 0 === iP ? '' : 'width:' + (98 < iP ? 100 : iP) + '%';
}, this); }, this);
this.title = ko.computed(function () { this.title = ko.computed(function() {
var sError = this.error(); var sError = this.error();
return '' !== sError ? sError : this.fileName(); return '' !== sError ? sError : this.fileName();
}, this); }, this);
this.friendlySize = ko.computed(function () { this.friendlySize = ko.computed(function() {
var mSize = this.size(); var mSize = this.size();
return null === mSize ? '' : Utils.friendlySize(this.size()); return null === mSize ? '' : Utils.friendlySize(this.size());
}, this); }, this);
this.mimeType = ko.computed(function () { this.mimeType = ko.computed(function() {
return Utils.mimeContentType(this.fileName()); return Utils.mimeContentType(this.fileName());
}, this); }, this);
this.fileExt = ko.computed(function () { this.fileExt = ko.computed(function() {
return Utils.getFileExtension(this.fileName()); return Utils.getFileExtension(this.fileName());
}, this); }, this);
this.regDisposables([this.progressText, this.progressStyle, this.title, this.friendlySize, this.mimeType, this.fileExt]); this.regDisposables([this.progressText, this.progressStyle, this.title, this.friendlySize, this.mimeType, this.fileExt]);
} }
_.extend(ComposeAttachmentModel.prototype, AbstractModel.prototype); _.extend(ComposeAttachmentModel.prototype, AbstractModel.prototype);
ComposeAttachmentModel.prototype.id = ''; ComposeAttachmentModel.prototype.id = '';
ComposeAttachmentModel.prototype.isInline = false; ComposeAttachmentModel.prototype.isInline = false;
ComposeAttachmentModel.prototype.isLinked = false; ComposeAttachmentModel.prototype.isLinked = false;
ComposeAttachmentModel.prototype.CID = ''; ComposeAttachmentModel.prototype.CID = '';
ComposeAttachmentModel.prototype.contentLocation = ''; ComposeAttachmentModel.prototype.contentLocation = '';
ComposeAttachmentModel.prototype.fromMessage = false; ComposeAttachmentModel.prototype.fromMessage = false;
ComposeAttachmentModel.prototype.cancel = Utils.noop; ComposeAttachmentModel.prototype.cancel = Utils.noop;
/** /**
* @param {AjaxJsonComposeAttachment} oJsonAttachment * @param {AjaxJsonComposeAttachment} oJsonAttachment
* @return {boolean} * @returns {boolean}
*/ */
ComposeAttachmentModel.prototype.initByUploadJson = function (oJsonAttachment) ComposeAttachmentModel.prototype.initByUploadJson = function(oJsonAttachment)
{ {
var bResult = false; var bResult = false;
if (oJsonAttachment) if (oJsonAttachment)
{ {
@ -105,26 +100,24 @@
} }
return bResult; return bResult;
}; };
/** /**
* @return {string} * @returns {string}
*/ */
ComposeAttachmentModel.prototype.iconClass = function () ComposeAttachmentModel.prototype.iconClass = function()
{ {
return AttachmentModel.staticIconClass( return AttachmentModel.staticIconClass(
AttachmentModel.staticFileType(this.fileExt(), this.mimeType()))[0]; AttachmentModel.staticFileType(this.fileExt(), this.mimeType()))[0];
}; };
/** /**
* @return {string} * @returns {string}
*/ */
ComposeAttachmentModel.prototype.iconText = function () ComposeAttachmentModel.prototype.iconText = function()
{ {
return AttachmentModel.staticIconClass( return AttachmentModel.staticIconClass(
AttachmentModel.staticFileType(this.fileExt(), this.mimeType()))[1]; AttachmentModel.staticFileType(this.fileExt(), this.mimeType()))[1];
}; };
module.exports = ComposeAttachmentModel; module.exports = ComposeAttachmentModel;
}());

View file

@ -1,9 +1,5 @@
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
ko = require('ko'), ko = require('ko'),
@ -11,14 +7,13 @@
Utils = require('Common/Utils'), Utils = require('Common/Utils'),
Links = require('Common/Links'), Links = require('Common/Links'),
AbstractModel = require('Knoin/AbstractModel') AbstractModel = require('Knoin/AbstractModel');
;
/** /**
* @constructor * @constructor
*/ */
function ContactModel() function ContactModel()
{ {
AbstractModel.call(this, 'ContactModel'); AbstractModel.call(this, 'ContactModel');
this.idContact = 0; this.idContact = 0;
@ -30,23 +25,22 @@
this.selected = ko.observable(false); this.selected = ko.observable(false);
this.checked = ko.observable(false); this.checked = ko.observable(false);
this.deleted = ko.observable(false); this.deleted = ko.observable(false);
} }
_.extend(ContactModel.prototype, AbstractModel.prototype); _.extend(ContactModel.prototype, AbstractModel.prototype);
/** /**
* @return {Array|null} * @returns {Array|null}
*/ */
ContactModel.prototype.getNameAndEmailHelper = function () ContactModel.prototype.getNameAndEmailHelper = function()
{ {
var var
sName = '', sName = '',
sEmail = '' sEmail = '';
;
if (Utils.isNonEmptyArray(this.properties)) if (Utils.isNonEmptyArray(this.properties))
{ {
_.each(this.properties, function (aProperty) { _.each(this.properties, function(aProperty) {
if (aProperty) if (aProperty)
{ {
if (Enums.ContactPropertyType.FirstName === aProperty[0]) if (Enums.ContactPropertyType.FirstName === aProperty[0])
@ -66,10 +60,10 @@
} }
return '' === sEmail ? null : [sEmail, sName]; return '' === sEmail ? null : [sEmail, sName];
}; };
ContactModel.prototype.parse = function (oItem) ContactModel.prototype.parse = function(oItem)
{ {
var bResult = false; var bResult = false;
if (oItem && 'Object/Contact' === oItem['@Object']) if (oItem && 'Object/Contact' === oItem['@Object'])
{ {
@ -79,7 +73,7 @@
if (Utils.isNonEmptyArray(oItem.Properties)) if (Utils.isNonEmptyArray(oItem.Properties))
{ {
_.each(oItem.Properties, function (oProperty) { _.each(oItem.Properties, function(oProperty) {
if (oProperty && oProperty.Type && Utils.isNormal(oProperty.Value) && Utils.isNormal(oProperty.TypeStr)) if (oProperty && oProperty.Type && Utils.isNormal(oProperty.Value) && Utils.isNormal(oProperty.TypeStr))
{ {
this.properties.push([Utils.pInt(oProperty.Type), Utils.pString(oProperty.Value), Utils.pString(oProperty.TypeStr)]); this.properties.push([Utils.pInt(oProperty.Type), Utils.pString(oProperty.Value), Utils.pString(oProperty.TypeStr)]);
@ -91,29 +85,29 @@
} }
return bResult; return bResult;
}; };
/** /**
* @return {string} * @returns {string}
*/ */
ContactModel.prototype.srcAttr = function () ContactModel.prototype.srcAttr = function()
{ {
return Links.emptyContactPic(); return Links.emptyContactPic();
}; };
/** /**
* @return {string} * @returns {string}
*/ */
ContactModel.prototype.generateUid = function () ContactModel.prototype.generateUid = function()
{ {
return '' + this.idContact; return '' + this.idContact;
}; };
/** /**
* @return string * @return string
*/ */
ContactModel.prototype.lineAsCss = function () ContactModel.prototype.lineAsCss = function()
{ {
var aResult = []; var aResult = [];
if (this.deleted()) if (this.deleted())
{ {
@ -133,8 +127,6 @@
} }
return aResult.join(' '); return aResult.join(' ');
}; };
module.exports = ContactModel; module.exports = ContactModel;
}());

View file

@ -1,9 +1,5 @@
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
ko = require('ko'), ko = require('ko'),
@ -11,10 +7,9 @@
Utils = require('Common/Utils'), Utils = require('Common/Utils'),
Translator = require('Common/Translator'), Translator = require('Common/Translator'),
AbstractModel = require('Knoin/AbstractModel') AbstractModel = require('Knoin/AbstractModel');
;
/** /**
* @constructor * @constructor
* @param {number=} iType = Enums.ContactPropertyType.Unknown * @param {number=} iType = Enums.ContactPropertyType.Unknown
* @param {string=} sTypeStr = '' * @param {string=} sTypeStr = ''
@ -22,8 +17,8 @@
* @param {boolean=} bFocused = false * @param {boolean=} bFocused = false
* @param {string=} sPlaceholder = '' * @param {string=} sPlaceholder = ''
*/ */
function ContactPropertyModel(iType, sTypeStr, sValue, bFocused, sPlaceholder) function ContactPropertyModel(iType, sTypeStr, sValue, bFocused, sPlaceholder)
{ {
AbstractModel.call(this, 'ContactPropertyModel'); AbstractModel.call(this, 'ContactPropertyModel');
this.type = ko.observable(Utils.isUnd(iType) ? Enums.ContactPropertyType.Unknown : iType); this.type = ko.observable(Utils.isUnd(iType) ? Enums.ContactPropertyType.Unknown : iType);
@ -33,20 +28,18 @@
this.placeholder = ko.observable(sPlaceholder || ''); this.placeholder = ko.observable(sPlaceholder || '');
this.placeholderValue = ko.computed(function () { this.placeholderValue = ko.computed(function() {
var value = this.placeholder(); var value = this.placeholder();
return value ? Translator.i18n(value) : ''; return value ? Translator.i18n(value) : '';
}, this); }, this);
this.largeValue = ko.computed(function () { this.largeValue = ko.computed(function() {
return Enums.ContactPropertyType.Note === this.type(); return Enums.ContactPropertyType.Note === this.type();
}, this); }, this);
this.regDisposables([this.placeholderValue, this.largeValue]); this.regDisposables([this.placeholderValue, this.largeValue]);
} }
_.extend(ContactPropertyModel.prototype, AbstractModel.prototype); _.extend(ContactPropertyModel.prototype, AbstractModel.prototype);
module.exports = ContactPropertyModel; module.exports = ContactPropertyModel;
}());

View file

@ -1,49 +1,42 @@
(function () { var Utils = require('Common/Utils');
'use strict'; /**
* @constructor
var
Utils = require('Common/Utils')
;
/**
* @param {string=} sEmail * @param {string=} sEmail
* @param {string=} sName * @param {string=} sName
* @param {string=} sDkimStatus * @param {string=} sDkimStatus
* @param {string=} sDkimValue * @param {string=} sDkimValue
*
* @constructor
*/ */
function EmailModel(sEmail, sName, sDkimStatus, sDkimValue) function EmailModel(sEmail, sName, sDkimStatus, sDkimValue)
{ {
this.email = sEmail || ''; this.email = sEmail || '';
this.name = sName || ''; this.name = sName || '';
this.dkimStatus = sDkimStatus || 'none'; this.dkimStatus = sDkimStatus || 'none';
this.dkimValue = sDkimValue || ''; this.dkimValue = sDkimValue || '';
this.clearDuplicateName(); this.clearDuplicateName();
} }
/** /**
* @static * @static
* @param {AjaxJsonEmail} oJsonEmail * @param {AjaxJsonEmail} oJsonEmail
* @return {?EmailModel} * @returns {?EmailModel}
*/ */
EmailModel.newInstanceFromJson = function (oJsonEmail) EmailModel.newInstanceFromJson = function(oJsonEmail)
{ {
var oEmailModel = new EmailModel(); var oEmailModel = new EmailModel();
return oEmailModel.initByJson(oJsonEmail) ? oEmailModel : null; return oEmailModel.initByJson(oJsonEmail) ? oEmailModel : null;
}; };
/** /**
* @static * @static
* @param {string} sLine * @param {string} sLine
* @param {string=} sDelimiter = ';' * @param {string=} sDelimiter = ';'
* @return {Array} * @returns {Array}
*/ */
EmailModel.splitHelper = function (sLine, sDelimiter) EmailModel.splitHelper = function(sLine, sDelimiter)
{ {
sDelimiter = sDelimiter || ';'; sDelimiter = sDelimiter || ';';
sLine = sLine.replace(/[\r\n]+/g, '; ').replace(/[\s]+/g, ' '); sLine = sLine.replace(/[\r\n]+/g, '; ').replace(/[\s]+/g, ' ');
@ -53,8 +46,7 @@
iLen = sLine.length, iLen = sLine.length,
bAt = false, bAt = false,
sChar = '', sChar = '',
sResult = '' sResult = '';
;
for (; iIndex < iLen; iIndex++) for (; iIndex < iLen; iIndex++)
{ {
@ -71,90 +63,90 @@
sResult += sDelimiter; sResult += sDelimiter;
} }
break; break;
// no default
} }
sResult += sChar; sResult += sChar;
} }
return sResult.split(sDelimiter); return sResult.split(sDelimiter);
}; };
/** /**
* @type {string} * @type {string}
*/ */
EmailModel.prototype.name = ''; EmailModel.prototype.name = '';
/** /**
* @type {string} * @type {string}
*/ */
EmailModel.prototype.email = ''; EmailModel.prototype.email = '';
/** /**
* @type {string} * @type {string}
*/ */
EmailModel.prototype.dkimStatus = 'none'; EmailModel.prototype.dkimStatus = 'none';
/** /**
* @type {string} * @type {string}
*/ */
EmailModel.prototype.dkimValue = ''; EmailModel.prototype.dkimValue = '';
EmailModel.prototype.clear = function () EmailModel.prototype.clear = function()
{ {
this.email = ''; this.email = '';
this.name = ''; this.name = '';
this.dkimStatus = 'none'; this.dkimStatus = 'none';
this.dkimValue = ''; this.dkimValue = '';
}; };
/** /**
* @return {boolean} * @returns {boolean}
*/ */
EmailModel.prototype.validate = function () EmailModel.prototype.validate = function()
{ {
return '' !== this.name || '' !== this.email; return '' !== this.name || '' !== this.email;
}; };
/** /**
* @param {boolean} bWithoutName = false * @param {boolean} bWithoutName = false
* @return {string} * @returns {string}
*/ */
EmailModel.prototype.hash = function (bWithoutName) EmailModel.prototype.hash = function(bWithoutName)
{ {
return '#' + (bWithoutName ? '' : this.name) + '#' + this.email + '#'; return '#' + (bWithoutName ? '' : this.name) + '#' + this.email + '#';
}; };
EmailModel.prototype.clearDuplicateName = function () EmailModel.prototype.clearDuplicateName = function()
{ {
if (this.name === this.email) if (this.name === this.email)
{ {
this.name = ''; this.name = '';
} }
}; };
/** /**
* @param {string} sQuery * @param {string} sQuery
* @return {boolean} * @returns {boolean}
*/ */
EmailModel.prototype.search = function (sQuery) EmailModel.prototype.search = function(sQuery)
{ {
return -1 < (this.name + ' ' + this.email).toLowerCase().indexOf(sQuery.toLowerCase()); return -1 < (this.name + ' ' + this.email).toLowerCase().indexOf(sQuery.toLowerCase());
}; };
/** /**
* @param {string} sString * @param {string} sString
*/ */
EmailModel.prototype.parse = function (sString) EmailModel.prototype.parse = function(sString)
{ {
this.clear(); this.clear();
sString = Utils.trim(sString); sString = Utils.trim(sString);
var var
mRegex = /(?:"([^"]+)")? ?[<]?(.*?@[^>,]+)>?,? ?/g, mRegex = /(?:"([^"]+)")? ?[<]?(.*?@[^>,]+)>?,? ?/g,
mMatch = mRegex.exec(sString) mMatch = mRegex.exec(sString);
;
if (mMatch) if (mMatch)
{ {
@ -168,14 +160,14 @@
this.name = ''; this.name = '';
this.email = sString; this.email = sString;
} }
}; };
/** /**
* @param {AjaxJsonEmail} oJsonEmail * @param {AjaxJsonEmail} oJsonEmail
* @return {boolean} * @returns {boolean}
*/ */
EmailModel.prototype.initByJson = function (oJsonEmail) EmailModel.prototype.initByJson = function(oJsonEmail)
{ {
var bResult = false; var bResult = false;
if (oJsonEmail && 'Object/Email' === oJsonEmail['@Object']) if (oJsonEmail && 'Object/Email' === oJsonEmail['@Object'])
{ {
@ -189,16 +181,16 @@
} }
return bResult; return bResult;
}; };
/** /**
* @param {boolean} bFriendlyView * @param {boolean} bFriendlyView
* @param {boolean=} bWrapWithLink = false * @param {boolean=} bWrapWithLink = false
* @param {boolean=} bEncodeHtml = false * @param {boolean=} bEncodeHtml = false
* @return {string} * @returns {string}
*/ */
EmailModel.prototype.toLine = function (bFriendlyView, bWrapWithLink, bEncodeHtml) EmailModel.prototype.toLine = function(bFriendlyView, bWrapWithLink, bEncodeHtml)
{ {
var sResult = ''; var sResult = '';
if ('' !== this.email) if ('' !== this.email)
{ {
@ -242,14 +234,14 @@
} }
return sResult; return sResult;
}; };
/** /**
* @param {string} $sEmailAddress * @param {string} $sEmailAddress
* @return {boolean} * @returns {boolean}
*/ */
EmailModel.prototype.mailsoParse = function ($sEmailAddress) EmailModel.prototype.mailsoParse = function($sEmailAddress)
{ {
$sEmailAddress = Utils.trim($sEmailAddress); $sEmailAddress = Utils.trim($sEmailAddress);
if ('' === $sEmailAddress) if ('' === $sEmailAddress)
{ {
@ -257,25 +249,25 @@
} }
var var
substr = function (str, start, len) { substr = function(str, start, len) {
str += ''; str += '';
var end = str.length; var end = str.length;
if (start < 0) { if (0 > start) {
start += end; start += end;
} }
end = typeof len === 'undefined' ? end : (len < 0 ? len + end : len + start); end = 'undefined' === typeof len ? end : (0 > len ? len + end : len + start);
return start >= str.length || start < 0 || start > end ? false : str.slice(start, end); return start >= str.length || 0 > start || start > end ? false : str.slice(start, end);
}, },
substr_replace = function (str, replace, start, length) { substrReplace = function(str, replace, start, length) {
if (start < 0) { if (0 > start) {
start += str.length; start += str.length;
} }
length = typeof length !== 'undefined' ? length : str.length; length = 'undefined' === typeof length ? length : str.length;
if (length < 0) { if (0 > length) {
length = length + str.length - start; length = length + str.length - start;
} }
return str.slice(0, start) + replace.substr(0, length) + replace.slice(length) + str.slice(start + length); return str.slice(0, start) + replace.substr(0, length) + replace.slice(length) + str.slice(start + length);
@ -293,8 +285,7 @@
$iStartIndex = 0, $iStartIndex = 0,
$iEndIndex = 0, $iEndIndex = 0,
$iCurrentIndex = 0 $iCurrentIndex = 0;
;
while ($iCurrentIndex < $sEmailAddress.length) while ($iCurrentIndex < $sEmailAddress.length)
{ {
@ -310,7 +301,7 @@
{ {
$iEndIndex = $iCurrentIndex; $iEndIndex = $iCurrentIndex;
$sName = substr($sEmailAddress, $iStartIndex + 1, $iEndIndex - $iStartIndex - 1); $sName = substr($sEmailAddress, $iStartIndex + 1, $iEndIndex - $iStartIndex - 1);
$sEmailAddress = substr_replace($sEmailAddress, '', $iStartIndex, $iEndIndex - $iStartIndex + 1); $sEmailAddress = substrReplace($sEmailAddress, '', $iStartIndex, $iEndIndex - $iStartIndex + 1);
$iEndIndex = 0; $iEndIndex = 0;
$iCurrentIndex = 0; $iCurrentIndex = 0;
$iStartIndex = 0; $iStartIndex = 0;
@ -320,7 +311,7 @@
case '<': case '<':
if ((!$bInName) && (!$bInAddress) && (!$bInComment)) if ((!$bInName) && (!$bInAddress) && (!$bInComment))
{ {
if ($iCurrentIndex > 0 && $sName.length === 0) if (0 < $iCurrentIndex && 0 === $sName.length)
{ {
$sName = substr($sEmailAddress, 0, $iCurrentIndex); $sName = substr($sEmailAddress, 0, $iCurrentIndex);
} }
@ -334,7 +325,7 @@
{ {
$iEndIndex = $iCurrentIndex; $iEndIndex = $iCurrentIndex;
$sEmail = substr($sEmailAddress, $iStartIndex + 1, $iEndIndex - $iStartIndex - 1); $sEmail = substr($sEmailAddress, $iStartIndex + 1, $iEndIndex - $iStartIndex - 1);
$sEmailAddress = substr_replace($sEmailAddress, '', $iStartIndex, $iEndIndex - $iStartIndex + 1); $sEmailAddress = substrReplace($sEmailAddress, '', $iStartIndex, $iEndIndex - $iStartIndex + 1);
$iEndIndex = 0; $iEndIndex = 0;
$iCurrentIndex = 0; $iCurrentIndex = 0;
$iStartIndex = 0; $iStartIndex = 0;
@ -353,7 +344,7 @@
{ {
$iEndIndex = $iCurrentIndex; $iEndIndex = $iCurrentIndex;
$sComment = substr($sEmailAddress, $iStartIndex + 1, $iEndIndex - $iStartIndex - 1); $sComment = substr($sEmailAddress, $iStartIndex + 1, $iEndIndex - $iStartIndex - 1);
$sEmailAddress = substr_replace($sEmailAddress, '', $iStartIndex, $iEndIndex - $iStartIndex + 1); $sEmailAddress = substrReplace($sEmailAddress, '', $iStartIndex, $iEndIndex - $iStartIndex + 1);
$iEndIndex = 0; $iEndIndex = 0;
$iCurrentIndex = 0; $iCurrentIndex = 0;
$iStartIndex = 0; $iStartIndex = 0;
@ -361,14 +352,15 @@
} }
break; break;
case '\\': case '\\':
$iCurrentIndex++; $iCurrentIndex += 1;
break; break;
// no default
} }
$iCurrentIndex++; $iCurrentIndex += 1;
} }
if ($sEmail.length === 0) if (0 === $sEmail.length)
{ {
$aRegs = $sEmailAddress.match(/[^@\s]+@\S+/i); $aRegs = $sEmailAddress.match(/[^@\s]+@\S+/i);
if ($aRegs && $aRegs[0]) if ($aRegs && $aRegs[0])
@ -381,7 +373,7 @@
} }
} }
if ($sEmail.length > 0 && $sName.length === 0 && $sComment.length === 0) if (0 < $sEmail.length && 0 === $sName.length && 0 === $sComment.length)
{ {
$sName = $sEmailAddress.replace($sEmail, ''); $sName = $sEmailAddress.replace($sEmail, '');
} }
@ -399,8 +391,6 @@
this.clearDuplicateName(); this.clearDuplicateName();
return true; return true;
}; };
module.exports = EmailModel; module.exports = EmailModel;
}());

View file

@ -1,9 +1,5 @@
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
ko = require('ko'), ko = require('ko'),
@ -15,14 +11,13 @@
FilterConditionModel = require('Model/FilterCondition'), FilterConditionModel = require('Model/FilterCondition'),
AbstractModel = require('Knoin/AbstractModel') AbstractModel = require('Knoin/AbstractModel');
;
/** /**
* @constructor * @constructor
*/ */
function FilterModel() function FilterModel()
{ {
AbstractModel.call(this, 'FilterModel'); AbstractModel.call(this, 'FilterModel');
this.enabled = ko.observable(true); this.enabled = ko.observable(true);
@ -53,7 +48,7 @@
this.actionType = ko.observable(Enums.FiltersAction.MoveTo); this.actionType = ko.observable(Enums.FiltersAction.MoveTo);
this.actionType.subscribe(function () { this.actionType.subscribe(function() {
this.actionValue(''); this.actionValue('');
this.actionValue.error(false); this.actionValue.error(false);
this.actionValueSecond(''); this.actionValueSecond('');
@ -62,18 +57,17 @@
this.actionValueFourth.error(false); this.actionValueFourth.error(false);
}, this); }, this);
var fGetRealFolderName = function (sFolderFullNameRaw) { var fGetRealFolderName = function(sFolderFullNameRaw) {
var oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw); var oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw);
return oFolder ? oFolder.fullName.replace( return oFolder ? oFolder.fullName.replace(
'.' === oFolder.delimiter ? /\./ : /[\\\/]+/, ' / ') : sFolderFullNameRaw; '.' === oFolder.delimiter ? /\./ : /[\\\/]+/, ' / ') : sFolderFullNameRaw;
}; };
this.nameSub = ko.computed(function () { this.nameSub = ko.computed(function() {
var var
sResult = '', sResult = '',
sActionValue = this.actionValue() sActionValue = this.actionValue();
;
switch (this.actionType()) switch (this.actionType())
{ {
@ -96,21 +90,18 @@
case Enums.FiltersAction.Discard: case Enums.FiltersAction.Discard:
sResult = Translator.i18n('SETTINGS_FILTERS/SUBNAME_DISCARD'); sResult = Translator.i18n('SETTINGS_FILTERS/SUBNAME_DISCARD');
break; break;
// no default
} }
return sResult ? '(' + sResult + ')' : ''; return sResult ? '(' + sResult + ')' : '';
}, this); }, this);
this.actionTemplate = ko.computed(function () { this.actionTemplate = ko.computed(function() {
var sTemplate = ''; var sTemplate = '';
switch (this.actionType()) switch (this.actionType())
{ {
default:
case Enums.FiltersAction.MoveTo:
sTemplate = 'SettingsFiltersActionMoveToFolder';
break;
case Enums.FiltersAction.Forward: case Enums.FiltersAction.Forward:
sTemplate = 'SettingsFiltersActionForward'; sTemplate = 'SettingsFiltersActionForward';
break; break;
@ -126,6 +117,10 @@
case Enums.FiltersAction.Discard: case Enums.FiltersAction.Discard:
sTemplate = 'SettingsFiltersActionDiscard'; sTemplate = 'SettingsFiltersActionDiscard';
break; break;
case Enums.FiltersAction.MoveTo:
default:
sTemplate = 'SettingsFiltersActionMoveToFolder';
break;
} }
return sTemplate; return sTemplate;
@ -134,11 +129,11 @@
this.regDisposables(this.conditions.subscribe(Utils.windowResizeCallback)); this.regDisposables(this.conditions.subscribe(Utils.windowResizeCallback));
this.regDisposables(this.name.subscribe(function (sValue) { this.regDisposables(this.name.subscribe(function(sValue) {
this.name.error('' === sValue); this.name.error('' === sValue);
}, this)); }, this));
this.regDisposables(this.actionValue.subscribe(function (sValue) { this.regDisposables(this.actionValue.subscribe(function(sValue) {
this.actionValue.error('' === sValue); this.actionValue.error('' === sValue);
}, this)); }, this));
@ -146,17 +141,17 @@
this.deleteAccess = ko.observable(false); this.deleteAccess = ko.observable(false);
this.canBeDeleted = ko.observable(true); this.canBeDeleted = ko.observable(true);
} }
_.extend(FilterModel.prototype, AbstractModel.prototype); _.extend(FilterModel.prototype, AbstractModel.prototype);
FilterModel.prototype.generateID = function () FilterModel.prototype.generateID = function()
{ {
this.id = Utils.fakeMd5(); this.id = Utils.fakeMd5();
}; };
FilterModel.prototype.verify = function () FilterModel.prototype.verify = function()
{ {
if ('' === this.name()) if ('' === this.name())
{ {
this.name.error(true); this.name.error(true);
@ -165,7 +160,7 @@
if (0 < this.conditions().length) if (0 < this.conditions().length)
{ {
if (_.find(this.conditions(), function (oCond) { if (_.find(this.conditions(), function(oCond) {
return oCond && !oCond.verify(); return oCond && !oCond.verify();
})) }))
{ {
@ -206,16 +201,16 @@
this.actionValue.error(false); this.actionValue.error(false);
return true; return true;
}; };
FilterModel.prototype.toJson = function () FilterModel.prototype.toJson = function()
{ {
return { return {
ID: this.id, ID: this.id,
Enabled: this.enabled() ? '1' : '0', Enabled: this.enabled() ? '1' : '0',
Name: this.name(), Name: this.name(),
ConditionsType: this.conditionsType(), ConditionsType: this.conditionsType(),
Conditions: _.map(this.conditions(), function (oItem) { Conditions: _.map(this.conditions(), function(oItem) {
return oItem.toJson(); return oItem.toJson();
}), }),
@ -229,26 +224,26 @@
Keep: this.actionKeep() ? '1' : '0', Keep: this.actionKeep() ? '1' : '0',
MarkAsRead: this.actionMarkAsRead() ? '1' : '0' MarkAsRead: this.actionMarkAsRead() ? '1' : '0'
}; };
}; };
FilterModel.prototype.addCondition = function () FilterModel.prototype.addCondition = function()
{ {
this.conditions.push(new FilterConditionModel()); this.conditions.push(new FilterConditionModel());
}; };
FilterModel.prototype.removeCondition = function (oConditionToDelete) FilterModel.prototype.removeCondition = function(oConditionToDelete)
{ {
this.conditions.remove(oConditionToDelete); this.conditions.remove(oConditionToDelete);
Utils.delegateRunOnDestroy(oConditionToDelete); Utils.delegateRunOnDestroy(oConditionToDelete);
}; };
FilterModel.prototype.setRecipients = function () FilterModel.prototype.setRecipients = function()
{ {
this.actionValueFourth(require('Stores/User/Account').accountsEmails().join(', ')); this.actionValueFourth(require('Stores/User/Account').accountsEmails().join(', '));
}; };
FilterModel.prototype.parse = function (oItem) FilterModel.prototype.parse = function(oItem)
{ {
var bResult = false; var bResult = false;
if (oItem && 'Object/Filter' === oItem['@Object']) if (oItem && 'Object/Filter' === oItem['@Object'])
{ {
@ -262,7 +257,7 @@
if (Utils.isNonEmptyArray(oItem.Conditions)) if (Utils.isNonEmptyArray(oItem.Conditions))
{ {
this.conditions(_.compact(_.map(oItem.Conditions, function (aData) { this.conditions(_.compact(_.map(oItem.Conditions, function(aData) {
var oFilterCondition = new FilterConditionModel(); var oFilterCondition = new FilterConditionModel();
return oFilterCondition && oFilterCondition.parse(aData) ? return oFilterCondition && oFilterCondition.parse(aData) ?
oFilterCondition : null; oFilterCondition : null;
@ -284,10 +279,10 @@
} }
return bResult; return bResult;
}; };
FilterModel.prototype.cloneSelf = function () FilterModel.prototype.cloneSelf = function()
{ {
var oClone = new FilterModel(); var oClone = new FilterModel();
oClone.id = this.id; oClone.id = this.id;
@ -313,13 +308,11 @@
oClone.actionKeep(this.actionKeep()); oClone.actionKeep(this.actionKeep());
oClone.actionNoStop(this.actionNoStop()); oClone.actionNoStop(this.actionNoStop());
oClone.conditions(_.map(this.conditions(), function (oCondition) { oClone.conditions(_.map(this.conditions(), function(oCondition) {
return oCondition.cloneSelf(); return oCondition.cloneSelf();
})); }));
return oClone; return oClone;
}; };
module.exports = FilterModel; module.exports = FilterModel;
}());

View file

@ -1,23 +1,18 @@
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
ko = require('ko'), ko = require('ko'),
Enums = require('Common/Enums'), Enums = require('Common/Enums'),
Utils = require('Common/Utils'), Utils = require('Common/Utils'),
AbstractModel = require('Knoin/AbstractModel') AbstractModel = require('Knoin/AbstractModel');
;
/** /**
* @constructor * @constructor
*/ */
function FilterConditionModel() function FilterConditionModel()
{ {
AbstractModel.call(this, 'FilterConditionModel'); AbstractModel.call(this, 'FilterConditionModel');
this.field = ko.observable(Enums.FilterConditionField.From); this.field = ko.observable(Enums.FilterConditionField.From);
@ -28,7 +23,7 @@
this.valueSecond = ko.observable(''); this.valueSecond = ko.observable('');
this.valueSecond.error = ko.observable(false); this.valueSecond.error = ko.observable(false);
this.template = ko.computed(function () { this.template = ko.computed(function() {
var sTemplate = ''; var sTemplate = '';
switch (this.field()) switch (this.field())
@ -48,18 +43,18 @@
}, this); }, this);
this.field.subscribe(function () { this.field.subscribe(function() {
this.value(''); this.value('');
this.valueSecond(''); this.valueSecond('');
}, this); }, this);
this.regDisposables([this.template]); this.regDisposables([this.template]);
} }
_.extend(FilterConditionModel.prototype, AbstractModel.prototype); _.extend(FilterConditionModel.prototype, AbstractModel.prototype);
FilterConditionModel.prototype.verify = function () FilterConditionModel.prototype.verify = function()
{ {
if ('' === this.value()) if ('' === this.value())
{ {
this.value.error(true); this.value.error(true);
@ -73,10 +68,10 @@
} }
return true; return true;
}; };
FilterConditionModel.prototype.parse = function (oItem) FilterConditionModel.prototype.parse = function(oItem)
{ {
if (oItem && oItem.Field && oItem.Type) if (oItem && oItem.Field && oItem.Type)
{ {
this.field(Utils.pString(oItem.Field)); this.field(Utils.pString(oItem.Field));
@ -88,20 +83,20 @@
} }
return false; return false;
}; };
FilterConditionModel.prototype.toJson = function () FilterConditionModel.prototype.toJson = function()
{ {
return { return {
Field: this.field(), Field: this.field(),
Type: this.type(), Type: this.type(),
Value: this.value(), Value: this.value(),
ValueSecond: this.valueSecond() ValueSecond: this.valueSecond()
}; };
}; };
FilterConditionModel.prototype.cloneSelf = function () FilterConditionModel.prototype.cloneSelf = function()
{ {
var oClone = new FilterConditionModel(); var oClone = new FilterConditionModel();
oClone.field(this.field()); oClone.field(this.field());
@ -110,8 +105,6 @@
oClone.valueSecond(this.valueSecond()); oClone.valueSecond(this.valueSecond());
return oClone; return oClone;
}; };
module.exports = FilterConditionModel; module.exports = FilterConditionModel;
}());

View file

@ -1,9 +1,5 @@
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
ko = require('ko'), ko = require('ko'),
@ -14,14 +10,13 @@
Cache = require('Common/Cache'), Cache = require('Common/Cache'),
AbstractModel = require('Knoin/AbstractModel') AbstractModel = require('Knoin/AbstractModel');
;
/** /**
* @constructor * @constructor
*/ */
function FolderModel() function FolderModel()
{ {
AbstractModel.call(this, 'FolderModel'); AbstractModel.call(this, 'FolderModel');
this.name = ko.observable(''); this.name = ko.observable('');
@ -54,75 +49,73 @@
this.privateMessageCountUnread = ko.observable(0); this.privateMessageCountUnread = ko.observable(0);
this.collapsedPrivate = ko.observable(true); this.collapsedPrivate = ko.observable(true);
} }
_.extend(FolderModel.prototype, AbstractModel.prototype); _.extend(FolderModel.prototype, AbstractModel.prototype);
/** /**
* @static * @static
* @param {AjaxJsonFolder} oJsonFolder * @param {AjaxJsonFolder} oJsonFolder
* @return {?FolderModel} * @returns {?FolderModel}
*/ */
FolderModel.newInstanceFromJson = function (oJsonFolder) FolderModel.newInstanceFromJson = function(oJsonFolder)
{ {
var oFolderModel = new FolderModel(); var oFolderModel = new FolderModel();
return oFolderModel.initByJson(oJsonFolder) ? oFolderModel.initComputed() : null; return oFolderModel.initByJson(oJsonFolder) ? oFolderModel.initComputed() : null;
}; };
/** /**
* @return {FolderModel} * @returns {FolderModel}
*/ */
FolderModel.prototype.initComputed = function () FolderModel.prototype.initComputed = function()
{ {
var sInboxFolderName = Cache.getFolderInboxName(); var sInboxFolderName = Cache.getFolderInboxName();
this.isInbox = ko.computed(function () { this.isInbox = ko.computed(function() {
return Enums.FolderType.Inbox === this.type(); return Enums.FolderType.Inbox === this.type();
}, this); }, this);
this.hasSubScribedSubfolders = ko.computed(function () { this.hasSubScribedSubfolders = ko.computed(function() {
return !!_.find(this.subFolders(), function (oFolder) { return !!_.find(this.subFolders(), function(oFolder) {
return (oFolder.subScribed() || oFolder.hasSubScribedSubfolders()) && !oFolder.isSystemFolder(); return (oFolder.subScribed() || oFolder.hasSubScribedSubfolders()) && !oFolder.isSystemFolder();
}); });
}, this); }, this);
this.canBeEdited = ko.computed(function () { this.canBeEdited = ko.computed(function() {
return Enums.FolderType.User === this.type() && this.existen && this.selectable; return Enums.FolderType.User === this.type() && this.existen && this.selectable;
}, this); }, this);
this.visible = ko.computed(function () { this.visible = ko.computed(function() {
var var
bSubScribed = this.subScribed(), bSubScribed = this.subScribed(),
bSubFolders = this.hasSubScribedSubfolders() bSubFolders = this.hasSubScribedSubfolders();
;
return (bSubScribed || (bSubFolders && (!this.existen || !this.selectable))); return (bSubScribed || (bSubFolders && (!this.existen || !this.selectable)));
}, this); }, this);
this.isSystemFolder = ko.computed(function () { this.isSystemFolder = ko.computed(function() {
return Enums.FolderType.User !== this.type(); return Enums.FolderType.User !== this.type();
}, this); }, this);
this.hidden = ko.computed(function () { this.hidden = ko.computed(function() {
var var
bSystem = this.isSystemFolder(), bSystem = this.isSystemFolder(),
bSubFolders = this.hasSubScribedSubfolders() bSubFolders = this.hasSubScribedSubfolders();
;
return (bSystem && !bSubFolders) || (!this.selectable && !bSubFolders); return (bSystem && !bSubFolders) || (!this.selectable && !bSubFolders);
}, this); }, this);
this.selectableForFolderList = ko.computed(function () { this.selectableForFolderList = ko.computed(function() {
return !this.isSystemFolder() && this.selectable; return !this.isSystemFolder() && this.selectable;
}, this); }, this);
this.messageCountAll = ko.computed({ this.messageCountAll = ko.computed({
'read': this.privateMessageCountAll, 'read': this.privateMessageCountAll,
'write': function (iValue) { 'write': function(iValue) {
if (Utils.isPosNumeric(iValue, true)) if (Utils.isPosNumeric(iValue, true))
{ {
this.privateMessageCountAll(iValue); this.privateMessageCountAll(iValue);
@ -137,7 +130,7 @@
this.messageCountUnread = ko.computed({ this.messageCountUnread = ko.computed({
'read': this.privateMessageCountUnread, 'read': this.privateMessageCountUnread,
'write': function (iValue) { 'write': function(iValue) {
if (Utils.isPosNumeric(iValue, true)) if (Utils.isPosNumeric(iValue, true))
{ {
this.privateMessageCountUnread(iValue); this.privateMessageCountUnread(iValue);
@ -150,12 +143,11 @@
'owner': this 'owner': this
}).extend({'notify': 'always'}); }).extend({'notify': 'always'});
this.printableUnreadCount = ko.computed(function () { this.printableUnreadCount = ko.computed(function() {
var var
iCount = this.messageCountAll(), iCount = this.messageCountAll(),
iUnread = this.messageCountUnread(), iUnread = this.messageCountUnread(),
iType = this.type() iType = this.type();
;
if (0 < iCount) if (0 < iCount)
{ {
@ -173,33 +165,31 @@
}, this); }, this);
this.canBeDeleted = ko.computed(function () { this.canBeDeleted = ko.computed(function() {
var var
bSystem = this.isSystemFolder() bSystem = this.isSystemFolder();
;
return !bSystem && 0 === this.subFolders().length && sInboxFolderName !== this.fullNameRaw; return !bSystem && 0 === this.subFolders().length && sInboxFolderName !== this.fullNameRaw;
}, this); }, this);
this.canBeSubScribed = ko.computed(function () { this.canBeSubScribed = ko.computed(function() {
return !this.isSystemFolder() && this.selectable && sInboxFolderName !== this.fullNameRaw; return !this.isSystemFolder() && this.selectable && sInboxFolderName !== this.fullNameRaw;
}, this); }, this);
this.canBeChecked = this.canBeSubScribed; this.canBeChecked = this.canBeSubScribed;
// this.visible.subscribe(function () { // this.visible.subscribe(function() {
// Utils.timeOutAction('folder-list-folder-visibility-change', function () { // Utils.timeOutAction('folder-list-folder-visibility-change', function() {
// Globals.$win.trigger('folder-list-folder-visibility-change'); // Globals.$win.trigger('folder-list-folder-visibility-change');
// }, 100); // }, 100);
// }); // });
this.localName = ko.computed(function () { this.localName = ko.computed(function() {
Translator.trigger(); Translator.trigger();
var var
iType = this.type(), iType = this.type(),
sName = this.name() sName = this.name();
;
if (this.isSystemFolder()) if (this.isSystemFolder())
{ {
@ -223,6 +213,7 @@
case Enums.FolderType.Archive: case Enums.FolderType.Archive:
sName = Translator.i18n('FOLDER_LIST/ARCHIVE_NAME'); sName = Translator.i18n('FOLDER_LIST/ARCHIVE_NAME');
break; break;
// no default
} }
} }
@ -230,15 +221,14 @@
}, this); }, this);
this.manageFolderSystemName = ko.computed(function () { this.manageFolderSystemName = ko.computed(function() {
Translator.trigger(); Translator.trigger();
var var
sSuffix = '', sSuffix = '',
iType = this.type(), iType = this.type(),
sName = this.name() sName = this.name();
;
if (this.isSystemFolder()) if (this.isSystemFolder())
{ {
@ -262,6 +252,7 @@
case Enums.FolderType.Archive: case Enums.FolderType.Archive:
sSuffix = '(' + Translator.i18n('FOLDER_LIST/ARCHIVE_NAME') + ')'; sSuffix = '(' + Translator.i18n('FOLDER_LIST/ARCHIVE_NAME') + ')';
break; break;
// no default
} }
} }
@ -275,38 +266,38 @@
}, this); }, this);
this.collapsed = ko.computed({ this.collapsed = ko.computed({
'read': function () { 'read': function() {
return !this.hidden() && this.collapsedPrivate(); return !this.hidden() && this.collapsedPrivate();
}, },
'write': function (mValue) { 'write': function(mValue) {
this.collapsedPrivate(mValue); this.collapsedPrivate(mValue);
}, },
'owner': this 'owner': this
}); });
this.hasUnreadMessages = ko.computed(function () { this.hasUnreadMessages = ko.computed(function() {
return 0 < this.messageCountUnread() && '' !== this.printableUnreadCount(); return 0 < this.messageCountUnread() && '' !== this.printableUnreadCount();
}, this); }, this);
this.hasSubScribedUnreadMessagesSubfolders = ko.computed(function () { this.hasSubScribedUnreadMessagesSubfolders = ko.computed(function() {
return !!_.find(this.subFolders(), function (oFolder) { return !!_.find(this.subFolders(), function(oFolder) {
return oFolder.hasUnreadMessages() || oFolder.hasSubScribedUnreadMessagesSubfolders(); return oFolder.hasUnreadMessages() || oFolder.hasSubScribedUnreadMessagesSubfolders();
}); });
}, this); }, this);
// subscribe // subscribe
this.name.subscribe(function (sValue) { this.name.subscribe(function(sValue) {
this.nameForEdit(sValue); this.nameForEdit(sValue);
}, this); }, this);
this.edited.subscribe(function (bValue) { this.edited.subscribe(function(bValue) {
if (bValue) if (bValue)
{ {
this.nameForEdit(this.name()); this.nameForEdit(this.name());
} }
}, this); }, this);
this.messageCountUnread.subscribe(function (iUnread) { this.messageCountUnread.subscribe(function(iUnread) {
if (Enums.FolderType.Inbox === this.type()) if (Enums.FolderType.Inbox === this.type())
{ {
Events.pub('mailbox.inbox-unread-count', [iUnread]); Events.pub('mailbox.inbox-unread-count', [iUnread]);
@ -314,35 +305,34 @@
}, this); }, this);
return this; return this;
}; };
FolderModel.prototype.fullName = ''; FolderModel.prototype.fullName = '';
FolderModel.prototype.fullNameRaw = ''; FolderModel.prototype.fullNameRaw = '';
FolderModel.prototype.fullNameHash = ''; FolderModel.prototype.fullNameHash = '';
FolderModel.prototype.delimiter = ''; FolderModel.prototype.delimiter = '';
FolderModel.prototype.namespace = ''; FolderModel.prototype.namespace = '';
FolderModel.prototype.deep = 0; FolderModel.prototype.deep = 0;
FolderModel.prototype.interval = 0; FolderModel.prototype.interval = 0;
/** /**
* @return {string} * @returns {string}
*/ */
FolderModel.prototype.collapsedCss = function () FolderModel.prototype.collapsedCss = function()
{ {
return this.hasSubScribedSubfolders() ? return this.hasSubScribedSubfolders() ?
(this.collapsed() ? 'icon-right-mini e-collapsed-sign' : 'icon-down-mini e-collapsed-sign') : 'icon-none e-collapsed-sign'; (this.collapsed() ? 'icon-right-mini e-collapsed-sign' : 'icon-down-mini e-collapsed-sign') : 'icon-none e-collapsed-sign';
}; };
/** /**
* @param {AjaxJsonFolder} oJsonFolder * @param {AjaxJsonFolder} oJsonFolder
* @return {boolean} * @returns {boolean}
*/ */
FolderModel.prototype.initByJson = function (oJsonFolder) FolderModel.prototype.initByJson = function(oJsonFolder)
{ {
var var
bResult = false, bResult = false,
sInboxFolderName = Cache.getFolderInboxName() sInboxFolderName = Cache.getFolderInboxName();
;
if (oJsonFolder && 'Object/Folder' === oJsonFolder['@Object']) if (oJsonFolder && 'Object/Folder' === oJsonFolder['@Object'])
{ {
@ -364,16 +354,14 @@
} }
return bResult; return bResult;
}; };
/** /**
* @return {string} * @returns {string}
*/ */
FolderModel.prototype.printableFullName = function () FolderModel.prototype.printableFullName = function()
{ {
return this.fullName.split(this.delimiter).join(' / '); return this.fullName.split(this.delimiter).join(' / ');
}; };
module.exports = FolderModel; module.exports = FolderModel;
}());

View file

@ -1,22 +1,17 @@
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
ko = require('ko'), ko = require('ko'),
AbstractModel = require('Knoin/AbstractModel') AbstractModel = require('Knoin/AbstractModel');
;
/** /**
* @constructor
* @param {string} sId * @param {string} sId
* @param {string} sEmail * @param {string} sEmail
* @constructor
*/ */
function IdentityModel(sId, sEmail) function IdentityModel(sId, sEmail)
{ {
AbstractModel.call(this, 'IdentityModel'); AbstractModel.call(this, 'IdentityModel');
this.id = ko.observable(sId || ''); this.id = ko.observable(sId || '');
@ -30,23 +25,20 @@
this.signatureInsertBefore = ko.observable(false); this.signatureInsertBefore = ko.observable(false);
this.deleteAccess = ko.observable(false); this.deleteAccess = ko.observable(false);
this.canBeDeleted = ko.computed(function () { this.canBeDeleted = ko.computed(function() {
return '' !== this.id(); return '' !== this.id();
}, this); }, this);
} }
_.extend(IdentityModel.prototype, AbstractModel.prototype); _.extend(IdentityModel.prototype, AbstractModel.prototype);
IdentityModel.prototype.formattedName = function () IdentityModel.prototype.formattedName = function()
{ {
var var
sName = this.name(), sName = this.name(),
sEmail = this.email() sEmail = this.email();
;
return ('' !== sName) ? sName + ' (' + sEmail + ')' : sEmail; return ('' !== sName) ? sName + ' (' + sEmail + ')' : sEmail;
}; };
module.exports = IdentityModel; module.exports = IdentityModel;
}());

View file

@ -1,9 +1,5 @@
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
$ = require('$'), $ = require('$'),
ko = require('ko'), ko = require('ko'),
@ -17,14 +13,13 @@
MessageHelper = require('Helper/Message').default, MessageHelper = require('Helper/Message').default,
AbstractModel = require('Knoin/AbstractModel') AbstractModel = require('Knoin/AbstractModel');
;
/** /**
* @constructor * @constructor
*/ */
function MessageModel() function MessageModel()
{ {
AbstractModel.call(this, 'MessageModel'); AbstractModel.call(this, 'MessageModel');
this.folderFullNameRaw = ''; this.folderFullNameRaw = '';
@ -73,7 +68,7 @@
this.hasAttachments = ko.observable(false); this.hasAttachments = ko.observable(false);
this.attachmentsSpecData = ko.observableArray([]); this.attachmentsSpecData = ko.observableArray([]);
this.attachmentIconClass = ko.computed(function () { this.attachmentIconClass = ko.computed(function() {
return AttachmentModel.staticCombinedIconClass( return AttachmentModel.staticCombinedIconClass(
this.hasAttachments() ? this.attachmentsSpecData() : []); this.hasAttachments() ? this.attachmentsSpecData() : []);
}, this); }, this);
@ -102,32 +97,32 @@
this.threads = ko.observableArray([]); this.threads = ko.observableArray([]);
this.threadsLen = ko.computed(function () { this.threadsLen = ko.computed(function() {
return this.threads().length; return this.threads().length;
}, this); }, this);
this.isImportant = ko.computed(function () { this.isImportant = ko.computed(function() {
return Enums.MessagePriority.High === this.priority(); return Enums.MessagePriority.High === this.priority();
}, this); }, this);
this.regDisposables([this.attachmentIconClass, this.threadsLen, this.isImportant]); this.regDisposables([this.attachmentIconClass, this.threadsLen, this.isImportant]);
} }
_.extend(MessageModel.prototype, AbstractModel.prototype); _.extend(MessageModel.prototype, AbstractModel.prototype);
/** /**
* @static * @static
* @param {AjaxJsonMessage} oJsonMessage * @param {AjaxJsonMessage} oJsonMessage
* @return {?MessageModel} * @returns {?MessageModel}
*/ */
MessageModel.newInstanceFromJson = function (oJsonMessage) MessageModel.newInstanceFromJson = function(oJsonMessage)
{ {
var oMessageModel = new MessageModel(); var oMessageModel = new MessageModel();
return oMessageModel.initByJson(oJsonMessage) ? oMessageModel : null; return oMessageModel.initByJson(oJsonMessage) ? oMessageModel : null;
}; };
MessageModel.prototype.clear = function () MessageModel.prototype.clear = function()
{ {
this.folderFullNameRaw = ''; this.folderFullNameRaw = '';
this.uid = ''; this.uid = '';
this.hash = ''; this.hash = '';
@ -193,62 +188,60 @@
this.hasUnseenSubMessage(false); this.hasUnseenSubMessage(false);
this.hasFlaggedSubMessage(false); this.hasFlaggedSubMessage(false);
}; };
/** /**
* @return {Array} * @returns {Array}
*/ */
MessageModel.prototype.getRecipientsEmails = function () MessageModel.prototype.getRecipientsEmails = function()
{ {
return this.getEmails(['to', 'cc']); return this.getEmails(['to', 'cc']);
}; };
/** /**
* @param {Array} aProperties * @param {Array} aProperties
* @return {Array} * @returns {Array}
*/ */
MessageModel.prototype.getEmails = function (aProperties) MessageModel.prototype.getEmails = function(aProperties)
{ {
var self = this; var self = this;
return _.compact(_.uniq(_.map(_.reduce(aProperties, function (aCarry, sProperty) { return _.compact(_.uniq(_.map(_.reduce(aProperties, function(aCarry, sProperty) {
return aCarry.concat(self[sProperty]); return aCarry.concat(self[sProperty]);
}, []), function (oItem) { }, []), function(oItem) {
return oItem ? oItem.email : ''; return oItem ? oItem.email : '';
}))); })));
}; };
/** /**
* @return {string} * @returns {string}
*/ */
MessageModel.prototype.friendlySize = function () MessageModel.prototype.friendlySize = function()
{ {
return Utils.friendlySize(this.size()); return Utils.friendlySize(this.size());
}; };
MessageModel.prototype.computeSenderEmail = function () MessageModel.prototype.computeSenderEmail = function()
{ {
var var
sSent = require('Stores/User/Folder').sentFolder(), sSent = require('Stores/User/Folder').sentFolder(),
sDraft = require('Stores/User/Folder').draftFolder() sDraft = require('Stores/User/Folder').draftFolder();
;
this.senderEmailsString(this.folderFullNameRaw === sSent || this.folderFullNameRaw === sDraft ? this.senderEmailsString(this.folderFullNameRaw === sSent || this.folderFullNameRaw === sDraft ?
this.toEmailsString() : this.fromEmailString()); this.toEmailsString() : this.fromEmailString());
this.senderClearEmailsString(this.folderFullNameRaw === sSent || this.folderFullNameRaw === sDraft ? this.senderClearEmailsString(this.folderFullNameRaw === sSent || this.folderFullNameRaw === sDraft ?
this.toClearEmailsString() : this.fromClearEmailString()); this.toClearEmailsString() : this.fromClearEmailString());
}; };
/** /**
* @param {AjaxJsonMessage} oJsonMessage * @param {AjaxJsonMessage} oJsonMessage
* @return {boolean} * @returns {boolean}
*/ */
MessageModel.prototype.initByJson = function (oJsonMessage) MessageModel.prototype.initByJson = function(oJsonMessage)
{ {
var var
bResult = false, bResult = false,
iPriority = Enums.MessagePriority.Normal iPriority = Enums.MessagePriority.Normal;
;
if (oJsonMessage && 'Object/Message' === oJsonMessage['@Object']) if (oJsonMessage && 'Object/Message' === oJsonMessage['@Object'])
{ {
@ -303,18 +296,17 @@
} }
return bResult; return bResult;
}; };
/** /**
* @param {AjaxJsonMessage} oJsonMessage * @param {AjaxJsonMessage} oJsonMessage
* @return {boolean} * @returns {boolean}
*/ */
MessageModel.prototype.initUpdateByMessageJson = function (oJsonMessage) MessageModel.prototype.initUpdateByMessageJson = function(oJsonMessage)
{ {
var var
bResult = false, bResult = false,
iPriority = Enums.MessagePriority.Normal iPriority = Enums.MessagePriority.Normal;
;
if (oJsonMessage && 'Object/Message' === oJsonMessage['@Object']) if (oJsonMessage && 'Object/Message' === oJsonMessage['@Object'])
{ {
@ -351,20 +343,19 @@
} }
return bResult; return bResult;
}; };
/** /**
* @param {(AjaxJsonAttachment|null)} oJsonAttachments * @param {(AjaxJsonAttachment|null)} oJsonAttachments
* @return {Array} * @returns {Array}
*/ */
MessageModel.prototype.initAttachmentsFromJson = function (oJsonAttachments) MessageModel.prototype.initAttachmentsFromJson = function(oJsonAttachments)
{ {
var var
iIndex = 0, iIndex = 0,
iLen = 0, iLen = 0,
oAttachmentModel = null, oAttachmentModel = null,
aResult = [] aResult = [];
;
if (oJsonAttachments && 'Collection/AttachmentCollection' === oJsonAttachments['@Object'] && if (oJsonAttachments && 'Collection/AttachmentCollection' === oJsonAttachments['@Object'] &&
Utils.isNonEmptyArray(oJsonAttachments['@Collection'])) Utils.isNonEmptyArray(oJsonAttachments['@Collection']))
@ -386,14 +377,14 @@
} }
return aResult; return aResult;
}; };
/** /**
* @param {AjaxJsonMessage} oJsonMessage * @param {AjaxJsonMessage} oJsonMessage
* @return {boolean} * @returns {boolean}
*/ */
MessageModel.prototype.initFlagsByJson = function (oJsonMessage) MessageModel.prototype.initFlagsByJson = function(oJsonMessage)
{ {
var bResult = false; var bResult = false;
if (oJsonMessage && 'Object/Message' === oJsonMessage['@Object']) if (oJsonMessage && 'Object/Message' === oJsonMessage['@Object'])
@ -409,23 +400,23 @@
} }
return bResult; return bResult;
}; };
/** /**
* @param {boolean} bFriendlyView * @param {boolean} bFriendlyView
* @param {boolean=} bWrapWithLink = false * @param {boolean=} bWrapWithLink = false
* @return {string} * @returns {string}
*/ */
MessageModel.prototype.fromToLine = function (bFriendlyView, bWrapWithLink) MessageModel.prototype.fromToLine = function(bFriendlyView, bWrapWithLink)
{ {
return MessageHelper.emailArrayToString(this.from, bFriendlyView, bWrapWithLink); return MessageHelper.emailArrayToString(this.from, bFriendlyView, bWrapWithLink);
}; };
/** /**
* @return {string} * @returns {string}
*/ */
MessageModel.prototype.fromDkimData = function () MessageModel.prototype.fromDkimData = function()
{ {
var aResult = ['none', '']; var aResult = ['none', ''];
if (Utils.isNonEmptyArray(this.from) && 1 === this.from.length && if (Utils.isNonEmptyArray(this.from) && 1 === this.from.length &&
this.from[0] && this.from[0].dkimStatus) this.from[0] && this.from[0].dkimStatus)
@ -434,53 +425,53 @@
} }
return aResult; return aResult;
}; };
/** /**
* @param {boolean} bFriendlyView * @param {boolean} bFriendlyView
* @param {boolean=} bWrapWithLink = false * @param {boolean=} bWrapWithLink = false
* @return {string} * @returns {string}
*/ */
MessageModel.prototype.toToLine = function (bFriendlyView, bWrapWithLink) MessageModel.prototype.toToLine = function(bFriendlyView, bWrapWithLink)
{ {
return MessageHelper.emailArrayToString(this.to, bFriendlyView, bWrapWithLink); return MessageHelper.emailArrayToString(this.to, bFriendlyView, bWrapWithLink);
}; };
/** /**
* @param {boolean} bFriendlyView * @param {boolean} bFriendlyView
* @param {boolean=} bWrapWithLink = false * @param {boolean=} bWrapWithLink = false
* @return {string} * @returns {string}
*/ */
MessageModel.prototype.ccToLine = function (bFriendlyView, bWrapWithLink) MessageModel.prototype.ccToLine = function(bFriendlyView, bWrapWithLink)
{ {
return MessageHelper.emailArrayToString(this.cc, bFriendlyView, bWrapWithLink); return MessageHelper.emailArrayToString(this.cc, bFriendlyView, bWrapWithLink);
}; };
/** /**
* @param {boolean} bFriendlyView * @param {boolean} bFriendlyView
* @param {boolean=} bWrapWithLink = false * @param {boolean=} bWrapWithLink = false
* @return {string} * @returns {string}
*/ */
MessageModel.prototype.bccToLine = function (bFriendlyView, bWrapWithLink) MessageModel.prototype.bccToLine = function(bFriendlyView, bWrapWithLink)
{ {
return MessageHelper.emailArrayToString(this.bcc, bFriendlyView, bWrapWithLink); return MessageHelper.emailArrayToString(this.bcc, bFriendlyView, bWrapWithLink);
}; };
/** /**
* @param {boolean} bFriendlyView * @param {boolean} bFriendlyView
* @param {boolean=} bWrapWithLink = false * @param {boolean=} bWrapWithLink = false
* @return {string} * @returns {string}
*/ */
MessageModel.prototype.replyToToLine = function (bFriendlyView, bWrapWithLink) MessageModel.prototype.replyToToLine = function(bFriendlyView, bWrapWithLink)
{ {
return MessageHelper.emailArrayToString(this.replyTo, bFriendlyView, bWrapWithLink); return MessageHelper.emailArrayToString(this.replyTo, bFriendlyView, bWrapWithLink);
}; };
/** /**
* @return string * @return string
*/ */
MessageModel.prototype.lineAsCss = function () MessageModel.prototype.lineAsCss = function()
{ {
var aResult = []; var aResult = [];
if (this.deleted()) if (this.deleted())
{ {
@ -548,121 +539,118 @@
} }
return aResult.join(' '); return aResult.join(' ');
}; };
/** /**
* @return {boolean} * @returns {boolean}
*/ */
MessageModel.prototype.hasVisibleAttachments = function () MessageModel.prototype.hasVisibleAttachments = function()
{ {
return !!_.find(this.attachments(), function (oAttachment) { return !!_.find(this.attachments(), function(oAttachment) {
return !oAttachment.isLinked; return !oAttachment.isLinked;
}); });
}; };
/** /**
* @param {string} sCid * @param {string} sCid
* @return {*} * @returns {*}
*/ */
MessageModel.prototype.findAttachmentByCid = function (sCid) MessageModel.prototype.findAttachmentByCid = function(sCid)
{ {
var var
oResult = null, oResult = null,
aAttachments = this.attachments() aAttachments = this.attachments();
;
if (Utils.isNonEmptyArray(aAttachments)) if (Utils.isNonEmptyArray(aAttachments))
{ {
sCid = sCid.replace(/^<+/, '').replace(/>+$/, ''); sCid = sCid.replace(/^<+/, '').replace(/>+$/, '');
oResult = _.find(aAttachments, function (oAttachment) { oResult = _.find(aAttachments, function(oAttachment) {
return sCid === oAttachment.cidWithOutTags; return sCid === oAttachment.cidWithOutTags;
}); });
} }
return oResult || null; return oResult || null;
}; };
/** /**
* @param {string} sContentLocation * @param {string} sContentLocation
* @return {*} * @returns {*}
*/ */
MessageModel.prototype.findAttachmentByContentLocation = function (sContentLocation) MessageModel.prototype.findAttachmentByContentLocation = function(sContentLocation)
{ {
var var
oResult = null, oResult = null,
aAttachments = this.attachments() aAttachments = this.attachments();
;
if (Utils.isNonEmptyArray(aAttachments)) if (Utils.isNonEmptyArray(aAttachments))
{ {
oResult = _.find(aAttachments, function (oAttachment) { oResult = _.find(aAttachments, function(oAttachment) {
return sContentLocation === oAttachment.contentLocation; return sContentLocation === oAttachment.contentLocation;
}); });
} }
return oResult || null; return oResult || null;
}; };
/** /**
* @return {string} * @returns {string}
*/ */
MessageModel.prototype.messageId = function () MessageModel.prototype.messageId = function()
{ {
return this.sMessageId; return this.sMessageId;
}; };
/** /**
* @return {string} * @returns {string}
*/ */
MessageModel.prototype.inReplyTo = function () MessageModel.prototype.inReplyTo = function()
{ {
return this.sInReplyTo; return this.sInReplyTo;
}; };
/** /**
* @return {string} * @returns {string}
*/ */
MessageModel.prototype.references = function () MessageModel.prototype.references = function()
{ {
return this.sReferences; return this.sReferences;
}; };
/** /**
* @return {string} * @returns {string}
*/ */
MessageModel.prototype.fromAsSingleEmail = function () MessageModel.prototype.fromAsSingleEmail = function()
{ {
return Utils.isArray(this.from) && this.from[0] ? this.from[0].email : ''; return Utils.isArray(this.from) && this.from[0] ? this.from[0].email : '';
}; };
/** /**
* @return {string} * @returns {string}
*/ */
MessageModel.prototype.viewLink = function () MessageModel.prototype.viewLink = function()
{ {
return Links.messageViewLink(this.requestHash); return Links.messageViewLink(this.requestHash);
}; };
/** /**
* @return {string} * @returns {string}
*/ */
MessageModel.prototype.downloadLink = function () MessageModel.prototype.downloadLink = function()
{ {
return Links.messageDownloadLink(this.requestHash); return Links.messageDownloadLink(this.requestHash);
}; };
/** /**
* @param {Object} oExcludeEmails * @param {Object} oExcludeEmails
* @param {boolean=} bLast = false * @param {boolean=} bLast = false
* @return {Array} * @returns {Array}
*/ */
MessageModel.prototype.replyEmails = function (oExcludeEmails, bLast) MessageModel.prototype.replyEmails = function(oExcludeEmails, bLast)
{ {
var var
aResult = [], aResult = [],
oUnic = Utils.isUnd(oExcludeEmails) ? {} : oExcludeEmails oUnic = Utils.isUnd(oExcludeEmails) ? {} : oExcludeEmails;
;
MessageHelper.replyHelper(this.replyTo, oUnic, aResult); MessageHelper.replyHelper(this.replyTo, oUnic, aResult);
if (0 === aResult.length) if (0 === aResult.length)
@ -676,21 +664,20 @@
} }
return aResult; return aResult;
}; };
/** /**
* @param {Object} oExcludeEmails * @param {Object} oExcludeEmails
* @param {boolean=} bLast = false * @param {boolean=} bLast = false
* @return {Array.<Array>} * @returns {Array.<Array>}
*/ */
MessageModel.prototype.replyAllEmails = function (oExcludeEmails, bLast) MessageModel.prototype.replyAllEmails = function(oExcludeEmails, bLast)
{ {
var var
aData = [], aData = [],
aToResult = [], aToResult = [],
aCcResult = [], aCcResult = [],
oUnic = Utils.isUnd(oExcludeEmails) ? {} : oExcludeEmails oUnic = Utils.isUnd(oExcludeEmails) ? {} : oExcludeEmails;
;
MessageHelper.replyHelper(this.replyTo, oUnic, aToResult); MessageHelper.replyHelper(this.replyTo, oUnic, aToResult);
if (0 === aToResult.length) if (0 === aToResult.length)
@ -708,33 +695,33 @@
} }
return [aToResult, aCcResult]; return [aToResult, aCcResult];
}; };
/** /**
* @return {string} * @returns {string}
*/ */
MessageModel.prototype.textBodyToString = function () MessageModel.prototype.textBodyToString = function()
{ {
return this.body ? this.body.html() : ''; return this.body ? this.body.html() : '';
}; };
/** /**
* @return {string} * @returns {string}
*/ */
MessageModel.prototype.attachmentsToStringLine = function () MessageModel.prototype.attachmentsToStringLine = function()
{ {
var aAttachLines = _.map(this.attachments(), function (oItem) { var aAttachLines = _.map(this.attachments(), function(oItem) {
return oItem.fileName + ' (' + oItem.friendlySize + ')'; return oItem.fileName + ' (' + oItem.friendlySize + ')';
}); });
return aAttachLines && 0 < aAttachLines.length ? aAttachLines.join(', ') : ''; return aAttachLines && 0 < aAttachLines.length ? aAttachLines.join(', ') : '';
}; };
/** /**
* @return {Object} * @returns {Object}
*/ */
MessageModel.prototype.getDataForWindowPopup = function () MessageModel.prototype.getDataForWindowPopup = function()
{ {
return { return {
'popupFrom': this.fromToLine(false), 'popupFrom': this.fromToLine(false),
'popupTo': this.toToLine(false), 'popupTo': this.toToLine(false),
@ -747,36 +734,36 @@
'popupAttachments': this.attachmentsToStringLine(), 'popupAttachments': this.attachmentsToStringLine(),
'popupBody': this.textBodyToString() 'popupBody': this.textBodyToString()
}; };
}; };
/** /**
* @param {boolean=} bPrint = false * @param {boolean=} bPrint = false
*/ */
MessageModel.prototype.viewPopupMessage = function (bPrint) MessageModel.prototype.viewPopupMessage = function(bPrint)
{ {
this.showLazyExternalImagesInBody(); this.showLazyExternalImagesInBody();
Utils.previewMessage(this.subject(), this.body, this.isHtml(), bPrint); Utils.previewMessage(this.subject(), this.body, this.isHtml(), bPrint);
}; };
MessageModel.prototype.printMessage = function () MessageModel.prototype.printMessage = function()
{ {
this.viewPopupMessage(true); this.viewPopupMessage(true);
}; };
/** /**
* @return {string} * @returns {string}
*/ */
MessageModel.prototype.generateUid = function () MessageModel.prototype.generateUid = function()
{ {
return this.folderFullNameRaw + '/' + this.uid; return this.folderFullNameRaw + '/' + this.uid;
}; };
/** /**
* @param {MessageModel} oMessage * @param {MessageModel} oMessage
* @return {MessageModel} * @returns {MessageModel}
*/ */
MessageModel.prototype.populateByMessageListItem = function (oMessage) MessageModel.prototype.populateByMessageListItem = function(oMessage)
{ {
if (oMessage) if (oMessage)
{ {
this.folderFullNameRaw = oMessage.folderFullNameRaw; this.folderFullNameRaw = oMessage.folderFullNameRaw;
@ -842,20 +829,20 @@
this.computeSenderEmail(); this.computeSenderEmail();
return this; return this;
}; };
MessageModel.prototype.showLazyExternalImagesInBody = function () MessageModel.prototype.showLazyExternalImagesInBody = function()
{ {
if (this.body) if (this.body)
{ {
$('.lazy.lazy-inited[data-original]', this.body).each(function () { $('.lazy.lazy-inited[data-original]', this.body).each(function() {
$(this).attr('src', $(this).attr('data-original')).removeAttr('data-original'); $(this).attr('src', $(this).attr('data-original')).removeAttr('data-original');
}); });
} }
}; };
MessageModel.prototype.showExternalImages = function (bLazy) MessageModel.prototype.showExternalImages = function(bLazy)
{ {
if (this.body && this.body.data('rl-has-images')) if (this.body && this.body.data('rl-has-images'))
{ {
bLazy = Utils.isUnd(bLazy) ? false : bLazy; bLazy = Utils.isUnd(bLazy) ? false : bLazy;
@ -864,14 +851,13 @@
this.body.data('rl-has-images', false); this.body.data('rl-has-images', false);
var sAttr = this.proxy ? 'data-x-additional-src' : 'data-x-src'; var sAttr = this.proxy ? 'data-x-additional-src' : 'data-x-src';
$('[' + sAttr + ']', this.body).each(function () { $('[' + sAttr + ']', this.body).each(function() {
if (bLazy && $(this).is('img')) if (bLazy && $(this).is('img'))
{ {
$(this) $(this)
.addClass('lazy') .addClass('lazy')
.attr('data-original', $(this).attr(sAttr)) .attr('data-original', $(this).attr(sAttr))
.removeAttr(sAttr) .removeAttr(sAttr);
;
} }
else else
{ {
@ -880,7 +866,7 @@
}); });
sAttr = this.proxy ? 'data-x-additional-style-url' : 'data-x-style-url'; sAttr = this.proxy ? 'data-x-additional-style-url' : 'data-x-style-url';
$('[' + sAttr + ']', this.body).each(function () { $('[' + sAttr + ']', this.body).each(function() {
var sStyle = Utils.trim($(this).attr('style')); var sStyle = Utils.trim($(this).attr('style'));
sStyle = '' === sStyle ? '' : (';' === sStyle.substr(-1) ? sStyle + ' ' : sStyle + '; '); sStyle = '' === sStyle ? '' : (';' === sStyle.substr(-1) ? sStyle + ' ' : sStyle + '; ');
$(this).attr('style', sStyle + $(this).attr(sAttr)).removeAttr(sAttr); $(this).attr('style', sStyle + $(this).attr(sAttr)).removeAttr(sAttr);
@ -900,10 +886,10 @@
Utils.windowResize(500); Utils.windowResize(500);
} }
}; };
MessageModel.prototype.showInternalImages = function (bLazy) MessageModel.prototype.showInternalImages = function(bLazy)
{ {
if (this.body && !this.body.data('rl-init-internal-images')) if (this.body && !this.body.data('rl-init-internal-images'))
{ {
this.body.data('rl-init-internal-images', true); this.body.data('rl-init-internal-images', true);
@ -912,7 +898,7 @@
var self = this; var self = this;
$('[data-x-src-cid]', this.body).each(function () { $('[data-x-src-cid]', this.body).each(function() {
var oAttachment = self.findAttachmentByCid($(this).attr('data-x-src-cid')); var oAttachment = self.findAttachmentByCid($(this).attr('data-x-src-cid'));
if (oAttachment && oAttachment.download) if (oAttachment && oAttachment.download)
@ -930,7 +916,7 @@
} }
}); });
$('[data-x-src-location]', this.body).each(function () { $('[data-x-src-location]', this.body).each(function() {
var oAttachment = self.findAttachmentByContentLocation($(this).attr('data-x-src-location')); var oAttachment = self.findAttachmentByContentLocation($(this).attr('data-x-src-location'));
if (!oAttachment) if (!oAttachment)
@ -953,13 +939,12 @@
} }
}); });
$('[data-x-style-cid]', this.body).each(function () { $('[data-x-style-cid]', this.body).each(function() {
var var
sStyle = '', sStyle = '',
sName = '', sName = '',
oAttachment = self.findAttachmentByCid($(this).attr('data-x-style-cid')) oAttachment = self.findAttachmentByCid($(this).attr('data-x-style-cid'));
;
if (oAttachment && oAttachment.linkPreview) if (oAttachment && oAttachment.linkPreview)
{ {
@ -975,8 +960,8 @@
if (bLazy) if (bLazy)
{ {
(function ($oImg, oContainer) { (function($oImg, oContainer) {
_.delay(function () { _.delay(function() {
$oImg.addClass('lazy-inited').lazyload({ $oImg.addClass('lazy-inited').lazyload({
'threshold': 400, 'threshold': 400,
'effect': 'fadeIn', 'effect': 'fadeIn',
@ -989,43 +974,41 @@
Utils.windowResize(500); Utils.windowResize(500);
} }
}; };
MessageModel.prototype.storeDataInDom = function () MessageModel.prototype.storeDataInDom = function()
{ {
if (this.body) if (this.body)
{ {
this.body.data('rl-is-html', !!this.isHtml()); this.body.data('rl-is-html', !!this.isHtml());
this.body.data('rl-has-images', !!this.hasImages()); this.body.data('rl-has-images', !!this.hasImages());
} }
}; };
MessageModel.prototype.fetchDataFromDom = function () MessageModel.prototype.fetchDataFromDom = function()
{ {
if (this.body) if (this.body)
{ {
this.isHtml(!!this.body.data('rl-is-html')); this.isHtml(!!this.body.data('rl-is-html'));
this.hasImages(!!this.body.data('rl-has-images')); this.hasImages(!!this.body.data('rl-has-images'));
} }
}; };
MessageModel.prototype.replacePlaneTextBody = function (sPlain) MessageModel.prototype.replacePlaneTextBody = function(sPlain)
{ {
if (this.body) if (this.body)
{ {
this.body.html(sPlain).addClass('b-text-part plain'); this.body.html(sPlain).addClass('b-text-part plain');
} }
}; };
/** /**
* @return {string} * @returns {string}
*/ */
MessageModel.prototype.flagHash = function () MessageModel.prototype.flagHash = function()
{ {
return [this.deleted(), this.deletedMark(), this.unseen(), this.flagged(), this.answered(), this.forwarded(), return [this.deleted(), this.deletedMark(), this.unseen(), this.flagged(), this.answered(), this.forwarded(),
this.isReadReceipt()].join(','); this.isReadReceipt()].join(',');
}; };
module.exports = MessageModel; module.exports = MessageModel;
}());

View file

@ -1,37 +1,30 @@
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
Enums = require('Common/Enums'), Enums = require('Common/Enums'),
Utils = require('Common/Utils'), Utils = require('Common/Utils'),
// MessageHelper = require('Helper/Message').default, MessageSimpleModel = require('Model/MessageSimple');
MessageSimpleModel = require('Model/MessageSimple') /**
;
/**
* @constructor * @constructor
*/ */
function MessageFullModel() function MessageFullModel()
{ {
MessageSimpleModel.call(this, 'MessageFullModel'); MessageSimpleModel.call(this, 'MessageFullModel');
} }
_.extend(MessageFullModel.prototype, MessageSimpleModel.prototype); _.extend(MessageFullModel.prototype, MessageSimpleModel.prototype);
MessageFullModel.prototype.priority = 0; MessageFullModel.prototype.priority = 0;
MessageFullModel.prototype.hash = ''; MessageFullModel.prototype.hash = '';
MessageFullModel.prototype.requestHash = ''; MessageFullModel.prototype.requestHash = '';
MessageFullModel.prototype.proxy = false; MessageFullModel.prototype.proxy = false;
MessageFullModel.prototype.hasAttachments = false; MessageFullModel.prototype.hasAttachments = false;
MessageFullModel.prototype.clear = function () MessageFullModel.prototype.clear = function()
{ {
MessageSimpleModel.prototype.clear.call(this); MessageSimpleModel.prototype.clear.call(this);
this.priority = 0; this.priority = 0;
@ -41,14 +34,14 @@
this.proxy = false; this.proxy = false;
this.hasAttachments = false; this.hasAttachments = false;
}; };
/** /**
* @param {AjaxJsonMessage} oJson * @param {AjaxJsonMessage} oJson
* @return {boolean} * @returns {boolean}
*/ */
MessageFullModel.prototype.initByJson = function (oJson) MessageFullModel.prototype.initByJson = function(oJson)
{ {
var bResult = false; var bResult = false;
if (oJson && 'Object/Message' === oJson['@Object']) if (oJson && 'Object/Message' === oJson['@Object'])
@ -71,19 +64,17 @@
} }
return bResult; return bResult;
}; };
/** /**
* @static * @static
* @param {AjaxJsonMessage} oJson * @param {AjaxJsonMessage} oJson
* @return {?MessageFullModel} * @returns {?MessageFullModel}
*/ */
MessageFullModel.newInstanceFromJson = function (oJson) MessageFullModel.newInstanceFromJson = function(oJson)
{ {
var oItem = oJson ? new MessageFullModel() : null; var oItem = oJson ? new MessageFullModel() : null;
return oItem && oItem.initByJson(oJson) ? oItem : null; return oItem && oItem.initByJson(oJson) ? oItem : null;
}; };
module.exports = MessageFullModel; module.exports = MessageFullModel;
}());

View file

@ -1,9 +1,5 @@
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
ko = require('ko'), ko = require('ko'),
@ -11,50 +7,49 @@
MessageHelper = require('Helper/Message').default, MessageHelper = require('Helper/Message').default,
AbstractModel = require('Knoin/AbstractModel') AbstractModel = require('Knoin/AbstractModel');
;
/** /**
* @param {string=} sSuperName
* @constructor * @constructor
* @param {string=} sSuperName
*/ */
function MessageSimpleModel(sSuperName) function MessageSimpleModel(sSuperName)
{ {
AbstractModel.call(this, sSuperName || 'MessageSimpleModel'); AbstractModel.call(this, sSuperName || 'MessageSimpleModel');
this.flagged = ko.observable(false); this.flagged = ko.observable(false);
this.selected = ko.observable(false); this.selected = ko.observable(false);
} }
_.extend(MessageSimpleModel.prototype, AbstractModel.prototype); _.extend(MessageSimpleModel.prototype, AbstractModel.prototype);
MessageSimpleModel.prototype.__simple_message__ = true; MessageSimpleModel.prototype.isSimpleMessage = true;
MessageSimpleModel.prototype.folder = ''; MessageSimpleModel.prototype.folder = '';
MessageSimpleModel.prototype.folderFullNameRaw = ''; MessageSimpleModel.prototype.folderFullNameRaw = '';
MessageSimpleModel.prototype.uid = ''; MessageSimpleModel.prototype.uid = '';
MessageSimpleModel.prototype.subject = ''; MessageSimpleModel.prototype.subject = '';
MessageSimpleModel.prototype.to = []; MessageSimpleModel.prototype.to = [];
MessageSimpleModel.prototype.from = []; MessageSimpleModel.prototype.from = [];
MessageSimpleModel.prototype.cc = []; MessageSimpleModel.prototype.cc = [];
MessageSimpleModel.prototype.bcc = []; MessageSimpleModel.prototype.bcc = [];
MessageSimpleModel.prototype.replyTo = []; MessageSimpleModel.prototype.replyTo = [];
MessageSimpleModel.prototype.deliveredTo = []; MessageSimpleModel.prototype.deliveredTo = [];
MessageSimpleModel.prototype.fromAsString = ''; MessageSimpleModel.prototype.fromAsString = '';
MessageSimpleModel.prototype.fromAsStringClear = ''; MessageSimpleModel.prototype.fromAsStringClear = '';
MessageSimpleModel.prototype.toAsString = ''; MessageSimpleModel.prototype.toAsString = '';
MessageSimpleModel.prototype.toAsStringClear = ''; MessageSimpleModel.prototype.toAsStringClear = '';
MessageSimpleModel.prototype.senderAsString = ''; MessageSimpleModel.prototype.senderAsString = '';
MessageSimpleModel.prototype.senderAsStringClear = ''; MessageSimpleModel.prototype.senderAsStringClear = '';
MessageSimpleModel.prototype.size = 0; MessageSimpleModel.prototype.size = 0;
MessageSimpleModel.prototype.timestamp = 0; MessageSimpleModel.prototype.timestamp = 0;
MessageSimpleModel.prototype.clear = function () MessageSimpleModel.prototype.clear = function()
{ {
this.folder = ''; this.folder = '';
this.folderFullNameRaw = ''; this.folderFullNameRaw = '';
@ -81,14 +76,14 @@
this.flagged(false); this.flagged(false);
this.selected(false); this.selected(false);
}; };
/** /**
* @param {Object} oJson * @param {Object} oJson
* @return {boolean} * @returns {boolean}
*/ */
MessageSimpleModel.prototype.initByJson = function (oJson) MessageSimpleModel.prototype.initByJson = function(oJson)
{ {
var bResult = false; var bResult = false;
if (oJson && 'Object/Message' === oJson['@Object']) if (oJson && 'Object/Message' === oJson['@Object'])
@ -136,10 +131,10 @@
} }
return bResult; return bResult;
}; };
MessageSimpleModel.prototype.populateSenderEmail = function (bDraftOrSentFolder) MessageSimpleModel.prototype.populateSenderEmail = function(bDraftOrSentFolder)
{ {
this.senderAsString = this.fromAsString; this.senderAsString = this.fromAsString;
this.senderAsStringClear = this.fromAsStringClear; this.senderAsStringClear = this.fromAsStringClear;
@ -148,27 +143,25 @@
this.senderAsString = this.toAsString; this.senderAsString = this.toAsString;
this.senderAsStringClear = this.toAsStringClear; this.senderAsStringClear = this.toAsStringClear;
} }
}; };
/** /**
* @return {Array} * @returns {Array}
*/ */
MessageSimpleModel.prototype.threads = function () MessageSimpleModel.prototype.threads = function()
{ {
return []; return [];
}; };
/** /**
* @static * @static
* @param {Object} oJson * @param {Object} oJson
* @return {?MessageSimpleModel} * @returns {?MessageSimpleModel}
*/ */
MessageSimpleModel.newInstanceFromJson = function (oJson) MessageSimpleModel.newInstanceFromJson = function(oJson)
{ {
var oItem = oJson ? new MessageSimpleModel() : null; var oItem = oJson ? new MessageSimpleModel() : null;
return oItem && oItem.initByJson(oJson) ? oItem : null; return oItem && oItem.initByJson(oJson) ? oItem : null;
}; };
module.exports = MessageSimpleModel; module.exports = MessageSimpleModel;
}());

View file

@ -1,9 +1,5 @@
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
ko = require('ko'), ko = require('ko'),
@ -11,10 +7,10 @@
PgpStore = require('Stores/User/Pgp'), PgpStore = require('Stores/User/Pgp'),
AbstractModel = require('Knoin/AbstractModel') AbstractModel = require('Knoin/AbstractModel');
;
/** /**
* @constructor
* @param {string} iIndex * @param {string} iIndex
* @param {string} sGuID * @param {string} sGuID
* @param {string} sID * @param {string} sID
@ -24,10 +20,9 @@
* @param {boolean} bIsPrivate * @param {boolean} bIsPrivate
* @param {string} sArmor * @param {string} sArmor
* @param {string} sUserID * @param {string} sUserID
* @constructor
*/ */
function OpenPgpKeyModel(iIndex, sGuID, sID, aIDs, aUserIDs, aEmails, bIsPrivate, sArmor, sUserID) function OpenPgpKeyModel(iIndex, sGuID, sID, aIDs, aUserIDs, aEmails, bIsPrivate, sArmor, sUserID)
{ {
AbstractModel.call(this, 'OpenPgpKeyModel'); AbstractModel.call(this, 'OpenPgpKeyModel');
this.index = iIndex; this.index = iIndex;
@ -42,23 +37,23 @@
this.selectUser(sUserID); this.selectUser(sUserID);
this.deleteAccess = ko.observable(false); this.deleteAccess = ko.observable(false);
} }
_.extend(OpenPgpKeyModel.prototype, AbstractModel.prototype); _.extend(OpenPgpKeyModel.prototype, AbstractModel.prototype);
OpenPgpKeyModel.prototype.index = 0; OpenPgpKeyModel.prototype.index = 0;
OpenPgpKeyModel.prototype.id = ''; OpenPgpKeyModel.prototype.id = '';
OpenPgpKeyModel.prototype.ids = []; OpenPgpKeyModel.prototype.ids = [];
OpenPgpKeyModel.prototype.guid = ''; OpenPgpKeyModel.prototype.guid = '';
OpenPgpKeyModel.prototype.user = ''; OpenPgpKeyModel.prototype.user = '';
OpenPgpKeyModel.prototype.users = []; OpenPgpKeyModel.prototype.users = [];
OpenPgpKeyModel.prototype.email = ''; OpenPgpKeyModel.prototype.email = '';
OpenPgpKeyModel.prototype.emails = []; OpenPgpKeyModel.prototype.emails = [];
OpenPgpKeyModel.prototype.armor = ''; OpenPgpKeyModel.prototype.armor = '';
OpenPgpKeyModel.prototype.isPrivate = false; OpenPgpKeyModel.prototype.isPrivate = false;
OpenPgpKeyModel.prototype.getNativeKey = function () OpenPgpKeyModel.prototype.getNativeKey = function()
{ {
var oKey = null; var oKey = null;
try try
{ {
@ -74,38 +69,35 @@
} }
return null; return null;
}; };
OpenPgpKeyModel.prototype.getNativeKeys = function () OpenPgpKeyModel.prototype.getNativeKeys = function()
{ {
var oKey = this.getNativeKey(); var oKey = this.getNativeKey();
return oKey && oKey.keys ? oKey.keys : null; return oKey && oKey.keys ? oKey.keys : null;
}; };
OpenPgpKeyModel.prototype.select = function (sPattern, sProperty) OpenPgpKeyModel.prototype.select = function(sPattern, sProperty)
{ {
if (this[sProperty]) if (this[sProperty])
{ {
var index = this[sProperty].indexOf(sPattern); var index = this[sProperty].indexOf(sPattern);
if (index !== -1) if (-1 !== index)
{ {
this.user = this.users[index]; this.user = this.users[index];
this.email = this.emails[index]; this.email = this.emails[index];
} }
} }
}; };
OpenPgpKeyModel.prototype.selectUser = function (sUser) OpenPgpKeyModel.prototype.selectUser = function(sUser)
{ {
this.select(sUser, 'users'); this.select(sUser, 'users');
}; };
OpenPgpKeyModel.prototype.selectEmail = function (sEmail) OpenPgpKeyModel.prototype.selectEmail = function(sEmail)
{ {
this.select(sEmail, 'emails'); this.select(sEmail, 'emails');
}; };
module.exports = OpenPgpKeyModel;
}());
module.exports = OpenPgpKeyModel;

View file

@ -1,26 +1,20 @@
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
ko = require('ko'), ko = require('ko'),
Utils = require('Common/Utils'), Utils = require('Common/Utils'),
AbstractModel = require('Knoin/AbstractModel') AbstractModel = require('Knoin/AbstractModel');
;
/** /**
* @constructor * @constructor
*
* @param {string} sID * @param {string} sID
* @param {string} sName * @param {string} sName
* @param {string} sBody * @param {string} sBody
*/ */
function TemplateModel(sID, sName, sBody) function TemplateModel(sID, sName, sBody)
{ {
AbstractModel.call(this, 'TemplateModel'); AbstractModel.call(this, 'TemplateModel');
this.id = sID; this.id = sID;
@ -29,35 +23,35 @@
this.populated = true; this.populated = true;
this.deleteAccess = ko.observable(false); this.deleteAccess = ko.observable(false);
} }
_.extend(TemplateModel.prototype, AbstractModel.prototype); _.extend(TemplateModel.prototype, AbstractModel.prototype);
/** /**
* @type {string} * @type {string}
*/ */
TemplateModel.prototype.id = ''; TemplateModel.prototype.id = '';
/** /**
* @type {string} * @type {string}
*/ */
TemplateModel.prototype.name = ''; TemplateModel.prototype.name = '';
/** /**
* @type {string} * @type {string}
*/ */
TemplateModel.prototype.body = ''; TemplateModel.prototype.body = '';
/** /**
* @type {boolean} * @type {boolean}
*/ */
TemplateModel.prototype.populated = true; TemplateModel.prototype.populated = true;
/** /**
* @type {boolean} * @type {boolean}
*/ */
TemplateModel.prototype.parse = function (oItem) TemplateModel.prototype.parse = function(oItem)
{ {
var bResult = false; var bResult = false;
if (oItem && 'Object/Template' === oItem['@Object']) if (oItem && 'Object/Template' === oItem['@Object'])
{ {
@ -70,8 +64,6 @@
} }
return bResult; return bResult;
}; };
module.exports = TemplateModel; module.exports = TemplateModel;
}());

View file

@ -1,9 +1,5 @@
(function () { var
'use strict';
var
$ = require('$'), $ = require('$'),
_ = require('_'), _ = require('_'),
Promise = require('Promise'), Promise = require('Promise'),
@ -17,30 +13,29 @@
Settings = require('Storage/Settings'), Settings = require('Storage/Settings'),
AbstractBasicPromises = require('Promises/AbstractBasic') AbstractBasicPromises = require('Promises/AbstractBasic');
;
/** /**
* @constructor * @constructor
*/ */
function AbstractAjaxPromises() function AbstractAjaxPromises()
{ {
AbstractBasicPromises.call(this); AbstractBasicPromises.call(this);
this.clear(); this.clear();
} }
_.extend(AbstractAjaxPromises.prototype, AbstractBasicPromises.prototype); _.extend(AbstractAjaxPromises.prototype, AbstractBasicPromises.prototype);
AbstractAjaxPromises.prototype.oRequests = {}; AbstractAjaxPromises.prototype.oRequests = {};
AbstractAjaxPromises.prototype.clear = function () AbstractAjaxPromises.prototype.clear = function()
{ {
this.oRequests = {}; this.oRequests = {};
}; };
AbstractAjaxPromises.prototype.abort = function (sAction, bClearOnly) AbstractAjaxPromises.prototype.abort = function(sAction, bClearOnly)
{ {
if (this.oRequests[sAction]) if (this.oRequests[sAction])
{ {
if (!bClearOnly && this.oRequests[sAction].abort) if (!bClearOnly && this.oRequests[sAction].abort)
@ -54,17 +49,16 @@
} }
return this; return this;
}; };
AbstractAjaxPromises.prototype.ajaxRequest = function (sAction, bPost, iTimeOut, oParameters, sAdditionalGetString, fTrigger) AbstractAjaxPromises.prototype.ajaxRequest = function(sAction, bPost, iTimeOut, oParameters, sAdditionalGetString, fTrigger)
{ {
var self = this; var self = this;
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
var var
oH = null, oH = null,
iStart = Utils.microtime() iStart = Utils.microtime();
;
iTimeOut = Utils.isNormal(iTimeOut) ? iTimeOut : Consts.DEFAULT_AJAX_TIMEOUT; iTimeOut = Utils.isNormal(iTimeOut) ? iTimeOut : Consts.DEFAULT_AJAX_TIMEOUT;
sAdditionalGetString = Utils.isUnd(sAdditionalGetString) ? '' : Utils.pString(sAdditionalGetString); sAdditionalGetString = Utils.isUnd(sAdditionalGetString) ? '' : Utils.pString(sAdditionalGetString);
@ -86,7 +80,7 @@
data: bPost ? (oParameters || {}) : {}, data: bPost ? (oParameters || {}) : {},
timeout: iTimeOut, timeout: iTimeOut,
global: true global: true
}).always(function (oData, sTextStatus) { }).always(function(oData, sTextStatus) {
var bCached = false, oErrorData = null, sType = Enums.StorageResultType.Error; var bCached = false, oErrorData = null, sType = Enums.StorageResultType.Error;
if (oData && oData.Time) if (oData && oData.Time)
@ -103,6 +97,7 @@
case 'abort' === sTextStatus && (!oData || !oData.__aborted__): case 'abort' === sTextStatus && (!oData || !oData.__aborted__):
sType = Enums.StorageResultType.Abort; sType = Enums.StorageResultType.Abort;
break; break;
// no default
} }
Plugins.runHook('ajax-default-response', [sAction, Plugins.runHook('ajax-default-response', [sAction,
@ -160,12 +155,12 @@
Enums.Notification.MailServerError, Enums.Notification.UnknownNotification, Enums.Notification.UnknownError Enums.Notification.MailServerError, Enums.Notification.UnknownNotification, Enums.Notification.UnknownError
])) ]))
{ {
Globals.data.iAjaxErrorCount++; Globals.data.iAjaxErrorCount += 1;
} }
if (Enums.Notification.InvalidToken === oErrorData.ErrorCode) if (Enums.Notification.InvalidToken === oErrorData.ErrorCode)
{ {
Globals.data.iTokenErrorCount++; Globals.data.iTokenErrorCount += 1;
} }
if (Consts.TOKEN_ERROR_LIMIT < Globals.data.iTokenErrorCount) if (Consts.TOKEN_ERROR_LIMIT < Globals.data.iTokenErrorCount)
@ -203,24 +198,22 @@
self.oRequests[sAction] = oH; self.oRequests[sAction] = oH;
} }
}); });
}; };
AbstractAjaxPromises.prototype.getRequest = function (sAction, fTrigger, sAdditionalGetString, iTimeOut) AbstractAjaxPromises.prototype.getRequest = function(sAction, fTrigger, sAdditionalGetString, iTimeOut)
{ {
sAdditionalGetString = Utils.isUnd(sAdditionalGetString) ? '' : Utils.pString(sAdditionalGetString); sAdditionalGetString = Utils.isUnd(sAdditionalGetString) ? '' : Utils.pString(sAdditionalGetString);
sAdditionalGetString = sAction + '/' + sAdditionalGetString; sAdditionalGetString = sAction + '/' + sAdditionalGetString;
return this.ajaxRequest(sAction, false, iTimeOut, null, sAdditionalGetString, fTrigger); return this.ajaxRequest(sAction, false, iTimeOut, null, sAdditionalGetString, fTrigger);
}; };
AbstractAjaxPromises.prototype.postRequest = function (action, fTrigger, params, timeOut) AbstractAjaxPromises.prototype.postRequest = function(action, fTrigger, params, timeOut)
{ {
params = params || {}; params = params || {};
params.Action = action; params.Action = action;
return this.ajaxRequest(action, true, timeOut, params, '', fTrigger); return this.ajaxRequest(action, true, timeOut, params, '', fTrigger);
}; };
module.exports = AbstractAjaxPromises; module.exports = AbstractAjaxPromises;
}());

View file

@ -1,52 +1,45 @@
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
Promise = require('Promise'), Promise = require('Promise'),
Utils = require('Common/Utils') Utils = require('Common/Utils');
;
/** /**
* @constructor * @constructor
*/ */
function AbstractBasicPromises() function AbstractBasicPromises()
{ {
this.oPromisesStack = {}; this.oPromisesStack = {};
} }
AbstractBasicPromises.prototype.func = function (fFunc) AbstractBasicPromises.prototype.func = function(fFunc)
{ {
fFunc(); fFunc();
return this; return this;
}; };
AbstractBasicPromises.prototype.fastResolve = function (mData) AbstractBasicPromises.prototype.fastResolve = function(mData)
{ {
return Promise.resolve(mData); return Promise.resolve(mData);
}; };
AbstractBasicPromises.prototype.fastReject = function (mData) AbstractBasicPromises.prototype.fastReject = function(mData)
{ {
return Promise.reject(mData); return Promise.reject(mData);
}; };
AbstractBasicPromises.prototype.setTrigger = function (mTrigger, bValue) AbstractBasicPromises.prototype.setTrigger = function(mTrigger, bValue)
{ {
if (mTrigger) if (mTrigger)
{ {
_.each(Utils.isArray(mTrigger) ? mTrigger : [mTrigger], function (fTrigger) { _.each(Utils.isArray(mTrigger) ? mTrigger : [mTrigger], function(fTrigger) {
if (fTrigger) if (fTrigger)
{ {
fTrigger(!!bValue); fTrigger(!!bValue);
} }
}); });
} }
}; };
module.exports = AbstractBasicPromises; module.exports = AbstractBasicPromises;
}());

View file

@ -1,94 +1,78 @@
(function () { var
'use strict';
var
window = require('window'), window = require('window'),
_ = require('_'), _ = require('_'),
// Enums = require('Common/Enums'),
// Utils = require('Common/Utils'),
// Base64 = require('Common/Base64'),
// Cache = require('Common/Cache'),
// Links = require('Common/Links'),
//
// AppStore = require('Stores/User/App'),
// SettingsStore = require('Stores/User/Settings'),
PromisesPopulator = require('Promises/User/Populator'), PromisesPopulator = require('Promises/User/Populator'),
AbstractAjaxPromises = require('Promises/AbstractAjax') AbstractAjaxPromises = require('Promises/AbstractAjax');
;
/** /**
* @constructor * @constructor
* @extends AbstractAjaxPromises * @extends AbstractAjaxPromises
*/ */
function UserAjaxUserPromises() function UserAjaxUserPromises()
{ {
AbstractAjaxPromises.call(this); AbstractAjaxPromises.call(this);
} }
_.extend(UserAjaxUserPromises.prototype, AbstractAjaxPromises.prototype); _.extend(UserAjaxUserPromises.prototype, AbstractAjaxPromises.prototype);
UserAjaxUserPromises.prototype.foldersReload = function (fTrigger) UserAjaxUserPromises.prototype.foldersReload = function(fTrigger)
{ {
return this.abort('Folders') return this.abort('Folders')
.postRequest('Folders', fTrigger).then(function (oData) { .postRequest('Folders', fTrigger).then(function(oData) {
PromisesPopulator.foldersList(oData.Result); PromisesPopulator.foldersList(oData.Result);
PromisesPopulator.foldersAdditionalParameters(oData.Result); PromisesPopulator.foldersAdditionalParameters(oData.Result);
return true; return true;
}); });
}; };
UserAjaxUserPromises.prototype._folders_timeout_ = 0; UserAjaxUserPromises.prototype.foldersTimeout = 0;
UserAjaxUserPromises.prototype.foldersReloadWithTimeout = function (fTrigger) UserAjaxUserPromises.prototype.foldersReloadWithTimeout = function(fTrigger)
{ {
this.setTrigger(fTrigger, true); this.setTrigger(fTrigger, true);
var self = this; var self = this;
window.clearTimeout(this._folders_timeout_); window.clearTimeout(this.foldersTimeout);
this._folders_timeout_ = window.setTimeout(function () { this.foldersTimeout = window.setTimeout(function() {
self.foldersReload(fTrigger); self.foldersReload(fTrigger);
}, 500); }, 500);
}; };
UserAjaxUserPromises.prototype.folderDelete = function (sFolderFullNameRaw, fTrigger) UserAjaxUserPromises.prototype.folderDelete = function(sFolderFullNameRaw, fTrigger)
{ {
return this.postRequest('FolderDelete', fTrigger, { return this.postRequest('FolderDelete', fTrigger, {
'Folder': sFolderFullNameRaw 'Folder': sFolderFullNameRaw
}); });
}; };
UserAjaxUserPromises.prototype.folderCreate = function (sNewFolderName, sParentName, fTrigger) UserAjaxUserPromises.prototype.folderCreate = function(sNewFolderName, sParentName, fTrigger)
{ {
return this.postRequest('FolderCreate', fTrigger, { return this.postRequest('FolderCreate', fTrigger, {
'Folder': sNewFolderName, 'Folder': sNewFolderName,
'Parent': sParentName 'Parent': sParentName
}); });
}; };
UserAjaxUserPromises.prototype.folderRename = function (sPrevFolderFullNameRaw, sNewFolderName, fTrigger) UserAjaxUserPromises.prototype.folderRename = function(sPrevFolderFullNameRaw, sNewFolderName, fTrigger)
{ {
return this.postRequest('FolderRename', fTrigger, { return this.postRequest('FolderRename', fTrigger, {
'Folder': sPrevFolderFullNameRaw, 'Folder': sPrevFolderFullNameRaw,
'NewFolderName': sNewFolderName 'NewFolderName': sNewFolderName
}); });
}; };
UserAjaxUserPromises.prototype.attachmentsActions = function (sAction, aHashes, fTrigger) UserAjaxUserPromises.prototype.attachmentsActions = function(sAction, aHashes, fTrigger)
{ {
return this.postRequest('AttachmentsActions', fTrigger, { return this.postRequest('AttachmentsActions', fTrigger, {
'Do': sAction, 'Do': sAction,
'Hashes': aHashes 'Hashes': aHashes
}); });
}; };
UserAjaxUserPromises.prototype.welcomeClose = function () UserAjaxUserPromises.prototype.welcomeClose = function()
{ {
return this.postRequest('WelcomeClose'); return this.postRequest('WelcomeClose');
}; };
module.exports = new UserAjaxUserPromises(); module.exports = new UserAjaxUserPromises();
}());

View file

@ -1,9 +1,5 @@
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
Consts = require('Common/Consts'), Consts = require('Common/Consts'),
@ -19,46 +15,45 @@
FolderModel = require('Model/Folder'), FolderModel = require('Model/Folder'),
AbstractBasicPromises = require('Promises/AbstractBasic') AbstractBasicPromises = require('Promises/AbstractBasic');
;
/** /**
* @constructor * @constructor
*/ */
function PromisesUserPopulator() function PromisesUserPopulator()
{ {
AbstractBasicPromises.call(this); AbstractBasicPromises.call(this);
} }
_.extend(PromisesUserPopulator.prototype, AbstractBasicPromises.prototype); _.extend(PromisesUserPopulator.prototype, AbstractBasicPromises.prototype);
/** /**
* @param {string} sFullNameHash * @param {string} sFullNameHash
* @return {boolean} * @returns {boolean}
*/ */
PromisesUserPopulator.prototype.isFolderExpanded = function (sFullNameHash) PromisesUserPopulator.prototype.isFolderExpanded = function(sFullNameHash)
{ {
var aExpandedList = Local.get(Enums.ClientSideKeyName.ExpandedFolders); var aExpandedList = Local.get(Enums.ClientSideKeyName.ExpandedFolders);
return Utils.isArray(aExpandedList) && -1 !== _.indexOf(aExpandedList, sFullNameHash); return Utils.isArray(aExpandedList) && -1 !== _.indexOf(aExpandedList, sFullNameHash);
}; };
/** /**
* @param {string} sFolderFullNameRaw * @param {string} sFolderFullNameRaw
* @return {string} * @returns {string}
*/ */
PromisesUserPopulator.prototype.normalizeFolder = function (sFolderFullNameRaw) PromisesUserPopulator.prototype.normalizeFolder = function(sFolderFullNameRaw)
{ {
return ('' === sFolderFullNameRaw || Consts.UNUSED_OPTION_VALUE === sFolderFullNameRaw || return ('' === sFolderFullNameRaw || Consts.UNUSED_OPTION_VALUE === sFolderFullNameRaw ||
null !== Cache.getFolderFromCacheList(sFolderFullNameRaw)) ? sFolderFullNameRaw : ''; null !== Cache.getFolderFromCacheList(sFolderFullNameRaw)) ? sFolderFullNameRaw : '';
}; };
/** /**
* @param {string} sNamespace * @param {string} sNamespace
* @param {Array} aFolders * @param {Array} aFolders
* @return {Array} * @returns {Array}
*/ */
PromisesUserPopulator.prototype.folderResponseParseRec = function (sNamespace, aFolders) PromisesUserPopulator.prototype.folderResponseParseRec = function(sNamespace, aFolders)
{ {
var var
self = this, self = this,
iIndex = 0, iIndex = 0,
@ -67,8 +62,7 @@
oCacheFolder = null, oCacheFolder = null,
sFolderFullNameRaw = '', sFolderFullNameRaw = '',
aSubFolders = [], aSubFolders = [],
aList = [] aList = [];
;
for (iIndex = 0, iLen = aFolders.length; iIndex < iLen; iIndex++) for (iIndex = 0, iLen = aFolders.length; iIndex < iLen; iIndex++)
{ {
@ -133,17 +127,16 @@
} }
return aList; return aList;
}; };
PromisesUserPopulator.prototype.foldersList = function (oData) PromisesUserPopulator.prototype.foldersList = function(oData)
{ {
if (oData && 'Collection/FolderCollection' === oData['@Object'] && if (oData && 'Collection/FolderCollection' === oData['@Object'] &&
oData['@Collection'] && Utils.isArray(oData['@Collection'])) oData['@Collection'] && Utils.isArray(oData['@Collection']))
{ {
var var
iLimit = Utils.pInt(Settings.appSettingsGet('folderSpecLimit')), iLimit = Utils.pInt(Settings.appSettingsGet('folderSpecLimit')),
iC = Utils.pInt(oData.CountRec) iC = Utils.pInt(oData.CountRec);
;
iLimit = 100 < iLimit ? 100 : (10 > iLimit ? 10 : iLimit); iLimit = 100 < iLimit ? 100 : (10 > iLimit ? 10 : iLimit);
@ -151,10 +144,10 @@
FolderStore.folderList(this.folderResponseParseRec( FolderStore.folderList(this.folderResponseParseRec(
Utils.isUnd(oData.Namespace) ? '' : oData.Namespace, oData['@Collection'])); Utils.isUnd(oData.Namespace) ? '' : oData.Namespace, oData['@Collection']));
} }
}; };
PromisesUserPopulator.prototype.foldersAdditionalParameters = function (oData) PromisesUserPopulator.prototype.foldersAdditionalParameters = function(oData)
{ {
if (oData && oData && 'Collection/FolderCollection' === oData['@Object'] && if (oData && oData && 'Collection/FolderCollection' === oData['@Object'] &&
oData['@Collection'] && Utils.isArray(oData['@Collection'])) oData['@Collection'] && Utils.isArray(oData['@Collection']))
{ {
@ -206,8 +199,6 @@
Local.set(Enums.ClientSideKeyName.FoldersLashHash, oData.FoldersHash); Local.set(Enums.ClientSideKeyName.FoldersLashHash, oData.FoldersHash);
} }
}; };
module.exports = new PromisesUserPopulator(); module.exports = new PromisesUserPopulator();
}());

View file

@ -1,9 +1,5 @@
(function () { var
'use strict';
var
window = require('window'), window = require('window'),
_ = require('_'), _ = require('_'),
$ = require('$'), $ = require('$'),
@ -15,20 +11,19 @@
Plugins = require('Common/Plugins'), Plugins = require('Common/Plugins'),
Links = require('Common/Links'), Links = require('Common/Links'),
Settings = require('Storage/Settings') Settings = require('Storage/Settings');
;
/** /**
* @constructor * @constructor
*/ */
function AbstractAjaxRemote() function AbstractAjaxRemote()
{ {
this.oRequests = {}; this.oRequests = {};
} }
AbstractAjaxRemote.prototype.oRequests = {}; AbstractAjaxRemote.prototype.oRequests = {};
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sRequestAction * @param {string} sRequestAction
* @param {string} sType * @param {string} sType
@ -36,10 +31,10 @@
* @param {boolean} bCached * @param {boolean} bCached
* @param {*=} oRequestParameters * @param {*=} oRequestParameters
*/ */
AbstractAjaxRemote.prototype.defaultResponse = function (fCallback, sRequestAction, sType, oData, bCached, oRequestParameters) AbstractAjaxRemote.prototype.defaultResponse = function(fCallback, sRequestAction, sType, oData, bCached, oRequestParameters)
{ {
var var
fCall = function () { fCall = function() {
if (Enums.StorageResultType.Success !== sType && Globals.data.bUnload) if (Enums.StorageResultType.Success !== sType && Globals.data.bUnload)
{ {
sType = Enums.StorageResultType.Unload; sType = Enums.StorageResultType.Unload;
@ -53,12 +48,12 @@
Enums.Notification.MailServerError, Enums.Notification.UnknownNotification, Enums.Notification.UnknownError Enums.Notification.MailServerError, Enums.Notification.UnknownNotification, Enums.Notification.UnknownError
])) ]))
{ {
Globals.data.iAjaxErrorCount++; Globals.data.iAjaxErrorCount += 1;
} }
if (oData && Enums.Notification.InvalidToken === oData.ErrorCode) if (oData && Enums.Notification.InvalidToken === oData.ErrorCode)
{ {
Globals.data.iTokenErrorCount++; Globals.data.iTokenErrorCount += 1;
} }
if (Consts.TOKEN_ERROR_LIMIT < Globals.data.iTokenErrorCount) if (Consts.TOKEN_ERROR_LIMIT < Globals.data.iTokenErrorCount)
@ -100,8 +95,7 @@
oRequestParameters oRequestParameters
); );
} }
} };
;
switch (sType) switch (sType)
{ {
@ -124,26 +118,25 @@
{ {
fCall(); fCall();
} }
}; };
/** /**
* @param {?Function} fResultCallback * @param {?Function} fResultCallback
* @param {Object} oParameters * @param {Object} oParameters
* @param {?number=} iTimeOut = 20000 * @param {?number=} iTimeOut = 20000
* @param {string=} sGetAdd = '' * @param {string=} sGetAdd = ''
* @param {Array=} aAbortActions = [] * @param {Array=} aAbortActions = []
* @return {jQuery.jqXHR} * @returns {jQuery.jqXHR}
*/ */
AbstractAjaxRemote.prototype.ajaxRequest = function (fResultCallback, oParameters, iTimeOut, sGetAdd, aAbortActions) AbstractAjaxRemote.prototype.ajaxRequest = function(fResultCallback, oParameters, iTimeOut, sGetAdd, aAbortActions)
{ {
var var
self = this, self = this,
bPost = '' === sGetAdd, bPost = '' === sGetAdd,
oHeaders = {}, oHeaders = {},
iStart = (new window.Date()).getTime(), iStart = (new window.Date()).getTime(),
oDefAjax = null, oDefAjax = null,
sAction = '' sAction = '';
;
oParameters = oParameters || {}; oParameters = oParameters || {};
iTimeOut = Utils.isNormal(iTimeOut) ? iTimeOut : 20000; iTimeOut = Utils.isNormal(iTimeOut) ? iTimeOut : 20000;
@ -154,7 +147,7 @@
if (sAction && 0 < aAbortActions.length) if (sAction && 0 < aAbortActions.length)
{ {
_.each(aAbortActions, function (sActionToAbort) { _.each(aAbortActions, function(sActionToAbort) {
if (self.oRequests[sActionToAbort]) if (self.oRequests[sActionToAbort])
{ {
self.oRequests[sActionToAbort].__aborted = true; self.oRequests[sActionToAbort].__aborted = true;
@ -183,7 +176,7 @@
global: true global: true
}); });
oDefAjax.always(function (oData, sType) { oDefAjax.always(function(oData, sType) {
var bCached = false; var bCached = false;
if (oData && oData.Time) if (oData && oData.Time)
@ -220,9 +213,9 @@
} }
return oDefAjax; return oDefAjax;
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sAction * @param {string} sAction
* @param {Object=} oParameters * @param {Object=} oParameters
@ -230,8 +223,8 @@
* @param {string=} sGetAdd = '' * @param {string=} sGetAdd = ''
* @param {Array=} aAbortActions = [] * @param {Array=} aAbortActions = []
*/ */
AbstractAjaxRemote.prototype.defaultRequest = function (fCallback, sAction, oParameters, iTimeout, sGetAdd, aAbortActions) AbstractAjaxRemote.prototype.defaultRequest = function(fCallback, sAction, oParameters, iTimeout, sGetAdd, aAbortActions)
{ {
oParameters = oParameters || {}; oParameters = oParameters || {};
oParameters.Action = sAction; oParameters.Action = sAction;
@ -241,17 +234,17 @@
return this.ajaxRequest(fCallback, oParameters, return this.ajaxRequest(fCallback, oParameters,
Utils.isUnd(iTimeout) ? Consts.DEFAULT_AJAX_TIMEOUT : Utils.pInt(iTimeout), sGetAdd, aAbortActions); Utils.isUnd(iTimeout) ? Consts.DEFAULT_AJAX_TIMEOUT : Utils.pInt(iTimeout), sGetAdd, aAbortActions);
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
*/ */
AbstractAjaxRemote.prototype.noop = function (fCallback) AbstractAjaxRemote.prototype.noop = function(fCallback)
{ {
this.defaultRequest(fCallback, 'Noop'); this.defaultRequest(fCallback, 'Noop');
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sMessage * @param {string} sMessage
* @param {string} sFileName * @param {string} sFileName
@ -260,8 +253,8 @@
* @param {string} sHtmlCapa * @param {string} sHtmlCapa
* @param {number} iTime * @param {number} iTime
*/ */
AbstractAjaxRemote.prototype.jsError = function (fCallback, sMessage, sFileName, iLineNo, sLocation, sHtmlCapa, iTime) AbstractAjaxRemote.prototype.jsError = function(fCallback, sMessage, sFileName, iLineNo, sLocation, sHtmlCapa, iTime)
{ {
this.defaultRequest(fCallback, 'JsError', { this.defaultRequest(fCallback, 'JsError', {
'Message': sMessage, 'Message': sMessage,
'FileName': sFileName, 'FileName': sFileName,
@ -270,42 +263,40 @@
'HtmlCapa': sHtmlCapa, 'HtmlCapa': sHtmlCapa,
'TimeOnPage': iTime 'TimeOnPage': iTime
}); });
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sType * @param {string} sType
* @param {Array=} mData = null * @param {Array=} mData = null
* @param {boolean=} bIsError = false * @param {boolean=} bIsError = false
*/ */
AbstractAjaxRemote.prototype.jsInfo = function (fCallback, sType, mData, bIsError) AbstractAjaxRemote.prototype.jsInfo = function(fCallback, sType, mData, bIsError)
{ {
this.defaultRequest(fCallback, 'JsInfo', { this.defaultRequest(fCallback, 'JsInfo', {
'Type': sType, 'Type': sType,
'Data': mData, 'Data': mData,
'IsError': (Utils.isUnd(bIsError) ? false : !!bIsError) ? '1' : '0' 'IsError': (Utils.isUnd(bIsError) ? false : !!bIsError) ? '1' : '0'
}); });
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
*/ */
AbstractAjaxRemote.prototype.getPublicKey = function (fCallback) AbstractAjaxRemote.prototype.getPublicKey = function(fCallback)
{ {
this.defaultRequest(fCallback, 'GetPublicKey'); this.defaultRequest(fCallback, 'GetPublicKey');
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sVersion * @param {string} sVersion
*/ */
AbstractAjaxRemote.prototype.jsVersion = function (fCallback, sVersion) AbstractAjaxRemote.prototype.jsVersion = function(fCallback, sVersion)
{ {
this.defaultRequest(fCallback, 'Version', { this.defaultRequest(fCallback, 'Version', {
'Version': sVersion 'Version': sVersion
}); });
}; };
module.exports = AbstractAjaxRemote; module.exports = AbstractAjaxRemote;
}());

View file

@ -1,234 +1,229 @@
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
Utils = require('Common/Utils'), Utils = require('Common/Utils'),
AbstractAjaxRemote = require('Remote/AbstractAjax') AbstractAjaxRemote = require('Remote/AbstractAjax');
;
/** /**
* @constructor * @constructor
* @extends AbstractAjaxRemote * @extends AbstractAjaxRemote
*/ */
function RemoteAdminStorage() function RemoteAdminStorage()
{ {
AbstractAjaxRemote.call(this); AbstractAjaxRemote.call(this);
this.oRequests = {}; this.oRequests = {};
} }
_.extend(RemoteAdminStorage.prototype, AbstractAjaxRemote.prototype); _.extend(RemoteAdminStorage.prototype, AbstractAjaxRemote.prototype);
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sLogin * @param {string} sLogin
* @param {string} sPassword * @param {string} sPassword
*/ */
RemoteAdminStorage.prototype.adminLogin = function (fCallback, sLogin, sPassword) RemoteAdminStorage.prototype.adminLogin = function(fCallback, sLogin, sPassword)
{ {
this.defaultRequest(fCallback, 'AdminLogin', { this.defaultRequest(fCallback, 'AdminLogin', {
'Login': sLogin, 'Login': sLogin,
'Password': sPassword 'Password': sPassword
}); });
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
*/ */
RemoteAdminStorage.prototype.adminLogout = function (fCallback) RemoteAdminStorage.prototype.adminLogout = function(fCallback)
{ {
this.defaultRequest(fCallback, 'AdminLogout'); this.defaultRequest(fCallback, 'AdminLogout');
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {?} oData * @param {?} oData
*/ */
RemoteAdminStorage.prototype.saveAdminConfig = function (fCallback, oData) RemoteAdminStorage.prototype.saveAdminConfig = function(fCallback, oData)
{ {
this.defaultRequest(fCallback, 'AdminSettingsUpdate', oData); this.defaultRequest(fCallback, 'AdminSettingsUpdate', oData);
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {boolean=} bIncludeAliases = true * @param {boolean=} bIncludeAliases = true
*/ */
RemoteAdminStorage.prototype.domainList = function (fCallback, bIncludeAliases) RemoteAdminStorage.prototype.domainList = function(fCallback, bIncludeAliases)
{ {
bIncludeAliases = Utils.isUnd(bIncludeAliases) ? true : bIncludeAliases; bIncludeAliases = Utils.isUnd(bIncludeAliases) ? true : bIncludeAliases;
this.defaultRequest(fCallback, 'AdminDomainList', { this.defaultRequest(fCallback, 'AdminDomainList', {
'IncludeAliases': bIncludeAliases ? '1' : '0' 'IncludeAliases': bIncludeAliases ? '1' : '0'
}); });
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
*/ */
RemoteAdminStorage.prototype.pluginList = function (fCallback) RemoteAdminStorage.prototype.pluginList = function(fCallback)
{ {
this.defaultRequest(fCallback, 'AdminPluginList'); this.defaultRequest(fCallback, 'AdminPluginList');
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
*/ */
RemoteAdminStorage.prototype.packagesList = function (fCallback) RemoteAdminStorage.prototype.packagesList = function(fCallback)
{ {
this.defaultRequest(fCallback, 'AdminPackagesList'); this.defaultRequest(fCallback, 'AdminPackagesList');
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
*/ */
RemoteAdminStorage.prototype.coreData = function (fCallback) RemoteAdminStorage.prototype.coreData = function(fCallback)
{ {
this.defaultRequest(fCallback, 'AdminCoreData'); this.defaultRequest(fCallback, 'AdminCoreData');
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
*/ */
RemoteAdminStorage.prototype.updateCoreData = function (fCallback) RemoteAdminStorage.prototype.updateCoreData = function(fCallback)
{ {
this.defaultRequest(fCallback, 'AdminUpdateCoreData', {}, 90000); this.defaultRequest(fCallback, 'AdminUpdateCoreData', {}, 90000);
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {Object} oPackage * @param {Object} oPackage
*/ */
RemoteAdminStorage.prototype.packageInstall = function (fCallback, oPackage) RemoteAdminStorage.prototype.packageInstall = function(fCallback, oPackage)
{ {
this.defaultRequest(fCallback, 'AdminPackageInstall', { this.defaultRequest(fCallback, 'AdminPackageInstall', {
'Id': oPackage.id, 'Id': oPackage.id,
'Type': oPackage.type, 'Type': oPackage.type,
'File': oPackage.file 'File': oPackage.file
}, 60000); }, 60000);
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {Object} oPackage * @param {Object} oPackage
*/ */
RemoteAdminStorage.prototype.packageDelete = function (fCallback, oPackage) RemoteAdminStorage.prototype.packageDelete = function(fCallback, oPackage)
{ {
this.defaultRequest(fCallback, 'AdminPackageDelete', { this.defaultRequest(fCallback, 'AdminPackageDelete', {
'Id': oPackage.id 'Id': oPackage.id
}); });
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sName * @param {string} sName
*/ */
RemoteAdminStorage.prototype.domain = function (fCallback, sName) RemoteAdminStorage.prototype.domain = function(fCallback, sName)
{ {
this.defaultRequest(fCallback, 'AdminDomainLoad', { this.defaultRequest(fCallback, 'AdminDomainLoad', {
'Name': sName 'Name': sName
}); });
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sName * @param {string} sName
*/ */
RemoteAdminStorage.prototype.plugin = function (fCallback, sName) RemoteAdminStorage.prototype.plugin = function(fCallback, sName)
{ {
this.defaultRequest(fCallback, 'AdminPluginLoad', { this.defaultRequest(fCallback, 'AdminPluginLoad', {
'Name': sName 'Name': sName
}); });
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sName * @param {string} sName
*/ */
RemoteAdminStorage.prototype.domainDelete = function (fCallback, sName) RemoteAdminStorage.prototype.domainDelete = function(fCallback, sName)
{ {
this.defaultRequest(fCallback, 'AdminDomainDelete', { this.defaultRequest(fCallback, 'AdminDomainDelete', {
'Name': sName 'Name': sName
}); });
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sName * @param {string} sName
* @param {boolean} bDisabled * @param {boolean} bDisabled
*/ */
RemoteAdminStorage.prototype.domainDisable = function (fCallback, sName, bDisabled) RemoteAdminStorage.prototype.domainDisable = function(fCallback, sName, bDisabled)
{ {
return this.defaultRequest(fCallback, 'AdminDomainDisable', { return this.defaultRequest(fCallback, 'AdminDomainDisable', {
Name: sName, Name: sName,
Disabled: bDisabled ? '1' : '0' Disabled: bDisabled ? '1' : '0'
}); });
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {Object} oConfig * @param {Object} oConfig
*/ */
RemoteAdminStorage.prototype.pluginSettingsUpdate = function (fCallback, oConfig) RemoteAdminStorage.prototype.pluginSettingsUpdate = function(fCallback, oConfig)
{ {
return this.defaultRequest(fCallback, 'AdminPluginSettingsUpdate', oConfig); return this.defaultRequest(fCallback, 'AdminPluginSettingsUpdate', oConfig);
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {boolean} bForce * @param {boolean} bForce
*/ */
RemoteAdminStorage.prototype.licensing = function (fCallback, bForce) RemoteAdminStorage.prototype.licensing = function(fCallback, bForce)
{ {
return this.defaultRequest(fCallback, 'AdminLicensing', { return this.defaultRequest(fCallback, 'AdminLicensing', {
Force: bForce ? '1' : '0' Force: bForce ? '1' : '0'
}); });
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sDomain * @param {string} sDomain
* @param {string} sKey * @param {string} sKey
*/ */
RemoteAdminStorage.prototype.licensingActivate = function (fCallback, sDomain, sKey) RemoteAdminStorage.prototype.licensingActivate = function(fCallback, sDomain, sKey)
{ {
return this.defaultRequest(fCallback, 'AdminLicensingActivate', { return this.defaultRequest(fCallback, 'AdminLicensingActivate', {
Domain: sDomain, Domain: sDomain,
Key: sKey Key: sKey
}); });
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sName * @param {string} sName
* @param {boolean} bDisabled * @param {boolean} bDisabled
*/ */
RemoteAdminStorage.prototype.pluginDisable = function (fCallback, sName, bDisabled) RemoteAdminStorage.prototype.pluginDisable = function(fCallback, sName, bDisabled)
{ {
return this.defaultRequest(fCallback, 'AdminPluginDisable', { return this.defaultRequest(fCallback, 'AdminPluginDisable', {
Name: sName, Name: sName,
Disabled: bDisabled ? '1' : '0' Disabled: bDisabled ? '1' : '0'
}); });
}; };
RemoteAdminStorage.prototype.createDomainAlias = function (fCallback, sName, sAlias) RemoteAdminStorage.prototype.createDomainAlias = function(fCallback, sName, sAlias)
{ {
this.defaultRequest(fCallback, 'AdminDomainAliasSave', { this.defaultRequest(fCallback, 'AdminDomainAliasSave', {
Name: sName, Name: sName,
Alias: sAlias Alias: sAlias
}); });
}; };
RemoteAdminStorage.prototype.createOrUpdateDomain = function (fCallback, RemoteAdminStorage.prototype.createOrUpdateDomain = function(fCallback,
bCreate, sName, bCreate, sName,
sIncHost, iIncPort, sIncSecure, bIncShortLogin, sIncHost, iIncPort, sIncSecure, bIncShortLogin,
bUseSieve, sSieveAllowRaw, sSieveHost, iSievePort, sSieveSecure, bUseSieve, sSieveAllowRaw, sSieveHost, iSievePort, sSieveSecure,
sOutHost, iOutPort, sOutSecure, bOutShortLogin, bOutAuth, bOutPhpMail, sOutHost, iOutPort, sOutSecure, bOutShortLogin, bOutAuth, bOutPhpMail,
sWhiteList) sWhiteList)
{ {
this.defaultRequest(fCallback, 'AdminDomainSave', { this.defaultRequest(fCallback, 'AdminDomainSave', {
'Create': bCreate ? '1' : '0', 'Create': bCreate ? '1' : '0',
'Name': sName, 'Name': sName,
@ -253,13 +248,13 @@
'WhiteList': sWhiteList 'WhiteList': sWhiteList
}); });
}; };
RemoteAdminStorage.prototype.testConnectionForDomain = function (fCallback, sName, RemoteAdminStorage.prototype.testConnectionForDomain = function(fCallback, sName,
sIncHost, iIncPort, sIncSecure, sIncHost, iIncPort, sIncSecure,
bUseSieve, sSieveHost, iSievePort, sSieveSecure, bUseSieve, sSieveHost, iSievePort, sSieveSecure,
sOutHost, iOutPort, sOutSecure, bOutAuth, bOutPhpMail) sOutHost, iOutPort, sOutSecure, bOutAuth, bOutPhpMail)
{ {
this.defaultRequest(fCallback, 'AdminDomainTest', { this.defaultRequest(fCallback, 'AdminDomainTest', {
'Name': sName, 'Name': sName,
'IncHost': sIncHost, 'IncHost': sIncHost,
@ -275,34 +270,32 @@
'OutAuth': bOutAuth ? '1' : '0', 'OutAuth': bOutAuth ? '1' : '0',
'OutUsePhpMail': bOutPhpMail ? '1' : '0' 'OutUsePhpMail': bOutPhpMail ? '1' : '0'
}); });
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {?} oData * @param {?} oData
*/ */
RemoteAdminStorage.prototype.testContacts = function (fCallback, oData) RemoteAdminStorage.prototype.testContacts = function(fCallback, oData)
{ {
this.defaultRequest(fCallback, 'AdminContactsTest', oData); this.defaultRequest(fCallback, 'AdminContactsTest', oData);
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {?} oData * @param {?} oData
*/ */
RemoteAdminStorage.prototype.saveNewAdminPassword = function (fCallback, oData) RemoteAdminStorage.prototype.saveNewAdminPassword = function(fCallback, oData)
{ {
this.defaultRequest(fCallback, 'AdminPasswordUpdate', oData); this.defaultRequest(fCallback, 'AdminPasswordUpdate', oData);
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
*/ */
RemoteAdminStorage.prototype.adminPing = function (fCallback) RemoteAdminStorage.prototype.adminPing = function(fCallback)
{ {
this.defaultRequest(fCallback, 'AdminPing'); this.defaultRequest(fCallback, 'AdminPing');
}; };
module.exports = new RemoteAdminStorage(); module.exports = new RemoteAdminStorage();
}());

File diff suppressed because it is too large Load diff

View file

@ -1,9 +1,5 @@
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
$ = require('$'), $ = require('$'),
ko = require('ko'), ko = require('ko'),
@ -13,16 +9,15 @@
Links = require('Common/Links'), Links = require('Common/Links'),
kn = require('Knoin/Knoin'), kn = require('Knoin/Knoin'),
AbstractScreen = require('Knoin/AbstractScreen') AbstractScreen = require('Knoin/AbstractScreen');
;
/** /**
* @constructor * @constructor
* @param {Array} aViewModels * @param {Array} aViewModels
* @extends AbstractScreen * @extends AbstractScreen
*/ */
function AbstractSettingsScreen(aViewModels) function AbstractSettingsScreen(aViewModels)
{ {
AbstractScreen.call(this, 'settings', aViewModels); AbstractScreen.call(this, 'settings', aViewModels);
this.menu = ko.observableArray([]); this.menu = ko.observableArray([]);
@ -31,46 +26,45 @@
this.oViewModelPlace = null; this.oViewModelPlace = null;
this.setupSettings(); this.setupSettings();
} }
_.extend(AbstractSettingsScreen.prototype, AbstractScreen.prototype); _.extend(AbstractSettingsScreen.prototype, AbstractScreen.prototype);
/** /**
* @param {Function=} fCallback * @param {Function=} fCallback
*/ */
AbstractSettingsScreen.prototype.setupSettings = function (fCallback) AbstractSettingsScreen.prototype.setupSettings = function(fCallback)
{ {
if (fCallback) if (fCallback)
{ {
fCallback(); fCallback();
} }
}; };
AbstractSettingsScreen.prototype.onRoute = function (sSubName) AbstractSettingsScreen.prototype.onRoute = function(sSubName)
{ {
var var
self = this, self = this,
oSettingsScreen = null, oSettingsScreen = null,
RoutedSettingsViewModel = null, RoutedSettingsViewModel = null,
oViewModelPlace = null, oViewModelPlace = null,
oViewModelDom = null oViewModelDom = null;
;
RoutedSettingsViewModel = _.find(Globals.aViewModels.settings, function (SettingsViewModel) { RoutedSettingsViewModel = _.find(Globals.aViewModels.settings, function(SettingsViewModel) {
return SettingsViewModel && SettingsViewModel.__rlSettingsData && return SettingsViewModel && SettingsViewModel.__rlSettingsData &&
sSubName === SettingsViewModel.__rlSettingsData.Route; sSubName === SettingsViewModel.__rlSettingsData.Route;
}); });
if (RoutedSettingsViewModel) if (RoutedSettingsViewModel)
{ {
if (_.find(Globals.aViewModels['settings-removed'], function (DisabledSettingsViewModel) { if (_.find(Globals.aViewModels['settings-removed'], function(DisabledSettingsViewModel) {
return DisabledSettingsViewModel && DisabledSettingsViewModel === RoutedSettingsViewModel; return DisabledSettingsViewModel && DisabledSettingsViewModel === RoutedSettingsViewModel;
})) }))
{ {
RoutedSettingsViewModel = null; RoutedSettingsViewModel = null;
} }
if (RoutedSettingsViewModel && _.find(Globals.aViewModels['settings-disabled'], function (DisabledSettingsViewModel) { if (RoutedSettingsViewModel && _.find(Globals.aViewModels['settings-disabled'], function(DisabledSettingsViewModel) {
return DisabledSettingsViewModel && DisabledSettingsViewModel === RoutedSettingsViewModel; return DisabledSettingsViewModel && DisabledSettingsViewModel === RoutedSettingsViewModel;
})) }))
{ {
@ -103,8 +97,12 @@
RoutedSettingsViewModel.__vm = oSettingsScreen; RoutedSettingsViewModel.__vm = oSettingsScreen;
ko.applyBindingAccessorsToNode(oViewModelDom[0], { ko.applyBindingAccessorsToNode(oViewModelDom[0], {
'translatorInit': true, translatorInit: true,
'template': function () { return {'name': RoutedSettingsViewModel.__rlSettingsData.Template}; } template: function() {
return {
name: RoutedSettingsViewModel.__rlSettingsData.Template
};
}
}, oSettingsScreen); }, oSettingsScreen);
Utils.delegateRun(oSettingsScreen, 'onBuild', [oViewModelDom]); Utils.delegateRun(oSettingsScreen, 'onBuild', [oViewModelDom]);
@ -117,7 +115,7 @@
if (oSettingsScreen) if (oSettingsScreen)
{ {
_.defer(function () { _.defer(function() {
// hide // hide
if (self.oCurrentSubScreen) if (self.oCurrentSubScreen)
{ {
@ -136,7 +134,7 @@
Utils.delegateRun(self.oCurrentSubScreen, 'onShow'); Utils.delegateRun(self.oCurrentSubScreen, 'onShow');
Utils.delegateRun(self.oCurrentSubScreen, 'onShowWithDelay', [], 200); Utils.delegateRun(self.oCurrentSubScreen, 'onShowWithDelay', [], 200);
_.each(self.menu(), function (oItem) { _.each(self.menu(), function(oItem) {
oItem.selected(oSettingsScreen && oSettingsScreen.__rlSettingsData && oItem.route === oSettingsScreen.__rlSettingsData.Route); oItem.selected(oSettingsScreen && oSettingsScreen.__rlSettingsData && oItem.route === oSettingsScreen.__rlSettingsData.Route);
}); });
@ -152,22 +150,22 @@
{ {
kn.setHash(Links.settings(), false, true); kn.setHash(Links.settings(), false, true);
} }
}; };
AbstractSettingsScreen.prototype.onHide = function () AbstractSettingsScreen.prototype.onHide = function()
{ {
if (this.oCurrentSubScreen && this.oCurrentSubScreen.viewModelDom) if (this.oCurrentSubScreen && this.oCurrentSubScreen.viewModelDom)
{ {
Utils.delegateRun(this.oCurrentSubScreen, 'onHide'); Utils.delegateRun(this.oCurrentSubScreen, 'onHide');
this.oCurrentSubScreen.viewModelDom.hide(); this.oCurrentSubScreen.viewModelDom.hide();
} }
}; };
AbstractSettingsScreen.prototype.onBuild = function () AbstractSettingsScreen.prototype.onBuild = function()
{ {
_.each(Globals.aViewModels.settings, function (SettingsViewModel) { _.each(Globals.aViewModels.settings, function(SettingsViewModel) {
if (SettingsViewModel && SettingsViewModel.__rlSettingsData && if (SettingsViewModel && SettingsViewModel.__rlSettingsData &&
!_.find(Globals.aViewModels['settings-removed'], function (RemoveSettingsViewModel) { !_.find(Globals.aViewModels['settings-removed'], function(RemoveSettingsViewModel) {
return RemoveSettingsViewModel && RemoveSettingsViewModel === SettingsViewModel; return RemoveSettingsViewModel && RemoveSettingsViewModel === SettingsViewModel;
})) }))
{ {
@ -175,7 +173,7 @@
route: SettingsViewModel.__rlSettingsData.Route, route: SettingsViewModel.__rlSettingsData.Route,
label: SettingsViewModel.__rlSettingsData.Label, label: SettingsViewModel.__rlSettingsData.Label,
selected: ko.observable(false), selected: ko.observable(false),
disabled: !!_.find(Globals.aViewModels['settings-disabled'], function (DisabledSettingsViewModel) { disabled: !!_.find(Globals.aViewModels['settings-disabled'], function(DisabledSettingsViewModel) {
return DisabledSettingsViewModel && DisabledSettingsViewModel === SettingsViewModel; return DisabledSettingsViewModel && DisabledSettingsViewModel === SettingsViewModel;
}) })
}); });
@ -183,32 +181,29 @@
}, this); }, this);
this.oViewModelPlace = $('#rl-content #rl-settings-subscreen'); this.oViewModelPlace = $('#rl-content #rl-settings-subscreen');
}; };
AbstractSettingsScreen.prototype.routes = function () AbstractSettingsScreen.prototype.routes = function()
{ {
var var
DefaultViewModel = _.find(Globals.aViewModels.settings, function (SettingsViewModel) { DefaultViewModel = _.find(Globals.aViewModels.settings, function(SettingsViewModel) {
return SettingsViewModel && SettingsViewModel.__rlSettingsData && SettingsViewModel.__rlSettingsData.IsDefault; return SettingsViewModel && SettingsViewModel.__rlSettingsData && SettingsViewModel.__rlSettingsData.IsDefault;
}), }),
sDefaultRoute = DefaultViewModel && DefaultViewModel.__rlSettingsData ? sDefaultRoute = DefaultViewModel && DefaultViewModel.__rlSettingsData ?
DefaultViewModel.__rlSettingsData.Route : 'general', DefaultViewModel.__rlSettingsData.Route : 'general',
oRules = { oRules = {
subname: /^(.*)$/, subname: /^(.*)$/,
normalize_: function (oRequest, oVals) { normalize_: function(oRequest, oVals) {
oVals.subname = Utils.isUnd(oVals.subname) ? sDefaultRoute : Utils.pString(oVals.subname); oVals.subname = Utils.isUnd(oVals.subname) ? sDefaultRoute : Utils.pString(oVals.subname);
return [oVals.subname]; return [oVals.subname];
} }
} };
;
return [ return [
['{subname}/', oRules], ['{subname}/', oRules],
['{subname}', oRules], ['{subname}', oRules],
['', oRules] ['', oRules]
]; ];
}; };
module.exports = AbstractSettingsScreen; module.exports = AbstractSettingsScreen;
}());

View file

@ -1,32 +1,25 @@
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
AbstractScreen = require('Knoin/AbstractScreen') AbstractScreen = require('Knoin/AbstractScreen');
;
/** /**
* @constructor * @constructor
* @extends AbstractScreen * @extends AbstractScreen
*/ */
function LoginAdminScreen() function LoginAdminScreen()
{ {
AbstractScreen.call(this, 'login', [ AbstractScreen.call(this, 'login', [
require('View/Admin/Login') require('View/Admin/Login')
]); ]);
} }
_.extend(LoginAdminScreen.prototype, AbstractScreen.prototype); _.extend(LoginAdminScreen.prototype, AbstractScreen.prototype);
LoginAdminScreen.prototype.onShow = function () LoginAdminScreen.prototype.onShow = function()
{ {
require('App/Admin').default.setWindowTitle(''); require('App/Admin').default.setWindowTitle('');
}; };
module.exports = LoginAdminScreen; module.exports = LoginAdminScreen;
}());

View file

@ -1,39 +1,34 @@
/* global RL_COMMUNITY */ /* global RL_COMMUNITY */
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
kn = require('Knoin/Knoin'), kn = require('Knoin/Knoin'),
Plugins = require('Common/Plugins'), Plugins = require('Common/Plugins'),
AbstractSettings = require('Screen/AbstractSettings') AbstractSettings = require('Screen/AbstractSettings');
;
/** /**
* @constructor * @constructor
* @extends AbstractSettings * @extends AbstractSettings
*/ */
function SettingsAdminScreen() function SettingsAdminScreen()
{ {
AbstractSettings.call(this, [ AbstractSettings.call(this, [
require('View/Admin/Settings/Menu'), require('View/Admin/Settings/Menu'),
require('View/Admin/Settings/Pane') require('View/Admin/Settings/Pane')
]); ]);
} }
_.extend(SettingsAdminScreen.prototype, AbstractSettings.prototype); _.extend(SettingsAdminScreen.prototype, AbstractSettings.prototype);
/** /**
* @param {Function=} fCallback * @param {Function=} fCallback
*/ */
SettingsAdminScreen.prototype.setupSettings = function (fCallback) SettingsAdminScreen.prototype.setupSettings = function(fCallback)
{ {
kn.addSettingsViewModel(require('Settings/Admin/General'), kn.addSettingsViewModel(require('Settings/Admin/General'),
'AdminSettingsGeneral', 'TABS_LABELS/LABEL_GENERAL_NAME', 'general', true); 'AdminSettingsGeneral', 'TABS_LABELS/LABEL_GENERAL_NAME', 'general', true);
@ -84,13 +79,11 @@
{ {
fCallback(); fCallback();
} }
}; };
SettingsAdminScreen.prototype.onShow = function () SettingsAdminScreen.prototype.onShow = function()
{ {
require('App/Admin').default.setWindowTitle(''); require('App/Admin').default.setWindowTitle('');
}; };
module.exports = SettingsAdminScreen; module.exports = SettingsAdminScreen;
}());

View file

@ -1,32 +1,25 @@
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
AbstractScreen = require('Knoin/AbstractScreen') AbstractScreen = require('Knoin/AbstractScreen');
;
/** /**
* @constructor * @constructor
* @extends AbstractScreen * @extends AbstractScreen
*/ */
function AboutUserScreen() function AboutUserScreen()
{ {
AbstractScreen.call(this, 'about', [ AbstractScreen.call(this, 'about', [
require('View/User/About') require('View/User/About')
]); ]);
} }
_.extend(AboutUserScreen.prototype, AbstractScreen.prototype); _.extend(AboutUserScreen.prototype, AbstractScreen.prototype);
AboutUserScreen.prototype.onShow = function () AboutUserScreen.prototype.onShow = function()
{ {
require('App/User').default.setWindowTitle('RainLoop'); require('App/User').default.setWindowTitle('RainLoop');
}; };
module.exports = AboutUserScreen; module.exports = AboutUserScreen;
}());

View file

@ -1,32 +1,25 @@
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
AbstractScreen = require('Knoin/AbstractScreen') AbstractScreen = require('Knoin/AbstractScreen');
;
/** /**
* @constructor * @constructor
* @extends AbstractScreen * @extends AbstractScreen
*/ */
function LoginUserScreen() function LoginUserScreen()
{ {
AbstractScreen.call(this, 'login', [ AbstractScreen.call(this, 'login', [
require('View/User/Login') require('View/User/Login')
]); ]);
} }
_.extend(LoginUserScreen.prototype, AbstractScreen.prototype); _.extend(LoginUserScreen.prototype, AbstractScreen.prototype);
LoginUserScreen.prototype.onShow = function () LoginUserScreen.prototype.onShow = function()
{ {
require('App/User').default.setWindowTitle(''); require('App/User').default.setWindowTitle('');
}; };
module.exports = LoginUserScreen; module.exports = LoginUserScreen;
}());

View file

@ -1,9 +1,5 @@
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
Enums = require('Common/Enums'), Enums = require('Common/Enums'),
@ -22,15 +18,14 @@
Settings = require('Storage/Settings'), Settings = require('Storage/Settings'),
AbstractScreen = require('Knoin/AbstractScreen') AbstractScreen = require('Knoin/AbstractScreen');
;
/** /**
* @constructor * @constructor
* @extends AbstractScreen * @extends AbstractScreen
*/ */
function MailBoxUserScreen() function MailBoxUserScreen()
{ {
AbstractScreen.call(this, 'mailbox', [ AbstractScreen.call(this, 'mailbox', [
require('View/User/MailBox/SystemDropDown'), require('View/User/MailBox/SystemDropDown'),
require('View/User/MailBox/FolderList'), require('View/User/MailBox/FolderList'),
@ -39,21 +34,20 @@
]); ]);
this.oLastRoute = {}; this.oLastRoute = {};
} }
_.extend(MailBoxUserScreen.prototype, AbstractScreen.prototype); _.extend(MailBoxUserScreen.prototype, AbstractScreen.prototype);
/** /**
* @type {Object} * @type {Object}
*/ */
MailBoxUserScreen.prototype.oLastRoute = {}; MailBoxUserScreen.prototype.oLastRoute = {};
MailBoxUserScreen.prototype.updateWindowTitle = function () MailBoxUserScreen.prototype.updateWindowTitle = function()
{ {
var var
sEmail = AccountStore.email(), sEmail = AccountStore.email(),
nFoldersInboxUnreadCount = FolderStore.foldersInboxUnreadCount() nFoldersInboxUnreadCount = FolderStore.foldersInboxUnreadCount();
;
if (Settings.appSettingsGet('listPermanentFiltered')) if (Settings.appSettingsGet('listPermanentFiltered'))
{ {
@ -63,10 +57,10 @@
require('App/User').default.setWindowTitle(('' === sEmail ? '' : '' + require('App/User').default.setWindowTitle(('' === sEmail ? '' : '' +
(0 < nFoldersInboxUnreadCount ? '(' + nFoldersInboxUnreadCount + ') ' : ' ') + (0 < nFoldersInboxUnreadCount ? '(' + nFoldersInboxUnreadCount + ') ' : ' ') +
sEmail + ' - ') + Translator.i18n('TITLES/MAILBOX')); sEmail + ' - ') + Translator.i18n('TITLES/MAILBOX'));
}; };
MailBoxUserScreen.prototype.onShow = function () MailBoxUserScreen.prototype.onShow = function()
{ {
this.updateWindowTitle(); this.updateWindowTitle();
AppStore.focusedState(Enums.Focused.None); AppStore.focusedState(Enums.Focused.None);
@ -86,20 +80,19 @@
{ {
Globals.leftPanelType(''); Globals.leftPanelType('');
} }
}; };
/** /**
* @param {string} sFolderHash * @param {string} sFolderHash
* @param {number} iPage * @param {number} iPage
* @param {string} sSearch * @param {string} sSearch
*/ */
MailBoxUserScreen.prototype.onRoute = function (sFolderHash, iPage, sSearch) MailBoxUserScreen.prototype.onRoute = function(sFolderHash, iPage, sSearch)
{ {
var var
sThreadUid = sFolderHash.replace(/^(.+)~([\d]+)$/, '$2'), sThreadUid = sFolderHash.replace(/^(.+)~([\d]+)$/, '$2'),
oFolder = Cache.getFolderFromCacheList(Cache.getFolderFullNameRaw( oFolder = Cache.getFolderFromCacheList(Cache.getFolderFullNameRaw(
sFolderHash.replace(/~([\d]+)$/, ''))) sFolderHash.replace(/~([\d]+)$/, '')));
;
if (oFolder) if (oFolder)
{ {
@ -116,26 +109,26 @@
require('App/User').default.reloadMessageList(); require('App/User').default.reloadMessageList();
} }
}; };
MailBoxUserScreen.prototype.onStart = function () MailBoxUserScreen.prototype.onStart = function()
{ {
FolderStore.folderList.subscribe(Utils.windowResizeCallback); FolderStore.folderList.subscribe(Utils.windowResizeCallback);
MessageStore.messageList.subscribe(Utils.windowResizeCallback); MessageStore.messageList.subscribe(Utils.windowResizeCallback);
MessageStore.message.subscribe(Utils.windowResizeCallback); MessageStore.message.subscribe(Utils.windowResizeCallback);
_.delay(function () { _.delay(function() {
SettingsStore.layout.valueHasMutated(); SettingsStore.layout.valueHasMutated();
}, 50); }, 50);
Events.sub('mailbox.inbox-unread-count', _.bind(function (iCount) { Events.sub('mailbox.inbox-unread-count', _.bind(function(iCount) {
FolderStore.foldersInboxUnreadCount(iCount); FolderStore.foldersInboxUnreadCount(iCount);
var sEmail = AccountStore.email(); var sEmail = AccountStore.email();
_.each(AccountStore.accounts(), function (oItem) { _.each(AccountStore.accounts(), function(oItem) {
if (oItem && sEmail === oItem.email) if (oItem && sEmail === oItem.email)
{ {
oItem.count(iCount); oItem.count(iCount);
@ -145,26 +138,26 @@
this.updateWindowTitle(); this.updateWindowTitle();
}, this)); }, this));
}; };
MailBoxUserScreen.prototype.onBuild = function () MailBoxUserScreen.prototype.onBuild = function()
{ {
if (!Globals.bMobileDevice && !Settings.appSettingsGet('mobile')) if (!Globals.bMobileDevice && !Settings.appSettingsGet('mobile'))
{ {
_.defer(function () { _.defer(function() {
require('App/User').default.initHorizontalLayoutResizer(Enums.ClientSideKeyName.MessageListSize); require('App/User').default.initHorizontalLayoutResizer(Enums.ClientSideKeyName.MessageListSize);
}); });
} }
}; };
/** /**
* @return {Array} * @returns {Array}
*/ */
MailBoxUserScreen.prototype.routes = function () MailBoxUserScreen.prototype.routes = function()
{ {
var var
sInboxFolderName = Cache.getFolderInboxName(), sInboxFolderName = Cache.getFolderInboxName(),
fNormS = function (oRequest, oVals) { fNormS = function(oRequest, oVals) {
oVals[0] = Utils.pString(oVals[0]); oVals[0] = Utils.pString(oVals[0]);
oVals[1] = Utils.pInt(oVals[1]); oVals[1] = Utils.pInt(oVals[1]);
oVals[1] = 0 >= oVals[1] ? 1 : oVals[1]; oVals[1] = 0 >= oVals[1] ? 1 : oVals[1];
@ -178,7 +171,7 @@
return [decodeURI(oVals[0]), oVals[1], decodeURI(oVals[2])]; return [decodeURI(oVals[0]), oVals[1], decodeURI(oVals[2])];
}, },
fNormD = function (oRequest, oVals) { fNormD = function(oRequest, oVals) {
oVals[0] = Utils.pString(oVals[0]); oVals[0] = Utils.pString(oVals[0]);
oVals[1] = Utils.pString(oVals[1]); oVals[1] = Utils.pString(oVals[1]);
@ -188,8 +181,7 @@
} }
return [decodeURI(oVals[0]), 1, decodeURI(oVals[1])]; return [decodeURI(oVals[0]), 1, decodeURI(oVals[1])];
} };
;
return [ return [
[/^([a-zA-Z0-9~]+)\/p([1-9][0-9]*)\/(.+)\/?$/, {'normalize_': fNormS}], [/^([a-zA-Z0-9~]+)\/p([1-9][0-9]*)\/(.+)\/?$/, {'normalize_': fNormS}],
@ -197,8 +189,6 @@
[/^([a-zA-Z0-9~]+)\/(.+)\/?$/, {'normalize_': fNormD}], [/^([a-zA-Z0-9~]+)\/(.+)\/?$/, {'normalize_': fNormD}],
[/^([^\/]*)$/, {'normalize_': fNormS}] [/^([^\/]*)$/, {'normalize_': fNormS}]
]; ];
}; };
module.exports = MailBoxUserScreen; module.exports = MailBoxUserScreen;
}());

View file

@ -1,9 +1,5 @@
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
Enums = require('Common/Enums'), Enums = require('Common/Enums'),
@ -18,35 +14,34 @@
kn = require('Knoin/Knoin'), kn = require('Knoin/Knoin'),
AbstractSettingsScreen = require('Screen/AbstractSettings') AbstractSettingsScreen = require('Screen/AbstractSettings');
;
/** /**
* @constructor * @constructor
* @extends AbstractSettingsScreen * @extends AbstractSettingsScreen
*/ */
function SettingsUserScreen() function SettingsUserScreen()
{ {
AbstractSettingsScreen.call(this, [ AbstractSettingsScreen.call(this, [
require('View/User/Settings/SystemDropDown'), require('View/User/Settings/SystemDropDown'),
require('View/User/Settings/Menu'), require('View/User/Settings/Menu'),
require('View/User/Settings/Pane') require('View/User/Settings/Pane')
]); ]);
Translator.initOnStartOrLangChange(function () { Translator.initOnStartOrLangChange(function() {
this.sSettingsTitle = Translator.i18n('TITLES/SETTINGS'); this.sSettingsTitle = Translator.i18n('TITLES/SETTINGS');
}, this, function () { }, this, function() {
this.setSettingsTitle(); this.setSettingsTitle();
}); });
} }
_.extend(SettingsUserScreen.prototype, AbstractSettingsScreen.prototype); _.extend(SettingsUserScreen.prototype, AbstractSettingsScreen.prototype);
/** /**
* @param {Function=} fCallback * @param {Function=} fCallback
*/ */
SettingsUserScreen.prototype.setupSettings = function (fCallback) SettingsUserScreen.prototype.setupSettings = function(fCallback)
{ {
if (!Settings.capa(Enums.Capa.Settings)) if (!Settings.capa(Enums.Capa.Settings))
{ {
if (fCallback) if (fCallback)
@ -132,10 +127,10 @@
} }
return true; return true;
}; };
SettingsUserScreen.prototype.onShow = function () SettingsUserScreen.prototype.onShow = function()
{ {
this.setSettingsTitle(); this.setSettingsTitle();
Globals.keyScope(Enums.KeyState.Settings); Globals.keyScope(Enums.KeyState.Settings);
Globals.leftPanelType(''); Globals.leftPanelType('');
@ -144,14 +139,12 @@
{ {
Globals.leftPanelDisabled(true); Globals.leftPanelDisabled(true);
} }
}; };
SettingsUserScreen.prototype.setSettingsTitle = function () SettingsUserScreen.prototype.setSettingsTitle = function()
{ {
var sEmail = AccountStore.email(); var sEmail = AccountStore.email();
require('App/User').default.setWindowTitle(('' === sEmail ? '' : sEmail + ' - ') + this.sSettingsTitle); require('App/User').default.setWindowTitle(('' === sEmail ? '' : sEmail + ' - ') + this.sSettingsTitle);
}; };
module.exports = SettingsUserScreen; module.exports = SettingsUserScreen;
}());

View file

@ -1,25 +1,20 @@
/* global RL_COMMUNITY */ /* global RL_COMMUNITY */
(function () { var
'use strict';
var
ko = require('ko'), ko = require('ko'),
Translator = require('Common/Translator'), Translator = require('Common/Translator'),
Settings = require('Storage/Settings'), Settings = require('Storage/Settings'),
CoreStore = require('Stores/Admin/Core'), CoreStore = require('Stores/Admin/Core'),
AppStore = require('Stores/Admin/App') AppStore = require('Stores/Admin/App');
;
/** /**
* @constructor * @constructor
*/ */
function AboutAdminSettings() function AboutAdminSettings()
{ {
this.version = ko.observable(Settings.appSettingsGet('version')); this.version = ko.observable(Settings.appSettingsGet('version'));
this.access = ko.observable(!!Settings.settingsGet('CoreAccess')); this.access = ko.observable(!!Settings.settingsGet('CoreAccess'));
this.errorDesc = ko.observable(''); this.errorDesc = ko.observable('');
@ -39,20 +34,19 @@
this.community = RL_COMMUNITY || AppStore.community(); this.community = RL_COMMUNITY || AppStore.community();
this.coreRemoteVersionHtmlDesc = ko.computed(function () { this.coreRemoteVersionHtmlDesc = ko.computed(function() {
Translator.trigger(); Translator.trigger();
return Translator.i18n('TAB_ABOUT/HTML_NEW_VERSION', {'VERSION': this.coreRemoteVersion()}); return Translator.i18n('TAB_ABOUT/HTML_NEW_VERSION', {'VERSION': this.coreRemoteVersion()});
}, this); }, this);
this.statusType = ko.computed(function () { this.statusType = ko.computed(function() {
var var
sType = '', sType = '',
iVersionCompare = this.coreVersionCompare(), iVersionCompare = this.coreVersionCompare(),
bChecking = this.coreChecking(), bChecking = this.coreChecking(),
bUpdating = this.coreUpdating(), bUpdating = this.coreUpdating(),
bReal = this.coreReal() bReal = this.coreReal();
;
if (bChecking) if (bChecking)
{ {
@ -79,24 +73,22 @@
return sType; return sType;
}, this); }, this);
} }
AboutAdminSettings.prototype.onBuild = function () AboutAdminSettings.prototype.onBuild = function()
{ {
if (this.access() && !this.community) if (this.access() && !this.community)
{ {
require('App/Admin').default.reloadCoreData(); require('App/Admin').default.reloadCoreData();
} }
}; };
AboutAdminSettings.prototype.updateCoreData = function () AboutAdminSettings.prototype.updateCoreData = function()
{ {
if (!this.coreUpdating() && !this.community) if (!this.coreUpdating() && !this.community)
{ {
require('App/Admin').default.updateCoreData(); require('App/Admin').default.updateCoreData();
} }
}; };
module.exports = AboutAdminSettings; module.exports = AboutAdminSettings;
}());

View file

@ -1,28 +1,22 @@
/* global RL_COMMUNITY */ /* global RL_COMMUNITY */
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
ko = require('ko'), ko = require('ko'),
Utils = require('Common/Utils'), Utils = require('Common/Utils'),
Translator = require('Common/Translator') Translator = require('Common/Translator');
;
/** /**
* @constructor * @constructor
*/ */
function BrandingAdminSettings() function BrandingAdminSettings()
{ {
var var
Enums = require('Common/Enums'), Enums = require('Common/Enums'),
Settings = require('Storage/Settings'), Settings = require('Storage/Settings'),
AppStore = require('Stores/Admin/App') AppStore = require('Stores/Admin/App');
;
this.capa = AppStore.prem; this.capa = AppStore.prem;
@ -68,7 +62,7 @@
this.welcomePageDisplay = ko.observable(Settings.settingsGet('WelcomePageDisplay')); this.welcomePageDisplay = ko.observable(Settings.settingsGet('WelcomePageDisplay'));
this.welcomePageDisplay.trigger = ko.observable(Enums.SaveSettingsStep.Idle); this.welcomePageDisplay.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.welcomePageDisplay.options = ko.computed(function () { this.welcomePageDisplay.options = ko.computed(function() {
Translator.trigger(); Translator.trigger();
return [ return [
{'optValue': 'none', 'optText': Translator.i18n('TAB_BRANDING/OPTION_WELCOME_PAGE_DISPLAY_NONE')}, {'optValue': 'none', 'optText': Translator.i18n('TAB_BRANDING/OPTION_WELCOME_PAGE_DISPLAY_NONE')},
@ -80,44 +74,40 @@
this.loginPowered = ko.observable(!!Settings.settingsGet('LoginPowered')); this.loginPowered = ko.observable(!!Settings.settingsGet('LoginPowered'));
this.community = RL_COMMUNITY || AppStore.community(); this.community = RL_COMMUNITY || AppStore.community();
} }
BrandingAdminSettings.prototype.onBuild = function () BrandingAdminSettings.prototype.onBuild = function()
{ {
var var
self = this, self = this,
Remote = require('Remote/Admin/Ajax') Remote = require('Remote/Admin/Ajax');
;
_.delay(function () { _.delay(function() {
var var
f1 = Utils.settingsSaveHelperSimpleFunction(self.title.trigger, self), f1 = Utils.settingsSaveHelperSimpleFunction(self.title.trigger, self),
f2 = Utils.settingsSaveHelperSimpleFunction(self.loadingDesc.trigger, self), f2 = Utils.settingsSaveHelperSimpleFunction(self.loadingDesc.trigger, self),
f3 = Utils.settingsSaveHelperSimpleFunction(self.faviconUrl.trigger, self) f3 = Utils.settingsSaveHelperSimpleFunction(self.faviconUrl.trigger, self);
;
self.title.subscribe(function (sValue) { self.title.subscribe(function(sValue) {
Remote.saveAdminConfig(f1, { Remote.saveAdminConfig(f1, {
'Title': Utils.trim(sValue) 'Title': Utils.trim(sValue)
}); });
}); });
self.loadingDesc.subscribe(function (sValue) { self.loadingDesc.subscribe(function(sValue) {
Remote.saveAdminConfig(f2, { Remote.saveAdminConfig(f2, {
'LoadingDescription': Utils.trim(sValue) 'LoadingDescription': Utils.trim(sValue)
}); });
}); });
self.faviconUrl.subscribe(function (sValue) { self.faviconUrl.subscribe(function(sValue) {
Remote.saveAdminConfig(f3, { Remote.saveAdminConfig(f3, {
'FaviconUrl': Utils.trim(sValue) 'FaviconUrl': Utils.trim(sValue)
}); });
}); });
}, 50); }, 50);
}; };
module.exports = BrandingAdminSettings; module.exports = BrandingAdminSettings;
}());

View file

@ -1,9 +1,5 @@
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
ko = require('ko'), ko = require('ko'),
@ -12,17 +8,15 @@
Translator = require('Common/Translator'), Translator = require('Common/Translator'),
Settings = require('Storage/Settings') Settings = require('Storage/Settings');
;
/** /**
* @constructor * @constructor
*/ */
function ContactsAdminSettings() function ContactsAdminSettings()
{ {
var var
Remote = require('Remote/Admin/Ajax') Remote = require('Remote/Admin/Ajax');
;
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender; this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
this.enableContacts = ko.observable(!!Settings.settingsGet('ContactsEnable')); this.enableContacts = ko.observable(!!Settings.settingsGet('ContactsEnable'));
@ -44,11 +38,11 @@
case 'pgsql': case 'pgsql':
sName = 'PostgreSQL'; sName = 'PostgreSQL';
break; break;
// no default
} }
return sName; return sName;
} };
;
if (Settings.settingsGet('SQLiteIsSupported')) if (Settings.settingsGet('SQLiteIsSupported'))
{ {
@ -66,7 +60,7 @@
this.contactsSupported = 0 < aSupportedTypes.length; this.contactsSupported = 0 < aSupportedTypes.length;
this.contactsTypes = ko.observableArray([]); this.contactsTypes = ko.observableArray([]);
this.contactsTypesOptions = this.contactsTypes.map(function (sValue) { this.contactsTypesOptions = this.contactsTypes.map(function(sValue) {
var bDisabled = -1 === Utils.inArray(sValue, aSupportedTypes); var bDisabled = -1 === Utils.inArray(sValue, aSupportedTypes);
return { return {
'id': sValue, 'id': sValue,
@ -81,7 +75,7 @@
this.mainContactsType = ko.computed({ this.mainContactsType = ko.computed({
'owner': this, 'owner': this,
'read': this.contactsType, 'read': this.contactsType,
'write': function (sValue) { 'write': function(sValue) {
if (sValue !== this.contactsType()) if (sValue !== this.contactsType())
{ {
if (-1 < Utils.inArray(sValue, aSupportedTypes)) if (-1 < Utils.inArray(sValue, aSupportedTypes))
@ -100,7 +94,7 @@
} }
}).extend({'notify': 'always'}); }).extend({'notify': 'always'});
this.contactsType.subscribe(function () { this.contactsType.subscribe(function() {
this.testContactsSuccess(false); this.testContactsSuccess(false);
this.testContactsError(false); this.testContactsError(false);
this.testContactsErrorMessage(''); this.testContactsErrorMessage('');
@ -120,7 +114,7 @@
this.testContactsError = ko.observable(false); this.testContactsError = ko.observable(false);
this.testContactsErrorMessage = ko.observable(''); this.testContactsErrorMessage = ko.observable('');
this.testContactsCommand = Utils.createCommand(this, function () { this.testContactsCommand = Utils.createCommand(this, function() {
this.testContactsSuccess(false); this.testContactsSuccess(false);
this.testContactsError(false); this.testContactsError(false);
@ -134,17 +128,17 @@
'ContactsPdoPassword': this.pdoPassword() 'ContactsPdoPassword': this.pdoPassword()
}); });
}, function () { }, function() {
return '' !== this.pdoDsn() && '' !== this.pdoUser(); return '' !== this.pdoDsn() && '' !== this.pdoUser();
}); });
this.contactsType(Settings.settingsGet('ContactsPdoType')); this.contactsType(Settings.settingsGet('ContactsPdoType'));
this.onTestContactsResponse = _.bind(this.onTestContactsResponse, this); this.onTestContactsResponse = _.bind(this.onTestContactsResponse, this);
} }
ContactsAdminSettings.prototype.onTestContactsResponse = function (sResult, oData) ContactsAdminSettings.prototype.onTestContactsResponse = function(sResult, oData)
{ {
this.testContactsSuccess(false); this.testContactsSuccess(false);
this.testContactsError(false); this.testContactsError(false);
this.testContactsErrorMessage(''); this.testContactsErrorMessage('');
@ -167,68 +161,66 @@
} }
this.testing(false); this.testing(false);
}; };
ContactsAdminSettings.prototype.onShow = function () ContactsAdminSettings.prototype.onShow = function()
{ {
this.testContactsSuccess(false); this.testContactsSuccess(false);
this.testContactsError(false); this.testContactsError(false);
this.testContactsErrorMessage(''); this.testContactsErrorMessage('');
}; };
ContactsAdminSettings.prototype.onBuild = function () ContactsAdminSettings.prototype.onBuild = function()
{ {
var var
self = this, self = this,
Remote = require('Remote/Admin/Ajax') Remote = require('Remote/Admin/Ajax');
;
_.delay(function () { _.delay(function() {
var var
f1 = Utils.settingsSaveHelperSimpleFunction(self.pdoDsnTrigger, self), f1 = Utils.settingsSaveHelperSimpleFunction(self.pdoDsnTrigger, self),
f3 = Utils.settingsSaveHelperSimpleFunction(self.pdoUserTrigger, self), f3 = Utils.settingsSaveHelperSimpleFunction(self.pdoUserTrigger, self),
f4 = Utils.settingsSaveHelperSimpleFunction(self.pdoPasswordTrigger, self), f4 = Utils.settingsSaveHelperSimpleFunction(self.pdoPasswordTrigger, self),
f5 = Utils.settingsSaveHelperSimpleFunction(self.contactsTypeTrigger, self) f5 = Utils.settingsSaveHelperSimpleFunction(self.contactsTypeTrigger, self);
;
self.enableContacts.subscribe(function (bValue) { self.enableContacts.subscribe(function(bValue) {
Remote.saveAdminConfig(null, { Remote.saveAdminConfig(null, {
'ContactsEnable': bValue ? '1' : '0' 'ContactsEnable': bValue ? '1' : '0'
}); });
}); });
self.contactsSharing.subscribe(function (bValue) { self.contactsSharing.subscribe(function(bValue) {
Remote.saveAdminConfig(null, { Remote.saveAdminConfig(null, {
'ContactsSharing': bValue ? '1' : '0' 'ContactsSharing': bValue ? '1' : '0'
}); });
}); });
self.contactsSync.subscribe(function (bValue) { self.contactsSync.subscribe(function(bValue) {
Remote.saveAdminConfig(null, { Remote.saveAdminConfig(null, {
'ContactsSync': bValue ? '1' : '0' 'ContactsSync': bValue ? '1' : '0'
}); });
}); });
self.contactsType.subscribe(function (sValue) { self.contactsType.subscribe(function(sValue) {
Remote.saveAdminConfig(f5, { Remote.saveAdminConfig(f5, {
'ContactsPdoType': sValue 'ContactsPdoType': sValue
}); });
}); });
self.pdoDsn.subscribe(function (sValue) { self.pdoDsn.subscribe(function(sValue) {
Remote.saveAdminConfig(f1, { Remote.saveAdminConfig(f1, {
'ContactsPdoDsn': Utils.trim(sValue) 'ContactsPdoDsn': Utils.trim(sValue)
}); });
}); });
self.pdoUser.subscribe(function (sValue) { self.pdoUser.subscribe(function(sValue) {
Remote.saveAdminConfig(f3, { Remote.saveAdminConfig(f3, {
'ContactsPdoUser': Utils.trim(sValue) 'ContactsPdoUser': Utils.trim(sValue)
}); });
}); });
self.pdoPassword.subscribe(function (sValue) { self.pdoPassword.subscribe(function(sValue) {
Remote.saveAdminConfig(f4, { Remote.saveAdminConfig(f4, {
'ContactsPdoPassword': Utils.trim(sValue) 'ContactsPdoPassword': Utils.trim(sValue)
}); });
@ -237,8 +229,6 @@
self.contactsType(Settings.settingsGet('ContactsPdoType')); self.contactsType(Settings.settingsGet('ContactsPdoType'));
}, 50); }, 50);
}; };
module.exports = ContactsAdminSettings; module.exports = ContactsAdminSettings;
}());

View file

@ -1,26 +1,21 @@
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
ko = require('ko'), ko = require('ko'),
Enums = require('Common/Enums'), Enums = require('Common/Enums'),
DomainStore = require('Stores/Admin/Domain'), DomainStore = require('Stores/Admin/Domain'),
Remote = require('Remote/Admin/Ajax') Remote = require('Remote/Admin/Ajax');
;
/** /**
* @constructor * @constructor
*/ */
function DomainsAdminSettings() function DomainsAdminSettings()
{ {
this.domains = DomainStore.domains; this.domains = DomainStore.domains;
this.visibility = ko.computed(function () { this.visibility = ko.computed(function() {
return this.domains.loading() ? 'visible' : 'hidden'; return this.domains.loading() ? 'visible' : 'hidden';
}, this); }, this);
@ -28,59 +23,56 @@
this.onDomainListChangeRequest = _.bind(this.onDomainListChangeRequest, this); this.onDomainListChangeRequest = _.bind(this.onDomainListChangeRequest, this);
this.onDomainLoadRequest = _.bind(this.onDomainLoadRequest, this); this.onDomainLoadRequest = _.bind(this.onDomainLoadRequest, this);
} }
DomainsAdminSettings.prototype.createDomain = function () DomainsAdminSettings.prototype.createDomain = function()
{ {
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Domain')); require('Knoin/Knoin').showScreenPopup(require('View/Popup/Domain'));
}; };
DomainsAdminSettings.prototype.createDomainAlias = function () DomainsAdminSettings.prototype.createDomainAlias = function()
{ {
require('Knoin/Knoin').showScreenPopup(require('View/Popup/DomainAlias')); require('Knoin/Knoin').showScreenPopup(require('View/Popup/DomainAlias'));
}; };
DomainsAdminSettings.prototype.deleteDomain = function (oDomain) DomainsAdminSettings.prototype.deleteDomain = function(oDomain)
{ {
this.domains.remove(oDomain); this.domains.remove(oDomain);
Remote.domainDelete(this.onDomainListChangeRequest, oDomain.name); Remote.domainDelete(this.onDomainListChangeRequest, oDomain.name);
}; };
DomainsAdminSettings.prototype.disableDomain = function (oDomain) DomainsAdminSettings.prototype.disableDomain = function(oDomain)
{ {
oDomain.disabled(!oDomain.disabled()); oDomain.disabled(!oDomain.disabled());
Remote.domainDisable(this.onDomainListChangeRequest, oDomain.name, oDomain.disabled()); Remote.domainDisable(this.onDomainListChangeRequest, oDomain.name, oDomain.disabled());
}; };
DomainsAdminSettings.prototype.onBuild = function (oDom) DomainsAdminSettings.prototype.onBuild = function(oDom)
{ {
var self = this; var self = this;
oDom oDom
.on('click', '.b-admin-domains-list-table .e-item .e-action', function () { .on('click', '.b-admin-domains-list-table .e-item .e-action', function() {
var oDomainItem = ko.dataFor(this); var oDomainItem = ko.dataFor(this);
if (oDomainItem) if (oDomainItem)
{ {
Remote.domain(self.onDomainLoadRequest, oDomainItem.name); Remote.domain(self.onDomainLoadRequest, oDomainItem.name);
} }
}) });
;
require('App/Admin').default.reloadDomainList(); require('App/Admin').default.reloadDomainList();
}; };
DomainsAdminSettings.prototype.onDomainLoadRequest = function (sResult, oData) DomainsAdminSettings.prototype.onDomainLoadRequest = function(sResult, oData)
{ {
if (Enums.StorageResultType.Success === sResult && oData && oData.Result) if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{ {
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Domain'), [oData.Result]); require('Knoin/Knoin').showScreenPopup(require('View/Popup/Domain'), [oData.Result]);
} }
}; };
DomainsAdminSettings.prototype.onDomainListChangeRequest = function () DomainsAdminSettings.prototype.onDomainListChangeRequest = function()
{ {
require('App/Admin').default.reloadDomainList(); require('App/Admin').default.reloadDomainList();
}; };
module.exports = DomainsAdminSettings; module.exports = DomainsAdminSettings;
}());

View file

@ -1,9 +1,5 @@
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
ko = require('ko'), ko = require('ko'),
@ -17,14 +13,13 @@
AppAdminStore = require('Stores/Admin/App'), AppAdminStore = require('Stores/Admin/App'),
CapaAdminStore = require('Stores/Admin/Capa'), CapaAdminStore = require('Stores/Admin/Capa'),
Settings = require('Storage/Settings') Settings = require('Storage/Settings');
;
/** /**
* @constructor * @constructor
*/ */
function GeneralAdminSettings() function GeneralAdminSettings()
{ {
this.language = LanguageStore.language; this.language = LanguageStore.language;
this.languages = LanguageStore.languages; this.languages = LanguageStore.languages;
this.languageAdmin = LanguageStore.languageAdmin; this.languageAdmin = LanguageStore.languageAdmin;
@ -51,8 +46,8 @@
this.uploadData.post_max_size ? 'post_max_size = ' + this.uploadData.post_max_size : '' this.uploadData.post_max_size ? 'post_max_size = ' + this.uploadData.post_max_size : ''
].join('') : ''; ].join('') : '';
this.themesOptions = ko.computed(function () { this.themesOptions = ko.computed(function() {
return _.map(this.themes(), function (sTheme) { return _.map(this.themes(), function(sTheme) {
return { return {
optValue: sTheme, optValue: sTheme,
optText: Utils.convertThemeName(sTheme) optText: Utils.convertThemeName(sTheme)
@ -60,11 +55,11 @@
}); });
}, this); }, this);
this.languageFullName = ko.computed(function () { this.languageFullName = ko.computed(function() {
return Utils.convertLangName(this.language()); return Utils.convertLangName(this.language());
}, this); }, this);
this.languageAdminFullName = ko.computed(function () { this.languageAdminFullName = ko.computed(function() {
return Utils.convertLangName(this.languageAdmin()); return Utils.convertLangName(this.languageAdmin());
}, this); }, this);
@ -72,44 +67,42 @@
this.languageTrigger = ko.observable(Enums.SaveSettingsStep.Idle); this.languageTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.languageAdminTrigger = ko.observable(Enums.SaveSettingsStep.Idle).extend({'throttle': 100}); this.languageAdminTrigger = ko.observable(Enums.SaveSettingsStep.Idle).extend({'throttle': 100});
this.themeTrigger = ko.observable(Enums.SaveSettingsStep.Idle); this.themeTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
} }
GeneralAdminSettings.prototype.onBuild = function () GeneralAdminSettings.prototype.onBuild = function()
{ {
var var
self = this, self = this,
Remote = require('Remote/Admin/Ajax') Remote = require('Remote/Admin/Ajax');
;
_.delay(function () { _.delay(function() {
var var
f1 = Utils.settingsSaveHelperSimpleFunction(self.attachmentLimitTrigger, self), f1 = Utils.settingsSaveHelperSimpleFunction(self.attachmentLimitTrigger, self),
f2 = Utils.settingsSaveHelperSimpleFunction(self.languageTrigger, self), f2 = Utils.settingsSaveHelperSimpleFunction(self.languageTrigger, self),
f3 = Utils.settingsSaveHelperSimpleFunction(self.themeTrigger, self), f3 = Utils.settingsSaveHelperSimpleFunction(self.themeTrigger, self),
fReloadLanguageHelper = function (iSaveSettingsStep) { fReloadLanguageHelper = function(iSaveSettingsStep) {
return function() { return function() {
self.languageAdminTrigger(iSaveSettingsStep); self.languageAdminTrigger(iSaveSettingsStep);
_.delay(function () { _.delay(function() {
self.languageAdminTrigger(Enums.SaveSettingsStep.Idle); self.languageAdminTrigger(Enums.SaveSettingsStep.Idle);
}, 1000); }, 1000);
}; };
} };
;
self.mainAttachmentLimit.subscribe(function (sValue) { self.mainAttachmentLimit.subscribe(function(sValue) {
Remote.saveAdminConfig(f1, { Remote.saveAdminConfig(f1, {
'AttachmentLimit': Utils.pInt(sValue) 'AttachmentLimit': Utils.pInt(sValue)
}); });
}); });
self.language.subscribe(function (sValue) { self.language.subscribe(function(sValue) {
Remote.saveAdminConfig(f2, { Remote.saveAdminConfig(f2, {
'Language': Utils.trim(sValue) 'Language': Utils.trim(sValue)
}); });
}); });
self.languageAdmin.subscribe(function (sValue) { self.languageAdmin.subscribe(function(sValue) {
self.languageAdminTrigger(Enums.SaveSettingsStep.Animate); self.languageAdminTrigger(Enums.SaveSettingsStep.Animate);
@ -124,7 +117,7 @@
}); });
self.theme.subscribe(function (sValue) { self.theme.subscribe(function(sValue) {
Utils.changeTheme(sValue, self.themeTrigger); Utils.changeTheme(sValue, self.themeTrigger);
@ -133,79 +126,77 @@
}); });
}); });
self.capaAdditionalAccounts.subscribe(function (bValue) { self.capaAdditionalAccounts.subscribe(function(bValue) {
Remote.saveAdminConfig(null, { Remote.saveAdminConfig(null, {
'CapaAdditionalAccounts': bValue ? '1' : '0' 'CapaAdditionalAccounts': bValue ? '1' : '0'
}); });
}); });
self.capaIdentities.subscribe(function (bValue) { self.capaIdentities.subscribe(function(bValue) {
Remote.saveAdminConfig(null, { Remote.saveAdminConfig(null, {
'CapaIdentities': bValue ? '1' : '0' 'CapaIdentities': bValue ? '1' : '0'
}); });
}); });
self.capaTemplates.subscribe(function (bValue) { self.capaTemplates.subscribe(function(bValue) {
Remote.saveAdminConfig(null, { Remote.saveAdminConfig(null, {
'CapaTemplates': bValue ? '1' : '0' 'CapaTemplates': bValue ? '1' : '0'
}); });
}); });
self.capaGravatar.subscribe(function (bValue) { self.capaGravatar.subscribe(function(bValue) {
Remote.saveAdminConfig(null, { Remote.saveAdminConfig(null, {
'CapaGravatar': bValue ? '1' : '0' 'CapaGravatar': bValue ? '1' : '0'
}); });
}); });
self.capaAttachmentThumbnails.subscribe(function (bValue) { self.capaAttachmentThumbnails.subscribe(function(bValue) {
Remote.saveAdminConfig(null, { Remote.saveAdminConfig(null, {
'CapaAttachmentThumbnails': bValue ? '1' : '0' 'CapaAttachmentThumbnails': bValue ? '1' : '0'
}); });
}); });
self.capaThemes.subscribe(function (bValue) { self.capaThemes.subscribe(function(bValue) {
Remote.saveAdminConfig(null, { Remote.saveAdminConfig(null, {
'CapaThemes': bValue ? '1' : '0' 'CapaThemes': bValue ? '1' : '0'
}); });
}); });
self.capaUserBackground.subscribe(function (bValue) { self.capaUserBackground.subscribe(function(bValue) {
Remote.saveAdminConfig(null, { Remote.saveAdminConfig(null, {
'CapaUserBackground': bValue ? '1' : '0' 'CapaUserBackground': bValue ? '1' : '0'
}); });
}); });
self.allowLanguagesOnSettings.subscribe(function (bValue) { self.allowLanguagesOnSettings.subscribe(function(bValue) {
Remote.saveAdminConfig(null, { Remote.saveAdminConfig(null, {
'AllowLanguagesOnSettings': bValue ? '1' : '0' 'AllowLanguagesOnSettings': bValue ? '1' : '0'
}); });
}); });
}, 50); }, 50);
}; };
GeneralAdminSettings.prototype.selectLanguage = function () GeneralAdminSettings.prototype.selectLanguage = function()
{ {
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Languages'), [ require('Knoin/Knoin').showScreenPopup(require('View/Popup/Languages'), [
this.language, this.languages(), LanguageStore.userLanguage() this.language, this.languages(), LanguageStore.userLanguage()
]); ]);
}; };
GeneralAdminSettings.prototype.selectLanguageAdmin = function () GeneralAdminSettings.prototype.selectLanguageAdmin = function()
{ {
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Languages'), [ require('Knoin/Knoin').showScreenPopup(require('View/Popup/Languages'), [
this.languageAdmin, this.languagesAdmin(), LanguageStore.userLanguageAdmin() this.languageAdmin, this.languagesAdmin(), LanguageStore.userLanguageAdmin()
]); ]);
}; };
/** /**
* @return {string} * @returns {string}
*/ */
GeneralAdminSettings.prototype.phpInfoLink = function () GeneralAdminSettings.prototype.phpInfoLink = function()
{ {
return Links.phpInfo(); return Links.phpInfo();
}; };
module.exports = GeneralAdminSettings; module.exports = GeneralAdminSettings;
}());

View file

@ -1,9 +1,5 @@
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
ko = require('ko'), ko = require('ko'),
@ -12,14 +8,13 @@
AppAdminStore = require('Stores/Admin/App'), AppAdminStore = require('Stores/Admin/App'),
Settings = require('Storage/Settings') Settings = require('Storage/Settings');
;
/** /**
* @constructor * @constructor
*/ */
function LoginAdminSettings() function LoginAdminSettings()
{ {
this.determineUserLanguage = AppAdminStore.determineUserLanguage; this.determineUserLanguage = AppAdminStore.determineUserLanguage;
this.determineUserDomain = AppAdminStore.determineUserDomain; this.determineUserDomain = AppAdminStore.determineUserDomain;
@ -29,46 +24,43 @@
this.defaultDomainTrigger = ko.observable(Enums.SaveSettingsStep.Idle); this.defaultDomainTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.dummy = ko.observable(false); this.dummy = ko.observable(false);
} }
LoginAdminSettings.prototype.onBuild = function () LoginAdminSettings.prototype.onBuild = function()
{ {
var var
self = this, self = this,
Remote = require('Remote/Admin/Ajax') Remote = require('Remote/Admin/Ajax');
;
_.delay(function () { _.delay(function() {
var f1 = Utils.settingsSaveHelperSimpleFunction(self.defaultDomainTrigger, self); var f1 = Utils.settingsSaveHelperSimpleFunction(self.defaultDomainTrigger, self);
self.determineUserLanguage.subscribe(function (bValue) { self.determineUserLanguage.subscribe(function(bValue) {
Remote.saveAdminConfig(null, { Remote.saveAdminConfig(null, {
'DetermineUserLanguage': bValue ? '1' : '0' 'DetermineUserLanguage': bValue ? '1' : '0'
}); });
}); });
self.determineUserDomain.subscribe(function (bValue) { self.determineUserDomain.subscribe(function(bValue) {
Remote.saveAdminConfig(null, { Remote.saveAdminConfig(null, {
'DetermineUserDomain': bValue ? '1' : '0' 'DetermineUserDomain': bValue ? '1' : '0'
}); });
}); });
self.allowLanguagesOnLogin.subscribe(function (bValue) { self.allowLanguagesOnLogin.subscribe(function(bValue) {
Remote.saveAdminConfig(null, { Remote.saveAdminConfig(null, {
'AllowLanguagesOnLogin': bValue ? '1' : '0' 'AllowLanguagesOnLogin': bValue ? '1' : '0'
}); });
}); });
self.defaultDomain.subscribe(function (sValue) { self.defaultDomain.subscribe(function(sValue) {
Remote.saveAdminConfig(f1, { Remote.saveAdminConfig(f1, {
'LoginDefaultDomain': Utils.trim(sValue) 'LoginDefaultDomain': Utils.trim(sValue)
}); });
}); });
}, 50); }, 50);
}; };
module.exports = LoginAdminSettings; module.exports = LoginAdminSettings;
}());

View file

@ -1,9 +1,5 @@
(function () { var
'use strict';
var
window = require('window'), window = require('window'),
_ = require('_'), _ = require('_'),
ko = require('ko'), ko = require('ko'),
@ -12,51 +8,50 @@
Translator = require('Common/Translator'), Translator = require('Common/Translator'),
PackageStore = require('Stores/Admin/Package'), PackageStore = require('Stores/Admin/Package'),
Remote = require('Remote/Admin/Ajax') Remote = require('Remote/Admin/Ajax');
;
/** /**
* @constructor * @constructor
*/ */
function PackagesAdminSettings() function PackagesAdminSettings()
{ {
this.packagesError = ko.observable(''); this.packagesError = ko.observable('');
this.packages = PackageStore.packages; this.packages = PackageStore.packages;
this.packagesReal = PackageStore.packagesReal; this.packagesReal = PackageStore.packagesReal;
this.packagesMainUpdatable = PackageStore.packagesMainUpdatable; this.packagesMainUpdatable = PackageStore.packagesMainUpdatable;
this.packagesCurrent = this.packages.filter(function (item) { this.packagesCurrent = this.packages.filter(function(item) {
return item && '' !== item.installed && !item.compare; return item && '' !== item.installed && !item.compare;
}); });
this.packagesAvailableForUpdate = this.packages.filter(function (item) { this.packagesAvailableForUpdate = this.packages.filter(function(item) {
return item && '' !== item.installed && !!item.compare; return item && '' !== item.installed && !!item.compare;
}); });
this.packagesAvailableForInstallation = this.packages.filter(function (item) { this.packagesAvailableForInstallation = this.packages.filter(function(item) {
return item && '' === item.installed; return item && '' === item.installed;
}); });
this.visibility = ko.computed(function () { this.visibility = ko.computed(function() {
return PackageStore.packages.loading() ? 'visible' : 'hidden'; return PackageStore.packages.loading() ? 'visible' : 'hidden';
}, this); }, this);
} }
PackagesAdminSettings.prototype.onShow = function () PackagesAdminSettings.prototype.onShow = function()
{ {
this.packagesError(''); this.packagesError('');
}; };
PackagesAdminSettings.prototype.onBuild = function () PackagesAdminSettings.prototype.onBuild = function()
{ {
require('App/Admin').default.reloadPackagesList(); require('App/Admin').default.reloadPackagesList();
}; };
PackagesAdminSettings.prototype.requestHelper = function (oPackage, bInstall) PackagesAdminSettings.prototype.requestHelper = function(oPackage, bInstall)
{ {
var self = this; var self = this;
return function (sResult, oData) { return function(sResult, oData) {
if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result) if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result)
{ {
@ -71,7 +66,7 @@
} }
} }
_.each(self.packages(), function (item) { _.each(self.packages(), function(item) {
if (item && oPackage && item.loading && item.loading() && oPackage.file === item.file) if (item && oPackage && item.loading && item.loading() && oPackage.file === item.file)
{ {
oPackage.loading(false); oPackage.loading(false);
@ -88,26 +83,24 @@
require('App/Admin').default.reloadPackagesList(); require('App/Admin').default.reloadPackagesList();
} }
}; };
}; };
PackagesAdminSettings.prototype.deletePackage = function (oPackage) PackagesAdminSettings.prototype.deletePackage = function(oPackage)
{ {
if (oPackage) if (oPackage)
{ {
oPackage.loading(true); oPackage.loading(true);
Remote.packageDelete(this.requestHelper(oPackage, false), oPackage); Remote.packageDelete(this.requestHelper(oPackage, false), oPackage);
} }
}; };
PackagesAdminSettings.prototype.installPackage = function (oPackage) PackagesAdminSettings.prototype.installPackage = function(oPackage)
{ {
if (oPackage) if (oPackage)
{ {
oPackage.loading(true); oPackage.loading(true);
Remote.packageInstall(this.requestHelper(oPackage, true), oPackage); Remote.packageInstall(this.requestHelper(oPackage, true), oPackage);
} }
}; };
module.exports = PackagesAdminSettings; module.exports = PackagesAdminSettings;
}());

View file

@ -1,11 +1,7 @@
/* global RL_COMMUNITY */ /* global RL_COMMUNITY */
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
ko = require('ko'), ko = require('ko'),
@ -18,14 +14,13 @@
AppStore = require('Stores/Admin/App'), AppStore = require('Stores/Admin/App'),
PluginStore = require('Stores/Admin/Plugin'), PluginStore = require('Stores/Admin/Plugin'),
Remote = require('Remote/Admin/Ajax') Remote = require('Remote/Admin/Ajax');
;
/** /**
* @constructor * @constructor
*/ */
function PluginsAdminSettings() function PluginsAdminSettings()
{ {
this.enabledPlugins = ko.observable(!!Settings.settingsGet('EnabledPlugins')); this.enabledPlugins = ko.observable(!!Settings.settingsGet('EnabledPlugins'));
this.plugins = PluginStore.plugins; this.plugins = PluginStore.plugins;
@ -33,69 +28,68 @@
this.community = RL_COMMUNITY || AppStore.community(); this.community = RL_COMMUNITY || AppStore.community();
this.visibility = ko.computed(function () { this.visibility = ko.computed(function() {
return PluginStore.plugins.loading() ? 'visible' : 'hidden'; return PluginStore.plugins.loading() ? 'visible' : 'hidden';
}, this); }, this);
this.onPluginLoadRequest = _.bind(this.onPluginLoadRequest, this); this.onPluginLoadRequest = _.bind(this.onPluginLoadRequest, this);
this.onPluginDisableRequest = _.bind(this.onPluginDisableRequest, this); this.onPluginDisableRequest = _.bind(this.onPluginDisableRequest, this);
} }
PluginsAdminSettings.prototype.disablePlugin = function (oPlugin) PluginsAdminSettings.prototype.disablePlugin = function(oPlugin)
{ {
oPlugin.disabled(!oPlugin.disabled()); oPlugin.disabled(!oPlugin.disabled());
Remote.pluginDisable(this.onPluginDisableRequest, oPlugin.name, oPlugin.disabled()); Remote.pluginDisable(this.onPluginDisableRequest, oPlugin.name, oPlugin.disabled());
}; };
PluginsAdminSettings.prototype.configurePlugin = function (oPlugin) PluginsAdminSettings.prototype.configurePlugin = function(oPlugin)
{ {
Remote.plugin(this.onPluginLoadRequest, oPlugin.name); Remote.plugin(this.onPluginLoadRequest, oPlugin.name);
}; };
PluginsAdminSettings.prototype.onBuild = function (oDom) PluginsAdminSettings.prototype.onBuild = function(oDom)
{ {
var self = this; var self = this;
oDom oDom
.on('click', '.e-item .configure-plugin-action', function () { .on('click', '.e-item .configure-plugin-action', function() {
var oPlugin = ko.dataFor(this); var oPlugin = ko.dataFor(this);
if (oPlugin) if (oPlugin)
{ {
self.configurePlugin(oPlugin); self.configurePlugin(oPlugin);
} }
}) })
.on('click', '.e-item .disabled-plugin', function () { .on('click', '.e-item .disabled-plugin', function() {
var oPlugin = ko.dataFor(this); var oPlugin = ko.dataFor(this);
if (oPlugin) if (oPlugin)
{ {
self.disablePlugin(oPlugin); self.disablePlugin(oPlugin);
} }
}) });
;
this.enabledPlugins.subscribe(function (bValue) { this.enabledPlugins.subscribe(function(bValue) {
Remote.saveAdminConfig(Utils.noop, { Remote.saveAdminConfig(Utils.noop, {
'EnabledPlugins': bValue ? '1' : '0' 'EnabledPlugins': bValue ? '1' : '0'
}); });
}); });
}; };
PluginsAdminSettings.prototype.onShow = function () PluginsAdminSettings.prototype.onShow = function()
{ {
PluginStore.plugins.error(''); PluginStore.plugins.error('');
require('App/Admin').default.reloadPluginList(); require('App/Admin').default.reloadPluginList();
}; };
PluginsAdminSettings.prototype.onPluginLoadRequest = function (sResult, oData) PluginsAdminSettings.prototype.onPluginLoadRequest = function(sResult, oData)
{ {
if (Enums.StorageResultType.Success === sResult && oData && oData.Result) if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{ {
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Plugin'), [oData.Result]); require('Knoin/Knoin').showScreenPopup(require('View/Popup/Plugin'), [oData.Result]);
} }
}; };
PluginsAdminSettings.prototype.onPluginDisableRequest = function (sResult, oData) PluginsAdminSettings.prototype.onPluginDisableRequest = function(sResult, oData)
{ {
if (Enums.StorageResultType.Success === sResult && oData) if (Enums.StorageResultType.Success === sResult && oData)
{ {
if (!oData.Result && oData.ErrorCode) if (!oData.Result && oData.ErrorCode)
@ -112,8 +106,6 @@
} }
require('App/Admin').default.reloadPluginList(); require('App/Admin').default.reloadPluginList();
}; };
module.exports = PluginsAdminSettings; module.exports = PluginsAdminSettings;
}());

View file

@ -1,9 +1,5 @@
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
ko = require('ko'), ko = require('ko'),
@ -15,14 +11,13 @@
CapaAdminStore = require('Stores/Admin/Capa'), CapaAdminStore = require('Stores/Admin/Capa'),
Settings = require('Storage/Settings'), Settings = require('Storage/Settings'),
Remote = require('Remote/Admin/Ajax') Remote = require('Remote/Admin/Ajax');
;
/** /**
* @constructor * @constructor
*/ */
function SecurityAdminSettings() function SecurityAdminSettings()
{ {
this.useLocalProxyForExternalImages = AppAdminStore.useLocalProxyForExternalImages; this.useLocalProxyForExternalImages = AppAdminStore.useLocalProxyForExternalImages;
this.weakPassword = AppAdminStore.weakPassword; this.weakPassword = AppAdminStore.weakPassword;
@ -32,7 +27,7 @@
this.capaTwoFactorAuth = CapaAdminStore.twoFactorAuth; this.capaTwoFactorAuth = CapaAdminStore.twoFactorAuth;
this.capaTwoFactorAuthForce = CapaAdminStore.twoFactorAuthForce; this.capaTwoFactorAuthForce = CapaAdminStore.twoFactorAuthForce;
this.capaTwoFactorAuth.subscribe(function (bValue) { this.capaTwoFactorAuth.subscribe(function(bValue) {
if (!bValue) if (!bValue)
{ {
this.capaTwoFactorAuthForce(false); this.capaTwoFactorAuthForce(false);
@ -42,7 +37,7 @@
this.verifySslCertificate = ko.observable(!!Settings.settingsGet('VerifySslCertificate')); this.verifySslCertificate = ko.observable(!!Settings.settingsGet('VerifySslCertificate'));
this.allowSelfSigned = ko.observable(!!Settings.settingsGet('AllowSelfSigned')); this.allowSelfSigned = ko.observable(!!Settings.settingsGet('AllowSelfSigned'));
this.verifySslCertificate.subscribe(function (bValue) { this.verifySslCertificate.subscribe(function(bValue) {
if (!bValue) if (!bValue)
{ {
this.allowSelfSigned(true); this.allowSelfSigned(true);
@ -59,28 +54,28 @@
this.adminPasswordUpdateError = ko.observable(false); this.adminPasswordUpdateError = ko.observable(false);
this.adminPasswordUpdateSuccess = ko.observable(false); this.adminPasswordUpdateSuccess = ko.observable(false);
this.adminPassword.subscribe(function () { this.adminPassword.subscribe(function() {
this.adminPasswordUpdateError(false); this.adminPasswordUpdateError(false);
this.adminPasswordUpdateSuccess(false); this.adminPasswordUpdateSuccess(false);
}, this); }, this);
this.adminLogin.subscribe(function () { this.adminLogin.subscribe(function() {
this.adminLoginError(false); this.adminLoginError(false);
}, this); }, this);
this.adminPasswordNew.subscribe(function () { this.adminPasswordNew.subscribe(function() {
this.adminPasswordUpdateError(false); this.adminPasswordUpdateError(false);
this.adminPasswordUpdateSuccess(false); this.adminPasswordUpdateSuccess(false);
this.adminPasswordNewError(false); this.adminPasswordNewError(false);
}, this); }, this);
this.adminPasswordNew2.subscribe(function () { this.adminPasswordNew2.subscribe(function() {
this.adminPasswordUpdateError(false); this.adminPasswordUpdateError(false);
this.adminPasswordUpdateSuccess(false); this.adminPasswordUpdateSuccess(false);
this.adminPasswordNewError(false); this.adminPasswordNewError(false);
}, this); }, this);
this.saveNewAdminPasswordCommand = Utils.createCommand(this, function () { this.saveNewAdminPasswordCommand = Utils.createCommand(this, function() {
if ('' === Utils.trim(this.adminLogin())) if ('' === Utils.trim(this.adminLogin()))
{ {
@ -103,15 +98,15 @@
'NewPassword': this.adminPasswordNew() 'NewPassword': this.adminPasswordNew()
}); });
}, function () { }, function() {
return '' !== Utils.trim(this.adminLogin()) && '' !== this.adminPassword(); return '' !== Utils.trim(this.adminLogin()) && '' !== this.adminPassword();
}); });
this.onNewAdminPasswordResponse = _.bind(this.onNewAdminPasswordResponse, this); this.onNewAdminPasswordResponse = _.bind(this.onNewAdminPasswordResponse, this);
} }
SecurityAdminSettings.prototype.onNewAdminPasswordResponse = function (sResult, oData) SecurityAdminSettings.prototype.onNewAdminPasswordResponse = function(sResult, oData)
{ {
if (Enums.StorageResultType.Success === sResult && oData && oData.Result) if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{ {
this.adminPassword(''); this.adminPassword('');
@ -126,62 +121,60 @@
{ {
this.adminPasswordUpdateError(true); this.adminPasswordUpdateError(true);
} }
}; };
SecurityAdminSettings.prototype.onBuild = function () SecurityAdminSettings.prototype.onBuild = function()
{ {
this.capaOpenPGP.subscribe(function (bValue) { this.capaOpenPGP.subscribe(function(bValue) {
Remote.saveAdminConfig(Utils.noop, { Remote.saveAdminConfig(Utils.noop, {
'CapaOpenPGP': bValue ? '1' : '0' 'CapaOpenPGP': bValue ? '1' : '0'
}); });
}); });
this.capaTwoFactorAuth.subscribe(function (bValue) { this.capaTwoFactorAuth.subscribe(function(bValue) {
Remote.saveAdminConfig(Utils.noop, { Remote.saveAdminConfig(Utils.noop, {
'CapaTwoFactorAuth': bValue ? '1' : '0' 'CapaTwoFactorAuth': bValue ? '1' : '0'
}); });
}); });
this.capaTwoFactorAuthForce.subscribe(function (bValue) { this.capaTwoFactorAuthForce.subscribe(function(bValue) {
Remote.saveAdminConfig(Utils.noop, { Remote.saveAdminConfig(Utils.noop, {
'CapaTwoFactorAuthForce': bValue ? '1' : '0' 'CapaTwoFactorAuthForce': bValue ? '1' : '0'
}); });
}); });
this.useLocalProxyForExternalImages.subscribe(function (bValue) { this.useLocalProxyForExternalImages.subscribe(function(bValue) {
Remote.saveAdminConfig(null, { Remote.saveAdminConfig(null, {
'UseLocalProxyForExternalImages': bValue ? '1' : '0' 'UseLocalProxyForExternalImages': bValue ? '1' : '0'
}); });
}); });
this.verifySslCertificate.subscribe(function (bValue) { this.verifySslCertificate.subscribe(function(bValue) {
Remote.saveAdminConfig(null, { Remote.saveAdminConfig(null, {
'VerifySslCertificate': bValue ? '1' : '0' 'VerifySslCertificate': bValue ? '1' : '0'
}); });
}); });
this.allowSelfSigned.subscribe(function (bValue) { this.allowSelfSigned.subscribe(function(bValue) {
Remote.saveAdminConfig(null, { Remote.saveAdminConfig(null, {
'AllowSelfSigned': bValue ? '1' : '0' 'AllowSelfSigned': bValue ? '1' : '0'
}); });
}); });
}; };
SecurityAdminSettings.prototype.onHide = function () SecurityAdminSettings.prototype.onHide = function()
{ {
this.adminPassword(''); this.adminPassword('');
this.adminPasswordNew(''); this.adminPasswordNew('');
this.adminPasswordNew2(''); this.adminPasswordNew2('');
}; };
/** /**
* @return {string} * @returns {string}
*/ */
SecurityAdminSettings.prototype.phpInfoLink = function () SecurityAdminSettings.prototype.phpInfoLink = function()
{ {
return Links.phpInfo(); return Links.phpInfo();
}; };
module.exports = SecurityAdminSettings; module.exports = SecurityAdminSettings;
}());

View file

@ -1,21 +1,16 @@
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
ko = require('ko'), ko = require('ko'),
Enums = require('Common/Enums'), Enums = require('Common/Enums'),
Utils = require('Common/Utils') Utils = require('Common/Utils');
;
/** /**
* @constructor * @constructor
*/ */
function SocialAdminSettings() function SocialAdminSettings()
{ {
var SocialStore = require('Stores/Social'); var SocialStore = require('Stores/Social');
this.googleEnable = SocialStore.google.enabled; this.googleEnable = SocialStore.google.enabled;
@ -54,16 +49,15 @@
this.dropboxApiKey = SocialStore.dropbox.apiKey; this.dropboxApiKey = SocialStore.dropbox.apiKey;
this.dropboxTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle); this.dropboxTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle);
} }
SocialAdminSettings.prototype.onBuild = function () SocialAdminSettings.prototype.onBuild = function()
{ {
var var
self = this, self = this,
Remote = require('Remote/Admin/Ajax') Remote = require('Remote/Admin/Ajax');
;
_.delay(function () { _.delay(function() {
var var
f1 = Utils.settingsSaveHelperSimpleFunction(self.facebookTrigger1, self), f1 = Utils.settingsSaveHelperSimpleFunction(self.facebookTrigger1, self),
@ -73,10 +67,9 @@
f5 = Utils.settingsSaveHelperSimpleFunction(self.googleTrigger1, self), f5 = Utils.settingsSaveHelperSimpleFunction(self.googleTrigger1, self),
f6 = Utils.settingsSaveHelperSimpleFunction(self.googleTrigger2, self), f6 = Utils.settingsSaveHelperSimpleFunction(self.googleTrigger2, self),
f7 = Utils.settingsSaveHelperSimpleFunction(self.googleTrigger3, self), f7 = Utils.settingsSaveHelperSimpleFunction(self.googleTrigger3, self),
f8 = Utils.settingsSaveHelperSimpleFunction(self.dropboxTrigger1, self) f8 = Utils.settingsSaveHelperSimpleFunction(self.dropboxTrigger1, self);
;
self.facebookEnable.subscribe(function (bValue) { self.facebookEnable.subscribe(function(bValue) {
if (self.facebookSupported()) if (self.facebookSupported())
{ {
Remote.saveAdminConfig(Utils.noop, { Remote.saveAdminConfig(Utils.noop, {
@ -85,7 +78,7 @@
} }
}); });
self.facebookAppID.subscribe(function (sValue) { self.facebookAppID.subscribe(function(sValue) {
if (self.facebookSupported()) if (self.facebookSupported())
{ {
Remote.saveAdminConfig(f1, { Remote.saveAdminConfig(f1, {
@ -94,7 +87,7 @@
} }
}); });
self.facebookAppSecret.subscribe(function (sValue) { self.facebookAppSecret.subscribe(function(sValue) {
if (self.facebookSupported()) if (self.facebookSupported())
{ {
Remote.saveAdminConfig(f2, { Remote.saveAdminConfig(f2, {
@ -103,81 +96,79 @@
} }
}); });
self.twitterEnable.subscribe(function (bValue) { self.twitterEnable.subscribe(function(bValue) {
Remote.saveAdminConfig(Utils.noop, { Remote.saveAdminConfig(Utils.noop, {
'TwitterEnable': bValue ? '1' : '0' 'TwitterEnable': bValue ? '1' : '0'
}); });
}); });
self.twitterConsumerKey.subscribe(function (sValue) { self.twitterConsumerKey.subscribe(function(sValue) {
Remote.saveAdminConfig(f3, { Remote.saveAdminConfig(f3, {
'TwitterConsumerKey': Utils.trim(sValue) 'TwitterConsumerKey': Utils.trim(sValue)
}); });
}); });
self.twitterConsumerSecret.subscribe(function (sValue) { self.twitterConsumerSecret.subscribe(function(sValue) {
Remote.saveAdminConfig(f4, { Remote.saveAdminConfig(f4, {
'TwitterConsumerSecret': Utils.trim(sValue) 'TwitterConsumerSecret': Utils.trim(sValue)
}); });
}); });
self.googleEnable.subscribe(function (bValue) { self.googleEnable.subscribe(function(bValue) {
Remote.saveAdminConfig(Utils.noop, { Remote.saveAdminConfig(Utils.noop, {
'GoogleEnable': bValue ? '1' : '0' 'GoogleEnable': bValue ? '1' : '0'
}); });
}); });
self.googleEnableAuth.subscribe(function (bValue) { self.googleEnableAuth.subscribe(function(bValue) {
Remote.saveAdminConfig(Utils.noop, { Remote.saveAdminConfig(Utils.noop, {
'GoogleEnableAuth': bValue ? '1' : '0' 'GoogleEnableAuth': bValue ? '1' : '0'
}); });
}); });
self.googleEnableDrive.subscribe(function (bValue) { self.googleEnableDrive.subscribe(function(bValue) {
Remote.saveAdminConfig(Utils.noop, { Remote.saveAdminConfig(Utils.noop, {
'GoogleEnableDrive': bValue ? '1' : '0' 'GoogleEnableDrive': bValue ? '1' : '0'
}); });
}); });
self.googleEnablePreview.subscribe(function (bValue) { self.googleEnablePreview.subscribe(function(bValue) {
Remote.saveAdminConfig(Utils.noop, { Remote.saveAdminConfig(Utils.noop, {
'GoogleEnablePreview': bValue ? '1' : '0' 'GoogleEnablePreview': bValue ? '1' : '0'
}); });
}); });
self.googleClientID.subscribe(function (sValue) { self.googleClientID.subscribe(function(sValue) {
Remote.saveAdminConfig(f5, { Remote.saveAdminConfig(f5, {
'GoogleClientID': Utils.trim(sValue) 'GoogleClientID': Utils.trim(sValue)
}); });
}); });
self.googleClientSecret.subscribe(function (sValue) { self.googleClientSecret.subscribe(function(sValue) {
Remote.saveAdminConfig(f6, { Remote.saveAdminConfig(f6, {
'GoogleClientSecret': Utils.trim(sValue) 'GoogleClientSecret': Utils.trim(sValue)
}); });
}); });
self.googleApiKey.subscribe(function (sValue) { self.googleApiKey.subscribe(function(sValue) {
Remote.saveAdminConfig(f7, { Remote.saveAdminConfig(f7, {
'GoogleApiKey': Utils.trim(sValue) 'GoogleApiKey': Utils.trim(sValue)
}); });
}); });
self.dropboxEnable.subscribe(function (bValue) { self.dropboxEnable.subscribe(function(bValue) {
Remote.saveAdminConfig(Utils.noop, { Remote.saveAdminConfig(Utils.noop, {
'DropboxEnable': bValue ? '1' : '0' 'DropboxEnable': bValue ? '1' : '0'
}); });
}); });
self.dropboxApiKey.subscribe(function (sValue) { self.dropboxApiKey.subscribe(function(sValue) {
Remote.saveAdminConfig(f8, { Remote.saveAdminConfig(f8, {
'DropboxApiKey': Utils.trim(sValue) 'DropboxApiKey': Utils.trim(sValue)
}); });
}); });
}, 50); }, 50);
}; };
module.exports = SocialAdminSettings; module.exports = SocialAdminSettings;
}());

View file

@ -1,9 +1,5 @@
(function () { var
'use strict';
var
window = require('window'), window = require('window'),
_ = require('_'), _ = require('_'),
ko = require('ko'), ko = require('ko'),
@ -15,14 +11,13 @@
IdentityStore = require('Stores/User/Identity'), IdentityStore = require('Stores/User/Identity'),
Settings = require('Storage/Settings'), Settings = require('Storage/Settings'),
Remote = require('Remote/User/Ajax') Remote = require('Remote/User/Ajax');
;
/** /**
* @constructor * @constructor
*/ */
function AccountsUserSettings() function AccountsUserSettings()
{ {
this.allowAdditionalAccount = Settings.capa(Enums.Capa.AdditionalAccounts); this.allowAdditionalAccount = Settings.capa(Enums.Capa.AdditionalAccounts);
this.allowIdentities = Settings.capa(Enums.Capa.Identities); this.allowIdentities = Settings.capa(Enums.Capa.Identities);
@ -31,61 +26,60 @@
this.accountForDeletion = ko.observable(null).deleteAccessHelper(); this.accountForDeletion = ko.observable(null).deleteAccessHelper();
this.identityForDeletion = ko.observable(null).deleteAccessHelper(); this.identityForDeletion = ko.observable(null).deleteAccessHelper();
} }
AccountsUserSettings.prototype.scrollableOptions = function (sWrapper) AccountsUserSettings.prototype.scrollableOptions = function(sWrapper)
{ {
return { return {
handle: '.drag-handle', handle: '.drag-handle',
containment: sWrapper || 'parent', containment: sWrapper || 'parent',
axis: 'y' axis: 'y'
}; };
}; };
AccountsUserSettings.prototype.addNewAccount = function () AccountsUserSettings.prototype.addNewAccount = function()
{ {
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Account')); require('Knoin/Knoin').showScreenPopup(require('View/Popup/Account'));
}; };
AccountsUserSettings.prototype.editAccount = function (oAccountItem) AccountsUserSettings.prototype.editAccount = function(oAccountItem)
{ {
if (oAccountItem && oAccountItem.canBeEdit()) if (oAccountItem && oAccountItem.canBeEdit())
{ {
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Account'), [oAccountItem]); require('Knoin/Knoin').showScreenPopup(require('View/Popup/Account'), [oAccountItem]);
} }
}; };
AccountsUserSettings.prototype.addNewIdentity = function () AccountsUserSettings.prototype.addNewIdentity = function()
{ {
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Identity')); require('Knoin/Knoin').showScreenPopup(require('View/Popup/Identity'));
}; };
AccountsUserSettings.prototype.editIdentity = function (oIdentity) AccountsUserSettings.prototype.editIdentity = function(oIdentity)
{ {
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Identity'), [oIdentity]); require('Knoin/Knoin').showScreenPopup(require('View/Popup/Identity'), [oIdentity]);
}; };
/** /**
* @param {AccountModel} oAccountToRemove * @param {AccountModel} oAccountToRemove
*/ */
AccountsUserSettings.prototype.deleteAccount = function (oAccountToRemove) AccountsUserSettings.prototype.deleteAccount = function(oAccountToRemove)
{ {
if (oAccountToRemove && oAccountToRemove.deleteAccess()) if (oAccountToRemove && oAccountToRemove.deleteAccess())
{ {
this.accountForDeletion(null); this.accountForDeletion(null);
var var
kn = require('Knoin/Knoin'), kn = require('Knoin/Knoin'),
fRemoveAccount = function (oAccount) { fRemoveAccount = function(oAccount) {
return oAccountToRemove === oAccount; return oAccountToRemove === oAccount;
} };
;
if (oAccountToRemove) if (oAccountToRemove)
{ {
this.accounts.remove(fRemoveAccount); this.accounts.remove(fRemoveAccount);
Remote.accountDelete(function (sResult, oData) { Remote.accountDelete(function(sResult, oData) {
if (Enums.StorageResultType.Success === sResult && oData && if (Enums.StorageResultType.Success === sResult && oData &&
oData.Result && oData.Reload) oData.Result && oData.Reload)
@ -94,7 +88,7 @@
kn.setHash(Links.root(), true); kn.setHash(Links.root(), true);
kn.routeOff(); kn.routeOff();
_.defer(function () { _.defer(function() {
window.location.reload(); window.location.reload();
}); });
} }
@ -106,58 +100,55 @@
}, oAccountToRemove.email); }, oAccountToRemove.email);
} }
} }
}; };
/** /**
* @param {IdentityModel} oIdentityToRemove * @param {IdentityModel} oIdentityToRemove
*/ */
AccountsUserSettings.prototype.deleteIdentity = function (oIdentityToRemove) AccountsUserSettings.prototype.deleteIdentity = function(oIdentityToRemove)
{ {
if (oIdentityToRemove && oIdentityToRemove.deleteAccess()) if (oIdentityToRemove && oIdentityToRemove.deleteAccess())
{ {
this.identityForDeletion(null); this.identityForDeletion(null);
if (oIdentityToRemove) if (oIdentityToRemove)
{ {
IdentityStore.identities.remove(function (oIdentity) { IdentityStore.identities.remove(function(oIdentity) {
return oIdentityToRemove === oIdentity; return oIdentityToRemove === oIdentity;
}); });
Remote.identityDelete(function () { Remote.identityDelete(function() {
require('App/User').default.accountsAndIdentities(); require('App/User').default.accountsAndIdentities();
}, oIdentityToRemove.id); }, oIdentityToRemove.id);
} }
} }
}; };
AccountsUserSettings.prototype.accountsAndIdentitiesAfterMove = function () AccountsUserSettings.prototype.accountsAndIdentitiesAfterMove = function()
{ {
Remote.accountsAndIdentitiesSortOrder(null, Remote.accountsAndIdentitiesSortOrder(null,
AccountStore.accountsEmails.peek(), IdentityStore.identitiesIDS.peek()); AccountStore.accountsEmails.peek(), IdentityStore.identitiesIDS.peek());
}; };
AccountsUserSettings.prototype.onBuild = function (oDom) AccountsUserSettings.prototype.onBuild = function(oDom)
{ {
var self = this; var self = this;
oDom oDom
.on('click', '.accounts-list .account-item .e-action', function () { .on('click', '.accounts-list .account-item .e-action', function() {
var oAccountItem = ko.dataFor(this); var oAccountItem = ko.dataFor(this);
if (oAccountItem) if (oAccountItem)
{ {
self.editAccount(oAccountItem); self.editAccount(oAccountItem);
} }
}) })
.on('click', '.identities-list .identity-item .e-action', function () { .on('click', '.identities-list .identity-item .e-action', function() {
var oIdentityItem = ko.dataFor(this); var oIdentityItem = ko.dataFor(this);
if (oIdentityItem) if (oIdentityItem)
{ {
self.editIdentity(oIdentityItem); self.editIdentity(oIdentityItem);
} }
}) });
; };
};
module.exports = AccountsUserSettings; module.exports = AccountsUserSettings;
}());

View file

@ -1,9 +1,5 @@
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
ko = require('ko'), ko = require('ko'),
@ -11,14 +7,13 @@
Utils = require('Common/Utils'), Utils = require('Common/Utils'),
Translator = require('Common/Translator'), Translator = require('Common/Translator'),
Remote = require('Remote/User/Ajax') Remote = require('Remote/User/Ajax');
;
/** /**
* @constructor * @constructor
*/ */
function ChangePasswordUserSettings() function ChangePasswordUserSettings()
{ {
this.changeProcess = ko.observable(false); this.changeProcess = ko.observable(false);
this.errorDescription = ko.observable(''); this.errorDescription = ko.observable('');
@ -31,25 +26,25 @@
this.newPassword = ko.observable(''); this.newPassword = ko.observable('');
this.newPassword2 = ko.observable(''); this.newPassword2 = ko.observable('');
this.currentPassword.subscribe(function () { this.currentPassword.subscribe(function() {
this.passwordUpdateError(false); this.passwordUpdateError(false);
this.passwordUpdateSuccess(false); this.passwordUpdateSuccess(false);
this.currentPassword.error(false); this.currentPassword.error(false);
}, this); }, this);
this.newPassword.subscribe(function () { this.newPassword.subscribe(function() {
this.passwordUpdateError(false); this.passwordUpdateError(false);
this.passwordUpdateSuccess(false); this.passwordUpdateSuccess(false);
this.passwordMismatch(false); this.passwordMismatch(false);
}, this); }, this);
this.newPassword2.subscribe(function () { this.newPassword2.subscribe(function() {
this.passwordUpdateError(false); this.passwordUpdateError(false);
this.passwordUpdateSuccess(false); this.passwordUpdateSuccess(false);
this.passwordMismatch(false); this.passwordMismatch(false);
}, this); }, this);
this.saveNewPasswordCommand = Utils.createCommand(this, function () { this.saveNewPasswordCommand = Utils.createCommand(this, function() {
if (this.newPassword() !== this.newPassword2()) if (this.newPassword() !== this.newPassword2())
{ {
@ -69,16 +64,16 @@
Remote.changePassword(this.onChangePasswordResponse, this.currentPassword(), this.newPassword()); Remote.changePassword(this.onChangePasswordResponse, this.currentPassword(), this.newPassword());
} }
}, function () { }, function() {
return !this.changeProcess() && '' !== this.currentPassword() && return !this.changeProcess() && '' !== this.currentPassword() &&
'' !== this.newPassword() && '' !== this.newPassword2(); '' !== this.newPassword() && '' !== this.newPassword2();
}); });
this.onChangePasswordResponse = _.bind(this.onChangePasswordResponse, this); this.onChangePasswordResponse = _.bind(this.onChangePasswordResponse, this);
} }
ChangePasswordUserSettings.prototype.onHide = function () ChangePasswordUserSettings.prototype.onHide = function()
{ {
this.changeProcess(false); this.changeProcess(false);
this.currentPassword(''); this.currentPassword('');
this.newPassword(''); this.newPassword('');
@ -86,10 +81,10 @@
this.errorDescription(''); this.errorDescription('');
this.passwordMismatch(false); this.passwordMismatch(false);
this.currentPassword.error(false); this.currentPassword.error(false);
}; };
ChangePasswordUserSettings.prototype.onChangePasswordResponse = function (sResult, oData) ChangePasswordUserSettings.prototype.onChangePasswordResponse = function(sResult, oData)
{ {
this.changeProcess(false); this.changeProcess(false);
this.passwordMismatch(false); this.passwordMismatch(false);
this.errorDescription(''); this.errorDescription('');
@ -117,8 +112,6 @@
this.errorDescription( this.errorDescription(
Translator.getNotificationFromResponse(oData, Enums.Notification.CouldNotSaveNewPassword)); Translator.getNotificationFromResponse(oData, Enums.Notification.CouldNotSaveNewPassword));
} }
}; };
module.exports = ChangePasswordUserSettings; module.exports = ChangePasswordUserSettings;
}());

View file

@ -1,22 +1,17 @@
(function () { var
'use strict';
var
ko = require('ko'), ko = require('ko'),
AppStore = require('Stores/User/App'), AppStore = require('Stores/User/App'),
ContactStore = require('Stores/User/Contact'), ContactStore = require('Stores/User/Contact'),
Remote = require('Remote/User/Ajax') Remote = require('Remote/User/Ajax');
;
/** /**
* @constructor * @constructor
*/ */
function ContactsUserSettings() function ContactsUserSettings()
{ {
this.contactsAutosave = AppStore.contactsAutosave; this.contactsAutosave = AppStore.contactsAutosave;
this.allowContactsSync = ContactStore.allowContactsSync; this.allowContactsSync = ContactStore.allowContactsSync;
@ -25,7 +20,7 @@
this.contactsSyncUser = ContactStore.contactsSyncUser; this.contactsSyncUser = ContactStore.contactsSyncUser;
this.contactsSyncPass = ContactStore.contactsSyncPass; this.contactsSyncPass = ContactStore.contactsSyncPass;
this.saveTrigger = ko.computed(function () { this.saveTrigger = ko.computed(function() {
return [ return [
this.enableContactsSync() ? '1' : '0', this.enableContactsSync() ? '1' : '0',
this.contactsSyncUrl(), this.contactsSyncUrl(),
@ -33,17 +28,17 @@
this.contactsSyncPass() this.contactsSyncPass()
].join('|'); ].join('|');
}, this).extend({'throttle': 500}); }, this).extend({'throttle': 500});
} }
ContactsUserSettings.prototype.onBuild = function () ContactsUserSettings.prototype.onBuild = function()
{ {
this.contactsAutosave.subscribe(function (bValue) { this.contactsAutosave.subscribe(function(bValue) {
Remote.saveSettings(null, { Remote.saveSettings(null, {
'ContactsAutosave': bValue ? '1' : '0' 'ContactsAutosave': bValue ? '1' : '0'
}); });
}); });
this.saveTrigger.subscribe(function () { this.saveTrigger.subscribe(function() {
Remote.saveContactsSyncData(null, Remote.saveContactsSyncData(null,
this.enableContactsSync(), this.enableContactsSync(),
this.contactsSyncUrl(), this.contactsSyncUrl(),
@ -51,8 +46,6 @@
this.contactsSyncPass() this.contactsSyncPass()
); );
}, this); }, this);
}; };
module.exports = ContactsUserSettings; module.exports = ContactsUserSettings;
}());

View file

@ -1,9 +1,5 @@
(function () { var
'use strict';
var
ko = require('ko'), ko = require('ko'),
_ = require('_'), _ = require('_'),
@ -13,14 +9,13 @@
FilterStore = require('Stores/User/Filter'), FilterStore = require('Stores/User/Filter'),
Remote = require('Remote/User/Ajax') Remote = require('Remote/User/Ajax');
;
/** /**
* @constructor * @constructor
*/ */
function FiltersUserSettings() function FiltersUserSettings()
{ {
var self = this; var self = this;
this.modules = FilterStore.modules; this.modules = FilterStore.modules;
@ -35,7 +30,7 @@
this.filters.subscribe(Utils.windowResizeCallback); this.filters.subscribe(Utils.windowResizeCallback);
this.serverError.subscribe(function (bValue) { this.serverError.subscribe(function(bValue) {
if (!bValue) if (!bValue)
{ {
this.serverErrorDesc(''); this.serverErrorDesc('');
@ -51,7 +46,7 @@
this.filterForDeletion = ko.observable(null).extend({'falseTimeout': 3000}).extend( this.filterForDeletion = ko.observable(null).extend({'falseTimeout': 3000}).extend(
{'toggleSubscribeProperty': [this, 'deleteAccess']}); {'toggleSubscribeProperty': [this, 'deleteAccess']});
this.saveChanges = Utils.createCommand(this, function () { this.saveChanges = Utils.createCommand(this, function() {
if (!this.filters.saving()) if (!this.filters.saving())
{ {
@ -64,7 +59,7 @@
this.filters.saving(true); this.filters.saving(true);
this.saveErrorText(''); this.saveErrorText('');
Remote.filtersSave(function (sResult, oData) { Remote.filtersSave(function(sResult, oData) {
self.filters.saving(false); self.filters.saving(false);
@ -87,50 +82,49 @@
return true; return true;
}, function () { }, function() {
return this.haveChanges(); return this.haveChanges();
}); });
this.filters.subscribe(function () { this.filters.subscribe(function() {
this.haveChanges(true); this.haveChanges(true);
}, this); }, this);
this.filterRaw.subscribe(function () { this.filterRaw.subscribe(function() {
this.haveChanges(true); this.haveChanges(true);
this.filterRaw.error(false); this.filterRaw.error(false);
}, this); }, this);
this.haveChanges.subscribe(function () { this.haveChanges.subscribe(function() {
this.saveErrorText(''); this.saveErrorText('');
}, this); }, this);
this.filterRaw.active.subscribe(function () { this.filterRaw.active.subscribe(function() {
this.haveChanges(true); this.haveChanges(true);
this.filterRaw.error(false); this.filterRaw.error(false);
}, this); }, this);
} }
FiltersUserSettings.prototype.scrollableOptions = function (sWrapper) FiltersUserSettings.prototype.scrollableOptions = function(sWrapper)
{ {
return { return {
handle: '.drag-handle', handle: '.drag-handle',
containment: sWrapper || 'parent', containment: sWrapper || 'parent',
axis: 'y' axis: 'y'
}; };
}; };
FiltersUserSettings.prototype.updateList = function () FiltersUserSettings.prototype.updateList = function()
{ {
var var
self = this, self = this,
FilterModel = require('Model/Filter') FilterModel = require('Model/Filter');
;
if (!this.filters.loading()) if (!this.filters.loading())
{ {
this.filters.loading(true); this.filters.loading(true);
Remote.filtersGet(function (sResult, oData) { Remote.filtersGet(function(sResult, oData) {
self.filters.loading(false); self.filters.loading(false);
self.serverError(false); self.serverError(false);
@ -141,7 +135,7 @@
self.inited(true); self.inited(true);
self.serverError(false); self.serverError(false);
var aResult = _.compact(_.map(oData.Result.Filters, function (aItem) { var aResult = _.compact(_.map(oData.Result.Filters, function(aItem) {
var oNew = new FilterModel(); var oNew = new FilterModel();
return (oNew && oNew.parse(aItem)) ? oNew : null; return (oNew && oNew.parse(aItem)) ? oNew : null;
})); }));
@ -170,44 +164,41 @@
self.haveChanges(false); self.haveChanges(false);
}); });
} }
}; };
FiltersUserSettings.prototype.deleteFilter = function (oFilter) FiltersUserSettings.prototype.deleteFilter = function(oFilter)
{ {
this.filters.remove(oFilter); this.filters.remove(oFilter);
Utils.delegateRunOnDestroy(oFilter); Utils.delegateRunOnDestroy(oFilter);
}; };
FiltersUserSettings.prototype.addFilter = function () FiltersUserSettings.prototype.addFilter = function()
{ {
var var
self = this, self = this,
FilterModel = require('Model/Filter'), FilterModel = require('Model/Filter'),
oNew = new FilterModel() oNew = new FilterModel();
;
oNew.generateID(); oNew.generateID();
require('Knoin/Knoin').showScreenPopup( require('Knoin/Knoin').showScreenPopup(
require('View/Popup/Filter'), [oNew, function () { require('View/Popup/Filter'), [oNew, function() {
self.filters.push(oNew); self.filters.push(oNew);
self.filterRaw.active(false); self.filterRaw.active(false);
}, false]); }, false]);
}; };
FiltersUserSettings.prototype.editFilter = function (oEdit) FiltersUserSettings.prototype.editFilter = function(oEdit)
{ {
var var
self = this, self = this,
oCloned = oEdit.cloneSelf() oCloned = oEdit.cloneSelf();
;
require('Knoin/Knoin').showScreenPopup( require('Knoin/Knoin').showScreenPopup(
require('View/Popup/Filter'), [oCloned, function () { require('View/Popup/Filter'), [oCloned, function() {
var var
aFilters = self.filters(), aFilters = self.filters(),
iIndex = aFilters.indexOf(oEdit) iIndex = aFilters.indexOf(oEdit);
;
if (-1 < iIndex && aFilters[iIndex]) if (-1 < iIndex && aFilters[iIndex])
{ {
@ -219,28 +210,25 @@
} }
}, true]); }, true]);
}; };
FiltersUserSettings.prototype.onBuild = function (oDom) FiltersUserSettings.prototype.onBuild = function(oDom)
{ {
var self = this; var self = this;
oDom oDom
.on('click', '.filter-item .e-action', function () { .on('click', '.filter-item .e-action', function() {
var oFilterItem = ko.dataFor(this); var oFilterItem = ko.dataFor(this);
if (oFilterItem) if (oFilterItem)
{ {
self.editFilter(oFilterItem); self.editFilter(oFilterItem);
} }
}) });
; };
};
FiltersUserSettings.prototype.onShow = function () FiltersUserSettings.prototype.onShow = function()
{ {
this.updateList(); this.updateList();
}; };
module.exports = FiltersUserSettings; module.exports = FiltersUserSettings;
}());

View file

@ -1,9 +1,5 @@
(function () { var
'use strict';
var
ko = require('ko'), ko = require('ko'),
Enums = require('Common/Enums'), Enums = require('Common/Enums'),
@ -18,27 +14,25 @@
FolderStore = require('Stores/User/Folder'), FolderStore = require('Stores/User/Folder'),
Promises = require('Promises/User/Ajax'), Promises = require('Promises/User/Ajax'),
Remote = require('Remote/User/Ajax') Remote = require('Remote/User/Ajax');
;
/** /**
* @constructor * @constructor
*/ */
function FoldersUserSettings() function FoldersUserSettings()
{ {
this.displaySpecSetting = FolderStore.displaySpecSetting; this.displaySpecSetting = FolderStore.displaySpecSetting;
this.folderList = FolderStore.folderList; this.folderList = FolderStore.folderList;
this.folderListHelp = ko.observable('').extend({'throttle': 100}); this.folderListHelp = ko.observable('').extend({'throttle': 100});
this.loading = ko.computed(function () { this.loading = ko.computed(function() {
var var
bLoading = FolderStore.foldersLoading(), bLoading = FolderStore.foldersLoading(),
bCreating = FolderStore.foldersCreating(), bCreating = FolderStore.foldersCreating(),
bDeleting = FolderStore.foldersDeleting(), bDeleting = FolderStore.foldersDeleting(),
bRenaming = FolderStore.foldersRenaming() bRenaming = FolderStore.foldersRenaming();
;
return bLoading || bCreating || bDeleting || bRenaming; return bLoading || bCreating || bDeleting || bRenaming;
@ -47,12 +41,12 @@
this.folderForDeletion = ko.observable(null).deleteAccessHelper(); this.folderForDeletion = ko.observable(null).deleteAccessHelper();
this.folderForEdit = ko.observable(null).extend({'toggleSubscribe': [this, this.folderForEdit = ko.observable(null).extend({'toggleSubscribe': [this,
function (oPrev) { function(oPrev) {
if (oPrev) if (oPrev)
{ {
oPrev.edited(false); oPrev.edited(false);
} }
}, function (oNext) { }, function(oNext) {
if (oNext && oNext.canBeEdited()) if (oNext && oNext.canBeEdited())
{ {
oNext.edited(true); oNext.edited(true);
@ -61,13 +55,12 @@
]}); ]});
this.useImapSubscribe = !!Settings.appSettingsGet('useImapSubscribe'); this.useImapSubscribe = !!Settings.appSettingsGet('useImapSubscribe');
} }
FoldersUserSettings.prototype.folderEditOnEnter = function (oFolder) FoldersUserSettings.prototype.folderEditOnEnter = function(oFolder)
{ {
var var
sEditName = oFolder ? Utils.trim(oFolder.nameForEdit()) : '' sEditName = oFolder ? Utils.trim(oFolder.nameForEdit()) : '';
;
if ('' !== sEditName && oFolder.name() !== sEditName) if ('' !== sEditName && oFolder.name() !== sEditName)
{ {
@ -84,59 +77,58 @@
} }
oFolder.edited(false); oFolder.edited(false);
}; };
FoldersUserSettings.prototype.folderEditOnEsc = function (oFolder) FoldersUserSettings.prototype.folderEditOnEsc = function(oFolder)
{ {
if (oFolder) if (oFolder)
{ {
oFolder.edited(false); oFolder.edited(false);
} }
}; };
FoldersUserSettings.prototype.onShow = function () FoldersUserSettings.prototype.onShow = function()
{ {
FolderStore.folderList.error(''); FolderStore.folderList.error('');
}; };
FoldersUserSettings.prototype.onBuild = function (oDom) FoldersUserSettings.prototype.onBuild = function(oDom)
{ {
var self = this; var self = this;
oDom oDom
.on('mouseover', '.delete-folder-parent', function () { .on('mouseover', '.delete-folder-parent', function() {
self.folderListHelp(Translator.i18n('SETTINGS_FOLDERS/HELP_DELETE_FOLDER')); self.folderListHelp(Translator.i18n('SETTINGS_FOLDERS/HELP_DELETE_FOLDER'));
}) })
.on('mouseover', '.subscribe-folder-parent', function () { .on('mouseover', '.subscribe-folder-parent', function() {
self.folderListHelp(Translator.i18n('SETTINGS_FOLDERS/HELP_SHOW_HIDE_FOLDER')); self.folderListHelp(Translator.i18n('SETTINGS_FOLDERS/HELP_SHOW_HIDE_FOLDER'));
}) })
.on('mouseover', '.check-folder-parent', function () { .on('mouseover', '.check-folder-parent', function() {
self.folderListHelp(Translator.i18n('SETTINGS_FOLDERS/HELP_CHECK_FOR_NEW_MESSAGES')); self.folderListHelp(Translator.i18n('SETTINGS_FOLDERS/HELP_CHECK_FOR_NEW_MESSAGES'));
}) })
.on('mouseout', '.subscribe-folder-parent, .check-folder-parent, .delete-folder-parent', function () { .on('mouseout', '.subscribe-folder-parent, .check-folder-parent, .delete-folder-parent', function() {
self.folderListHelp(''); self.folderListHelp('');
}) });
; };
};
FoldersUserSettings.prototype.createFolder = function () FoldersUserSettings.prototype.createFolder = function()
{ {
require('Knoin/Knoin').showScreenPopup(require('View/Popup/FolderCreate')); require('Knoin/Knoin').showScreenPopup(require('View/Popup/FolderCreate'));
}; };
FoldersUserSettings.prototype.systemFolder = function () FoldersUserSettings.prototype.systemFolder = function()
{ {
require('Knoin/Knoin').showScreenPopup(require('View/Popup/FolderSystem')); require('Knoin/Knoin').showScreenPopup(require('View/Popup/FolderSystem'));
}; };
FoldersUserSettings.prototype.deleteFolder = function (oFolderToRemove) FoldersUserSettings.prototype.deleteFolder = function(oFolderToRemove)
{ {
if (oFolderToRemove && oFolderToRemove.canBeDeleted() && oFolderToRemove.deleteAccess() && if (oFolderToRemove && oFolderToRemove.canBeDeleted() && oFolderToRemove.deleteAccess() &&
0 === oFolderToRemove.privateMessageCountAll()) 0 === oFolderToRemove.privateMessageCountAll())
{ {
this.folderForDeletion(null); this.folderForDeletion(null);
var var
fRemoveFolder = function (oFolder) { fRemoveFolder = function(oFolder) {
if (oFolderToRemove === oFolder) if (oFolderToRemove === oFolder)
{ {
@ -145,8 +137,7 @@
oFolder.subFolders.remove(fRemoveFolder); oFolder.subFolders.remove(fRemoveFolder);
return false; return false;
} };
;
if (oFolderToRemove) if (oFolderToRemove)
{ {
@ -166,38 +157,36 @@
{ {
FolderStore.folderList.error(Translator.getNotification(Enums.Notification.CantDeleteNonEmptyFolder)); FolderStore.folderList.error(Translator.getNotification(Enums.Notification.CantDeleteNonEmptyFolder));
} }
}; };
FoldersUserSettings.prototype.subscribeFolder = function (oFolder) FoldersUserSettings.prototype.subscribeFolder = function(oFolder)
{ {
Local.set(Enums.ClientSideKeyName.FoldersLashHash, ''); Local.set(Enums.ClientSideKeyName.FoldersLashHash, '');
Remote.folderSetSubscribe(Utils.noop, oFolder.fullNameRaw, true); Remote.folderSetSubscribe(Utils.noop, oFolder.fullNameRaw, true);
oFolder.subScribed(true); oFolder.subScribed(true);
}; };
FoldersUserSettings.prototype.unSubscribeFolder = function (oFolder) FoldersUserSettings.prototype.unSubscribeFolder = function(oFolder)
{ {
Local.set(Enums.ClientSideKeyName.FoldersLashHash, ''); Local.set(Enums.ClientSideKeyName.FoldersLashHash, '');
Remote.folderSetSubscribe(Utils.noop, oFolder.fullNameRaw, false); Remote.folderSetSubscribe(Utils.noop, oFolder.fullNameRaw, false);
oFolder.subScribed(false); oFolder.subScribed(false);
}; };
FoldersUserSettings.prototype.checkableTrueFolder = function (oFolder) FoldersUserSettings.prototype.checkableTrueFolder = function(oFolder)
{ {
Remote.folderSetCheckable(Utils.noop, oFolder.fullNameRaw, true); Remote.folderSetCheckable(Utils.noop, oFolder.fullNameRaw, true);
oFolder.checkable(true); oFolder.checkable(true);
}; };
FoldersUserSettings.prototype.checkableFalseFolder = function (oFolder) FoldersUserSettings.prototype.checkableFalseFolder = function(oFolder)
{ {
Remote.folderSetCheckable(Utils.noop, oFolder.fullNameRaw, false); Remote.folderSetCheckable(Utils.noop, oFolder.fullNameRaw, false);
oFolder.checkable(false); oFolder.checkable(false);
}; };
module.exports = FoldersUserSettings; module.exports = FoldersUserSettings;
}());

View file

@ -1,9 +1,5 @@
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
ko = require('ko'), ko = require('ko'),
@ -20,14 +16,13 @@
NotificationStore = require('Stores/User/Notification'), NotificationStore = require('Stores/User/Notification'),
MessageStore = require('Stores/User/Message'), MessageStore = require('Stores/User/Message'),
Remote = require('Remote/User/Ajax') Remote = require('Remote/User/Ajax');
;
/** /**
* @constructor * @constructor
*/ */
function GeneralUserSettings() function GeneralUserSettings()
{ {
this.language = LanguageStore.language; this.language = LanguageStore.language;
this.languages = LanguageStore.languages; this.languages = LanguageStore.languages;
this.messagesPerPage = SettingsStore.messagesPerPage; this.messagesPerPage = SettingsStore.messagesPerPage;
@ -51,7 +46,7 @@
this.replySameFolder = SettingsStore.replySameFolder; this.replySameFolder = SettingsStore.replySameFolder;
this.allowLanguagesOnSettings = AppStore.allowLanguagesOnSettings; this.allowLanguagesOnSettings = AppStore.allowLanguagesOnSettings;
this.languageFullName = ko.computed(function () { this.languageFullName = ko.computed(function() {
return Utils.convertLangName(this.language()); return Utils.convertLangName(this.language());
}, this); }, this);
@ -65,19 +60,19 @@
this.identities = IdentityStore.identities; this.identities = IdentityStore.identities;
this.identityMain = ko.computed(function () { this.identityMain = ko.computed(function() {
var aList = this.identities(); var aList = this.identities();
return Utils.isArray(aList) ? _.find(aList, function (oItem) { return Utils.isArray(aList) ? _.find(aList, function(oItem) {
return oItem && '' === oItem.id() ? true : false; return oItem && '' === oItem.id();
}) : null; }) : null;
}, this); }, this);
this.identityMainDesc = ko.computed(function () { this.identityMainDesc = ko.computed(function() {
var oIdentity = this.identityMain(); var oIdentity = this.identityMain();
return oIdentity ? oIdentity.formattedName() : '---'; return oIdentity ? oIdentity.formattedName() : '---';
}, this); }, this);
this.editorDefaultTypes = ko.computed(function () { this.editorDefaultTypes = ko.computed(function() {
Translator.trigger(); Translator.trigger();
return [ return [
{'id': Enums.EditorDefaultType.Html, 'name': Translator.i18n('SETTINGS_GENERAL/LABEL_EDITOR_HTML')}, {'id': Enums.EditorDefaultType.Html, 'name': Translator.i18n('SETTINGS_GENERAL/LABEL_EDITOR_HTML')},
@ -87,7 +82,7 @@
]; ];
}, this); }, this);
this.layoutTypes = ko.computed(function () { this.layoutTypes = ko.computed(function() {
Translator.trigger(); Translator.trigger();
return [ return [
{'id': Enums.Layout.NoPreview, 'name': Translator.i18n('SETTINGS_GENERAL/LABEL_LAYOUT_NO_SPLIT')}, {'id': Enums.Layout.NoPreview, 'name': Translator.i18n('SETTINGS_GENERAL/LABEL_LAYOUT_NO_SPLIT')},
@ -95,43 +90,42 @@
{'id': Enums.Layout.BottomPreview, 'name': Translator.i18n('SETTINGS_GENERAL/LABEL_LAYOUT_HORIZONTAL_SPLIT')} {'id': Enums.Layout.BottomPreview, 'name': Translator.i18n('SETTINGS_GENERAL/LABEL_LAYOUT_HORIZONTAL_SPLIT')}
]; ];
}, this); }, this);
} }
GeneralUserSettings.prototype.editMainIdentity = function () GeneralUserSettings.prototype.editMainIdentity = function()
{ {
var oIdentity = this.identityMain(); var oIdentity = this.identityMain();
if (oIdentity) if (oIdentity)
{ {
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Identity'), [oIdentity]); require('Knoin/Knoin').showScreenPopup(require('View/Popup/Identity'), [oIdentity]);
} }
}; };
GeneralUserSettings.prototype.testSoundNotification = function () GeneralUserSettings.prototype.testSoundNotification = function()
{ {
NotificationStore.playSoundNotification(true); NotificationStore.playSoundNotification(true);
}; };
GeneralUserSettings.prototype.onBuild = function () GeneralUserSettings.prototype.onBuild = function()
{ {
var self = this; var self = this;
_.delay(function () { _.delay(function() {
var var
f0 = Utils.settingsSaveHelperSimpleFunction(self.editorDefaultTypeTrigger, self), f0 = Utils.settingsSaveHelperSimpleFunction(self.editorDefaultTypeTrigger, self),
f1 = Utils.settingsSaveHelperSimpleFunction(self.mppTrigger, self), f1 = Utils.settingsSaveHelperSimpleFunction(self.mppTrigger, self),
f2 = Utils.settingsSaveHelperSimpleFunction(self.layoutTrigger, self), f2 = Utils.settingsSaveHelperSimpleFunction(self.layoutTrigger, self),
fReloadLanguageHelper = function (iSaveSettingsStep) { fReloadLanguageHelper = function(iSaveSettingsStep) {
return function() { return function() {
self.languageTrigger(iSaveSettingsStep); self.languageTrigger(iSaveSettingsStep);
_.delay(function () { _.delay(function() {
self.languageTrigger(Enums.SaveSettingsStep.Idle); self.languageTrigger(Enums.SaveSettingsStep.Idle);
}, 1000); }, 1000);
}; };
} };
;
self.language.subscribe(function (sValue) { self.language.subscribe(function(sValue) {
self.languageTrigger(Enums.SaveSettingsStep.Animate); self.languageTrigger(Enums.SaveSettingsStep.Animate);
@ -146,49 +140,49 @@
}); });
self.editorDefaultType.subscribe(function (sValue) { self.editorDefaultType.subscribe(function(sValue) {
Remote.saveSettings(f0, { Remote.saveSettings(f0, {
'EditorDefaultType': sValue 'EditorDefaultType': sValue
}); });
}); });
self.messagesPerPage.subscribe(function (iValue) { self.messagesPerPage.subscribe(function(iValue) {
Remote.saveSettings(f1, { Remote.saveSettings(f1, {
'MPP': iValue 'MPP': iValue
}); });
}); });
self.showImages.subscribe(function (bValue) { self.showImages.subscribe(function(bValue) {
Remote.saveSettings(null, { Remote.saveSettings(null, {
'ShowImages': bValue ? '1' : '0' 'ShowImages': bValue ? '1' : '0'
}); });
}); });
self.enableDesktopNotification.subscribe(function (bValue) { self.enableDesktopNotification.subscribe(function(bValue) {
Utils.timeOutAction('SaveDesktopNotifications', function () { Utils.timeOutAction('SaveDesktopNotifications', function() {
Remote.saveSettings(null, { Remote.saveSettings(null, {
'DesktopNotifications': bValue ? '1' : '0' 'DesktopNotifications': bValue ? '1' : '0'
}); });
}, 3000); }, 3000);
}); });
self.enableSoundNotification.subscribe(function (bValue) { self.enableSoundNotification.subscribe(function(bValue) {
Utils.timeOutAction('SaveSoundNotification', function () { Utils.timeOutAction('SaveSoundNotification', function() {
Remote.saveSettings(null, { Remote.saveSettings(null, {
'SoundNotification': bValue ? '1' : '0' 'SoundNotification': bValue ? '1' : '0'
}); });
}, 3000); }, 3000);
}); });
self.replySameFolder.subscribe(function (bValue) { self.replySameFolder.subscribe(function(bValue) {
Utils.timeOutAction('SaveReplySameFolder', function () { Utils.timeOutAction('SaveReplySameFolder', function() {
Remote.saveSettings(null, { Remote.saveSettings(null, {
'ReplySameFolder': bValue ? '1' : '0' 'ReplySameFolder': bValue ? '1' : '0'
}); });
}, 3000); }, 3000);
}); });
self.useThreads.subscribe(function (bValue) { self.useThreads.subscribe(function(bValue) {
MessageStore.messageList([]); MessageStore.messageList([]);
@ -197,7 +191,7 @@
}); });
}); });
self.layout.subscribe(function (nValue) { self.layout.subscribe(function(nValue) {
MessageStore.messageList([]); MessageStore.messageList([]);
@ -206,27 +200,25 @@
}); });
}); });
self.useCheckboxesInList.subscribe(function (bValue) { self.useCheckboxesInList.subscribe(function(bValue) {
Remote.saveSettings(null, { Remote.saveSettings(null, {
'UseCheckboxesInList': bValue ? '1' : '0' 'UseCheckboxesInList': bValue ? '1' : '0'
}); });
}); });
}, 50); }, 50);
}; };
GeneralUserSettings.prototype.onShow = function () GeneralUserSettings.prototype.onShow = function()
{ {
this.enableDesktopNotification.valueHasMutated(); this.enableDesktopNotification.valueHasMutated();
}; };
GeneralUserSettings.prototype.selectLanguage = function () GeneralUserSettings.prototype.selectLanguage = function()
{ {
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Languages'), [ require('Knoin/Knoin').showScreenPopup(require('View/Popup/Languages'), [
this.language, this.languages(), LanguageStore.userLanguage() this.language, this.languages(), LanguageStore.userLanguage()
]); ]);
}; };
module.exports = GeneralUserSettings; module.exports = GeneralUserSettings;
}());

View file

@ -1,9 +1,5 @@
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
ko = require('ko'), ko = require('ko'),
window = require('window'), window = require('window'),
@ -12,14 +8,13 @@
kn = require('Knoin/Knoin'), kn = require('Knoin/Knoin'),
PgpStore = require('Stores/User/Pgp') PgpStore = require('Stores/User/Pgp');
;
/** /**
* @constructor * @constructor
*/ */
function OpenPgpUserSettings() function OpenPgpUserSettings()
{ {
this.openpgpkeys = PgpStore.openpgpkeys; this.openpgpkeys = PgpStore.openpgpkeys;
this.openpgpkeysPublic = PgpStore.openpgpkeysPublic; this.openpgpkeysPublic = PgpStore.openpgpkeysPublic;
this.openpgpkeysPrivate = PgpStore.openpgpkeysPrivate; this.openpgpkeysPrivate = PgpStore.openpgpkeysPrivate;
@ -27,38 +22,38 @@
this.openPgpKeyForDeletion = ko.observable(null).deleteAccessHelper(); this.openPgpKeyForDeletion = ko.observable(null).deleteAccessHelper();
this.isHttps = window.document && window.document.location ? 'https:' === window.document.location.protocol : false; this.isHttps = window.document && window.document.location ? 'https:' === window.document.location.protocol : false;
} }
OpenPgpUserSettings.prototype.addOpenPgpKey = function () OpenPgpUserSettings.prototype.addOpenPgpKey = function()
{ {
kn.showScreenPopup(require('View/Popup/AddOpenPgpKey')); kn.showScreenPopup(require('View/Popup/AddOpenPgpKey'));
}; };
OpenPgpUserSettings.prototype.generateOpenPgpKey = function () OpenPgpUserSettings.prototype.generateOpenPgpKey = function()
{ {
kn.showScreenPopup(require('View/Popup/NewOpenPgpKey')); kn.showScreenPopup(require('View/Popup/NewOpenPgpKey'));
}; };
OpenPgpUserSettings.prototype.viewOpenPgpKey = function (oOpenPgpKey) OpenPgpUserSettings.prototype.viewOpenPgpKey = function(oOpenPgpKey)
{ {
if (oOpenPgpKey) if (oOpenPgpKey)
{ {
kn.showScreenPopup(require('View/Popup/ViewOpenPgpKey'), [oOpenPgpKey]); kn.showScreenPopup(require('View/Popup/ViewOpenPgpKey'), [oOpenPgpKey]);
} }
}; };
/** /**
* @param {OpenPgpKeyModel} oOpenPgpKeyToRemove * @param {OpenPgpKeyModel} oOpenPgpKeyToRemove
*/ */
OpenPgpUserSettings.prototype.deleteOpenPgpKey = function (oOpenPgpKeyToRemove) OpenPgpUserSettings.prototype.deleteOpenPgpKey = function(oOpenPgpKeyToRemove)
{ {
if (oOpenPgpKeyToRemove && oOpenPgpKeyToRemove.deleteAccess()) if (oOpenPgpKeyToRemove && oOpenPgpKeyToRemove.deleteAccess())
{ {
this.openPgpKeyForDeletion(null); this.openPgpKeyForDeletion(null);
if (oOpenPgpKeyToRemove && PgpStore.openpgpKeyring) if (oOpenPgpKeyToRemove && PgpStore.openpgpKeyring)
{ {
var oFindedItem = _.find(PgpStore.openpgpkeys(), function (oOpenPgpKey) { var oFindedItem = _.find(PgpStore.openpgpkeys(), function(oOpenPgpKey) {
return oOpenPgpKeyToRemove === oOpenPgpKey; return oOpenPgpKeyToRemove === oOpenPgpKey;
}); });
@ -76,8 +71,6 @@
require('App/User').default.reloadOpenPgpKeys(); require('App/User').default.reloadOpenPgpKeys();
} }
} }
}; };
module.exports = OpenPgpUserSettings; module.exports = OpenPgpUserSettings;
}());

View file

@ -1,9 +1,5 @@
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
ko = require('ko'), ko = require('ko'),
@ -15,21 +11,20 @@
Settings = require('Storage/Settings'), Settings = require('Storage/Settings'),
Remote = require('Remote/User/Ajax') Remote = require('Remote/User/Ajax');
;
/** /**
* @constructor * @constructor
*/ */
function SecurityUserSettings() function SecurityUserSettings()
{ {
this.capaAutoLogout = Settings.capa(Enums.Capa.AutoLogout); this.capaAutoLogout = Settings.capa(Enums.Capa.AutoLogout);
this.capaTwoFactor = Settings.capa(Enums.Capa.TwoFactor); this.capaTwoFactor = Settings.capa(Enums.Capa.TwoFactor);
this.autoLogout = SettinsStore.autoLogout; this.autoLogout = SettinsStore.autoLogout;
this.autoLogout.trigger = ko.observable(Enums.SaveSettingsStep.Idle); this.autoLogout.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.autoLogoutOptions = ko.computed(function () { this.autoLogoutOptions = ko.computed(function() {
Translator.trigger(); Translator.trigger();
return [ return [
{'id': 0, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_NEVER_OPTION_NAME')}, {'id': 0, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_NEVER_OPTION_NAME')},
@ -42,26 +37,25 @@
{'id': 60 * 10, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_HOURS_OPTION_NAME', {'HOURS': 10})} {'id': 60 * 10, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_HOURS_OPTION_NAME', {'HOURS': 10})}
]; ];
}); });
} }
SecurityUserSettings.prototype.configureTwoFactor = function () SecurityUserSettings.prototype.configureTwoFactor = function()
{ {
require('Knoin/Knoin').showScreenPopup(require('View/Popup/TwoFactorConfiguration')); require('Knoin/Knoin').showScreenPopup(require('View/Popup/TwoFactorConfiguration'));
}; };
SecurityUserSettings.prototype.onBuild = function () SecurityUserSettings.prototype.onBuild = function()
{ {
if (this.capaAutoLogout) if (this.capaAutoLogout)
{ {
var self = this; var self = this;
_.delay(function () { _.delay(function() {
var var
f0 = Utils.settingsSaveHelperSimpleFunction(self.autoLogout.trigger, self) f0 = Utils.settingsSaveHelperSimpleFunction(self.autoLogout.trigger, self);
;
self.autoLogout.subscribe(function (sValue) { self.autoLogout.subscribe(function(sValue) {
Remote.saveSettings(f0, { Remote.saveSettings(f0, {
'AutoLogout': Utils.pInt(sValue) 'AutoLogout': Utils.pInt(sValue)
}); });
@ -69,8 +63,6 @@
}); });
} }
}; };
module.exports = SecurityUserSettings; module.exports = SecurityUserSettings;
}());

View file

@ -1,17 +1,12 @@
(function () { /**
'use strict';
/**
* @constructor * @constructor
*/ */
function SocialUserSettings() function SocialUserSettings()
{ {
var var
Utils = require('Common/Utils'), Utils = require('Common/Utils'),
SocialStore = require('Stores/Social') SocialStore = require('Stores/Social');
;
this.googleEnable = SocialStore.google.enabled; this.googleEnable = SocialStore.google.enabled;
this.googleEnableAuth = SocialStore.google.capa.auth; this.googleEnableAuth = SocialStore.google.capa.auth;
@ -35,46 +30,44 @@
this.twitterLoggined = SocialStore.twitter.loggined; this.twitterLoggined = SocialStore.twitter.loggined;
this.twitterUserName = SocialStore.twitter.userName; this.twitterUserName = SocialStore.twitter.userName;
this.connectGoogle = Utils.createCommand(this, function () { this.connectGoogle = Utils.createCommand(this, function() {
if (!this.googleLoggined()) if (!this.googleLoggined())
{ {
require('App/User').default.googleConnect(); require('App/User').default.googleConnect();
} }
}, function () { }, function() {
return !this.googleLoggined() && !this.googleActions(); return !this.googleLoggined() && !this.googleActions();
}); });
this.disconnectGoogle = Utils.createCommand(this, function () { this.disconnectGoogle = Utils.createCommand(this, function() {
require('App/User').default.googleDisconnect(); require('App/User').default.googleDisconnect();
}); });
this.connectFacebook = Utils.createCommand(this, function () { this.connectFacebook = Utils.createCommand(this, function() {
if (!this.facebookLoggined()) if (!this.facebookLoggined())
{ {
require('App/User').default.facebookConnect(); require('App/User').default.facebookConnect();
} }
}, function () { }, function() {
return !this.facebookLoggined() && !this.facebookActions(); return !this.facebookLoggined() && !this.facebookActions();
}); });
this.disconnectFacebook = Utils.createCommand(this, function () { this.disconnectFacebook = Utils.createCommand(this, function() {
require('App/User').default.facebookDisconnect(); require('App/User').default.facebookDisconnect();
}); });
this.connectTwitter = Utils.createCommand(this, function () { this.connectTwitter = Utils.createCommand(this, function() {
if (!this.twitterLoggined()) if (!this.twitterLoggined())
{ {
require('App/User').default.twitterConnect(); require('App/User').default.twitterConnect();
} }
}, function () { }, function() {
return !this.twitterLoggined() && !this.twitterActions(); return !this.twitterLoggined() && !this.twitterActions();
}); });
this.disconnectTwitter = Utils.createCommand(this, function () { this.disconnectTwitter = Utils.createCommand(this, function() {
require('App/User').default.twitterDisconnect(); require('App/User').default.twitterDisconnect();
}); });
} }
module.exports = SocialUserSettings; module.exports = SocialUserSettings;
}());

View file

@ -1,107 +1,98 @@
(function () { var
'use strict';
var
ko = require('ko'), ko = require('ko'),
Translator = require('Common/Translator'), Translator = require('Common/Translator'),
TemplateStore = require('Stores/User/Template'), TemplateStore = require('Stores/User/Template'),
Remote = require('Remote/User/Ajax') Remote = require('Remote/User/Ajax');
;
/** /**
* @constructor * @constructor
*/ */
function TemplatesUserSettings() function TemplatesUserSettings()
{ {
this.templates = TemplateStore.templates; this.templates = TemplateStore.templates;
this.processText = ko.computed(function () { this.processText = ko.computed(function() {
return TemplateStore.templates.loading() ? Translator.i18n('SETTINGS_TEMPLETS/LOADING_PROCESS') : ''; return TemplateStore.templates.loading() ? Translator.i18n('SETTINGS_TEMPLETS/LOADING_PROCESS') : '';
}, this); }, this);
this.visibility = ko.computed(function () { this.visibility = ko.computed(function() {
return '' === this.processText() ? 'hidden' : 'visible'; return '' === this.processText() ? 'hidden' : 'visible';
}, this); }, this);
this.templateForDeletion = ko.observable(null).deleteAccessHelper(); this.templateForDeletion = ko.observable(null).deleteAccessHelper();
} }
TemplatesUserSettings.prototype.scrollableOptions = function (sWrapper) TemplatesUserSettings.prototype.scrollableOptions = function(sWrapper)
{ {
return { return {
handle: '.drag-handle', handle: '.drag-handle',
containment: sWrapper || 'parent', containment: sWrapper || 'parent',
axis: 'y' axis: 'y'
}; };
}; };
TemplatesUserSettings.prototype.addNewTemplate = function () TemplatesUserSettings.prototype.addNewTemplate = function()
{ {
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Template')); require('Knoin/Knoin').showScreenPopup(require('View/Popup/Template'));
}; };
TemplatesUserSettings.prototype.editTemplate = function (oTemplateItem) TemplatesUserSettings.prototype.editTemplate = function(oTemplateItem)
{ {
if (oTemplateItem) if (oTemplateItem)
{ {
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Template'), [oTemplateItem]); require('Knoin/Knoin').showScreenPopup(require('View/Popup/Template'), [oTemplateItem]);
} }
}; };
/** /**
* @param {AccountModel} oTemplateToRemove * @param {AccountModel} oTemplateToRemove
*/ */
TemplatesUserSettings.prototype.deleteTemplate = function (oTemplateToRemove) TemplatesUserSettings.prototype.deleteTemplate = function(oTemplateToRemove)
{ {
if (oTemplateToRemove && oTemplateToRemove.deleteAccess()) if (oTemplateToRemove && oTemplateToRemove.deleteAccess())
{ {
this.templateForDeletion(null); this.templateForDeletion(null);
var var
self = this, self = this,
fRemoveAccount = function (oAccount) { fRemoveAccount = function(oAccount) {
return oTemplateToRemove === oAccount; return oTemplateToRemove === oAccount;
} };
;
if (oTemplateToRemove) if (oTemplateToRemove)
{ {
this.templates.remove(fRemoveAccount); this.templates.remove(fRemoveAccount);
Remote.templateDelete(function () { Remote.templateDelete(function() {
self.reloadTemplates(); self.reloadTemplates();
}, oTemplateToRemove.id); }, oTemplateToRemove.id);
} }
} }
}; };
TemplatesUserSettings.prototype.reloadTemplates = function () TemplatesUserSettings.prototype.reloadTemplates = function()
{ {
require('App/User').default.templates(); require('App/User').default.templates();
}; };
TemplatesUserSettings.prototype.onBuild = function (oDom) TemplatesUserSettings.prototype.onBuild = function(oDom)
{ {
var self = this; var self = this;
oDom oDom
.on('click', '.templates-list .template-item .e-action', function () { .on('click', '.templates-list .template-item .e-action', function() {
var oTemplateItem = ko.dataFor(this); var oTemplateItem = ko.dataFor(this);
if (oTemplateItem) if (oTemplateItem)
{ {
self.editTemplate(oTemplateItem); self.editTemplate(oTemplateItem);
} }
}) });
;
this.reloadTemplates(); this.reloadTemplates();
}; };
module.exports = TemplatesUserSettings; module.exports = TemplatesUserSettings;
}());

View file

@ -1,9 +1,5 @@
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
$ = require('$'), $ = require('$'),
ko = require('ko'), ko = require('ko'),
@ -19,14 +15,13 @@
Settings = require('Storage/Settings'), Settings = require('Storage/Settings'),
Remote = require('Remote/User/Ajax') Remote = require('Remote/User/Ajax');
;
/** /**
* @constructor * @constructor
*/ */
function ThemesUserSettings() function ThemesUserSettings()
{ {
this.theme = ThemeStore.theme; this.theme = ThemeStore.theme;
this.themes = ThemeStore.themes; this.themes = ThemeStore.themes;
this.themesObjects = ko.observableArray([]); this.themesObjects = ko.observableArray([]);
@ -45,9 +40,9 @@
this.iTimer = 0; this.iTimer = 0;
this.oThemeAjaxRequest = null; this.oThemeAjaxRequest = null;
this.theme.subscribe(function (sValue) { this.theme.subscribe(function(sValue) {
_.each(this.themesObjects(), function (oTheme) { _.each(this.themesObjects(), function(oTheme) {
oTheme.selected(sValue === oTheme.name); oTheme.selected(sValue === oTheme.name);
}); });
@ -59,7 +54,7 @@
}, this); }, this);
this.background.hash.subscribe(function (sValue) { this.background.hash.subscribe(function(sValue) {
var $oBg = $('#rl-bg'); var $oBg = $('#rl-bg');
if (!sValue) if (!sValue)
@ -78,12 +73,12 @@
} }
}, this); }, this);
} }
ThemesUserSettings.prototype.onBuild = function () ThemesUserSettings.prototype.onBuild = function()
{ {
var sCurrentTheme = this.theme(); var sCurrentTheme = this.theme();
this.themesObjects(_.map(this.themes(), function (sTheme) { this.themesObjects(_.map(this.themes(), function(sTheme) {
return { return {
'name': sTheme, 'name': sTheme,
'nameDisplay': Utils.convertThemeName(sTheme), 'nameDisplay': Utils.convertThemeName(sTheme),
@ -93,27 +88,27 @@
})); }));
this.initUploader(); this.initUploader();
}; };
ThemesUserSettings.prototype.onShow = function () ThemesUserSettings.prototype.onShow = function()
{ {
this.background.error(''); this.background.error('');
}; };
ThemesUserSettings.prototype.clearBackground = function () ThemesUserSettings.prototype.clearBackground = function()
{ {
if (this.capaUserBackground()) if (this.capaUserBackground())
{ {
var self = this; var self = this;
Remote.clearUserBackground(function () { Remote.clearUserBackground(function() {
self.background.name(''); self.background.name('');
self.background.hash(''); self.background.hash('');
}); });
} }
}; };
ThemesUserSettings.prototype.initUploader = function () ThemesUserSettings.prototype.initUploader = function()
{ {
if (this.background.uploaderButton() && this.capaUserBackground()) if (this.background.uploaderButton() && this.capaUserBackground())
{ {
var var
@ -125,11 +120,10 @@
'disableDragAndDrop': true, 'disableDragAndDrop': true,
'disableMultiple': true, 'disableMultiple': true,
'clickElement': this.background.uploaderButton() 'clickElement': this.background.uploaderButton()
}) });
;
oJua oJua
.on('onStart', _.bind(function () { .on('onStart', _.bind(function() {
this.background.loading(true); this.background.loading(true);
this.background.error(''); this.background.error('');
@ -137,7 +131,7 @@
return true; return true;
}, this)) }, this))
.on('onComplete', _.bind(function (sId, bResult, oData) { .on('onComplete', _.bind(function(sId, bResult, oData) {
this.background.loading(false); this.background.loading(false);
@ -162,6 +156,7 @@
case Enums.UploadErrorCode.FileType: case Enums.UploadErrorCode.FileType:
sError = Translator.i18n('SETTINGS_THEMES/ERROR_FILE_TYPE_ERROR'); sError = Translator.i18n('SETTINGS_THEMES/ERROR_FILE_TYPE_ERROR');
break; break;
// no default
} }
} }
@ -175,11 +170,8 @@
return true; return true;
}, this)) }, this));
;
} }
}; };
module.exports = ThemesUserSettings; module.exports = ThemesUserSettings;
}());

View file

@ -12,7 +12,7 @@ const driver = SupportedStorageDriver ? new SupportedStorageDriver() : null;
/** /**
* @param {number} key * @param {number} key
* @param {*} data * @param {*} data
* @return {boolean} * @returns {boolean}
*/ */
export function set(key, data) export function set(key, data)
{ {
@ -21,7 +21,7 @@ export function set(key, data)
/** /**
* @param {number} key * @param {number} key
* @return {*} * @returns {*}
*/ */
export function get(key) export function get(key)
{ {

View file

@ -45,35 +45,43 @@ const timestamp = () => window.Math.round((new window.Date()).getTime() / 1000);
const setTimestamp = () => __set(TIME_KEY, timestamp()); const setTimestamp = () => __set(TIME_KEY, timestamp());
const getTimestamp = () => { const getTimestamp = () => {
let time = __get(TIME_KEY, 0); const time = __get(TIME_KEY, 0);
return time ? (window.parseInt(time, 10) || 0) : 0; return time ? (window.parseInt(time, 10) || 0) : 0;
}; };
/** /**
* @return {string} * @returns {string}
*/ */
export function getHash() export function getHash()
{ {
return __get(STORAGE_KEY); return __get(STORAGE_KEY);
} }
/**
* @returns {void}
*/
export function setHash() export function setHash()
{ {
const const
key = 'AuthAccountHash', key = 'AuthAccountHash',
appData = window.__rlah_data() appData = window.__rlah_data();
;
__set(STORAGE_KEY, appData && appData[key] ? appData[key] : ''); __set(STORAGE_KEY, appData && appData[key] ? appData[key] : '');
setTimestamp(); setTimestamp();
} }
/**
* @returns {void}
*/
export function clearHash() export function clearHash()
{ {
__set(STORAGE_KEY, ''); __set(STORAGE_KEY, '');
setTimestamp(); setTimestamp();
} }
/**
* @returns {boolean}
*/
export function checkTimestamp() export function checkTimestamp()
{ {
if (timestamp() > getTimestamp() + 1000 * 60 * 60) // 60m if (timestamp() > getTimestamp() + 1000 * 60 * 60) // 60m

View file

@ -10,7 +10,7 @@ APP_SETTINGS = isNormal(APP_SETTINGS) ? APP_SETTINGS : {};
/** /**
* @param {string} name * @param {string} name
* @return {*} * @returns {*}
*/ */
export function settingsGet(name) export function settingsGet(name)
{ {
@ -28,7 +28,7 @@ export function settingsSet(name, value)
/** /**
* @param {string} name * @param {string} name
* @return {*} * @returns {*}
*/ */
export function appSettingsGet(name) export function appSettingsGet(name)
{ {
@ -37,7 +37,7 @@ export function appSettingsGet(name)
/** /**
* @param {string} name * @param {string} name
* @return {boolean} * @returns {boolean}
*/ */
export function capa(name) export function capa(name)
{ {

View file

@ -12,7 +12,7 @@ class AbstractAppStore
this.interfaceAnimation = ko.observable(true); this.interfaceAnimation = ko.observable(true);
this.interfaceAnimation.subscribe(function (bValue) { this.interfaceAnimation.subscribe(function(bValue) {
const bAnim = bMobileDevice || !bValue; const bAnim = bMobileDevice || !bValue;
$html.toggleClass('rl-anim', !bAnim).toggleClass('no-rl-anim', bAnim); $html.toggleClass('rl-anim', !bAnim).toggleClass('no-rl-anim', bAnim);
}); });

View file

@ -1,21 +1,16 @@
(function () { var
'use strict';
var
ko = require('ko'), ko = require('ko'),
Enums = require('Common/Enums'), Enums = require('Common/Enums'),
Settings = require('Storage/Settings') Settings = require('Storage/Settings');
;
/** /**
* @constructor * @constructor
*/ */
function CapaAdminStore() function CapaAdminStore()
{ {
this.additionalAccounts = ko.observable(false); this.additionalAccounts = ko.observable(false);
this.identities = ko.observable(false); this.identities = ko.observable(false);
this.gravatar = ko.observable(false); this.gravatar = ko.observable(false);
@ -28,10 +23,10 @@
this.twoFactorAuth = ko.observable(false); this.twoFactorAuth = ko.observable(false);
this.twoFactorAuthForce = ko.observable(false); this.twoFactorAuthForce = ko.observable(false);
this.templates = ko.observable(false); this.templates = ko.observable(false);
} }
CapaAdminStore.prototype.populate = function() CapaAdminStore.prototype.populate = function()
{ {
this.additionalAccounts(Settings.capa(Enums.Capa.AdditionalAccounts)); this.additionalAccounts(Settings.capa(Enums.Capa.AdditionalAccounts));
this.identities(Settings.capa(Enums.Capa.Identities)); this.identities(Settings.capa(Enums.Capa.Identities));
this.gravatar(Settings.capa(Enums.Capa.Gravatar)); this.gravatar(Settings.capa(Enums.Capa.Gravatar));
@ -44,8 +39,6 @@
this.twoFactorAuth(Settings.capa(Enums.Capa.TwoFactor)); this.twoFactorAuth(Settings.capa(Enums.Capa.TwoFactor));
this.twoFactorAuthForce(Settings.capa(Enums.Capa.TwoFactorForce)); this.twoFactorAuthForce(Settings.capa(Enums.Capa.TwoFactorForce));
this.templates(Settings.capa(Enums.Capa.Templates)); this.templates(Settings.capa(Enums.Capa.Templates));
}; };
module.exports = new CapaAdminStore(); module.exports = new CapaAdminStore();
}());

View file

@ -1,17 +1,11 @@
(function () { var ko = require('ko');
'use strict'; /**
var
ko = require('ko')
;
/**
* @constructor * @constructor
*/ */
function CoreAdminStore() function CoreAdminStore()
{ {
this.coreReal = ko.observable(true); this.coreReal = ko.observable(true);
this.coreChannel = ko.observable('stable'); this.coreChannel = ko.observable('stable');
this.coreType = ko.observable('stable'); this.coreType = ko.observable('stable');
@ -24,8 +18,6 @@
this.coreRemoteVersion = ko.observable(''); this.coreRemoteVersion = ko.observable('');
this.coreRemoteRelease = ko.observable(''); this.coreRemoteRelease = ko.observable('');
this.coreVersionCompare = ko.observable(-2); this.coreVersionCompare = ko.observable(-2);
} }
module.exports = new CoreAdminStore(); module.exports = new CoreAdminStore();
}());

View file

@ -1,25 +1,17 @@
(function () { var ko = require('ko');
'use strict'; /**
var
ko = require('ko')
;
/**
* @constructor * @constructor
*/ */
function DomainAdminStore() function DomainAdminStore()
{ {
this.domains = ko.observableArray([]); this.domains = ko.observableArray([]);
this.domains.loading = ko.observable(false).extend({'throttle': 100}); this.domains.loading = ko.observable(false).extend({'throttle': 100});
this.domainsWithoutAliases = this.domains.filter(function (oItem) { this.domainsWithoutAliases = this.domains.filter(function(oItem) {
return oItem && !oItem.alias; return oItem && !oItem.alias;
}); });
} }
module.exports = new DomainAdminStore(); module.exports = new DomainAdminStore();
}());

View file

@ -1,17 +1,11 @@
(function () { var ko = require('ko');
'use strict'; /**
var
ko = require('ko')
;
/**
* @constructor * @constructor
*/ */
function LicenseAdminStore() function LicenseAdminStore()
{ {
this.licensing = ko.observable(false); this.licensing = ko.observable(false);
this.licensingProcess = ko.observable(false); this.licensingProcess = ko.observable(false);
this.licenseValid = ko.observable(false); this.licenseValid = ko.observable(false);
@ -19,8 +13,6 @@
this.licenseError = ko.observable(''); this.licenseError = ko.observable('');
this.licenseTrigger = ko.observable(false); this.licenseTrigger = ko.observable(false);
} }
module.exports = new LicenseAdminStore(); module.exports = new LicenseAdminStore();
}());

View file

@ -1,24 +1,16 @@
(function () { var ko = require('ko');
'use strict'; /**
var
ko = require('ko')
;
/**
* @constructor * @constructor
*/ */
function PackageAdminStore() function PackageAdminStore()
{ {
this.packages = ko.observableArray([]); this.packages = ko.observableArray([]);
this.packages.loading = ko.observable(false).extend({'throttle': 100}); this.packages.loading = ko.observable(false).extend({'throttle': 100});
this.packagesReal = ko.observable(true); this.packagesReal = ko.observable(true);
this.packagesMainUpdatable = ko.observable(true); this.packagesMainUpdatable = ko.observable(true);
} }
module.exports = new PackageAdminStore(); module.exports = new PackageAdminStore();
}());

View file

@ -1,22 +1,14 @@
(function () { var ko = require('ko');
'use strict'; /**
var
ko = require('ko')
;
/**
* @constructor * @constructor
*/ */
function PluginAdminStore() function PluginAdminStore()
{ {
this.plugins = ko.observableArray([]); this.plugins = ko.observableArray([]);
this.plugins.loading = ko.observable(false).extend({'throttle': 100}); this.plugins.loading = ko.observable(false).extend({'throttle': 100});
this.plugins.error = ko.observable(''); this.plugins.error = ko.observable('');
} }
module.exports = new PluginAdminStore(); module.exports = new PluginAdminStore();
}());

View file

@ -1,44 +1,36 @@
(function () { var
'use strict';
var
ko = require('ko'), ko = require('ko'),
Utils = require('Common/Utils'), Utils = require('Common/Utils'),
Settings = require('Storage/Settings') Settings = require('Storage/Settings');
;
/** /**
* @constructor * @constructor
*/ */
function LanguageStore() function LanguageStore()
{ {
this.languages = ko.observableArray([]); this.languages = ko.observableArray([]);
this.languagesAdmin = ko.observableArray([]); this.languagesAdmin = ko.observableArray([]);
this.language = ko.observable('') this.language = ko.observable('')
.extend({'limitedList': this.languages}) .extend({'limitedList': this.languages})
.extend({'reversible': true}) .extend({'reversible': true});
;
this.languageAdmin = ko.observable('') this.languageAdmin = ko.observable('')
.extend({'limitedList': this.languagesAdmin}) .extend({'limitedList': this.languagesAdmin})
.extend({'reversible': true}) .extend({'reversible': true});
;
this.userLanguage = ko.observable(''); this.userLanguage = ko.observable('');
this.userLanguageAdmin = ko.observable(''); this.userLanguageAdmin = ko.observable('');
} }
LanguageStore.prototype.populate = function () LanguageStore.prototype.populate = function()
{ {
var var
aLanguages = Settings.appSettingsGet('languages'), aLanguages = Settings.appSettingsGet('languages'),
aLanguagesAdmin = Settings.appSettingsGet('languagesAdmin') aLanguagesAdmin = Settings.appSettingsGet('languagesAdmin');
;
this.languages(Utils.isArray(aLanguages) ? aLanguages : []); this.languages(Utils.isArray(aLanguages) ? aLanguages : []);
this.languagesAdmin(Utils.isArray(aLanguagesAdmin) ? aLanguagesAdmin : []); this.languagesAdmin(Utils.isArray(aLanguagesAdmin) ? aLanguagesAdmin : []);
@ -48,8 +40,6 @@
this.userLanguage(Settings.settingsGet('UserLanguage')); this.userLanguage(Settings.settingsGet('UserLanguage'));
this.userLanguageAdmin(Settings.settingsGet('UserLanguageAdmin')); this.userLanguageAdmin(Settings.settingsGet('UserLanguageAdmin'));
}; };
module.exports = new LanguageStore(); module.exports = new LanguageStore();
}());

View file

@ -1,17 +1,11 @@
(function () { var ko = require('ko');
'use strict'; /**
var
ko = require('ko')
;
/**
* @constructor * @constructor
*/ */
function SocialStore() function SocialStore()
{ {
this.google = {}; this.google = {};
this.twitter = {}; this.twitter = {};
this.facebook = {}; this.facebook = {};
@ -27,7 +21,7 @@
this.google.loading = ko.observable(false); this.google.loading = ko.observable(false);
this.google.userName = ko.observable(''); this.google.userName = ko.observable('');
this.google.loggined = ko.computed(function () { this.google.loggined = ko.computed(function() {
return '' !== this.google.userName(); return '' !== this.google.userName();
}, this); }, this);
@ -38,11 +32,11 @@
this.google.capa.preview = ko.observable(false); this.google.capa.preview = ko.observable(false);
this.google.require = {}; this.google.require = {};
this.google.require.clientSettings = ko.computed(function () { this.google.require.clientSettings = ko.computed(function() {
return this.google.enabled() && (this.google.capa.auth() || this.google.capa.drive()); return this.google.enabled() && (this.google.capa.auth() || this.google.capa.drive());
}, this); }, this);
this.google.require.apiKeySettings = ko.computed(function () { this.google.require.apiKeySettings = ko.computed(function() {
return this.google.enabled() && this.google.capa.drive(); return this.google.enabled() && this.google.capa.drive();
}, this); }, this);
@ -54,7 +48,7 @@
this.facebook.userName = ko.observable(''); this.facebook.userName = ko.observable('');
this.facebook.supported = ko.observable(false); this.facebook.supported = ko.observable(false);
this.facebook.loggined = ko.computed(function () { this.facebook.loggined = ko.computed(function() {
return '' !== this.facebook.userName(); return '' !== this.facebook.userName();
}, this); }, this);
@ -65,22 +59,22 @@
this.twitter.loading = ko.observable(false); this.twitter.loading = ko.observable(false);
this.twitter.userName = ko.observable(''); this.twitter.userName = ko.observable('');
this.twitter.loggined = ko.computed(function () { this.twitter.loggined = ko.computed(function() {
return '' !== this.twitter.userName(); return '' !== this.twitter.userName();
}, this); }, this);
// Dropbox // Dropbox
this.dropbox.enabled = ko.observable(false); this.dropbox.enabled = ko.observable(false);
this.dropbox.apiKey = ko.observable(''); this.dropbox.apiKey = ko.observable('');
} }
SocialStore.prototype.google = {}; SocialStore.prototype.google = {};
SocialStore.prototype.twitter = {}; SocialStore.prototype.twitter = {};
SocialStore.prototype.facebook = {}; SocialStore.prototype.facebook = {};
SocialStore.prototype.dropbox = {}; SocialStore.prototype.dropbox = {};
SocialStore.prototype.populate = function () SocialStore.prototype.populate = function()
{ {
var Settings = require('Storage/Settings'); var Settings = require('Storage/Settings');
this.google.enabled(!!Settings.settingsGet('AllowGoogleSocial')); this.google.enabled(!!Settings.settingsGet('AllowGoogleSocial'));
@ -104,8 +98,6 @@
this.dropbox.enabled(!!Settings.settingsGet('AllowDropboxSocial')); this.dropbox.enabled(!!Settings.settingsGet('AllowDropboxSocial'));
this.dropbox.apiKey(Settings.settingsGet('DropboxApiKey')); this.dropbox.apiKey(Settings.settingsGet('DropboxApiKey'));
}; };
module.exports = new SocialStore(); module.exports = new SocialStore();
}());

View file

@ -1,39 +1,32 @@
(function () { var
'use strict';
var
ko = require('ko'), ko = require('ko'),
Utils = require('Common/Utils'), Utils = require('Common/Utils'),
Settings = require('Storage/Settings') Settings = require('Storage/Settings');
;
/** /**
* @constructor * @constructor
*/ */
function ThemeStore() function ThemeStore()
{ {
this.themes = ko.observableArray([]); this.themes = ko.observableArray([]);
this.themeBackgroundName = ko.observable(''); this.themeBackgroundName = ko.observable('');
this.themeBackgroundHash = ko.observable(''); this.themeBackgroundHash = ko.observable('');
this.theme = ko.observable('') this.theme = ko.observable('')
.extend({'limitedList': this.themes}); .extend({'limitedList': this.themes});
} }
ThemeStore.prototype.populate = function () ThemeStore.prototype.populate = function()
{ {
var aThemes = Settings.appSettingsGet('themes'); var aThemes = Settings.appSettingsGet('themes');
this.themes(Utils.isArray(aThemes) ? aThemes : []); this.themes(Utils.isArray(aThemes) ? aThemes : []);
this.theme(Settings.settingsGet('Theme')); this.theme(Settings.settingsGet('Theme'));
this.themeBackgroundName(Settings.settingsGet('UserBackgroundName')); this.themeBackgroundName(Settings.settingsGet('UserBackgroundName'));
this.themeBackgroundHash(Settings.settingsGet('UserBackgroundHash')); this.themeBackgroundHash(Settings.settingsGet('UserBackgroundHash'));
}; };
module.exports = new ThemeStore(); module.exports = new ThemeStore();
}());

View file

@ -1,20 +1,15 @@
(function () { var
'use strict';
var
_ = require('_'), _ = require('_'),
ko = require('ko'), ko = require('ko'),
Settings = require('Storage/Settings') Settings = require('Storage/Settings');
;
/** /**
* @constructor * @constructor
*/ */
function AccountUserStore() function AccountUserStore()
{ {
this.email = ko.observable(''); this.email = ko.observable('');
this.parentEmail = ko.observable(''); this.parentEmail = ko.observable('');
// this.incLogin = ko.observable(''); // this.incLogin = ko.observable('');
@ -26,21 +21,21 @@
this.accounts.loading = ko.observable(false).extend({'throttle': 100}); this.accounts.loading = ko.observable(false).extend({'throttle': 100});
this.computers(); this.computers();
} }
AccountUserStore.prototype.computers = function () AccountUserStore.prototype.computers = function()
{ {
this.accountsEmails = ko.computed(function () { this.accountsEmails = ko.computed(function() {
return _.compact(_.map(this.accounts(), function (oItem) { return _.compact(_.map(this.accounts(), function(oItem) {
return oItem ? oItem.email : null; return oItem ? oItem.email : null;
})); }));
}, this); }, this);
this.accountsUnreadCount = ko.computed(function () { this.accountsUnreadCount = ko.computed(function() {
var iResult = 0; var iResult = 0;
// _.each(this.accounts(), function (oItem) { // _.each(this.accounts(), function(oItem) {
// if (oItem) // if (oItem)
// { // {
// iResult += oItem.count(); // iResult += oItem.count();
@ -50,22 +45,20 @@
return iResult; return iResult;
}, this); }, this);
}; };
AccountUserStore.prototype.populate = function () AccountUserStore.prototype.populate = function()
{ {
this.email(Settings.settingsGet('Email')); this.email(Settings.settingsGet('Email'));
this.parentEmail(Settings.settingsGet('ParentEmail')); this.parentEmail(Settings.settingsGet('ParentEmail'));
}; };
/** /**
* @return {boolean} * @returns {boolean}
*/ */
AccountUserStore.prototype.isRootAccount = function () AccountUserStore.prototype.isRootAccount = function()
{ {
return '' === this.parentEmail(); return '' === this.parentEmail();
}; };
module.exports = new AccountUserStore(); module.exports = new AccountUserStore();
}());

View file

@ -17,12 +17,10 @@ class AppUserStore extends AbstractAppStore
this.focusedState = ko.observable(Focused.None); this.focusedState = ko.observable(Focused.None);
this.focusedState.subscribe(function (value) { this.focusedState.subscribe(function(value) {
switch (value) switch (value)
{ {
default:
break;
case Focused.MessageList: case Focused.MessageList:
keyScope(KeyState.MessageList); keyScope(KeyState.MessageList);
break; break;
@ -32,6 +30,8 @@ class AppUserStore extends AbstractAppStore
case Focused.FolderList: case Focused.FolderList:
keyScope(KeyState.FolderList); keyScope(KeyState.FolderList);
break; break;
default:
break;
} }
}, this); }, this);

Some files were not shown because too many files have changed in this diff Show more