Browse Source

去第三方js

es6
windy 7 years ago
parent
commit
a338f8b963
  1. 786
      bi/base.js
  2. 42
      bi/sliders.css
  3. 786
      dist/base.js
  4. 786
      dist/bundle.js
  5. 72
      dist/bundle.min.js
  6. 2410
      dist/demo.js
  7. 42
      dist/sliders.css
  8. 145
      src/third/jquery.splendid.textchange.js

786
bi/base.js

@ -200,150 +200,6 @@
} }
}));/** }));/**
* jQuery "splendid textchange" plugin
* http://benalpert.com/2013/06/18/a-near-perfect-oninput-shim-for-ie-8-and-9.html
*
* (c) 2013 Ben Alpert, released under the MIT license
*/
(function($) {
var testNode = document.createElement("input");
var isInputSupported = "oninput" in testNode &&
(!("documentMode" in document) || document.documentMode > 9);
var hasInputCapabilities = function(elem) {
// The HTML5 spec lists many more types than `text` and `password` on
// which the input event is triggered but none of them exist in IE 8 or
// 9, so we don't check them here.
// TODO: <textarea> should be supported too but IE seems to reset the
// selection when changing textarea contents during a selectionchange
// event so it's not listed here for now.
return elem.nodeName === "INPUT" &&
(elem.type === "text" || elem.type === "password");
};
var activeElement = null;
var activeElementValue = null;
var activeElementValueProp = null;
/**
* (For old IE.) Replacement getter/setter for the `value` property that
* gets set on the active element.
*/
var newValueProp = {
get: function() {
return activeElementValueProp.get.call(this);
},
set: function(val) {
activeElementValue = val;
activeElementValueProp.set.call(this, val);
}
};
/**
* (For old IE.) Starts tracking propertychange events on the passed-in element
* and override the value property so that we can distinguish user events from
* value changes in JS.
*/
var startWatching = function(target) {
activeElement = target;
activeElementValue = target.value;
activeElementValueProp = Object.getOwnPropertyDescriptor(
target.constructor.prototype, "value");
Object.defineProperty(activeElement, "value", newValueProp);
activeElement.attachEvent("onpropertychange", handlePropertyChange);
};
/**
* (For old IE.) Removes the event listeners from the currently-tracked
* element, if any exists.
*/
var stopWatching = function() {
if (!activeElement) return;
// delete restores the original property definition
delete activeElement.value;
activeElement.detachEvent("onpropertychange", handlePropertyChange);
activeElement = null;
activeElementValue = null;
activeElementValueProp = null;
};
/**
* (For old IE.) Handles a propertychange event, sending a textChange event if
* the value of the active element has changed.
*/
var handlePropertyChange = function(nativeEvent) {
if (nativeEvent.propertyName !== "value") return;
var value = nativeEvent.srcElement.value;
if (value === activeElementValue) return;
activeElementValue = value;
$(activeElement).trigger("textchange");
};
if (isInputSupported) {
$(document)
.on("input", function(e) {
// In modern browsers (i.e., not IE 8 or 9), the input event is
// exactly what we want so fall through here and trigger the
// event...
if (e.target.nodeName !== "TEXTAREA") {
// ...unless it's a textarea, in which case we don't fire an
// event (so that we have consistency with our old-IE shim).
$(e.target).trigger("textchange");
}
});
} else {
$(document)
.on("focusin", function(e) {
// In IE 8, we can capture almost all .value changes by adding a
// propertychange handler and looking for events with propertyName
// equal to 'value'.
// In IE 9, propertychange fires for most input events but is buggy
// and doesn't fire when text is deleted, but conveniently,
// selectionchange appears to fire in all of the remaining cases so
// we catch those and forward the event if the value has changed.
// In either case, we don't want to call the event handler if the
// value is changed from JS so we redefine a setter for `.value`
// that updates our activeElementValue variable, allowing us to
// ignore those changes.
if (hasInputCapabilities(e.target)) {
// stopWatching() should be a noop here but we call it just in
// case we missed a blur event somehow.
stopWatching();
startWatching(e.target);
}
})
.on("focusout", function() {
stopWatching();
})
.on("selectionchange keyup keydown", function() {
// On the selectionchange event, e.target is just document which
// isn't helpful for us so just check activeElement instead.
//
// 90% of the time, keydown and keyup aren't necessary. IE 8 fails
// to fire propertychange on the first input event after setting
// `value` from a script and fires only keydown, keypress, keyup.
// Catching keyup usually gets it and catching keydown lets us fire
// an event for the first keystroke if user does a key repeat
// (it'll be a little delayed: right before the second keystroke).
// Other input methods (e.g., paste) seem to fire selectionchange
// normally.
if (activeElement && activeElement.value !== activeElementValue) {
activeElementValue = activeElement.value;
$(activeElement).trigger("textchange");
}
});
}
})(jQuery);/**
* 当没有元素时有提示信息的view * 当没有元素时有提示信息的view
* *
* Created by GUY on 2015/9/8. * Created by GUY on 2015/9/8.
@ -16411,68 +16267,68 @@ BI.RichEditorParamAction = BI.inherit(BI.RichEditorAction, {
key: function (e) { key: function (e) {
} }
});/** });/**
* 颜色选择 * 颜色选择
* *
* Created by GUY on 2015/11/26. * Created by GUY on 2015/11/26.
* @class BI.RichEditorTextToolbar * @class BI.RichEditorTextToolbar
* @extends BI.Widget * @extends BI.Widget
*/ */
BI.RichEditorTextToolbar = BI.inherit(BI.Widget, { BI.RichEditorTextToolbar = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.RichEditorTextToolbar.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.RichEditorTextToolbar.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-rich-editor-text-toolbar bi-background", baseCls: "bi-rich-editor-text-toolbar bi-background",
buttons: [ buttons: [
{type: "bi.rich_editor_size_chooser"}, {type: "bi.rich_editor_size_chooser"},
{type: "bi.rich_editor_bold_button"}, {type: "bi.rich_editor_bold_button"},
{type: "bi.rich_editor_italic_button"}, {type: "bi.rich_editor_italic_button"},
{type: "bi.rich_editor_underline_button"}, {type: "bi.rich_editor_underline_button"},
{type: "bi.rich_editor_color_chooser"}, {type: "bi.rich_editor_color_chooser"},
{type: "bi.rich_editor_background_color_chooser"}, {type: "bi.rich_editor_background_color_chooser"},
{type: "bi.rich_editor_align_left_button"}, {type: "bi.rich_editor_align_left_button"},
{type: "bi.rich_editor_align_center_button"}, {type: "bi.rich_editor_align_center_button"},
{type: "bi.rich_editor_align_right_button"}, {type: "bi.rich_editor_align_right_button"},
{type: "bi.rich_editor_param_button"}, {type: "bi.rich_editor_param_button"},
], ],
height: 28 height: 28
}); });
}, },
_init: function () { _init: function () {
BI.RichEditorTextToolbar.superclass._init.apply(this, arguments); BI.RichEditorTextToolbar.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
BI.createWidget({ BI.createWidget({
type: "bi.left", type: "bi.left",
element: this, element: this,
items: BI.map(o.buttons, function (i, btn) { items: BI.map(o.buttons, function (i, btn) {
return BI.extend(btn, { return BI.extend(btn, {
editor: o.editor editor: o.editor
}); });
}), }),
hgap: 3, hgap: 3,
vgap: 3 vgap: 3
}) })
}, },
mounted: function () { mounted: function () {
var self = this; var self = this;
if (BI.isIE9Below()) {//IE8下必须要设置unselectable才能不blur输入框 if (BI.isIE9Below()) {//IE8下必须要设置unselectable才能不blur输入框
this.element.mousedown(function () { this.element.mousedown(function () {
self._noSelect(self.element[0]); self._noSelect(self.element[0]);
}); });
this._noSelect(this.element[0]); this._noSelect(this.element[0]);
} }
}, },
_noSelect: function (element) { _noSelect: function (element) {
if (element.setAttribute && element.nodeName.toLowerCase() != 'input' && element.nodeName.toLowerCase() != 'textarea') { if (element.setAttribute && element.nodeName.toLowerCase() != 'input' && element.nodeName.toLowerCase() != 'textarea') {
element.setAttribute('unselectable', 'on'); element.setAttribute('unselectable', 'on');
} }
for (var i = 0; i < element.childNodes.length; i++) { for (var i = 0; i < element.childNodes.length; i++) {
this._noSelect(element.childNodes[i]); this._noSelect(element.childNodes[i]);
} }
} }
}); });
BI.shortcut('bi.rich_editor_text_toolbar', BI.RichEditorTextToolbar);/** BI.shortcut('bi.rich_editor_text_toolbar', BI.RichEditorTextToolbar);/**
* 富文本编辑器 * 富文本编辑器
* *
@ -16753,57 +16609,57 @@ BI.shortcut('bi.rich_editor_text_toolbar', BI.RichEditorTextToolbar);/**
} }
}); });
}()); }());
/** /**
* 颜色选择trigger * 颜色选择trigger
* *
* Created by GUY on 2015/11/26. * Created by GUY on 2015/11/26.
* @class BI.RichEditorBackgroundChooserTrigger * @class BI.RichEditorBackgroundChooserTrigger
* @extends BI.Widget * @extends BI.Widget
*/ */
BI.RichEditorBackgroundChooserTrigger = BI.inherit(BI.Widget, { BI.RichEditorBackgroundChooserTrigger = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.RichEditorBackgroundChooserTrigger.superclass._defaultConfig.apply(this, arguments); var conf = BI.RichEditorBackgroundChooserTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
width: 20, width: 20,
height: 20 height: 20
}); });
}, },
_init: function () { _init: function () {
BI.RichEditorBackgroundChooserTrigger.superclass._init.apply(this, arguments); BI.RichEditorBackgroundChooserTrigger.superclass._init.apply(this, arguments);
this.font = BI.createWidget({ this.font = BI.createWidget({
type: "bi.icon_button", type: "bi.icon_button",
cls: "text-background-font" cls: "text-background-font"
}); });
this.underline = BI.createWidget({ this.underline = BI.createWidget({
type: "bi.icon_button", type: "bi.icon_button",
cls: "text-color-underline-font" cls: "text-color-underline-font"
}); });
BI.createWidget({ BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
element: this, element: this,
items: [{ items: [{
el: this.font, el: this.font,
top: 2, top: 2,
left: 2 left: 2
}, { }, {
el: this.underline, el: this.underline,
top: 7, top: 7,
left: 2 left: 2
}] }]
}) })
}, },
setValue: function (color) { setValue: function (color) {
this.underline.element.css("color", color); this.underline.element.css("color", color);
}, },
getValue: function () { getValue: function () {
return this.font.element.css("color"); return this.font.element.css("color");
} }
}); });
BI.shortcut('bi.rich_editor_background_color_chooser_trigger', BI.RichEditorBackgroundChooserTrigger);/** BI.shortcut('bi.rich_editor_background_color_chooser_trigger', BI.RichEditorBackgroundChooserTrigger);/**
* *
* Created by GUY on 2015/11/26. * Created by GUY on 2015/11/26.
@ -17071,214 +16927,214 @@ BI.RichEditorUnderlineButton = BI.inherit(BI.RichEditorAction, {
this.underline.setSelected(false); this.underline.setSelected(false);
}, },
}); });
BI.shortcut("bi.rich_editor_underline_button", BI.RichEditorUnderlineButton)/** BI.shortcut("bi.rich_editor_underline_button", BI.RichEditorUnderlineButton)/**
* 颜色选择trigger * 颜色选择trigger
* *
* Created by GUY on 2015/11/26. * Created by GUY on 2015/11/26.
* @class BI.RichEditorColorChooserTrigger * @class BI.RichEditorColorChooserTrigger
* @extends BI.Widget * @extends BI.Widget
*/ */
BI.RichEditorColorChooserTrigger = BI.inherit(BI.Widget, { BI.RichEditorColorChooserTrigger = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.RichEditorColorChooserTrigger.superclass._defaultConfig.apply(this, arguments); var conf = BI.RichEditorColorChooserTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
width: 20, width: 20,
height: 20 height: 20
}); });
}, },
_init: function () { _init: function () {
BI.RichEditorColorChooserTrigger.superclass._init.apply(this, arguments); BI.RichEditorColorChooserTrigger.superclass._init.apply(this, arguments);
this.font = BI.createWidget({ this.font = BI.createWidget({
type: "bi.icon_button", type: "bi.icon_button",
cls: "text-color-font" cls: "text-color-font"
}); });
this.underline = BI.createWidget({ this.underline = BI.createWidget({
type: "bi.icon_button", type: "bi.icon_button",
cls: "text-color-underline-font" cls: "text-color-underline-font"
}); });
BI.createWidget({ BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
element: this, element: this,
items: [{ items: [{
el: this.font, el: this.font,
top: 2, top: 2,
left: 2 left: 2
}, { }, {
el: this.underline, el: this.underline,
top: 7, top: 7,
left: 2 left: 2
}] }]
}) })
}, },
setValue: function (color) { setValue: function (color) {
this.underline.element.css("color", color); this.underline.element.css("color", color);
}, },
getValue: function () { getValue: function () {
return this.font.element.css("color"); return this.font.element.css("color");
} }
}); });
BI.shortcut('bi.rich_editor_color_chooser_trigger', BI.RichEditorColorChooserTrigger);/** BI.shortcut('bi.rich_editor_color_chooser_trigger', BI.RichEditorColorChooserTrigger);/**
* 颜色选择 * 颜色选择
* *
* Created by GUY on 2015/11/26. * Created by GUY on 2015/11/26.
* @class BI.RichEditorBackgroundColorChooser * @class BI.RichEditorBackgroundColorChooser
* @extends BI.RichEditorAction * @extends BI.RichEditorAction
*/ */
BI.RichEditorBackgroundColorChooser = BI.inherit(BI.RichEditorAction, { BI.RichEditorBackgroundColorChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.RichEditorBackgroundColorChooser.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.RichEditorBackgroundColorChooser.superclass._defaultConfig.apply(this, arguments), {
width: 20, width: 20,
height: 20, height: 20,
}); });
}, },
_init: function () { _init: function () {
BI.RichEditorBackgroundColorChooser.superclass._init.apply(this, arguments); BI.RichEditorBackgroundColorChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.colorchooser = BI.createWidget({ this.colorchooser = BI.createWidget({
type: "bi.color_chooser", type: "bi.color_chooser",
element: this, element: this,
width: o.width, width: o.width,
height: o.height, height: o.height,
el: { el: {
type: "bi.rich_editor_background_color_chooser_trigger", type: "bi.rich_editor_background_color_chooser_trigger",
title: BI.i18nText("BI-Widget_Background_Colour"), title: BI.i18nText("BI-Widget_Background_Colour"),
cls: "text-toolbar-button" cls: "text-toolbar-button"
} }
}); });
this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () { this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () {
var backgroundColor = this.getValue(); var backgroundColor = this.getValue();
o.editor.element.css({ o.editor.element.css({
backgroundColor: backgroundColor, backgroundColor: backgroundColor,
color: BI.DOM.getContrastColor(backgroundColor) color: BI.DOM.getContrastColor(backgroundColor)
}); });
this.setValue(""); this.setValue("");
}); });
}, },
deactivate: function () { deactivate: function () {
} }
}); });
BI.shortcut('bi.rich_editor_background_color_chooser', BI.RichEditorBackgroundColorChooser);/** BI.shortcut('bi.rich_editor_background_color_chooser', BI.RichEditorBackgroundColorChooser);/**
* 颜色选择 * 颜色选择
* *
* Created by GUY on 2015/11/26. * Created by GUY on 2015/11/26.
* @class BI.RichEditorColorChooser * @class BI.RichEditorColorChooser
* @extends BI.RichEditorAction * @extends BI.RichEditorAction
*/ */
BI.RichEditorColorChooser = BI.inherit(BI.RichEditorAction, { BI.RichEditorColorChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.RichEditorColorChooser.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.RichEditorColorChooser.superclass._defaultConfig.apply(this, arguments), {
width: 20, width: 20,
height: 20, height: 20,
command: "foreColor" command: "foreColor"
}); });
}, },
_init: function () { _init: function () {
BI.RichEditorColorChooser.superclass._init.apply(this, arguments); BI.RichEditorColorChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.colorchooser = BI.createWidget({ this.colorchooser = BI.createWidget({
type: "bi.color_chooser", type: "bi.color_chooser",
element: this, element: this,
width: o.width, width: o.width,
height: o.height, height: o.height,
el: { el: {
type: "bi.rich_editor_color_chooser_trigger", type: "bi.rich_editor_color_chooser_trigger",
title: BI.i18nText("BI-Font_Colour"), title: BI.i18nText("BI-Font_Colour"),
cls: "text-toolbar-button" cls: "text-toolbar-button"
} }
}); });
this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () { this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () {
self.doCommand(this.getValue()); self.doCommand(this.getValue());
}); });
}, },
deactivate: function () { deactivate: function () {
this.colorchooser.setValue(""); this.colorchooser.setValue("");
} }
}); });
BI.shortcut('bi.rich_editor_color_chooser', BI.RichEditorColorChooser);/** BI.shortcut('bi.rich_editor_color_chooser', BI.RichEditorColorChooser);/**
* 字体大小选择 * 字体大小选择
* *
* Created by GUY on 2015/11/26. * Created by GUY on 2015/11/26.
* @class BI.RichEditorSizeChooser * @class BI.RichEditorSizeChooser
* @extends BI.RichEditorAction * @extends BI.RichEditorAction
*/ */
BI.RichEditorSizeChooser = BI.inherit(BI.RichEditorAction, { BI.RichEditorSizeChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.RichEditorSizeChooser.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.RichEditorSizeChooser.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-rich-editor-size-chooser bi-border bi-card", baseCls: "bi-rich-editor-size-chooser bi-border bi-card",
command: "FontSize", command: "FontSize",
width: 50, width: 50,
height: 20 height: 20
}); });
}, },
_items: [{ _items: [{
value: 1, value: 1,
text: "1(8pt)" text: "1(8pt)"
}, { }, {
value: 2, value: 2,
text: "2(10pt)" text: "2(10pt)"
}, { }, {
value: 3, value: 3,
text: "3(12pt)" text: "3(12pt)"
}, { }, {
value: 4, value: 4,
text: "4(14pt)" text: "4(14pt)"
}, { }, {
value: 5, value: 5,
text: "5(18pt)" text: "5(18pt)"
}, { }, {
value: 6, value: 6,
text: "6(24pt)" text: "6(24pt)"
}], }],
_init: function () { _init: function () {
BI.RichEditorSizeChooser.superclass._init.apply(this, arguments); BI.RichEditorSizeChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.trigger = BI.createWidget({ this.trigger = BI.createWidget({
type: "bi.text_trigger", type: "bi.text_trigger",
readonly: true, readonly: true,
height: o.height, height: o.height,
triggerWidth: 12, triggerWidth: 12,
text: BI.i18nText("BI-Font_Size") text: BI.i18nText("BI-Font_Size")
}); });
this.combo = BI.createWidget({ this.combo = BI.createWidget({
type: "bi.combo", type: "bi.combo",
element: this, element: this,
el: this.trigger, el: this.trigger,
adjustLength: 1, adjustLength: 1,
popup: { popup: {
maxWidth: 70, maxWidth: 70,
minWidth: 70, minWidth: 70,
el: { el: {
type: "bi.button_group", type: "bi.button_group",
items: BI.createItems(this._items, { items: BI.createItems(this._items, {
type: "bi.single_select_item" type: "bi.single_select_item"
}), }),
layouts: [{ layouts: [{
type: "bi.vertical" type: "bi.vertical"
}] }]
} }
} }
}); });
this.combo.on(BI.Combo.EVENT_CHANGE, function () { this.combo.on(BI.Combo.EVENT_CHANGE, function () {
var val = this.getValue()[0]; var val = this.getValue()[0];
self.doCommand(val); self.doCommand(val);
this.hideView(); this.hideView();
this.setValue([]); this.setValue([]);
}) })
} }
}); });
BI.shortcut('bi.rich_editor_size_chooser', BI.RichEditorSizeChooser);/** BI.shortcut('bi.rich_editor_size_chooser', BI.RichEditorSizeChooser);/**
* 富文本编辑器 * 富文本编辑器
* *

42
bi/sliders.css

@ -24,27 +24,15 @@
-moz-border-radius: 7px; -moz-border-radius: 7px;
border-radius: 7px; border-radius: 7px;
} }
.bi-single-slider-button .slider-button { .bi-single-slider-button .slider-button {
cursor: ew-resize; cursor: ew-resize;
-webkit-box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); -webkit-box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
-moz-box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); -moz-box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
-webkit-border-radius: 7px; -webkit-border-radius: 7px;
-moz-border-radius: 7px; -moz-border-radius: 7px;
border-radius: 7px; border-radius: 7px;
} }
.bi-slider-track .gray-track {
background-color: rgba(153, 153, 153, 0.3);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#4d999999,endColorstr=#4d999999);
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
.bi-slider-track .blue-track {
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
.bi-slider-track .gray-track { .bi-slider-track .gray-track {
background-color: rgba(153, 153, 153, 0.3); background-color: rgba(153, 153, 153, 0.3);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#4d999999,endColorstr=#4d999999); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#4d999999,endColorstr=#4d999999);
@ -57,3 +45,15 @@
-moz-border-radius: 3px; -moz-border-radius: 3px;
border-radius: 3px; border-radius: 3px;
} }
.bi-slider-track .gray-track {
background-color: rgba(153, 153, 153, 0.3);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#4d999999,endColorstr=#4d999999);
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
.bi-slider-track .blue-track {
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}

786
dist/base.js vendored

@ -200,150 +200,6 @@
} }
}));/** }));/**
* jQuery "splendid textchange" plugin
* http://benalpert.com/2013/06/18/a-near-perfect-oninput-shim-for-ie-8-and-9.html
*
* (c) 2013 Ben Alpert, released under the MIT license
*/
(function($) {
var testNode = document.createElement("input");
var isInputSupported = "oninput" in testNode &&
(!("documentMode" in document) || document.documentMode > 9);
var hasInputCapabilities = function(elem) {
// The HTML5 spec lists many more types than `text` and `password` on
// which the input event is triggered but none of them exist in IE 8 or
// 9, so we don't check them here.
// TODO: <textarea> should be supported too but IE seems to reset the
// selection when changing textarea contents during a selectionchange
// event so it's not listed here for now.
return elem.nodeName === "INPUT" &&
(elem.type === "text" || elem.type === "password");
};
var activeElement = null;
var activeElementValue = null;
var activeElementValueProp = null;
/**
* (For old IE.) Replacement getter/setter for the `value` property that
* gets set on the active element.
*/
var newValueProp = {
get: function() {
return activeElementValueProp.get.call(this);
},
set: function(val) {
activeElementValue = val;
activeElementValueProp.set.call(this, val);
}
};
/**
* (For old IE.) Starts tracking propertychange events on the passed-in element
* and override the value property so that we can distinguish user events from
* value changes in JS.
*/
var startWatching = function(target) {
activeElement = target;
activeElementValue = target.value;
activeElementValueProp = Object.getOwnPropertyDescriptor(
target.constructor.prototype, "value");
Object.defineProperty(activeElement, "value", newValueProp);
activeElement.attachEvent("onpropertychange", handlePropertyChange);
};
/**
* (For old IE.) Removes the event listeners from the currently-tracked
* element, if any exists.
*/
var stopWatching = function() {
if (!activeElement) return;
// delete restores the original property definition
delete activeElement.value;
activeElement.detachEvent("onpropertychange", handlePropertyChange);
activeElement = null;
activeElementValue = null;
activeElementValueProp = null;
};
/**
* (For old IE.) Handles a propertychange event, sending a textChange event if
* the value of the active element has changed.
*/
var handlePropertyChange = function(nativeEvent) {
if (nativeEvent.propertyName !== "value") return;
var value = nativeEvent.srcElement.value;
if (value === activeElementValue) return;
activeElementValue = value;
$(activeElement).trigger("textchange");
};
if (isInputSupported) {
$(document)
.on("input", function(e) {
// In modern browsers (i.e., not IE 8 or 9), the input event is
// exactly what we want so fall through here and trigger the
// event...
if (e.target.nodeName !== "TEXTAREA") {
// ...unless it's a textarea, in which case we don't fire an
// event (so that we have consistency with our old-IE shim).
$(e.target).trigger("textchange");
}
});
} else {
$(document)
.on("focusin", function(e) {
// In IE 8, we can capture almost all .value changes by adding a
// propertychange handler and looking for events with propertyName
// equal to 'value'.
// In IE 9, propertychange fires for most input events but is buggy
// and doesn't fire when text is deleted, but conveniently,
// selectionchange appears to fire in all of the remaining cases so
// we catch those and forward the event if the value has changed.
// In either case, we don't want to call the event handler if the
// value is changed from JS so we redefine a setter for `.value`
// that updates our activeElementValue variable, allowing us to
// ignore those changes.
if (hasInputCapabilities(e.target)) {
// stopWatching() should be a noop here but we call it just in
// case we missed a blur event somehow.
stopWatching();
startWatching(e.target);
}
})
.on("focusout", function() {
stopWatching();
})
.on("selectionchange keyup keydown", function() {
// On the selectionchange event, e.target is just document which
// isn't helpful for us so just check activeElement instead.
//
// 90% of the time, keydown and keyup aren't necessary. IE 8 fails
// to fire propertychange on the first input event after setting
// `value` from a script and fires only keydown, keypress, keyup.
// Catching keyup usually gets it and catching keydown lets us fire
// an event for the first keystroke if user does a key repeat
// (it'll be a little delayed: right before the second keystroke).
// Other input methods (e.g., paste) seem to fire selectionchange
// normally.
if (activeElement && activeElement.value !== activeElementValue) {
activeElementValue = activeElement.value;
$(activeElement).trigger("textchange");
}
});
}
})(jQuery);/**
* 当没有元素时有提示信息的view * 当没有元素时有提示信息的view
* *
* Created by GUY on 2015/9/8. * Created by GUY on 2015/9/8.
@ -16411,68 +16267,68 @@ BI.RichEditorParamAction = BI.inherit(BI.RichEditorAction, {
key: function (e) { key: function (e) {
} }
});/** });/**
* 颜色选择 * 颜色选择
* *
* Created by GUY on 2015/11/26. * Created by GUY on 2015/11/26.
* @class BI.RichEditorTextToolbar * @class BI.RichEditorTextToolbar
* @extends BI.Widget * @extends BI.Widget
*/ */
BI.RichEditorTextToolbar = BI.inherit(BI.Widget, { BI.RichEditorTextToolbar = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.RichEditorTextToolbar.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.RichEditorTextToolbar.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-rich-editor-text-toolbar bi-background", baseCls: "bi-rich-editor-text-toolbar bi-background",
buttons: [ buttons: [
{type: "bi.rich_editor_size_chooser"}, {type: "bi.rich_editor_size_chooser"},
{type: "bi.rich_editor_bold_button"}, {type: "bi.rich_editor_bold_button"},
{type: "bi.rich_editor_italic_button"}, {type: "bi.rich_editor_italic_button"},
{type: "bi.rich_editor_underline_button"}, {type: "bi.rich_editor_underline_button"},
{type: "bi.rich_editor_color_chooser"}, {type: "bi.rich_editor_color_chooser"},
{type: "bi.rich_editor_background_color_chooser"}, {type: "bi.rich_editor_background_color_chooser"},
{type: "bi.rich_editor_align_left_button"}, {type: "bi.rich_editor_align_left_button"},
{type: "bi.rich_editor_align_center_button"}, {type: "bi.rich_editor_align_center_button"},
{type: "bi.rich_editor_align_right_button"}, {type: "bi.rich_editor_align_right_button"},
{type: "bi.rich_editor_param_button"}, {type: "bi.rich_editor_param_button"},
], ],
height: 28 height: 28
}); });
}, },
_init: function () { _init: function () {
BI.RichEditorTextToolbar.superclass._init.apply(this, arguments); BI.RichEditorTextToolbar.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
BI.createWidget({ BI.createWidget({
type: "bi.left", type: "bi.left",
element: this, element: this,
items: BI.map(o.buttons, function (i, btn) { items: BI.map(o.buttons, function (i, btn) {
return BI.extend(btn, { return BI.extend(btn, {
editor: o.editor editor: o.editor
}); });
}), }),
hgap: 3, hgap: 3,
vgap: 3 vgap: 3
}) })
}, },
mounted: function () { mounted: function () {
var self = this; var self = this;
if (BI.isIE9Below()) {//IE8下必须要设置unselectable才能不blur输入框 if (BI.isIE9Below()) {//IE8下必须要设置unselectable才能不blur输入框
this.element.mousedown(function () { this.element.mousedown(function () {
self._noSelect(self.element[0]); self._noSelect(self.element[0]);
}); });
this._noSelect(this.element[0]); this._noSelect(this.element[0]);
} }
}, },
_noSelect: function (element) { _noSelect: function (element) {
if (element.setAttribute && element.nodeName.toLowerCase() != 'input' && element.nodeName.toLowerCase() != 'textarea') { if (element.setAttribute && element.nodeName.toLowerCase() != 'input' && element.nodeName.toLowerCase() != 'textarea') {
element.setAttribute('unselectable', 'on'); element.setAttribute('unselectable', 'on');
} }
for (var i = 0; i < element.childNodes.length; i++) { for (var i = 0; i < element.childNodes.length; i++) {
this._noSelect(element.childNodes[i]); this._noSelect(element.childNodes[i]);
} }
} }
}); });
BI.shortcut('bi.rich_editor_text_toolbar', BI.RichEditorTextToolbar);/** BI.shortcut('bi.rich_editor_text_toolbar', BI.RichEditorTextToolbar);/**
* 富文本编辑器 * 富文本编辑器
* *
@ -16753,57 +16609,57 @@ BI.shortcut('bi.rich_editor_text_toolbar', BI.RichEditorTextToolbar);/**
} }
}); });
}()); }());
/** /**
* 颜色选择trigger * 颜色选择trigger
* *
* Created by GUY on 2015/11/26. * Created by GUY on 2015/11/26.
* @class BI.RichEditorBackgroundChooserTrigger * @class BI.RichEditorBackgroundChooserTrigger
* @extends BI.Widget * @extends BI.Widget
*/ */
BI.RichEditorBackgroundChooserTrigger = BI.inherit(BI.Widget, { BI.RichEditorBackgroundChooserTrigger = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.RichEditorBackgroundChooserTrigger.superclass._defaultConfig.apply(this, arguments); var conf = BI.RichEditorBackgroundChooserTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
width: 20, width: 20,
height: 20 height: 20
}); });
}, },
_init: function () { _init: function () {
BI.RichEditorBackgroundChooserTrigger.superclass._init.apply(this, arguments); BI.RichEditorBackgroundChooserTrigger.superclass._init.apply(this, arguments);
this.font = BI.createWidget({ this.font = BI.createWidget({
type: "bi.icon_button", type: "bi.icon_button",
cls: "text-background-font" cls: "text-background-font"
}); });
this.underline = BI.createWidget({ this.underline = BI.createWidget({
type: "bi.icon_button", type: "bi.icon_button",
cls: "text-color-underline-font" cls: "text-color-underline-font"
}); });
BI.createWidget({ BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
element: this, element: this,
items: [{ items: [{
el: this.font, el: this.font,
top: 2, top: 2,
left: 2 left: 2
}, { }, {
el: this.underline, el: this.underline,
top: 7, top: 7,
left: 2 left: 2
}] }]
}) })
}, },
setValue: function (color) { setValue: function (color) {
this.underline.element.css("color", color); this.underline.element.css("color", color);
}, },
getValue: function () { getValue: function () {
return this.font.element.css("color"); return this.font.element.css("color");
} }
}); });
BI.shortcut('bi.rich_editor_background_color_chooser_trigger', BI.RichEditorBackgroundChooserTrigger);/** BI.shortcut('bi.rich_editor_background_color_chooser_trigger', BI.RichEditorBackgroundChooserTrigger);/**
* *
* Created by GUY on 2015/11/26. * Created by GUY on 2015/11/26.
@ -17071,214 +16927,214 @@ BI.RichEditorUnderlineButton = BI.inherit(BI.RichEditorAction, {
this.underline.setSelected(false); this.underline.setSelected(false);
}, },
}); });
BI.shortcut("bi.rich_editor_underline_button", BI.RichEditorUnderlineButton)/** BI.shortcut("bi.rich_editor_underline_button", BI.RichEditorUnderlineButton)/**
* 颜色选择trigger * 颜色选择trigger
* *
* Created by GUY on 2015/11/26. * Created by GUY on 2015/11/26.
* @class BI.RichEditorColorChooserTrigger * @class BI.RichEditorColorChooserTrigger
* @extends BI.Widget * @extends BI.Widget
*/ */
BI.RichEditorColorChooserTrigger = BI.inherit(BI.Widget, { BI.RichEditorColorChooserTrigger = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.RichEditorColorChooserTrigger.superclass._defaultConfig.apply(this, arguments); var conf = BI.RichEditorColorChooserTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
width: 20, width: 20,
height: 20 height: 20
}); });
}, },
_init: function () { _init: function () {
BI.RichEditorColorChooserTrigger.superclass._init.apply(this, arguments); BI.RichEditorColorChooserTrigger.superclass._init.apply(this, arguments);
this.font = BI.createWidget({ this.font = BI.createWidget({
type: "bi.icon_button", type: "bi.icon_button",
cls: "text-color-font" cls: "text-color-font"
}); });
this.underline = BI.createWidget({ this.underline = BI.createWidget({
type: "bi.icon_button", type: "bi.icon_button",
cls: "text-color-underline-font" cls: "text-color-underline-font"
}); });
BI.createWidget({ BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
element: this, element: this,
items: [{ items: [{
el: this.font, el: this.font,
top: 2, top: 2,
left: 2 left: 2
}, { }, {
el: this.underline, el: this.underline,
top: 7, top: 7,
left: 2 left: 2
}] }]
}) })
}, },
setValue: function (color) { setValue: function (color) {
this.underline.element.css("color", color); this.underline.element.css("color", color);
}, },
getValue: function () { getValue: function () {
return this.font.element.css("color"); return this.font.element.css("color");
} }
}); });
BI.shortcut('bi.rich_editor_color_chooser_trigger', BI.RichEditorColorChooserTrigger);/** BI.shortcut('bi.rich_editor_color_chooser_trigger', BI.RichEditorColorChooserTrigger);/**
* 颜色选择 * 颜色选择
* *
* Created by GUY on 2015/11/26. * Created by GUY on 2015/11/26.
* @class BI.RichEditorBackgroundColorChooser * @class BI.RichEditorBackgroundColorChooser
* @extends BI.RichEditorAction * @extends BI.RichEditorAction
*/ */
BI.RichEditorBackgroundColorChooser = BI.inherit(BI.RichEditorAction, { BI.RichEditorBackgroundColorChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.RichEditorBackgroundColorChooser.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.RichEditorBackgroundColorChooser.superclass._defaultConfig.apply(this, arguments), {
width: 20, width: 20,
height: 20, height: 20,
}); });
}, },
_init: function () { _init: function () {
BI.RichEditorBackgroundColorChooser.superclass._init.apply(this, arguments); BI.RichEditorBackgroundColorChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.colorchooser = BI.createWidget({ this.colorchooser = BI.createWidget({
type: "bi.color_chooser", type: "bi.color_chooser",
element: this, element: this,
width: o.width, width: o.width,
height: o.height, height: o.height,
el: { el: {
type: "bi.rich_editor_background_color_chooser_trigger", type: "bi.rich_editor_background_color_chooser_trigger",
title: BI.i18nText("BI-Widget_Background_Colour"), title: BI.i18nText("BI-Widget_Background_Colour"),
cls: "text-toolbar-button" cls: "text-toolbar-button"
} }
}); });
this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () { this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () {
var backgroundColor = this.getValue(); var backgroundColor = this.getValue();
o.editor.element.css({ o.editor.element.css({
backgroundColor: backgroundColor, backgroundColor: backgroundColor,
color: BI.DOM.getContrastColor(backgroundColor) color: BI.DOM.getContrastColor(backgroundColor)
}); });
this.setValue(""); this.setValue("");
}); });
}, },
deactivate: function () { deactivate: function () {
} }
}); });
BI.shortcut('bi.rich_editor_background_color_chooser', BI.RichEditorBackgroundColorChooser);/** BI.shortcut('bi.rich_editor_background_color_chooser', BI.RichEditorBackgroundColorChooser);/**
* 颜色选择 * 颜色选择
* *
* Created by GUY on 2015/11/26. * Created by GUY on 2015/11/26.
* @class BI.RichEditorColorChooser * @class BI.RichEditorColorChooser
* @extends BI.RichEditorAction * @extends BI.RichEditorAction
*/ */
BI.RichEditorColorChooser = BI.inherit(BI.RichEditorAction, { BI.RichEditorColorChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.RichEditorColorChooser.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.RichEditorColorChooser.superclass._defaultConfig.apply(this, arguments), {
width: 20, width: 20,
height: 20, height: 20,
command: "foreColor" command: "foreColor"
}); });
}, },
_init: function () { _init: function () {
BI.RichEditorColorChooser.superclass._init.apply(this, arguments); BI.RichEditorColorChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.colorchooser = BI.createWidget({ this.colorchooser = BI.createWidget({
type: "bi.color_chooser", type: "bi.color_chooser",
element: this, element: this,
width: o.width, width: o.width,
height: o.height, height: o.height,
el: { el: {
type: "bi.rich_editor_color_chooser_trigger", type: "bi.rich_editor_color_chooser_trigger",
title: BI.i18nText("BI-Font_Colour"), title: BI.i18nText("BI-Font_Colour"),
cls: "text-toolbar-button" cls: "text-toolbar-button"
} }
}); });
this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () { this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () {
self.doCommand(this.getValue()); self.doCommand(this.getValue());
}); });
}, },
deactivate: function () { deactivate: function () {
this.colorchooser.setValue(""); this.colorchooser.setValue("");
} }
}); });
BI.shortcut('bi.rich_editor_color_chooser', BI.RichEditorColorChooser);/** BI.shortcut('bi.rich_editor_color_chooser', BI.RichEditorColorChooser);/**
* 字体大小选择 * 字体大小选择
* *
* Created by GUY on 2015/11/26. * Created by GUY on 2015/11/26.
* @class BI.RichEditorSizeChooser * @class BI.RichEditorSizeChooser
* @extends BI.RichEditorAction * @extends BI.RichEditorAction
*/ */
BI.RichEditorSizeChooser = BI.inherit(BI.RichEditorAction, { BI.RichEditorSizeChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.RichEditorSizeChooser.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.RichEditorSizeChooser.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-rich-editor-size-chooser bi-border bi-card", baseCls: "bi-rich-editor-size-chooser bi-border bi-card",
command: "FontSize", command: "FontSize",
width: 50, width: 50,
height: 20 height: 20
}); });
}, },
_items: [{ _items: [{
value: 1, value: 1,
text: "1(8pt)" text: "1(8pt)"
}, { }, {
value: 2, value: 2,
text: "2(10pt)" text: "2(10pt)"
}, { }, {
value: 3, value: 3,
text: "3(12pt)" text: "3(12pt)"
}, { }, {
value: 4, value: 4,
text: "4(14pt)" text: "4(14pt)"
}, { }, {
value: 5, value: 5,
text: "5(18pt)" text: "5(18pt)"
}, { }, {
value: 6, value: 6,
text: "6(24pt)" text: "6(24pt)"
}], }],
_init: function () { _init: function () {
BI.RichEditorSizeChooser.superclass._init.apply(this, arguments); BI.RichEditorSizeChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.trigger = BI.createWidget({ this.trigger = BI.createWidget({
type: "bi.text_trigger", type: "bi.text_trigger",
readonly: true, readonly: true,
height: o.height, height: o.height,
triggerWidth: 12, triggerWidth: 12,
text: BI.i18nText("BI-Font_Size") text: BI.i18nText("BI-Font_Size")
}); });
this.combo = BI.createWidget({ this.combo = BI.createWidget({
type: "bi.combo", type: "bi.combo",
element: this, element: this,
el: this.trigger, el: this.trigger,
adjustLength: 1, adjustLength: 1,
popup: { popup: {
maxWidth: 70, maxWidth: 70,
minWidth: 70, minWidth: 70,
el: { el: {
type: "bi.button_group", type: "bi.button_group",
items: BI.createItems(this._items, { items: BI.createItems(this._items, {
type: "bi.single_select_item" type: "bi.single_select_item"
}), }),
layouts: [{ layouts: [{
type: "bi.vertical" type: "bi.vertical"
}] }]
} }
} }
}); });
this.combo.on(BI.Combo.EVENT_CHANGE, function () { this.combo.on(BI.Combo.EVENT_CHANGE, function () {
var val = this.getValue()[0]; var val = this.getValue()[0];
self.doCommand(val); self.doCommand(val);
this.hideView(); this.hideView();
this.setValue([]); this.setValue([]);
}) })
} }
}); });
BI.shortcut('bi.rich_editor_size_chooser', BI.RichEditorSizeChooser);/** BI.shortcut('bi.rich_editor_size_chooser', BI.RichEditorSizeChooser);/**
* 富文本编辑器 * 富文本编辑器
* *

786
dist/bundle.js vendored

@ -29243,150 +29243,6 @@ $(function () {
} }
}));/** }));/**
* jQuery "splendid textchange" plugin
* http://benalpert.com/2013/06/18/a-near-perfect-oninput-shim-for-ie-8-and-9.html
*
* (c) 2013 Ben Alpert, released under the MIT license
*/
(function($) {
var testNode = document.createElement("input");
var isInputSupported = "oninput" in testNode &&
(!("documentMode" in document) || document.documentMode > 9);
var hasInputCapabilities = function(elem) {
// The HTML5 spec lists many more types than `text` and `password` on
// which the input event is triggered but none of them exist in IE 8 or
// 9, so we don't check them here.
// TODO: <textarea> should be supported too but IE seems to reset the
// selection when changing textarea contents during a selectionchange
// event so it's not listed here for now.
return elem.nodeName === "INPUT" &&
(elem.type === "text" || elem.type === "password");
};
var activeElement = null;
var activeElementValue = null;
var activeElementValueProp = null;
/**
* (For old IE.) Replacement getter/setter for the `value` property that
* gets set on the active element.
*/
var newValueProp = {
get: function() {
return activeElementValueProp.get.call(this);
},
set: function(val) {
activeElementValue = val;
activeElementValueProp.set.call(this, val);
}
};
/**
* (For old IE.) Starts tracking propertychange events on the passed-in element
* and override the value property so that we can distinguish user events from
* value changes in JS.
*/
var startWatching = function(target) {
activeElement = target;
activeElementValue = target.value;
activeElementValueProp = Object.getOwnPropertyDescriptor(
target.constructor.prototype, "value");
Object.defineProperty(activeElement, "value", newValueProp);
activeElement.attachEvent("onpropertychange", handlePropertyChange);
};
/**
* (For old IE.) Removes the event listeners from the currently-tracked
* element, if any exists.
*/
var stopWatching = function() {
if (!activeElement) return;
// delete restores the original property definition
delete activeElement.value;
activeElement.detachEvent("onpropertychange", handlePropertyChange);
activeElement = null;
activeElementValue = null;
activeElementValueProp = null;
};
/**
* (For old IE.) Handles a propertychange event, sending a textChange event if
* the value of the active element has changed.
*/
var handlePropertyChange = function(nativeEvent) {
if (nativeEvent.propertyName !== "value") return;
var value = nativeEvent.srcElement.value;
if (value === activeElementValue) return;
activeElementValue = value;
$(activeElement).trigger("textchange");
};
if (isInputSupported) {
$(document)
.on("input", function(e) {
// In modern browsers (i.e., not IE 8 or 9), the input event is
// exactly what we want so fall through here and trigger the
// event...
if (e.target.nodeName !== "TEXTAREA") {
// ...unless it's a textarea, in which case we don't fire an
// event (so that we have consistency with our old-IE shim).
$(e.target).trigger("textchange");
}
});
} else {
$(document)
.on("focusin", function(e) {
// In IE 8, we can capture almost all .value changes by adding a
// propertychange handler and looking for events with propertyName
// equal to 'value'.
// In IE 9, propertychange fires for most input events but is buggy
// and doesn't fire when text is deleted, but conveniently,
// selectionchange appears to fire in all of the remaining cases so
// we catch those and forward the event if the value has changed.
// In either case, we don't want to call the event handler if the
// value is changed from JS so we redefine a setter for `.value`
// that updates our activeElementValue variable, allowing us to
// ignore those changes.
if (hasInputCapabilities(e.target)) {
// stopWatching() should be a noop here but we call it just in
// case we missed a blur event somehow.
stopWatching();
startWatching(e.target);
}
})
.on("focusout", function() {
stopWatching();
})
.on("selectionchange keyup keydown", function() {
// On the selectionchange event, e.target is just document which
// isn't helpful for us so just check activeElement instead.
//
// 90% of the time, keydown and keyup aren't necessary. IE 8 fails
// to fire propertychange on the first input event after setting
// `value` from a script and fires only keydown, keypress, keyup.
// Catching keyup usually gets it and catching keydown lets us fire
// an event for the first keystroke if user does a key repeat
// (it'll be a little delayed: right before the second keystroke).
// Other input methods (e.g., paste) seem to fire selectionchange
// normally.
if (activeElement && activeElement.value !== activeElementValue) {
activeElementValue = activeElement.value;
$(activeElement).trigger("textchange");
}
});
}
})(jQuery);/**
* 当没有元素时有提示信息的view * 当没有元素时有提示信息的view
* *
* Created by GUY on 2015/9/8. * Created by GUY on 2015/9/8.
@ -45454,68 +45310,68 @@ BI.RichEditorParamAction = BI.inherit(BI.RichEditorAction, {
key: function (e) { key: function (e) {
} }
});/** });/**
* 颜色选择 * 颜色选择
* *
* Created by GUY on 2015/11/26. * Created by GUY on 2015/11/26.
* @class BI.RichEditorTextToolbar * @class BI.RichEditorTextToolbar
* @extends BI.Widget * @extends BI.Widget
*/ */
BI.RichEditorTextToolbar = BI.inherit(BI.Widget, { BI.RichEditorTextToolbar = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.RichEditorTextToolbar.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.RichEditorTextToolbar.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-rich-editor-text-toolbar bi-background", baseCls: "bi-rich-editor-text-toolbar bi-background",
buttons: [ buttons: [
{type: "bi.rich_editor_size_chooser"}, {type: "bi.rich_editor_size_chooser"},
{type: "bi.rich_editor_bold_button"}, {type: "bi.rich_editor_bold_button"},
{type: "bi.rich_editor_italic_button"}, {type: "bi.rich_editor_italic_button"},
{type: "bi.rich_editor_underline_button"}, {type: "bi.rich_editor_underline_button"},
{type: "bi.rich_editor_color_chooser"}, {type: "bi.rich_editor_color_chooser"},
{type: "bi.rich_editor_background_color_chooser"}, {type: "bi.rich_editor_background_color_chooser"},
{type: "bi.rich_editor_align_left_button"}, {type: "bi.rich_editor_align_left_button"},
{type: "bi.rich_editor_align_center_button"}, {type: "bi.rich_editor_align_center_button"},
{type: "bi.rich_editor_align_right_button"}, {type: "bi.rich_editor_align_right_button"},
{type: "bi.rich_editor_param_button"}, {type: "bi.rich_editor_param_button"},
], ],
height: 28 height: 28
}); });
}, },
_init: function () { _init: function () {
BI.RichEditorTextToolbar.superclass._init.apply(this, arguments); BI.RichEditorTextToolbar.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
BI.createWidget({ BI.createWidget({
type: "bi.left", type: "bi.left",
element: this, element: this,
items: BI.map(o.buttons, function (i, btn) { items: BI.map(o.buttons, function (i, btn) {
return BI.extend(btn, { return BI.extend(btn, {
editor: o.editor editor: o.editor
}); });
}), }),
hgap: 3, hgap: 3,
vgap: 3 vgap: 3
}) })
}, },
mounted: function () { mounted: function () {
var self = this; var self = this;
if (BI.isIE9Below()) {//IE8下必须要设置unselectable才能不blur输入框 if (BI.isIE9Below()) {//IE8下必须要设置unselectable才能不blur输入框
this.element.mousedown(function () { this.element.mousedown(function () {
self._noSelect(self.element[0]); self._noSelect(self.element[0]);
}); });
this._noSelect(this.element[0]); this._noSelect(this.element[0]);
} }
}, },
_noSelect: function (element) { _noSelect: function (element) {
if (element.setAttribute && element.nodeName.toLowerCase() != 'input' && element.nodeName.toLowerCase() != 'textarea') { if (element.setAttribute && element.nodeName.toLowerCase() != 'input' && element.nodeName.toLowerCase() != 'textarea') {
element.setAttribute('unselectable', 'on'); element.setAttribute('unselectable', 'on');
} }
for (var i = 0; i < element.childNodes.length; i++) { for (var i = 0; i < element.childNodes.length; i++) {
this._noSelect(element.childNodes[i]); this._noSelect(element.childNodes[i]);
} }
} }
}); });
BI.shortcut('bi.rich_editor_text_toolbar', BI.RichEditorTextToolbar);/** BI.shortcut('bi.rich_editor_text_toolbar', BI.RichEditorTextToolbar);/**
* 富文本编辑器 * 富文本编辑器
* *
@ -45796,57 +45652,57 @@ BI.shortcut('bi.rich_editor_text_toolbar', BI.RichEditorTextToolbar);/**
} }
}); });
}()); }());
/** /**
* 颜色选择trigger * 颜色选择trigger
* *
* Created by GUY on 2015/11/26. * Created by GUY on 2015/11/26.
* @class BI.RichEditorBackgroundChooserTrigger * @class BI.RichEditorBackgroundChooserTrigger
* @extends BI.Widget * @extends BI.Widget
*/ */
BI.RichEditorBackgroundChooserTrigger = BI.inherit(BI.Widget, { BI.RichEditorBackgroundChooserTrigger = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.RichEditorBackgroundChooserTrigger.superclass._defaultConfig.apply(this, arguments); var conf = BI.RichEditorBackgroundChooserTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
width: 20, width: 20,
height: 20 height: 20
}); });
}, },
_init: function () { _init: function () {
BI.RichEditorBackgroundChooserTrigger.superclass._init.apply(this, arguments); BI.RichEditorBackgroundChooserTrigger.superclass._init.apply(this, arguments);
this.font = BI.createWidget({ this.font = BI.createWidget({
type: "bi.icon_button", type: "bi.icon_button",
cls: "text-background-font" cls: "text-background-font"
}); });
this.underline = BI.createWidget({ this.underline = BI.createWidget({
type: "bi.icon_button", type: "bi.icon_button",
cls: "text-color-underline-font" cls: "text-color-underline-font"
}); });
BI.createWidget({ BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
element: this, element: this,
items: [{ items: [{
el: this.font, el: this.font,
top: 2, top: 2,
left: 2 left: 2
}, { }, {
el: this.underline, el: this.underline,
top: 7, top: 7,
left: 2 left: 2
}] }]
}) })
}, },
setValue: function (color) { setValue: function (color) {
this.underline.element.css("color", color); this.underline.element.css("color", color);
}, },
getValue: function () { getValue: function () {
return this.font.element.css("color"); return this.font.element.css("color");
} }
}); });
BI.shortcut('bi.rich_editor_background_color_chooser_trigger', BI.RichEditorBackgroundChooserTrigger);/** BI.shortcut('bi.rich_editor_background_color_chooser_trigger', BI.RichEditorBackgroundChooserTrigger);/**
* *
* Created by GUY on 2015/11/26. * Created by GUY on 2015/11/26.
@ -46114,214 +45970,214 @@ BI.RichEditorUnderlineButton = BI.inherit(BI.RichEditorAction, {
this.underline.setSelected(false); this.underline.setSelected(false);
}, },
}); });
BI.shortcut("bi.rich_editor_underline_button", BI.RichEditorUnderlineButton)/** BI.shortcut("bi.rich_editor_underline_button", BI.RichEditorUnderlineButton)/**
* 颜色选择trigger * 颜色选择trigger
* *
* Created by GUY on 2015/11/26. * Created by GUY on 2015/11/26.
* @class BI.RichEditorColorChooserTrigger * @class BI.RichEditorColorChooserTrigger
* @extends BI.Widget * @extends BI.Widget
*/ */
BI.RichEditorColorChooserTrigger = BI.inherit(BI.Widget, { BI.RichEditorColorChooserTrigger = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
var conf = BI.RichEditorColorChooserTrigger.superclass._defaultConfig.apply(this, arguments); var conf = BI.RichEditorColorChooserTrigger.superclass._defaultConfig.apply(this, arguments);
return BI.extend(conf, { return BI.extend(conf, {
width: 20, width: 20,
height: 20 height: 20
}); });
}, },
_init: function () { _init: function () {
BI.RichEditorColorChooserTrigger.superclass._init.apply(this, arguments); BI.RichEditorColorChooserTrigger.superclass._init.apply(this, arguments);
this.font = BI.createWidget({ this.font = BI.createWidget({
type: "bi.icon_button", type: "bi.icon_button",
cls: "text-color-font" cls: "text-color-font"
}); });
this.underline = BI.createWidget({ this.underline = BI.createWidget({
type: "bi.icon_button", type: "bi.icon_button",
cls: "text-color-underline-font" cls: "text-color-underline-font"
}); });
BI.createWidget({ BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
element: this, element: this,
items: [{ items: [{
el: this.font, el: this.font,
top: 2, top: 2,
left: 2 left: 2
}, { }, {
el: this.underline, el: this.underline,
top: 7, top: 7,
left: 2 left: 2
}] }]
}) })
}, },
setValue: function (color) { setValue: function (color) {
this.underline.element.css("color", color); this.underline.element.css("color", color);
}, },
getValue: function () { getValue: function () {
return this.font.element.css("color"); return this.font.element.css("color");
} }
}); });
BI.shortcut('bi.rich_editor_color_chooser_trigger', BI.RichEditorColorChooserTrigger);/** BI.shortcut('bi.rich_editor_color_chooser_trigger', BI.RichEditorColorChooserTrigger);/**
* 颜色选择 * 颜色选择
* *
* Created by GUY on 2015/11/26. * Created by GUY on 2015/11/26.
* @class BI.RichEditorBackgroundColorChooser * @class BI.RichEditorBackgroundColorChooser
* @extends BI.RichEditorAction * @extends BI.RichEditorAction
*/ */
BI.RichEditorBackgroundColorChooser = BI.inherit(BI.RichEditorAction, { BI.RichEditorBackgroundColorChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.RichEditorBackgroundColorChooser.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.RichEditorBackgroundColorChooser.superclass._defaultConfig.apply(this, arguments), {
width: 20, width: 20,
height: 20, height: 20,
}); });
}, },
_init: function () { _init: function () {
BI.RichEditorBackgroundColorChooser.superclass._init.apply(this, arguments); BI.RichEditorBackgroundColorChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.colorchooser = BI.createWidget({ this.colorchooser = BI.createWidget({
type: "bi.color_chooser", type: "bi.color_chooser",
element: this, element: this,
width: o.width, width: o.width,
height: o.height, height: o.height,
el: { el: {
type: "bi.rich_editor_background_color_chooser_trigger", type: "bi.rich_editor_background_color_chooser_trigger",
title: BI.i18nText("BI-Widget_Background_Colour"), title: BI.i18nText("BI-Widget_Background_Colour"),
cls: "text-toolbar-button" cls: "text-toolbar-button"
} }
}); });
this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () { this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () {
var backgroundColor = this.getValue(); var backgroundColor = this.getValue();
o.editor.element.css({ o.editor.element.css({
backgroundColor: backgroundColor, backgroundColor: backgroundColor,
color: BI.DOM.getContrastColor(backgroundColor) color: BI.DOM.getContrastColor(backgroundColor)
}); });
this.setValue(""); this.setValue("");
}); });
}, },
deactivate: function () { deactivate: function () {
} }
}); });
BI.shortcut('bi.rich_editor_background_color_chooser', BI.RichEditorBackgroundColorChooser);/** BI.shortcut('bi.rich_editor_background_color_chooser', BI.RichEditorBackgroundColorChooser);/**
* 颜色选择 * 颜色选择
* *
* Created by GUY on 2015/11/26. * Created by GUY on 2015/11/26.
* @class BI.RichEditorColorChooser * @class BI.RichEditorColorChooser
* @extends BI.RichEditorAction * @extends BI.RichEditorAction
*/ */
BI.RichEditorColorChooser = BI.inherit(BI.RichEditorAction, { BI.RichEditorColorChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.RichEditorColorChooser.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.RichEditorColorChooser.superclass._defaultConfig.apply(this, arguments), {
width: 20, width: 20,
height: 20, height: 20,
command: "foreColor" command: "foreColor"
}); });
}, },
_init: function () { _init: function () {
BI.RichEditorColorChooser.superclass._init.apply(this, arguments); BI.RichEditorColorChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.colorchooser = BI.createWidget({ this.colorchooser = BI.createWidget({
type: "bi.color_chooser", type: "bi.color_chooser",
element: this, element: this,
width: o.width, width: o.width,
height: o.height, height: o.height,
el: { el: {
type: "bi.rich_editor_color_chooser_trigger", type: "bi.rich_editor_color_chooser_trigger",
title: BI.i18nText("BI-Font_Colour"), title: BI.i18nText("BI-Font_Colour"),
cls: "text-toolbar-button" cls: "text-toolbar-button"
} }
}); });
this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () { this.colorchooser.on(BI.ColorChooser.EVENT_CHANGE, function () {
self.doCommand(this.getValue()); self.doCommand(this.getValue());
}); });
}, },
deactivate: function () { deactivate: function () {
this.colorchooser.setValue(""); this.colorchooser.setValue("");
} }
}); });
BI.shortcut('bi.rich_editor_color_chooser', BI.RichEditorColorChooser);/** BI.shortcut('bi.rich_editor_color_chooser', BI.RichEditorColorChooser);/**
* 字体大小选择 * 字体大小选择
* *
* Created by GUY on 2015/11/26. * Created by GUY on 2015/11/26.
* @class BI.RichEditorSizeChooser * @class BI.RichEditorSizeChooser
* @extends BI.RichEditorAction * @extends BI.RichEditorAction
*/ */
BI.RichEditorSizeChooser = BI.inherit(BI.RichEditorAction, { BI.RichEditorSizeChooser = BI.inherit(BI.RichEditorAction, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.RichEditorSizeChooser.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.RichEditorSizeChooser.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-rich-editor-size-chooser bi-border bi-card", baseCls: "bi-rich-editor-size-chooser bi-border bi-card",
command: "FontSize", command: "FontSize",
width: 50, width: 50,
height: 20 height: 20
}); });
}, },
_items: [{ _items: [{
value: 1, value: 1,
text: "1(8pt)" text: "1(8pt)"
}, { }, {
value: 2, value: 2,
text: "2(10pt)" text: "2(10pt)"
}, { }, {
value: 3, value: 3,
text: "3(12pt)" text: "3(12pt)"
}, { }, {
value: 4, value: 4,
text: "4(14pt)" text: "4(14pt)"
}, { }, {
value: 5, value: 5,
text: "5(18pt)" text: "5(18pt)"
}, { }, {
value: 6, value: 6,
text: "6(24pt)" text: "6(24pt)"
}], }],
_init: function () { _init: function () {
BI.RichEditorSizeChooser.superclass._init.apply(this, arguments); BI.RichEditorSizeChooser.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.trigger = BI.createWidget({ this.trigger = BI.createWidget({
type: "bi.text_trigger", type: "bi.text_trigger",
readonly: true, readonly: true,
height: o.height, height: o.height,
triggerWidth: 12, triggerWidth: 12,
text: BI.i18nText("BI-Font_Size") text: BI.i18nText("BI-Font_Size")
}); });
this.combo = BI.createWidget({ this.combo = BI.createWidget({
type: "bi.combo", type: "bi.combo",
element: this, element: this,
el: this.trigger, el: this.trigger,
adjustLength: 1, adjustLength: 1,
popup: { popup: {
maxWidth: 70, maxWidth: 70,
minWidth: 70, minWidth: 70,
el: { el: {
type: "bi.button_group", type: "bi.button_group",
items: BI.createItems(this._items, { items: BI.createItems(this._items, {
type: "bi.single_select_item" type: "bi.single_select_item"
}), }),
layouts: [{ layouts: [{
type: "bi.vertical" type: "bi.vertical"
}] }]
} }
} }
}); });
this.combo.on(BI.Combo.EVENT_CHANGE, function () { this.combo.on(BI.Combo.EVENT_CHANGE, function () {
var val = this.getValue()[0]; var val = this.getValue()[0];
self.doCommand(val); self.doCommand(val);
this.hideView(); this.hideView();
this.setValue([]); this.setValue([]);
}) })
} }
}); });
BI.shortcut('bi.rich_editor_size_chooser', BI.RichEditorSizeChooser);/** BI.shortcut('bi.rich_editor_size_chooser', BI.RichEditorSizeChooser);/**
* 富文本编辑器 * 富文本编辑器
* *

72
dist/bundle.min.js vendored

File diff suppressed because one or more lines are too long

2410
dist/demo.js vendored

File diff suppressed because it is too large Load Diff

42
dist/sliders.css vendored

@ -24,27 +24,15 @@
-moz-border-radius: 7px; -moz-border-radius: 7px;
border-radius: 7px; border-radius: 7px;
} }
.bi-single-slider-button .slider-button { .bi-single-slider-button .slider-button {
cursor: ew-resize; cursor: ew-resize;
-webkit-box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); -webkit-box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
-moz-box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); -moz-box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
-webkit-border-radius: 7px; -webkit-border-radius: 7px;
-moz-border-radius: 7px; -moz-border-radius: 7px;
border-radius: 7px; border-radius: 7px;
} }
.bi-slider-track .gray-track {
background-color: rgba(153, 153, 153, 0.3);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#4d999999,endColorstr=#4d999999);
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
.bi-slider-track .blue-track {
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
.bi-slider-track .gray-track { .bi-slider-track .gray-track {
background-color: rgba(153, 153, 153, 0.3); background-color: rgba(153, 153, 153, 0.3);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#4d999999,endColorstr=#4d999999); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#4d999999,endColorstr=#4d999999);
@ -57,3 +45,15 @@
-moz-border-radius: 3px; -moz-border-radius: 3px;
border-radius: 3px; border-radius: 3px;
} }
.bi-slider-track .gray-track {
background-color: rgba(153, 153, 153, 0.3);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#4d999999,endColorstr=#4d999999);
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
.bi-slider-track .blue-track {
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}

145
src/third/jquery.splendid.textchange.js

@ -1,145 +0,0 @@
/**
* jQuery "splendid textchange" plugin
* http://benalpert.com/2013/06/18/a-near-perfect-oninput-shim-for-ie-8-and-9.html
*
* (c) 2013 Ben Alpert, released under the MIT license
*/
(function($) {
var testNode = document.createElement("input");
var isInputSupported = "oninput" in testNode &&
(!("documentMode" in document) || document.documentMode > 9);
var hasInputCapabilities = function(elem) {
// The HTML5 spec lists many more types than `text` and `password` on
// which the input event is triggered but none of them exist in IE 8 or
// 9, so we don't check them here.
// TODO: <textarea> should be supported too but IE seems to reset the
// selection when changing textarea contents during a selectionchange
// event so it's not listed here for now.
return elem.nodeName === "INPUT" &&
(elem.type === "text" || elem.type === "password");
};
var activeElement = null;
var activeElementValue = null;
var activeElementValueProp = null;
/**
* (For old IE.) Replacement getter/setter for the `value` property that
* gets set on the active element.
*/
var newValueProp = {
get: function() {
return activeElementValueProp.get.call(this);
},
set: function(val) {
activeElementValue = val;
activeElementValueProp.set.call(this, val);
}
};
/**
* (For old IE.) Starts tracking propertychange events on the passed-in element
* and override the value property so that we can distinguish user events from
* value changes in JS.
*/
var startWatching = function(target) {
activeElement = target;
activeElementValue = target.value;
activeElementValueProp = Object.getOwnPropertyDescriptor(
target.constructor.prototype, "value");
Object.defineProperty(activeElement, "value", newValueProp);
activeElement.attachEvent("onpropertychange", handlePropertyChange);
};
/**
* (For old IE.) Removes the event listeners from the currently-tracked
* element, if any exists.
*/
var stopWatching = function() {
if (!activeElement) return;
// delete restores the original property definition
delete activeElement.value;
activeElement.detachEvent("onpropertychange", handlePropertyChange);
activeElement = null;
activeElementValue = null;
activeElementValueProp = null;
};
/**
* (For old IE.) Handles a propertychange event, sending a textChange event if
* the value of the active element has changed.
*/
var handlePropertyChange = function(nativeEvent) {
if (nativeEvent.propertyName !== "value") return;
var value = nativeEvent.srcElement.value;
if (value === activeElementValue) return;
activeElementValue = value;
$(activeElement).trigger("textchange");
};
if (isInputSupported) {
$(document)
.on("input", function(e) {
// In modern browsers (i.e., not IE 8 or 9), the input event is
// exactly what we want so fall through here and trigger the
// event...
if (e.target.nodeName !== "TEXTAREA") {
// ...unless it's a textarea, in which case we don't fire an
// event (so that we have consistency with our old-IE shim).
$(e.target).trigger("textchange");
}
});
} else {
$(document)
.on("focusin", function(e) {
// In IE 8, we can capture almost all .value changes by adding a
// propertychange handler and looking for events with propertyName
// equal to 'value'.
// In IE 9, propertychange fires for most input events but is buggy
// and doesn't fire when text is deleted, but conveniently,
// selectionchange appears to fire in all of the remaining cases so
// we catch those and forward the event if the value has changed.
// In either case, we don't want to call the event handler if the
// value is changed from JS so we redefine a setter for `.value`
// that updates our activeElementValue variable, allowing us to
// ignore those changes.
if (hasInputCapabilities(e.target)) {
// stopWatching() should be a noop here but we call it just in
// case we missed a blur event somehow.
stopWatching();
startWatching(e.target);
}
})
.on("focusout", function() {
stopWatching();
})
.on("selectionchange keyup keydown", function() {
// On the selectionchange event, e.target is just document which
// isn't helpful for us so just check activeElement instead.
//
// 90% of the time, keydown and keyup aren't necessary. IE 8 fails
// to fire propertychange on the first input event after setting
// `value` from a script and fires only keydown, keypress, keyup.
// Catching keyup usually gets it and catching keydown lets us fire
// an event for the first keystroke if user does a key repeat
// (it'll be a little delayed: right before the second keystroke).
// Other input methods (e.g., paste) seem to fire selectionchange
// normally.
if (activeElement && activeElement.value !== activeElementValue) {
activeElementValue = activeElement.value;
$(activeElement).trigger("textchange");
}
});
}
})(jQuery);
Loading…
Cancel
Save