Browse Source

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

* commit '3660ede288f477c8e10702c452eccf951dd44b1c':
  add
  富文本编辑器
  add
  富文本编辑器
  IE8
es6
guy 7 years ago
parent
commit
4b7be970aa
  1. 3
      bi/base.css
  2. 1841
      bi/base.js
  3. 21
      bi/case.js
  4. 2
      bi/core.js
  5. 2
      demo/js/base/editor/demo.rich_editor.js
  6. 3
      dist/base.css
  7. 1841
      dist/base.js
  8. 3
      dist/bundle.css
  9. 1858
      dist/bundle.js
  10. 2
      dist/bundle.min.css
  11. 58
      dist/bundle.min.js
  12. 21
      dist/case.js
  13. 2
      dist/core.js
  14. 2
      dist/demo.js
  15. 112
      dist/resource.css
  16. 1
      docs/base/button/button.md
  17. 1
      docs/base/label.md
  18. 1
      docs/base/toast.md
  19. 74
      src/base/richeditor/bar/button.richeditor.js
  20. 62
      src/base/richeditor/bar/texttoolbar.js
  21. 1325
      src/base/richeditor/nicEdit.js
  22. 324
      src/base/richeditor/niceditor/niceditor.js
  23. 52
      src/base/richeditor/plugins/backgroundchooser/trigger.backgroundchooser.js
  24. 38
      src/base/richeditor/plugins/button.align.center.js
  25. 38
      src/base/richeditor/plugins/button.align.left.js
  26. 38
      src/base/richeditor/plugins/button.align.right.js
  27. 41
      src/base/richeditor/plugins/button.bold.js
  28. 41
      src/base/richeditor/plugins/button.italic.js
  29. 41
      src/base/richeditor/plugins/button.underline.js
  30. 52
      src/base/richeditor/plugins/colorchooser/trigger.colorchooser.js
  31. 43
      src/base/richeditor/plugins/combo.backgroundcolorchooser.js
  32. 41
      src/base/richeditor/plugins/combo.colorchooser.js
  33. 76
      src/base/richeditor/plugins/combo.sizechooser.js
  34. 50
      src/base/richeditor/richeditor.js
  35. 13
      src/case/trigger/trigger.text.js
  36. 8
      src/case/trigger/trigger.text.small.js
  37. 2
      src/core/model.js
  38. 3
      src/css/base/richeditor/texttoolbar/texttoolbar.css
  39. 112
      src/css/resource/font.css
  40. 5
      src/less/base/richeditor/texttoolbar/alignchooser/texttoolbar.alignchooser.less
  41. 7
      src/less/base/richeditor/texttoolbar/texttoolbar.less
  42. 18
      src/less/resource/font.less

3
bi/base.css

