editor.setDirty(false);\r
}\r
}\r
+ },\r
+ showed: function(slug) {\r
+ if(slug === 'visual')\r
+ sandbox.getModule('visualEditor').onShowed();\r
}\r
};\r
\r
\r
eventHandlers.visualEditor = {\r
ready: function() {\r
- addTab('Visual', 'visual', sandbox.getModule('visualEditor').getView());\r
sandbox.getModule('visualEditor').setDocument(sandbox.getModule('data').getDocument());\r
+ addTab('Visual', 'visual', sandbox.getModule('visualEditor').getView());\r
+ \r
}\r
};\r
\r
tabContent[prevSlug].detach();\r
tabContent[slug].appendTo(view.find('#rng-tabsManager-content'));\r
currentSlug = slug;\r
+ sandbox.publish('showed', slug);\r
}\r
\r
\r
node.addClass('rng-current');\r
mediator.nodeSelected(node);\r
},\r
+ markFirstSelected: function() {\r
+ var firstNodeWithText = this.node.find('[wlxml-tag]').filter(function() {\r
+ return $(this).clone().children().remove().end().text().trim() !== '';\r
+ }).first();\r
+ if(firstNodeWithText.length)\r
+ $(firstNodeWithText[0]).click().focus();\r
+ },\r
_addMetaRow: function(key, value) {\r
var newRow = $(sandbox.getTemplate('metaItem')({key: key || '', value: value || ''}));\r
newRow.appendTo(this.metaTable);\r
}\r
\r
var isDirty = false;\r
- \r
+ var wasShownAlready = false;\r
\r
\r
return {\r
},\r
setDirty: function(dirty) {\r
isDirty = dirty;\r
+ },\r
+ onShowed: function() {\r
+ if(!wasShownAlready) {\r
+ wasShownAlready = true;\r
+ view.markFirstSelected();\r
+ }\r
}\r
\r
}\r