mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-01 13:39:22 +03:00
Uploading and preparing the repository to the dev version.
Original unminified source code (dev folder - js, css, less) (fixes #6) Grunt build system Multiple identities correction (fixes #9) Compose html editor (fixes #12) New general settings - Loading Description New warning about default admin password Split general and login screen settings
This commit is contained in:
parent
afad45137e
commit
4cc2207513
846 changed files with 99453 additions and 2123 deletions
14
dev/Knoin/AbstractBoot.js
Normal file
14
dev/Knoin/AbstractBoot.js
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function KnoinAbstractBoot()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
KnoinAbstractBoot.prototype.bootstart = function ()
|
||||
{
|
||||
|
||||
};
|
||||
77
dev/Knoin/AbstractScreen.js
Normal file
77
dev/Knoin/AbstractScreen.js
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @param {string} sScreenName
|
||||
* @param {?=} aViewModels = []
|
||||
* @constructor
|
||||
*/
|
||||
function KnoinAbstractScreen(sScreenName, aViewModels)
|
||||
{
|
||||
this.sScreenName = sScreenName;
|
||||
this.aViewModels = Utils.isArray(aViewModels) ? aViewModels : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {Array}
|
||||
*/
|
||||
KnoinAbstractScreen.prototype.oCross = null;
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
KnoinAbstractScreen.prototype.sScreenName = '';
|
||||
|
||||
/**
|
||||
* @type {Array}
|
||||
*/
|
||||
KnoinAbstractScreen.prototype.aViewModels = [];
|
||||
|
||||
/**
|
||||
* @return {Array}
|
||||
*/
|
||||
KnoinAbstractScreen.prototype.viewModels = function ()
|
||||
{
|
||||
return this.aViewModels;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
KnoinAbstractScreen.prototype.screenName = function ()
|
||||
{
|
||||
return this.sScreenName;
|
||||
};
|
||||
|
||||
KnoinAbstractScreen.prototype.routes = function ()
|
||||
{
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {?Object}
|
||||
*/
|
||||
KnoinAbstractScreen.prototype.__cross = function ()
|
||||
{
|
||||
return this.oCross;
|
||||
};
|
||||
|
||||
KnoinAbstractScreen.prototype.__start = function ()
|
||||
{
|
||||
var
|
||||
aRoutes = this.routes(),
|
||||
oRoute = null,
|
||||
fMatcher = null
|
||||
;
|
||||
|
||||
if (Utils.isNonEmptyArray(aRoutes))
|
||||
{
|
||||
fMatcher = _.bind(this.onRoute || Utils.emptyFunction, this);
|
||||
oRoute = crossroads.create();
|
||||
|
||||
_.each(aRoutes, function (aItem) {
|
||||
oRoute.addRoute(aItem[0], fMatcher).rules = aItem[1];
|
||||
});
|
||||
|
||||
this.oCross = oRoute;
|
||||
}
|
||||
};
|
||||
61
dev/Knoin/AbstractViewModel.js
Normal file
61
dev/Knoin/AbstractViewModel.js
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @param {string=} sPosition = ''
|
||||
* @param {string=} sTemplate = ''
|
||||
* @constructor
|
||||
*/
|
||||
function KnoinAbstractViewModel(sPosition, sTemplate)
|
||||
{
|
||||
this.sPosition = Utils.pString(sPosition);
|
||||
this.sTemplate = Utils.pString(sTemplate);
|
||||
|
||||
this.viewModelName = '';
|
||||
this.viewModelVisibility = ko.observable(false);
|
||||
if ('Popups' === this.sPosition)
|
||||
{
|
||||
this.modalVisibility = ko.observable(false);
|
||||
}
|
||||
|
||||
this.viewModelDom = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
KnoinAbstractViewModel.prototype.sPosition = '';
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
KnoinAbstractViewModel.prototype.sTemplate = '';
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
KnoinAbstractViewModel.prototype.viewModelName = '';
|
||||
|
||||
/**
|
||||
* @type {?}
|
||||
*/
|
||||
KnoinAbstractViewModel.prototype.viewModelDom = null;
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
KnoinAbstractViewModel.prototype.viewModelTemplate = function ()
|
||||
{
|
||||
return this.sTemplate;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
KnoinAbstractViewModel.prototype.viewModelPosition = function ()
|
||||
{
|
||||
return this.sPosition;
|
||||
};
|
||||
|
||||
KnoinAbstractViewModel.prototype.cancelCommand = KnoinAbstractViewModel.prototype.closeCommand = function ()
|
||||
{
|
||||
};
|
||||
382
dev/Knoin/Knoin.js
Normal file
382
dev/Knoin/Knoin.js
Normal file
|
|
@ -0,0 +1,382 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function Knoin()
|
||||
{
|
||||
this.sDefaultScreenName = '';
|
||||
this.oScreens = {};
|
||||
this.oBoot = null;
|
||||
this.oCurrentScreen = null;
|
||||
|
||||
this.popupVisibility = ko.observable(false);
|
||||
|
||||
this.popupVisibility.subscribe(function (bValue) {
|
||||
if (RL)
|
||||
{
|
||||
RL.popupVisibility(bValue);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Knoin.prototype.sDefaultScreenName = '';
|
||||
Knoin.prototype.oScreens = {};
|
||||
Knoin.prototype.oBoot = null;
|
||||
Knoin.prototype.oCurrentScreen = null;
|
||||
|
||||
Knoin.prototype.showLoading = function ()
|
||||
{
|
||||
$('#rl-loading').show();
|
||||
};
|
||||
|
||||
Knoin.prototype.hideLoading = function ()
|
||||
{
|
||||
$('#rl-loading').hide();
|
||||
};
|
||||
|
||||
Knoin.prototype.routeOff = function ()
|
||||
{
|
||||
hasher.changed.active = false;
|
||||
};
|
||||
|
||||
Knoin.prototype.routeOn = function ()
|
||||
{
|
||||
hasher.changed.active = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Object} oBoot
|
||||
* @return {Knoin}
|
||||
*/
|
||||
Knoin.prototype.setBoot = function (oBoot)
|
||||
{
|
||||
if (Utils.isNormal(oBoot))
|
||||
{
|
||||
this.oBoot = oBoot;
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sScreenName
|
||||
* @return {?Object}
|
||||
*/
|
||||
Knoin.prototype.screen = function (sScreenName)
|
||||
{
|
||||
return ('' !== sScreenName && !Utils.isUnd(this.oScreens[sScreenName])) ? this.oScreens[sScreenName] : null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?} oViewModel
|
||||
* @param {string} sDelegateName
|
||||
* @param {Array=} aParameters
|
||||
*/
|
||||
Knoin.prototype.delegateRun = function (oViewModel, sDelegateName, aParameters)
|
||||
{
|
||||
if (oViewModel && oViewModel[sDelegateName])
|
||||
{
|
||||
oViewModel[sDelegateName].apply(oViewModel, Utils.isArray(aParameters) ? aParameters : []);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Function} ViewModelClass
|
||||
* @param {Object=} oScreen
|
||||
*/
|
||||
Knoin.prototype.buildViewModel = function (ViewModelClass, oScreen)
|
||||
{
|
||||
if (ViewModelClass && !ViewModelClass.__builded)
|
||||
{
|
||||
var
|
||||
oViewModel = new ViewModelClass(oScreen),
|
||||
sPosition = oViewModel.viewModelPosition(),
|
||||
oViewModelPlace = $('#rl-content #rl-' + sPosition.toLowerCase()),
|
||||
oViewModelDom = null
|
||||
;
|
||||
|
||||
ViewModelClass.__builded = true;
|
||||
ViewModelClass.__vm = oViewModel;
|
||||
oViewModel.data = RL.data();
|
||||
|
||||
oViewModel.viewModelName = ViewModelClass.__name;
|
||||
|
||||
if (oViewModelPlace && 1 === oViewModelPlace.length)
|
||||
{
|
||||
oViewModelDom = $('<div>').addClass('rl-view-model').addClass('RL-' + oViewModel.viewModelTemplate()).hide().attr('data-bind',
|
||||
'template: {name: "' + oViewModel.viewModelTemplate() + '"}, i18nInit: true');
|
||||
|
||||
oViewModelDom.appendTo(oViewModelPlace);
|
||||
oViewModel.viewModelDom = oViewModelDom;
|
||||
ViewModelClass.__dom = oViewModelDom;
|
||||
|
||||
if ('Popups' === sPosition)
|
||||
{
|
||||
oViewModel.cancelCommand = oViewModel.closeCommand = Utils.createCommand(oViewModel, function () {
|
||||
kn.hideScreenPopup(ViewModelClass);
|
||||
});
|
||||
}
|
||||
|
||||
Plugins.runHook('view-model-pre-build', [ViewModelClass.__name, oViewModel, oViewModelDom]);
|
||||
|
||||
ko.applyBindings(oViewModel, oViewModelDom[0]);
|
||||
this.delegateRun(oViewModel, 'onBuild', [oViewModelDom]);
|
||||
|
||||
Plugins.runHook('view-model-post-build', [ViewModelClass.__name, oViewModel, oViewModelDom]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Utils.log('Cannot find view model position: ' + sPosition);
|
||||
}
|
||||
}
|
||||
|
||||
return ViewModelClass ? ViewModelClass.__vm : null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Object} oViewModel
|
||||
* @param {Object} oViewModelDom
|
||||
*/
|
||||
Knoin.prototype.applyExternal = function (oViewModel, oViewModelDom)
|
||||
{
|
||||
if (oViewModel && oViewModelDom)
|
||||
{
|
||||
ko.applyBindings(oViewModel, oViewModelDom);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Function} ViewModelClassToHide
|
||||
*/
|
||||
Knoin.prototype.hideScreenPopup = function (ViewModelClassToHide)
|
||||
{
|
||||
if (ViewModelClassToHide && ViewModelClassToHide.__vm && ViewModelClassToHide.__dom)
|
||||
{
|
||||
ViewModelClassToHide.__dom.hide();
|
||||
ViewModelClassToHide.__vm.modalVisibility(false);
|
||||
this.delegateRun(ViewModelClassToHide.__vm, 'onHide');
|
||||
this.popupVisibility(false);
|
||||
|
||||
_.defer(function () {
|
||||
ViewModelClassToHide.__dom.find('.ko-select2').select2('close');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Function} ViewModelClassToShow
|
||||
* @param {Array=} aParameters
|
||||
*/
|
||||
Knoin.prototype.showScreenPopup = function (ViewModelClassToShow, aParameters)
|
||||
{
|
||||
if (ViewModelClassToShow)
|
||||
{
|
||||
this.buildViewModel(ViewModelClassToShow);
|
||||
|
||||
if (ViewModelClassToShow.__vm && ViewModelClassToShow.__dom)
|
||||
{
|
||||
ViewModelClassToShow.__dom.show();
|
||||
ViewModelClassToShow.__vm.modalVisibility(true);
|
||||
this.delegateRun(ViewModelClassToShow.__vm, 'onShow', aParameters || []);
|
||||
this.popupVisibility(true);
|
||||
|
||||
Plugins.runHook('view-model-on-show', [ViewModelClassToShow.__name, ViewModelClassToShow.__vm, aParameters || []]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sScreenName
|
||||
* @param {string} sSubPart
|
||||
*/
|
||||
Knoin.prototype.screenOnRoute = function (sScreenName, sSubPart)
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
oScreen = null,
|
||||
oCross = null
|
||||
;
|
||||
|
||||
if ('' === Utils.pString(sScreenName))
|
||||
{
|
||||
sScreenName = this.sDefaultScreenName;
|
||||
}
|
||||
|
||||
if ('' !== sScreenName)
|
||||
{
|
||||
oScreen = this.screen(sScreenName);
|
||||
if (!oScreen)
|
||||
{
|
||||
oScreen = this.screen(this.sDefaultScreenName);
|
||||
if (oScreen)
|
||||
{
|
||||
sSubPart = sScreenName + '/' + sSubPart;
|
||||
sScreenName = this.sDefaultScreenName;
|
||||
}
|
||||
}
|
||||
|
||||
if (oScreen && oScreen.__started)
|
||||
{
|
||||
if (!oScreen.__builded)
|
||||
{
|
||||
oScreen.__builded = true;
|
||||
|
||||
if (Utils.isNonEmptyArray(oScreen.viewModels()))
|
||||
{
|
||||
_.each(oScreen.viewModels(), function (ViewModelClass) {
|
||||
this.buildViewModel(ViewModelClass, oScreen);
|
||||
}, this);
|
||||
}
|
||||
|
||||
this.delegateRun(oScreen, 'onBuild');
|
||||
}
|
||||
|
||||
_.defer(function () {
|
||||
|
||||
// hide screen
|
||||
if (self.oCurrentScreen)
|
||||
{
|
||||
self.delegateRun(self.oCurrentScreen, 'onHide');
|
||||
|
||||
if (Utils.isNonEmptyArray(self.oCurrentScreen.viewModels()))
|
||||
{
|
||||
_.each(self.oCurrentScreen.viewModels(), function (ViewModelClass) {
|
||||
|
||||
if (ViewModelClass.__vm && ViewModelClass.__dom &&
|
||||
'Popups' !== ViewModelClass.__vm.viewModelPosition())
|
||||
{
|
||||
ViewModelClass.__dom.hide();
|
||||
ViewModelClass.__vm.viewModelVisibility(false);
|
||||
self.delegateRun(ViewModelClass.__vm, 'onHide');
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
// --
|
||||
|
||||
self.oCurrentScreen = oScreen;
|
||||
|
||||
// show screen
|
||||
if (self.oCurrentScreen)
|
||||
{
|
||||
|
||||
self.delegateRun(self.oCurrentScreen, 'onShow');
|
||||
|
||||
Plugins.runHook('screen-on-show', [self.oCurrentScreen.screenName(), self.oCurrentScreen]);
|
||||
|
||||
if (Utils.isNonEmptyArray(self.oCurrentScreen.viewModels()))
|
||||
{
|
||||
_.each(self.oCurrentScreen.viewModels(), function (ViewModelClass) {
|
||||
|
||||
if (ViewModelClass.__vm && ViewModelClass.__dom &&
|
||||
'Popups' !== ViewModelClass.__vm.viewModelPosition())
|
||||
{
|
||||
ViewModelClass.__dom.show();
|
||||
ViewModelClass.__vm.viewModelVisibility(true);
|
||||
self.delegateRun(ViewModelClass.__vm, 'onShow');
|
||||
|
||||
Plugins.runHook('view-model-on-show', [ViewModelClass.__name, ViewModelClass.__vm]);
|
||||
}
|
||||
|
||||
}, self);
|
||||
}
|
||||
}
|
||||
// --
|
||||
|
||||
oCross = oScreen.__cross();
|
||||
if (oCross)
|
||||
{
|
||||
oCross.parse(sSubPart);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Array} aScreensClasses
|
||||
*/
|
||||
Knoin.prototype.startScreens = function (aScreensClasses)
|
||||
{
|
||||
_.each(aScreensClasses, function (CScreen) {
|
||||
|
||||
var
|
||||
oScreen = new CScreen(),
|
||||
sScreenName = oScreen ? oScreen.screenName() : ''
|
||||
;
|
||||
|
||||
if (oScreen && '' !== sScreenName)
|
||||
{
|
||||
if ('' === this.sDefaultScreenName)
|
||||
{
|
||||
this.sDefaultScreenName = sScreenName;
|
||||
}
|
||||
|
||||
this.oScreens[sScreenName] = oScreen;
|
||||
}
|
||||
|
||||
}, this);
|
||||
|
||||
|
||||
_.each(this.oScreens, function (oScreen) {
|
||||
if (oScreen && !oScreen.__started && oScreen.__start)
|
||||
{
|
||||
oScreen.__started = true;
|
||||
oScreen.__start();
|
||||
|
||||
Plugins.runHook('screen-pre-start', [oScreen.screenName(), oScreen]);
|
||||
this.delegateRun(oScreen, 'onStart');
|
||||
Plugins.runHook('screen-post-start', [oScreen.screenName(), oScreen]);
|
||||
}
|
||||
}, this);
|
||||
|
||||
var oCross = crossroads.create();
|
||||
oCross.addRoute(/^([a-zA-Z0-9\-]*)\/?(.*)$/, _.bind(this.screenOnRoute, this));
|
||||
|
||||
hasher.initialized.add(oCross.parse, oCross);
|
||||
hasher.changed.add(oCross.parse, oCross);
|
||||
hasher.init();
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sHash
|
||||
* @param {boolean=} bSilence = false
|
||||
* @param {boolean=} bReplace = false
|
||||
*/
|
||||
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;
|
||||
|
||||
bReplace = Utils.isUnd(bReplace) ? false : !!bReplace;
|
||||
|
||||
if (Utils.isUnd(bSilence) ? false : !!bSilence)
|
||||
{
|
||||
hasher.changed.active = false;
|
||||
hasher[bReplace ? 'replaceHash' : 'setHash'](sHash);
|
||||
hasher.changed.active = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
hasher.changed.active = true;
|
||||
hasher[bReplace ? 'replaceHash' : 'setHash'](sHash);
|
||||
hasher.setHash(sHash);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {Knoin}
|
||||
*/
|
||||
Knoin.prototype.bootstart = function ()
|
||||
{
|
||||
if (this.oBoot && this.oBoot.bootstart)
|
||||
{
|
||||
this.oBoot.bootstart();
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
kn = new Knoin();
|
||||
Loading…
Add table
Add a link
Reference in a new issue