@ -617,6 +617,9 @@ li.CodeMirror-hint-active {
.bi-direction-pager .direction-pager-next { .bi-direction-pager .direction-pager-next {
font-size: 16px; font-size: 16px;
} }
.bi-text-toolbar .text-toolbar-button {
font-size: 16px;
}
/****** common color(常用颜色,可用于普遍场景) *****/ /****** common color(常用颜色,可用于普遍场景) *****/
/**** custom color(自定义颜色,用于特定场景) ****/ /**** custom color(自定义颜色,用于特定场景) ****/
.bi-segment > .center-element { .bi-segment > .center-element {

1841
bi/base.js

File diff suppressed because it is too large Load Diff

21
bi/case.js

@ -12628,15 +12628,15 @@ BI.shortcut("bi.icon_text_trigger", BI.IconTextTrigger);/**
*/ */
BI.TextTrigger = BI.inherit(BI.Trigger, { BI.TextTrigger = BI.inherit(BI.Trigger, {
_const: { _const: {
hgap: 4, hgap: 4
triggerWidth: 30
}, },
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.TextTrigger.superclass._defaultConfig.apply(this, arguments); var conf = BI.TextTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-text-trigger", baseCls: (conf.baseCls || "") + " bi-text-trigger",
height: 30 height: 30,
triggerWidth: 30
}); });
}, },
@ -12648,12 +12648,13 @@ BI.TextTrigger = BI.inherit(BI.Trigger, {
textAlign: "left", textAlign: "left",
height: o.height, height: o.height,
text: o.text, text: o.text,
hgap: c.hgap hgap: c.hgap,
readonly: o.readonly
}); });
this.trigerButton = BI.createWidget({ this.trigerButton = BI.createWidget({
type: "bi.trigger_icon_button", type: "bi.trigger_icon_button",
cls: "bi-border-left", cls: "bi-border-left",
width: c.triggerWidth width: o.triggerWidth
}); });
BI.createWidget({ BI.createWidget({
@ -12664,7 +12665,7 @@ BI.TextTrigger = BI.inherit(BI.Trigger, {
el: this.text el: this.text
}, { }, {
el: this.trigerButton, el: this.trigerButton,
width: c.triggerWidth width: o.triggerWidth
} }
] ]
}); });
@ -12794,14 +12795,14 @@ BI.shortcut("bi.small_select_text_trigger", BI.SmallSelectTextTrigger);/**
BI.SmallTextTrigger = BI.inherit(BI.Trigger, { BI.SmallTextTrigger = BI.inherit(BI.Trigger, {
_const: { _const: {
hgap: 4, hgap: 4,
triggerWidth: 20
}, },
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.SmallTextTrigger.superclass._defaultConfig.apply(this, arguments); var conf = BI.SmallTextTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-text-trigger", baseCls: (conf.baseCls || "") + " bi-text-trigger",
height: 20 height: 20,
triggerWidth: 20
}); });
}, },
@ -12817,7 +12818,7 @@ BI.SmallTextTrigger = BI.inherit(BI.Trigger, {
}); });
this.trigerButton = BI.createWidget({ this.trigerButton = BI.createWidget({
type: "bi.trigger_icon_button", type: "bi.trigger_icon_button",
width: c.triggerWidth width: o.triggerWidth
}); });
BI.createWidget({ BI.createWidget({
@ -12828,7 +12829,7 @@ BI.SmallTextTrigger = BI.inherit(BI.Trigger, {
el: this.text el: this.text
}, { }, {
el: this.trigerButton, el: this.trigerButton,
width: c.triggerWidth width: o.triggerWidth
} }
] ]
}); });

2
bi/core.js

@ -5084,7 +5084,7 @@ BI.Widget = BI.inherit(BI.OB, {
return this.attributes[attr]; return this.attributes[attr];
} }
var sta = _.result(this, "_static"); var sta = _.result(this, "_static");
return BI.isFunction(sta[attr]) ? sta[attr].apply(this, BI.values(arguments).slice(1)) : sta[attr]; return BI.isFunction(sta[attr]) ? sta[attr].apply(this, Array.prototype.slice.apply(arguments, [1])) : sta[attr];
}, },
get: function () { get: function () {

2
demo/js/base/editor/demo.rich_editor.js

@ -13,7 +13,7 @@ Demo.RichEditor = BI.inherit(BI.Widget, {
type: "bi.vertical", type: "bi.vertical",
element: this, element: this,
hgap: 30, hgap: 30,
vgap: 20, vgap: 50,
items: [this.editor] items: [this.editor]
}) })
}, },

3
dist/base.css vendored

@ -617,6 +617,9 @@ li.CodeMirror-hint-active {
.bi-direction-pager .direction-pager-next { .bi-direction-pager .direction-pager-next {
font-size: 16px; font-size: 16px;
} }
.bi-text-toolbar .text-toolbar-button {
font-size: 16px;
}
/****** common color(常用颜色,可用于普遍场景) *****/ /****** common color(常用颜色,可用于普遍场景) *****/
/**** custom color(自定义颜色,用于特定场景) ****/ /**** custom color(自定义颜色,用于特定场景) ****/
.bi-segment > .center-element { .bi-segment > .center-element {

1841
dist/base.js vendored

File diff suppressed because it is too large Load Diff

3
dist/bundle.css vendored

@ -2197,6 +2197,9 @@ li.CodeMirror-hint-active {
.bi-direction-pager .direction-pager-next { .bi-direction-pager .direction-pager-next {
font-size: 16px; font-size: 16px;
} }
.bi-text-toolbar .text-toolbar-button {
font-size: 16px;
}
/****** common color(常用颜色,可用于普遍场景) *****/ /****** common color(常用颜色,可用于普遍场景) *****/
/**** custom color(自定义颜色,用于特定场景) ****/ /**** custom color(自定义颜色,用于特定场景) ****/
.bi-segment > .center-element { .bi-segment > .center-element {

1858
dist/bundle.js vendored

File diff suppressed because it is too large Load Diff

2
dist/bundle.min.css vendored

File diff suppressed because one or more lines are too long

58
dist/bundle.min.js vendored

File diff suppressed because one or more lines are too long

21
dist/case.js vendored

@ -12628,15 +12628,15 @@ BI.shortcut("bi.icon_text_trigger", BI.IconTextTrigger);/**
*/ */
BI.TextTrigger = BI.inherit(BI.Trigger, { BI.TextTrigger = BI.inherit(BI.Trigger, {
_const: { _const: {
hgap: 4, hgap: 4
triggerWidth: 30
}, },
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.TextTrigger.superclass._defaultConfig.apply(this, arguments); var conf = BI.TextTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-text-trigger", baseCls: (conf.baseCls || "") + " bi-text-trigger",
height: 30 height: 30,
triggerWidth: 30
}); });
}, },
@ -12648,12 +12648,13 @@ BI.TextTrigger = BI.inherit(BI.Trigger, {
textAlign: "left", textAlign: "left",
height: o.height, height: o.height,
text: o.text, text: o.text,
hgap: c.hgap hgap: c.hgap,
readonly: o.readonly
}); });
this.trigerButton = BI.createWidget({ this.trigerButton = BI.createWidget({
type: "bi.trigger_icon_button", type: "bi.trigger_icon_button",
cls: "bi-border-left", cls: "bi-border-left",
width: c.triggerWidth width: o.triggerWidth
}); });
BI.createWidget({ BI.createWidget({
@ -12664,7 +12665,7 @@ BI.TextTrigger = BI.inherit(BI.Trigger, {
el: this.text el: this.text
}, { }, {
el: this.trigerButton, el: this.trigerButton,
width: c.triggerWidth width: o.triggerWidth
} }
] ]
}); });
@ -12794,14 +12795,14 @@ BI.shortcut("bi.small_select_text_trigger", BI.SmallSelectTextTrigger);/**
BI.SmallTextTrigger = BI.inherit(BI.Trigger, { BI.SmallTextTrigger = BI.inherit(BI.Trigger, {
_const: { _const: {
hgap: 4, hgap: 4,
triggerWidth: 20
}, },
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.SmallTextTrigger.superclass._defaultConfig.apply(this, arguments); var conf = BI.SmallTextTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-text-trigger", baseCls: (conf.baseCls || "") + " bi-text-trigger",
height: 20 height: 20,
triggerWidth: 20
}); });
}, },
@ -12817,7 +12818,7 @@ BI.SmallTextTrigger = BI.inherit(BI.Trigger, {
}); });
this.trigerButton = BI.createWidget({ this.trigerButton = BI.createWidget({
type: "bi.trigger_icon_button", type: "bi.trigger_icon_button",
width: c.triggerWidth width: o.triggerWidth
}); });
BI.createWidget({ BI.createWidget({
@ -12828,7 +12829,7 @@ BI.SmallTextTrigger = BI.inherit(BI.Trigger, {
el: this.text el: this.text
}, { }, {
el: this.trigerButton, el: this.trigerButton,
width: c.triggerWidth width: o.triggerWidth
} }
] ]
}); });

2
dist/core.js vendored

@ -15073,7 +15073,7 @@ BI.Widget = BI.inherit(BI.OB, {
return this.attributes[attr]; return this.attributes[attr];
} }
var sta = _.result(this, "_static"); var sta = _.result(this, "_static");
return BI.isFunction(sta[attr]) ? sta[attr].apply(this, BI.values(arguments).slice(1)) : sta[attr]; return BI.isFunction(sta[attr]) ? sta[attr].apply(this, Array.prototype.slice.apply(arguments, [1])) : sta[attr];
}, },
get: function () { get: function () {

2
dist/demo.js vendored

@ -824,7 +824,7 @@ BI.shortcut("demo.multifile_editor", Demo.CodeEditor);Demo.RichEditor = BI.inher
type: "bi.vertical", type: "bi.vertical",
element: this, element: this,
hgap: 30, hgap: 30,
vgap: 20, vgap: 50,
items: [this.editor] items: [this.editor]
}) })
}, },

112
dist/resource.css vendored

@ -138,6 +138,10 @@ textarea::-webkit-scrollbar-thumb:hover {
/* iOS 4.1- */ /* iOS 4.1- */
} }
@font-face {
font-family: 'bi';
src: url('font/iconfont.eot') /* IE6-IE8 */;
}
.b-font { .b-font {
font-family: "bi"; font-family: "bi";
font-style: normal; font-style: normal;
@ -864,6 +868,114 @@ textarea::-webkit-scrollbar-thumb:hover {
content: "\e636"; content: "\e636";
color: inherit; color: inherit;
} }
.text-bold-font .b-font {
*zoom: expression( this.runtimeStyle['zoom'] = '1',this.innerHTML = '');
}
.text-bold-font .b-font:before {
content: "\e64d";
color: inherit;
}
.text-bold-font.native .b-font:before,
.text-bold-font.disabled .b-font:before {
content: "\e64d";
color: inherit;
}
.text-italic-font .b-font {
*zoom: expression( this.runtimeStyle['zoom'] = '1',this.innerHTML = '');
}
.text-italic-font .b-font:before {
content: "\e656";
color: inherit;
}
.text-italic-font.native .b-font:before,
.text-italic-font.disabled .b-font:before {
content: "\e656";
color: inherit;
}
.text-underline-font .b-font {
*zoom: expression( this.runtimeStyle['zoom'] = '1',this.innerHTML = '');
}
.text-underline-font .b-font:before {
content: "\e650";
color: inherit;
}
.text-underline-font.native .b-font:before,
.text-underline-font.disabled .b-font:before {
content: "\e650";
color: inherit;
}
.text-color-font .b-font {
*zoom: expression( this.runtimeStyle['zoom'] = '1',this.innerHTML = '');
}
.text-color-font .b-font:before {
content: "\e69c";
color: inherit;
}
.text-color-font.native .b-font:before,
.text-color-font.disabled .b-font:before {
content: "\e69c";
color: inherit;
}
.text-background-font .b-font {
*zoom: expression( this.runtimeStyle['zoom'] = '1',this.innerHTML = '');
}
.text-background-font .b-font:before {
content: "\e696";
color: inherit;
}
.text-background-font.native .b-font:before,
.text-background-font.disabled .b-font:before {
content: "\e696";
color: inherit;
}
.text-color-underline-font .b-font {
*zoom: expression( this.runtimeStyle['zoom'] = '1',this.innerHTML = '');
}
.text-color-underline-font .b-font:before {
content: "\e69d";
color: inherit;
}
.text-color-underline-font.native .b-font:before,
.text-color-underline-font.disabled .b-font:before {
content: "\e69d";
color: inherit;
}
.text-align-left-font .b-font {
*zoom: expression( this.runtimeStyle['zoom'] = '1',this.innerHTML = '');
}
.text-align-left-font .b-font:before {
content: "\e654";
color: inherit;
}
.text-align-left-font.native .b-font:before,
.text-align-left-font.disabled .b-font:before {
content: "\e654";
color: inherit;
}
.text-align-center-font .b-font {
*zoom: expression( this.runtimeStyle['zoom'] = '1',this.innerHTML = '');
}
.text-align-center-font .b-font:before {
content: "\e64f";
color: inherit;
}
.text-align-center-font.native .b-font:before,
.text-align-center-font.disabled .b-font:before {
content: "\e64f";
color: inherit;
}
.text-align-right-font .b-font {
*zoom: expression( this.runtimeStyle['zoom'] = '1',this.innerHTML = '');
}
.text-align-right-font .b-font:before {
content: "\e651";
color: inherit;
}
.text-align-right-font.native .b-font:before,
.text-align-right-font.disabled .b-font:before {
content: "\e651";
color: inherit;
}
.tree-collapse-icon-type1 .x-icon, .tree-collapse-icon-type1 .x-icon,
.tree-collapse-icon-type1:hover .x-icon, .tree-collapse-icon-type1:hover .x-icon,
.tree-collapse-icon-type1:active .x-icon { .tree-collapse-icon-type1:active .x-icon {

1
docs/base/button/button.md

@ -31,7 +31,6 @@ BI.createWidget({
| rgap | 效果相当于文本框right-padding值 | number | — | 0 | | rgap | 效果相当于文本框right-padding值 | number | — | 0 |
| tgap |效果相当于文本框top-padding值 | number | — | 0 | | tgap |效果相当于文本框top-padding值 | number | — | 0 |
| bgap | 效果相当于文本框bottom-padding值 | number | — | 0 | | bgap | 效果相当于文本框bottom-padding值 | number | — | 0 |
| items | 子控件数组 | array | — | [ ] |
| width | 宽度 | number | — | — | | width | 宽度 | number | — | — |
| height | 高度 | number | — | — | | height | 高度 | number | — | — |

1
docs/base/label.md

@ -61,7 +61,6 @@ BI.createWidget({
| getText| 获取文本值 | —| | getText| 获取文本值 | —|
| setStyle | 设置文本样式 |需要设置的文本标签样式,例{"color":"#000"} | | setStyle | 设置文本样式 |需要设置的文本标签样式,例{"color":"#000"} |
| setValue | 设置文本值 | 需要设置的文本值text | | setValue | 设置文本值 | 需要设置的文本值text |
| populate| 清空label | —|
--- ---

1
docs/base/toast.md

@ -37,6 +37,5 @@ BI.createWidget({
| 名称 | 说明 | 回调参数 | 名称 | 说明 | 回调参数
| :------ |:------------- | :----- | :------ |:------------- | :-----
| setText | 设置文本值 | 需要设置的文本值text | | setText | 设置文本值 | 需要设置的文本值text |
| setHeight | 设置高度 | 需要设置的高度值height |
--- ---

74
src/base/richeditor/bar/button.richeditor.js

@ -0,0 +1,74 @@
/**
* 颜色选择
*
* Created by GUY on 2015/11/26.
* @class BI.TextToolbar
* @extends BI.Widget
*/
BI.RichEditorAction = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorAction.superclass._defaultConfig.apply(this, arguments), {
width: 20,
height: 20,
command: "",
disabled: true
});
},
_init: function () {
BI.RichEditorAction.superclass._init.apply(this, arguments);
var self = this, o = this.options;
o.editor.on(BI.NicEditor.EVENT_SELECTED, function (ins, target) {
self.setEnable(true);
self.checkNodes(target);
});
o.editor.on(BI.NicEditor.EVENT_BLUR, function () {
self.setEnable(false);
});
o.editor.on(BI.NicEditor.EVENT_KEY, BI.bind(this.key, this));
},
checkNodes: function (e) {
if (!e) {
return false;
}
var elm = e;
do {
if (this.options.tags && this.options.tags.contains(elm.nodeName)) {
this.activate();
return true;
}
} while (elm = elm.parentNode && elm.className && elm.className.indexOf("bi-nic-editor") >= -1);
elm = e;
while (elm.nodeType == 3) {
elm = elm.parentNode;
}
if (this.options.css) {
for (var itm in this.options.css) {
if ($(elm).css(itm) == this.options.css[itm]) {
this.activate();
return true;
}
}
}
this.deactivate();
return false;
},
key: function () {
},
activate: function () {
},
deactivate: function () {
},
doCommand: function (args) {
if (this.options.command) {
this.options.editor.nicCommand(this.options.command, args);
}
this.options.editor.fireEvent("buttonClick", this);
}
});

62
src/base/richeditor/bar/texttoolbar.js

@ -0,0 +1,62 @@
/**
* 颜色选择
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorTextToolbar
* @extends BI.Widget
*/
BI.RichEditorTextToolbar = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorTextToolbar.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-text-toolbar bi-background",
buttons: [
{type: "bi.rich_editor_size_chooser"},
{type: "bi.rich_editor_bold_button"},
{type: "bi.rich_editor_italic_button"},
{type: "bi.rich_editor_underline_button"},
{type: "bi.rich_editor_color_chooser"},
{type: "bi.rich_editor_background_color_chooser"},
{type: "bi.rich_editor_align_left_button"},
{type: "bi.rich_editor_align_center_button"},
{type: "bi.rich_editor_align_right_button"},
],
height: 28
});
},
_init: function () {
BI.RichEditorTextToolbar.superclass._init.apply(this, arguments);
var self = this, o = this.options;
BI.createWidget({
type: "bi.left",
element: this,
items: BI.map(o.buttons, function (i, btn) {
return BI.extend(btn, {
editor: o.editor
});
}),
hgap: 3,
vgap: 3
})
},
mounted: function () {
var self = this;
if (BI.isIE9Below()) {//IE8下必须要设置unselectable才能不blur输入框
this.element.mousedown(function () {
self._noSelect(self.element[0]);
});
this._noSelect(this.element[0]);
}
},
_noSelect: function (element) {
if (element.setAttribute && element.nodeName.toLowerCase() != 'input' && element.nodeName.toLowerCase() != 'textarea') {
element.setAttribute('unselectable', 'on');
}
for (var i = 0; i < element.childNodes.length; i++) {
this._noSelect(element.childNodes[i]);
}
}
});
BI.shortcut('bi.rich_editor_text_toolbar', BI.RichEditorTextToolbar);

