Skip to content

Commit

Permalink
Merge pull request mycolorway#290 from mycolorway/rc-fix-containerNode
Browse files Browse the repository at this point in the history
Rc fix container
  • Loading branch information
farthinker committed Jul 31, 2015
2 parents 4e3654a + f4fe48f commit 8372b7f
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 67 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simditor",
"version": "2.2.0",
"version": "2.2.1",
"homepage": "http://simditor.tower.im/",
"authors": [
"farthinker <[email protected]>"
Expand Down
14 changes: 7 additions & 7 deletions lib/simditor.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
* Simditor v2.2.0
* Simditor v2.2.1
* http://simditor.tower.im/
* 2015-07-28
* 2015-07-31
*/
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
Expand Down Expand Up @@ -2167,7 +2167,7 @@ Indentation = (function(superClass) {
return;
}
if ($blockEl.is('pre')) {
$pre = this.editor.selection.containerNode;
$pre = this.editor.selection.containerNode();
if (!($pre.is($blockEl) || $pre.closest('pre').is($blockEl))) {
return;
}
Expand All @@ -2191,7 +2191,7 @@ Indentation = (function(superClass) {
marginLeft = (Math.round(marginLeft / this.opts.indentWidth) + 1) * this.opts.indentWidth;
$blockEl.css('margin-left', marginLeft);
} else if ($blockEl.is('table') || $blockEl.is('.simditor-table')) {
$td = this.editor.selection.containerNode.closest('td, th');
$td = this.editor.selection.containerNode().closest('td, th');
$nextTd = $td.next('td, th');
if (!($nextTd.length > 0)) {
$tr = $td.parent('tr');
Expand Down Expand Up @@ -2232,7 +2232,7 @@ Indentation = (function(superClass) {
return;
}
if ($blockEl.is('pre')) {
$pre = this.editor.selection.containerNode;
$pre = this.editor.selection.containerNode();
if (!($pre.is($blockEl) || $pre.closest('pre').is($blockEl))) {
return;
}
Expand Down Expand Up @@ -2263,7 +2263,7 @@ Indentation = (function(superClass) {
marginLeft = Math.max(Math.round(marginLeft / this.opts.indentWidth) - 1, 0) * this.opts.indentWidth;
$blockEl.css('margin-left', marginLeft === 0 ? '' : marginLeft);
} else if ($blockEl.is('table') || $blockEl.is('.simditor-table')) {
$td = this.editor.selection.containerNode.closest('td, th');
$td = this.editor.selection.containerNode().closest('td, th');
$prevTd = $td.prev('td, th');
if (!($prevTd.length > 0)) {
$tr = $td.parent('tr');
Expand Down Expand Up @@ -5054,7 +5054,7 @@ TableButton = (function(superClass) {

TableButton.prototype.command = function(param) {
var $td;
$td = this.editor.selection.containerNode.closest('td, th');
$td = this.editor.selection.containerNode().closest('td, th');
if (!($td.length > 0)) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simditor",
"version": "2.2.0",
"version": "2.2.1",
"description": "A simple online editor",
"keywords": "editor simditor",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion site/assets/scripts/hotkeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory(require("jquery"),require("simplemodule"));
module.exports = factory(require("jquery"),require("simple-module"));
} else {
root.simple = root.simple || {};
root.simple['hotkeys'] = factory(jQuery,SimpleModule);
Expand Down
84 changes: 41 additions & 43 deletions site/assets/scripts/module.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define('simple-module', ["jquery"], function ($) {
return (root.returnExportsGlobal = factory($));
// AMD. Register as an anonymous module unless amdModuleId is set
define('simple-module', ["jquery"], function (a0) {
return (root['Module'] = factory(a0));
});
} else if (typeof exports === 'object') {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like enviroments that support module.exports,
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory(require("jquery"));
} else {
Expand All @@ -15,11 +15,11 @@
}(this, function ($) {

var Module,
__slice = [].slice;
slice = [].slice;

Module = (function() {
Module.extend = function(obj) {
var key, val, _ref;
var key, ref, val;
if (!((obj != null) && typeof obj === 'object')) {
return;
}
Expand All @@ -29,11 +29,11 @@ Module = (function() {
this[key] = val;
}
}
return (_ref = obj.extended) != null ? _ref.call(this) : void 0;
return (ref = obj.extended) != null ? ref.call(this) : void 0;
};

Module.include = function(obj) {
var key, val, _ref;
var key, ref, val;
if (!((obj != null) && typeof obj === 'object')) {
return;
}
Expand All @@ -43,7 +43,7 @@ Module = (function() {
this.prototype[key] = val;
}
}
return (_ref = obj.included) != null ? _ref.call(this) : void 0;
return (ref = obj.included) != null ? ref.call(this) : void 0;
};

Module.connect = function(cls) {
Expand All @@ -67,29 +67,29 @@ Module = (function() {
Module.prototype.opts = {};

function Module(opts) {
var cls, instance, instances, name, _base, _i, _len;
var base, cls, i, instance, instances, len, name;
this.opts = $.extend({}, this.opts, opts);
(_base = this.constructor)._connectedClasses || (_base._connectedClasses = []);
(base = this.constructor)._connectedClasses || (base._connectedClasses = []);
instances = (function() {
var _i, _len, _ref, _results;
_ref = this.constructor._connectedClasses;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
cls = _ref[_i];
var i, len, ref, results;
ref = this.constructor._connectedClasses;
results = [];
for (i = 0, len = ref.length; i < len; i++) {
cls = ref[i];
name = cls.pluginName.charAt(0).toLowerCase() + cls.pluginName.slice(1);
if (cls.prototype._connected) {
cls.prototype._module = this;
}
_results.push(this[name] = new cls());
results.push(this[name] = new cls());
}
return _results;
return results;
}).call(this);
if (this._connected) {
this.opts = $.extend({}, this.opts, this._module.opts);
} else {
this._init();
for (_i = 0, _len = instances.length; _i < _len; _i++) {
instance = instances[_i];
for (i = 0, len = instances.length; i < len; i++) {
instance = instances[i];
if (typeof instance._init === "function") {
instance._init();
}
Expand All @@ -101,49 +101,49 @@ Module = (function() {
Module.prototype._init = function() {};

Module.prototype.on = function() {
var args, _ref;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
(_ref = $(this)).on.apply(_ref, args);
var args, ref;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
(ref = $(this)).on.apply(ref, args);
return this;
};

Module.prototype.one = function() {
var args, _ref;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
(_ref = $(this)).one.apply(_ref, args);
var args, ref;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
(ref = $(this)).one.apply(ref, args);
return this;
};

Module.prototype.off = function() {
var args, _ref;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
(_ref = $(this)).off.apply(_ref, args);
var args, ref;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
(ref = $(this)).off.apply(ref, args);
return this;
};

Module.prototype.trigger = function() {
var args, _ref;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
(_ref = $(this)).trigger.apply(_ref, args);
var args, ref;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
(ref = $(this)).trigger.apply(ref, args);
return this;
};

Module.prototype.triggerHandler = function() {
var args, _ref;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
return (_ref = $(this)).triggerHandler.apply(_ref, args);
var args, ref;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return (ref = $(this)).triggerHandler.apply(ref, args);
};

Module.prototype._t = function() {
var args, _ref;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
return (_ref = this.constructor)._t.apply(_ref, args);
var args, ref;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return (ref = this.constructor)._t.apply(ref, args);
};

Module._t = function() {
var args, key, result, _ref;
key = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
result = ((_ref = this.i18n[this.locale]) != null ? _ref[key] : void 0) || '';
var args, key, ref, result;
key = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
result = ((ref = this.i18n[this.locale]) != null ? ref[key] : void 0) || '';
if (!(args.length > 0)) {
return result;
}
Expand All @@ -167,8 +167,6 @@ Module = (function() {

})();


return Module;


}));
10 changes: 5 additions & 5 deletions site/assets/scripts/simditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2162,7 +2162,7 @@ Indentation = (function(superClass) {
return;
}
if ($blockEl.is('pre')) {
$pre = this.editor.selection.containerNode;
$pre = this.editor.selection.containerNode();
if (!($pre.is($blockEl) || $pre.closest('pre').is($blockEl))) {
return;
}
Expand All @@ -2186,7 +2186,7 @@ Indentation = (function(superClass) {
marginLeft = (Math.round(marginLeft / this.opts.indentWidth) + 1) * this.opts.indentWidth;
$blockEl.css('margin-left', marginLeft);
} else if ($blockEl.is('table') || $blockEl.is('.simditor-table')) {
$td = this.editor.selection.containerNode.closest('td, th');
$td = this.editor.selection.containerNode().closest('td, th');
$nextTd = $td.next('td, th');
if (!($nextTd.length > 0)) {
$tr = $td.parent('tr');
Expand Down Expand Up @@ -2227,7 +2227,7 @@ Indentation = (function(superClass) {
return;
}
if ($blockEl.is('pre')) {
$pre = this.editor.selection.containerNode;
$pre = this.editor.selection.containerNode();
if (!($pre.is($blockEl) || $pre.closest('pre').is($blockEl))) {
return;
}
Expand Down Expand Up @@ -2258,7 +2258,7 @@ Indentation = (function(superClass) {
marginLeft = Math.max(Math.round(marginLeft / this.opts.indentWidth) - 1, 0) * this.opts.indentWidth;
$blockEl.css('margin-left', marginLeft === 0 ? '' : marginLeft);
} else if ($blockEl.is('table') || $blockEl.is('.simditor-table')) {
$td = this.editor.selection.containerNode.closest('td, th');
$td = this.editor.selection.containerNode().closest('td, th');
$prevTd = $td.prev('td, th');
if (!($prevTd.length > 0)) {
$tr = $td.parent('tr');
Expand Down Expand Up @@ -5049,7 +5049,7 @@ TableButton = (function(superClass) {

TableButton.prototype.command = function(param) {
var $td;
$td = this.editor.selection.containerNode.closest('td, th');
$td = this.editor.selection.containerNode().closest('td, th');
if (!($td.length > 0)) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion site/assets/scripts/uploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory(require("jquery"),require("simplemodule"));
module.exports = factory(require("jquery"),require("simple-module"));
} else {
root.simple = root.simple || {};
root.simple['uploader'] = factory(jQuery,SimpleModule);
Expand Down
2 changes: 1 addition & 1 deletion src/buttons/table.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ class TableButton extends Button
@editor.selection.setRangeAtStartOf($block) if $block.length > 0

command: (param) ->
$td = @editor.selection.containerNode.closest('td, th')
$td = @editor.selection.containerNode().closest('td, th')
return unless $td.length > 0

if param == 'deleteRow'
Expand Down
10 changes: 5 additions & 5 deletions src/indentation.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Indentation extends SimpleModule
return unless $blockEl.length

if $blockEl.is('pre')
$pre = @editor.selection.containerNode
$pre = @editor.selection.containerNode()
return unless $pre.is($blockEl) or $pre.closest('pre').is($blockEl)
@indentText range
else if $blockEl.is('li')
Expand All @@ -75,7 +75,7 @@ class Indentation extends SimpleModule
@opts.indentWidth
$blockEl.css 'margin-left', marginLeft
else if $blockEl.is('table') or $blockEl.is('.simditor-table')
$td = @editor.selection.containerNode.closest('td, th')
$td = @editor.selection.containerNode().closest('td, th')
$nextTd = $td.next('td, th')
unless $nextTd.length > 0
$tr = $td.parent('tr')
Expand Down Expand Up @@ -107,7 +107,7 @@ class Indentation extends SimpleModule
return unless $blockEl and $blockEl.length > 0

if $blockEl.is('pre')
$pre = @editor.selection.containerNode
$pre = @editor.selection.containerNode()
return unless $pre.is($blockEl) or $pre.closest('pre').is($blockEl)
@outdentText range
else if $blockEl.is('li')
Expand All @@ -124,7 +124,7 @@ class Indentation extends SimpleModule
$('<p/>').insertBefore($parent)
.after($blockEl.children('ul, ol'))
.append($blockEl.contents())

$blockEl.remove()
else
if $blockEl.next('li').length > 0
Expand All @@ -142,7 +142,7 @@ class Indentation extends SimpleModule
@opts.indentWidth
$blockEl.css 'margin-left', if marginLeft == 0 then '' else marginLeft
else if $blockEl.is('table') or $blockEl.is('.simditor-table')
$td = @editor.selection.containerNode.closest('td, th')
$td = @editor.selection.containerNode().closest('td, th')
$prevTd = $td.prev('td, th')
unless $prevTd.length > 0
$tr = $td.parent('tr')
Expand Down
4 changes: 2 additions & 2 deletions styles/simditor.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
* Simditor v2.2.0
* Simditor v2.2.1
* http://simditor.tower.im/
* 2015-07-28
* 2015-07-31
*/
@font-face {
font-family: 'Simditor';
Expand Down

0 comments on commit 8372b7f

Please sign in to comment.