Code refactoring (v2)

This commit is contained in:
RainLoop Team 2016-06-17 02:23:49 +03:00
parent 90d95d3ca4
commit 80ab02363e
29 changed files with 858 additions and 857 deletions

View file

@ -2,7 +2,7 @@
import {$, _, key} from 'common';
import ko from 'ko';
import {EventKeyCode} from 'Common/Enums';
import {isArray, inArray} from 'Common/Utils';
import {isArray, inArray, noop, noopTrue} from 'Common/Utils';
class Selector
{
@ -118,9 +118,6 @@ class Selector
this.sLastUid = '';
this.oCallbacks = {};
this.emptyFunction = () => {};
this.emptyTrueFunction = () => true;
this.focusedItem.subscribe((item) => {
if (item)
{
@ -291,14 +288,14 @@ class Selector
{
if (!item)
{
(this.oCallbacks.onItemSelect || this.emptyFunction)(item || null);
(this.oCallbacks.onItemSelect || noop)(item || null);
}
}
else
{
if (item)
{
(this.oCallbacks.onItemSelect || this.emptyFunction)(item);
(this.oCallbacks.onItemSelect || noop)(item);
}
}
}
@ -416,14 +413,14 @@ class Selector
* @return {boolean}
*/
autoSelect() {
return !!(this.oCallbacks.onAutoSelect || this.emptyTrueFunction)();
return !!(this.oCallbacks.onAutoSelect || noopTrue)();
}
/**
* @param {boolean} up
*/
doUpUpOrDownDown(up) {
(this.oCallbacks.onUpUpOrDownDown || this.emptyTrueFunction)(!!up);
(this.oCallbacks.onUpUpOrDownDown || noopTrue)(!!up);
}
/**