1325
src/base/richeditor/nicEdit.js

File diff suppressed because it is too large Load Diff

324
src/base/richeditor/niceditor/niceditor.js

@ -0,0 +1,324 @@
/**
* 富文本编辑器
*
* Created by GUY on 2017/9/15.
* @class BI.NicEditor
* @extends BI.Widget
*/
!(function () {
BI.NicEditor = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.NicEditor.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-nic-editor"
});
},
_init: function () {
BI.NicEditor.superclass._init.apply(this, arguments);
var o = this.options;
$(document.body).mousedown(BI.bind(this.selectCheck, this));
BI.createWidget({
type: "bi.vertical",
element: this,
items: [{
type: "bi.layout",
height: 1
}, this.instance = this.addInstance()]
})
},
addInstance: function () {
var o = this.options;
var conf = {
ne: this,
height: o.height - 1,
maxHeight: o.maxHeight ? o.maxHeight : null
};
if (this.element[0].contentEditable || !!window.opera) {
var newInstance = new nicEditorInstance(conf);
} else {
var newInstance = new nicEditorIFrameInstance(conf);
}
return newInstance;
},
nicCommand: function (cmd, args) {
if (this.selectedInstance) {
this.selectedInstance.nicCommand(cmd, args);
}
},
selectCheck: function (e) {
var t = e.target;
var found = false;
do {
if (t.className && t.className.indexOf(prefix) != -1) {
return;
// return false;
}
} while (t = t.parentNode);
this.fireEvent('blur', this.selectedInstance, t);
this.lastSelectedInstance = this.selectedInstance;
this.selectedInstance = null;
// return false;
},
setValue: function (v) {
this.instance.setContent(v);
},
getValue: function () {
return this.instance.getContent();
}
});
BI.NicEditor.EVENT_SELECTED = "selected";
BI.NicEditor.EVENT_BLUR = "blur";
BI.NicEditor.EVENT_KEY = "key";
BI.shortcut('bi.nic_editor', BI.NicEditor);
var prefix = "niceditor-";
var nicEditorInstance = BI.inherit(BI.Layout, {
isSelected: false,
_init: function () {
nicEditorInstance.superclass._init.apply(this, arguments);
var o = this.options;
this.ne = this.options.ne;
this.elm = BI.createWidget({
type: "bi.layout",
width: o.width - 8,
scrollable: false
});
this.elm.element.css({
margin: "4px",
minHeight: (o.height - 8) + "px",
outline: "none"
}).html(o.value);
this.element.css("maxHeight", (o.maxHeight) ? o.maxHeight + 'px' : null);
this.e = BI.createWidget({
type: "bi.layout",
invisible: true,
tagName: "textarea"
});
BI.createWidget({
type: "bi.default",
element: this,
scrolly: true,
items: [this.elm, this.e]
});
this.ne.on("blur", BI.bind(this.blur, this));
this.start();
this.blur();
},
start: function () {
this.elm.element.attr("contentEditable", true);
if (this.getContent() == "") {
this.setContent("<br />");
}
this.instanceDoc = document.defaultView;
this.elm.element.on('mousedown', BI.bind(this.selected, this));
this.elm.element.on('keypress', BI.bind(this.keyDown, this));
this.elm.element.on('focus', BI.bind(this.selected, this));
this.elm.element.on('blur', BI.bind(this.blur, this));
this.elm.element.on('keyup', BI.bind(this.selected, this));
this.ne.fireEvent('add', this);
},
disable: function () {
this.elm.element.attr("contentEditable", false);
},
getSel: function () {
return (window.getSelection) ? window.getSelection() : document.selection;
},
getRng: function () {
var s = this.getSel();
if (!s || s.rangeCount === 0) {
return;
}
return (s.rangeCount > 0) ? s.getRangeAt(0) : s.createRange();
},
selRng: function (rng, s) {
if (window.getSelection) {
s.removeAllRanges();
s.addRange(rng);
} else {
rng.select();
}
},
selElm: function () {
var r = this.getRng();
if (!r) {
return;
}
if (r.startContainer) {
var contain = r.startContainer;
if (r.cloneContents().childNodes.length == 1) {
for (var i = 0; i < contain.childNodes.length; i++) {
var rng = contain.childNodes[i].ownerDocument.createRange();
rng.selectNode(contain.childNodes[i]);
if (r.compareBoundaryPoints(Range.START_TO_START, rng) != 1 &&
r.compareBoundaryPoints(Range.END_TO_END, rng) != -1) {
return contain.childNodes[i];
}
}
}
return contain;
} else {
return (this.getSel().type == "Control") ? r.item(0) : r.parentElement();
}
},
saveRng: function () {
this.savedRange = this.getRng();
this.savedSel = this.getSel();
},
restoreRng: function () {
if (this.savedRange) {
this.selRng(this.savedRange, this.savedSel);
}
},
keyDown: function (e, t) {
if (e.ctrlKey) {
this.ne.fireEvent('key', this, e);
}
},
selected: function (e) {
var t = e.target;
if (!t && !(t = this.selElm())) {
t = this.selElm();
}
if (!e.ctrlKey) {
var selInstance = this.ne.selectedInstance;
if (selInstance != this) {
if (selInstance) {
this.ne.fireEvent('blur', selInstance, t);
}
this.ne.selectedInstance = this;
this.ne.fireEvent('focus', selInstance, t);
}
this.ne.fireEvent('selected', selInstance, t);
this.isFocused = true;
this.elm.element.addClass(prefix + 'selected');
}
// return false;
},
blur: function () {
this.isFocused = false;
this.elm.element.removeClass(prefix + 'selected');
},
saveContent: function () {
this.ne.fireEvent('save', this);
this.e.element.value(this.getContent());
},
getElm: function () {
return this.elm;
},
getContent: function () {
this.content = this.getElm().element.html();
this.ne.fireEvent('get', this);
return this.content;
},
setContent: function (e) {
this.content = e;
this.ne.fireEvent('set', this);
this.elm.element.html(this.content);
},
nicCommand: function (cmd, args) {
document.execCommand(cmd, false, args);
}
});
var nicEditorIFrameInstance = BI.inherit(nicEditorInstance, {
savedStyles: [],
start: function () {
var o = this.options;
var c = this.elm.element.html().replace(/^\s+|\s+$/g, '');
this.elm.element.html("");
(!c) ? c = "<br />" : c;
this.initialContent = c;
this.elmFrame = $('iframe').attr({
'src': 'javascript:;',
'frameBorder': 0,
'allowTransparency': 'true',
'scrolling': 'no'
}).css({height: '100px', width: '100%'}).addClass(prefix + 'frame').appendTo(this.elm.element);
this.elmFrame.css({width: (o.width - 4) + 'px'});
var styleList = ['font-size', 'font-family', 'font-weight', 'color'];
for (var item in styleList) {
this.savedStyles[BI.camelize(item)] = this.elm.element.css(item);
}
setTimeout(BI.bind(this.initFrame, this), 50);
},
disable: function () {
this.elm.element.html(this.getContent());
},
initFrame: function () {
var fd = $(this.elmFrame.contentWindow.document)[0];
fd.designMode = "on";
fd.open();
var css = this.ne.options.externalCSS;
fd.write('<html><head>' + ((css) ? '<link href="' + css + '" rel="stylesheet" type="text/css" />' : '') + '</head><body id="nicEditContent" style="margin: 0 !important; background-color: transparent !important;">' + this.initialContent + '</body></html>');
fd.close();
this.frameDoc = $(fd);
this.frameWin = $(this.elmFrame[0].contentWindow);
this.frameContent = $(this.frameWin[0].document.body).css(this.savedStyles);
this.instanceDoc = this.frameWin[0].document.defaultView;
this.heightUpdate();
this.frameDoc.on('mousedown', BI.bind(this.selected, this));
this.frameDoc.on('keyup', BI.bind(this.heightUpdate, this));
this.frameDoc.on('keydown', BI.bind(this.keyDown, this));
this.frameDoc.on('keyup', BI.bind(this.selected, this));
this.ne.fireEvent('add', this);
},
getElm: function () {
return this.frameContent;
},
setContent: function (c) {
this.content = c;
this.ne.fireEvent('set', this);
this.frameContent.html(this.content);
this.heightUpdate();
},
getSel: function () {
return (this.frameWin[0]) ? this.frameWin[0].getSelection() : this.frameDoc[0].selection;
},
heightUpdate: function () {
this.elmFrame[0].style.height = Math.max(this.frameContent[0].offsetHeight, this.options.height - 8) + 'px';
},
nicCommand: function (cmd, args) {
this.frameDoc.execCommand(cmd, false, args);
setTimeout(BI.bind(this.heightUpdate, this), 100);
}
})
}());

