CommonJS (research/4)

This commit is contained in:
RainLoop Team 2014-08-25 11:10:51 +04:00
parent 06bb124379
commit 8d73c7b1b2
127 changed files with 1893 additions and 1085 deletions

View file

@ -1,10 +1,9 @@
// Base64 encode / decode
// http://www.webtoolkit.info/
'use strict';
(function (module) {
'use strict';
/*jslint bitwise: true*/
var Base64 = {

View file

@ -1,9 +1,8 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
'use strict';
(function (module) {
'use strict';
var Consts = {};
Consts.Values = {};

View file

@ -1,9 +1,8 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
'use strict';
(function (module) {
'use strict';
var Enums = {};
/**

View file

@ -1,16 +1,15 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
'use strict';
(function (module) {
'use strict';
var
_ = require('../External/underscore.js'),
Utils = require('./Utils.js'),
Plugins = require('./Plugins.js')
;
/**
* @constructor
*/
@ -47,7 +46,7 @@
Events.prototype.pub = function (sName, aArgs)
{
Plugins.runHook('rl-pub', [sName, aArgs]);
if (!Utils.isUnd(this.oSubs[sName]))
{
_.each(this.oSubs[sName], function (aItem) {

View file

@ -1,16 +1,15 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
'use strict';
(function (module) {
'use strict';
var
Globals = {},
window = require('../External/window.js'),
ko = require('../External/ko.js'),
key = require('../External/key.js'),
$html = require('../External/$html.js'),
Enums = require('../Common/Enums.js')
;
@ -108,7 +107,7 @@
* @type {string}
*/
Globals.sAnimationType = '';
/**
* @type {*}
*/
@ -181,11 +180,11 @@
}
Globals.oI18N = window['rainloopI18N'] || {};
Globals.oNotificationI18N = {};
Globals.aBootstrapDropdowns = [];
Globals.aViewModels = {
'settings': [],
'settings-removed': [],
@ -270,7 +269,7 @@
Globals.keyScope(Globals.keyScopeFake());
}
});
module.exports = Globals;
}(module));

View file

@ -1,20 +1,20 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
'use strict';
(function (module) {
'use strict';
var
window = require('../External/window.js'),
Utils = require('./Utils.js'),
AppSettings = require('../Storages/AppSettings.js')
Utils = require('./Utils.js')
;
/**
* @constructor
*/
function LinkBuilder()
{
var AppSettings = require('../Storages/AppSettings.js');
this.sBase = '#/';
this.sServer = './?';
this.sVersion = AppSettings.settingsGet('Version');

View file

@ -1,15 +1,15 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
'use strict';
(function (module) {
'use strict';
var
window = require('../External/window.js'),
_ = require('../External/underscore.js'),
Globals = require('./Globals.js'),
AppSettings = require('../Storages/AppSettings.js')
;
/**
* @constructor
* @param {Object} oElement
@ -19,18 +19,17 @@
*/
function NewHtmlEditorWrapper(oElement, fOnBlur, fOnReady, fOnModeChange)
{
var self = this;
self.editor = null;
self.iBlurTimer = 0;
self.fOnBlur = fOnBlur || null;
self.fOnReady = fOnReady || null;
self.fOnModeChange = fOnModeChange || null;
this.editor = null;
this.iBlurTimer = 0;
this.fOnBlur = fOnBlur || null;
this.fOnReady = fOnReady || null;
this.fOnModeChange = fOnModeChange || null;
self.$element = $(oElement);
this.$element = $(oElement);
self.resize = _.throttle(_.bind(self.resize, self), 100);
this.resize = _.throttle(_.bind(this.resize, this), 100);
self.init();
this.init();
}
NewHtmlEditorWrapper.prototype.blurTrigger = function ()
@ -38,8 +37,8 @@
if (this.fOnBlur)
{
var self = this;
window.clearTimeout(self.iBlurTimer);
self.iBlurTimer = window.setTimeout(function () {
window.clearTimeout(this.iBlurTimer);
this.iBlurTimer = window.setTimeout(function () {
self.fOnBlur();
}, 200);
}

View file

@ -1,9 +1,8 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
'use strict';
(function (module) {
'use strict';
var
Plugins = {
__boot: null,

View file

@ -1,9 +1,8 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
'use strict';
(function (module) {
'use strict';
var
$ = require('../External/jquery.js'),
_ = require('../External/underscore.js'),

View file

@ -1,18 +1,18 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
'use strict';
(function (module) {
'use strict';
var
Utils = {},
$ = require('../External/jquery.js'),
_ = require('../External/underscore.js'),
ko = require('../External/ko.js'),
window = require('../External/window.js'),
$window = require('../External/$window.js'),
$html = require('../External/$html.js'),
$div = require('../External/$div.js'),
$doc = require('../External/$doc.js'),
NotificationClass = require('../External/NotificationClass.js'),
@ -419,15 +419,15 @@
if (window['rainloopI18N'])
{
Globals.oI18N = window['rainloopI18N'] || {};
Utils.i18nToNode($doc);
Globals.langChangeTrigger(!Globals.langChangeTrigger());
}
window['rainloopI18N'] = null;
};
/**
* @param {Function} fCallback
* @param {Object} oScope
@ -462,14 +462,14 @@
*/
Utils.inFocus = function ()
{
if (document.activeElement)
if (window.document.activeElement)
{
if (Utils.isUnd(document.activeElement.__inFocusCache))
if (Utils.isUnd(window.document.activeElement.__inFocusCache))
{
document.activeElement.__inFocusCache = $(document.activeElement).is('input,textarea,iframe,.cke_editable');
window.document.activeElement.__inFocusCache = $(window.document.activeElement).is('input,textarea,iframe,.cke_editable');
}
return !!document.activeElement.__inFocusCache;
return !!window.document.activeElement.__inFocusCache;
}
return false;
@ -477,12 +477,12 @@
Utils.removeInFocus = function ()
{
if (document && document.activeElement && document.activeElement.blur)
if (window.document && window.document.activeElement && window.document.activeElement.blur)
{
var oA = $(document.activeElement);
var oA = $(window.document.activeElement);
if (oA.is('input,textarea'))
{
document.activeElement.blur();
window.document.activeElement.blur();
}
}
};
@ -497,9 +497,9 @@
oSel.removeAllRanges();
}
}
else if (document && document.selection && document.selection.empty)
else if (window.document && window.document.selection && window.document.selection.empty)
{
document.selection.empty();
window.document.selection.empty();
}
};
@ -919,11 +919,14 @@
{
var
fResult = fExecute ? function () {
if (fResult.canExecute && fResult.canExecute())
if (fResult && fResult.canExecute && fResult.canExecute())
{
fExecute.apply(oContext, Array.prototype.slice.call(arguments));
}
return false;
} : function () {}
;
@ -1466,8 +1469,6 @@
return Utils.settingsSaveHelperFunction(null, koTrigger, oContext, 1000);
};
Utils.$div = $('<div></div>');
/**
* @param {string} sHtml
* @return {string}
@ -1576,7 +1577,7 @@
.replace(/<[^>]*>/gm, '')
;
sText = Utils.$div.html(sText).text();
sText = $div.html(sText).text();
sText = sText
.replace(/\n[ \t]+/gm, '\n')
@ -1713,7 +1714,7 @@
{
if ($.fn && $.fn.linkify)
{
sHtml = Utils.$div.html(sHtml.replace(/&amp;/ig, 'amp_amp_12345_amp_amp'))
sHtml = $div.html(sHtml.replace(/&amp;/ig, 'amp_amp_12345_amp_amp'))
.linkify()
.find('.linkified').removeClass('linkified').end()
.html()
@ -1731,7 +1732,7 @@
var
aDiff = [0, 0],
oCanvas = document.createElement('canvas'),
oCanvas = window.document.createElement('canvas'),
oCtx = oCanvas.getContext('2d')
;