Browse Source

Merge pull request #695 in VISUAL/fineui from ~GUY/fineui:master to master

* commit '8c339515753b2dde168aac92e6223bd31f597110':
  update
  update
es6
guy 6 years ago
parent
commit
d7f75724ec
  1. 344
      dist/bundle.js
  2. 52
      dist/bundle.min.js
  3. 298
      dist/core.js
  4. 842
      dist/fineui.js
  5. 50
      dist/fineui.min.js
  6. 344
      dist/fineui_without_jquery_polyfill.js
  7. 298
      dist/utils.js
  8. 4
      dist/utils.min.js
  9. 296
      src/core/ob.js

344
dist/bundle.js vendored

@ -11478,158 +11478,184 @@ if (!_global.BI) {
} }
}); });
})();/** })();!(function () {
* 客户端观察者主要处理事件的添加删除执行等 function extend () {
* @class BI.OB var target = arguments[0] || {}, length = arguments.length, i = 1, options, name, src, copy;
* @abstract for (; i < length; i++) {
*/ // Only deal with non-null/undefined values
BI.OB = function (config) { if ((options = arguments[i]) != null) {
var props = this.props; // Extend the base object
if (BI.isFunction(this.props)) { for (name in options) {
props = this.props(config); src = target[name];
} copy = options[name];
this.options = (_global.$ || _global._).extend(this._defaultConfig(config), props, config);
this._init(); // Prevent never-ending loop
this._initRef(); if (target === copy) {
}; continue;
_.extend(BI.OB.prototype, { }
props: {},
init: null,
destroyed: null,
_defaultConfig: function (config) { if (copy !== undefined) {
return {}; target[name] = copy;
}, }
}
}
}
return target;
}
_init: function () { /**
this._initListeners(); * 客户端观察者主要处理事件的添加删除执行等
this.init && this.init(); * @class BI.OB
}, * @abstract
*/
BI.OB = function (config) {
var props = this.props;
if (BI.isFunction(this.props)) {
props = this.props(config);
}
this.options = extend(this._defaultConfig(config), props, config);
this._init();
this._initRef();
};
_.extend(BI.OB.prototype, {
props: {},
init: null,
destroyed: null,
_initListeners: function () { _defaultConfig: function (config) {
var self = this; return {};
if (this.options.listeners != null) { },
_.each(this.options.listeners, function (lis) {
(lis.target ? lis.target : self)[lis.once ? "once" : "on"]
(lis.eventName, _.bind(lis.action, self));
});
delete this.options.listeners;
}
},
// 获得一个当前对象的引用 _init: function () {
_initRef: function () { this._initListeners();
if (this.options.ref) { this.init && this.init();
this.options.ref.call(this, this); },
}
},
//释放当前对象 _initListeners: function () {
_purgeRef: function(){ var self = this;
if (this.options.ref) { if (this.options.listeners != null) {
this.options.ref.call(null); _.each(this.options.listeners, function (lis) {
} (lis.target ? lis.target : self)[lis.once ? "once" : "on"]
}, (lis.eventName, _.bind(lis.action, self));
});
delete this.options.listeners;
}
},
_getEvents: function () { // 获得一个当前对象的引用
if (!_.isArray(this.events)) { _initRef: function () {
this.events = []; if (this.options.ref) {
} this.options.ref.call(this, this);
return this.events; }
}, },
/** //释放当前对象
* 给观察者绑定一个事件 _purgeRef: function () {
* @param {String} eventName 事件的名字 if (this.options.ref) {
* @param {Function} fn 事件对应的执行函数 this.options.ref.call(null);
*/ }
on: function (eventName, fn) { },
eventName = eventName.toLowerCase();
var fns = this._getEvents()[eventName];
if (!_.isArray(fns)) {
fns = [];
this._getEvents()[eventName] = fns;
}
fns.push(fn);
},
/** _getEvents: function () {
* 给观察者绑定一个只执行一次的事件 if (!_.isArray(this.events)) {
* @param {String} eventName 事件的名字 this.events = [];
* @param {Function} fn 事件对应的执行函数 }
*/ return this.events;
once: function (eventName, fn) { },
var proxy = function () {
fn.apply(this, arguments);
this.un(eventName, proxy);
};
this.on(eventName, proxy);
},
/**
* 解除观察者绑定的指定事件
* @param {String} eventName 要解除绑定事件的名字
* @param {Function} fn 事件对应的执行函数该参数是可选的没有该参数时将解除绑定所有同名字的事件
*/
un: function (eventName, fn) {
eventName = eventName.toLowerCase();
/* alex:如果fn是null,就是把eventName上面所有方法都un掉*/ /**
if (fn == null) { * 给观察者绑定一个事件
delete this._getEvents()[eventName]; * @param {String} eventName 事件的名字
} else { * @param {Function} fn 事件对应的执行函数
*/
on: function (eventName, fn) {
eventName = eventName.toLowerCase();
var fns = this._getEvents()[eventName]; var fns = this._getEvents()[eventName];
if (_.isArray(fns)) { if (!_.isArray(fns)) {
var newFns = []; fns = [];
_.each(fns, function (ifn) { this._getEvents()[eventName] = fns;
if (ifn != fn) {
newFns.push(ifn);
}
});
this._getEvents()[eventName] = newFns;
} }
} fns.push(fn);
}, },
/**
* 清除观察者的所有事件绑定 /**
*/ * 给观察者绑定一个只执行一次的事件
purgeListeners: function () { * @param {String} eventName 事件的名字
/* alex:清空events*/ * @param {Function} fn 事件对应的执行函数
this.events = []; */
}, once: function (eventName, fn) {
/** var proxy = function () {
* 触发绑定过的事件 fn.apply(this, arguments);
* this.un(eventName, proxy);
* @param {String} eventName 要触发的事件的名字 };
* @returns {Boolean} 如果事件函数返回false则返回false并中断其他同名事件的执行否则执行所有的同名事件并返回true this.on(eventName, proxy);
*/ },
fireEvent: function () { /**
var eventName = arguments[0].toLowerCase(); * 解除观察者绑定的指定事件
var fns = this._getEvents()[eventName]; * @param {String} eventName 要解除绑定事件的名字
if (BI.isArray(fns)) { * @param {Function} fn 事件对应的执行函数该参数是可选的没有该参数时将解除绑定所有同名字的事件
if (BI.isArguments(arguments[1])) { */
for (var i = 0; i < fns.length; i++) { un: function (eventName, fn) {
if (fns[i].apply(this, arguments[1]) === false) { eventName = eventName.toLowerCase();
return false;
} /* alex:如果fn是null,就是把eventName上面所有方法都un掉*/
} if (fn == null) {
delete this._getEvents()[eventName];
} else { } else {
var args = Array.prototype.slice.call(arguments, 1); var fns = this._getEvents()[eventName];
for (var i = 0; i < fns.length; i++) { if (_.isArray(fns)) {
if (fns[i].apply(this, args) === false) { var newFns = [];
return false; _.each(fns, function (ifn) {
if (ifn != fn) {
newFns.push(ifn);
}
});
this._getEvents()[eventName] = newFns;
}
}
},
/**
* 清除观察者的所有事件绑定
*/
purgeListeners: function () {
/* alex:清空events*/
this.events = [];
},
/**
* 触发绑定过的事件
*
* @param {String} eventName 要触发的事件的名字
* @returns {Boolean} 如果事件函数返回false则返回false并中断其他同名事件的执行否则执行所有的同名事件并返回true
*/
fireEvent: function () {
var eventName = arguments[0].toLowerCase();
var fns = this._getEvents()[eventName];
if (BI.isArray(fns)) {
if (BI.isArguments(arguments[1])) {
for (var i = 0; i < fns.length; i++) {
if (fns[i].apply(this, arguments[1]) === false) {
return false;
}
}
} else {
var args = Array.prototype.slice.call(arguments, 1);
for (var i = 0; i < fns.length; i++) {
if (fns[i].apply(this, args) === false) {
return false;
}
} }
} }
} }
} return true;
return true; },
},
destroy: function () { destroy: function () {
this.destroyed && this.destroyed(); this.destroyed && this.destroyed();
this._purgeRef(); this._purgeRef();
this.purgeListeners(); this.purgeListeners();
} }
});/** });
})();/**
* Widget超类 * Widget超类
* @class BI.Widget * @class BI.Widget
* @extends BI.OB * @extends BI.OB
@ -43842,18 +43868,30 @@ BI.Editor = BI.inherit(BI.Single, {
} }
e.stopEvent(); e.stopEvent();
}); });
this.watermark.element.css({ }
position: "absolute",
left: "3px", var _items = [];
right: "3px", if (this.watermark) {
top: "0px", _items.push({
bottom: "0px" el: this.watermark,
left: 3,
right: 3,
top: 0,
bottom: 0
}); });
} }
_items.push({
el: this.editor,
left: 0,
right: 0,
top: 0,
bottom: 0
});
var items = [{ var items = [{
el: { el: {
type: "bi.default", type: "bi.absolute",
items: this.watermark ? [this.editor, this.watermark] : [this.editor] items: _items
}, },
left: o.hgap + o.lgap, left: o.hgap + o.lgap,
right: o.hgap + o.rgap, right: o.hgap + o.rgap,
@ -43888,8 +43926,11 @@ BI.Editor = BI.inherit(BI.Single, {
this.editor.on(BI.Input.EVENT_KEY_DOWN, function (v) { this.editor.on(BI.Input.EVENT_KEY_DOWN, function (v) {
self.fireEvent(BI.Editor.EVENT_KEY_DOWN, arguments); self.fireEvent(BI.Editor.EVENT_KEY_DOWN, arguments);
}); });
this.editor.on(BI.Input.EVENT_QUICK_DOWN, function (v) { this.editor.on(BI.Input.EVENT_QUICK_DOWN, function (e) {
self.watermark && self.watermark.invisible(); // tab键就不要隐藏了
if (e.keyCode !== BI.KeyCode.TAB && self.watermark) {
self.watermark.invisible();
}
}); });
this.editor.on(BI.Input.EVENT_VALID, function () { this.editor.on(BI.Input.EVENT_VALID, function () {
@ -45129,6 +45170,10 @@ BI.Input = BI.inherit(BI.Single, {
"leading": true, "leading": true,
"trailing": false "trailing": false
}); });
this._focusDebounce = BI.debounce(BI.bind(this._focus, this), BI.EVENT_RESPONSE_TIME, {
"leading": true,
"trailing": false
});
this._blurDebounce = BI.debounce(BI.bind(this._blur, this), BI.EVENT_RESPONSE_TIME, { this._blurDebounce = BI.debounce(BI.bind(this._blur, this), BI.EVENT_RESPONSE_TIME, {
"leading": true, "leading": true,
"trailing": false "trailing": false
@ -45137,7 +45182,7 @@ BI.Input = BI.inherit(BI.Single, {
.keydown(function (e) { .keydown(function (e) {
inputEventValid = false; inputEventValid = false;
ctrlKey = e.ctrlKey; ctrlKey = e.ctrlKey;
self.fireEvent(BI.Input.EVENT_QUICK_DOWN); self.fireEvent(BI.Input.EVENT_QUICK_DOWN, arguments);
}) })
.keyup(function (e) { .keyup(function (e) {
if (!(inputEventValid && e.keyCode === BI.KeyCode.ENTER)) { if (!(inputEventValid && e.keyCode === BI.KeyCode.ENTER)) {
@ -45160,6 +45205,9 @@ BI.Input = BI.inherit(BI.Single, {
.mousedown(function (e) { .mousedown(function (e) {
self.element.val(self.element.val()); self.element.val(self.element.val());
}) })
.focus(function (e) { // 可以不用冒泡
self._focusDebounce();
})
.focusout(function (e) { .focusout(function (e) {
self._blurDebounce(); self._blurDebounce();
}); });
@ -45207,7 +45255,6 @@ BI.Input = BI.inherit(BI.Single, {
_click: function () { _click: function () {
if (this._isEditing !== true) { if (this._isEditing !== true) {
this._focus();
this.selectAll(); this.selectAll();
this.fireEvent(BI.Input.EVENT_CLICK); this.fireEvent(BI.Input.EVENT_CLICK);
} }
@ -45308,7 +45355,6 @@ BI.Input = BI.inherit(BI.Single, {
} }
if (!this._isEditing === true) { if (!this._isEditing === true) {
this.element.focus(); this.element.focus();
this._focus();
this.selectAll(); this.selectAll();
} }
}, },

52
dist/bundle.min.js vendored

File diff suppressed because one or more lines are too long

298
dist/core.js vendored

@ -11478,158 +11478,184 @@ if (!_global.BI) {
} }
}); });
})();/** })();!(function () {
* 客户端观察者主要处理事件的添加删除执行等 function extend () {
* @class BI.OB var target = arguments[0] || {}, length = arguments.length, i = 1, options, name, src, copy;
* @abstract for (; i < length; i++) {
*/ // Only deal with non-null/undefined values
BI.OB = function (config) { if ((options = arguments[i]) != null) {
var props = this.props; // Extend the base object
if (BI.isFunction(this.props)) { for (name in options) {
props = this.props(config); src = target[name];
} copy = options[name];
this.options = (_global.$ || _global._).extend(this._defaultConfig(config), props, config);
this._init(); // Prevent never-ending loop
this._initRef(); if (target === copy) {
}; continue;
_.extend(BI.OB.prototype, { }
props: {},
init: null,
destroyed: null,
_defaultConfig: function (config) {
return {};
},
_init: function () {
this._initListeners();
this.init && this.init();
},
_initListeners: function () { if (copy !== undefined) {
var self = this; target[name] = copy;
if (this.options.listeners != null) { }
_.each(this.options.listeners, function (lis) { }
(lis.target ? lis.target : self)[lis.once ? "once" : "on"] }
(lis.eventName, _.bind(lis.action, self));
});
delete this.options.listeners;
} }
}, return target;
}
// 获得一个当前对象的引用 /**
_initRef: function () { * 客户端观察者主要处理事件的添加删除执行等
if (this.options.ref) { * @class BI.OB
this.options.ref.call(this, this); * @abstract
*/
BI.OB = function (config) {
var props = this.props;
if (BI.isFunction(this.props)) {
props = this.props(config);
} }
}, this.options = extend(this._defaultConfig(config), props, config);
this._init();
this._initRef();
};
_.extend(BI.OB.prototype, {
props: {},
init: null,
destroyed: null,
//释放当前对象 _defaultConfig: function (config) {
_purgeRef: function(){ return {};
if (this.options.ref) { },
this.options.ref.call(null);
}
},
_getEvents: function () { _init: function () {
if (!_.isArray(this.events)) { this._initListeners();
this.events = []; this.init && this.init();
} },
return this.events;
},
/** _initListeners: function () {
* 给观察者绑定一个事件 var self = this;
* @param {String} eventName 事件的名字 if (this.options.listeners != null) {
* @param {Function} fn 事件对应的执行函数 _.each(this.options.listeners, function (lis) {
*/ (lis.target ? lis.target : self)[lis.once ? "once" : "on"]
on: function (eventName, fn) { (lis.eventName, _.bind(lis.action, self));
eventName = eventName.toLowerCase(); });
var fns = this._getEvents()[eventName]; delete this.options.listeners;
if (!_.isArray(fns)) { }
fns = []; },
this._getEvents()[eventName] = fns;
}
fns.push(fn);
},
/** // 获得一个当前对象的引用
* 给观察者绑定一个只执行一次的事件 _initRef: function () {
* @param {String} eventName 事件的名字 if (this.options.ref) {
* @param {Function} fn 事件对应的执行函数 this.options.ref.call(this, this);
*/ }
once: function (eventName, fn) { },
var proxy = function () {
fn.apply(this, arguments);
this.un(eventName, proxy);
};
this.on(eventName, proxy);
},
/**
* 解除观察者绑定的指定事件
* @param {String} eventName 要解除绑定事件的名字
* @param {Function} fn 事件对应的执行函数该参数是可选的没有该参数时将解除绑定所有同名字的事件
*/
un: function (eventName, fn) {
eventName = eventName.toLowerCase();
/* alex:如果fn是null,就是把eventName上面所有方法都un掉*/ //释放当前对象
if (fn == null) { _purgeRef: function () {
delete this._getEvents()[eventName]; if (this.options.ref) {
} else { this.options.ref.call(null);
}
},
_getEvents: function () {
if (!_.isArray(this.events)) {
this.events = [];
}
return this.events;
},
/**
* 给观察者绑定一个事件
* @param {String} eventName 事件的名字
* @param {Function} fn 事件对应的执行函数
*/
on: function (eventName, fn) {
eventName = eventName.toLowerCase();
var fns = this._getEvents()[eventName]; var fns = this._getEvents()[eventName];
if (_.isArray(fns)) { if (!_.isArray(fns)) {
var newFns = []; fns = [];
_.each(fns, function (ifn) { this._getEvents()[eventName] = fns;
if (ifn != fn) {
newFns.push(ifn);
}
});
this._getEvents()[eventName] = newFns;
} }
} fns.push(fn);
}, },
/**
* 清除观察者的所有事件绑定 /**
*/ * 给观察者绑定一个只执行一次的事件
purgeListeners: function () { * @param {String} eventName 事件的名字
/* alex:清空events*/ * @param {Function} fn 事件对应的执行函数
this.events = []; */
}, once: function (eventName, fn) {
/** var proxy = function () {
* 触发绑定过的事件 fn.apply(this, arguments);
* this.un(eventName, proxy);
* @param {String} eventName 要触发的事件的名字 };
* @returns {Boolean} 如果事件函数返回false则返回false并中断其他同名事件的执行否则执行所有的同名事件并返回true this.on(eventName, proxy);
*/ },
fireEvent: function () { /**
var eventName = arguments[0].toLowerCase(); * 解除观察者绑定的指定事件
var fns = this._getEvents()[eventName]; * @param {String} eventName 要解除绑定事件的名字
if (BI.isArray(fns)) { * @param {Function} fn 事件对应的执行函数该参数是可选的没有该参数时将解除绑定所有同名字的事件
if (BI.isArguments(arguments[1])) { */
for (var i = 0; i < fns.length; i++) { un: function (eventName, fn) {
if (fns[i].apply(this, arguments[1]) === false) { eventName = eventName.toLowerCase();
return false;
} /* alex:如果fn是null,就是把eventName上面所有方法都un掉*/
} if (fn == null) {
delete this._getEvents()[eventName];
} else { } else {
var args = Array.prototype.slice.call(arguments, 1); var fns = this._getEvents()[eventName];
for (var i = 0; i < fns.length; i++) { if (_.isArray(fns)) {
if (fns[i].apply(this, args) === false) { var newFns = [];
return false; _.each(fns, function (ifn) {
if (ifn != fn) {
newFns.push(ifn);
}
});
this._getEvents()[eventName] = newFns;
}
}
},
/**
* 清除观察者的所有事件绑定
*/
purgeListeners: function () {
/* alex:清空events*/
this.events = [];
},
/**
* 触发绑定过的事件
*
* @param {String} eventName 要触发的事件的名字
* @returns {Boolean} 如果事件函数返回false则返回false并中断其他同名事件的执行否则执行所有的同名事件并返回true
*/
fireEvent: function () {
var eventName = arguments[0].toLowerCase();
var fns = this._getEvents()[eventName];
if (BI.isArray(fns)) {
if (BI.isArguments(arguments[1])) {
for (var i = 0; i < fns.length; i++) {
if (fns[i].apply(this, arguments[1]) === false) {
return false;
}
}
} else {
var args = Array.prototype.slice.call(arguments, 1);
for (var i = 0; i < fns.length; i++) {
if (fns[i].apply(this, args) === false) {
return false;
}
} }
} }
} }
} return true;
return true; },
},
destroy: function () { destroy: function () {
this.destroyed && this.destroyed(); this.destroyed && this.destroyed();
this._purgeRef(); this._purgeRef();
this.purgeListeners(); this.purgeListeners();
} }
});/** });
})();/**
* Widget超类 * Widget超类
* @class BI.Widget * @class BI.Widget
* @extends BI.OB * @extends BI.OB

842
dist/fineui.js vendored

@ -11720,158 +11720,184 @@ if (!_global.BI) {
} }
}); });
})();/** })();!(function () {
* 客户端观察者主要处理事件的添加删除执行等 function extend () {
* @class BI.OB var target = arguments[0] || {}, length = arguments.length, i = 1, options, name, src, copy;
* @abstract for (; i < length; i++) {
*/ // Only deal with non-null/undefined values
BI.OB = function (config) { if ((options = arguments[i]) != null) {
var props = this.props; // Extend the base object
if (BI.isFunction(this.props)) { for (name in options) {
props = this.props(config); src = target[name];
} copy = options[name];
this.options = (_global.$ || _global._).extend(this._defaultConfig(config), props, config);
this._init(); // Prevent never-ending loop
this._initRef(); if (target === copy) {
}; continue;
_.extend(BI.OB.prototype, { }
props: {},
init: null,
destroyed: null,
_defaultConfig: function (config) { if (copy !== undefined) {
return {}; target[name] = copy;
}, }
}
}
}
return target;
}
_init: function () { /**
this._initListeners(); * 客户端观察者主要处理事件的添加删除执行等
this.init && this.init(); * @class BI.OB
}, * @abstract
*/
BI.OB = function (config) {
var props = this.props;
if (BI.isFunction(this.props)) {
props = this.props(config);
}
this.options = extend(this._defaultConfig(config), props, config);
this._init();
this._initRef();
};
_.extend(BI.OB.prototype, {
props: {},
init: null,
destroyed: null,
_initListeners: function () { _defaultConfig: function (config) {
var self = this; return {};
if (this.options.listeners != null) { },
_.each(this.options.listeners, function (lis) {
(lis.target ? lis.target : self)[lis.once ? "once" : "on"]
(lis.eventName, _.bind(lis.action, self));
});
delete this.options.listeners;
}
},
// 获得一个当前对象的引用 _init: function () {
_initRef: function () { this._initListeners();
if (this.options.ref) { this.init && this.init();
this.options.ref.call(this, this); },
}
},
//释放当前对象 _initListeners: function () {
_purgeRef: function(){ var self = this;
if (this.options.ref) { if (this.options.listeners != null) {
this.options.ref.call(null); _.each(this.options.listeners, function (lis) {
} (lis.target ? lis.target : self)[lis.once ? "once" : "on"]
}, (lis.eventName, _.bind(lis.action, self));
});
delete this.options.listeners;
}
},
_getEvents: function () { // 获得一个当前对象的引用
if (!_.isArray(this.events)) { _initRef: function () {
this.events = []; if (this.options.ref) {
} this.options.ref.call(this, this);
return this.events; }
}, },
/** //释放当前对象
* 给观察者绑定一个事件 _purgeRef: function () {
* @param {String} eventName 事件的名字 if (this.options.ref) {
* @param {Function} fn 事件对应的执行函数 this.options.ref.call(null);
*/ }
on: function (eventName, fn) { },
eventName = eventName.toLowerCase();
var fns = this._getEvents()[eventName];
if (!_.isArray(fns)) {
fns = [];
this._getEvents()[eventName] = fns;
}
fns.push(fn);
},
/** _getEvents: function () {
* 给观察者绑定一个只执行一次的事件 if (!_.isArray(this.events)) {
* @param {String} eventName 事件的名字 this.events = [];
* @param {Function} fn 事件对应的执行函数 }
*/ return this.events;
once: function (eventName, fn) { },
var proxy = function () {
fn.apply(this, arguments);
this.un(eventName, proxy);
};
this.on(eventName, proxy);
},
/**
* 解除观察者绑定的指定事件
* @param {String} eventName 要解除绑定事件的名字
* @param {Function} fn 事件对应的执行函数该参数是可选的没有该参数时将解除绑定所有同名字的事件
*/
un: function (eventName, fn) {
eventName = eventName.toLowerCase();
/* alex:如果fn是null,就是把eventName上面所有方法都un掉*/ /**
if (fn == null) { * 给观察者绑定一个事件
delete this._getEvents()[eventName]; * @param {String} eventName 事件的名字
} else { * @param {Function} fn 事件对应的执行函数
*/
on: function (eventName, fn) {
eventName = eventName.toLowerCase();
var fns = this._getEvents()[eventName]; var fns = this._getEvents()[eventName];
if (_.isArray(fns)) { if (!_.isArray(fns)) {
var newFns = []; fns = [];
_.each(fns, function (ifn) { this._getEvents()[eventName] = fns;
if (ifn != fn) {
newFns.push(ifn);
}
});
this._getEvents()[eventName] = newFns;
} }
} fns.push(fn);
}, },
/**
* 清除观察者的所有事件绑定 /**
*/ * 给观察者绑定一个只执行一次的事件
purgeListeners: function () { * @param {String} eventName 事件的名字
/* alex:清空events*/ * @param {Function} fn 事件对应的执行函数
this.events = []; */
}, once: function (eventName, fn) {
/** var proxy = function () {
* 触发绑定过的事件 fn.apply(this, arguments);
* this.un(eventName, proxy);
* @param {String} eventName 要触发的事件的名字 };
* @returns {Boolean} 如果事件函数返回false则返回false并中断其他同名事件的执行否则执行所有的同名事件并返回true this.on(eventName, proxy);
*/ },
fireEvent: function () { /**
var eventName = arguments[0].toLowerCase(); * 解除观察者绑定的指定事件
var fns = this._getEvents()[eventName]; * @param {String} eventName 要解除绑定事件的名字
if (BI.isArray(fns)) { * @param {Function} fn 事件对应的执行函数该参数是可选的没有该参数时将解除绑定所有同名字的事件
if (BI.isArguments(arguments[1])) { */
for (var i = 0; i < fns.length; i++) { un: function (eventName, fn) {
if (fns[i].apply(this, arguments[1]) === false) { eventName = eventName.toLowerCase();
return false;
} /* alex:如果fn是null,就是把eventName上面所有方法都un掉*/
} if (fn == null) {
delete this._getEvents()[eventName];
} else { } else {
var args = Array.prototype.slice.call(arguments, 1); var fns = this._getEvents()[eventName];
for (var i = 0; i < fns.length; i++) { if (_.isArray(fns)) {
if (fns[i].apply(this, args) === false) { var newFns = [];
return false; _.each(fns, function (ifn) {
if (ifn != fn) {
newFns.push(ifn);
}
});
this._getEvents()[eventName] = newFns;
}
}
},
/**
* 清除观察者的所有事件绑定
*/
purgeListeners: function () {
/* alex:清空events*/
this.events = [];
},
/**
* 触发绑定过的事件
*
* @param {String} eventName 要触发的事件的名字
* @returns {Boolean} 如果事件函数返回false则返回false并中断其他同名事件的执行否则执行所有的同名事件并返回true
*/
fireEvent: function () {
var eventName = arguments[0].toLowerCase();
var fns = this._getEvents()[eventName];
if (BI.isArray(fns)) {
if (BI.isArguments(arguments[1])) {
for (var i = 0; i < fns.length; i++) {
if (fns[i].apply(this, arguments[1]) === false) {
return false;
}
}
} else {
var args = Array.prototype.slice.call(arguments, 1);
for (var i = 0; i < fns.length; i++) {
if (fns[i].apply(this, args) === false) {
return false;
}
} }
} }
} }
} return true;
return true; },
},
destroy: function () { destroy: function () {
this.destroyed && this.destroyed(); this.destroyed && this.destroyed();
this._purgeRef(); this._purgeRef();
this.purgeListeners(); this.purgeListeners();
} }
});/** });
})();/**
* Widget超类 * Widget超类
* @class BI.Widget * @class BI.Widget
* @extends BI.OB * @extends BI.OB
@ -44084,18 +44110,30 @@ BI.Editor = BI.inherit(BI.Single, {
} }
e.stopEvent(); e.stopEvent();
}); });
this.watermark.element.css({ }
position: "absolute",
left: "3px", var _items = [];
right: "3px", if (this.watermark) {
top: "0px", _items.push({
bottom: "0px" el: this.watermark,
left: 3,
right: 3,
top: 0,
bottom: 0
}); });
} }
_items.push({
el: this.editor,
left: 0,
right: 0,
top: 0,
bottom: 0
});
var items = [{ var items = [{
el: { el: {
type: "bi.default", type: "bi.absolute",
items: this.watermark ? [this.editor, this.watermark] : [this.editor] items: _items
}, },
left: o.hgap + o.lgap, left: o.hgap + o.lgap,
right: o.hgap + o.rgap, right: o.hgap + o.rgap,
@ -44130,8 +44168,11 @@ BI.Editor = BI.inherit(BI.Single, {
this.editor.on(BI.Input.EVENT_KEY_DOWN, function (v) { this.editor.on(BI.Input.EVENT_KEY_DOWN, function (v) {
self.fireEvent(BI.Editor.EVENT_KEY_DOWN, arguments); self.fireEvent(BI.Editor.EVENT_KEY_DOWN, arguments);
}); });
this.editor.on(BI.Input.EVENT_QUICK_DOWN, function (v) { this.editor.on(BI.Input.EVENT_QUICK_DOWN, function (e) {
self.watermark && self.watermark.invisible(); // tab键就不要隐藏了
if (e.keyCode !== BI.KeyCode.TAB && self.watermark) {
self.watermark.invisible();
}
}); });
this.editor.on(BI.Input.EVENT_VALID, function () { this.editor.on(BI.Input.EVENT_VALID, function () {
@ -45371,6 +45412,10 @@ BI.Input = BI.inherit(BI.Single, {
"leading": true, "leading": true,
"trailing": false "trailing": false
}); });
this._focusDebounce = BI.debounce(BI.bind(this._focus, this), BI.EVENT_RESPONSE_TIME, {
"leading": true,
"trailing": false
});
this._blurDebounce = BI.debounce(BI.bind(this._blur, this), BI.EVENT_RESPONSE_TIME, { this._blurDebounce = BI.debounce(BI.bind(this._blur, this), BI.EVENT_RESPONSE_TIME, {
"leading": true, "leading": true,
"trailing": false "trailing": false
@ -45379,7 +45424,7 @@ BI.Input = BI.inherit(BI.Single, {
.keydown(function (e) { .keydown(function (e) {
inputEventValid = false; inputEventValid = false;
ctrlKey = e.ctrlKey; ctrlKey = e.ctrlKey;
self.fireEvent(BI.Input.EVENT_QUICK_DOWN); self.fireEvent(BI.Input.EVENT_QUICK_DOWN, arguments);
}) })
.keyup(function (e) { .keyup(function (e) {
if (!(inputEventValid && e.keyCode === BI.KeyCode.ENTER)) { if (!(inputEventValid && e.keyCode === BI.KeyCode.ENTER)) {
@ -45402,6 +45447,9 @@ BI.Input = BI.inherit(BI.Single, {
.mousedown(function (e) { .mousedown(function (e) {
self.element.val(self.element.val()); self.element.val(self.element.val());
}) })
.focus(function (e) { // 可以不用冒泡
self._focusDebounce();
})
.focusout(function (e) { .focusout(function (e) {
self._blurDebounce(); self._blurDebounce();
}); });
@ -45449,7 +45497,6 @@ BI.Input = BI.inherit(BI.Single, {
_click: function () { _click: function () {
if (this._isEditing !== true) { if (this._isEditing !== true) {
this._focus();
this.selectAll(); this.selectAll();
this.fireEvent(BI.Input.EVENT_CLICK); this.fireEvent(BI.Input.EVENT_CLICK);
} }
@ -45550,7 +45597,6 @@ BI.Input = BI.inherit(BI.Single, {
} }
if (!this._isEditing === true) { if (!this._isEditing === true) {
this.element.focus(); this.element.focus();
this._focus();
this.selectAll(); this.selectAll();
} }
}, },
@ -81837,255 +81883,7 @@ BI.ValueChooserPane = BI.inherit(BI.AbstractValueChooser, {
} }
}); });
BI.ValueChooserPane.EVENT_CHANGE = "ValueChooserPane.EVENT_CHANGE"; BI.ValueChooserPane.EVENT_CHANGE = "ValueChooserPane.EVENT_CHANGE";
BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);;(function () { BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);(function () {
function initWatch(vm, watch) {
vm._watchers || (vm._watchers = []);
for (var key in watch) {
var handler = watch[key];
if (BI.isArray(handler)) {
for (var i = 0; i < handler.length; i++) {
vm._watchers.push(createWatcher(vm, key, handler[i]));
}
} else {
vm._watchers.push(createWatcher(vm, key, handler));
}
}
}
function createWatcher(vm, keyOrFn, handler) {
return Fix.watch(vm.model, keyOrFn, _.bind(handler, vm), {
store: vm.store
});
}
var target = null;
var targetStack = [];
function pushTarget(_target) {
if (target) targetStack.push(target);
Fix.Model.target = target = _target;
}
function popTarget() {
Fix.Model.target = target = targetStack.pop();
}
var context = null;
var contextStack = [];
function pushContext(_context) {
if (context) contextStack.push(context);
Fix.Model.context = context = _context;
}
function popContext() {
Fix.Model.context = context = contextStack.pop();
}
var oldWatch = Fix.watch;
Fix.watch = function (model, expOrFn, cb, options) {
if (BI.isPlainObject(cb)) {
options = cb;
cb = cb.handler;
}
if (typeof cb === "string") {
cb = model[cb];
}
return oldWatch.call(this, model, expOrFn, function () {
options && options.store && pushTarget(options.store);
var res = cb.apply(this, arguments);
options && options.store && popTarget();
return res;
}, options);
};
function findStore(widget) {
if (target != null) {
return target;
}
widget = widget || context;
var p = widget;
while (p) {
if (p instanceof Fix.Model || p.store || p.__cacheStore) {
break;
}
p = p._parent || (p.options && p.options.element);
}
if (p) {
if (p instanceof Fix.Model) {
return widget.__cacheStore = p;
}
widget.__cacheStore = p.store || p.__cacheStore;
return p.__cacheStore || p.store;
}
}
var _create = BI.createWidget;
BI.createWidget = function (item, options, context) {
var pushed = false;
if (BI.isWidget(options)) {
pushContext(options);
pushed = true;
} else if (context != null) {
pushContext(context);
pushed = true;
}
var result = _create.apply(this, arguments);
pushed && popContext();
return result;
};
_.each(["populate", "addItems", "prependItems"], function (name) {
var old = BI.Loader.prototype[name];
BI.Loader.prototype[name] = function () {
pushContext(this);
var result = old.apply(this, arguments);
popContext();
return result;
};
});
function createStore() {
var needPop = false;
if (_global.Fix && this._store) {
var store = findStore(this.options.context || this.options.element);
if (store) {
pushTarget(store);
needPop = true;
}
this.store = this._store();
this.store && (this.store._widget = this);
needPop && popTarget();
needPop = false;
pushTarget(this.store);
if (this.store instanceof Fix.Model) {
this.model = this.store.model;
} else {
this.model = this.store;
}
needPop = true;
}
return needPop;
}
var _init = BI.Widget.prototype._init;
BI.Widget.prototype._init = function () {
var self = this;
var needPop = createStore.call(this);
_init.apply(this, arguments);
needPop && popTarget();
};
var _render = BI.Widget.prototype._render;
BI.Widget.prototype._render = function () {
var needPop = false;
if (_global.Fix && this._store) {
needPop = true;
pushTarget(this.store);
initWatch(this, this.watch);
}
_render.apply(this, arguments);
needPop && popTarget();
};
var unMount = BI.Widget.prototype.__d;
BI.Widget.prototype.__d = function () {
unMount.apply(this, arguments);
this.store && BI.isFunction(this.store.destroy) && this.store.destroy();
BI.each(this._watchers, function (i, unwatches) {
unwatches = BI.isArray(unwatches) ? unwatches : [unwatches];
BI.each(unwatches, function (j, unwatch) {
unwatch();
});
});
this._watchers && (this._watchers = []);
if (this.store) {
this.store._parent && (this.store._parent = null);
this.store._widget && (this.store._widget = null);
this.store = null;
}
delete this.__cacheStore;
};
_.each(["_mount"], function (name) {
var old = BI.Widget.prototype[name];
old && (BI.Widget.prototype[name] = function () {
this.store && pushTarget(this.store);
var res = old.apply(this, arguments);
this.store && popTarget();
return res;
});
});
if (BI.isIE9Below && BI.isIE9Below()) {
_.each(["each", "map", "reduce", "reduceRight", "find", "filter", "reject", "every", "all", "some", "any", "max", "min",
"sortBy", "groupBy", "indexBy", "countBy", "partition",
"keys", "allKeys", "values", "pairs", "invert",
"mapObject", "findKey", "pick", "omit", "tap"], function (name) {
var old = BI[name];
BI[name] = function (obj, fn, context) {
return typeof fn === "function" ? old(obj, function (key, value) {
if (!(key in Fix.$$skipArray)) {
return fn.apply(this, arguments);
}
}, context) : old.apply(this, arguments);
};
});
BI.isEmpty = function (ob) {
if (BI.isPlainObject(ob) && ob.__ob__) {
return BI.keys(ob).length === 0;
}
return _.isEmpty(ob);
};
BI.keys = function (ob) {
var keys = _.keys(ob);
var nKeys = [];
for (var i = 0; i < keys.length; i++) {
if (!(keys[i] in Fix.$$skipArray)) {
nKeys.push(keys[i]);
}
}
return nKeys;
};
BI.values = function (ob) {
var keys = BI.keys(obj);
var length = keys.length;
var values = [];
for (var i = 0; i < length; i++) {
values[i] = obj[keys[i]];
}
return values;
};
BI.extend = function () {
var args = Array.prototype.slice.call(arguments);
if (args.length < 1) {
return {};
}
var object = args[0];
var i = 1;
while (i < args.length) {
BI.each(args[i], function (key, v) {
object[key] = v;
});
i++;
}
return object;
};
BI.size = function (ob) {
if (BI.isPlainObject(ob) && ob.__ob__) {
return BI.keys(ob).length;
}
return _.size(ob);
};
BI.isEmptyObject = function (ob) {
return BI.size(ob) === 0;
};
BI.deepClone = function (ob) {
return Fix.toJSON(ob);
};
}
BI.watch = Fix.watch;
}());(function () {
var Events = { var Events = {
// Bind an event to a `callback` function. Passing `"all"` will bind // Bind an event to a `callback` function. Passing `"all"` will bind
@ -82669,4 +82467,252 @@ BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane);;(function () {
// Create the default BI.history. // Create the default BI.history.
BI.history = new History; BI.history = new History;
}());;(function () {
function initWatch(vm, watch) {
vm._watchers || (vm._watchers = []);
for (var key in watch) {
var handler = watch[key];
if (BI.isArray(handler)) {
for (var i = 0; i < handler.length; i++) {
vm._watchers.push(createWatcher(vm, key, handler[i]));
}
} else {
vm._watchers.push(createWatcher(vm, key, handler));
}
}
}
function createWatcher(vm, keyOrFn, handler) {
return Fix.watch(vm.model, keyOrFn, _.bind(handler, vm), {
store: vm.store
});
}
var target = null;
var targetStack = [];
function pushTarget(_target) {
if (target) targetStack.push(target);
Fix.Model.target = target = _target;
}
function popTarget() {
Fix.Model.target = target = targetStack.pop();
}
var context = null;
var contextStack = [];
function pushContext(_context) {
if (context) contextStack.push(context);
Fix.Model.context = context = _context;
}
function popContext() {
Fix.Model.context = context = contextStack.pop();
}
var oldWatch = Fix.watch;
Fix.watch = function (model, expOrFn, cb, options) {
if (BI.isPlainObject(cb)) {
options = cb;
cb = cb.handler;
}
if (typeof cb === "string") {
cb = model[cb];
}
return oldWatch.call(this, model, expOrFn, function () {
options && options.store && pushTarget(options.store);
var res = cb.apply(this, arguments);
options && options.store && popTarget();
return res;
}, options);
};
function findStore(widget) {
if (target != null) {
return target;
}
widget = widget || context;
var p = widget;
while (p) {
if (p instanceof Fix.Model || p.store || p.__cacheStore) {
break;
}
p = p._parent || (p.options && p.options.element);
}
if (p) {
if (p instanceof Fix.Model) {
return widget.__cacheStore = p;
}
widget.__cacheStore = p.store || p.__cacheStore;
return p.__cacheStore || p.store;
}
}
var _create = BI.createWidget;
BI.createWidget = function (item, options, context) {
var pushed = false;
if (BI.isWidget(options)) {
pushContext(options);
pushed = true;
} else if (context != null) {
pushContext(context);
pushed = true;
}
var result = _create.apply(this, arguments);
pushed && popContext();
return result;
};
_.each(["populate", "addItems", "prependItems"], function (name) {
var old = BI.Loader.prototype[name];
BI.Loader.prototype[name] = function () {
pushContext(this);
var result = old.apply(this, arguments);
popContext();
return result;
};
});
function createStore() {
var needPop = false;
if (_global.Fix && this._store) {
var store = findStore(this.options.context || this.options.element);
if (store) {
pushTarget(store);
needPop = true;
}
this.store = this._store();
this.store && (this.store._widget = this);
needPop && popTarget();
needPop = false;
pushTarget(this.store);
if (this.store instanceof Fix.Model) {
this.model = this.store.model;
} else {
this.model = this.store;
}
needPop = true;
}
return needPop;
}
var _init = BI.Widget.prototype._init;
BI.Widget.prototype._init = function () {
var self = this;
var needPop = createStore.call(this);
_init.apply(this, arguments);
needPop && popTarget();
};
var _render = BI.Widget.prototype._render;
BI.Widget.prototype._render = function () {
var needPop = false;
if (_global.Fix && this._store) {
needPop = true;
pushTarget(this.store);
initWatch(this, this.watch);
}
_render.apply(this, arguments);
needPop && popTarget();
};
var unMount = BI.Widget.prototype.__d;
BI.Widget.prototype.__d = function () {
unMount.apply(this, arguments);
this.store && BI.isFunction(this.store.destroy) && this.store.destroy();
BI.each(this._watchers, function (i, unwatches) {
unwatches = BI.isArray(unwatches) ? unwatches : [unwatches];
BI.each(unwatches, function (j, unwatch) {
unwatch();
});
});
this._watchers && (this._watchers = []);
if (this.store) {
this.store._parent && (this.store._parent = null);
this.store._widget && (this.store._widget = null);
this.store = null;
}
delete this.__cacheStore;
};
_.each(["_mount"], function (name) {
var old = BI.Widget.prototype[name];
old && (BI.Widget.prototype[name] = function () {
this.store && pushTarget(this.store);
var res = old.apply(this, arguments);
this.store && popTarget();
return res;
});
});
if (BI.isIE9Below && BI.isIE9Below()) {
_.each(["each", "map", "reduce", "reduceRight", "find", "filter", "reject", "every", "all", "some", "any", "max", "min",
"sortBy", "groupBy", "indexBy", "countBy", "partition",
"keys", "allKeys", "values", "pairs", "invert",
"mapObject", "findKey", "pick", "omit", "tap"], function (name) {
var old = BI[name];
BI[name] = function (obj, fn, context) {
return typeof fn === "function" ? old(obj, function (key, value) {
if (!(key in Fix.$$skipArray)) {
return fn.apply(this, arguments);
}
}, context) : old.apply(this, arguments);
};
});
BI.isEmpty = function (ob) {
if (BI.isPlainObject(ob) && ob.__ob__) {
return BI.keys(ob).length === 0;
}
return _.isEmpty(ob);
};
BI.keys = function (ob) {
var keys = _.keys(ob);
var nKeys = [];
for (var i = 0; i < keys.length; i++) {
if (!(keys[i] in Fix.$$skipArray)) {
nKeys.push(keys[i]);
}
}
return nKeys;
};
BI.values = function (ob) {
var keys = BI.keys(obj);
var length = keys.length;
var values = [];
for (var i = 0; i < length; i++) {
values[i] = obj[keys[i]];
}
return values;
};
BI.extend = function () {
var args = Array.prototype.slice.call(arguments);
if (args.length < 1) {
return {};
}
var object = args[0];
var i = 1;
while (i < args.length) {
BI.each(args[i], function (key, v) {
object[key] = v;
});
i++;
}
return object;
};
BI.size = function (ob) {
if (BI.isPlainObject(ob) && ob.__ob__) {
return BI.keys(ob).length;
}
return _.size(ob);
};
BI.isEmptyObject = function (ob) {
return BI.size(ob) === 0;
};
BI.deepClone = function (ob) {
return Fix.toJSON(ob);
};
}
BI.watch = Fix.watch;
}());BI.resourceURL = "file?path=/com/fr/web/ui/resource"; }());BI.resourceURL = "file?path=/com/fr/web/ui/resource";

50
dist/fineui.min.js vendored

File diff suppressed because one or more lines are too long

344
dist/fineui_without_jquery_polyfill.js vendored

@ -11478,158 +11478,184 @@ if (!_global.BI) {
} }
}); });
})();/** })();!(function () {
* 客户端观察者主要处理事件的添加删除执行等 function extend () {
* @class BI.OB var target = arguments[0] || {}, length = arguments.length, i = 1, options, name, src, copy;
* @abstract for (; i < length; i++) {
*/ // Only deal with non-null/undefined values
BI.OB = function (config) { if ((options = arguments[i]) != null) {
var props = this.props; // Extend the base object
if (BI.isFunction(this.props)) { for (name in options) {
props = this.props(config); src = target[name];
} copy = options[name];
this.options = (_global.$ || _global._).extend(this._defaultConfig(config), props, config);
this._init(); // Prevent never-ending loop
this._initRef(); if (target === copy) {
}; continue;
_.extend(BI.OB.prototype, { }
props: {},
init: null,
destroyed: null,
_defaultConfig: function (config) {
return {};
},
_init: function () {
this._initListeners();
this.init && this.init();
},
_initListeners: function () { if (copy !== undefined) {
var self = this; target[name] = copy;
if (this.options.listeners != null) { }
_.each(this.options.listeners, function (lis) { }
(lis.target ? lis.target : self)[lis.once ? "once" : "on"] }
(lis.eventName, _.bind(lis.action, self));
});
delete this.options.listeners;
} }
}, return target;
}
// 获得一个当前对象的引用 /**
_initRef: function () { * 客户端观察者主要处理事件的添加删除执行等
if (this.options.ref) { * @class BI.OB
this.options.ref.call(this, this); * @abstract
*/
BI.OB = function (config) {
var props = this.props;
if (BI.isFunction(this.props)) {
props = this.props(config);
} }
}, this.options = extend(this._defaultConfig(config), props, config);
this._init();
this._initRef();
};
_.extend(BI.OB.prototype, {
props: {},
init: null,
destroyed: null,
//释放当前对象 _defaultConfig: function (config) {
_purgeRef: function(){ return {};
if (this.options.ref) { },
this.options.ref.call(null);
}
},
_getEvents: function () { _init: function () {
if (!_.isArray(this.events)) { this._initListeners();
this.events = []; this.init && this.init();
} },
return this.events;
},
/** _initListeners: function () {
* 给观察者绑定一个事件 var self = this;
* @param {String} eventName 事件的名字 if (this.options.listeners != null) {
* @param {Function} fn 事件对应的执行函数 _.each(this.options.listeners, function (lis) {
*/ (lis.target ? lis.target : self)[lis.once ? "once" : "on"]
on: function (eventName, fn) { (lis.eventName, _.bind(lis.action, self));
eventName = eventName.toLowerCase(); });
var fns = this._getEvents()[eventName]; delete this.options.listeners;
if (!_.isArray(fns)) { }
fns = []; },
this._getEvents()[eventName] = fns;
}
fns.push(fn);
},
/** // 获得一个当前对象的引用
* 给观察者绑定一个只执行一次的事件 _initRef: function () {
* @param {String} eventName 事件的名字 if (this.options.ref) {
* @param {Function} fn 事件对应的执行函数 this.options.ref.call(this, this);
*/ }
once: function (eventName, fn) { },
var proxy = function () {
fn.apply(this, arguments);
this.un(eventName, proxy);
};
this.on(eventName, proxy);
},
/**
* 解除观察者绑定的指定事件
* @param {String} eventName 要解除绑定事件的名字
* @param {Function} fn 事件对应的执行函数该参数是可选的没有该参数时将解除绑定所有同名字的事件
*/
un: function (eventName, fn) {
eventName = eventName.toLowerCase();
/* alex:如果fn是null,就是把eventName上面所有方法都un掉*/ //释放当前对象
if (fn == null) { _purgeRef: function () {
delete this._getEvents()[eventName]; if (this.options.ref) {
} else { this.options.ref.call(null);
}
},
_getEvents: function () {
if (!_.isArray(this.events)) {
this.events = [];
}
return this.events;
},
/**
* 给观察者绑定一个事件
* @param {String} eventName 事件的名字
* @param {Function} fn 事件对应的执行函数
*/
on: function (eventName, fn) {
eventName = eventName.toLowerCase();
var fns = this._getEvents()[eventName]; var fns = this._getEvents()[eventName];
if (_.isArray(fns)) { if (!_.isArray(fns)) {
var newFns = []; fns = [];
_.each(fns, function (ifn) { this._getEvents()[eventName] = fns;
if (ifn != fn) {
newFns.push(ifn);
}
});
this._getEvents()[eventName] = newFns;
} }
} fns.push(fn);
}, },
/**
* 清除观察者的所有事件绑定 /**
*/ * 给观察者绑定一个只执行一次的事件
purgeListeners: function () { * @param {String} eventName 事件的名字
/* alex:清空events*/ * @param {Function} fn 事件对应的执行函数
this.events = []; */
}, once: function (eventName, fn) {
/** var proxy = function () {
* 触发绑定过的事件 fn.apply(this, arguments);
* this.un(eventName, proxy);
* @param {String} eventName 要触发的事件的名字 };
* @returns {Boolean} 如果事件函数返回false则返回false并中断其他同名事件的执行否则执行所有的同名事件并返回true this.on(eventName, proxy);
*/ },
fireEvent: function () { /**
var eventName = arguments[0].toLowerCase(); * 解除观察者绑定的指定事件
var fns = this._getEvents()[eventName]; * @param {String} eventName 要解除绑定事件的名字
if (BI.isArray(fns)) { * @param {Function} fn 事件对应的执行函数该参数是可选的没有该参数时将解除绑定所有同名字的事件
if (BI.isArguments(arguments[1])) { */
for (var i = 0; i < fns.length; i++) { un: function (eventName, fn) {
if (fns[i].apply(this, arguments[1]) === false) { eventName = eventName.toLowerCase();
return false;
} /* alex:如果fn是null,就是把eventName上面所有方法都un掉*/
} if (fn == null) {
delete this._getEvents()[eventName];
} else { } else {
var args = Array.prototype.slice.call(arguments, 1); var fns = this._getEvents()[eventName];
for (var i = 0; i < fns.length; i++) { if (_.isArray(fns)) {
if (fns[i].apply(this, args) === false) { var newFns = [];
return false; _.each(fns, function (ifn) {
if (ifn != fn) {
newFns.push(ifn);
}
});
this._getEvents()[eventName] = newFns;
}
}
},
/**
* 清除观察者的所有事件绑定
*/
purgeListeners: function () {
/* alex:清空events*/
this.events = [];
},
/**
* 触发绑定过的事件
*
* @param {String} eventName 要触发的事件的名字
* @returns {Boolean} 如果事件函数返回false则返回false并中断其他同名事件的执行否则执行所有的同名事件并返回true
*/
fireEvent: function () {
var eventName = arguments[0].toLowerCase();
var fns = this._getEvents()[eventName];
if (BI.isArray(fns)) {
if (BI.isArguments(arguments[1])) {
for (var i = 0; i < fns.length; i++) {
if (fns[i].apply(this, arguments[1]) === false) {
return false;
}
}
} else {
var args = Array.prototype.slice.call(arguments, 1);
for (var i = 0; i < fns.length; i++) {
if (fns[i].apply(this, args) === false) {
return false;
}
} }
} }
} }
} return true;
return true; },
},
destroy: function () { destroy: function () {
this.destroyed && this.destroyed(); this.destroyed && this.destroyed();
this._purgeRef(); this._purgeRef();
this.purgeListeners(); this.purgeListeners();
} }
});/** });
})();/**
* Widget超类 * Widget超类
* @class BI.Widget * @class BI.Widget
* @extends BI.OB * @extends BI.OB
@ -31752,18 +31778,30 @@ BI.Editor = BI.inherit(BI.Single, {
} }
e.stopEvent(); e.stopEvent();
}); });
this.watermark.element.css({ }
position: "absolute",
left: "3px", var _items = [];
right: "3px", if (this.watermark) {
top: "0px", _items.push({
bottom: "0px" el: this.watermark,
left: 3,
right: 3,
top: 0,
bottom: 0
}); });
} }
_items.push({
el: this.editor,
left: 0,
right: 0,
top: 0,
bottom: 0
});
var items = [{ var items = [{
el: { el: {
type: "bi.default", type: "bi.absolute",
items: this.watermark ? [this.editor, this.watermark] : [this.editor] items: _items
}, },
left: o.hgap + o.lgap, left: o.hgap + o.lgap,
right: o.hgap + o.rgap, right: o.hgap + o.rgap,
@ -31798,8 +31836,11 @@ BI.Editor = BI.inherit(BI.Single, {
this.editor.on(BI.Input.EVENT_KEY_DOWN, function (v) { this.editor.on(BI.Input.EVENT_KEY_DOWN, function (v) {
self.fireEvent(BI.Editor.EVENT_KEY_DOWN, arguments); self.fireEvent(BI.Editor.EVENT_KEY_DOWN, arguments);
}); });
this.editor.on(BI.Input.EVENT_QUICK_DOWN, function (v) { this.editor.on(BI.Input.EVENT_QUICK_DOWN, function (e) {
self.watermark && self.watermark.invisible(); // tab键就不要隐藏了
if (e.keyCode !== BI.KeyCode.TAB && self.watermark) {
self.watermark.invisible();
}
}); });
this.editor.on(BI.Input.EVENT_VALID, function () { this.editor.on(BI.Input.EVENT_VALID, function () {
@ -32423,6 +32464,10 @@ BI.Input = BI.inherit(BI.Single, {
"leading": true, "leading": true,
"trailing": false "trailing": false
}); });
this._focusDebounce = BI.debounce(BI.bind(this._focus, this), BI.EVENT_RESPONSE_TIME, {
"leading": true,
"trailing": false
});
this._blurDebounce = BI.debounce(BI.bind(this._blur, this), BI.EVENT_RESPONSE_TIME, { this._blurDebounce = BI.debounce(BI.bind(this._blur, this), BI.EVENT_RESPONSE_TIME, {
"leading": true, "leading": true,
"trailing": false "trailing": false
@ -32431,7 +32476,7 @@ BI.Input = BI.inherit(BI.Single, {
.keydown(function (e) { .keydown(function (e) {
inputEventValid = false; inputEventValid = false;
ctrlKey = e.ctrlKey; ctrlKey = e.ctrlKey;
self.fireEvent(BI.Input.EVENT_QUICK_DOWN); self.fireEvent(BI.Input.EVENT_QUICK_DOWN, arguments);
}) })
.keyup(function (e) { .keyup(function (e) {
if (!(inputEventValid && e.keyCode === BI.KeyCode.ENTER)) { if (!(inputEventValid && e.keyCode === BI.KeyCode.ENTER)) {
@ -32454,6 +32499,9 @@ BI.Input = BI.inherit(BI.Single, {
.mousedown(function (e) { .mousedown(function (e) {
self.element.val(self.element.val()); self.element.val(self.element.val());
}) })
.focus(function (e) { // 可以不用冒泡
self._focusDebounce();
})
.focusout(function (e) { .focusout(function (e) {
self._blurDebounce(); self._blurDebounce();
}); });
@ -32501,7 +32549,6 @@ BI.Input = BI.inherit(BI.Single, {
_click: function () { _click: function () {
if (this._isEditing !== true) { if (this._isEditing !== true) {
this._focus();
this.selectAll(); this.selectAll();
this.fireEvent(BI.Input.EVENT_CLICK); this.fireEvent(BI.Input.EVENT_CLICK);
} }
@ -32602,7 +32649,6 @@ BI.Input = BI.inherit(BI.Single, {
} }
if (!this._isEditing === true) { if (!this._isEditing === true) {
this.element.focus(); this.element.focus();
this._focus();
this.selectAll(); this.selectAll();
} }
}, },

298
dist/utils.js vendored

@ -12237,158 +12237,184 @@ if (!_global.BI) {
} }
}); });
})();/** })();!(function () {
* 客户端观察者主要处理事件的添加删除执行等 function extend () {
* @class BI.OB var target = arguments[0] || {}, length = arguments.length, i = 1, options, name, src, copy;
* @abstract for (; i < length; i++) {
*/ // Only deal with non-null/undefined values
BI.OB = function (config) { if ((options = arguments[i]) != null) {
var props = this.props; // Extend the base object
if (BI.isFunction(this.props)) { for (name in options) {
props = this.props(config); src = target[name];
} copy = options[name];
this.options = (_global.$ || _global._).extend(this._defaultConfig(config), props, config);
this._init(); // Prevent never-ending loop
this._initRef(); if (target === copy) {
}; continue;
_.extend(BI.OB.prototype, { }
props: {},
init: null,
destroyed: null,
_defaultConfig: function (config) {
return {};
},
_init: function () {
this._initListeners();
this.init && this.init();
},
_initListeners: function () { if (copy !== undefined) {
var self = this; target[name] = copy;
if (this.options.listeners != null) { }
_.each(this.options.listeners, function (lis) { }
(lis.target ? lis.target : self)[lis.once ? "once" : "on"] }
(lis.eventName, _.bind(lis.action, self));
});
delete this.options.listeners;
} }
}, return target;
}
// 获得一个当前对象的引用 /**
_initRef: function () { * 客户端观察者主要处理事件的添加删除执行等
if (this.options.ref) { * @class BI.OB
this.options.ref.call(this, this); * @abstract
*/
BI.OB = function (config) {
var props = this.props;
if (BI.isFunction(this.props)) {
props = this.props(config);
} }
}, this.options = extend(this._defaultConfig(config), props, config);
this._init();
this._initRef();
};
_.extend(BI.OB.prototype, {
props: {},
init: null,
destroyed: null,
//释放当前对象 _defaultConfig: function (config) {
_purgeRef: function(){ return {};
if (this.options.ref) { },
this.options.ref.call(null);
}
},
_getEvents: function () { _init: function () {
if (!_.isArray(this.events)) { this._initListeners();
this.events = []; this.init && this.init();
} },
return this.events;
},
/** _initListeners: function () {
* 给观察者绑定一个事件 var self = this;
* @param {String} eventName 事件的名字 if (this.options.listeners != null) {
* @param {Function} fn 事件对应的执行函数 _.each(this.options.listeners, function (lis) {
*/ (lis.target ? lis.target : self)[lis.once ? "once" : "on"]
on: function (eventName, fn) { (lis.eventName, _.bind(lis.action, self));
eventName = eventName.toLowerCase(); });
var fns = this._getEvents()[eventName]; delete this.options.listeners;
if (!_.isArray(fns)) { }
fns = []; },
this._getEvents()[eventName] = fns;
}
fns.push(fn);
},
/** // 获得一个当前对象的引用
* 给观察者绑定一个只执行一次的事件 _initRef: function () {
* @param {String} eventName 事件的名字 if (this.options.ref) {
* @param {Function} fn 事件对应的执行函数 this.options.ref.call(this, this);
*/ }
once: function (eventName, fn) { },
var proxy = function () {
fn.apply(this, arguments);
this.un(eventName, proxy);
};
this.on(eventName, proxy);
},
/**
* 解除观察者绑定的指定事件
* @param {String} eventName 要解除绑定事件的名字
* @param {Function} fn 事件对应的执行函数该参数是可选的没有该参数时将解除绑定所有同名字的事件
*/
un: function (eventName, fn) {
eventName = eventName.toLowerCase();
/* alex:如果fn是null,就是把eventName上面所有方法都un掉*/ //释放当前对象
if (fn == null) { _purgeRef: function () {
delete this._getEvents()[eventName]; if (this.options.ref) {
} else { this.options.ref.call(null);
}
},
_getEvents: function () {
if (!_.isArray(this.events)) {
this.events = [];
}
return this.events;
},
/**
* 给观察者绑定一个事件
* @param {String} eventName 事件的名字
* @param {Function} fn 事件对应的执行函数
*/
on: function (eventName, fn) {
eventName = eventName.toLowerCase();
var fns = this._getEvents()[eventName]; var fns = this._getEvents()[eventName];
if (_.isArray(fns)) { if (!_.isArray(fns)) {
var newFns = []; fns = [];
_.each(fns, function (ifn) { this._getEvents()[eventName] = fns;
if (ifn != fn) {
newFns.push(ifn);
}
});
this._getEvents()[eventName] = newFns;
} }
} fns.push(fn);
}, },
/**
* 清除观察者的所有事件绑定 /**
*/ * 给观察者绑定一个只执行一次的事件
purgeListeners: function () { * @param {String} eventName 事件的名字
/* alex:清空events*/ * @param {Function} fn 事件对应的执行函数
this.events = []; */
}, once: function (eventName, fn) {
/** var proxy = function () {
* 触发绑定过的事件 fn.apply(this, arguments);
* this.un(eventName, proxy);
* @param {String} eventName 要触发的事件的名字 };
* @returns {Boolean} 如果事件函数返回false则返回false并中断其他同名事件的执行否则执行所有的同名事件并返回true this.on(eventName, proxy);
*/ },
fireEvent: function () { /**
var eventName = arguments[0].toLowerCase(); * 解除观察者绑定的指定事件
var fns = this._getEvents()[eventName]; * @param {String} eventName 要解除绑定事件的名字
if (BI.isArray(fns)) { * @param {Function} fn 事件对应的执行函数该参数是可选的没有该参数时将解除绑定所有同名字的事件
if (BI.isArguments(arguments[1])) { */
for (var i = 0; i < fns.length; i++) { un: function (eventName, fn) {
if (fns[i].apply(this, arguments[1]) === false) { eventName = eventName.toLowerCase();
return false;
} /* alex:如果fn是null,就是把eventName上面所有方法都un掉*/
} if (fn == null) {
delete this._getEvents()[eventName];
} else { } else {
var args = Array.prototype.slice.call(arguments, 1); var fns = this._getEvents()[eventName];
for (var i = 0; i < fns.length; i++) { if (_.isArray(fns)) {
if (fns[i].apply(this, args) === false) { var newFns = [];
return false; _.each(fns, function (ifn) {
if (ifn != fn) {
newFns.push(ifn);
}
});
this._getEvents()[eventName] = newFns;
}
}
},
/**
* 清除观察者的所有事件绑定
*/
purgeListeners: function () {
/* alex:清空events*/
this.events = [];
},
/**
* 触发绑定过的事件
*
* @param {String} eventName 要触发的事件的名字
* @returns {Boolean} 如果事件函数返回false则返回false并中断其他同名事件的执行否则执行所有的同名事件并返回true
*/
fireEvent: function () {
var eventName = arguments[0].toLowerCase();
var fns = this._getEvents()[eventName];
if (BI.isArray(fns)) {
if (BI.isArguments(arguments[1])) {
for (var i = 0; i < fns.length; i++) {
if (fns[i].apply(this, arguments[1]) === false) {
return false;
}
}
} else {
var args = Array.prototype.slice.call(arguments, 1);
for (var i = 0; i < fns.length; i++) {
if (fns[i].apply(this, args) === false) {
return false;
}
} }
} }
} }
} return true;
return true; },
},
destroy: function () { destroy: function () {
this.destroyed && this.destroyed(); this.destroyed && this.destroyed();
this._purgeRef(); this._purgeRef();
this.purgeListeners(); this.purgeListeners();
} }
});(function () { });
})();(function () {
var _global; var _global;
if (typeof window !== "undefined") { if (typeof window !== "undefined") {
_global = window; _global = window;

4
dist/utils.min.js vendored

File diff suppressed because one or more lines are too long

296
src/core/ob.js

@ -1,152 +1,178 @@
/** !(function () {
* 客户端观察者主要处理事件的添加删除执行等 function extend () {
* @class BI.OB var target = arguments[0] || {}, length = arguments.length, i = 1, options, name, src, copy;
* @abstract for (; i < length; i++) {
*/ // Only deal with non-null/undefined values
BI.OB = function (config) { if ((options = arguments[i]) != null) {
var props = this.props; // Extend the base object
if (BI.isFunction(this.props)) { for (name in options) {
props = this.props(config); src = target[name];
} copy = options[name];
this.options = (_global.$ || _global._).extend(this._defaultConfig(config), props, config);
this._init();
this._initRef();
};
_.extend(BI.OB.prototype, {
props: {},
init: null,
destroyed: null,
_defaultConfig: function (config) {
return {};
},
_init: function () { // Prevent never-ending loop
this._initListeners(); if (target === copy) {
this.init && this.init(); continue;
}, }
_initListeners: function () { if (copy !== undefined) {
var self = this; target[name] = copy;
if (this.options.listeners != null) { }
_.each(this.options.listeners, function (lis) { }
(lis.target ? lis.target : self)[lis.once ? "once" : "on"] }
(lis.eventName, _.bind(lis.action, self));
});
delete this.options.listeners;
} }
}, return target;
}
// 获得一个当前对象的引用 /**
_initRef: function () { * 客户端观察者主要处理事件的添加删除执行等
if (this.options.ref) { * @class BI.OB
this.options.ref.call(this, this); * @abstract
*/
BI.OB = function (config) {
var props = this.props;
if (BI.isFunction(this.props)) {
props = this.props(config);
} }
}, this.options = extend(this._defaultConfig(config), props, config);
this._init();
this._initRef();
};
_.extend(BI.OB.prototype, {
props: {},
init: null,
destroyed: null,
//释放当前对象 _defaultConfig: function (config) {
_purgeRef: function(){ return {};
if (this.options.ref) { },
this.options.ref.call(null);
}
},
_getEvents: function () { _init: function () {
if (!_.isArray(this.events)) { this._initListeners();
this.events = []; this.init && this.init();
} },
return this.events;
},
/** _initListeners: function () {
* 给观察者绑定一个事件 var self = this;
* @param {String} eventName 事件的名字 if (this.options.listeners != null) {
* @param {Function} fn 事件对应的执行函数 _.each(this.options.listeners, function (lis) {
*/ (lis.target ? lis.target : self)[lis.once ? "once" : "on"]
on: function (eventName, fn) { (lis.eventName, _.bind(lis.action, self));
eventName = eventName.toLowerCase(); });
var fns = this._getEvents()[eventName]; delete this.options.listeners;
if (!_.isArray(fns)) { }
fns = []; },
this._getEvents()[eventName] = fns;
}
fns.push(fn);
},
/** // 获得一个当前对象的引用
* 给观察者绑定一个只执行一次的事件 _initRef: function () {
* @param {String} eventName 事件的名字 if (this.options.ref) {
* @param {Function} fn 事件对应的执行函数 this.options.ref.call(this, this);
*/ }
once: function (eventName, fn) { },
var proxy = function () {
fn.apply(this, arguments);
this.un(eventName, proxy);
};
this.on(eventName, proxy);
},
/**
* 解除观察者绑定的指定事件
* @param {String} eventName 要解除绑定事件的名字
* @param {Function} fn 事件对应的执行函数该参数是可选的没有该参数时将解除绑定所有同名字的事件
*/
un: function (eventName, fn) {
eventName = eventName.toLowerCase();
/* alex:如果fn是null,就是把eventName上面所有方法都un掉*/ //释放当前对象
if (fn == null) { _purgeRef: function () {
delete this._getEvents()[eventName]; if (this.options.ref) {
} else { this.options.ref.call(null);
}
},
_getEvents: function () {
if (!_.isArray(this.events)) {
this.events = [];
}
return this.events;
},
/**
* 给观察者绑定一个事件
* @param {String} eventName 事件的名字
* @param {Function} fn 事件对应的执行函数
*/
on: function (eventName, fn) {
eventName = eventName.toLowerCase();
var fns = this._getEvents()[eventName]; var fns = this._getEvents()[eventName];
if (_.isArray(fns)) { if (!_.isArray(fns)) {
var newFns = []; fns = [];
_.each(fns, function (ifn) { this._getEvents()[eventName] = fns;
if (ifn != fn) {
newFns.push(ifn);
}
});
this._getEvents()[eventName] = newFns;
} }
} fns.push(fn);
}, },
/**
* 清除观察者的所有事件绑定 /**
*/ * 给观察者绑定一个只执行一次的事件
purgeListeners: function () { * @param {String} eventName 事件的名字
/* alex:清空events*/ * @param {Function} fn 事件对应的执行函数
this.events = []; */
}, once: function (eventName, fn) {
/** var proxy = function () {
* 触发绑定过的事件 fn.apply(this, arguments);
* this.un(eventName, proxy);
* @param {String} eventName 要触发的事件的名字 };
* @returns {Boolean} 如果事件函数返回false则返回false并中断其他同名事件的执行否则执行所有的同名事件并返回true this.on(eventName, proxy);
*/ },
fireEvent: function () { /**
var eventName = arguments[0].toLowerCase(); * 解除观察者绑定的指定事件
var fns = this._getEvents()[eventName]; * @param {String} eventName 要解除绑定事件的名字
if (BI.isArray(fns)) { * @param {Function} fn 事件对应的执行函数该参数是可选的没有该参数时将解除绑定所有同名字的事件
if (BI.isArguments(arguments[1])) { */
for (var i = 0; i < fns.length; i++) { un: function (eventName, fn) {
if (fns[i].apply(this, arguments[1]) === false) { eventName = eventName.toLowerCase();
return false;
} /* alex:如果fn是null,就是把eventName上面所有方法都un掉*/
} if (fn == null) {
delete this._getEvents()[eventName];
} else { } else {
var args = Array.prototype.slice.call(arguments, 1); var fns = this._getEvents()[eventName];
for (var i = 0; i < fns.length; i++) { if (_.isArray(fns)) {
if (fns[i].apply(this, args) === false) { var newFns = [];
return false; _.each(fns, function (ifn) {
if (ifn != fn) {
newFns.push(ifn);
}
});
this._getEvents()[eventName] = newFns;
}
}
},
/**
* 清除观察者的所有事件绑定
*/
purgeListeners: function () {
/* alex:清空events*/
this.events = [];
},
/**
* 触发绑定过的事件
*
* @param {String} eventName 要触发的事件的名字
* @returns {Boolean} 如果事件函数返回false则返回false并中断其他同名事件的执行否则执行所有的同名事件并返回true
*/
fireEvent: function () {
var eventName = arguments[0].toLowerCase();
var fns = this._getEvents()[eventName];
if (BI.isArray(fns)) {
if (BI.isArguments(arguments[1])) {
for (var i = 0; i < fns.length; i++) {
if (fns[i].apply(this, arguments[1]) === false) {
return false;
}
}
} else {
var args = Array.prototype.slice.call(arguments, 1);
for (var i = 0; i < fns.length; i++) {
if (fns[i].apply(this, args) === false) {
return false;
}
} }
} }
} }
} return true;
return true; },
},
destroy: function () { destroy: function () {
this.destroyed && this.destroyed(); this.destroyed && this.destroyed();
this._purgeRef(); this._purgeRef();
this.purgeListeners(); this.purgeListeners();
} }
}); });
})();
Loading…
Cancel
Save