52
src/base/richeditor/plugins/backgroundchooser/trigger.backgroundchooser.js

@ -0,0 +1,52 @@
/**
* 颜色选择trigger
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorBackgroundChooserTrigger
* @extends BI.Widget
*/
BI.RichEditorBackgroundChooserTrigger = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.RichEditorBackgroundChooserTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
width: 20,
height: 20
});
},
_init: function () {
BI.RichEditorBackgroundChooserTrigger.superclass._init.apply(this, arguments);
this.font = BI.createWidget({
type: "bi.icon_button",
cls: "text-background-font"
});
this.underline = BI.createWidget({
type: "bi.icon_button",
cls: "text-color-underline-font"
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.font,
top: 2,
left: 2
}, {
el: this.underline,
top: 7,
left: 2
}]
})
},
setValue: function (color) {
this.underline.element.css("color", color);
},
getValue: function () {
return this.font.element.css("color");
}
});
BI.shortcut('bi.rich_editor_background_color_chooser_trigger', BI.RichEditorBackgroundChooserTrigger);

38
src/base/richeditor/plugins/button.align.center.js

@ -0,0 +1,38 @@
/**
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorAlignCenterButton
* @extends BI.RichEditorAction
*/
BI.RichEditorAlignCenterButton = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorAlignCenterButton.superclass._defaultConfig.apply(this, arguments), {
width: 20,
height: 20,
command: "justifycenter"
});
},
_init: function () {
BI.RichEditorAlignCenterButton.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.align = BI.createWidget({
type: "bi.icon_button",
element: this,
forceNotSelected: true,
title: BI.i18nText("BI-Word_Align_Center"),
height: 20,
width: 20,
cls: "text-toolbar-button bi-list-item-active text-align-center-font",
});
this.align.on(BI.IconButton.EVENT_CHANGE, function () {
self.doCommand();
});
},
activate: function () {
},
deactivate: function () {
}
});
BI.shortcut("bi.rich_editor_align_center_button", BI.RichEditorAlignCenterButton)

