'use strict';
var $ = require('libs/jquery'),
+ _ = require('libs/underscore'),
documentElement = require('./documentElement'),
utils = require('./utils'),
wlxmlUtils = require('utils/wlxml');
referenceAction = 'after';
}
- if(event.type === 'nodeMoved') {
- /* globals Node */
- if(event.meta.node.nodeType === Node.TEXT_NODE) {
- actionArg = utils.getElementForTextNode(event.meta.node);
- } else {
- actionArg = utils.getElementForNode(event.meta.node);
+ if(event.meta.move) {
+ /* Let's check if this node had its own canvas element and it's accessible. */
+ actionArg = utils.getElementForElementRootNode(event.meta.node);
+ if(actionArg && actionArg.sameNode(referenceElement)) {
+ referenceElement = this.children()[nodeIndex];
}
- } else {
+ }
+ if(!actionArg) {
actionArg = event.meta.node;
}
referenceElement[referenceAction](actionArg);
},
- onNodeMoved: function(event) {
- return this.onNodeAdded.call(this, event);
- },
onNodeDetached: function(event) {
if(event.meta.node.sameNode(this)) {
this.detach();
});
},
+ onStateChange: function(changes) {
+ if(_.isBoolean(changes.exposed) && !this.isSpan()) {
+ this._container().toggleClass('highlighted-element', changes.exposed);
+ }
+ if(_.isBoolean(changes.active) && !this.isSpan()) {
+ this._container().toggleClass('current-node-element', changes.active);
+ }
+ },
///
+
+ isSpan: function() {
+ return this.wlxmlNode.getTagName() === 'span';
+ },
containsBlock: function() {
return this.children()