Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deprecate several jquery-esque event aliases #831

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions src/lib/SCEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,17 @@ export default function SCEditor(original, userOptions) {
autoUpdate,
autoExpand;

/**
* @param {string} oldFnName
* @param {string} newFnName
*/
var logDeprecated = function (oldFnName, newFnName) {
console.warn('WARNING! Obsolete function called. Function `'
+ oldFnName + '` has been deprecated, use `'
+ newFnName + '` instead!');
console.trace();
};

/**
* All the commands supported by the editor
* @name commands
Expand Down Expand Up @@ -2742,9 +2753,13 @@ export default function SCEditor(original, userOptions) {
* @name blur^2
* @memberOf SCEditor.prototype
* @since 1.4.1
* @deprecated since v3.1.0 and will be removed in v4.0.0
*/
base.blur = function (handler, excludeWysiwyg, excludeSource) {
if (utils.isFunction(handler)) {
logDeprecated(
'instance.blur(handler)',
'instance.bind("blur", handler)');
base.bind('blur', handler, excludeWysiwyg, excludeSource);
} else if (!base.sourceMode()) {
wysiwygBody.blur();
Expand Down Expand Up @@ -2776,9 +2791,13 @@ export default function SCEditor(original, userOptions) {
* @name focus^2
* @memberOf SCEditor.prototype
* @since 1.4.1
* @deprecated since v3.1.0 and will be removed in v4.0.0
*/
base.focus = function (handler, excludeWysiwyg, excludeSource) {
if (utils.isFunction(handler)) {
logDeprecated(
'instance.focus(handler)',
'instance.bind("focus", handler)');
base.bind('focus', handler, excludeWysiwyg, excludeSource);
} else if (!base.inSourceMode()) {
// Already has focus so do nothing
Expand Down Expand Up @@ -2833,8 +2852,12 @@ export default function SCEditor(original, userOptions) {
* @name keyDown
* @memberOf SCEditor.prototype
* @since 1.4.1
* @deprecated since v3.1.0 and will be removed in v4.0.0
*/
base.keyDown = function (handler, excludeWysiwyg, excludeSource) {
logDeprecated(
'instance.keyDown(handler)',
'instance.bind("keydown", handler)');
return base.bind('keydown', handler, excludeWysiwyg, excludeSource);
};

Expand All @@ -2851,8 +2874,12 @@ export default function SCEditor(original, userOptions) {
* @name keyPress
* @memberOf SCEditor.prototype
* @since 1.4.1
* @deprecated since v3.1.0 and will be removed in v4.0.0
*/
base.keyPress = function (handler, excludeWysiwyg, excludeSource) {
logDeprecated(
'instance.keyPress(handler)',
'instance.bind("keypress", handler)');
return base
.bind('keypress', handler, excludeWysiwyg, excludeSource);
};
Expand All @@ -2870,8 +2897,12 @@ export default function SCEditor(original, userOptions) {
* @name keyUp
* @memberOf SCEditor.prototype
* @since 1.4.1
* @deprecated since v3.1.0 and will be removed in v4.0.0
*/
base.keyUp = function (handler, excludeWysiwyg, excludeSource) {
logDeprecated(
'instance.keyUp(handler)',
'instance.bind("keyup", handler)');
return base.bind('keyup', handler, excludeWysiwyg, excludeSource);
};

Expand All @@ -2887,8 +2918,12 @@ export default function SCEditor(original, userOptions) {
* @name nodeChanged
* @memberOf SCEditor.prototype
* @since 1.4.1
* @deprecated since v3.1.0 and will be removed in v4.0.0
*/
base.nodeChanged = function (handler) {
logDeprecated(
'instance.nodeChanged(handler)',
'instance.bind("nodechanged", handler)');
return base.bind('nodechanged', handler, false, true);
};

Expand All @@ -2903,8 +2938,12 @@ export default function SCEditor(original, userOptions) {
* @name selectionChanged
* @memberOf SCEditor.prototype
* @since 1.4.1
* @deprecated since v3.1.0 and will be removed in v4.0.0
*/
base.selectionChanged = function (handler) {
logDeprecated(
'instance.selectionChanged(handler)',
'instance.bind("selectionchanged", handler)');
return base.bind('selectionchanged', handler, false, true);
};

Expand All @@ -2928,8 +2967,12 @@ export default function SCEditor(original, userOptions) {
* @name valueChanged
* @memberOf SCEditor.prototype
* @since 1.4.5
* @deprecated since v3.1.0 and will be removed in v4.0.0
*/
base.valueChanged = function (handler, excludeWysiwyg, excludeSource) {
logDeprecated(
'instance.valueChanged(handler)',
'instance.bind("valuechanged", handler)');
return base
.bind('valuechanged', handler, excludeWysiwyg, excludeSource);
};
Expand Down