38
src/base/richeditor/plugins/button.align.left.js

@ -0,0 +1,38 @@
/**
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorAlignLeftButton
* @extends BI.RichEditorAction
*/
BI.RichEditorAlignLeftButton = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorAlignLeftButton.superclass._defaultConfig.apply(this, arguments), {
width: 20,
height: 20,
command: "justifyleft"
});
},
_init: function () {
BI.RichEditorAlignLeftButton.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.align = BI.createWidget({
type: "bi.icon_button",
element: this,
forceNotSelected: true,
title: BI.i18nText("BI-Word_Align_Left"),
height: 20,
width: 20,
cls: "text-toolbar-button bi-list-item-active text-align-left-font",
});
this.align.on(BI.IconButton.EVENT_CHANGE, function () {
self.doCommand();
});
},
activate: function () {
},
deactivate: function () {
}
});
BI.shortcut("bi.rich_editor_align_left_button", BI.RichEditorAlignLeftButton)

38
src/base/richeditor/plugins/button.align.right.js

@ -0,0 +1,38 @@
/**
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorAlignRightButton
* @extends BI.RichEditorAction
*/
BI.RichEditorAlignRightButton = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorAlignRightButton.superclass._defaultConfig.apply(this, arguments), {
width: 20,
height: 20,
command: "justifyright"
});
},
_init: function () {
BI.RichEditorAlignRightButton.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.align = BI.createWidget({
type: "bi.icon_button",
element: this,
forceNotSelected: true,
title: BI.i18nText("BI-Word_Align_Right"),
height: 20,
width: 20,
cls: "text-toolbar-button bi-list-item-active text-align-right-font",
});
this.align.on(BI.IconButton.EVENT_CHANGE, function () {
self.doCommand();
});
},
activate: function () {
},
deactivate: function () {
}
});
BI.shortcut("bi.rich_editor_align_right_button", BI.RichEditorAlignRightButton)

