padding: 5px 10px;\r
}\r
\r
-#rng-visualEditor-contentWrapper::-webkit-scrollbar {\r
+#rng-visualEditor-contentWrapper::-webkit-scrollbar,\r
+#rng-visualEditor-editPaneNavigation::-webkit-scrollbar\r
+{\r
width: 9px;\r
}\r
\r
-#rng-visualEditor-contentWrapper::-webkit-scrollbar-track {\r
+#rng-visualEditor-contentWrapper::-webkit-scrollbar-track,\r
+#rng-visualEditor-editPaneNavigation::-webkit-scrollbar-track\r
+ {\r
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3); \r
-webkit-border-radius: 10px;\r
border-radius: 10px;\r
}\r
\r
-#rng-visualEditor-contentWrapper::-webkit-scrollbar-thumb {\r
+#rng-visualEditor-contentWrapper::-webkit-scrollbar-thumb,\r
+#rng-visualEditor-editPaneNavigation::-webkit-scrollbar-thumb\r
+{\r
-webkit-border-radius: 10px;\r
border-radius: 10px;\r
background: rgba(73,175,205,0.8); \r
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5); \r
}\r
-#rng-visualEditor-contentWrapper::-webkit-scrollbar-thumb:window-inactive {\r
+#rng-visualEditor-contentWrapper::-webkit-scrollbar-thumb:window-inactive,\r
+#rng-visualEditor-editPaneNavigation::-webkit-scrollbar-thumb:window-inactive\r
+ {\r
background: rgba(73,175,205,0.4); \r
}\r
\r
line-height:10px;\r
}\r
\r
+#rng-visualEditor-editPaneNavigation {\r
+ overflow-y: scroll;\r
+ max-height: 150px;\r
+ width:100%;\r
+ margin-top:10px;\r
+}\r
+#rng-visualEditor-editPaneNavigation table {\r
+ width: 90%;\r
+ margin: 0;\r
+}\r
+#rng-visualEditor-editPaneNavigation table tr td:nth-child(1) {\r
+ width: 30%;\r
+}\r
+#rng-visualEditor-editPaneNavigation table tr td:nth-child(2) {\r
+ width: 70%;\r
+}\r
+\r
+#rng-visualEditor-editPaneNavigation table tr td ul {\r
+ list-style-type: none;\r
+ margin-left:0px;\r
+}\r
#rng-sourceEditor-editor {\r
width: 940px;\r
height: 500px;\r
if(anchor[0].nodeType === Node.TEXT_NODE)\r
anchor = anchor.parent();\r
var newNode = anchor.clone().empty();\r
+ newNode.attr('id', '');\r
anchor.after(newNode);\r
view.selectNode(newNode);\r
}\r
}\r
\r
});\r
-
+ \r
+ \r
+ var observer = new MutationObserver(function(mutations) {\r
+ mutations.forEach(function(mutation) {\r
+ if(mutation.addedNodes.length > 0) {\r
+ console.log(mutation.addedNodes);\r
+ }\r
+ _.each(mutation.addedNodes, function(node) {\r
+ node = $(node);\r
+ node.parent().find('[wlxml-tag]').each(function() {\r
+ tag = $(this);\r
+ if(!tag.attr('id'))\r
+ tag.attr('id', 'xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {var r = Math.random()*16|0,v=c=='x'?r:r&0x3|0x8;return v.toString(16);}));\r
+ });\r
+ });\r
+ }); \r
+ });\r
+ var config = { attributes: true, childList: true, characterData: true, subtree: true };\r
+ observer.observe(this.node.find('#rng-visualEditor-contentWrapper')[0], config);
},\r
getMetaData: function() {\r
var toret = {};\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
selectFirstNode: function() {\r
var firstNodeWithText = this.node.find('[wlxml-tag]').filter(function() {\r
return $(this).clone().children().remove().end().text().trim() !== '';\r
isDirty = true;\r
}\r
});\r
+ \r
+ view.node.on('click', '.rng-visualEditor-editPaneSurrouding a', function(e) {\r
+ var target = $(e.target);\r
+ mediator.nodeSelectedById(target.attr('data-id'));\r
+ });\r
},\r
selectTab: function(id) {\r
this.node.find('.rng-visualEditor-sidebarContentItem').hide();\r
updateEditPane: function(node) {\r
var pane = this.node.find('#rng-visualEditor-edit');\r
pane.html( $(sandbox.getTemplate('editPane')({tag: node.attr('wlxml-tag'), klass: node.attr('wlxml-class')})));\r
+ \r
+ var parent = {\r
+ repr: node.parent().attr('wlxml-tag') + ' / ' + (node.parent().attr('wlxml-class') || '[[no class]]'),\r
+ id: node.parent().attr('id')\r
+ }\r
+ var children = [];\r
+ node.children().each(function() {\r
+ var child = $(this);\r
+ children.push({repr: child.attr('wlxml-tag') + ' / ' + (child.attr('wlxml-class') || '[[no class]]'), id: child.attr('id')});\r
+ });\r
+ var naviTemplate = sandbox.getTemplate('editPaneNavigation')({parent: parent, children: children});\r
+ pane.find('.rng-visualEditor-editPaneSurrouding > div').html($(naviTemplate));\r
}\r
}\r
\r
},\r
nodeSelected: function(node) {\r
sideBarView.updateEditPane(node);\r
+ },\r
+ nodeSelectedById: function(id) {\r
+ view.selectNodeById(id);\r
}\r
}\r
\r