Browse Source

sign_initial_editor

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

201
bi/case.js

@ -6903,15 +6903,13 @@ BI.ShelterEditor.EVENT_SPACE = "EVENT_SPACE";
BI.ShelterEditor.EVENT_EMPTY = "EVENT_EMPTY";
BI.shortcut("bi.shelter_editor", BI.ShelterEditor);/**
* sign是新值初始value值形式的自适应宽度的输入框
* @class BI.SignInitialEditor
* @extends BI.Single
* Created by User on 2017/7/28.
*/
BI.SignInitialEditor = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.SignInitialEditor.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-sign-initial-editor",
baseCls: (conf.baseCls || "") + " bi-sign-editor",
hgap: 4,
vgap: 2,
lgap: 0,
@ -6924,8 +6922,6 @@ BI.SignInitialEditor = BI.inherit(BI.Widget, {
allowBlank: true,
watermark: "",
errorText: "",
value: "",
text: "",
height: 30
})
},
@ -6934,8 +6930,7 @@ BI.SignInitialEditor = BI.inherit(BI.Widget, {
BI.SignInitialEditor.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.editor = BI.createWidget({
type: "bi.sign_editor",
element: this,
type: "bi.editor",
height: o.height,
hgap: o.hgap,
vgap: o.vgap,
@ -6943,89 +6938,175 @@ BI.SignInitialEditor = BI.inherit(BI.Widget, {
rgap: o.rgap,
tgap: o.tgap,
bgap: o.bgap,
value: o.value || o.text,
value: o.value,
validationChecker: o.validationChecker,
quitChecker: o.quitChecker,
title: o.title,
warningTitle: o.warningTitle,
mouseOut: o.mouseOut,
allowBlank: o.allowBlank,
watermark: o.watermark,
errorText: o.errorText
});
if(BI.isNotNull(o.value)){
this.setState(o.value);
}
this.text = BI.createWidget({
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 () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
});
this.editor.on(BI.SignEditor.EVENT_FOCUS, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_FOCUS);
this.editor.on(BI.Editor.EVENT_FOCUS, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_FOCUS, arguments);
});
this.editor.on(BI.SignEditor.EVENT_BLUR, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_BLUR);
this.editor.on(BI.Editor.EVENT_BLUR, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_BLUR, arguments);
});
this.editor.on(BI.SignEditor.EVENT_CLICK, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_CLICK);
this.editor.on(BI.Editor.EVENT_CLICK, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_CLICK, arguments);
});
this.editor.on(BI.SignEditor.EVENT_CHANGE, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_CHANGE);
this.editor.on(BI.Editor.EVENT_CHANGE, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_CHANGE, arguments);
});
this.editor.on(BI.SignEditor.EVENT_KEY_DOWN, function (v) {
self.fireEvent(BI.SignInitialEditor.EVENT_KEY_DOWN);
this.editor.on(BI.Editor.EVENT_KEY_DOWN, function (v) {
self.fireEvent(BI.SignInitialEditor.EVENT_KEY_DOWN, arguments);
});
this.editor.on(BI.SignEditor.EVENT_VALID, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_VALID);
this.editor.on(BI.Editor.EVENT_VALID, function () {
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 () {
self.setState(self.editor.getValue());
self.fireEvent(BI.SignInitialEditor.EVENT_CONFIRM);
this.editor.on(BI.Editor.EVENT_START, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_START, arguments);
});
this.editor.on(BI.SignEditor.EVENT_START, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_START);
this.editor.on(BI.Editor.EVENT_PAUSE, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_PAUSE, arguments);
});
this.editor.on(BI.SignEditor.EVENT_PAUSE, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_PAUSE);
this.editor.on(BI.Editor.EVENT_STOP, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_STOP, arguments);
});
this.editor.on(BI.SignEditor.EVENT_STOP, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_STOP);
this.editor.on(BI.Editor.EVENT_SPACE, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_SPACE, arguments);
});
this.editor.on(BI.SignEditor.EVENT_SPACE, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_SPACE);
this.editor.on(BI.Editor.EVENT_ERROR, function () {
self._checkText();
self.fireEvent(BI.SignInitialEditor.EVENT_ERROR, arguments);
});
this.editor.on(BI.SignEditor.EVENT_ERROR, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_ERROR);
this.editor.on(BI.Editor.EVENT_ENTER, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_ENTER, arguments);
});
this.editor.on(BI.SignEditor.EVENT_ENTER, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_ENTER);
this.editor.on(BI.Editor.EVENT_RESTRICT, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_RESTRICT, arguments);
});
this.editor.on(BI.SignEditor.EVENT_RESTRICT, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_RESTRICT);
this.editor.on(BI.Editor.EVENT_EMPTY, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_EMPTY, arguments);
});
this.editor.on(BI.SignEditor.EVENT_EMPTY, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_EMPTY);
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 () {
this._showInput();
this.editor.focus();
},
blur: function () {
this.editor.blur();
this._showHint();
this._checkText();
},
isValid: function () {
return this.editor.isValid();
doRedMark: function () {
if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
return;
}
this.text.doRedMark.apply(this.text, arguments);
},
setTitle: function (title) {
this.editor.setTitle(title);
unRedMark: function () {
this.text.unRedMark.apply(this.text, arguments);
},
setWarningTitle: function (title) {
this.editor.setWarningTitle(title);
doHighLight: function () {
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) {
@ -7036,9 +7117,19 @@ BI.SignInitialEditor = BI.inherit(BI.Widget, {
return this.editor.getErrorText();
},
isEditing: function () {
return this.editor.isEditing();
},
getLastValidValue: function () {
return this.editor.getLastValidValue();
},
setValue: function (v) {
var o = this.options;
this.editor.setValue(v.value);
this.setState(v.value);
o.text = v.text || o.text;
this._checkText();
},
getValue: function () {
@ -7049,13 +7140,13 @@ BI.SignInitialEditor = BI.inherit(BI.Widget, {
},
getState: function () {
return this.editor.getState();
return this.text.getValue();
},
setState: function (v) {
var o = this.options;
this._showHint();
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";

1
demo/js/base/editor/demo.code_editor.js

@ -9,6 +9,7 @@ Demo.CodeEditor = BI.inherit(BI.Widget, {
width: 600,
height: 400
});
editor.setValue("select * from ${123} where ${456} = sdsds");
BI.createWidget({
type: "bi.vertical",
element: this,

518
docs/base.js

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

201
docs/case.js

@ -6903,15 +6903,13 @@ BI.ShelterEditor.EVENT_SPACE = "EVENT_SPACE";
BI.ShelterEditor.EVENT_EMPTY = "EVENT_EMPTY";
BI.shortcut("bi.shelter_editor", BI.ShelterEditor);/**
* sign是新值初始value值形式的自适应宽度的输入框
* @class BI.SignInitialEditor
* @extends BI.Single
* Created by User on 2017/7/28.
*/
BI.SignInitialEditor = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.SignInitialEditor.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-sign-initial-editor",
baseCls: (conf.baseCls || "") + " bi-sign-editor",
hgap: 4,
vgap: 2,
lgap: 0,
@ -6924,8 +6922,6 @@ BI.SignInitialEditor = BI.inherit(BI.Widget, {
allowBlank: true,
watermark: "",
errorText: "",
value: "",
text: "",
height: 30
})
},
@ -6934,8 +6930,7 @@ BI.SignInitialEditor = BI.inherit(BI.Widget, {
BI.SignInitialEditor.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.editor = BI.createWidget({
type: "bi.sign_editor",
element: this,
type: "bi.editor",
height: o.height,
hgap: o.hgap,
vgap: o.vgap,
@ -6943,89 +6938,175 @@ BI.SignInitialEditor = BI.inherit(BI.Widget, {
rgap: o.rgap,
tgap: o.tgap,
bgap: o.bgap,
value: o.value || o.text,
value: o.value,
validationChecker: o.validationChecker,
quitChecker: o.quitChecker,
title: o.title,
warningTitle: o.warningTitle,
mouseOut: o.mouseOut,
allowBlank: o.allowBlank,
watermark: o.watermark,
errorText: o.errorText
});
if(BI.isNotNull(o.value)){
this.setState(o.value);
}
this.text = BI.createWidget({
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 () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
});
this.editor.on(BI.SignEditor.EVENT_FOCUS, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_FOCUS);
this.editor.on(BI.Editor.EVENT_FOCUS, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_FOCUS, arguments);
});
this.editor.on(BI.SignEditor.EVENT_BLUR, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_BLUR);
this.editor.on(BI.Editor.EVENT_BLUR, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_BLUR, arguments);
});
this.editor.on(BI.SignEditor.EVENT_CLICK, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_CLICK);
this.editor.on(BI.Editor.EVENT_CLICK, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_CLICK, arguments);
});
this.editor.on(BI.SignEditor.EVENT_CHANGE, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_CHANGE);
this.editor.on(BI.Editor.EVENT_CHANGE, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_CHANGE, arguments);
});
this.editor.on(BI.SignEditor.EVENT_KEY_DOWN, function (v) {
self.fireEvent(BI.SignInitialEditor.EVENT_KEY_DOWN);
this.editor.on(BI.Editor.EVENT_KEY_DOWN, function (v) {
self.fireEvent(BI.SignInitialEditor.EVENT_KEY_DOWN, arguments);
});
this.editor.on(BI.SignEditor.EVENT_VALID, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_VALID);
this.editor.on(BI.Editor.EVENT_VALID, function () {
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 () {
self.setState(self.editor.getValue());
self.fireEvent(BI.SignInitialEditor.EVENT_CONFIRM);
this.editor.on(BI.Editor.EVENT_START, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_START, arguments);
});
this.editor.on(BI.SignEditor.EVENT_START, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_START);
this.editor.on(BI.Editor.EVENT_PAUSE, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_PAUSE, arguments);
});
this.editor.on(BI.SignEditor.EVENT_PAUSE, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_PAUSE);
this.editor.on(BI.Editor.EVENT_STOP, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_STOP, arguments);
});
this.editor.on(BI.SignEditor.EVENT_STOP, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_STOP);
this.editor.on(BI.Editor.EVENT_SPACE, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_SPACE, arguments);
});
this.editor.on(BI.SignEditor.EVENT_SPACE, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_SPACE);
this.editor.on(BI.Editor.EVENT_ERROR, function () {
self._checkText();
self.fireEvent(BI.SignInitialEditor.EVENT_ERROR, arguments);
});
this.editor.on(BI.SignEditor.EVENT_ERROR, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_ERROR);
this.editor.on(BI.Editor.EVENT_ENTER, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_ENTER, arguments);
});
this.editor.on(BI.SignEditor.EVENT_ENTER, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_ENTER);
this.editor.on(BI.Editor.EVENT_RESTRICT, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_RESTRICT, arguments);
});
this.editor.on(BI.SignEditor.EVENT_RESTRICT, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_RESTRICT);
this.editor.on(BI.Editor.EVENT_EMPTY, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_EMPTY, arguments);
});
this.editor.on(BI.SignEditor.EVENT_EMPTY, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_EMPTY);
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 () {
this._showInput();
this.editor.focus();
},
blur: function () {
this.editor.blur();
this._showHint();
this._checkText();
},
isValid: function () {
return this.editor.isValid();
doRedMark: function () {
if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
return;
}
this.text.doRedMark.apply(this.text, arguments);
},
setTitle: function (title) {
this.editor.setTitle(title);
unRedMark: function () {
this.text.unRedMark.apply(this.text, arguments);
},
setWarningTitle: function (title) {
this.editor.setWarningTitle(title);
doHighLight: function () {
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) {
@ -7036,9 +7117,19 @@ BI.SignInitialEditor = BI.inherit(BI.Widget, {
return this.editor.getErrorText();
},
isEditing: function () {
return this.editor.isEditing();
},
getLastValidValue: function () {
return this.editor.getLastValidValue();
},
setValue: function (v) {
var o = this.options;
this.editor.setValue(v.value);
this.setState(v.value);
o.text = v.text || o.text;
this._checkText();
},
getValue: function () {
@ -7049,13 +7140,13 @@ BI.SignInitialEditor = BI.inherit(BI.Widget, {
},
getState: function () {
return this.editor.getState();
return this.text.getValue();
},
setState: function (v) {
var o = this.options;
this._showHint();
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";

1
docs/demo.js

@ -611,6 +611,7 @@ BI.shortcut("demo.svg", Demo.Func);Demo.CodeEditor = BI.inherit(BI.Widget, {
width: 600,
height: 400
});
editor.setValue("select * from ${123} where ${456} = sdsds");
BI.createWidget({
type: "bi.vertical",
element: this,

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

@ -1,13 +1,11 @@
/**
* sign是新值初始value值形式的自适应宽度的输入框
* @class BI.SignInitialEditor
* @extends BI.Single
* Created by User on 2017/7/28.
*/
BI.SignInitialEditor = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.SignInitialEditor.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-sign-initial-editor",
baseCls: (conf.baseCls || "") + " bi-sign-editor",
hgap: 4,
vgap: 2,
lgap: 0,
@ -20,8 +18,6 @@ BI.SignInitialEditor = BI.inherit(BI.Widget, {
allowBlank: true,
watermark: "",
errorText: "",
value: "",
text: "",
height: 30
})
},
@ -30,8 +26,7 @@ BI.SignInitialEditor = BI.inherit(BI.Widget, {
BI.SignInitialEditor.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.editor = BI.createWidget({
type: "bi.sign_editor",
element: this,
type: "bi.editor",
height: o.height,
hgap: o.hgap,
vgap: o.vgap,
@ -39,89 +34,175 @@ BI.SignInitialEditor = BI.inherit(BI.Widget, {
rgap: o.rgap,
tgap: o.tgap,
bgap: o.bgap,
value: o.value || o.text,
value: o.value,
validationChecker: o.validationChecker,
quitChecker: o.quitChecker,
title: o.title,
warningTitle: o.warningTitle,
mouseOut: o.mouseOut,
allowBlank: o.allowBlank,
watermark: o.watermark,
errorText: o.errorText
});
if(BI.isNotNull(o.value)){
this.setState(o.value);
}
this.text = BI.createWidget({
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 () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
});
this.editor.on(BI.SignEditor.EVENT_FOCUS, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_FOCUS);
this.editor.on(BI.Editor.EVENT_FOCUS, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_FOCUS, arguments);
});
this.editor.on(BI.SignEditor.EVENT_BLUR, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_BLUR);
this.editor.on(BI.Editor.EVENT_BLUR, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_BLUR, arguments);
});
this.editor.on(BI.SignEditor.EVENT_CLICK, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_CLICK);
this.editor.on(BI.Editor.EVENT_CLICK, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_CLICK, arguments);
});
this.editor.on(BI.SignEditor.EVENT_CHANGE, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_CHANGE);
this.editor.on(BI.Editor.EVENT_CHANGE, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_CHANGE, arguments);
});
this.editor.on(BI.SignEditor.EVENT_KEY_DOWN, function (v) {
self.fireEvent(BI.SignInitialEditor.EVENT_KEY_DOWN);
this.editor.on(BI.Editor.EVENT_KEY_DOWN, function (v) {
self.fireEvent(BI.SignInitialEditor.EVENT_KEY_DOWN, arguments);
});
this.editor.on(BI.SignEditor.EVENT_VALID, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_VALID);
this.editor.on(BI.Editor.EVENT_VALID, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_VALID, arguments);
});
this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () {
self.setState(self.editor.getValue());
self.fireEvent(BI.SignInitialEditor.EVENT_CONFIRM);
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_START, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_START);
this.editor.on(BI.Editor.EVENT_START, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_START, arguments);
});
this.editor.on(BI.SignEditor.EVENT_PAUSE, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_PAUSE);
this.editor.on(BI.Editor.EVENT_PAUSE, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_PAUSE, arguments);
});
this.editor.on(BI.SignEditor.EVENT_STOP, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_STOP);
this.editor.on(BI.Editor.EVENT_STOP, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_STOP, arguments);
});
this.editor.on(BI.SignEditor.EVENT_SPACE, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_SPACE);
this.editor.on(BI.Editor.EVENT_SPACE, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_SPACE, arguments);
});
this.editor.on(BI.SignEditor.EVENT_ERROR, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_ERROR);
this.editor.on(BI.Editor.EVENT_ERROR, function () {
self._checkText();
self.fireEvent(BI.SignInitialEditor.EVENT_ERROR, arguments);
});
this.editor.on(BI.SignEditor.EVENT_ENTER, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_ENTER);
this.editor.on(BI.Editor.EVENT_ENTER, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_ENTER, arguments);
});
this.editor.on(BI.SignEditor.EVENT_RESTRICT, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_RESTRICT);
this.editor.on(BI.Editor.EVENT_RESTRICT, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_RESTRICT, arguments);
});
this.editor.on(BI.SignEditor.EVENT_EMPTY, function () {
self.fireEvent(BI.SignInitialEditor.EVENT_EMPTY);
this.editor.on(BI.Editor.EVENT_EMPTY, function () {
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 () {
this._showInput();
this.editor.focus();
},
blur: function () {
this.editor.blur();
this._showHint();
this._checkText();
},
isValid: function () {
return this.editor.isValid();
doRedMark: function () {
if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) {
return;
}
this.text.doRedMark.apply(this.text, arguments);
},
setTitle: function (title) {
this.editor.setTitle(title);
unRedMark: function () {
this.text.unRedMark.apply(this.text, arguments);
},
setWarningTitle: function (title) {
this.editor.setWarningTitle(title);
doHighLight: function () {
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) {
@ -132,9 +213,19 @@ BI.SignInitialEditor = BI.inherit(BI.Widget, {
return this.editor.getErrorText();
},
isEditing: function () {
return this.editor.isEditing();
},
getLastValidValue: function () {
return this.editor.getLastValidValue();
},
setValue: function (v) {
var o = this.options;
this.editor.setValue(v.value);
this.setState(v.value);
o.text = v.text || o.text;
this._checkText();
},
getValue: function () {
@ -145,13 +236,13 @@ BI.SignInitialEditor = BI.inherit(BI.Widget, {
},
getState: function () {
return this.editor.getState();
return this.text.getValue();
},
setState: function (v) {
var o = this.options;
this._showHint();
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";

Loading…
Cancel
Save