41
src/base/richeditor/plugins/button.bold.js

@ -0,0 +1,41 @@
/**
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorBoldButton
* @extends BI.RichEditorAction
*/
BI.RichEditorBoldButton = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorBoldButton.superclass._defaultConfig.apply(this, arguments), {
width: 20,
height: 20,
command: "Bold",
tags: ["B", "STRONG"],
css: {fontWeight: "bold"}
});
},
_init: function () {
BI.RichEditorBoldButton.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.bold = BI.createWidget({
type: "bi.icon_button",
element: this,
title: BI.i18nText("BI-Basic_Bold"),
height: 20,
width: 20,
cls: "text-toolbar-button bi-list-item-active text-bold-font",
});
this.bold.on(BI.IconButton.EVENT_CHANGE, function () {
self.doCommand();
});
},
activate: function () {
this.bold.setSelected(true);
},
deactivate: function () {
this.bold.setSelected(false);
},
});
BI.shortcut("bi.rich_editor_bold_button", BI.RichEditorBoldButton)

41
src/base/richeditor/plugins/button.italic.js

@ -0,0 +1,41 @@
/**
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorItalicButton
* @extends BI.RichEditorAction
*/
BI.RichEditorItalicButton = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorItalicButton.superclass._defaultConfig.apply(this, arguments), {
width: 20,
height: 20,
command: "Italic",
tags: ["EM", "I"],
css: {fontStyle: "italic"}
});
},
_init: function () {
BI.RichEditorItalicButton.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.italic = BI.createWidget({
type: "bi.icon_button",
element: this,
title: BI.i18nText("BI-Basic_Italic"),
height: 20,
width: 20,
cls: "text-toolbar-button bi-list-item-active text-italic-font",
});
this.italic.on(BI.IconButton.EVENT_CHANGE, function () {
self.doCommand();
});
},
activate: function () {
this.italic.setSelected(true);
},
deactivate: function () {
this.italic.setSelected(false);
},
});
BI.shortcut("bi.rich_editor_italic_button", BI.RichEditorItalicButton)

41
src/base/richeditor/plugins/button.underline.js

@ -0,0 +1,41 @@
/**
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorItalicButton
* @extends BI.RichEditorAction
*/
BI.RichEditorUnderlineButton = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorUnderlineButton.superclass._defaultConfig.apply(this, arguments), {
width: 20,
height: 20,
command: "Underline",
tags: ["U"],
css: {textDecoration: "underline"}
});
},
_init: function () {
BI.RichEditorUnderlineButton.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.underline = BI.createWidget({
type: "bi.icon_button",
element: this,
title: BI.i18nText("BI-Basic_Underline"),
height: 20,
width: 20,
cls: "text-toolbar-button bi-list-item-active text-underline-font",
});
this.underline.on(BI.IconButton.EVENT_CHANGE, function () {
self.doCommand();
});
},
activate: function () {
this.underline.setSelected(true);
},
deactivate: function () {
this.underline.setSelected(false);
},
});
BI.shortcut("bi.rich_editor_underline_button", BI.RichEditorUnderlineButton)

52
src/base/richeditor/plugins/colorchooser/trigger.colorchooser.js

@ -0,0 +1,52 @@
/**
* 颜色选择trigger
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorColorChooserTrigger
* @extends BI.Widget
*/
BI.RichEditorColorChooserTrigger = BI.inherit(BI.Widget, {
_defaultConfig: function () {
var conf = BI.RichEditorColorChooserTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, {
width: 20,
height: 20
});
},
_init: function () {
BI.RichEditorColorChooserTrigger.superclass._init.apply(this, arguments);
this.font = BI.createWidget({
type: "bi.icon_button",
cls: "text-color-font"
});
this.underline = BI.createWidget({
type: "bi.icon_button",
cls: "text-color-underline-font"
});
BI.createWidget({
type: "bi.absolute",
element: this,
items: [{
el: this.font,
top: 2,
left: 2
}, {
el: this.underline,
top: 7,
left: 2
}]
})
},
setValue: function (color) {
this.underline.element.css("color", color);
},
getValue: function () {
return this.font.element.css("color");
}
});
BI.shortcut('bi.rich_editor_color_chooser_trigger', BI.RichEditorColorChooserTrigger);

43
src/base/richeditor/plugins/combo.backgroundcolorchooser.js

@ -0,0 +1,43 @@
/**
* 颜色选择
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorBackgroundColorChooser
* @extends BI.RichEditorAction
*/
BI.RichEditorBackgroundColorChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorBackgroundColorChooser.superclass._defaultConfig.apply(this, arguments), {
width: 20,
height: 20,
});
},
_init: function () {
BI.RichEditorBackgroundColorChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.colorchooser = BI.createWidget({
type: "bi.color_chooser",
element: this,
width: o.width,
height: o.height,
el: {
type: "bi.rich_editor_background_color_chooser_trigger",
title: BI.i18nText("BI-Widget_Background_Colour"),
cls: "text-toolbar-button"
}
});
this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () {
var backgroundColor = this.getValue();
o.editor.element.css({
backgroundColor: backgroundColor,
color: BI.DOM.getContrastColor(backgroundColor)
});
this.setValue("");
});
},
deactivate: function () {
}
});
BI.shortcut('bi.rich_editor_background_color_chooser', BI.RichEditorBackgroundColorChooser);

41
src/base/richeditor/plugins/combo.colorchooser.js

@ -0,0 +1,41 @@
/**
* 颜色选择
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorColorChooser
* @extends BI.RichEditorAction
*/
BI.RichEditorColorChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorColorChooser.superclass._defaultConfig.apply(this, arguments), {
width: 20,
height: 20,
command: "foreColor"
});
},
_init: function () {
BI.RichEditorColorChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.colorchooser = BI.createWidget({
type: "bi.color_chooser",
element: this,
width: o.width,
height: o.height,
el: {
type: "bi.rich_editor_color_chooser_trigger",
title: BI.i18nText("BI-Font_Colour"),
cls: "text-toolbar-button"
}
});
this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () {
self.doCommand(this.getValue());
});
},
deactivate: function () {
this.colorchooser.setValue("");
}
});
BI.shortcut('bi.rich_editor_color_chooser', BI.RichEditorColorChooser);

