From: Aleksander Ɓukasz Date: Mon, 22 Apr 2013 13:51:30 +0000 (+0200) Subject: Visual editor - grid toggle X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/c9ec6d3adaf0d2119ed2ef7eecc2e5b525f2f86d Visual editor - grid toggle --- diff --git a/editor.css b/editor.css index ad7ebc1..4194718 100644 --- a/editor.css +++ b/editor.css @@ -28,6 +28,7 @@ body { height: 500px; overflow-y: scroll; padding: 5px 10px; + margin-top:10px; } #rng-visualEditor-contentWrapper::-webkit-scrollbar, @@ -133,6 +134,10 @@ body { +#rng-visualEditor-toolbar { + margin: -15px 0 10px 0; +} + .rng-visualEditor-sidebarContentItem fieldset { margin-bottom: 10px; } diff --git a/modules/visualEditor.js b/modules/visualEditor.js index b03b14b..39859a8 100644 --- a/modules/visualEditor.js +++ b/modules/visualEditor.js @@ -91,7 +91,9 @@ rng.modules.visualEditor = function(sandbox) { }); }); var config = { attributes: true, childList: true, characterData: true, subtree: true }; - observer.observe(this.node.find('#rng-visualEditor-contentWrapper')[0], config); + observer.observe(this.node.find('#rng-visualEditor-contentWrapper')[0], config); + + this.gridToggled = false; }, getMetaData: function() { var toret = {}; @@ -140,10 +142,12 @@ rng.modules.visualEditor = function(sandbox) { this.selectNode(node); }, highlightNode: function(node) { - node.addClass('rng-hover'); + if(!this.gridToggled) + node.addClass('rng-hover'); }, dimNode: function(node) { - node.removeClass('rng-hover'); + if(!this.gridToggled) + node.removeClass('rng-hover'); }, highlightNodeById: function(id) { var node = this.node.find('#'+id); @@ -171,6 +175,10 @@ rng.modules.visualEditor = function(sandbox) { var newRow = $(sandbox.getTemplate('metaItem')({key: key || '', value: value || ''})); newRow.appendTo(this.metaTable); return newRow; + }, + toggleGrid: function(toggle) { + this.node.find('[wlxml-tag]').toggleClass('rng-hover', toggle); + this.gridToggled = toggle; } }; @@ -267,8 +275,24 @@ rng.modules.visualEditor = function(sandbox) { } } + var toolbarView = { + node: view.node.find('#rng-visualEditor-toolbar'), + setup: function() { + var view = this; + + view.node.find('button').click(function(e) { + var btn = $(e.currentTarget); + if(btn.attr('data-btn-type') === 'toggle') { + btn.toggleClass('active') + mediator.toolbarButtonToggled(btn.attr('data-btn'), btn.hasClass('active')); + } + }); + } + } + view.setup(); sideBarView.setup(); + toolbarView.setup(); var mediator = { getCurrentNode: function() { @@ -290,6 +314,10 @@ rng.modules.visualEditor = function(sandbox) { nodeDimmedById: function(id) { view.dimNodeById(id); }, + toolbarButtonToggled: function(btn, toggle) { + if(btn === 'grid') + view.toggleGrid(toggle); + }, nodeHovered: function(node) { view.highlightNode(node); sideBarView.highlightNode(node.attr('id')); @@ -298,6 +326,7 @@ rng.modules.visualEditor = function(sandbox) { view.dimNode(node); sideBarView.dimNode(node.attr('id')); } + } var isDirty = false;