canvas manager wip - setting cursor at the beginning of a new node
[fnpeditor.git] / modules / documentCanvas / wlxmlNode.js
1 define(['libs/jquery-1.9.1.min'], function($) {\r
2     \r
3 'use strict';\r
4 \r
5 var tagSelector = '[wlxml-tag]';\r
6 \r
7 var Node = function(domNode) {\r
8        \r
9     return {\r
10         id: domNode.attr('id'),\r
11         tag: domNode.attr('wlxml-tag'),\r
12         klass: domNode.attr('wlxml-class'),\r
13         parent: function() {\r
14             var node = domNode.parent(tagSelector);\r
15             if(node.length)\r
16                 return new Node(node);\r
17             return null;\r
18         },\r
19         children: function() {\r
20             var list = [];\r
21             domNode.children(tagSelector).each(function() {\r
22                 list.push(new Node($(this)));\r
23             });\r
24             return $(list);\r
25         },\r
26         parents: function() {\r
27             var list = [];\r
28             domNode.parents(tagSelector).each(function() {\r
29                 list.push(new Node($(this)));\r
30             });\r
31             return $(list);\r
32         },\r
33         is: function(wlxmlNode) {\r
34             return wlxmlNode && (wlxmlNode.id === this.id);\r
35         }\r
36     }\r
37 \r
38 };\r
39 \r
40 return { Node: Node}\r
41 \r
42 });