editor: remove unused code
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Wed, 28 May 2014 12:31:39 +0000 (14:31 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Wed, 28 May 2014 12:45:47 +0000 (14:45 +0200)
13 files changed:
src/editor/modules.js
src/editor/modules/nodeBreadCrumbs/nodeBreadCrumbs.js
src/editor/modules/nodeFamilyTree/nodeFamilyTree.js [deleted file]
src/editor/modules/nodeFamilyTree/nodeFamilyTree.less [deleted file]
src/editor/modules/nodeFamilyTree/template.html [deleted file]
src/editor/modules/nodePane/metaWidget/metaWidget.js [deleted file]
src/editor/modules/nodePane/metaWidget/metaWidget.test.js [deleted file]
src/editor/modules/nodePane/metaWidget/stringField.html [deleted file]
src/editor/modules/nodePane/nodePane.js [deleted file]
src/editor/modules/nodePane/nodePane.less [deleted file]
src/editor/modules/nodePane/template.html [deleted file]
src/editor/modules/rng/rng.js
src/editor/styles/main.less

index 6b92a5e..312ac0b 100644 (file)
@@ -17,9 +17,7 @@ define(function(require) {
         
         documentCanvas: require('modules/documentCanvas/documentCanvas'),
         documentToolbar: require('modules/documentToolbar/documentToolbar'),
-        nodePane: require('modules/nodePane/nodePane'),
         metadataEditor: require('modules/metadataEditor/metadataEditor'),
-        nodeFamilyTree: require('modules/nodeFamilyTree/nodeFamilyTree'),
         nodeBreadCrumbs: require('modules/nodeBreadCrumbs/nodeBreadCrumbs'),
         
         documentHistory: require('modules/documentHistory/documentHistory'),
index 0540542..24a61de 100644 (file)
@@ -14,14 +14,6 @@ return function(sandbox) {
     var view = {
         dom: $('<div>' + template({node:null, parents: null}) + '</div>'),
         setup: function() {
-            this.dom.on('mouseenter', 'a', function(e) {
-                var target = $(e.target);
-                sandbox.publish('elementEntered', target.data('element'));
-            });
-            this.dom.on('mouseleave', 'a', function(e) {
-                var target = $(e.target);
-                sandbox.publish('elementLeft', target.data('element'));
-            });
             this.dom.on('click', 'a', function(e) {
                 e.preventDefault();
                 var target = $(e.target);
diff --git a/src/editor/modules/nodeFamilyTree/nodeFamilyTree.js b/src/editor/modules/nodeFamilyTree/nodeFamilyTree.js
deleted file mode 100644 (file)
index bda562f..0000000
+++ /dev/null
@@ -1,149 +0,0 @@
-define([
-'libs/jquery',
-'libs/underscore',
-'utils/wlxml',
-'libs/text!./template.html'
-], function($, _, wlxmlUtils, templateSrc) {
-
-'use strict';
-
-return function(sandbox) {
-    
-    var template = _.template(templateSrc),
-        listens = false,
-        items = [];
-
-    var getItemId = function(item) {
-        var idx = -1;
-        var found = _.find(items, function(i) {
-            idx += 1;
-            return item.sameNode(i);
-        });
-        if(found) {
-            return idx;
-        }
-        return -1;
-    };
-    
-    var startListening = function(document) {
-        listens = true;
-        document.on('change', function(event) {
-            if(event.type === 'nodeTextChange' && event.meta.node.parent().sameNode(view.currentNodeElement)) {
-                view.setElement(view.currentNodeElement);
-            }
-        }, this);
-    };
-
-    var view = {
-        dom: $('<div>' + template({contents: null, parent: null}) + '</div>'),
-        setup: function() {
-            this.dom.on('click', 'a', function(e) {
-                var target = $(e.target);
-                sandbox.publish('nodeClicked', target.data('element'));
-            });
-            
-            this.dom.on('mouseenter', 'a', function(e) {
-                var target = $(e.target);
-                sandbox.publish('nodeEntered', target.data('element'));
-            });
-            this.dom.on('mouseleave', 'a', function(e) {
-                var target = $(e.target);
-                sandbox.publish('nodeLeft', target.data('element'));
-            });
-        },
-        setElement: function(element) {
-            var contents = [],
-                parent, nodeElementParent;
-
-            if(element) {
-                element = element || this.currentNodeElement;
-                var textElement = element.getText ? element : null,
-                    nodeElement = element.getText ? element.parent() : element, // TODO: better type detection
-                    items;
-                
-                this.currentNodeElement = nodeElement;
-                items = [];
-                nodeElementParent = nodeElement.parent();
-
-                if(nodeElementParent) {
-                    items.push(nodeElementParent);
-                    parent = {
-                        id: items.length - 1,
-                        repr: wlxmlUtils.getTagLabel(nodeElementParent.getTagName()) + (nodeElementParent.getClass() ? ' / ' + wlxmlUtils.getClassLabel(nodeElementParent.getClass()) : '')
-                    };
-                    
-                }
-            
-                var nodeContents = nodeElement.contents();
-                nodeContents.forEach(function(child) {
-                    if(child.getText) {
-                        var text = child.getText();
-                        if(!text) {
-                            text = '<pusty tekst>';
-                        }
-                        else {
-                            if(text.length > 13) {
-                                text = text.substr(0,13) + '...';
-                            }
-                            text = '"' + text + '"';
-                        }
-                        contents.push({
-                            id: items.length,
-                            repr: _.escape(text), bold: child.sameNode(textElement)
-                        });
-                    } else {
-                        contents.push({
-                            id: items.length,
-                            repr: wlxmlUtils.getTagLabel(child.getTagName()) + (child.getClass() ? ' / ' + wlxmlUtils.getClassLabel(child.getClass()) : '')
-                        });
-                    }
-                    items.push(child);
-                });
-            }
-            this.dom.empty();
-            this.dom.append($(template({parent: parent, contents: contents})));
-
-            if(parent) {
-                this.dom.find('.rng-module-nodeFamilyTree-parent').data('element', nodeElementParent);
-            }
-            this.dom.find('li a').each(function(idx, a) {
-                $(a).data('element', nodeContents[idx]);
-            });
-        },
-        highlightNode: function(canvasNode) {
-            var id = getItemId(canvasNode);
-            this.dom.find('a[rng-module-nodeFamilyTree-item-id="'+id+'"]').addClass('rng-common-hoveredNode');
-        },
-        dimNode: function(canvasNode) {
-            var id = getItemId(canvasNode);
-            this.dom.find('a[rng-module-nodeFamilyTree-item-id="'+id+'"]').removeClass('rng-common-hoveredNode');
-        }
-    };
-    
-    view.setup();
-    
-    return {
-        start: function() {
-            sandbox.publish('ready');
-        },
-        setElement: function(element) {
-            if(!listens && element) {
-                startListening(element.document);
-            }
-            if(!element || !(element.sameNode(view.currentNodeElement))) {
-                view.setElement(element);
-            }
-        },
-        getView: function() {
-            return view.dom;
-        },
-        highlightElement: function(canvasNode) {
-            view.highlightNode(canvasNode);
-        },
-        dimElement: function(canvasNode) {
-            view.dimNode(canvasNode);
-        }
-    };
-};
-
-});
\ No newline at end of file
diff --git a/src/editor/modules/nodeFamilyTree/nodeFamilyTree.less b/src/editor/modules/nodeFamilyTree/nodeFamilyTree.less
deleted file mode 100644 (file)
index 6b4dc77..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-.rng-module-nodeFamilyTree {
-    overflow-y: scroll;
-    max-height: 150px;
-    width:100%;
-    margin-top:10px;
-
-    table {
-        width: 90%;
-        margin: 0;
-    
-        tr {
-            td:nth-child(1) {
-                width: 30%;
-            }
-            td:nth-child(2) {
-                width: 70%;
-            }
-            td ul {
-                list-style-type: none;
-                margin: 0;
-            }
-            
-        }
-    }
-    
-    &::-webkit-scrollbar {
-        .rng-mixin-scrollbar;
-    }
-    &::-webkit-scrollbar-track {
-        .rng-mixin-scrollbar-track;
-    }
-    &::-webkit-scrollbar-thumb {
-        .rng-mixin-scrollbar-thumb;
-    }
-    &::-webkit-scrollbar-thumb:window-inactive {
-        .rng-mixin-scrollbar-thumb-window-inactive;
-    }
-}
\ No newline at end of file
diff --git a/src/editor/modules/nodeFamilyTree/template.html b/src/editor/modules/nodeFamilyTree/template.html
deleted file mode 100644 (file)
index 77e5366..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-<div class="rng-module-nodeFamilyTree">
-    <table class="table table-bordered">
-        <tr>
-            <td>powyżej</td>
-            <td><% if(parent) { %><a href="#" class="rng-module-nodeFamilyTree-parent" rng-module-nodeFamilyTree-item-id="<%= parent.id %>"><%= parent.repr %></a><% } else { %>-<% } %></td>
-        </tr>
-        <tr>
-            <td rowspan="0">poniżej</td>
-            <td>
-                <ul>
-                <% if(!contents || contents.length === 0) { %>-<% } else { %>
-                    <% contents.forEach(function(element) { %>
-                        <li><% if(element.bold) { %><strong><% } %><a rng-module-nodeFamilyTree-item-id="<%= element.id %>" href="#"><%= element.repr %></a><% if(element.bold) { %></strong><% } %></li>
-                    <% }); %>
-                <% } %>
-                </ul>
-            </td>
-        </tr>
-</div>
\ No newline at end of file
diff --git a/src/editor/modules/nodePane/metaWidget/metaWidget.js b/src/editor/modules/nodePane/metaWidget/metaWidget.js
deleted file mode 100644 (file)
index 6f9b34c..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-define([
-'libs/jquery',
-'libs/underscore',
-'libs/backbone',
-'libs/text!./stringField.html'
-], function($, _, Backbone, stringFieldTpl) {
-
-'use strict';
-
-var templates = {
-    string: _.template(stringFieldTpl)
-};
-
-var getAttrElement = function(attrName, attr) {
-    var toret = $('<div>');
-    toret.append(templates.string({name: attrName, value: attr.value}));
-    return toret;
-};
-
-var MetaWidget = Backbone.View.extend({
-    events: {
-        'change [metaField-name]': 'onMetaFieldChange'
-    },
-    initialize: function() {
-        var view = this;
-        _.keys(this.options.attrs).forEach(function(attrName) {
-            view.$el.append(getAttrElement(attrName, this.options.attrs[attrName]));
-        }.bind(this));
-    },
-    onMetaFieldChange: function(e) {
-        var target = $(e.target);
-        this.trigger('valueChanged', target.attr('metaField-name'), target.val());
-    }
-});
-
-
-return {
-    create: function(options) {
-        return new MetaWidget(options);
-    }
-};
-
-});
\ No newline at end of file
diff --git a/src/editor/modules/nodePane/metaWidget/metaWidget.test.js b/src/editor/modules/nodePane/metaWidget/metaWidget.test.js
deleted file mode 100644 (file)
index bc1a579..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-define([
-'libs/jquery',
-'libs/chai',
-'libs/sinon',
-'modules/nodePane/metaWidget/metaWidget'
-], function($, chai, sinon, metaWidget) {
-
-'use strict';
-/* globals describe, it */
-
-var assert = chai.assert;
-
-describe('metaWidget', function() {
-    it('calls calls registered callback on value change', function() {
-        var dom = $('<div>');
-        var widget = metaWidget.create({
-                el: dom,
-                attrs: {'uri': {type: 'string', value: 'test string'}},
-            });
-
-        var spy = sinon.spy();
-        widget.on('valueChanged', spy);
-        var input = dom.find('input');
-
-        input.change();
-        assert.ok(spy.calledOnce, 'called once');
-        assert.ok(spy.calledWith('uri', 'test string'), 'called with');
-
-        spy.reset();
-        input.val('new val').change();
-        assert.ok(spy.calledOnce, 'called once');
-        assert.ok(spy.calledWith('uri', 'new val'), 'called with new val');
-    });
-});
-
-
-});
\ No newline at end of file
diff --git a/src/editor/modules/nodePane/metaWidget/stringField.html b/src/editor/modules/nodePane/metaWidget/stringField.html
deleted file mode 100644 (file)
index a5156a2..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-<label><%= name %></label>
-<input type="text" metaField-name="<%= name %>" value="<%= value %>">
\ No newline at end of file
diff --git a/src/editor/modules/nodePane/nodePane.js b/src/editor/modules/nodePane/nodePane.js
deleted file mode 100644 (file)
index 25e5ddb..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-define([
-'libs/text!./template.html',
-'libs/jquery',
-'libs/underscore',
-'modules/nodePane/metaWidget/metaWidget',
-'utils/wlxml'
-], function(templateSrc, $, _, metaWidget, wlxmlUtils) {
-
-'use strict';
-
-return function(sandbox) {
-    
-    var view = $(_.template(templateSrc)({utils: wlxmlUtils})),
-        listens = false,
-        currentNode,
-        msgs = {
-            Tag: gettext('Tag editing'),
-            Class: gettext('Class editing')
-        };
-    
-    view.on('change', 'select', function(e) {
-        var target = $(e.target);
-        var attr = target.attr('class').split('-')[3] === 'tagSelect' ? 'Tag' : 'Class',
-            value = target.val().replace(/-/g, '.'),
-            oldValue = attr === 'Tag' ? currentNode.getTagName() : currentNode.getClass();
-        currentNode.document.transaction(function() {
-            currentNode['set' + attr](value);
-        }, this, msgs[attr] + ': ' + oldValue + ' -> ' + value);
-    });
-
-
-   
-    return {
-        start: function() {
-            sandbox.publish('ready');
-        },
-        getView: function() {
-            return view;
-        },
-        setNodeElement: function(wlxmlNodeElement) {
-            if(wlxmlNodeElement) {
-                var module = this;
-                if(!listens) {
-                    wlxmlNodeElement.document.on('change', function(event) {
-                        if(currentNode && !currentNode.isInDocument()) {
-                            module.setNodeElement(null);
-                        }
-                        if(event.type === 'nodeAttrChange' && event.meta.node.sameNode(currentNode)) {
-                            module.setNodeElement(currentNode);
-                        }
-                    });
-                    listens = true;
-                }
-
-                view.find('.rng-module-nodePane-tagSelect').attr('disabled', false).val(wlxmlNodeElement.getTagName());
-
-                var escapedClassName = (wlxmlNodeElement.getClass() || '').replace(/\./g, '-');
-                view.find('.rng-module-nodePane-classSelect').attr('disabled', false).val(escapedClassName);
-
-                var attrs = _.extend(wlxmlNodeElement.getMetaAttributes(), wlxmlNodeElement.getOtherAttributes());
-                var widget = metaWidget.create({attrs:attrs});
-                widget.on('valueChanged', function(key, value) {
-                    wlxmlNodeElement.setMetaAttribute(key, value);
-                    //wlxmlNodeElement.setMetaAttribute(key, value);
-                });
-                view.find('.metaFields').empty().append(widget.el);
-            } else {
-                view.find('.rng-module-nodePane-tagSelect').attr('disabled', true).val('');
-                view.find('.rng-module-nodePane-classSelect').attr('disabled', true).val('');
-                view.find('.metaFields').empty();
-            }
-            currentNode = wlxmlNodeElement;
-        }
-    };
-    
-};
-
-});
\ No newline at end of file
diff --git a/src/editor/modules/nodePane/nodePane.less b/src/editor/modules/nodePane/nodePane.less
deleted file mode 100644 (file)
index b7e4012..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-.rng-module-nodePane {
-    label {
-        width: 50px;
-        display: inline-block;
-    }
-    select {
-        width: 100px;
-    }
-
-    input {
-        width: 80px;
-        padding: 0 10px;
-    }
-}
\ No newline at end of file
diff --git a/src/editor/modules/nodePane/template.html b/src/editor/modules/nodePane/template.html
deleted file mode 100644 (file)
index 663dc38..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-<div class="rng-module-nodePane">
-    <fieldset>
-        <legend><%= gettext('Current node') %></legend>
-        <div>
-            <label>Tag</label>
-            <select class="rng-module-nodePane-tagSelect">
-                <% var options = ['', 'section', 'header', 'div', 'span', 'aside']; %>
-                <% options.forEach(function(option) { %>
-                    <option value="<%= option %>" <% if(option === '') { %>selected<% } %>><%= utils.getTagLabel(option) %></option>
-                <% }); %>
-            </select>
-        </div>
-        <div>
-            <label>Klasa</label>
-            <select  class="rng-module-nodePane-classSelect">
-                <% var options = ['', 'author', 'title', 'comment', 'cite', 'cite.code', 'cite.code.xml', 'list.items', 'list.items.enum', 'item', 'link', 'p', 'footnote', 'todo', 'emp', 'gap'] %>
-                <% options.forEach(function(option) { %>
-                    <option value="<%= option.replace(/\./g, '-') %>" <% if(option === '') { %>selected<% } %>><%= utils.getClassLabel(option) %></option>
-                <% }); %>
-            </select>
-        </div>
-        <div class="metaFields">
-        </div>
-    </fieldset>
-</div>
\ No newline at end of file
index dba2d2f..3274067 100644 (file)
@@ -23,22 +23,6 @@ return function(sandbox) {
     }
      
     var commands = {
-        highlightDocumentElement: function(element, origin) {
-            ///'nodeBreadCrumbs', 'nodeFamilyTree'
-            ['documentCanvas', 'nodeFamilyTree'].forEach(function(moduleName) {
-                if(!origin || moduleName !== origin) {
-                    sandbox.getModule(moduleName).highlightElement(element);
-                }
-            });
-        },
-        dimDocumentElement: function(element, origin) {
-            //'nodeBreadCrumbs', 'nodeFamilyTree'
-            ['documentCanvas', 'nodeFamilyTree'].forEach(function(moduleName) {
-                if(!origin || moduleName !== origin) {
-                    sandbox.getModule(moduleName).dimElement(element);
-                }
-            });
-        },
         jumpToDocumentElement: function(element) {
             sandbox.getModule('documentCanvas').jumpToElement(element);
         },
@@ -50,13 +34,9 @@ return function(sandbox) {
             
             if(fragment && fragment.node) {
                 elementParent = fragment.node.getNearestElementNode();
-                sandbox.getModule('nodePane').setNodeElement(elementParent);
-                sandbox.getModule('nodeFamilyTree').setElement(fragment.node);
                 sandbox.getModule('nodeBreadCrumbs').setNodeElement(elementParent);
                 sandbox.getModule('metadataEditor').setNodeElement(elementParent);
             } else {
-                sandbox.getModule('nodePane').setNodeElement(null);
-                sandbox.getModule('nodeFamilyTree').setElement(null);
                 sandbox.getModule('nodeBreadCrumbs').setNodeElement(null);
                 sandbox.getModule('metadataEditor').setNodeElement(null);
             }
@@ -214,12 +194,6 @@ return function(sandbox) {
             commands.refreshCanvasSelection(selection);
         }
     };
-
-    eventHandlers.nodePane = {
-        ready: function() {
-            views.currentNodePaneLayout.appendView(sandbox.getModule('nodePane').getView());
-        }
-    };
     
     eventHandlers.metadataEditor = {
         ready: function() {
@@ -228,21 +202,6 @@ return function(sandbox) {
         }
     };
     
-    eventHandlers.nodeFamilyTree = {
-        ready: function() {
-            views.currentNodePaneLayout.appendView(sandbox.getModule('nodeFamilyTree').getView());
-        },
-        nodeEntered: function(node) {
-            commands.highlightDocumentElement(node, 'nodeFamilyTree');
-        },
-        nodeLeft: function(node) {
-            commands.dimDocumentElement(node, 'nodeFamilyTree');
-        },
-        nodeClicked: function(node) {
-            commands.jumpToDocumentElement(node);
-        }
-    };
-    
     eventHandlers.documentToolbar = {
         ready: function() {
             views.visualEditing.setView('toolbar', sandbox.getModule('documentToolbar').getView());
@@ -257,12 +216,6 @@ return function(sandbox) {
         ready: function() {
             views.visualEditing.setView('statusBar', sandbox.getModule('nodeBreadCrumbs').getView());
         },
-        elementEntered: function(element) {
-            commands.highlightDocumentElement(element, 'nodeBreadCrumbs');
-        },
-        elementLeft: function(element) {
-            commands.dimDocumentElement(element, 'nodeBreadCrumbs');
-        },
         elementClicked: function(element) {
             commands.jumpToDocumentElement(element);
         }
index f9ae798..299cd47 100644 (file)
@@ -12,8 +12,6 @@
 @import '../modules/documentToolbar/documentToolbar.less';
 @import '../modules/documentHistory/documentHistory.less';
 @import '../modules/indicator/indicator.less';
-@import '../modules/nodePane/nodePane.less';
-@import '../modules/nodeFamilyTree/nodeFamilyTree.less';
 @import '../modules/metadataEditor/metadataEditor.less';
 @import '../modules/diffViewer/diffViewer.less';
 @import '../modules/statusBar/statusBar.less';