linting
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Fri, 22 Nov 2013 10:31:07 +0000 (11:31 +0100)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 2 Dec 2013 13:50:53 +0000 (14:50 +0100)
16 files changed:
src/editor/entrypoint.js
src/editor/modules.js
src/editor/modules/data/data.js
src/editor/modules/data/saveDialog.js
src/editor/modules/documentHistory/documentHistory.js
src/editor/modules/documentHistory/restoreDialog.js
src/editor/modules/indicator/indicator.js
src/editor/modules/metadataEditor/metadataEditor.js
src/editor/modules/metadataEditor/transformations.js
src/editor/modules/nodeBreadCrumbs/nodeBreadCrumbs.js
src/editor/modules/nodeFamilyTree/nodeFamilyTree.js
src/editor/modules/nodePane/nodePane.js
src/editor/modules/rng/rng.js
src/editor/modules/sourceEditor/sourceEditor.js
src/editor/rng.js
src/editor/views/tabs/tabs.js

index 851ced3..20460b3 100644 (file)
@@ -1,6 +1,8 @@
 (function() {
     'use strict';
     
+    /* globals requirejs, RNG_BOOTSTRAP_DATA */
+
     requirejs.config({
         baseUrl: '/static/editor/src/editor',
         
index bb4d439..f7c5f6e 100644 (file)
@@ -24,5 +24,5 @@ define(function(require) {
         documentHistory: require('modules/documentHistory/documentHistory'),
         diffViewer: require('modules/diffViewer/diffViewer')
         
-    }
+    };
 });
\ No newline at end of file
index c9ecf7d..a8144cb 100644 (file)
@@ -1,12 +1,14 @@
 define([
+    'libs/jquery',
     './saveDialog',
     'wlxml/wlxml'
 
-], function(saveDialog, wlxml) {
+], function($, saveDialog, wlxml) {
 
 'use strict';
 
 return function(sandbox) {
+    /* global gettext */
 
     var document_id = sandbox.getBootstrappedData().document_id;
     var document_version = sandbox.getBootstrappedData().version;
@@ -16,12 +18,17 @@ return function(sandbox) {
      
     
     function readCookie(name) {
-        var nameEQ = escape(name) + "=";
+        /* global escape, unescape */
+        var nameEQ = escape(name) + '=';
         var ca = document.cookie.split(';');
         for (var i = 0; i < ca.length; i++) {
             var c = ca[i];
-            while (c.charAt(0) == ' ') c = c.substring(1, c.length);
-            if (c.indexOf(nameEQ) === 0) return unescape(c.substring(nameEQ.length, c.length));
+            while (c.charAt(0) === ' ') {
+                c = c.substring(1, c.length);
+            }
+            if (c.indexOf(nameEQ) === 0) {
+                return unescape(c.substring(nameEQ.length, c.length));
+            }
         }
         return null;
     }
@@ -30,7 +37,7 @@ return function(sandbox) {
         crossDomain: false,
         beforeSend: function(xhr, settings) {
             if (!(/^(GET|HEAD|OPTIONS|TRACE)$/.test(settings.type))) {
-                xhr.setRequestHeader("X-CSRFToken", readCookie('csrftoken'));
+                xhr.setRequestHeader('X-CSRFToken', readCookie('csrftoken'));
             }
         }
     });
@@ -40,7 +47,7 @@ return function(sandbox) {
             method: 'get',
             url: '/' + gettext('editor') + '/' + document_id + '/history',
             success: function(data) {
-                history = data; 
+                history = data;
                 sandbox.publish('historyItemAdded', data.slice(-1)[0]);
             },
         });
@@ -53,10 +60,6 @@ return function(sandbox) {
         getDocument: function() {
             return wlxmlDocument;
         },
-        commitDocument: function(newDocument, reason) {
-            // doc = newDocument;
-            // sandbox.publish('documentChanged', doc, reason);
-        },
         saveDocument: function() {
 
             var dialog = saveDialog.create();
@@ -74,7 +77,6 @@ return function(sandbox) {
                     },
                     error: function() {event.error(); sandbox.publish('savingEnded', 'error');}
                 });
-                console.log('save');
             });
             dialog.on('cancel', function() {
             });
@@ -108,7 +110,7 @@ return function(sandbox) {
                         reloadHistory();
                         sandbox.publish('documentReverted', data);
                     },
-                }); 
+                });
             }
         },
         getDocumentId: function() {
index 90832e6..e1f49b4 100644 (file)
@@ -1,9 +1,10 @@
 define([
 'libs/text!./saveDialog.html',
 'libs/underscore',
-'libs/backbone',
-'libs/jquery'
-], function(saveDialogTemplate, _, Backbone, $) {
+'libs/backbone'
+], function(saveDialogTemplate, _, Backbone) {
+
+    'use strict';
 
     var DialogView = Backbone.View.extend({
         template: _.template(saveDialogTemplate),
@@ -16,7 +17,7 @@ define([
             _.bindAll(this);
             this.actionsDisabled = false;
         },
-        show: function() {           
+        show: function() {
             this.setElement(this.template());
             this.$el.modal({backdrop: 'static'});
             this.$el.modal('show');
@@ -33,8 +34,9 @@ define([
             });
         },
         close: function(e) {
-            if(e)
+            if(e) {
                 e.preventDefault();
+            }
             if(!this.actionsDisabled) {
                 this.$el.modal('hide');
                 this.$el.remove();
index f595594..b90fc59 100644 (file)
@@ -17,12 +17,12 @@ return function(sandbox) {
     var itemViews = [];
     
     
-    dom.find('.btn.compare').click(function(e) {
+    dom.find('.btn.compare').click(function() {
         var selected = historyItems.getSelected();
         sandbox.publish('compare', selected[0], selected[1]);
     });
     
-    dom.find('.btn.restore').click(function(e) {
+    dom.find('.btn.restore').click(function() {
         var dialog = restoreDialog.create();
         dialog.on('restore', function(event) {
             sandbox.publish('restoreVersion', {version: historyItems.getSelected()[0], description: event.data.description});
@@ -31,7 +31,7 @@ return function(sandbox) {
         dialog.show();
     });
     
-    dom.find('.btn.display').click(function(e) {
+    dom.find('.btn.display').click(function() {
         sandbox.publish('displayVersion', {version: historyItems.getSelected()[0]});
     });
         
@@ -47,8 +47,9 @@ return function(sandbox) {
     
     var toggleItemViews = function(toggle) {
         itemViews.forEach(function(view) {
-            if(!historyItems.isSelected(view.item))
+            if(!historyItems.isSelected(view.item)) {
                 view.toggle(toggle);
+            }
         });
     };
     
@@ -116,7 +117,7 @@ return function(sandbox) {
             this.dimItem();
         } else if(historyItems.select(this.item)) {
             this.highlightItem();
-        }            
+        }
     };
     ItemView.prototype.highlightItem = function() {
         this.dom.addClass('highlighted');
index 2bf16f6..a05b50f 100644 (file)
@@ -1,9 +1,11 @@
 define([
 'libs/text!./templates/restoreDialog.html',
 'libs/underscore',
-'libs/backbone',
-'libs/jquery'
-], function(restoreDialogTemplate, _, Backbone, $) {
+'libs/backbone'
+], function(restoreDialogTemplate, _, Backbone) {
+
+    'use strict';
+
 
     var DialogView = Backbone.View.extend({
         template: _.template(restoreDialogTemplate),
@@ -16,7 +18,7 @@ define([
             _.bindAll(this);
             this.actionsDisabled = false;
         },
-        show: function() {           
+        show: function() {
             this.setElement(this.template());
             this.$el.modal({backdrop: 'static'});
             this.$el.modal('show');
@@ -32,8 +34,9 @@ define([
             });
         },
         close: function(e) {
-            if(e)
+            if(e) {
                 e.preventDefault();
+            }
             if(!this.actionsDisabled) {
                 this.$el.modal('hide');
                 this.$el.remove();
index 827a4b7..5b9f95c 100644 (file)
@@ -9,10 +9,7 @@ define([
 return function(sandbox) {
 
     var view = {
-        dom: $(_.template(template)()),
-        setup: function() {
-        
-        }
+        dom: $(_.template(template)())
     };
 
     return {
index 94ad85b..0c8a816 100644 (file)
@@ -29,8 +29,7 @@ return function(sandbox) {
             });
             
             this.metaTable.on('keydown', '[contenteditable]', function(e) {
-                console.log(e.which);
-                if(e.which === 13) { 
+                if(e.which === 13) {
                     if($(document.activeElement).hasClass('rng-module-metadataEditor-metaItemKey')) {
                         metaTable.find('.rng-module-metadataEditor-metaItemValue').focus();
                     } else {
@@ -45,15 +44,15 @@ return function(sandbox) {
             
             
             var onKeyUp = function(e) {
-                if(e.which !== 13)
+                if(e.which !== 13) {
                     sandbox.publish('metadataChanged', view.getMetadata());
+                }
             };
             this.metaTable.on('keyup', '[contenteditable]', _.throttle(onKeyUp, 500));
         },
         getMetadata: function() {
             var toret = {};
             this.node.find('tr').each(function() {
-                var tr = $(this);
                 var inputs = $(this).find('td [contenteditable]');
                 var key = $(inputs[0]).text();
                 var value = $(inputs[1]).text();
@@ -64,7 +63,7 @@ return function(sandbox) {
         setMetadata: function(metadata) {
             var view = this;
             this.metaTable.find('tr').remove();
-            _.each(_.keys(metadata), function(key) {    
+            _.each(_.keys(metadata), function(key) {
                 view._addMetaRow(key, metadata[key]);
             });
         },
index a09ee38..4bb3fdc 100644 (file)
@@ -1,4 +1,4 @@
-define(['libs/jquery'], function($) {
+define(['libs/jquery', 'libs/underscore'], function($, _) {
 
     'use strict';
 
@@ -17,6 +17,7 @@ define(['libs/jquery'], function($) {
                 meta.append('\n\t<dc:'+key+'>' + metadata[key] + '</dc:'+key+'>');
             });
             meta.append('\n');
+            /* globals vkbeautify */
             return vkbeautify.xml(meta.html());
         }
     };
index 320a1e8..00c6197 100644 (file)
@@ -13,7 +13,6 @@ return function(sandbox) {
     var view = {
         dom: $('<div>' + template({node:null, parents: null}) + '</div>'),
         setup: function() {
-            var view = this;
             this.dom.on('mouseenter', 'a', function(e) {
                 var target = $(e.target);
                 sandbox.publish('elementEntered', target.data('element'));
index cb7b57a..d6a6290 100644 (file)
@@ -23,7 +23,7 @@ return function(sandbox) {
             return idx;
         }
         return -1;
-    }
+    };
     
     var startListening = function(document) {
         listens = true;
@@ -32,12 +32,11 @@ return function(sandbox) {
                 view.setElement();
             }
         }, this);
-    }
+    };
 
     var view = {
         dom: $('<div>' + template({contents: null, parent: null}) + '</div>'),
         setup: function() {
-            var view = this;
             this.dom.on('click', 'a', function(e) {
                 var target = $(e.target);
                 sandbox.publish('nodeClicked', target.data('element'));
@@ -54,7 +53,6 @@ return function(sandbox) {
         },
         setElement: function(element) {
             element = element || this.currentNodeElement;
-            console.log('familyTree sets node');
             var textElement = element.getText ? element : null,
                 nodeElement = element.getText ? element.parent() : element, // TODO: better type detection
                 nodeElementParent = nodeElement.parent(),
@@ -77,8 +75,9 @@ return function(sandbox) {
             nodeContents.forEach(function(child) {
                 if(child.getText) {
                     var text = child.getText();
-                    if(!text)
+                    if(!text) {
                         text = '<pusty tekst>';
+                    }
                     else {
                         if(text.length > 13) {
                             text = text.substr(0,13) + '...';
@@ -101,7 +100,7 @@ return function(sandbox) {
             this.dom.append($(template({parent: parent, contents: contents})));
 
             if(parent) {
-                this.dom.find('.rng-module-nodeFamilyTree-parent').data('element', nodeElementParent)
+                this.dom.find('.rng-module-nodeFamilyTree-parent').data('element', nodeElementParent);
             }
             this.dom.find('li a').each(function(idx, a) {
                 $(a).data('element', nodeContents[idx]);
@@ -127,8 +126,9 @@ return function(sandbox) {
             if(!listens) {
                 startListening(element.document);
             }
-            if(!(element.sameNode(view.currentNodeElement)))
+            if(!(element.sameNode(view.currentNodeElement))) {
                 view.setElement(element);
+            }
         },
         getView: function() {
             return view.dom;
index b2a1161..5b4f80e 100644 (file)
@@ -31,7 +31,7 @@ return function(sandbox) {
         setNodeElement: function(wlxmlNodeElement) {
             view.find('.rng-module-nodePane-tagSelect').val(wlxmlNodeElement.getTagName());
 
-            var escapedClassName = (wlxmlNodeElement.getClass() || '').replace(/\./g, '-')
+            var escapedClassName = (wlxmlNodeElement.getClass() || '').replace(/\./g, '-');
             view.find('.rng-module-nodePane-classSelect').val(escapedClassName);
 
             var widget = metaWidget.create({attrs:wlxmlNodeElement.getMetaAttributes()});
index d4fa434..3621050 100644 (file)
@@ -1,15 +1,18 @@
 define([
+'libs/underscore',
 'fnpjs/layout',
 'fnpjs/vbox',
 'views/tabs/tabs',
 'libs/text!./mainLayout.html',
 'libs/text!./editingLayout.html',
 'libs/text!./diffLayout.html',
-], function(layout, vbox, tabs, mainLayoutTemplate, visualEditingLayoutTemplate, diffLayoutTemplate) {
+], function(_, layout, vbox, tabs, mainLayoutTemplate, visualEditingLayoutTemplate, diffLayoutTemplate) {
 
 'use strict';
 
 return function(sandbox) {
+
+    /* globals gettext */
     
     function addMainTab(title, slug, view) {
         views.mainTabs.addTab(title, slug, view);
@@ -19,15 +22,17 @@ return function(sandbox) {
         highlightDocumentElement: function(element, origin) {
             ///'nodeBreadCrumbs', 'nodeFamilyTree'
             ['documentCanvas', 'nodeFamilyTree'].forEach(function(moduleName) {
-                if(!origin || moduleName != origin)
+                if(!origin || moduleName !== origin) {
                     sandbox.getModule(moduleName).highlightElement(element);
+                }
             });
         },
         dimDocumentElement: function(element, origin) {
             //'nodeBreadCrumbs', 'nodeFamilyTree'
             ['documentCanvas', 'nodeFamilyTree'].forEach(function(moduleName) {
-                if(!origin || moduleName != origin)
+                if(!origin || moduleName !== origin) {
                     sandbox.getModule(moduleName).dimElement(element);
+                }
             });
         },
         jumpToDocumentElement: function(element) {
@@ -43,12 +48,15 @@ return function(sandbox) {
         },
         resetDocument: function(document, reason) {
             var modules = [];
-            if(reason === 'source_edit')
+            if(reason === 'source_edit') {
                 modules = ['documentCanvas', 'metadataEditor'];
-            else if (reason === 'edit')
+            }
+            else if (reason === 'edit') {
                 modules = ['sourceEditor'];
-            else if (reason === 'revert')
+            }
+            else if (reason === 'revert') {
                 modules = ['documentCanvas', 'metadataEditor', 'sourceEditor'];
+            }
                 
             modules.forEach(function(moduleName) {
                 sandbox.getModule(moduleName).setDocument(document);
@@ -103,6 +111,7 @@ return function(sandbox) {
             sandbox.getModule('indicator').showMessage(gettext('Saving...'));
         },
         savingEnded: function(status) {
+            void(status);
             sandbox.getModule('mainBar').setCommandEnabled('save', true);
             sandbox.getModule('indicator').clearMessage({message:'Dokument zapisany'});
         },
@@ -222,7 +231,7 @@ return function(sandbox) {
         },
         elementClicked: function(element) {
             commands.jumpToDocumentElement(element);
-        }        
+        }
     };
     
     eventHandlers.documentHistory = {
@@ -254,9 +263,7 @@ return function(sandbox) {
             sandbox.getModule('data').start();
         },
         handleEvent: function(moduleName, eventName, args) {
-            if('')
-                wysiwigHandler.handleEvent(moduleName, eventName, args);
-            else if(eventHandlers[moduleName] && eventHandlers[moduleName][eventName]) {
+            if(eventHandlers[moduleName] && eventHandlers[moduleName][eventName]) {
                 eventHandlers[moduleName][eventName].apply(eventHandlers, args);
             }
         }
index 0d7b12e..a2ec127 100644 (file)
@@ -1,4 +1,4 @@
-define(function() {
+define(['libs/jquery'], function($) {
 
 'use strict';
 
@@ -18,19 +18,20 @@ return function(sandbox) {
             sandbox.publish('documentSet');
             documentIsDirty = false;
         }
-    }
+    };
 
     view.onHide = function() {
         if(documentEditedHere) {
             documentEditedHere = false;
             wlxmlDocument.loadXML(editor.getValue());
         }
-    }
+    };
     
+    /* globals ace */
     var editor = ace.edit(view.find('#rng-sourceEditor-editor')[0]),
         session = editor.getSession();
-    editor.setTheme("ace/theme/chrome");
-    session.setMode("ace/mode/xml")
+    editor.setTheme('ace/theme/chrome');
+    session.setMode('ace/mode/xml');
     session.setUseWrapMode(true);
     
     $('textarea', view).on('keyup', function() {
index 04a8d4f..f19604d 100644 (file)
@@ -3,12 +3,12 @@ define(function() {
 'use strict';
     
 return {
-    modules: {}, 
+    modules: {},
     initModules: ['rng'],
     permissions: {
         'skelton': ['getDOM'],
         'rng': ['getModule', 'handleEvents', 'getDOM']
     }
-}
+};
 
 });
\ No newline at end of file
index b910b92..ada2dba 100644 (file)
@@ -1,9 +1,10 @@
 define([
+'libs/jquery',
 'libs/text!./templates/main.html',
 'libs/text!./templates/handle.html',
 'libs/underscore',
 'libs/backbone'
-], function(mainTemplate, handleTemplate, _, Backbone) {
+], function($, mainTemplate, handleTemplate, _, Backbone) {
     'use strict';
     
     var View = Backbone.View.extend({
@@ -47,10 +48,12 @@ define([
             var text = (typeof title === 'string') ? title : (title.text || '');
             var icon = title.icon || null;
             
-            if(!this.tabExists(slug))
+            if(!this.tabExists(slug)) {
                 this.nodes.tabBar.append(this.handleTemplate({text: text, icon: icon, slug: slug}));
-            if(!this.selectedTab)
+            }
+            if(!this.selectedTab) {
                 this.selectTab(slug);
+            }
         },
         
         selectTab: function(slug) {
@@ -59,8 +62,9 @@ define([
                 
                 if(this.selectedTab) {
                     var toDetach = this.contents[this.selectedTab];
-                    if(toDetach.onHide)
+                    if(toDetach.onHide) {
                         toDetach.onHide();
+                    }
                     toDetach.detach();
                 }
                 this.nodes.content.append(this.contents[slug]);
@@ -93,8 +97,9 @@ define([
         _onTabTitleClicked: function(e) {
             e.preventDefault();
             var target = $(e.target);
-            if(target.is('i'))
+            if(target.is('i')) {
                 target = target.parent();
+            }
             var slug = target.attr('href').substr(1);
             this.selectTab(slug);
         }