1 define(['libs/jquery-1.9.1.min', 'libs/underscore-min', 'libs/text!./template.html'], function($, _, template) {
\r
5 return function(sandbox) {
\r
8 node: $(_.template(template)()),
\r
12 this.node.find('button').click(function(e) {
\r
13 e.stopPropagation();
\r
14 var btn = $(e.currentTarget);
\r
15 if(btn.attr('data-btn-type') === 'toggle') {
\r
16 btn.toggleClass('active')
\r
18 var btnId = btn.attr('data-btn');
\r
19 if(btnId === 'grid')
\r
20 event = 'toggleGrid';
\r
21 if(btnId === 'tags')
\r
22 event = 'toggleTags';
\r
23 sandbox.publish(event, btn.hasClass('active'));
\r
25 if(btn.attr('data-btn-type') === 'cmd') {
\r
26 var command = btn.attr('data-btn');
\r
27 var meta = btn.attr('data-meta');
\r
28 if(command === 'new-node') {
\r
29 var wlxmlTag = view.getOption('newTag-tag');
\r
30 var wlxmlClass = view.getOption('newTag-class');
\r
32 var split = meta.split('/');
\r
33 wlxmlTag = split[0];
\r
34 wlxmlClass = split[1];
\r
36 if(window.getSelection().isCollapsed) {
\r
37 //view.insertNewNode(wlxmlTag, wlxmlClass);
\r
40 //this.wrapWithNodeRequest(wlxmlTag, wlxmlClass);
\r
42 sandbox.publish('newNodeRequested', wlxmlTag, wlxmlClass);
\r
44 sandbox.publish('command', btn.attr('data-btn'), btn.attr('data-meta'));
\r
49 getOption: function(option) {
\r
50 return this.node.find('.rng-module-documentToolbar-toolbarOption[data-option=' + option +']').val();
\r
57 start: function() { sandbox.publish('ready'); },
\r
58 getView: function() { return view.node; },
\r
59 getOption: function(option) { return view.getOption(option); }
\r