Browse Source

Merge branch 'es6' of ssh://code.fineres.com:7999/~zhenfei.li/fineui into es6

es6
Zhenfei.Li 2 years ago
parent
commit
ce500ccec1
  1. 64
      src/base/single/0.single.js
  2. 3
      src/base/single/button/node/texticonnode.js
  3. 4
      src/base/single/editor/editor.js
  4. 62
      src/base/single/iframe/iframe.js
  5. 42
      src/base/single/img/img.js
  6. 5
      src/base/single/index.js
  7. 89
      src/base/single/instruction/instruction.js
  8. 2
      src/base/single/label/html.label.js
  9. 2
      src/base/single/label/label.js
  10. 44
      src/base/single/link/link.js
  11. 2
      src/base/single/text.pure.js
  12. 23
      src/base/single/trigger/trigger.js

64
src/base/single/0.single.js

@ -5,12 +5,12 @@
* 2title的控制
* 3文字超过边界显示3个点
* 4cursor默认pointor
* @class BI.Single
* @extends BI.Widget
* @class Single
* @extends Widget
* @abstract
*/
import { Widget, shortcut } from "../../core";
import { Widget, shortcut, Actions, extend, isKey, isNotNull, isFunction, isPlainObject, isNull, delay } from "../../core";
import { Tooltips } from "../0.base";
@shortcut()
@ -20,7 +20,7 @@ export class Single extends Widget {
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
return BI.extend(conf, {
return extend(conf, {
readonly: false,
title: null,
warningTitle: null, // deprecated
@ -36,12 +36,12 @@ export class Single extends Widget {
const title = this.getTitle();
const showToolTip = (tooltipOpt) => {
if (BI.isKey(tooltipOpt.text) && !Tooltips.has(this.getName())) {
if (isKey(tooltipOpt.text) && !Tooltips.has(this.getName())) {
Tooltips.show(e, this.getName(), tooltipOpt, this, opt);
if (action) {
BI.Actions.runAction(action, "hover", this.options, this);
Actions.runAction(action, "hover", this.options, this);
}
BI.Actions.runGlobalAction("hover", this.options, this);
Actions.runGlobalAction("hover", this.options, this);
}
}
@ -59,7 +59,7 @@ export class Single extends Widget {
_hideTooltip() {
const tooltip = Tooltips.get(this.getName());
if (BI.isNotNull(tooltip)) {
if (isNotNull(tooltip)) {
tooltip.element.fadeOut(200, () => {
Tooltips.remove(this.getName());
});
@ -68,7 +68,7 @@ export class Single extends Widget {
_init() {
const { value } = this.options;
this.options.value = BI.isFunction(value) ? this.__watch(value, (context, newValue) => {
this.options.value = isFunction(value) ? this.__watch(value, (context, newValue) => {
this.setValue(newValue);
}) : value;
super._init(arguments);
@ -76,8 +76,8 @@ export class Single extends Widget {
_mounted() {
const { enableHover, title, warningTitle, belowMouse, container } = this.options;
if (enableHover || BI.isKey(title) || BI.isKey(warningTitle)
|| BI.isFunction(title) || BI.isFunction(warningTitle)) {
if (enableHover || isKey(title) || isKey(warningTitle)
|| isFunction(title) || isFunction(warningTitle)) {
this.enableHover({
belowMouse,
container,
@ -86,11 +86,11 @@ export class Single extends Widget {
}
_clearTimeOut() {
if (BI.isNotNull(this.showTimeout)) {
if (isNotNull(this.showTimeout)) {
clearTimeout(this.showTimeout);
this.showTimeout = null;
}
if (BI.isNotNull(this.hideTimeout)) {
if (isNotNull(this.hideTimeout)) {
clearTimeout(this.hideTimeout);
this.hideTimeout = null;
}
@ -99,12 +99,12 @@ export class Single extends Widget {
_getTooltipOptions(title) {
const { tipType } = this.options;
let tooltipOpt = {};
if (BI.isPlainObject(title)) {
if (isPlainObject(title)) {
tooltipOpt = title;
} else {
tooltipOpt.level = this.getTipType() || "success";
// 由于以前的用法,存在大量disabled:true搭配warningTitle的情况,所以这里做一个兼容,disabled:true的情况下,依然优先显示warningTitle,避免只设置了warningTitle而没有设置title的情况
if (BI.isNull(tipType) && !this.isEnabled()) {
if (isNull(tipType) && !this.isEnabled()) {
tooltipOpt.text = (this.getWarningTitle() || title);
} else {
tooltipOpt.text = tooltipOpt.level === "success" ? title : (this.getWarningTitle() || title);
@ -120,17 +120,17 @@ export class Single extends Widget {
this.element.unbind("mouseenter.title").on("mouseenter.title", (e) => {
this._e = e;
this.mouseOver = true;
if (this.getTipType() === "warning" || (BI.isKey(this.getWarningTitle()) && !this.isEnabled())) {
if (this.getTipType() === "warning" || (isKey(this.getWarningTitle()) && !this.isEnabled())) {
delayingTooltips = this.getName();
this.showTimeout = BI.delay(() => {
if (BI.isNotNull(this.showTimeout) && delayingTooltips === this.getName()) {
this.showTimeout = delay(() => {
if (isNotNull(this.showTimeout) && delayingTooltips === this.getName()) {
this._showToolTip(this._e || e, opt);
}
}, 200);
} else if (this.getTipType() === "success" || this.isEnabled()) {
delayingTooltips = this.getName();
this.showTimeout = BI.delay(() => {
if (BI.isNotNull(this.showTimeout) && delayingTooltips === this.getName()) {
this.showTimeout = delay(() => {
if (isNotNull(this.showTimeout) && delayingTooltips === this.getName()) {
this._showToolTip(this._e || e, opt);
}
}, 500);
@ -138,22 +138,22 @@ export class Single extends Widget {
});
this.element.unbind("mousemove.title").on("mousemove.title", (e) => {
this._e = e;
if (BI.isNotNull(this.showTimeout)) {
if (isNotNull(this.showTimeout)) {
clearTimeout(this.showTimeout);
this.showTimeout = null;
}
if (BI.isNull(this.hideTimeout)) {
this.hideTimeout = BI.delay(() => {
if (BI.isNotNull(this.hideTimeout)) {
if (isNull(this.hideTimeout)) {
this.hideTimeout = delay(() => {
if (isNotNull(this.hideTimeout)) {
this._hideTooltip();
}
}, 500);
}
this.showTimeout = BI.delay(() => {
this.showTimeout = delay(() => {
// DEC-5321 IE下如果回调已经进入事件队列,clearTimeout将不会起作用
if (BI.isNotNull(this.showTimeout)) {
if (BI.isNotNull(this.hideTimeout)) {
if (isNotNull(this.showTimeout)) {
if (isNotNull(this.hideTimeout)) {
clearTimeout(this.hideTimeout);
this.hideTimeout = null;
}
@ -188,7 +188,7 @@ export class Single extends Widget {
// opt: {container: '', belowMouse: false}
setTitle(title, opt) {
this.options.title = title;
if (BI.isKey(title) || BI.isFunction(title)) {
if (isKey(title) || isFunction(title)) {
this.enableHover(opt);
} else {
this.disabledHover();
@ -197,7 +197,7 @@ export class Single extends Widget {
setWarningTitle(title, opt) {
this.options.warningTitle = title;
if (BI.isKey(title) || BI.isFunction(title)) {
if (isKey(title) || isFunction(title)) {
this.enableHover(opt);
} else {
this.disabledHover();
@ -218,7 +218,7 @@ export class Single extends Widget {
getTitle() {
const title = this.options.title;
if (BI.isFunction(title)) {
if (isFunction(title)) {
return title();
}
@ -227,7 +227,7 @@ export class Single extends Widget {
getWarningTitle() {
const title = this.options.warningTitle;
if (BI.isFunction(title)) {
if (isFunction(title)) {
return title();
}
@ -246,7 +246,7 @@ export class Single extends Widget {
}
_destroyed() {
if (BI.isNotNull(this.showTimeout)) {
if (isNotNull(this.showTimeout)) {
clearTimeout(this.showTimeout);
this.showTimeout = null;
}

3
src/base/single/button/node/texticonnode.js

@ -7,7 +7,8 @@ import { extend, shortcut } from "../../../../core";
* @extends NodeButton
*/
@shortcut()
export default class TextIconNode extends NodeButton {
export class TextIconNode extends NodeButton {
static EVENT_CHANGE = "EVENT_CHANGE";
static xtype = "bi.text_icon_node";

4
src/base/single/editor/editor.js

@ -206,7 +206,7 @@ export class Editor extends Single {
_checkToolTip() {
const { errorText } = this.options;
if (isFunction(errorText)) {
errorText = errorText(this.editor.getValue());
this.options.errorText = errorText(this.editor.getValue());
}
if (isKey(errorText)) {
if (!this.isEnabled() || this.isValid() || Bubbles.has(this.getName())) {
@ -298,7 +298,7 @@ export class Editor extends Single {
_setErrorVisible(b) {
const { errorText, autoTrim, simple } = this.options;
if (isFunction(errorText)) {
errorText = errorText(autoTrim ? trim(this.editor.getValue()) : this.editor.getValue());
this.options.errorText = errorText(autoTrim ? trim(this.editor.getValue()) : this.editor.getValue());
}
if (!this.disabledError && isKey(errorText)) {
Bubbles[b ? "show" : "hide"](this.getName(), errorText, this, {

62
src/base/single/iframe/iframe.js

@ -1,14 +1,19 @@
/**
* @class BI.Iframe
* @extends BI.Single
* @class Iframe
* @extends Single
* @abstract
* Created by GameJian on 2016/3/2.
*/
BI.Iframe = BI.inherit(BI.Single, {
_defaultConfig: function (config) {
var conf = BI.Iframe.superclass._defaultConfig.apply(this, arguments);
import { shortcut, extend } from "../../../core";
import { Single } from "../0.single";
return BI.extend(conf, {
@shortcut()
export class Iframe extends Single {
static xtype = "bi.iframe";
_defaultConfig(config) {
const conf = super._defaultConfig(...arguments);
return extend(conf, {
tagName: "iframe",
baseCls: (conf.baseCls || "") + " bi-iframe",
src: "",
@ -17,42 +22,39 @@ BI.Iframe = BI.inherit(BI.Single, {
width: "100%",
height: "100%",
});
},
}
render: function () {
var self = this;
this.element.on("load", function () {
self.fireEvent("EVENT_LOADED");
render() {
this.element.on("load", () => {
this.fireEvent("EVENT_LOADED");
});
},
}
_initProps: function () {
BI.Iframe.superclass._initProps.apply(this, arguments);
var o = this.options;
this.options.attributes = BI.extend({
_initProps() {
super._initProps(...arguments)
const { src, name } = this.options;
this.options.attributes = extend({
frameborder: 0,
src: o.src,
name: o.name,
src,
name,
}, this.options.attributes);
},
}
setSrc: function (src) {
setSrc(src) {
this.options.src = src;
this.element.attr("src", src);
},
}
getSrc: function () {
getSrc() {
return this.options.src;
},
}
setName: function (name) {
setName(name) {
this.options.name = name;
this.element.attr("name", name);
},
}
getName: function () {
getName() {
return this.options.name;
},
});
BI.shortcut("bi.iframe", BI.Iframe);
}
}

42
src/base/single/img/img.js

@ -6,11 +6,17 @@
* @extends BI.Single
* @abstract
*/
BI.Img = BI.inherit(BI.Single, {
_defaultConfig: function (config) {
var conf = BI.Img.superclass._defaultConfig.apply(this, arguments);
import { shortcut, extend } from "../../../core";
import { Single } from "../0.single";
return BI.extend(conf, {
@shortcut()
export class Img extends Single {
static xtype = "bi.img";
_defaultConfig(config) {
const conf = super._defaultConfig(...arguments);
return extend(conf, {
tagName: "img",
baseCls: (conf.baseCls || "") + " bi-img display-block",
src: "",
@ -18,24 +24,22 @@ BI.Img = BI.inherit(BI.Single, {
width: "100%",
height: "100%",
});
},
}
_initProps: function () {
BI.Img.superclass._initProps.apply(this, arguments);
var o = this.options;
this.options.attributes = BI.extend({
src: o.src,
_initProps() {
super._initProps(...arguments)
const { src } = this.options;
this.options.attributes = extend({
src,
}, this.options.attributes);
},
setSrc: function (src) {
}
setSrc(src) {
this.options.src = src;
this.element.attr("src", src);
},
}
getSrc: function () {
getSrc() {
return this.options.src;
},
});
BI.shortcut("bi.img", BI.Img);
}
}

5
src/base/single/index.js

@ -4,6 +4,11 @@ export { PureText } from "./text.pure";
export { Icon } from "./icon/icon";
export { Html } from "./html/html";
export { A } from "./a/a";
export { Iframe } from "./iframe/iframe";
export { Link } from "./link/link";
export { Instruction } from "./instruction/instruction";
export { Img } from "./img/img";
export { Trigger } from "./trigger/trigger";
export * from "./tip";
export * from "./label";
export * from "./input";

89
src/base/single/instruction/instruction.js

@ -1,7 +1,12 @@
BI.Instruction = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.Link.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
import { shortcut, Widget, extend } from "../../../core";
@shortcut()
export class Instruction extends Widget {
static xtype = "bi.instruction";
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
return extend(conf, {
baseCls: (conf.baseCls || "") + " bi-instruction",
height: 20,
level: "error",
@ -9,68 +14,66 @@ BI.Instruction = BI.inherit(BI.Widget, {
whiteSpace: "nowrap",
hgap: 5
});
},
}
render: function () {
var self = this, o = this.options;
render() {
const { level, textAlign, whiteSpace, height, hgap, rgap, lgap, vgap, text, keyword, value, py } = this.options;
return {
type: "bi.label",
ref: function (_ref) {
self.text = _ref;
ref: (_ref) => {
this.text = _ref;
},
cls: "instruction-" + o.level,
textAlign: o.textAlign,
whiteSpace: o.whiteSpace,
textHeight: o.height,
height: o.height,
hgap: o.hgap,
rgap: o.rgap,
lgap: o.lgap,
vgap: o.vgap,
text: o.text,
keyword: o.keyword,
value: o.value,
py: o.py
cls: "instruction-" + level,
textAlign,
whiteSpace,
textHeight: height,
height,
hgap,
rgap,
lgap,
vgap,
text,
keyword,
value,
py
};
},
}
doRedMark: function () {
doRedMark() {
this.text.doRedMark.apply(this.text, arguments);
},
}
unRedMark: function () {
unRedMark() {
this.text.unRedMark.apply(this.text, arguments);
},
}
doHighLight: function () {
doHighLight() {
this.text.doHighLight.apply(this.text, arguments);
},
}
unHighLight: function () {
unHighLight() {
this.text.unHighLight.apply(this.text, arguments);
},
}
setText: function (v) {
setText(v) {
this.options.text = v;
this.text.setText(v);
},
}
getText: function () {
getText() {
return this.options.text;
},
}
setStyle: function (css) {
setStyle(css) {
this.text.setStyle(css);
},
}
setValue: function (v) {
setValue(v) {
this.text.setValue(v);
},
}
getValue: function () {
getValue() {
this.text.getValue();
}
});
BI.shortcut("bi.instruction", BI.Instruction);
}

2
src/base/single/label/html.label.js

@ -2,7 +2,7 @@
* Created by GUY on 2015/6/26.
*/
import { shortcut } from "../../../core";
import { AbstractLabel } from "./abstract.label"
import { AbstractLabel } from "./abstract.label";
@shortcut()
export class HtmlLabel extends AbstractLabel {

2
src/base/single/label/label.js

@ -2,7 +2,7 @@
* Created by GUY on 2015/6/26.
*/
import { shortcut, isFunction, isNotNull } from "../../../core";
import { AbstractLabel } from "./abstract.label"
import { AbstractLabel } from "./abstract.label";
@shortcut()
export class Label extends AbstractLabel {

44
src/base/single/link/link.js

@ -3,34 +3,38 @@
* @class BI.Link
* @extends BI.Text
*/
BI.Link = BI.inherit(BI.Label, {
_defaultConfig: function () {
var conf = BI.Link.superclass._defaultConfig.apply(this, arguments);
import { shortcut, extend } from "../../../core";
import { Label } from "../label/label";
return BI.extend(conf, {
@shortcut()
export class Link extends Label {
static xtype = "bi.link";
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
return extend(conf, {
baseCls: (conf.baseCls || "") + " bi-link display-block",
tagName: "a",
href: "",
target: "_blank",
});
},
}
_createJson: function () {
var o = this.options;
_createJson() {
const { textAlign, whiteSpace, textHeight, text, keyword, value, py, href, target } = this.options;
return {
type: "bi.a",
textAlign: o.textAlign,
whiteSpace: o.whiteSpace,
lineHeight: o.textHeight,
text: o.text,
keyword: o.keyword,
value: o.value,
py: o.py,
href: o.href,
target: o.target,
textAlign,
whiteSpace,
lineHeight: textHeight,
text,
keyword,
value,
py,
href,
target,
};
},
});
BI.shortcut("bi.link", BI.Link);
}
}

2
src/base/single/text.pure.js

@ -26,7 +26,7 @@ export class PureText extends Widget {
_getShowText() {
const { text: optionsText, value } = this.options;
const text = isFunction(optionsText) ? optionsText() : optionsText;
let text = isFunction(optionsText) ? optionsText() : optionsText;
text = isKey(text) ? text : value;
if (!isKey(text)) {
return "";

23
src/base/single/trigger/trigger.js

@ -4,21 +4,24 @@
* @extends BI.Single
* @abstract
*/
BI.Trigger = BI.inherit(BI.Single, {
_defaultConfig: function () {
var conf = BI.Trigger.superclass._defaultConfig.apply(this, arguments);
import { extend } from "../../../core";
import { Single } from "../0.single";
return BI.extend(conf, {
export class Trigger extends Single {
_defaultConfig() {
const conf = super._defaultConfig(...arguments);
return extend(conf, {
_baseCls: (conf._baseCls || "") + " bi-trigger cursor-pointer",
height: 24,
});
},
}
setKey: function () {
setKey() {
},
}
getKey: function () {
getKey() {
},
});
}
}

Loading…
Cancel
Save