76
src/base/richeditor/plugins/combo.sizechooser.js

@ -0,0 +1,76 @@
/**
* 字体大小选择
*
* Created by GUY on 2015/11/26.
* @class BI.RichEditorSizeChooser
* @extends BI.RichEditorAction
*/
BI.RichEditorSizeChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () {
return BI.extend(BI.RichEditorSizeChooser.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-rich-editor-size-chooser bi-border bi-card",
command: "FontSize",
width: 50,
height: 20
});
},
_items: [{
value: 1,
text: "1(8pt)"
}, {
value: 2,
text: "2(10pt)"
}, {
value: 3,
text: "3(12pt)"
}, {
value: 4,
text: "4(14pt)"
}, {
value: 5,
text: "5(18pt)"
}, {
value: 6,
text: "6(24pt)"
}],
_init: function () {
BI.RichEditorSizeChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.trigger = BI.createWidget({
type: "bi.text_trigger",
readonly: true,
height: o.height,
triggerWidth: 12,
text: BI.i18nText("BI-Font_Size")
});
this.combo = BI.createWidget({
type: "bi.combo",
element: this,
el: this.trigger,
adjustLength: 1,
popup: {
maxWidth: o.width,
minWidth: o.width,
el: {
type: "bi.button_group",
items: BI.createItems(this._items, {
type: "bi.single_select_item"
}),
layouts: [{
type: "bi.vertical"
}]
}
}
});
this.combo.on(BI.Combo.EVENT_CHANGE, function () {
var val = this.getValue()[0];
self.doCommand(val);
this.hideView();
this.setValue([]);
})
}
});
BI.shortcut('bi.rich_editor_size_chooser', BI.RichEditorSizeChooser);

50
src/base/richeditor/richeditor.js

@ -13,32 +13,50 @@ BI.RichEditor = BI.inherit(BI.Widget, {
}, },
_init: function () { _init: function () {
BI.RichEditor.superclass._init.apply(this, arguments); BI.RichEditor.superclass._init.apply(this, arguments);
var o = this.options; var self = this, o = this.options;
this.editor = BI.createWidget({ this.editor = BI.createWidget({
type: "bi.layout", type: "bi.nic_editor",
tagName: "textarea", width: o.width,
width: o.width || "100%", height: o.height
height: o.height || "100%"
}); });
BI.createWidget({
type: "bi.default", this.editor.on(BI.NicEditor.EVENT_BLUR, function () {
self.fireEvent(BI.RichEditor.EVENT_CONFIRM);
});
this.toolbar = BI.createWidget({
type: "bi.rich_editor_text_toolbar",
editor: this.editor
});
this.combo = BI.createWidget({
type: "bi.combo",
element: this, element: this,
items: [this.editor] toggle: false,
}) direction: "top",
}, isNeedAdjustWidth: false,
isNeedAdjustHeight: false,
adjustLength: 1,
el: this.editor,
popup: {
el: this.toolbar,
height: 30,
stopPropagation: true,
stopEvent: true
}
});
mounted: function () { this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () {
this.ne = new BI.nicEditor({ });
maxHeight: this.options.height
}).panelInstance(this.editor.element[0]);
}, },
setValue: function (v) { setValue: function (v) {
this.ne.nicInstances[0].setContent(v); this.editor.setValue(v);
}, },
getValue: function () { getValue: function () {
return this.ne.nicInstances[0].getContent(); return this.editor.getValue();
} }
}); });
BI.RichEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut('bi.rich_editor', BI.RichEditor); BI.shortcut('bi.rich_editor', BI.RichEditor);

13
src/case/trigger/trigger.text.js

@ -7,15 +7,15 @@
*/ */
BI.TextTrigger = BI.inherit(BI.Trigger, { BI.TextTrigger = BI.inherit(BI.Trigger, {
_const: { _const: {
hgap: 4, hgap: 4
triggerWidth: 30
}, },
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.TextTrigger.superclass._defaultConfig.apply(this, arguments); var conf = BI.TextTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-text-trigger", baseCls: (conf.baseCls || "") + " bi-text-trigger",
height: 30 height: 30,
triggerWidth: 30
}); });
}, },
@ -27,12 +27,13 @@ BI.TextTrigger = BI.inherit(BI.Trigger, {
textAlign: "left", textAlign: "left",
height: o.height, height: o.height,
text: o.text, text: o.text,
hgap: c.hgap hgap: c.hgap,
readonly: o.readonly
}); });
this.trigerButton = BI.createWidget({ this.trigerButton = BI.createWidget({
type: "bi.trigger_icon_button", type: "bi.trigger_icon_button",
cls: "bi-border-left", cls: "bi-border-left",
width: c.triggerWidth width: o.triggerWidth
}); });
BI.createWidget({ BI.createWidget({
@ -43,7 +44,7 @@ BI.TextTrigger = BI.inherit(BI.Trigger, {
el: this.text el: this.text
}, { }, {
el: this.trigerButton, el: this.trigerButton,
width: c.triggerWidth width: o.triggerWidth
} }
] ]
}); });

8
src/case/trigger/trigger.text.small.js

@ -7,14 +7,14 @@
BI.SmallTextTrigger = BI.inherit(BI.Trigger, { BI.SmallTextTrigger = BI.inherit(BI.Trigger, {
_const: { _const: {
hgap: 4, hgap: 4,
triggerWidth: 20
}, },
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.SmallTextTrigger.superclass._defaultConfig.apply(this, arguments); var conf = BI.SmallTextTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
baseCls: (conf.baseCls || "") + " bi-text-trigger", baseCls: (conf.baseCls || "") + " bi-text-trigger",
height: 20 height: 20,
triggerWidth: 20
}); });
}, },
@ -30,7 +30,7 @@ BI.SmallTextTrigger = BI.inherit(BI.Trigger, {
}); });
this.trigerButton = BI.createWidget({ this.trigerButton = BI.createWidget({
type: "bi.trigger_icon_button", type: "bi.trigger_icon_button",
width: c.triggerWidth width: o.triggerWidth
}); });
BI.createWidget({ BI.createWidget({
@ -41,7 +41,7 @@ BI.SmallTextTrigger = BI.inherit(BI.Trigger, {
el: this.text el: this.text
}, { }, {
el: this.trigerButton, el: this.trigerButton,
width: c.triggerWidth width: o.triggerWidth
} }
] ]
}); });

2
src/core/model.js

