Browse Source

Merge pull request #97 in ~GUY/fineui from ~WINDY/fineui:master to master

* commit '850e098331985712b1d8970aae9c64638e9257d2':
  update
  update
  update
  sign_initial_editor
es6
windy 8 years ago
parent
commit
a667374857
  1. 518
      bi/base.js
  2. 197
      bi/case.js
  3. 518
      docs/base.js
  4. 197
      docs/case.js
  5. 197
      src/case/editor/editor.sign.initial.js

518
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");

197
bi/case.js

@ -6903,9 +6903,7 @@ BI.ShelterEditor.EVENT_SPACE = "EVENT_SPACE";
BI.ShelterEditor.EVENT_EMPTY = "EVENT_EMPTY"; BI.ShelterEditor.EVENT_EMPTY = "EVENT_EMPTY";
BI.shortcut("bi.shelter_editor", BI.ShelterEditor);/** BI.shortcut("bi.shelter_editor", BI.ShelterEditor);/**
* sign是新值初始value值形式的自适应宽度的输入框 * Created by User on 2017/7/28.
* @class BI.SignInitialEditor
* @extends BI.Single
*/ */
BI.SignInitialEditor = BI.inherit(BI.Widget, { BI.SignInitialEditor = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
@ -6934,8 +6932,7 @@ BI.SignInitialEditor = BI.inherit(BI.Widget, {
BI.SignInitialEditor.superclass._init.apply(this, arguments); BI.SignInitialEditor.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.editor = BI.createWidget({ this.editor = BI.createWidget({
type: "bi.sign_editor", type: "bi.editor",
element: this,
height: o.height, height: o.height,
hgap: o.hgap, hgap: o.hgap,
vgap: o.vgap, vgap: o.vgap,
@ -6943,89 +6940,175 @@ BI.SignInitialEditor = BI.inherit(BI.Widget, {
rgap: o.rgap, rgap: o.rgap,
tgap: o.tgap, tgap: o.tgap,
bgap: o.bgap, bgap: o.bgap,
value: o.value || o.text, value: o.value,
validationChecker: o.validationChecker, validationChecker: o.validationChecker,
quitChecker: o.quitChecker, quitChecker: o.quitChecker,
title: o.title,
warningTitle: o.warningTitle,
mouseOut: o.mouseOut, mouseOut: o.mouseOut,
allowBlank: o.allowBlank, allowBlank: o.allowBlank,
watermark: o.watermark, watermark: o.watermark,
errorText: o.errorText errorText: o.errorText
}); });
if(BI.isNotNull(o.value)){ this.text = BI.createWidget({
this.setState(o.value); type: "bi.text_button",
} cls: "sign-editor-text",
title: o.title,
warningTitle: o.warningTitle,
tipType: o.tipType,
textAlign: "left",
height: o.height,
hgap: 4,
handler: function () {
self._showInput();
self.editor.focus();
self.editor.selectAll();
}
});
this.text.on(BI.TextButton.EVENT_CHANGE, function () {
BI.nextTick(function () {
self.fireEvent(BI.SignInitialEditor.EVENT_CLICK_LABEL)
});
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.text,
left: 0,
right: 0,
top: 0,
bottom: 0
}]
});
this.editor.on(BI.Controller.EVENT_CHANGE, function () { this.editor.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_FOCUS, function () { this.editor.on(BI.Editor.EVENT_FOCUS, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_FOCUS); self.fireEvent(BI.SignInitialEditor.EVENT_FOCUS, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_BLUR, function () { this.editor.on(BI.Editor.EVENT_BLUR, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_BLUR); self.fireEvent(BI.SignInitialEditor.EVENT_BLUR, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_CLICK, function () { this.editor.on(BI.Editor.EVENT_CLICK, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_CLICK); self.fireEvent(BI.SignInitialEditor.EVENT_CLICK, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_CHANGE, function () { this.editor.on(BI.Editor.EVENT_CHANGE, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_CHANGE); self.fireEvent(BI.SignInitialEditor.EVENT_CHANGE, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_KEY_DOWN, function (v) { this.editor.on(BI.Editor.EVENT_KEY_DOWN, function (v) {
self.fireEvent(BI.SignInitialEditor.EVENT_KEY_DOWN); self.fireEvent(BI.SignInitialEditor.EVENT_KEY_DOWN, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_VALID, function () { this.editor.on(BI.Editor.EVENT_VALID, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_VALID); self.fireEvent(BI.SignInitialEditor.EVENT_VALID, arguments);
});
this.editor.on(BI.Editor.EVENT_CONFIRM, function () {
self._showHint();
self._checkText();
self.fireEvent(BI.SignInitialEditor.EVENT_CONFIRM, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () { this.editor.on(BI.Editor.EVENT_START, function () {
self.setState(self.editor.getValue()); self.fireEvent(BI.SignInitialEditor.EVENT_START, arguments);
self.fireEvent(BI.SignInitialEditor.EVENT_CONFIRM);
}); });
this.editor.on(BI.SignEditor.EVENT_START, function () { this.editor.on(BI.Editor.EVENT_PAUSE, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_START); self.fireEvent(BI.SignInitialEditor.EVENT_PAUSE, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_PAUSE, function () { this.editor.on(BI.Editor.EVENT_STOP, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_PAUSE); self.fireEvent(BI.SignInitialEditor.EVENT_STOP, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_STOP, function () { this.editor.on(BI.Editor.EVENT_SPACE, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_STOP); self.fireEvent(BI.SignInitialEditor.EVENT_SPACE, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_SPACE, function () { this.editor.on(BI.Editor.EVENT_ERROR, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_SPACE); self._checkText();
self.fireEvent(BI.SignInitialEditor.EVENT_ERROR, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_ERROR, function () { this.editor.on(BI.Editor.EVENT_ENTER, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_ERROR); self.fireEvent(BI.SignInitialEditor.EVENT_ENTER, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_ENTER, function () { this.editor.on(BI.Editor.EVENT_RESTRICT, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_ENTER); self.fireEvent(BI.SignInitialEditor.EVENT_RESTRICT, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_RESTRICT, function () { this.editor.on(BI.Editor.EVENT_EMPTY, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_RESTRICT); self.fireEvent(BI.SignInitialEditor.EVENT_EMPTY, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_EMPTY, function () { BI.createWidget({
self.fireEvent(BI.SignInitialEditor.EVENT_EMPTY); type: "bi.vertical",
scrolly: false,
element: this,
items: [this.editor]
}); });
this._showHint();
self._checkText();
},
_checkText: function () {
var o = this.options;
BI.nextTick(BI.bind(function () {
if (this.editor.getValue() === "") {
this.text.setValue(o.watermark || "");
this.text.element.addClass("bi-water-mark");
} else {
var v = this.editor.getValue();
v = (BI.isEmpty(v) || v == o.text) ? o.text : v + "(" + o.text + ")";
this.text.setValue(v);
this.text.element.removeClass("bi-water-mark");
}
}, this));
},
_showInput: function () {
this.editor.visible();
this.text.invisible();
},
_showHint: function () {
this.editor.invisible();
this.text.visible();
},
setTitle: function (title) {
this.text.setTitle(title);
},
setWarningTitle: function (title) {
this.text.setWarningTitle(title);
}, },
focus: function () { focus: function () {
this._showInput();
this.editor.focus(); this.editor.focus();
}, },
blur: function () { blur: function () {
this.editor.blur(); this.editor.blur();
this._showHint();
this._checkText();
}, },
isValid: function () { doRedMark: function () {
return this.editor.isValid(); if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
return;
}
this.text.doRedMark.apply(this.text, arguments);
}, },
setTitle: function (title) { unRedMark: function () {
this.editor.setTitle(title); this.text.unRedMark.apply(this.text, arguments);
}, },
setWarningTitle: function (title) { doHighLight: function () {
this.editor.setWarningTitle(title); if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
return;
}
this.text.doHighLight.apply(this.text, arguments);
},
unHighLight: function () {
this.text.unHighLight.apply(this.text, arguments);
},
isValid: function () {
return this.editor.isValid();
}, },
setErrorText: function (text) { setErrorText: function (text) {
@ -7036,9 +7119,19 @@ BI.SignInitialEditor = BI.inherit(BI.Widget, {
return this.editor.getErrorText(); return this.editor.getErrorText();
}, },
isEditing: function () {
return this.editor.isEditing();
},
getLastValidValue: function () {
return this.editor.getLastValidValue();
},
setValue: function (v) { setValue: function (v) {
var o = this.options;
this.editor.setValue(v.value); this.editor.setValue(v.value);
this.setState(v.value); o.text = v.text || o.text;
this._checkText();
}, },
getValue: function () { getValue: function () {
@ -7049,13 +7142,13 @@ BI.SignInitialEditor = BI.inherit(BI.Widget, {
}, },
getState: function () { getState: function () {
return this.editor.getState(); return this.text.getValue();
}, },
setState: function (v) { setState: function (v) {
var o = this.options; this._showHint();
v = (BI.isEmpty(v) || v == o.text) ? o.text : v + "(" + o.text + ")"; v = (BI.isEmpty(v) || v == o.text) ? o.text : v + "(" + o.text + ")";
this.editor.setState(v); this.text.setValue(v);
} }
}); });
BI.SignInitialEditor.EVENT_CHANGE = "EVENT_CHANGE"; BI.SignInitialEditor.EVENT_CHANGE = "EVENT_CHANGE";

518
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");

197
docs/case.js

@ -6903,9 +6903,7 @@ BI.ShelterEditor.EVENT_SPACE = "EVENT_SPACE";
BI.ShelterEditor.EVENT_EMPTY = "EVENT_EMPTY"; BI.ShelterEditor.EVENT_EMPTY = "EVENT_EMPTY";
BI.shortcut("bi.shelter_editor", BI.ShelterEditor);/** BI.shortcut("bi.shelter_editor", BI.ShelterEditor);/**
* sign是新值初始value值形式的自适应宽度的输入框 * Created by User on 2017/7/28.
* @class BI.SignInitialEditor
* @extends BI.Single
*/ */
BI.SignInitialEditor = BI.inherit(BI.Widget, { BI.SignInitialEditor = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
@ -6934,8 +6932,7 @@ BI.SignInitialEditor = BI.inherit(BI.Widget, {
BI.SignInitialEditor.superclass._init.apply(this, arguments); BI.SignInitialEditor.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.editor = BI.createWidget({ this.editor = BI.createWidget({
type: "bi.sign_editor", type: "bi.editor",
element: this,
height: o.height, height: o.height,
hgap: o.hgap, hgap: o.hgap,
vgap: o.vgap, vgap: o.vgap,
@ -6943,89 +6940,175 @@ BI.SignInitialEditor = BI.inherit(BI.Widget, {
rgap: o.rgap, rgap: o.rgap,
tgap: o.tgap, tgap: o.tgap,
bgap: o.bgap, bgap: o.bgap,
value: o.value || o.text, value: o.value,
validationChecker: o.validationChecker, validationChecker: o.validationChecker,
quitChecker: o.quitChecker, quitChecker: o.quitChecker,
title: o.title,
warningTitle: o.warningTitle,
mouseOut: o.mouseOut, mouseOut: o.mouseOut,
allowBlank: o.allowBlank, allowBlank: o.allowBlank,
watermark: o.watermark, watermark: o.watermark,
errorText: o.errorText errorText: o.errorText
}); });
if(BI.isNotNull(o.value)){ this.text = BI.createWidget({
this.setState(o.value); type: "bi.text_button",
} cls: "sign-editor-text",
title: o.title,
warningTitle: o.warningTitle,
tipType: o.tipType,
textAlign: "left",
height: o.height,
hgap: 4,
handler: function () {
self._showInput();
self.editor.focus();
self.editor.selectAll();
}
});
this.text.on(BI.TextButton.EVENT_CHANGE, function () {
BI.nextTick(function () {
self.fireEvent(BI.SignInitialEditor.EVENT_CLICK_LABEL)
});
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.text,
left: 0,
right: 0,
top: 0,
bottom: 0
}]
});
this.editor.on(BI.Controller.EVENT_CHANGE, function () { this.editor.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_FOCUS, function () { this.editor.on(BI.Editor.EVENT_FOCUS, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_FOCUS); self.fireEvent(BI.SignInitialEditor.EVENT_FOCUS, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_BLUR, function () { this.editor.on(BI.Editor.EVENT_BLUR, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_BLUR); self.fireEvent(BI.SignInitialEditor.EVENT_BLUR, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_CLICK, function () { this.editor.on(BI.Editor.EVENT_CLICK, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_CLICK); self.fireEvent(BI.SignInitialEditor.EVENT_CLICK, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_CHANGE, function () { this.editor.on(BI.Editor.EVENT_CHANGE, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_CHANGE); self.fireEvent(BI.SignInitialEditor.EVENT_CHANGE, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_KEY_DOWN, function (v) { this.editor.on(BI.Editor.EVENT_KEY_DOWN, function (v) {
self.fireEvent(BI.SignInitialEditor.EVENT_KEY_DOWN); self.fireEvent(BI.SignInitialEditor.EVENT_KEY_DOWN, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_VALID, function () { this.editor.on(BI.Editor.EVENT_VALID, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_VALID); self.fireEvent(BI.SignInitialEditor.EVENT_VALID, arguments);
});
this.editor.on(BI.Editor.EVENT_CONFIRM, function () {
self._showHint();
self._checkText();
self.fireEvent(BI.SignInitialEditor.EVENT_CONFIRM, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () { this.editor.on(BI.Editor.EVENT_START, function () {
self.setState(self.editor.getValue()); self.fireEvent(BI.SignInitialEditor.EVENT_START, arguments);
self.fireEvent(BI.SignInitialEditor.EVENT_CONFIRM);
}); });
this.editor.on(BI.SignEditor.EVENT_START, function () { this.editor.on(BI.Editor.EVENT_PAUSE, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_START); self.fireEvent(BI.SignInitialEditor.EVENT_PAUSE, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_PAUSE, function () { this.editor.on(BI.Editor.EVENT_STOP, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_PAUSE); self.fireEvent(BI.SignInitialEditor.EVENT_STOP, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_STOP, function () { this.editor.on(BI.Editor.EVENT_SPACE, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_STOP); self.fireEvent(BI.SignInitialEditor.EVENT_SPACE, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_SPACE, function () { this.editor.on(BI.Editor.EVENT_ERROR, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_SPACE); self._checkText();
self.fireEvent(BI.SignInitialEditor.EVENT_ERROR, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_ERROR, function () { this.editor.on(BI.Editor.EVENT_ENTER, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_ERROR); self.fireEvent(BI.SignInitialEditor.EVENT_ENTER, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_ENTER, function () { this.editor.on(BI.Editor.EVENT_RESTRICT, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_ENTER); self.fireEvent(BI.SignInitialEditor.EVENT_RESTRICT, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_RESTRICT, function () { this.editor.on(BI.Editor.EVENT_EMPTY, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_RESTRICT); self.fireEvent(BI.SignInitialEditor.EVENT_EMPTY, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_EMPTY, function () { BI.createWidget({
self.fireEvent(BI.SignInitialEditor.EVENT_EMPTY); type: "bi.vertical",
scrolly: false,
element: this,
items: [this.editor]
}); });
this._showHint();
self._checkText();
},
_checkText: function () {
var o = this.options;
BI.nextTick(BI.bind(function () {
if (this.editor.getValue() === "") {
this.text.setValue(o.watermark || "");
this.text.element.addClass("bi-water-mark");
} else {
var v = this.editor.getValue();
v = (BI.isEmpty(v) || v == o.text) ? o.text : v + "(" + o.text + ")";
this.text.setValue(v);
this.text.element.removeClass("bi-water-mark");
}
}, this));
},
_showInput: function () {
this.editor.visible();
this.text.invisible();
},
_showHint: function () {
this.editor.invisible();
this.text.visible();
},
setTitle: function (title) {
this.text.setTitle(title);
},
setWarningTitle: function (title) {
this.text.setWarningTitle(title);
}, },
focus: function () { focus: function () {
this._showInput();
this.editor.focus(); this.editor.focus();
}, },
blur: function () { blur: function () {
this.editor.blur(); this.editor.blur();
this._showHint();
this._checkText();
}, },
isValid: function () { doRedMark: function () {
return this.editor.isValid(); if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
return;
}
this.text.doRedMark.apply(this.text, arguments);
}, },
setTitle: function (title) { unRedMark: function () {
this.editor.setTitle(title); this.text.unRedMark.apply(this.text, arguments);
}, },
setWarningTitle: function (title) { doHighLight: function () {
this.editor.setWarningTitle(title); if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
return;
}
this.text.doHighLight.apply(this.text, arguments);
},
unHighLight: function () {
this.text.unHighLight.apply(this.text, arguments);
},
isValid: function () {
return this.editor.isValid();
}, },
setErrorText: function (text) { setErrorText: function (text) {
@ -7036,9 +7119,19 @@ BI.SignInitialEditor = BI.inherit(BI.Widget, {
return this.editor.getErrorText(); return this.editor.getErrorText();
}, },
isEditing: function () {
return this.editor.isEditing();
},
getLastValidValue: function () {
return this.editor.getLastValidValue();
},
setValue: function (v) { setValue: function (v) {
var o = this.options;
this.editor.setValue(v.value); this.editor.setValue(v.value);
this.setState(v.value); o.text = v.text || o.text;
this._checkText();
}, },
getValue: function () { getValue: function () {
@ -7049,13 +7142,13 @@ BI.SignInitialEditor = BI.inherit(BI.Widget, {
}, },
getState: function () { getState: function () {
return this.editor.getState(); return this.text.getValue();
}, },
setState: function (v) { setState: function (v) {
var o = this.options; this._showHint();
v = (BI.isEmpty(v) || v == o.text) ? o.text : v + "(" + o.text + ")"; v = (BI.isEmpty(v) || v == o.text) ? o.text : v + "(" + o.text + ")";
this.editor.setState(v); this.text.setValue(v);
} }
}); });
BI.SignInitialEditor.EVENT_CHANGE = "EVENT_CHANGE"; BI.SignInitialEditor.EVENT_CHANGE = "EVENT_CHANGE";

197
src/case/editor/editor.sign.initial.js

@ -1,7 +1,5 @@
/** /**
* sign是新值初始value值形式的自适应宽度的输入框 * Created by User on 2017/7/28.
* @class BI.SignInitialEditor
* @extends BI.Single
*/ */
BI.SignInitialEditor = BI.inherit(BI.Widget, { BI.SignInitialEditor = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
@ -30,8 +28,7 @@ BI.SignInitialEditor = BI.inherit(BI.Widget, {
BI.SignInitialEditor.superclass._init.apply(this, arguments); BI.SignInitialEditor.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.editor = BI.createWidget({ this.editor = BI.createWidget({
type: "bi.sign_editor", type: "bi.editor",
element: this,
height: o.height, height: o.height,
hgap: o.hgap, hgap: o.hgap,
vgap: o.vgap, vgap: o.vgap,
@ -39,89 +36,175 @@ BI.SignInitialEditor = BI.inherit(BI.Widget, {
rgap: o.rgap, rgap: o.rgap,
tgap: o.tgap, tgap: o.tgap,
bgap: o.bgap, bgap: o.bgap,
value: o.value || o.text, value: o.value,
validationChecker: o.validationChecker, validationChecker: o.validationChecker,
quitChecker: o.quitChecker, quitChecker: o.quitChecker,
title: o.title,
warningTitle: o.warningTitle,
mouseOut: o.mouseOut, mouseOut: o.mouseOut,
allowBlank: o.allowBlank, allowBlank: o.allowBlank,
watermark: o.watermark, watermark: o.watermark,
errorText: o.errorText errorText: o.errorText
}); });
if(BI.isNotNull(o.value)){ this.text = BI.createWidget({
this.setState(o.value); type: "bi.text_button",
} cls: "sign-editor-text",
title: o.title,
warningTitle: o.warningTitle,
tipType: o.tipType,
textAlign: "left",
height: o.height,
hgap: 4,
handler: function () {
self._showInput();
self.editor.focus();
self.editor.selectAll();
}
});
this.text.on(BI.TextButton.EVENT_CHANGE, function () {
BI.nextTick(function () {
self.fireEvent(BI.SignInitialEditor.EVENT_CLICK_LABEL)
});
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.text,
left: 0,
right: 0,
top: 0,
bottom: 0
}]
});
this.editor.on(BI.Controller.EVENT_CHANGE, function () { this.editor.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_FOCUS, function () { this.editor.on(BI.Editor.EVENT_FOCUS, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_FOCUS); self.fireEvent(BI.SignInitialEditor.EVENT_FOCUS, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_BLUR, function () { this.editor.on(BI.Editor.EVENT_BLUR, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_BLUR); self.fireEvent(BI.SignInitialEditor.EVENT_BLUR, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_CLICK, function () { this.editor.on(BI.Editor.EVENT_CLICK, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_CLICK); self.fireEvent(BI.SignInitialEditor.EVENT_CLICK, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_CHANGE, function () { this.editor.on(BI.Editor.EVENT_CHANGE, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_CHANGE); self.fireEvent(BI.SignInitialEditor.EVENT_CHANGE, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_KEY_DOWN, function (v) { this.editor.on(BI.Editor.EVENT_KEY_DOWN, function (v) {
self.fireEvent(BI.SignInitialEditor.EVENT_KEY_DOWN); self.fireEvent(BI.SignInitialEditor.EVENT_KEY_DOWN, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_VALID, function () { this.editor.on(BI.Editor.EVENT_VALID, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_VALID); self.fireEvent(BI.SignInitialEditor.EVENT_VALID, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () { this.editor.on(BI.Editor.EVENT_CONFIRM, function () {
self.setState(self.editor.getValue()); self._showHint();
self.fireEvent(BI.SignInitialEditor.EVENT_CONFIRM); self._checkText();
self.fireEvent(BI.SignInitialEditor.EVENT_CONFIRM, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_START, function () { this.editor.on(BI.Editor.EVENT_START, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_START); self.fireEvent(BI.SignInitialEditor.EVENT_START, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_PAUSE, function () { this.editor.on(BI.Editor.EVENT_PAUSE, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_PAUSE); self.fireEvent(BI.SignInitialEditor.EVENT_PAUSE, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_STOP, function () { this.editor.on(BI.Editor.EVENT_STOP, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_STOP); self.fireEvent(BI.SignInitialEditor.EVENT_STOP, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_SPACE, function () { this.editor.on(BI.Editor.EVENT_SPACE, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_SPACE); self.fireEvent(BI.SignInitialEditor.EVENT_SPACE, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_ERROR, function () { this.editor.on(BI.Editor.EVENT_ERROR, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_ERROR); self._checkText();
self.fireEvent(BI.SignInitialEditor.EVENT_ERROR, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_ENTER, function () { this.editor.on(BI.Editor.EVENT_ENTER, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_ENTER); self.fireEvent(BI.SignInitialEditor.EVENT_ENTER, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_RESTRICT, function () { this.editor.on(BI.Editor.EVENT_RESTRICT, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_RESTRICT); self.fireEvent(BI.SignInitialEditor.EVENT_RESTRICT, arguments);
}); });
this.editor.on(BI.SignEditor.EVENT_EMPTY, function () { this.editor.on(BI.Editor.EVENT_EMPTY, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_EMPTY); self.fireEvent(BI.SignInitialEditor.EVENT_EMPTY, arguments);
}); });
BI.createWidget({
type: "bi.vertical",
scrolly: false,
element: this,
items: [this.editor]
});
this._showHint();
self._checkText();
},
_checkText: function () {
var o = this.options;
BI.nextTick(BI.bind(function () {
if (this.editor.getValue() === "") {
this.text.setValue(o.watermark || "");
this.text.element.addClass("bi-water-mark");
} else {
var v = this.editor.getValue();
v = (BI.isEmpty(v) || v == o.text) ? o.text : v + "(" + o.text + ")";
this.text.setValue(v);
this.text.element.removeClass("bi-water-mark");
}
}, this));
},
_showInput: function () {
this.editor.visible();
this.text.invisible();
},
_showHint: function () {
this.editor.invisible();
this.text.visible();
},
setTitle: function (title) {
this.text.setTitle(title);
},
setWarningTitle: function (title) {
this.text.setWarningTitle(title);
}, },
focus: function () { focus: function () {
this._showInput();
this.editor.focus(); this.editor.focus();
}, },
blur: function () { blur: function () {
this.editor.blur(); this.editor.blur();
this._showHint();
this._checkText();
}, },
isValid: function () { doRedMark: function () {
return this.editor.isValid(); if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
return;
}
this.text.doRedMark.apply(this.text, arguments);
}, },
setTitle: function (title) { unRedMark: function () {
this.editor.setTitle(title); this.text.unRedMark.apply(this.text, arguments);
}, },
setWarningTitle: function (title) { doHighLight: function () {
this.editor.setWarningTitle(title); if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
return;
}
this.text.doHighLight.apply(this.text, arguments);
},
unHighLight: function () {
this.text.unHighLight.apply(this.text, arguments);
},
isValid: function () {
return this.editor.isValid();
}, },
setErrorText: function (text) { setErrorText: function (text) {
@ -132,9 +215,19 @@ BI.SignInitialEditor = BI.inherit(BI.Widget, {
return this.editor.getErrorText(); return this.editor.getErrorText();
}, },
isEditing: function () {
return this.editor.isEditing();
},
getLastValidValue: function () {
return this.editor.getLastValidValue();
},
setValue: function (v) { setValue: function (v) {
var o = this.options;
this.editor.setValue(v.value); this.editor.setValue(v.value);
this.setState(v.value); o.text = v.text || o.text;
this._checkText();
}, },
getValue: function () { getValue: function () {
@ -145,13 +238,13 @@ BI.SignInitialEditor = BI.inherit(BI.Widget, {
}, },
getState: function () { getState: function () {
return this.editor.getState(); return this.text.getValue();
}, },
setState: function (v) { setState: function (v) {
var o = this.options; this._showHint();
v = (BI.isEmpty(v) || v == o.text) ? o.text : v + "(" + o.text + ")"; v = (BI.isEmpty(v) || v == o.text) ? o.text : v + "(" + o.text + ")";
this.editor.setState(v); this.text.setValue(v);
} }
}); });
BI.SignInitialEditor.EVENT_CHANGE = "EVENT_CHANGE"; BI.SignInitialEditor.EVENT_CHANGE = "EVENT_CHANGE";

Loading…
Cancel
Save