Skip to content

Commit 2a14691

Browse files
committed
Update Changelog and dist files
1 parent ebbd973 commit 2a14691

File tree

3 files changed

+45
-16
lines changed

3 files changed

+45
-16
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#### Bugfixes
1515

1616
- Remove range.detach() [#73](https://github.com/upfrontIO/editable.js/pull/73)
17+
- Separate instance and global configuration. Fixes [#75](https://github.com/upfrontIO/editable.js/issues/75)
1718

1819

1920
# v0.3.2 (2014-06-11)

editable.js

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3452,12 +3452,25 @@ var string = (function() {
34523452
* first in editable.prefix in order for it to be the only externally visible
34533453
* variable.
34543454
*
3455+
* @param {Object} configuration for this editable instance.
3456+
* window: The window where to attach the editable events.
3457+
* defaultBehavior: {Boolean} Load default-behavior.js.
3458+
* mouseMoveSelectionChanges: {Boolean} Whether to get cursor and selection events on mousemove.
3459+
* browserSpellcheck: {Boolean} Set the spellcheck attribute on editable elements
3460+
*
34553461
* @class Editable
34563462
*/
3457-
Editable = function(userConfig) {
3458-
this.config = $.extend(true, {}, config, userConfig);
3459-
this.win = this.config.window || window;
3460-
this.editableSelector = '.' + this.config.editableClass;
3463+
Editable = function(instanceConfig) {
3464+
var defaultInstanceConfig = {
3465+
window: window,
3466+
defaultBehavior: true,
3467+
mouseMoveSelectionChanges: false,
3468+
browserSpellcheck: true
3469+
};
3470+
3471+
this.config = $.extend(defaultInstanceConfig, instanceConfig);
3472+
this.win = this.config.window;
3473+
this.editableSelector = '.' + config.editableClass;
34613474

34623475
if (!rangy.initialized) {
34633476
rangy.init();
@@ -3469,6 +3482,25 @@ Editable = function(userConfig) {
34693482
}
34703483
};
34713484

3485+
3486+
/**
3487+
* Set configuration options that affect all editable
3488+
* instances.
3489+
*
3490+
* @param {Object} global configuration options (defaults are defined in config.js)
3491+
* log: {Boolean}
3492+
* logErrors: {Boolean}
3493+
* editableClass: {String} e.g. 'js-editable'
3494+
* editableDisabledClass: {String} e.g. 'js-editable-disabled'
3495+
* pastingAttribute: {String} default: e.g. 'data-editable-is-pasting'
3496+
* boldTag: e.g. '<strong>'
3497+
* italicTag: e.g. '<em>'
3498+
*/
3499+
Editable.globalConfig = function(globalConfig) {
3500+
$.extend(config, globalConfig);
3501+
};
3502+
3503+
34723504
/**
34733505
* Adds the Editable.JS API to the given target elements.
34743506
* Opposite of {{#crossLink "Editable/remove"}}{{/crossLink}}.
@@ -3478,14 +3510,10 @@ Editable = function(userConfig) {
34783510
* @param {HTMLElement|Array(HTMLElement)|String} target A HTMLElement, an
34793511
* array of HTMLElement or a query selector representing the target where
34803512
* the API should be added on.
3481-
* @param {Object} [elementConfiguration={}] Configuration options override.
34823513
* @chainable
34833514
*/
3484-
Editable.prototype.add = function(target, elementConfiguration) {
3485-
var elemConfig = $.extend(true, {}, config, elementConfiguration);
3486-
// todo: store element configuration
3515+
Editable.prototype.add = function(target) {
34873516
this.enable($(target));
3488-
34893517
// todo: check css whitespace settings
34903518
return this;
34913519
};
@@ -3523,6 +3551,7 @@ Editable.prototype.disable = function($elem) {
35233551
$elem = $elem || $('.' + config.editableClass, body);
35243552
$elem
35253553
.removeAttr('contenteditable')
3554+
.removeAttr('spellcheck')
35263555
.removeClass(config.editableClass)
35273556
.addClass(config.editableDisabledClass);
35283557

@@ -3544,6 +3573,7 @@ Editable.prototype.enable = function($elem, normalize) {
35443573
$elem = $elem || $('.' + config.editableDisabledClass, body);
35453574
$elem
35463575
.attr('contenteditable', true)
3576+
.attr('spellcheck', this.config.browserSpellcheck)
35473577
.removeClass(config.editableDisabledClass)
35483578
.addClass(config.editableClass);
35493579

@@ -3811,10 +3841,8 @@ var config = {
38113841
editableClass: 'js-editable',
38123842
editableDisabledClass: 'js-editable-disabled',
38133843
pastingAttribute: 'data-editable-is-pasting',
3814-
mouseMoveSelectionChanges: false,
38153844
boldTag: '<strong>',
3816-
italicTag: '<em>',
3817-
defaultBehavior: true
3845+
italicTag: '<em>'
38183846
};
38193847

38203848

@@ -4959,10 +4987,10 @@ Dispatcher.prototype.unload = function() {
49594987
Dispatcher.prototype.setupElementEvents = function() {
49604988
var _this = this;
49614989
this.$document.on('focus.editable', _this.editableSelector, function(event) {
4962-
if (this.getAttribute(_this.config.pastingAttribute)) return;
4990+
if (this.getAttribute(config.pastingAttribute)) return;
49634991
_this.notify('focus', this);
49644992
}).on('blur.editable', _this.editableSelector, function(event) {
4965-
if (this.getAttribute(_this.config.pastingAttribute)) return;
4993+
if (this.getAttribute(config.pastingAttribute)) return;
49664994
_this.notify('blur', this);
49674995
}).on('copy.editable', _this.editableSelector, function(event) {
49684996
log('Copy');

0 commit comments

Comments
 (0)