Browse Source

Merge pull request #69 in FUI/fineui from ~GUY/fineui:master to master

* commit '86f10a15ab864068637c123eaf7ec0cbf57c144c':
  性能优化
  add
  update
  BI-7322 日期 时分秒基本控件  日期格式打印方式修改
  add
  少改了
  add
  add
es6
guy 7 years ago
parent
commit
e7e8183775
  1. 522
      bi/base.js
  2. 4
      bi/case.js
  3. 40
      bi/core.js
  4. 33332
      bi/widget.js
  5. 16
      demo/js/widget/demo.datetime.js
  6. 522
      docs/base.js
  7. 4
      docs/case.js
  8. 40
      docs/core.js
  9. 16
      docs/demo.js
  10. 33332
      docs/widget.js
  11. 4
      src/base/table/table.js
  12. 4
      src/case/list/list.select.js
  13. 36
      src/core/model.js
  14. 4
      src/core/utils/load.js
  15. 46
      src/widget/datetime/datetime.combo.js
  16. 6
      src/widget/datetime/datetime.js
  17. 82
      src/widget/datetime/datetime.popup.js
  18. 2
      src/widget/datetime/datetime.select.js
  19. 42
      src/widget/datetime/datetime.trigger.js

522
bi/base.js

@ -308,163 +308,163 @@ BI.Pane = BI.inherit(BI.Widget, {
} }
}); });
BI.Pane.EVENT_LOADED = "EVENT_LOADED";/** BI.Pane.EVENT_LOADED = "EVENT_LOADED";/**
* guy * guy
* 这仅仅只是一个超类, 所有简单控件的基类 * 这仅仅只是一个超类, 所有简单控件的基类
* 1类的控制 * 1类的控制
* 2title的控制 * 2title的控制
* 3文字超过边界显示3个点 * 3文字超过边界显示3个点
* 4cursor默认pointor * 4cursor默认pointor
* @class BI.Single * @class BI.Single
* @extends BI.Widget * @extends BI.Widget
* @abstract * @abstract
*/ */
BI.Single = BI.inherit(BI.Widget, { BI.Single = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.Single.superclass._defaultConfig.apply(this, arguments); var conf = BI.Single.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-single", baseCls: (conf.baseCls || "") + " bi-single",
readonly: false, readonly: false,
title: null, title: null,
warningTitle: null, warningTitle: null,
tipType: null, // success或warning tipType: null, // success或warning
value: null value: null
}) })
}, },
_showToolTip: function (e, opt) { _showToolTip: function (e, opt) {
opt || (opt = {}); opt || (opt = {});
var self = this; var self = this;
var type = this.getTipType() || (this.isEnabled() ? "success" : "warning"); var type = this.getTipType() || (this.isEnabled() ? "success" : "warning");
var title = type === "success" ? this.getTitle() : (this.getWarningTitle() || this.getTitle()); var title = type === "success" ? this.getTitle() : (this.getWarningTitle() || this.getTitle());
if (BI.isKey(title)) { if (BI.isKey(title)) {
BI.Tooltips.show(e, this.getName(), title, type, this, opt); BI.Tooltips.show(e, this.getName(), title, type, this, opt);
} }
}, },
_hideTooltip: function () { _hideTooltip: function () {
var self = this; var self = this;
var tooltip = BI.Tooltips.get(this.getName()); var tooltip = BI.Tooltips.get(this.getName());
if (BI.isNotNull(tooltip)) { if (BI.isNotNull(tooltip)) {
tooltip.element.fadeOut(200, function () { tooltip.element.fadeOut(200, function () {
BI.Tooltips.remove(self.getName()); BI.Tooltips.remove(self.getName());
}); });
} }
}, },
_init: function () { _init: function () {
BI.Single.superclass._init.apply(this, arguments); BI.Single.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
if (BI.isKey(o.title) || BI.isKey(o.warningTitle) if (BI.isKey(o.title) || BI.isKey(o.warningTitle)
|| BI.isFunction(o.title) || BI.isFunction(o.warningTitle)) { || BI.isFunction(o.title) || BI.isFunction(o.warningTitle)) {
this.enableHover(); this.enableHover();
} }
}, },
enableHover: function (opt) { enableHover: function (opt) {
opt || (opt = {}); opt || (opt = {});
var self = this; var self = this;
if (!this._hoverBinded) { if (!this._hoverBinded) {
this.element.on("mouseenter.title" + this.getName(), function (e) { this.element.on("mouseenter.title" + this.getName(), function (e) {
self._e = e; self._e = e;
if (self.getTipType() === "warning" || (BI.isKey(self.getWarningTitle()) && !self.isEnabled())) { if (self.getTipType() === "warning" || (BI.isKey(self.getWarningTitle()) && !self.isEnabled())) {
self.timeout = BI.delay(function () { self.timeout = BI.delay(function () {
self._showToolTip(self._e || e, opt); self._showToolTip(self._e || e, opt);
}, 200); }, 200);
} else if (self.getTipType() === "success" || self.isEnabled()) { } else if (self.getTipType() === "success" || self.isEnabled()) {
self.timeout = BI.delay(function () { self.timeout = BI.delay(function () {
self._showToolTip(self._e || e, opt); self._showToolTip(self._e || e, opt);
}, 500); }, 500);
} }
}); });
this.element.on("mousemove.title" + this.getName(), function (e) { this.element.on("mousemove.title" + this.getName(), function (e) {
self._e = e; self._e = e;
if (!self.element.__isMouseInBounds__(e)) { if (!self.element.__isMouseInBounds__(e)) {
if (BI.isNotNull(self.timeout)) { if (BI.isNotNull(self.timeout)) {
clearTimeout(self.timeout); clearTimeout(self.timeout);
} }
self._hideTooltip(); self._hideTooltip();
} }
}); });
this.element.on("mouseleave.title" + this.getName(), function () { this.element.on("mouseleave.title" + this.getName(), function () {
self._e = null; self._e = null;
if (BI.isNotNull(self.timeout)) { if (BI.isNotNull(self.timeout)) {
clearTimeout(self.timeout); clearTimeout(self.timeout);
} }
self._hideTooltip(); self._hideTooltip();
}); });
this._hoverBinded = true; this._hoverBinded = true;
} }
}, },
disabledHover: function () { disabledHover: function () {
//取消hover事件 //取消hover事件
if (BI.isNotNull(this.timeout)) { if (BI.isNotNull(this.timeout)) {
clearTimeout(this.timeout); clearTimeout(this.timeout);
} }
this._hideTooltip(); this._hideTooltip();
$(this.element).unbind("mouseenter.title" + this.getName()) $(this.element).unbind("mouseenter.title" + this.getName())
.unbind("mousemove.title" + this.getName()) .unbind("mousemove.title" + this.getName())
.unbind("mouseleave.title" + this.getName()); .unbind("mouseleave.title" + this.getName());
this._hoverBinded = false; this._hoverBinded = false;
}, },
populate: function (items) { populate: function (items) {
this.items = items || []; this.items = items || [];
}, },
//opt: {container: '', belowMouse: false} //opt: {container: '', belowMouse: false}
setTitle: function (title, opt) { setTitle: function (title, opt) {
this.options.title = title; this.options.title = title;
if (BI.isKey(title)) { if (BI.isKey(title)) {
this.enableHover(opt); this.enableHover(opt);
} else { } else {
this.disabledHover(); this.disabledHover();
} }
}, },
setWarningTitle: function (title, opt) { setWarningTitle: function (title, opt) {
this.options.warningTitle = title; this.options.warningTitle = title;
if (BI.isKey(title)) { if (BI.isKey(title)) {
this.enableHover(opt); this.enableHover(opt);
} else { } else {
this.disabledHover(); this.disabledHover();
} }
}, },
getTipType: function () { getTipType: function () {
return this.options.tipType; return this.options.tipType;
}, },
isReadOnly: function () { isReadOnly: function () {
return !!this.options.readonly; return !!this.options.readonly;
}, },
getTitle: function () { getTitle: function () {
var title = this.options.title; var title = this.options.title;
if(BI.isFunction(title)) { if(BI.isFunction(title)) {
return title(); return title();
} }
return title; return title;
}, },
getWarningTitle: function () { getWarningTitle: function () {
var title = this.options.warningTitle; var title = this.options.warningTitle;
if(BI.isFunction(title)) { if(BI.isFunction(title)) {
return title(); return title();
} }
return title; return title;
}, },
setValue: function (val) { setValue: function (val) {
if (!this.options.readonly) { if (!this.options.readonly) {
this.options.value = val; this.options.value = val;
} }
}, },
getValue: function () { getValue: function () {
return this.options.value; return this.options.value;
} }
});/** });/**
* guy 表示一行数据通过position来定位位置的数据 * guy 表示一行数据通过position来定位位置的数据
* @class BI.Text * @class BI.Text
@ -918,82 +918,82 @@ BI.BasicButton = BI.inherit(BI.Single, {
BI.BasicButton.superclass.destroy.apply(this, arguments); BI.BasicButton.superclass.destroy.apply(this, arguments);
} }
}); });
BI.BasicButton.EVENT_CHANGE = "BasicButton.EVENT_CHANGE";/** BI.BasicButton.EVENT_CHANGE = "BasicButton.EVENT_CHANGE";/**
* 表示一个可以展开的节点, 不仅有选中状态而且有展开状态 * 表示一个可以展开的节点, 不仅有选中状态而且有展开状态
* *
* Created by GUY on 2015/9/9. * Created by GUY on 2015/9/9.
* @class BI.NodeButton * @class BI.NodeButton
* @extends BI.BasicButton * @extends BI.BasicButton
* @abstract * @abstract
*/ */
BI.NodeButton = BI.inherit(BI.BasicButton, { BI.NodeButton = BI.inherit(BI.BasicButton, {
_defaultConfig: function() { _defaultConfig: function() {
var conf = BI.NodeButton.superclass._defaultConfig.apply(this, arguments); var conf = BI.NodeButton.superclass._defaultConfig.apply(this, arguments);
return BI.extend( conf, { return BI.extend( conf, {
baseCls: (conf.baseCls || "") + " bi-node", baseCls: (conf.baseCls || "") + " bi-node",
open: false open: false
}) })
}, },
_init:function() { _init:function() {
BI.NodeButton.superclass._init.apply(this, arguments); BI.NodeButton.superclass._init.apply(this, arguments);
var self = this; var self = this;
BI.nextTick(function(){ BI.nextTick(function(){
self.setOpened(self.isOpened()); self.setOpened(self.isOpened());
}) })
}, },
doClick: function(){ doClick: function(){
BI.NodeButton.superclass.doClick.apply(this, arguments); BI.NodeButton.superclass.doClick.apply(this, arguments);
this.setOpened(!this.isOpened()); this.setOpened(!this.isOpened());
}, },
isOnce: function(){ isOnce: function(){
return false; return false;
}, },
isOpened: function(){ isOpened: function(){
return !!this.options.open; return !!this.options.open;
}, },
setOpened: function(b){ setOpened: function(b){
this.options.open = !!b; this.options.open = !!b;
}, },
triggerCollapse: function(){ triggerCollapse: function(){
if(this.isOpened()) { if(this.isOpened()) {
this.setOpened(false); this.setOpened(false);
this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, this.getValue(), this); this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, this.getValue(), this);
} }
}, },
triggerExpand: function(){ triggerExpand: function(){
if(!this.isOpened()) { if(!this.isOpened()) {
this.setOpened(true); this.setOpened(true);
this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, this.getValue(), this); this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, this.getValue(), this);
} }
} }
});/** });/**
* guy * guy
* tip提示 * tip提示
* zIndex在10亿级别 * zIndex在10亿级别
* @class BI.Tip * @class BI.Tip
* @extends BI.Single * @extends BI.Single
* @abstract * @abstract
*/ */
BI.Tip = BI.inherit(BI.Single, { BI.Tip = BI.inherit(BI.Single, {
_defaultConfig: function() { _defaultConfig: function() {
var conf = BI.Link.superclass._defaultConfig.apply(this, arguments); var conf = BI.Link.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-tip", baseCls: (conf.baseCls || "") + " bi-tip",
zIndex: BI.zIndex_tip zIndex: BI.zIndex_tip
}) })
}, },
_init : function() { _init : function() {
BI.Tip.superclass._init.apply(this, arguments); BI.Tip.superclass._init.apply(this, arguments);
this.element.css({"zIndex": this.options.zIndex}); this.element.css({"zIndex": this.options.zIndex});
} }
});/** });/**
* Created by GUY on 2015/6/26. * Created by GUY on 2015/6/26.
* @class BI.ButtonGroup * @class BI.ButtonGroup
@ -20293,32 +20293,32 @@ BI.Tooltip = BI.inherit(BI.Tip, {
} }
}); });
BI.shortcut("bi.tooltip", BI.Tooltip);/** BI.shortcut("bi.tooltip", BI.Tooltip);/**
* 下拉 * 下拉
* @class BI.Trigger * @class BI.Trigger
* @extends BI.Single * @extends BI.Single
* @abstract * @abstract
*/ */
BI.Trigger = BI.inherit(BI.Single, { BI.Trigger = BI.inherit(BI.Single, {
_defaultConfig: function() { _defaultConfig: function() {
var conf = BI.Trigger.superclass._defaultConfig.apply(this, arguments); var conf = BI.Trigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-trigger cursor-pointer", baseCls: (conf.baseCls || "") + " bi-trigger cursor-pointer",
height: 30 height: 30
}) })
}, },
_init : function() { _init : function() {
BI.Trigger.superclass._init.apply(this, arguments); BI.Trigger.superclass._init.apply(this, arguments);
}, },
setKey: function(){ setKey: function(){
}, },
getKey: function(){ getKey: function(){
} }
});// Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved. });// Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
@ -31366,8 +31366,8 @@ BI.Table = BI.inherit(BI.Widget, {
var isNeedMergeCol = o.mergeRule(map[i][j], map[i][j - 1]); var isNeedMergeCol = o.mergeRule(map[i][j], map[i][j - 1]);
if (isNeedMergeCol === true) { if (isNeedMergeCol === true) {
mergeCol(i, j); mergeCol(i, j);
preCol[j] = preRow[j - 1]; preCol[j] = preRow[i];
preCW[j] = preRW[j - 1]; preCW[j] = preRW[i];
} else { } else {
createOneEl(i, j); createOneEl(i, j);
} }

4
bi/case.js

@ -8791,9 +8791,9 @@ BI.SelectList = BI.inherit(BI.Widget, {
this._checkAllSelected(); this._checkAllSelected();
}, },
_setEnable: function () { _setEnable: function (enable) {
BI.SelectList.superclass._setEnable.apply(this, arguments); BI.SelectList.superclass._setEnable.apply(this, arguments);
this.toolbar.setEnable(arguments); this.toolbar.setEnable(enable);
}, },
resetHeight: function (h) { resetHeight: function (h) {

40
bi/core.js

@ -4904,7 +4904,41 @@ BI.Widget = BI.inherit(BI.OB, {
}, },
_change: function (child) { _change: function (child) {
this.set(this._map(child)); var self = this;
var childMap = this._map(child);
//this.set(childMap);
var changes = [];
var changing = this._changing;
var changed;
var options = {};
this._changing = true;
if (!changing) {
this._previousAttributes = _.clone(this.attributes);
this.changed = {};
}
var current = this.attributes, prev = this._previousAttributes, val;
for (var attr in childMap) {
val = childMap[attr];
changes.push(attr);
this.changed[attr] = val;
current[attr] = val;
}
if (changes.length) this._pending = options;
for (var i = 0, length = changes.length; i < length; i++) {
this.trigger('change:' + changes[i], this, current[changes[i]], options);
}
if (changing) return this;
changed = BI.clone(this.changed);
while (this._pending) {
options = this._pending;
this._pending = false;
this.trigger('change', changed, prev, this, options);
}
this._pending = false;
this._changing = false;
if (changes.length) {
this.trigger("changed", changed, prev, this, options);
}
return this; return this;
}, },
@ -9178,12 +9212,12 @@ $.extend(BI, {
must: false must: false
}, options); }, options);
config.url = BI.servletURL + '?op=' + config.op + '&resource=' + config.path; config.url = BI.servletURL + '?op=' + config.op + '&resource=' + config.path;
this.$import(config.url, config.type,config.must); this.$import(config.url, config.type, config.must);
}, },
$import: function () { $import: function () {
var _LOADED = {}; // alex:保存加载过的 var _LOADED = {}; // alex:保存加载过的
function loadReady(src, must) { function loadReady(src, must) {
var $scripts = $("head script"); var $scripts = $("head script, body script");
$.each($scripts, function (i, item) { $.each($scripts, function (i, item) {
if (item.src.indexOf(src) != -1) { if (item.src.indexOf(src) != -1) {
_LOADED[src] = true; _LOADED[src] = true;

33332
bi/widget.js

File diff suppressed because it is too large Load Diff

16
demo/js/widget/demo.datetime.js

@ -2,7 +2,8 @@
* Created by Urthur on 2017/7/18. * Created by Urthur on 2017/7/18.
*/ */
Demo.CustomDateTime = BI.inherit(BI.Widget, { Demo.CustomDateTime = BI.inherit(BI.Widget, {
props: {}, props: {
},
render: function () { render: function () {
var self = this; var self = this;
return { return {
@ -11,12 +12,19 @@ Demo.CustomDateTime = BI.inherit(BI.Widget, {
el: { el: {
type: "bi.custom_date_time_combo", type: "bi.custom_date_time_combo",
ref: function (_ref) { ref: function (_ref) {
self.customDateTime = _ref; self.customDateTime = _ref;
var value, date, dateStr;
self.customDateTime.on(BI.CustomDateTimeCombo.EVENT_CONFIRM, function () { self.customDateTime.on(BI.CustomDateTimeCombo.EVENT_CONFIRM, function () {
BI.Msg.alert("日期", this.getValue().text); value = this.getValue();
date = new Date(value.year,value.month,value.day,value.hour,value.minute,value.second);
dateStr = date.print("%Y-%X-%d %H:%M:%S");
BI.Msg.alert("日期", dateStr);
}); });
self.customDateTime.on(BI.CustomDateTimeCombo.EVENT_CANCEL, function () { self.customDateTime.on(BI.CustomDateTimeCombo.EVENT_CANCEL, function () {
BI.Msg.alert("日期", this.getValue().text); value = this.getValue();
date = new Date(value.year,value.month,value.day,value.hour,value.minute,value.second);
dateStr = date.print("%Y-%X-%d %H:%M:%S");
BI.Msg.alert("日期", dateStr);
}); });
} }
}, },

522
docs/base.js

@ -308,163 +308,163 @@ BI.Pane = BI.inherit(BI.Widget, {
} }
}); });
BI.Pane.EVENT_LOADED = "EVENT_LOADED";/** BI.Pane.EVENT_LOADED = "EVENT_LOADED";/**
* guy * guy
* 这仅仅只是一个超类, 所有简单控件的基类 * 这仅仅只是一个超类, 所有简单控件的基类
* 1类的控制 * 1类的控制
* 2title的控制 * 2title的控制
* 3文字超过边界显示3个点 * 3文字超过边界显示3个点
* 4cursor默认pointor * 4cursor默认pointor
* @class BI.Single * @class BI.Single
* @extends BI.Widget * @extends BI.Widget
* @abstract * @abstract
*/ */
BI.Single = BI.inherit(BI.Widget, { BI.Single = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.Single.superclass._defaultConfig.apply(this, arguments); var conf = BI.Single.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-single", baseCls: (conf.baseCls || "") + " bi-single",
readonly: false, readonly: false,
title: null, title: null,
warningTitle: null, warningTitle: null,
tipType: null, // success或warning tipType: null, // success或warning
value: null value: null
}) })
}, },
_showToolTip: function (e, opt) { _showToolTip: function (e, opt) {
opt || (opt = {}); opt || (opt = {});
var self = this; var self = this;
var type = this.getTipType() || (this.isEnabled() ? "success" : "warning"); var type = this.getTipType() || (this.isEnabled() ? "success" : "warning");
var title = type === "success" ? this.getTitle() : (this.getWarningTitle() || this.getTitle()); var title = type === "success" ? this.getTitle() : (this.getWarningTitle() || this.getTitle());
if (BI.isKey(title)) { if (BI.isKey(title)) {
BI.Tooltips.show(e, this.getName(), title, type, this, opt); BI.Tooltips.show(e, this.getName(), title, type, this, opt);
} }
}, },
_hideTooltip: function () { _hideTooltip: function () {
var self = this; var self = this;
var tooltip = BI.Tooltips.get(this.getName()); var tooltip = BI.Tooltips.get(this.getName());
if (BI.isNotNull(tooltip)) { if (BI.isNotNull(tooltip)) {
tooltip.element.fadeOut(200, function () { tooltip.element.fadeOut(200, function () {
BI.Tooltips.remove(self.getName()); BI.Tooltips.remove(self.getName());
}); });
} }
}, },
_init: function () { _init: function () {
BI.Single.superclass._init.apply(this, arguments); BI.Single.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
if (BI.isKey(o.title) || BI.isKey(o.warningTitle) if (BI.isKey(o.title) || BI.isKey(o.warningTitle)
|| BI.isFunction(o.title) || BI.isFunction(o.warningTitle)) { || BI.isFunction(o.title) || BI.isFunction(o.warningTitle)) {
this.enableHover(); this.enableHover();
} }
}, },
enableHover: function (opt) { enableHover: function (opt) {
opt || (opt = {}); opt || (opt = {});
var self = this; var self = this;
if (!this._hoverBinded) { if (!this._hoverBinded) {
this.element.on("mouseenter.title" + this.getName(), function (e) { this.element.on("mouseenter.title" + this.getName(), function (e) {
self._e = e; self._e = e;
if (self.getTipType() === "warning" || (BI.isKey(self.getWarningTitle()) && !self.isEnabled())) { if (self.getTipType() === "warning" || (BI.isKey(self.getWarningTitle()) && !self.isEnabled())) {
self.timeout = BI.delay(function () { self.timeout = BI.delay(function () {
self._showToolTip(self._e || e, opt); self._showToolTip(self._e || e, opt);
}, 200); }, 200);
} else if (self.getTipType() === "success" || self.isEnabled()) { } else if (self.getTipType() === "success" || self.isEnabled()) {
self.timeout = BI.delay(function () { self.timeout = BI.delay(function () {
self._showToolTip(self._e || e, opt); self._showToolTip(self._e || e, opt);
}, 500); }, 500);
} }
}); });
this.element.on("mousemove.title" + this.getName(), function (e) { this.element.on("mousemove.title" + this.getName(), function (e) {
self._e = e; self._e = e;
if (!self.element.__isMouseInBounds__(e)) { if (!self.element.__isMouseInBounds__(e)) {
if (BI.isNotNull(self.timeout)) { if (BI.isNotNull(self.timeout)) {
clearTimeout(self.timeout); clearTimeout(self.timeout);
} }
self._hideTooltip(); self._hideTooltip();
} }
}); });
this.element.on("mouseleave.title" + this.getName(), function () { this.element.on("mouseleave.title" + this.getName(), function () {
self._e = null; self._e = null;
if (BI.isNotNull(self.timeout)) { if (BI.isNotNull(self.timeout)) {
clearTimeout(self.timeout); clearTimeout(self.timeout);
} }
self._hideTooltip(); self._hideTooltip();
}); });
this._hoverBinded = true; this._hoverBinded = true;
} }
}, },
disabledHover: function () { disabledHover: function () {
//取消hover事件 //取消hover事件
if (BI.isNotNull(this.timeout)) { if (BI.isNotNull(this.timeout)) {
clearTimeout(this.timeout); clearTimeout(this.timeout);
} }
this._hideTooltip(); this._hideTooltip();
$(this.element).unbind("mouseenter.title" + this.getName()) $(this.element).unbind("mouseenter.title" + this.getName())
.unbind("mousemove.title" + this.getName()) .unbind("mousemove.title" + this.getName())
.unbind("mouseleave.title" + this.getName()); .unbind("mouseleave.title" + this.getName());
this._hoverBinded = false; this._hoverBinded = false;
}, },
populate: function (items) { populate: function (items) {
this.items = items || []; this.items = items || [];
}, },
//opt: {container: '', belowMouse: false} //opt: {container: '', belowMouse: false}
setTitle: function (title, opt) { setTitle: function (title, opt) {
this.options.title = title; this.options.title = title;
if (BI.isKey(title)) { if (BI.isKey(title)) {
this.enableHover(opt); this.enableHover(opt);
} else { } else {
this.disabledHover(); this.disabledHover();
} }
}, },
setWarningTitle: function (title, opt) { setWarningTitle: function (title, opt) {
this.options.warningTitle = title; this.options.warningTitle = title;
if (BI.isKey(title)) { if (BI.isKey(title)) {
this.enableHover(opt); this.enableHover(opt);
} else { } else {
this.disabledHover(); this.disabledHover();
} }
}, },
getTipType: function () { getTipType: function () {
return this.options.tipType; return this.options.tipType;
}, },
isReadOnly: function () { isReadOnly: function () {
return !!this.options.readonly; return !!this.options.readonly;
}, },
getTitle: function () { getTitle: function () {
var title = this.options.title; var title = this.options.title;
if(BI.isFunction(title)) { if(BI.isFunction(title)) {
return title(); return title();
} }
return title; return title;
}, },
getWarningTitle: function () { getWarningTitle: function () {
var title = this.options.warningTitle; var title = this.options.warningTitle;
if(BI.isFunction(title)) { if(BI.isFunction(title)) {
return title(); return title();
} }
return title; return title;
}, },
setValue: function (val) { setValue: function (val) {
if (!this.options.readonly) { if (!this.options.readonly) {
this.options.value = val; this.options.value = val;
} }
}, },
getValue: function () { getValue: function () {
return this.options.value; return this.options.value;
} }
});/** });/**
* guy 表示一行数据通过position来定位位置的数据 * guy 表示一行数据通过position来定位位置的数据
* @class BI.Text * @class BI.Text
@ -918,82 +918,82 @@ BI.BasicButton = BI.inherit(BI.Single, {
BI.BasicButton.superclass.destroy.apply(this, arguments); BI.BasicButton.superclass.destroy.apply(this, arguments);
} }
}); });
BI.BasicButton.EVENT_CHANGE = "BasicButton.EVENT_CHANGE";/** BI.BasicButton.EVENT_CHANGE = "BasicButton.EVENT_CHANGE";/**
* 表示一个可以展开的节点, 不仅有选中状态而且有展开状态 * 表示一个可以展开的节点, 不仅有选中状态而且有展开状态
* *
* Created by GUY on 2015/9/9. * Created by GUY on 2015/9/9.
* @class BI.NodeButton * @class BI.NodeButton
* @extends BI.BasicButton * @extends BI.BasicButton
* @abstract * @abstract
*/ */
BI.NodeButton = BI.inherit(BI.BasicButton, { BI.NodeButton = BI.inherit(BI.BasicButton, {
_defaultConfig: function() { _defaultConfig: function() {
var conf = BI.NodeButton.superclass._defaultConfig.apply(this, arguments); var conf = BI.NodeButton.superclass._defaultConfig.apply(this, arguments);
return BI.extend( conf, { return BI.extend( conf, {
baseCls: (conf.baseCls || "") + " bi-node", baseCls: (conf.baseCls || "") + " bi-node",
open: false open: false
}) })
}, },
_init:function() { _init:function() {
BI.NodeButton.superclass._init.apply(this, arguments); BI.NodeButton.superclass._init.apply(this, arguments);
var self = this; var self = this;
BI.nextTick(function(){ BI.nextTick(function(){
self.setOpened(self.isOpened()); self.setOpened(self.isOpened());
}) })
}, },
doClick: function(){ doClick: function(){
BI.NodeButton.superclass.doClick.apply(this, arguments); BI.NodeButton.superclass.doClick.apply(this, arguments);
this.setOpened(!this.isOpened()); this.setOpened(!this.isOpened());
}, },
isOnce: function(){ isOnce: function(){
return false; return false;
}, },
isOpened: function(){ isOpened: function(){
return !!this.options.open; return !!this.options.open;
}, },
setOpened: function(b){ setOpened: function(b){
this.options.open = !!b; this.options.open = !!b;
}, },
triggerCollapse: function(){ triggerCollapse: function(){
if(this.isOpened()) { if(this.isOpened()) {
this.setOpened(false); this.setOpened(false);
this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, this.getValue(), this); this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.COLLAPSE, this.getValue(), this);
} }
}, },
triggerExpand: function(){ triggerExpand: function(){
if(!this.isOpened()) { if(!this.isOpened()) {
this.setOpened(true); this.setOpened(true);
this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, this.getValue(), this); this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EXPAND, this.getValue(), this);
} }
} }
});/** });/**
* guy * guy
* tip提示 * tip提示
* zIndex在10亿级别 * zIndex在10亿级别
* @class BI.Tip * @class BI.Tip
* @extends BI.Single * @extends BI.Single
* @abstract * @abstract
*/ */
BI.Tip = BI.inherit(BI.Single, { BI.Tip = BI.inherit(BI.Single, {
_defaultConfig: function() { _defaultConfig: function() {
var conf = BI.Link.superclass._defaultConfig.apply(this, arguments); var conf = BI.Link.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-tip", baseCls: (conf.baseCls || "") + " bi-tip",
zIndex: BI.zIndex_tip zIndex: BI.zIndex_tip
}) })
}, },
_init : function() { _init : function() {
BI.Tip.superclass._init.apply(this, arguments); BI.Tip.superclass._init.apply(this, arguments);
this.element.css({"zIndex": this.options.zIndex}); this.element.css({"zIndex": this.options.zIndex});
} }
});/** });/**
* Created by GUY on 2015/6/26. * Created by GUY on 2015/6/26.
* @class BI.ButtonGroup * @class BI.ButtonGroup
@ -20293,32 +20293,32 @@ BI.Tooltip = BI.inherit(BI.Tip, {
} }
}); });
BI.shortcut("bi.tooltip", BI.Tooltip);/** BI.shortcut("bi.tooltip", BI.Tooltip);/**
* 下拉 * 下拉
* @class BI.Trigger * @class BI.Trigger
* @extends BI.Single * @extends BI.Single
* @abstract * @abstract
*/ */
BI.Trigger = BI.inherit(BI.Single, { BI.Trigger = BI.inherit(BI.Single, {
_defaultConfig: function() { _defaultConfig: function() {
var conf = BI.Trigger.superclass._defaultConfig.apply(this, arguments); var conf = BI.Trigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-trigger cursor-pointer", baseCls: (conf.baseCls || "") + " bi-trigger cursor-pointer",
height: 30 height: 30
}) })
}, },
_init : function() { _init : function() {
BI.Trigger.superclass._init.apply(this, arguments); BI.Trigger.superclass._init.apply(this, arguments);
}, },
setKey: function(){ setKey: function(){
}, },
getKey: function(){ getKey: function(){
} }
});// Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved. });// Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
@ -31366,8 +31366,8 @@ BI.Table = BI.inherit(BI.Widget, {
var isNeedMergeCol = o.mergeRule(map[i][j], map[i][j - 1]); var isNeedMergeCol = o.mergeRule(map[i][j], map[i][j - 1]);
if (isNeedMergeCol === true) { if (isNeedMergeCol === true) {
mergeCol(i, j); mergeCol(i, j);
preCol[j] = preRow[j - 1]; preCol[j] = preRow[i];
preCW[j] = preRW[j - 1]; preCW[j] = preRW[i];
} else { } else {
createOneEl(i, j); createOneEl(i, j);
} }

4
docs/case.js

@ -8791,9 +8791,9 @@ BI.SelectList = BI.inherit(BI.Widget, {
this._checkAllSelected(); this._checkAllSelected();
}, },
_setEnable: function () { _setEnable: function (enable) {
BI.SelectList.superclass._setEnable.apply(this, arguments); BI.SelectList.superclass._setEnable.apply(this, arguments);
this.toolbar.setEnable(arguments); this.toolbar.setEnable(enable);
}, },
resetHeight: function (h) { resetHeight: function (h) {

40
docs/core.js

@ -14900,7 +14900,41 @@ BI.Widget = BI.inherit(BI.OB, {
}, },
_change: function (child) { _change: function (child) {
this.set(this._map(child)); var self = this;
var childMap = this._map(child);
//this.set(childMap);
var changes = [];
var changing = this._changing;
var changed;
var options = {};
this._changing = true;
if (!changing) {
this._previousAttributes = _.clone(this.attributes);
this.changed = {};
}
var current = this.attributes, prev = this._previousAttributes, val;
for (var attr in childMap) {
val = childMap[attr];
changes.push(attr);
this.changed[attr] = val;
current[attr] = val;
}
if (changes.length) this._pending = options;
for (var i = 0, length = changes.length; i < length; i++) {
this.trigger('change:' + changes[i], this, current[changes[i]], options);
}
if (changing) return this;
changed = BI.clone(this.changed);
while (this._pending) {
options = this._pending;
this._pending = false;
this.trigger('change', changed, prev, this, options);
}
this._pending = false;
this._changing = false;
if (changes.length) {
this.trigger("changed", changed, prev, this, options);
}
return this; return this;
}, },
@ -17625,12 +17659,12 @@ $.extend(BI, {
must: false must: false
}, options); }, options);
config.url = BI.servletURL + '?op=' + config.op + '&resource=' + config.path; config.url = BI.servletURL + '?op=' + config.op + '&resource=' + config.path;
this.$import(config.url, config.type,config.must); this.$import(config.url, config.type, config.must);
}, },
$import: function () { $import: function () {
var _LOADED = {}; // alex:保存加载过的 var _LOADED = {}; // alex:保存加载过的
function loadReady(src, must) { function loadReady(src, must) {
var $scripts = $("head script"); var $scripts = $("head script, body script");
$.each($scripts, function (i, item) { $.each($scripts, function (i, item) {
if (item.src.indexOf(src) != -1) { if (item.src.indexOf(src) != -1) {
_LOADED[src] = true; _LOADED[src] = true;

16
docs/demo.js

@ -7275,7 +7275,8 @@ BI.shortcut("demo.date_pane_widget", Demo.DatePane);/**
* Created by Urthur on 2017/7/18. * Created by Urthur on 2017/7/18.
*/ */
Demo.CustomDateTime = BI.inherit(BI.Widget, { Demo.CustomDateTime = BI.inherit(BI.Widget, {
props: {}, props: {
},
render: function () { render: function () {
var self = this; var self = this;
return { return {
@ -7284,12 +7285,19 @@ Demo.CustomDateTime = BI.inherit(BI.Widget, {
el: { el: {
type: "bi.custom_date_time_combo", type: "bi.custom_date_time_combo",
ref: function (_ref) { ref: function (_ref) {
self.customDateTime = _ref; self.customDateTime = _ref;
var value, date, dateStr;
self.customDateTime.on(BI.CustomDateTimeCombo.EVENT_CONFIRM, function () { self.customDateTime.on(BI.CustomDateTimeCombo.EVENT_CONFIRM, function () {
BI.Msg.alert("日期", this.getValue().text); value = this.getValue();
date = new Date(value.year,value.month,value.day,value.hour,value.minute,value.second);
dateStr = date.print("%Y-%X-%d %H:%M:%S");
BI.Msg.alert("日期", dateStr);
}); });
self.customDateTime.on(BI.CustomDateTimeCombo.EVENT_CANCEL, function () { self.customDateTime.on(BI.CustomDateTimeCombo.EVENT_CANCEL, function () {
BI.Msg.alert("日期", this.getValue().text); value = this.getValue();
date = new Date(value.year,value.month,value.day,value.hour,value.minute,value.second);
dateStr = date.print("%Y-%X-%d %H:%M:%S");
BI.Msg.alert("日期", dateStr);
}); });
} }
}, },

33332
docs/widget.js

File diff suppressed because it is too large Load Diff

4
src/base/table/table.js

@ -418,8 +418,8 @@ BI.Table = BI.inherit(BI.Widget, {
var isNeedMergeCol = o.mergeRule(map[i][j], map[i][j - 1]); var isNeedMergeCol = o.mergeRule(map[i][j], map[i][j - 1]);
if (isNeedMergeCol === true) { if (isNeedMergeCol === true) {
mergeCol(i, j); mergeCol(i, j);
preCol[j] = preRow[j - 1]; preCol[j] = preRow[i];
preCW[j] = preRW[j - 1]; preCW[j] = preRW[i];
} else { } else {
createOneEl(i, j); createOneEl(i, j);
} }

4
src/case/list/list.select.js

@ -158,9 +158,9 @@ BI.SelectList = BI.inherit(BI.Widget, {
this._checkAllSelected(); this._checkAllSelected();
}, },
_setEnable: function () { _setEnable: function (enable) {
BI.SelectList.superclass._setEnable.apply(this, arguments); BI.SelectList.superclass._setEnable.apply(this, arguments);
this.toolbar.setEnable(arguments); this.toolbar.setEnable(enable);
}, },
resetHeight: function (h) { resetHeight: function (h) {

36
src/core/model.js

@ -117,7 +117,41 @@ BI.Model = BI.inherit(BI.M, {
}, },
_change: function (child) { _change: function (child) {
this.set(this._map(child)); var self = this;
var childMap = this._map(child);
//this.set(childMap);
var changes = [];
var changing = this._changing;
var changed;
var options = {};
this._changing = true;
if (!changing) {
this._previousAttributes = _.clone(this.attributes);
this.changed = {};
}
var current = this.attributes, prev = this._previousAttributes, val;
for (var attr in childMap) {
val = childMap[attr];
changes.push(attr);
this.changed[attr] = val;
current[attr] = val;
}
if (changes.length) this._pending = options;
for (var i = 0, length = changes.length; i < length; i++) {
this.trigger('change:' + changes[i], this, current[changes[i]], options);
}
if (changing) return this;
changed = BI.clone(this.changed);
while (this._pending) {
options = this._pending;
this._pending = false;
this.trigger('change', changed, prev, this, options);
}
this._pending = false;
this._changing = false;
if (changes.length) {
this.trigger("changed", changed, prev, this, options);
}
return this; return this;
}, },

4
src/core/utils/load.js

@ -9,12 +9,12 @@ $.extend(BI, {
must: false must: false
}, options); }, options);
config.url = BI.servletURL + '?op=' + config.op + '&resource=' + config.path; config.url = BI.servletURL + '?op=' + config.op + '&resource=' + config.path;
this.$import(config.url, config.type,config.must); this.$import(config.url, config.type, config.must);
}, },
$import: function () { $import: function () {
var _LOADED = {}; // alex:保存加载过的 var _LOADED = {}; // alex:保存加载过的
function loadReady(src, must) { function loadReady(src, must) {
var $scripts = $("head script"); var $scripts = $("head script, body script");
$.each($scripts, function (i, item) { $.each($scripts, function (i, item) {
if (item.src.indexOf(src) != -1) { if (item.src.indexOf(src) != -1) {
_LOADED[src] = true; _LOADED[src] = true;

46
src/widget/datetime/datetime.combo.js

@ -12,30 +12,26 @@ BI.DateTimeCombo = BI.inherit(BI.Single, {
}, },
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.DateTimeCombo.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.DateTimeCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: 'bi-date-time-combo', baseCls: 'bi-date-time-combo bi-border',
height: 24 height: 24
}); });
}, },
_init: function () { _init: function () {
BI.DateTimeCombo.superclass._init.apply(this, arguments); BI.DateTimeCombo.superclass._init.apply(this, arguments);
var self = this; var self = this, opts = this.options;
var date = new Date(); var date = new Date();
this.storeValue = { this.storeValue = {
value: { year: date.getFullYear(),
year: date.getFullYear(), month: date.getMonth(),
month: date.getMonth(), day: date.getDate(),
day: date.getDate(), hour: date.getHours(),
hour: date.getHours(), minute: date.getMinutes(),
minute: date.getMinutes(), second: date.getSeconds()
second: date.getSeconds()
}
}; };
this.trigger = BI.createWidget({ this.trigger = BI.createWidget({
type: 'bi.date_time_trigger' type: 'bi.date_time_trigger',
}); min: this.constants.DATE_MIN_VALUE,
max: this.constants.DATE_MAX_VALUE
this.trigger.on(BI.DateTrigger.EVENT_TRIGGER_CLICK, function () {
self.combo.toggle();
}); });
this.popup = BI.createWidget({ this.popup = BI.createWidget({
@ -47,18 +43,19 @@ BI.DateTimeCombo = BI.inherit(BI.Single, {
this.popup.on(BI.DateTimePopup.BUTTON_CANCEL_EVENT_CHANGE, function () { this.popup.on(BI.DateTimePopup.BUTTON_CANCEL_EVENT_CHANGE, function () {
self.setValue(self.storeValue); self.setValue(self.storeValue);
self.combo.hideView(); self.hidePopupView();
self.fireEvent(BI.DateTimeCombo.EVENT_CANCEL); self.fireEvent(BI.DateTimeCombo.EVENT_CANCEL);
}); });
this.popup.on(BI.DateTimePopup.BUTTON_OK_EVENT_CHANGE, function () { this.popup.on(BI.DateTimePopup.BUTTON_OK_EVENT_CHANGE, function () {
self.storeValue = self.popup.getValue(); self.storeValue = self.popup.getValue();
self.setValue(self.storeValue); self.setValue(self.storeValue);
self.combo.hideView(); self.hidePopupView();
self.fireEvent(BI.DateTimeCombo.EVENT_CONFIRM); self.fireEvent(BI.DateTimeCombo.EVENT_CONFIRM);
}); });
this.popup.on(BI.DateTimePopup.CALENDAR_EVENT_CHANGE, function () { this.popup.on(BI.DateTimePopup.CALENDAR_EVENT_CHANGE, function () {
self.trigger.setValue(self.popup.getValue()); self.trigger.setValue(self.popup.getValue());
}); self.fireEvent(BI.DateTimeCombo.EVENT_CHANGE);
});
this.combo = BI.createWidget({ this.combo = BI.createWidget({
type: 'bi.combo', type: 'bi.combo',
toggle: false, toggle: false,
@ -80,9 +77,9 @@ BI.DateTimeCombo = BI.inherit(BI.Single, {
var triggerBtn = BI.createWidget({ var triggerBtn = BI.createWidget({
type: "bi.trigger_icon_button", type: "bi.trigger_icon_button",
cls: "chart-date-normal-font bi-border-left bi-border-top bi-border-bottom", cls: "bi-trigger-date-button chart-date-normal-font bi-border-right",
width: 30, width: 30,
height: 25 height: 24
}); });
triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () { triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () {
if (self.combo.isViewVisible()) { if (self.combo.isViewVisible()) {
@ -118,10 +115,11 @@ BI.DateTimeCombo = BI.inherit(BI.Single, {
this.trigger.setValue(v); this.trigger.setValue(v);
}, },
getValue: function () { getValue: function () {
return { return this.storeValue;
value: this.storeValue, },
text: this.trigger.getValue()
}; hidePopupView: function () {
this.combo.hideView();
} }
}); });

6
src/widget/datetime/datetime.js

@ -16,12 +16,18 @@ BI.CustomDateTimeCombo = BI.inherit(BI.Widget, {
element: this element: this
}); });
this.DateTime.on(BI.DateTimeCombo.EVENT_CANCEL, function () { this.DateTime.on(BI.DateTimeCombo.EVENT_CANCEL, function () {
self.fireEvent(BI.CustomDateTimeCombo.EVENT_CHANGE);
self.fireEvent(BI.CustomDateTimeCombo.EVENT_CANCEL); self.fireEvent(BI.CustomDateTimeCombo.EVENT_CANCEL);
}); });
this.DateTime.on(BI.DateTimeCombo.EVENT_CONFIRM, function () { this.DateTime.on(BI.DateTimeCombo.EVENT_CONFIRM, function () {
self.fireEvent(BI.CustomDateTimeCombo.EVENT_CHANGE);
self.fireEvent(BI.CustomDateTimeCombo.EVENT_CONFIRM); self.fireEvent(BI.CustomDateTimeCombo.EVENT_CONFIRM);
}); });
this.DateTime.on(BI.DateTimeCombo.EVENT_CHANGE, function () {
self.fireEvent(BI.CustomDateTimeCombo.EVENT_CHANGE);
});
}, },
getValue: function () { getValue: function () {

82
src/widget/datetime/datetime.popup.js

@ -2,18 +2,6 @@
* Created by Urthur on 2017/7/14. * Created by Urthur on 2017/7/14.
*/ */
BI.DateTimePopup = BI.inherit(BI.Widget, { BI.DateTimePopup = BI.inherit(BI.Widget, {
constants: {
triggerHeight: 24,
buttonWidth: 90,
buttonHeight: 25,
popupHeight: 290,
popupWidth: 270,
comboAdjustHeight: 1,
lgap: 2,
border: 1
},
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.DateTimePopup.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.DateTimePopup.superclass._defaultConfig.apply(this, arguments), {
baseCls: 'bi-date-time-popup', baseCls: 'bi-date-time-popup',
@ -23,7 +11,7 @@ BI.DateTimePopup = BI.inherit(BI.Widget, {
}, },
_init: function () { _init: function () {
BI.DateTimePopup.superclass._init.apply(this, arguments); BI.DateTimePopup.superclass._init.apply(this, arguments);
var self = this; var self = this, opts = this.options;
this.cancelButton = BI.createWidget({ this.cancelButton = BI.createWidget({
type: 'bi.text_button', type: 'bi.text_button',
forceCenter: true, forceCenter: true,
@ -109,6 +97,16 @@ BI.DateTimePopup = BI.inherit(BI.Widget, {
}] }]
}); });
var date = new Date();
this.dateCombo.setValue({
year: date.getFullYear(),
month: date.getMonth(),
day: date.getDate()
});
this.hour.setValue(date.getHours());
this.minute.setValue(date.getMinutes());
this.second.setValue(date.getSeconds());
this.dateButton = BI.createWidget({ this.dateButton = BI.createWidget({
type: "bi.grid", type: "bi.grid",
items: [[this.cancelButton, this.okButton]] items: [[this.cancelButton, this.okButton]]
@ -129,42 +127,37 @@ BI.DateTimePopup = BI.inherit(BI.Widget, {
}, },
setValue: function (v) { setValue: function (v) {
var value, date; var value = v, date;
if (BI.isNotNull(v)) { if (BI.isNull(value)) {
value = v.value; date = new Date();
if(BI.isNull(value)){ this.dateCombo.setValue({
date = new Date(); year: date.getFullYear(),
this.dateCombo.setValue({ month: date.getMonth(),
year: date.getFullYear(), day: date.getDate()
month: date.getMonth(), });
day: date.getDate() this.hour.setValue(date.getHours());
}); this.minute.setValue(date.getMinutes());
this.hour.setValue(date.getHours()); this.second.setValue(date.getSeconds());
this.minute.setValue(date.getMinutes()); } else {
this.second.setValue(date.getSeconds()); this.dateCombo.setValue({
} else { year: value.year,
this.dateCombo.setValue({ month: value.month,
year: value.year, day: value.day
month: value.month, });
day: value.day this.hour.setValue(value.hour);
}); this.minute.setValue(value.minute);
this.hour.setValue(value.hour); this.second.setValue(value.second);
this.minute.setValue(value.minute);
this.second.setValue(value.second);
}
} }
}, },
getValue: function () { getValue: function () {
return { return {
value: { year: this.dateCombo.getValue().year,
year: this.dateCombo.getValue().year, month: this.dateCombo.getValue().month,
month: this.dateCombo.getValue().month, day: this.dateCombo.getValue().day,
day: this.dateCombo.getValue().day, hour: this.hour.getValue(),
hour: this.hour.getValue(), minute: this.minute.getValue(),
minute: this.minute.getValue(), second: this.second.getValue()
second: this.second.getValue()
}
} }
} }
}); });
@ -172,4 +165,3 @@ BI.DateTimePopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE";
BI.DateTimePopup.BUTTON_CANCEL_EVENT_CHANGE = "BUTTON_CANCEL_EVENT_CHANGE"; BI.DateTimePopup.BUTTON_CANCEL_EVENT_CHANGE = "BUTTON_CANCEL_EVENT_CHANGE";
BI.DateTimePopup.CALENDAR_EVENT_CHANGE = "CALENDAR_EVENT_CHANGE"; BI.DateTimePopup.CALENDAR_EVENT_CHANGE = "CALENDAR_EVENT_CHANGE";
BI.shortcut('bi.date_time_popup', BI.DateTimePopup); BI.shortcut('bi.date_time_popup', BI.DateTimePopup);

2
src/widget/datetime/datetime.select.js

@ -103,4 +103,4 @@ BI.DateTimeSelect = BI.inherit(BI.Widget, {
}); });
BI.DateTimeSelect.EVENT_CONFIRM = "EVENT_CONFIRM"; BI.DateTimeSelect.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.date_time_select", BI.DateTimeSelect); BI.shortcut("bi.date_time_select", BI.DateTimeSelect);

42
src/widget/datetime/datetime.trigger.js

@ -4,15 +4,16 @@
BI.DateTimeTrigger = BI.inherit(BI.Trigger, { BI.DateTimeTrigger = BI.inherit(BI.Trigger, {
_const: { _const: {
hgap: 4, hgap: 4,
vgap: 2,
triggerWidth: 30 triggerWidth: 30
}, },
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.DateTimeTrigger.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.DateTimeTrigger.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-date-time-trigger", extraCls: "bi-date-time-trigger",
height: 25, min: '1900-01-01', //最小日期
width: 180 max: '2099-12-31', //最大日期
height: 24,
width: 200
}); });
}, },
_init: function () { _init: function () {
@ -20,19 +21,18 @@ BI.DateTimeTrigger = BI.inherit(BI.Trigger, {
var self = this, o = this.options, c = this._const; var self = this, o = this.options, c = this._const;
this.text = BI.createWidget({ this.text = BI.createWidget({
type: "bi.label", type: "bi.label",
cls: "bi-border",
textAlign: "left", textAlign: "left",
height: o.height, height: o.height,
width: o.width, width: o.width,
hgap: c.hgap, hgap: c.hgap
vgap: c.vgap
}); });
BI.createWidget({ BI.createWidget({
type: "bi.htape", type: "bi.htape",
element: this, element: this,
items: [{ items: [{
el: BI.createWidget(), el: BI.createWidget(),
width: 30 width: c.triggerWidth
}, { }, {
el: this.text el: this.text
}] }]
@ -45,24 +45,18 @@ BI.DateTimeTrigger = BI.inherit(BI.Trigger, {
setValue: function (v) { setValue: function (v) {
var self = this; var self = this;
if (BI.isNotNull(v)) { var value = v, dateStr;
var value = v.value, dateStr; if(BI.isNull(value)){
if(BI.isNull(value)){ value = new Date();
value = new Date(); dateStr = value.print("%Y-%X-%d %H:%M:%S");
dateStr = value.getFullYear() + "-" + self._printTime(value.getMonth() + 1) + "-" + self._printTime(value.getDate()) } else {
+ " " + self._printTime(value.getHours()) + ":" + self._printTime(value.getMinutes()) + ":" + self._printTime(value.getSeconds()); var date = new Date(value.year,value.month,value.day,value.hour,value.minute,value.second);
} else { dateStr = date.print("%Y-%X-%d %H:%M:%S");
dateStr = value.year + "-" + self._printTime(value.month + 1) + "-" + self._printTime(value.day)
+ " " + self._printTime(value.hour) + ":" + self._printTime(value.minute) + ":" + self._printTime(value.second);
}
this.text.setText(dateStr);
this.text.setTitle(dateStr);
} }
}, this.text.setText(dateStr);
getValue: function () { this.text.setTitle(dateStr);
return this.text.getText();
} }
}); });
BI.DateTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK"; BI.shortcut("bi.date_time_trigger", BI.DateTimeTrigger);
BI.shortcut("bi.date_time_trigger", BI.DateTimeTrigger);
Loading…
Cancel
Save