Missing translation
[fnpeditor.git] / modules / documentToolbar / documentToolbar.js
1 define(['libs/jquery-1.9.1.min', 'libs/underscore-min', 'libs/text!./template.html'], function($, _, template) {\r
2 \r
3 'use strict';\r
4 \r
5 return function(sandbox) {\r
6     \r
7     var view = {\r
8         node: $(_.template(template)()),\r
9         setup: function() {\r
10             var view = this;\r
11             \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
17                     var event;\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
24                 }\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
31                         if(meta) {\r
32                             var split = meta.split('/');\r
33                             wlxmlTag = split[0];\r
34                             wlxmlClass = split[1];\r
35                         }\r
36                         if(window.getSelection().isCollapsed) {\r
37                             //view.insertNewNode(wlxmlTag, wlxmlClass);\r
38                         }\r
39                         else {\r
40                             //this.wrapWithNodeRequest(wlxmlTag, wlxmlClass);\r
41                         }\r
42                         sandbox.publish('newNodeRequested', wlxmlTag, wlxmlClass);\r
43                     }\r
44                     //sandbox.publish('command', btn.attr('data-btn'), btn.attr('data-meta'));\r
45                 }\r
46             });\r
47         },\r
48         getOption: function(option) {\r
49             return this.node.find('.rng-module-documentToolbar-toolbarOption[data-option=' + option +']').val();\r
50         }\r
51     }\r
52     \r
53     view.setup();\r
54 \r
55     return {\r
56         start: function() { sandbox.publish('ready'); },\r
57         getView: function() { return view.node; },\r
58         getOption: function(option) { return view.getOption(option); }\r
59     }\r
60 }\r
61 \r
62 });