@ -290,7 +290,7 @@ BI.Model = BI.inherit(BI.M, {
return this.attributes[attr]; return this.attributes[attr];
} }
var sta = _.result(this, "_static"); var sta = _.result(this, "_static");
return BI.isFunction(sta[attr]) ? sta[attr].apply(this, BI.values(arguments).slice(1)) : sta[attr]; return BI.isFunction(sta[attr]) ? sta[attr].apply(this, Array.prototype.slice.apply(arguments, [1])) : sta[attr];
}, },
get: function () { get: function () {

3
src/css/base/richeditor/texttoolbar/texttoolbar.css

@ -0,0 +1,3 @@
.bi-text-toolbar .text-toolbar-button {
font-size: 16px;
}

112
src/css/resource/font.css

@ -4,6 +4,10 @@
/* iOS 4.1- */ /* iOS 4.1- */
} }
@font-face {
font-family: 'bi';
src: url('font/iconfont.eot') /* IE6-IE8 */;
}
.b-font { .b-font {
font-family: "bi"; font-family: "bi";
font-style: normal; font-style: normal;
@ -730,3 +734,111 @@
content: "\e636"; content: "\e636";
color: inherit; color: inherit;
} }
.text-bold-font .b-font {
*zoom: expression( this.runtimeStyle['zoom'] = '1',this.innerHTML = '&#xe64d;');
}
.text-bold-font .b-font:before {
content: "\e64d";
color: inherit;
}
.text-bold-font.native .b-font:before,
.text-bold-font.disabled .b-font:before {
content: "\e64d";
color: inherit;
}
.text-italic-font .b-font {
*zoom: expression( this.runtimeStyle['zoom'] = '1',this.innerHTML = '&#xe656;');
}
.text-italic-font .b-font:before {
content: "\e656";
color: inherit;
}
.text-italic-font.native .b-font:before,
.text-italic-font.disabled .b-font:before {
content: "\e656";
color: inherit;
}
.text-underline-font .b-font {
*zoom: expression( this.runtimeStyle['zoom'] = '1',this.innerHTML = '&#xe650;');
}
.text-underline-font .b-font:before {
content: "\e650";
color: inherit;
}
.text-underline-font.native .b-font:before,
.text-underline-font.disabled .b-font:before {
content: "\e650";
color: inherit;
}
.text-color-font .b-font {
*zoom: expression( this.runtimeStyle['zoom'] = '1',this.innerHTML = '&#xe69c;');
}
.text-color-font .b-font:before {
content: "\e69c";
color: inherit;
}
.text-color-font.native .b-font:before,
.text-color-font.disabled .b-font:before {
content: "\e69c";
color: inherit;
}
.text-background-font .b-font {
*zoom: expression( this.runtimeStyle['zoom'] = '1',this.innerHTML = '&#xe696;');
}
.text-background-font .b-font:before {
content: "\e696";
color: inherit;
}
.text-background-font.native .b-font:before,
.text-background-font.disabled .b-font:before {
content: "\e696";
color: inherit;
}
.text-color-underline-font .b-font {
*zoom: expression( this.runtimeStyle['zoom'] = '1',this.innerHTML = '&#xe69d;');
}
.text-color-underline-font .b-font:before {
content: "\e69d";
color: inherit;
}
.text-color-underline-font.native .b-font:before,
.text-color-underline-font.disabled .b-font:before {
content: "\e69d";
color: inherit;
}
.text-align-left-font .b-font {
*zoom: expression( this.runtimeStyle['zoom'] = '1',this.innerHTML = '&#xe654;');
}
.text-align-left-font .b-font:before {
content: "\e654";
color: inherit;
}
.text-align-left-font.native .b-font:before,
.text-align-left-font.disabled .b-font:before {
content: "\e654";
color: inherit;
}
.text-align-center-font .b-font {
*zoom: expression( this.runtimeStyle['zoom'] = '1',this.innerHTML = '&#xe64f;');
}
.text-align-center-font .b-font:before {
content: "\e64f";
color: inherit;
}
.text-align-center-font.native .b-font:before,
.text-align-center-font.disabled .b-font:before {
content: "\e64f";
color: inherit;
}
.text-align-right-font .b-font {
*zoom: expression( this.runtimeStyle['zoom'] = '1',this.innerHTML = '&#xe651;');
}
.text-align-right-font .b-font:before {
content: "\e651";
color: inherit;
}
.text-align-right-font.native .b-font:before,
.text-align-right-font.disabled .b-font:before {
content: "\e651";
color: inherit;
}

5
src/less/base/richeditor/texttoolbar/alignchooser/texttoolbar.alignchooser.less

@ -0,0 +1,5 @@
@import "../../../../bibase";
.bi-text-toolbar-align-chooser{
& .align-chooser-button{
}
}

7
src/less/base/richeditor/texttoolbar/texttoolbar.less

@ -0,0 +1,7 @@
@import "../../../bibase";
.bi-text-toolbar {
& .text-toolbar-button {
font-size: @font-size-16;
}
}

18
src/less/resource/font.less

@ -7,6 +7,13 @@
src: url('@{webUrl}font/iconfont.eot'), /* IE6-IE8 */ url('@{webUrl}font/iconfont.woff') format('woff'), /* chrome、firefox */ url('@{webUrl}font/iconfont.ttf') format('truetype'), /* chrome、firefox、opera、Safari, Android, iOS 4.2+*/ url('@{webUrl}font/iconfont.svg#svgFontName') format('svg'); /* iOS 4.1- */ src: url('@{webUrl}font/iconfont.eot'), /* IE6-IE8 */ url('@{webUrl}font/iconfont.woff') format('woff'), /* chrome、firefox */ url('@{webUrl}font/iconfont.ttf') format('truetype'), /* chrome、firefox、opera、Safari, Android, iOS 4.2+*/ url('@{webUrl}font/iconfont.svg#svgFontName') format('svg'); /* iOS 4.1- */
} }
html.ie9below {
@font-face {
font-family: 'bi';
src: url('@{webUrl}font/iconfont.eot') /* IE6-IE8 */
}
}
.b-font { .b-font {
font-family: "bi"; font-family: "bi";
font-style: normal; font-style: normal;
@ -84,3 +91,14 @@
//数值区间 //数值区间
.font-hover-active(less-font, @font-less); .font-hover-active(less-font, @font-less);
.font-hover-active(less-equal-font, @font-less-equal); .font-hover-active(less-equal-font, @font-less-equal);
//文本控件
.font(text-bold-font, @font-bold);
.font(text-italic-font, @font-italic);
.font(text-underline-font, @font-underline);
.font(text-color-font, @font-color);
.font(text-background-font, @font-background);
.font(text-color-underline-font, @font-color-underline);
.font(text-align-left-font, @font-align-left);
.font(text-align-center-font, @font-align-center);
.font(text-align-right-font, @font-align-right);
Loading…
Cancel
Save