X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/e64e37a2fbe6d64b2513133d34370f0d1a63f7b9..058eee1d91537d6b060be9f5eb5433287e7303fc:/modules/documentToolbar/documentToolbar.js diff --git a/modules/documentToolbar/documentToolbar.js b/modules/documentToolbar/documentToolbar.js index c459428..2d963d2 100644 --- a/modules/documentToolbar/documentToolbar.js +++ b/modules/documentToolbar/documentToolbar.js @@ -1,63 +1,57 @@ -define(['libs/jquery-1.9.1.min', 'libs/underscore-min', 'libs/text!./template.html'], function($, _, template) { - -'use strict'; - -return function(sandbox) { - - var view = { - node: $(_.template(template)()), - setup: function() { - var view = this; - - this.node.find('button').click(function(e) { - e.stopPropagation(); - var btn = $(e.currentTarget); - if(btn.attr('data-btn-type') === 'toggle') { - btn.toggleClass('active') - var event; - var btnId = btn.attr('data-btn'); - if(btnId === 'grid') - event = 'toggleGrid'; - if(btnId === 'tags') - event = 'toggleTags'; - sandbox.publish(event, btn.hasClass('active')); - } - if(btn.attr('data-btn-type') === 'cmd') { - var command = btn.attr('data-btn'); - var meta = btn.attr('data-meta'); - if(command === 'new-node') { - var wlxmlTag = view.getOption('newTag-tag'); - var wlxmlClass = view.getOption('newTag-class'); - if(meta) { - var split = meta.split('/'); - wlxmlTag = split[0]; - wlxmlClass = split[1]; - } - if(window.getSelection().isCollapsed) { - //view.insertNewNode(wlxmlTag, wlxmlClass); - } - else { - //this.wrapWithNodeRequest(wlxmlTag, wlxmlClass); - } - sandbox.publish('newNodeRequested', wlxmlTag, wlxmlClass); - } else { - sandbox.publish('command', btn.attr('data-btn'), btn.attr('data-meta')); - } - } - }); - }, - getOption: function(option) { - return this.node.find('.rng-module-documentToolbar-toolbarOption[data-option=' + option +']').val(); - } - } - - view.setup(); - - return { - start: function() { sandbox.publish('ready'); }, - getView: function() { return view.node; }, - getOption: function(option) { return view.getOption(option); } - } -} - +define(['libs/jquery-1.9.1.min', 'libs/underscore-min', 'libs/text!./template.html'], function($, _, template) { + +'use strict'; + +return function(sandbox) { + + var view = { + node: $(_.template(template)()), + setup: function() { + var view = this; + + this.node.find('button').click(function(e) { + e.stopPropagation(); + var btn = $(e.currentTarget); + if(btn.attr('data-btn-type') === 'toggle') { + btn.toggleClass('active'); + var event; + var btnId = btn.attr('data-btn'); + if(btnId === 'grid') + event = 'toggleGrid'; + if(btnId === 'tags') + event = 'toggleTags'; + sandbox.publish(event, btn.hasClass('active')); + } + if(btn.attr('data-btn-type') === 'cmd') { + var command = btn.attr('data-btn'); + var meta = btn.attr('data-meta'); + if(command === 'new-node') { + var wlxmlTag = view.getOption('newTag-tag'); + var wlxmlClass = view.getOption('newTag-class'); + if(meta) { + var split = meta.split('/'); + wlxmlTag = split[0]; + wlxmlClass = split[1]; + } + sandbox.publish('newNodeRequested', wlxmlTag, wlxmlClass); + } else { + sandbox.publish('command', btn.attr('data-btn'), btn.attr('data-meta')); + } + } + }); + }, + getOption: function(option) { + return this.node.find('.rng-module-documentToolbar-toolbarOption[data-option=' + option +']').val(); + } + }; + + view.setup(); + + return { + start: function() { sandbox.publish('ready'); }, + getView: function() { return view.node; }, + getOption: function(option) { return view.getOption(option); } + }; +}; + }); \ No newline at end of file