es5 -> es2015 (last stage)

Signature plugin fixes
Add view decorator
A large number of fixes
This commit is contained in:
RainLoop Team 2016-08-17 01:01:20 +03:00
parent e88c193334
commit 17669b7be0
153 changed files with 21193 additions and 21115 deletions

View file

@ -1,134 +1,125 @@
var
_ = require('_'),
ko = require('ko'),
key = require('key'),
import ko from 'ko';
import key from 'key';
Enums = require('Common/Enums'),
Utils = require('Common/Utils'),
Translator = require('Common/Translator'),
import {KeyState} from 'Common/Enums';
import {isFunc} from 'Common/Utils';
import {i18n} from 'Common/Translator';
kn = require('Knoin/Knoin'),
AbstractView = require('Knoin/AbstractView');
import {view, ViewType} from 'Knoin/Knoin';
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
/**
* @constructor
* @extends AbstractView
*/
function AskPopupView()
@view({
name: 'View/Popup/Ask',
type: ViewType.Popup,
templateID: 'PopupsAsk'
})
class AskPopupView extends AbstractViewNext
{
AbstractView.call(this, 'Popups', 'PopupsAsk');
constructor() {
super();
this.askDesc = ko.observable('');
this.yesButton = ko.observable('');
this.noButton = ko.observable('');
this.askDesc = ko.observable('');
this.yesButton = ko.observable('');
this.noButton = ko.observable('');
this.yesFocus = ko.observable(false);
this.noFocus = ko.observable(false);
this.yesFocus = ko.observable(false);
this.noFocus = ko.observable(false);
this.fYesAction = null;
this.fNoAction = null;
this.fYesAction = null;
this.fNoAction = null;
this.bFocusYesOnShow = true;
this.bDisabeCloseOnEsc = true;
this.sDefaultKeyScope = Enums.KeyState.PopupAsk;
kn.constructorEnd(this);
}
kn.extendAsViewModel(['View/Popup/Ask', 'PopupsAskViewModel'], AskPopupView);
_.extend(AskPopupView.prototype, AbstractView.prototype);
AskPopupView.prototype.clearPopup = function()
{
this.askDesc('');
this.yesButton(Translator.i18n('POPUPS_ASK/BUTTON_YES'));
this.noButton(Translator.i18n('POPUPS_ASK/BUTTON_NO'));
this.yesFocus(false);
this.noFocus(false);
this.fYesAction = null;
this.fNoAction = null;
};
AskPopupView.prototype.yesClick = function()
{
this.cancelCommand();
if (Utils.isFunc(this.fYesAction))
{
this.fYesAction.call(null);
}
};
AskPopupView.prototype.noClick = function()
{
this.cancelCommand();
if (Utils.isFunc(this.fNoAction))
{
this.fNoAction.call(null);
}
};
/**
* @param {string} sAskDesc
* @param {Function=} fYesFunc
* @param {Function=} fNoFunc
* @param {string=} sYesButton
* @param {string=} sNoButton
* @param {boolean=} bFocusYesOnShow
* @returns {void}
*/
AskPopupView.prototype.onShow = function(sAskDesc, fYesFunc, fNoFunc, sYesButton, sNoButton, bFocusYesOnShow)
{
this.clearPopup();
this.fYesAction = fYesFunc || null;
this.fNoAction = fNoFunc || null;
this.askDesc(sAskDesc || '');
if (sYesButton)
{
this.yesButton(sYesButton);
this.bFocusYesOnShow = true;
this.bDisabeCloseOnEsc = true;
this.sDefaultKeyScope = KeyState.PopupAsk;
}
if (sNoButton)
{
this.noButton(sNoButton);
clearPopup() {
this.askDesc('');
this.yesButton(i18n('POPUPS_ASK/BUTTON_YES'));
this.noButton(i18n('POPUPS_ASK/BUTTON_NO'));
this.yesFocus(false);
this.noFocus(false);
this.fYesAction = null;
this.fNoAction = null;
}
this.bFocusYesOnShow = Utils.isUnd(bFocusYesOnShow) ? true : !!bFocusYesOnShow;
};
yesClick() {
this.cancelCommand();
AskPopupView.prototype.onShowWithDelay = function()
{
if (this.bFocusYesOnShow)
{
this.yesFocus(true);
}
};
AskPopupView.prototype.onBuild = function()
{
key('tab, shift+tab, right, left', Enums.KeyState.PopupAsk, _.bind(function() {
if (this.yesFocus())
if (isFunc(this.fYesAction))
{
this.noFocus(true);
this.fYesAction.call(null);
}
else
}
noClick() {
this.cancelCommand();
if (isFunc(this.fNoAction))
{
this.fNoAction.call(null);
}
}
/**
* @param {string} sAskDesc
* @param {Function=} fYesFunc
* @param {Function=} fNoFunc
* @param {string=} sYesButton
* @param {string=} sNoButton
* @param {boolean=} bFocusYesOnShow = true
* @returns {void}
*/
onShow(askDesc, fYesFunc = null, fNoFunc = null, yesButton = '', noButton = '', isFocusYesOnShow = true) {
this.clearPopup();
this.fYesAction = fYesFunc || null;
this.fNoAction = fNoFunc || null;
this.askDesc(askDesc || '');
if (yesButton)
{
this.yesButton(yesButton);
}
if (noButton)
{
this.noButton(noButton);
}
this.bFocusYesOnShow = !!isFocusYesOnShow;
}
onShowWithDelay() {
if (this.bFocusYesOnShow)
{
this.yesFocus(true);
}
return false;
}, this));
}
key('esc', Enums.KeyState.PopupAsk, _.bind(function() {
this.noClick();
return false;
}, this));
};
onBuild() {
key('tab, shift+tab, right, left', KeyState.PopupAsk, () => {
if (this.yesFocus())
{
this.noFocus(true);
}
else
{
this.yesFocus(true);
}
return false;
});
key('esc', KeyState.PopupAsk, () => {
this.noClick();
return false;
});
}
}
module.exports = AskPopupView;