fnp
/
fnpeditor.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
documentCanvas fix: node now dims correctly
[fnpeditor.git]
/
modules
/
documentCanvas
/
documentCanvas.js
diff --git
a/modules/documentCanvas/documentCanvas.js
b/modules/documentCanvas/documentCanvas.js
index
f7d7fd0
..
55c8d7e
100644
(file)
--- a/
modules/documentCanvas/documentCanvas.js
+++ b/
modules/documentCanvas/documentCanvas.js
@@
-3,7
+3,8
@@
define([
\r
'libs/underscore-min',
\r
'./transformations',
\r
define([
\r
'libs/underscore-min',
\r
'./transformations',
\r
-'libs/text!./template.html'], function(_, transformations, template) {
\r
+'./wlxmlNode',
\r
+'libs/text!./template.html'], function(_, transformations, wlxmlNode, template) {
\r
\r
\r
\r
\r
\r
\r
@@
-22,16
+23,16
@@
return function(sandbox) {
\r
this.node.on('mouseover', '[wlxml-tag]', function(e) {
\r
e.stopPropagation();
\r
\r
this.node.on('mouseover', '[wlxml-tag]', function(e) {
\r
e.stopPropagation();
\r
- sandbox.publish('nodeHovered',
$(e.target
));
\r
+ sandbox.publish('nodeHovered',
new wlxmlNode.Node($(e.target)
));
\r
});
\r
this.node.on('mouseout', '[wlxml-tag]', function(e) {
\r
e.stopPropagation();
\r
});
\r
this.node.on('mouseout', '[wlxml-tag]', function(e) {
\r
e.stopPropagation();
\r
- sandbox.publish('nodeBlured',
$(e.target
));
\r
+ sandbox.publish('nodeBlured',
new wlxmlNode.Node($(e.target)
));
\r
});
\r
this.node.on('click', '[wlxml-tag]', function(e) {
\r
e.stopPropagation();
\r
console.log('clicked node type: '+e.target.nodeType);
\r
});
\r
this.node.on('click', '[wlxml-tag]', function(e) {
\r
e.stopPropagation();
\r
console.log('clicked node type: '+e.target.nodeType);
\r
- view._markSelected(
$(e.target
));
\r
+ view._markSelected(
new wlxmlNode.Node($(e.target)
));
\r
});
\r
\r
this.node.on('keyup', '#rng-module-documentCanvas-contentWrapper', function(e) {
\r
});
\r
\r
this.node.on('keyup', '#rng-module-documentCanvas-contentWrapper', function(e) {
\r
@@
-40,7
+41,7
@@
return function(sandbox) {
anchor = anchor.parent();
\r
if(!anchor.is('[wlxml-tag]'))
\r
return;
\r
anchor = anchor.parent();
\r
if(!anchor.is('[wlxml-tag]'))
\r
return;
\r
- view._markSelected(
anchor
);
\r
+ view._markSelected(
new wlxmlNode.Node(anchor)
);
\r
});
\r
\r
this.node.on('keydown', '#rng-module-documentCanvas-contentWrapper', function(e) {
\r
});
\r
\r
this.node.on('keydown', '#rng-module-documentCanvas-contentWrapper', function(e) {
\r
@@
-164,9
+165,10
@@
return function(sandbox) {
_markSelected: function(node) {
\r
this.dimNode(node);
\r
\r
_markSelected: function(node) {
\r
this.dimNode(node);
\r
\r
+
\r
this.node.find('.rng-module-documentCanvas-currentNode').removeClass('rng-module-documentCanvas-currentNode');
\r
\r
this.node.find('.rng-module-documentCanvas-currentNode').removeClass('rng-module-documentCanvas-currentNode');
\r
\r
-
node
.addClass('rng-module-documentCanvas-currentNode');
\r
+
this.getNodeElement(node)
.addClass('rng-module-documentCanvas-currentNode');
\r
\r
this.currentNode = node;
\r
sandbox.publish('nodeSelected', node);
\r
\r
this.currentNode = node;
\r
sandbox.publish('nodeSelected', node);
\r
@@
-175,19
+177,15
@@
return function(sandbox) {
selectNode: function(node) {
\r
view._markSelected(node);
\r
var range = document.createRange();
\r
selectNode: function(node) {
\r
view._markSelected(node);
\r
var range = document.createRange();
\r
- range.selectNodeContents(
node
[0]);
\r
+ range.selectNodeContents(
this.getNodeElement(node)
[0]);
\r
range.collapse(false);
\r
\r
var selection = document.getSelection();
\r
selection.removeAllRanges()
\r
selection.addRange(range);
\r
},
\r
range.collapse(false);
\r
\r
var selection = document.getSelection();
\r
selection.removeAllRanges()
\r
selection.addRange(range);
\r
},
\r
- selectNodeById: function(id) {
\r
- var node = this.node.find('#'+id);
\r
- if(node)
\r
- this.selectNode(node);
\r
- },
\r
highlightNode: function(node) {
\r
highlightNode: function(node) {
\r
+ node = this.getNodeElement(node);
\r
if(!this.gridToggled) {
\r
node.addClass('rng-common-hoveredNode');
\r
var label = node.attr('wlxml-tag');
\r
if(!this.gridToggled) {
\r
node.addClass('rng-common-hoveredNode');
\r
var label = node.attr('wlxml-tag');
\r
@@
-198,21
+196,12
@@
return function(sandbox) {
}
\r
},
\r
dimNode: function(node) {
\r
}
\r
},
\r
dimNode: function(node) {
\r
+ node = this.getNodeElement(node);
\r
if(!this.gridToggled) {
\r
node.removeClass('rng-common-hoveredNode');
\r
node.find('.rng-module-documentCanvas-hoveredNodeTag').remove();
\r
}
\r
},
\r
if(!this.gridToggled) {
\r
node.removeClass('rng-common-hoveredNode');
\r
node.find('.rng-module-documentCanvas-hoveredNodeTag').remove();
\r
}
\r
},
\r
- highlightNodeById: function(id) {
\r
- var node = this.node.find('#'+id);
\r
- if(node)
\r
- this.highlightNode(node);
\r
- },
\r
- dimNodeById: function(id) {
\r
- var node = this.node.find('#'+id);
\r
- if(node)
\r
- this.dimNode(node);
\r
- },
\r
selectFirstNode: function() {
\r
var firstNodeWithText = this.node.find('[wlxml-tag]').filter(function() {
\r
return $(this).clone().children().remove().end().text().trim() !== '';
\r
selectFirstNode: function() {
\r
var firstNodeWithText = this.node.find('[wlxml-tag]').filter(function() {
\r
return $(this).clone().children().remove().end().text().trim() !== '';
\r
@@
-223,11
+212,14
@@
return function(sandbox) {
else {
\r
node = this.node.find('[wlxml-class|="p"]')
\r
}
\r
else {
\r
node = this.node.find('[wlxml-class|="p"]')
\r
}
\r
- this.selectNode(n
ode
);
\r
+ this.selectNode(n
ew wlxmlNode.Node(node)
);
\r
},
\r
toggleGrid: function(toggle) {
\r
this.node.find('[wlxml-tag]').toggleClass('rng-common-hoveredNode', toggle);
\r
this.gridToggled = toggle;
\r
},
\r
toggleGrid: function(toggle) {
\r
this.node.find('[wlxml-tag]').toggleClass('rng-common-hoveredNode', toggle);
\r
this.gridToggled = toggle;
\r
+ },
\r
+ getNodeElement: function(wlxmlNode) {
\r
+ return this.node.find('#'+wlxmlNode.id);
\r
}
\r
};
\r
\r
}
\r
};
\r
\r
@@
-247,14
+239,14
@@
return function(sandbox) {
if(view.currentNode)
\r
view.currentNode.attr('wlxml-'+attr, value);
\r
},
\r
if(view.currentNode)
\r
view.currentNode.attr('wlxml-'+attr, value);
\r
},
\r
- highlightNode: function(
id
) {
\r
- view.highlightNode
ById(id
);
\r
+ highlightNode: function(
wlxmlNode
) {
\r
+ view.highlightNode
(wlxmlNode
);
\r
},
\r
},
\r
- dimNode: function(
id
) {
\r
- view.dimNode
ById(id
);
\r
+ dimNode: function(
wlxmlNode
) {
\r
+ view.dimNode
(wlxmlNode
);
\r
},
\r
},
\r
- selectNode: function(
id
) {
\r
- view.selectNode
ById(id
);
\r
+ selectNode: function(
wlxmlNode
) {
\r
+ view.selectNode
(wlxmlNode
);
\r
},
\r
toggleGrid: function(toggle) {
\r
view.toggleGrid(toggle);
\r
},
\r
toggleGrid: function(toggle) {
\r
view.toggleGrid(toggle);
\r