Converting end of lines from crlf to lf
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 1 Jul 2013 07:48:16 +0000 (09:48 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 1 Jul 2013 07:48:16 +0000 (09:48 +0200)
67 files changed:
entrypoint.js
fnpjs/layout.js
fnpjs/runner.js
fnpjs/vbox.js
karma.conf.js
modules.js
modules/data/data.js
modules/data/saveDialog.html
modules/data/saveDialog.js
modules/data/saveDialog.less
modules/diffViewer/diffViewer.js
modules/diffViewer/diffViewer.less
modules/documentCanvas/canvas.js
modules/documentCanvas/canvasManager.js
modules/documentCanvas/canvasNode.js
modules/documentCanvas/documentCanvas.js
modules/documentCanvas/documentCanvas.less
modules/documentCanvas/nodes.less
modules/documentCanvas/template.html
modules/documentCanvas/tests/canvas.test.js
modules/documentCanvas/tests/canvasNode.test.js
modules/documentCanvas/tests/utils.js
modules/documentCanvas/tests/utils.test.js
modules/documentCanvas/transformations.js
modules/documentHistory/documentHistory.js
modules/documentHistory/documentHistory.less
modules/documentHistory/restoreDialog.js
modules/documentHistory/templates/item.html
modules/documentHistory/templates/main.html
modules/documentHistory/templates/restoreDialog.html
modules/documentToolbar/documentToolbar.js
modules/documentToolbar/documentToolbar.less
modules/documentToolbar/template.html
modules/indicator/indicator.js
modules/indicator/indicator.less
modules/indicator/template.html
modules/mainBar/mainBar.js
modules/mainBar/mainBar.less
modules/mainBar/template.html
modules/metadataEditor/metadataEditor.js
modules/metadataEditor/metadataEditor.less
modules/metadataEditor/templates/item.html
modules/metadataEditor/templates/main.html
modules/metadataEditor/transformations.js
modules/nodeBreadCrumbs/nodeBreadCrumbs.js
modules/nodeFamilyTree/nodeFamilyTree.js
modules/nodeFamilyTree/nodeFamilyTree.less
modules/nodeFamilyTree/template.html
modules/nodePane/nodePane.js
modules/nodePane/nodePane.less
modules/nodePane/template.html
modules/rng/diffLayout.html
modules/rng/diffLayout.less
modules/rng/editingLayout.html
modules/rng/editingLayout.less
modules/rng/mainLayout.html
modules/rng/mainLayout.less
modules/rng/rng.js
modules/rng/rng.less
modules/sourceEditor/sourceEditor.js
modules/sourceEditor/sourceEditor.less
styles/common.less
styles/main.less
styles/mixins.less
tests/main.js
views/tabs/tabs.js
views/tabs/templates/main.html

index 6f81c94..f15a832 100644 (file)
@@ -1,7 +1,7 @@
 (function() {
     'use strict';
     
 (function() {
     'use strict';
     
-    requirejs.config({\r
+    requirejs.config({
         baseUrl: '/static/editor',
         
         shim: {
         baseUrl: '/static/editor',
         
         shim: {
@@ -19,7 +19,7 @@
                 deps: ['libs/jquery-1.9.1.min', 'libs/underscore-min']
             }
         }
                 deps: ['libs/jquery-1.9.1.min', 'libs/underscore-min']
             }
         }
-\r
+
     });
     
     requirejs([
     });
     
     requirejs([
index d5fa098..05252fb 100644 (file)
@@ -1,37 +1,37 @@
-define(['libs/jquery-1.9.1.min', 'libs/underscore-min'], function($ ,_) {\r
-    'use strict';\r
-      \r
-    var Layout = function(template) {\r
-        var layout = this;\r
-        this.dom = $(_.template(template)());\r
-        this.views = {};\r
-        \r
-        this.dom.onShow = function() {\r
-            _.values(layout.views).forEach(function(view) {\r
-                if(view.onShow)\r
-                    view.onShow();\r
-            });\r
-        };\r
-        this.dom.onHide = function() {\r
-            _.values(layout.views).forEach(function(view) {\r
-                if(view.onHide)\r
-                    view.onHide();\r
-            });\r
-        };\r
-        \r
-    };\r
-    \r
-    Layout.prototype.setView = function(place, view) {\r
-        this.dom.find('[fnpjs-place=' + place + ']').append(view);\r
-        this.views[place] = view;\r
-        if(this.dom.is(':visible') && view.onShow) {\r
-            view.onShow();\r
-        }\r
-    };\r
-    \r
-    Layout.prototype.getAsView = function() {\r
-        return this.dom;\r
-    };\r
-    \r
-    return {Layout: Layout};\r
+define(['libs/jquery-1.9.1.min', 'libs/underscore-min'], function($ ,_) {
+    'use strict';
+      
+    var Layout = function(template) {
+        var layout = this;
+        this.dom = $(_.template(template)());
+        this.views = {};
+        
+        this.dom.onShow = function() {
+            _.values(layout.views).forEach(function(view) {
+                if(view.onShow)
+                    view.onShow();
+            });
+        };
+        this.dom.onHide = function() {
+            _.values(layout.views).forEach(function(view) {
+                if(view.onHide)
+                    view.onHide();
+            });
+        };
+        
+    };
+    
+    Layout.prototype.setView = function(place, view) {
+        this.dom.find('[fnpjs-place=' + place + ']').append(view);
+        this.views[place] = view;
+        if(this.dom.is(':visible') && view.onShow) {
+            view.onShow();
+        }
+    };
+    
+    Layout.prototype.getAsView = function() {
+        return this.dom;
+    };
+    
+    return {Layout: Layout};
 });
\ No newline at end of file
 });
\ No newline at end of file
index 817011d..d8dcda9 100644 (file)
@@ -1,77 +1,77 @@
-define(['libs/jquery-1.9.1.min', 'libs/underscore-min'], function($, _) {\r
-\r
-var Runner = function(app, modules) {\r
-\r
-    function getModuleInstance(moduleName) {\r
-        var module = moduleInstances[moduleName] = (moduleInstances[moduleName] || modules[moduleName](new Sandbox(moduleName)));\r
-        return module;\r
-    }\r
-\r
-    var bootstrappedData = {},\r
-        options = {},\r
-        moduleInstances = {},\r
-        eventListeners = [];\r
-        \r
-    _.each(_.keys(modules || {}), function(moduleName) {\r
-        if(_.contains(app.permissions[moduleName] || [], 'handleEvents')) {\r
-            eventListeners.push(moduleName);\r
-        }\r
-    });\r
-\r
-    \r
-        \r
-    var Sandbox = function(moduleName) {\r
-        this.$ = $;\r
-        this._ = _;\r
-        \r
-        this.getBootstrappedData = function() {\r
-            return bootstrappedData[moduleName];\r
-        };\r
-        \r
-        this.getTemplate = function(templateName) {\r
-            return _.template($('[data-template-name="' + moduleName + '.' + templateName + '"]').html().trim());\r
-        };\r
-        \r
-        this.publish = function(eventName) {\r
-            console.log(moduleName + ': ' + eventName);\r
-            var eventArgs = Array.prototype.slice.call(arguments, 1);\r
-            _.each(eventListeners, function(listenerModuleName) {\r
-                var listener = moduleInstances[listenerModuleName];\r
-                if(listener) {\r
-                    listener.handleEvent(moduleName, eventName, eventArgs);\r
-                }\r
-            });\r
-        };\r
-        \r
-        var permissions = app.permissions[moduleName];\r
-        \r
-        this.getModule = _.contains(permissions, 'getModule') ? function(requestedModuleName) {\r
-            return getModuleInstance(requestedModuleName);\r
-        } : undefined;\r
-        \r
-        this.getDOM = _.contains(permissions, 'getDOM') ? function() {\r
-            return $(options.rootSelector);\r
-        } : undefined;\r
-        \r
-    };\r
-    \r
-    \r
-    this.setBootstrappedData = function(moduleName, data) {\r
-        bootstrappedData[moduleName] = data;\r
-    };\r
-    \r
-    this.start = function(_options) {\r
-        options = _.extend({\r
-            rootSelector: 'body'\r
-        }, _options);\r
-        app.initModules.forEach(function(moduleName) {\r
-            getModuleInstance(moduleName).start();\r
-        });\r
-    };\r
-};\r
-\r
-return {\r
-    Runner: Runner\r
-};\r
-\r
+define(['libs/jquery-1.9.1.min', 'libs/underscore-min'], function($, _) {
+
+var Runner = function(app, modules) {
+
+    function getModuleInstance(moduleName) {
+        var module = moduleInstances[moduleName] = (moduleInstances[moduleName] || modules[moduleName](new Sandbox(moduleName)));
+        return module;
+    }
+
+    var bootstrappedData = {},
+        options = {},
+        moduleInstances = {},
+        eventListeners = [];
+        
+    _.each(_.keys(modules || {}), function(moduleName) {
+        if(_.contains(app.permissions[moduleName] || [], 'handleEvents')) {
+            eventListeners.push(moduleName);
+        }
+    });
+
+    
+        
+    var Sandbox = function(moduleName) {
+        this.$ = $;
+        this._ = _;
+        
+        this.getBootstrappedData = function() {
+            return bootstrappedData[moduleName];
+        };
+        
+        this.getTemplate = function(templateName) {
+            return _.template($('[data-template-name="' + moduleName + '.' + templateName + '"]').html().trim());
+        };
+        
+        this.publish = function(eventName) {
+            console.log(moduleName + ': ' + eventName);
+            var eventArgs = Array.prototype.slice.call(arguments, 1);
+            _.each(eventListeners, function(listenerModuleName) {
+                var listener = moduleInstances[listenerModuleName];
+                if(listener) {
+                    listener.handleEvent(moduleName, eventName, eventArgs);
+                }
+            });
+        };
+        
+        var permissions = app.permissions[moduleName];
+        
+        this.getModule = _.contains(permissions, 'getModule') ? function(requestedModuleName) {
+            return getModuleInstance(requestedModuleName);
+        } : undefined;
+        
+        this.getDOM = _.contains(permissions, 'getDOM') ? function() {
+            return $(options.rootSelector);
+        } : undefined;
+        
+    };
+    
+    
+    this.setBootstrappedData = function(moduleName, data) {
+        bootstrappedData[moduleName] = data;
+    };
+    
+    this.start = function(_options) {
+        options = _.extend({
+            rootSelector: 'body'
+        }, _options);
+        app.initModules.forEach(function(moduleName) {
+            getModuleInstance(moduleName).start();
+        });
+    };
+};
+
+return {
+    Runner: Runner
+};
+
 });
\ No newline at end of file
 });
\ No newline at end of file
index 84ac6db..569bf16 100644 (file)
@@ -1,13 +1,13 @@
-define(['libs/jquery-1.9.1.min', './layout'], function($, layout) {\r
-    \r
-    var VBox = function() {};\r
-    \r
-    VBox.prototype = new layout.Layout('<div class="fnpjs-vbox"></div>');\r
-    VBox.prototype.appendView = function(view) {\r
-        var item = $('<div>').addClass('fnpjs-vbox-item').append(view);\r
-        this.dom.append(item);\r
-    };\r
-    \r
-    return {VBox: VBox};\r
-    \r
+define(['libs/jquery-1.9.1.min', './layout'], function($, layout) {
+    
+    var VBox = function() {};
+    
+    VBox.prototype = new layout.Layout('<div class="fnpjs-vbox"></div>');
+    VBox.prototype.appendView = function(view) {
+        var item = $('<div>').addClass('fnpjs-vbox-item').append(view);
+        this.dom.append(item);
+    };
+    
+    return {VBox: VBox};
+    
 });
\ No newline at end of file
 });
\ No newline at end of file
index 9f3fa53..5153a22 100644 (file)
@@ -1,42 +1,42 @@
-basePath = '';\r
-\r
-files = [\r
-  MOCHA,\r
-  MOCHA_ADAPTER,\r
-  REQUIRE,\r
-  REQUIRE_ADAPTER,\r
-  \r
-  'vkbeautify.js',\r
-  {pattern: 'libs/*.js', included: false},\r
-  {pattern: 'fnpjs/**/*.js', included: false},\r
-  {pattern: 'modules/**/*.js', included: false},\r
-  {pattern: 'views/**/*.js', included: false},\r
-  {pattern: 'fnpjs/**/*.html', included: false},\r
-  {pattern: 'modules/**/*.html', included: false},\r
-  {pattern: 'views/**/*.html', included: false},\r
-\r
-  'tests/main.js',\r
-];\r
-\r
-reporters = ['progress'];\r
-\r
-port = 9876;\r
-runnerPort = 9100;\r
-captureTimeout = 60000;\r
-\r
-autoWatch = true;\r
-singleRun = false;\r
-\r
-browsers = ['PhantomJS'];\r
-\r
-colors = true;\r
-logLevel = LOG_INFO;\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
+basePath = '';
+
+files = [
+  MOCHA,
+  MOCHA_ADAPTER,
+  REQUIRE,
+  REQUIRE_ADAPTER,
+  
+  'vkbeautify.js',
+  {pattern: 'libs/*.js', included: false},
+  {pattern: 'fnpjs/**/*.js', included: false},
+  {pattern: 'modules/**/*.js', included: false},
+  {pattern: 'views/**/*.js', included: false},
+  {pattern: 'fnpjs/**/*.html', included: false},
+  {pattern: 'modules/**/*.html', included: false},
+  {pattern: 'views/**/*.html', included: false},
+
+  'tests/main.js',
+];
+
+reporters = ['progress'];
+
+port = 9876;
+runnerPort = 9100;
+captureTimeout = 60000;
+
+autoWatch = true;
+singleRun = false;
+
+browsers = ['PhantomJS'];
+
+colors = true;
+logLevel = LOG_INFO;
+
+
+
+
+
+
+
+
+
index 46d787e..bb4d439 100644 (file)
@@ -1,28 +1,28 @@
-define(function(require) {\r
-    /*\r
-       Each module must be required explicitly by apropriate 'require' function call\r
-       in order for requirejs optimizer to work.\r
-    */\r
-    \r
-    'use strict';\r
-    \r
-    return {\r
-        data: require('modules/data/data'),\r
-        rng: require('modules/rng/rng'),\r
-        mainBar: require('modules/mainBar/mainBar'),\r
-        indicator: require('modules/indicator/indicator'),\r
-        \r
-        sourceEditor: require('modules/sourceEditor/sourceEditor'),\r
-        \r
-        documentCanvas: require('modules/documentCanvas/documentCanvas'),\r
-        documentToolbar: require('modules/documentToolbar/documentToolbar'),\r
-        nodePane: require('modules/nodePane/nodePane'),\r
-        metadataEditor: require('modules/metadataEditor/metadataEditor'),\r
-        nodeFamilyTree: require('modules/nodeFamilyTree/nodeFamilyTree'),\r
-        nodeBreadCrumbs: require('modules/nodeBreadCrumbs/nodeBreadCrumbs'),\r
-        \r
-        documentHistory: require('modules/documentHistory/documentHistory'),\r
-        diffViewer: require('modules/diffViewer/diffViewer')\r
-        \r
-    }\r
+define(function(require) {
+    /*
+       Each module must be required explicitly by apropriate 'require' function call
+       in order for requirejs optimizer to work.
+    */
+    
+    'use strict';
+    
+    return {
+        data: require('modules/data/data'),
+        rng: require('modules/rng/rng'),
+        mainBar: require('modules/mainBar/mainBar'),
+        indicator: require('modules/indicator/indicator'),
+        
+        sourceEditor: require('modules/sourceEditor/sourceEditor'),
+        
+        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'),
+        diffViewer: require('modules/diffViewer/diffViewer')
+        
+    }
 });
\ No newline at end of file
 });
\ No newline at end of file
index 8bd553c..9b2f163 100644 (file)
-define(['./saveDialog'], function(saveDialog) {\r
-\r
-'use strict';\r
-\r
-return function(sandbox) {\r
-\r
-    var doc = sandbox.getBootstrappedData().document;\r
-    var document_id = sandbox.getBootstrappedData().document_id;\r
-    var document_version = sandbox.getBootstrappedData().version;\r
-    var history = sandbox.getBootstrappedData().history;\r
-\r
-    \r
-    if(doc === '') {\r
-        doc = '<section\n\\r
-        xmlns="http://nowoczesnapolska.org.pl/sst#"\n\\r
-        xmlns:xlink="http://www.w3.org/1999/xlink"\n\\r
-        xmlns:dc="http://purl.org/dc/elements/1.1/"\n\\r
-        xmlns:dcterms="http://purl.org/dc/terms/"\n\\r
-    >\n\\r
-        <metadata>\n\\r
-        </metadata>\n\\r
-        <div class="p"></div>\n\\r
-    </section>';\r
-    }\r
-    \r
-    \r
-    function readCookie(name) {\r
-        var nameEQ = escape(name) + "=";\r
-        var ca = document.cookie.split(';');\r
-        for (var i = 0; i < ca.length; i++) {\r
-            var c = ca[i];\r
-            while (c.charAt(0) == ' ') c = c.substring(1, c.length);\r
-            if (c.indexOf(nameEQ) === 0) return unescape(c.substring(nameEQ.length, c.length));\r
-        }\r
-        return null;\r
-    }\r
-    \r
-    $.ajaxSetup({\r
-        crossDomain: false,\r
-        beforeSend: function(xhr, settings) {\r
-            if (!(/^(GET|HEAD|OPTIONS|TRACE)$/.test(settings.type))) {\r
-                xhr.setRequestHeader("X-CSRFToken", readCookie('csrftoken'));\r
-            }\r
-        }\r
-    });\r
-    \r
-    var reloadHistory = function() {\r
-        $.ajax({\r
-            method: 'get',\r
-            url: '/' + gettext('editor') + '/' + document_id + '/history',\r
-            success: function(data) {\r
-                history = data; \r
-                sandbox.publish('historyItemAdded', data.slice(-1)[0]);\r
-            },\r
-        });\r
-    };\r
-    \r
-    return {\r
-        start: function() {\r
-            sandbox.publish('ready');\r
-        },\r
-        getDocument: function() {\r
-            return doc;\r
-        },\r
-        commitDocument: function(newDocument, reason) {\r
-            doc = newDocument;\r
-            sandbox.publish('documentChanged', doc, reason);\r
-        },\r
-        saveDocument: function() {\r
-\r
-            var dialog = saveDialog.create();\r
-            dialog.on('save', function(event) {\r
-                sandbox.publish('savingStarted');\r
-                dialog.toggleButtons(false);\r
-                $.ajax({\r
-                    method: 'post',\r
-                    url: '/' + gettext('editor') + '/' + document_id,\r
-                    data: JSON.stringify({document:doc, description: event.data.description}),\r
-                    success: function() {\r
-                        event.success();\r
-                        sandbox.publish('savingEnded', 'success');\r
-                        reloadHistory();\r
-                    },\r
-                    error: function() {event.error(); sandbox.publish('savingEnded', 'error');}\r
-                });\r
-                console.log('save');\r
-            });\r
-            dialog.on('cancel', function() {\r
-            });\r
-            dialog.show();\r
-            \r
-\r
-        },\r
-        getHistory: function() {\r
-            return history;\r
-        },\r
-        fetchDiff: function(ver1, ver2) {\r
-            $.ajax({\r
-                method: 'get',\r
-                url: '/' + gettext('editor') + '/' + document_id + '/diff',\r
-                data: {from: ver1, to: ver2},\r
-                success: function(data) {\r
-                    sandbox.publish('diffFetched', {table: data, ver1: ver1, ver2: ver2});\r
-                },\r
-            });\r
-        },\r
-        restoreVersion: function(options) {\r
-            if(options.version && options.description) {\r
-                sandbox.publish('restoringStarted', {version: options.version});\r
-                $.ajax({\r
-                    method: 'post',\r
-                    dataType: 'json',\r
-                    url: '/' + gettext('editor') + '/' + document_id + '/revert',\r
-                    data: JSON.stringify(options),\r
-                    success: function(data) {\r
-                        doc = data.document;\r
-                        document_version = data.version;\r
-                        reloadHistory();\r
-                        sandbox.publish('documentReverted', data);\r
-                    },\r
-                }); \r
-            }\r
-        },\r
-        getDocumentId: function() {\r
-            return document_id;\r
-        },\r
-        getDocumentVersion: function() {\r
-            return document_version;\r
-        }\r
-    };\r
-};\r
-\r
+define(['./saveDialog'], function(saveDialog) {
+
+'use strict';
+
+return function(sandbox) {
+
+    var doc = sandbox.getBootstrappedData().document;
+    var document_id = sandbox.getBootstrappedData().document_id;
+    var document_version = sandbox.getBootstrappedData().version;
+    var history = sandbox.getBootstrappedData().history;
+
+    
+    if(doc === '') {
+        doc = '<section\n\
+        xmlns="http://nowoczesnapolska.org.pl/sst#"\n\
+        xmlns:xlink="http://www.w3.org/1999/xlink"\n\
+        xmlns:dc="http://purl.org/dc/elements/1.1/"\n\
+        xmlns:dcterms="http://purl.org/dc/terms/"\n\
+    >\n\
+        <metadata>\n\
+        </metadata>\n\
+        <div class="p"></div>\n\
+    </section>';
+    }
+    
+    
+    function readCookie(name) {
+        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));
+        }
+        return null;
+    }
+    
+    $.ajaxSetup({
+        crossDomain: false,
+        beforeSend: function(xhr, settings) {
+            if (!(/^(GET|HEAD|OPTIONS|TRACE)$/.test(settings.type))) {
+                xhr.setRequestHeader("X-CSRFToken", readCookie('csrftoken'));
+            }
+        }
+    });
+    
+    var reloadHistory = function() {
+        $.ajax({
+            method: 'get',
+            url: '/' + gettext('editor') + '/' + document_id + '/history',
+            success: function(data) {
+                history = data; 
+                sandbox.publish('historyItemAdded', data.slice(-1)[0]);
+            },
+        });
+    };
+    
+    return {
+        start: function() {
+            sandbox.publish('ready');
+        },
+        getDocument: function() {
+            return doc;
+        },
+        commitDocument: function(newDocument, reason) {
+            doc = newDocument;
+            sandbox.publish('documentChanged', doc, reason);
+        },
+        saveDocument: function() {
+
+            var dialog = saveDialog.create();
+            dialog.on('save', function(event) {
+                sandbox.publish('savingStarted');
+                dialog.toggleButtons(false);
+                $.ajax({
+                    method: 'post',
+                    url: '/' + gettext('editor') + '/' + document_id,
+                    data: JSON.stringify({document:doc, description: event.data.description}),
+                    success: function() {
+                        event.success();
+                        sandbox.publish('savingEnded', 'success');
+                        reloadHistory();
+                    },
+                    error: function() {event.error(); sandbox.publish('savingEnded', 'error');}
+                });
+                console.log('save');
+            });
+            dialog.on('cancel', function() {
+            });
+            dialog.show();
+            
+
+        },
+        getHistory: function() {
+            return history;
+        },
+        fetchDiff: function(ver1, ver2) {
+            $.ajax({
+                method: 'get',
+                url: '/' + gettext('editor') + '/' + document_id + '/diff',
+                data: {from: ver1, to: ver2},
+                success: function(data) {
+                    sandbox.publish('diffFetched', {table: data, ver1: ver1, ver2: ver2});
+                },
+            });
+        },
+        restoreVersion: function(options) {
+            if(options.version && options.description) {
+                sandbox.publish('restoringStarted', {version: options.version});
+                $.ajax({
+                    method: 'post',
+                    dataType: 'json',
+                    url: '/' + gettext('editor') + '/' + document_id + '/revert',
+                    data: JSON.stringify(options),
+                    success: function(data) {
+                        doc = data.document;
+                        document_version = data.version;
+                        reloadHistory();
+                        sandbox.publish('documentReverted', data);
+                    },
+                }); 
+            }
+        },
+        getDocumentId: function() {
+            return document_id;
+        },
+        getDocumentVersion: function() {
+            return document_version;
+        }
+    };
+};
+
 });
\ No newline at end of file
 });
\ No newline at end of file
index 496d886..0846910 100644 (file)
@@ -1,14 +1,14 @@
-<div class="rng-module-data-saveDialog modal hide static">\r
-    <div class="modal-header">\r
-        <button type="button" class="close">&times;</button>\r
-        <h1>Zapisz dokument</h1>\r
-    </div>\r
-    <div class="modal-body">\r
-        <label>Opisz swoje zmiany</label>\r
-        <textarea rows="5"></textarea>\r
-    </div>\r
-    <div class="modal-footer">\r
-        <a href="#" class="btn btn-info btn-mini save-btn">Zapisz</a>\r
-        <a href="#" class="btn btn-danger btn-mini cancel-btn">Anuluj</a>\r
-    </div>\r
+<div class="rng-module-data-saveDialog modal hide static">
+    <div class="modal-header">
+        <button type="button" class="close">&times;</button>
+        <h1>Zapisz dokument</h1>
+    </div>
+    <div class="modal-body">
+        <label>Opisz swoje zmiany</label>
+        <textarea rows="5"></textarea>
+    </div>
+    <div class="modal-footer">
+        <a href="#" class="btn btn-info btn-mini save-btn">Zapisz</a>
+        <a href="#" class="btn btn-danger btn-mini cancel-btn">Anuluj</a>
+    </div>
 </div>
\ No newline at end of file
 </div>
\ No newline at end of file
index 0bdb718..d0049d5 100644 (file)
@@ -1,56 +1,56 @@
-define([\r
-'libs/text!./saveDialog.html',\r
-'libs/underscore-min',\r
-'libs/backbone-min',\r
-'libs/jquery-1.9.1.min'\r
-], function(saveDialogTemplate, _, Backbone, $) {\r
-\r
-    var DialogView = Backbone.View.extend({\r
-        template: _.template(saveDialogTemplate),\r
-        events: {\r
-            'click .save-btn': 'onSave',\r
-            'click .cancel-btn': 'close',\r
-            'click .close': 'close'\r
-        },\r
-        initialize: function() {\r
-            _.bindAll(this);\r
-            this.actionsDisabled = false;\r
-        },\r
-        show: function() {           \r
-            this.setElement(this.template());\r
-            this.$el.modal({backdrop: 'static'});\r
-            this.$el.modal('show');\r
-            this.$('textarea').focus();\r
-\r
-        },\r
-        onSave: function(e) {\r
-            e.preventDefault();\r
-            var view = this;\r
-            this.trigger('save', {\r
-                data: {description: view.$el.find('textarea').val()},\r
-                success: function() { view.actionsDisabled = false; view.close(); },\r
-                error: function() { view.actionsDisabled = false; view.close(); },\r
-            });\r
-        },\r
-        close: function(e) {\r
-            if(e)\r
-                e.preventDefault();\r
-            if(!this.actionsDisabled) {\r
-                this.$el.modal('hide');\r
-                this.$el.remove();\r
-            }\r
-        },\r
-        toggleButtons: function(toggle) {\r
-            this.$('.btn, button').toggleClass('disabled', !toggle);\r
-            this.$('textarea').attr('disabled', !toggle);\r
-            this.actionsDisabled = !toggle;\r
-        }\r
-    });\r
-\r
-    return {\r
-        create: function() {\r
-            return new DialogView();\r
-        }\r
-    };\r
-\r
+define([
+'libs/text!./saveDialog.html',
+'libs/underscore-min',
+'libs/backbone-min',
+'libs/jquery-1.9.1.min'
+], function(saveDialogTemplate, _, Backbone, $) {
+
+    var DialogView = Backbone.View.extend({
+        template: _.template(saveDialogTemplate),
+        events: {
+            'click .save-btn': 'onSave',
+            'click .cancel-btn': 'close',
+            'click .close': 'close'
+        },
+        initialize: function() {
+            _.bindAll(this);
+            this.actionsDisabled = false;
+        },
+        show: function() {           
+            this.setElement(this.template());
+            this.$el.modal({backdrop: 'static'});
+            this.$el.modal('show');
+            this.$('textarea').focus();
+
+        },
+        onSave: function(e) {
+            e.preventDefault();
+            var view = this;
+            this.trigger('save', {
+                data: {description: view.$el.find('textarea').val()},
+                success: function() { view.actionsDisabled = false; view.close(); },
+                error: function() { view.actionsDisabled = false; view.close(); },
+            });
+        },
+        close: function(e) {
+            if(e)
+                e.preventDefault();
+            if(!this.actionsDisabled) {
+                this.$el.modal('hide');
+                this.$el.remove();
+            }
+        },
+        toggleButtons: function(toggle) {
+            this.$('.btn, button').toggleClass('disabled', !toggle);
+            this.$('textarea').attr('disabled', !toggle);
+            this.actionsDisabled = !toggle;
+        }
+    });
+
+    return {
+        create: function() {
+            return new DialogView();
+        }
+    };
+
 });
\ No newline at end of file
 });
\ No newline at end of file
index 53c7d47..e863e93 100644 (file)
@@ -1,19 +1,19 @@
-.rng-module-data-saveDialog {\r
-    textarea {\r
-        padding: 3px 3px;\r
-        margin: 5px auto;\r
-        width: 95%;\r
-        display: block;\r
-    }\r
-    \r
-    h1, label {\r
-        font-size: 12px;\r
-        line-height: 12px;\r
-\r
-    }\r
-    \r
-    h1 {\r
-        margin: 2px 5px;\r
-        font-weight: bold;\r
-    }\r
+.rng-module-data-saveDialog {
+    textarea {
+        padding: 3px 3px;
+        margin: 5px auto;
+        width: 95%;
+        display: block;
+    }
+    
+    h1, label {
+        font-size: 12px;
+        line-height: 12px;
+
+    }
+    
+    h1 {
+        margin: 2px 5px;
+        font-weight: bold;
+    }
 }
\ No newline at end of file
 }
\ No newline at end of file
index 12e022a..be0e431 100644 (file)
@@ -1,38 +1,38 @@
-define([\r
-'libs/jquery-1.9.1.min',\r
-'libs/underscore-min',\r
-'views/tabs/tabs',\r
-'libs/text!./diff.html'\r
-], function($, _, tabs, diffTemplateSrc) {\r
-\r
-'use strict';\r
-\r
-return function(sandbox) {\r
-    \r
-    var dom = $('<div>').addClass('rng-module-diffViewer');\r
-    var tabsView = (new tabs.View({position: 'right'})).render();\r
-    dom.append(tabsView.getAsView());\r
-    \r
-    var DiffView = function() {\r
-        this.dom = $(diffTemplateSrc);\r
-    };\r
-    \r
-    DiffView.prototype.setTable = function(table) {\r
-        this.dom.append(table);\r
-    };\r
-    \r
-\r
-    return {\r
-        start: function() {sandbox.publish('ready');},\r
-        getView: function() {return dom;},\r
-        setDiff: function(diff) {\r
-            var diffView = new DiffView();\r
-            diffView.setTable(diff.table);\r
-            var slug = diff.ver1 + '-' + diff.ver2;\r
-            tabsView.addTab(diff.ver1 + '->' + diff.ver2, slug, diffView.dom);\r
-            tabsView.selectTab(slug);\r
-        }\r
-    };\r
-};\r
-\r
+define([
+'libs/jquery-1.9.1.min',
+'libs/underscore-min',
+'views/tabs/tabs',
+'libs/text!./diff.html'
+], function($, _, tabs, diffTemplateSrc) {
+
+'use strict';
+
+return function(sandbox) {
+    
+    var dom = $('<div>').addClass('rng-module-diffViewer');
+    var tabsView = (new tabs.View({position: 'right'})).render();
+    dom.append(tabsView.getAsView());
+    
+    var DiffView = function() {
+        this.dom = $(diffTemplateSrc);
+    };
+    
+    DiffView.prototype.setTable = function(table) {
+        this.dom.append(table);
+    };
+    
+
+    return {
+        start: function() {sandbox.publish('ready');},
+        getView: function() {return dom;},
+        setDiff: function(diff) {
+            var diffView = new DiffView();
+            diffView.setTable(diff.table);
+            var slug = diff.ver1 + '-' + diff.ver2;
+            tabsView.addTab(diff.ver1 + '->' + diff.ver2, slug, diffView.dom);
+            tabsView.selectTab(slug);
+        }
+    };
+};
+
 });
\ No newline at end of file
 });
\ No newline at end of file
index 1ab9c32..34ab240 100644 (file)
@@ -1,77 +1,77 @@
-.rng-module-diffViewer {\r
-    .nav-tabs > li > a {\r
-        min-width: 0;\r
-        font-size: 0.9em;\r
-        padding: 4px 6px;\r
-    }\r
-    \r
-    .tab-content {\r
-        position: absolute;\r
-        top:0;\r
-        bottom:0;\r
-        left:0;\r
-        right:60px;\r
-        overflow-y: scroll;\r
-        &::-webkit-scrollbar {\r
-            .rng-mixin-scrollbar;\r
-        }\r
-        &::-webkit-scrollbar-track {\r
-            .rng-mixin-scrollbar-track;\r
-        }\r
-        &::-webkit-scrollbar-thumb {\r
-            .rng-mixin-scrollbar-thumb;\r
-        }\r
-        &::-webkit-scrollbar-thumb:window-inactive {\r
-            .rng-mixin-scrollbar-thumb-window-inactive;\r
-        }\r
-    }\r
-    \r
-    .diff_table {\r
-        border-width: 1px 0 1px 1px;\r
-        border-style: solid;\r
-        border-color: #ddd;\r
-        empty-cells: show;\r
-        border-spacing: 0px;\r
-    }\r
-\r
-    .diff_table td {\r
-        border-width: 0px 1px 1px 0px;\r
-        border-style: dotted;\r
-        border-color: grey;\r
-        font-size: 10px;\r
-        line-height: 20px;\r
-        font-family: monospace;\r
-        padding: 0px;\r
-        white-space: pre-line;\r
-        /*word-wrap:break-word;\r
-         word-break:break-all; */\r
-    }\r
-\r
-    .diff_table th {\r
-        border-width: 0px 1px 1px 0px;\r
-        border-style: solid;\r
-        border-color: #ddd;\r
-        background: #e5ffe5;\r
-    }\r
-\r
-    .diff_table tr.change {\r
-        background-color: #dcdcdc;\r
-    }\r
-\r
-    .diff_mark {\r
-        display: inline-block;\r
-        padding: 2px;\r
-    }\r
-\r
-    .diff_mark_removed {\r
-        background-color: #ff9c94;\r
-    }\r
-\r
-    .diff_mark_added {\r
-        background-color: #90ee90;\r
-    }\r
-\r
-    .diff_mark_changed {\r
-        background-color: yellow;\r
-    }\r
+.rng-module-diffViewer {
+    .nav-tabs > li > a {
+        min-width: 0;
+        font-size: 0.9em;
+        padding: 4px 6px;
+    }
+    
+    .tab-content {
+        position: absolute;
+        top:0;
+        bottom:0;
+        left:0;
+        right:60px;
+        overflow-y: scroll;
+        &::-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;
+        }
+    }
+    
+    .diff_table {
+        border-width: 1px 0 1px 1px;
+        border-style: solid;
+        border-color: #ddd;
+        empty-cells: show;
+        border-spacing: 0px;
+    }
+
+    .diff_table td {
+        border-width: 0px 1px 1px 0px;
+        border-style: dotted;
+        border-color: grey;
+        font-size: 10px;
+        line-height: 20px;
+        font-family: monospace;
+        padding: 0px;
+        white-space: pre-line;
+        /*word-wrap:break-word;
+         word-break:break-all; */
+    }
+
+    .diff_table th {
+        border-width: 0px 1px 1px 0px;
+        border-style: solid;
+        border-color: #ddd;
+        background: #e5ffe5;
+    }
+
+    .diff_table tr.change {
+        background-color: #dcdcdc;
+    }
+
+    .diff_mark {
+        display: inline-block;
+        padding: 2px;
+    }
+
+    .diff_mark_removed {
+        background-color: #ff9c94;
+    }
+
+    .diff_mark_added {
+        background-color: #90ee90;
+    }
+
+    .diff_mark_changed {
+        background-color: yellow;
+    }
 }
\ No newline at end of file
 }
\ No newline at end of file
index 4a953d1..9c926e9 100644 (file)
-define([\r
-'libs/jquery-1.9.1.min',\r
-'libs/underscore-min',\r
-'modules/documentCanvas/transformations',\r
-'modules/documentCanvas/canvasNode',\r
-'libs/text!./template.html'\r
-], function($, _, transformations, canvasNode, template) {\r
-\r
-'use strict';\r
-\r
-var Canvas = function(html) {\r
-    this.dom = $(template);\r
-    this.content = this.dom.find('#rng-module-documentCanvas-content');\r
-    this.setHTML(html);\r
-};\r
-\r
-Canvas.prototype.setHTML = function(html) {\r
-    if(html) {\r
-        this.content.html(html);\r
-    }\r
-};\r
-\r
-Canvas.prototype.getContent = function() {\r
-    return this.content.contents();\r
-};\r
-\r
-Canvas.prototype.findNodes = function(desc) {\r
-    var selector = '';\r
-    if(typeof desc === 'string') {\r
-        selector = desc;\r
-    }\r
-    else {\r
-        if(desc.klass)\r
-            selector += '[wlxml-class=' + desc.klass + ']';\r
-        if(desc.tag)\r
-            selector += '[wlxml-tag=' + desc.tag + ']';\r
-    }\r
-    var toret = [];\r
-    this.content.find(selector).each(function() {\r
-        toret.push(canvasNode.create($(this)));\r
-    });\r
-    return toret;\r
-};\r
-\r
-Canvas.prototype.getNodeById = function(id) {\r
-    return canvasNode.create($(this.content.find('#' +id)));\r
-};\r
-\r
-Canvas.prototype.nodeAppend = function(options) {\r
-    var element; // = $(this.content.find('#' + options.context.id).get(0));\r
-    if(options.to === 'root') {\r
-        element = this.content;\r
-    } else {\r
-        element = $(this.content.find('#' + options.to.getId()).get(0));\r
-    }\r
-    element.append(options.node.dom);\r
-};\r
-\r
-Canvas.prototype.nodeInsertAfter = function(options) {\r
-    var element = $(this.content.find('#' + options.after.getId()).get(0));\r
-    element.after(options.node.dom);\r
-};\r
-\r
-Canvas.prototype.nodeWrap = function(options) {\r
-    options = _.extend({textNodeIdx: 0}, options);\r
-    if(typeof options.textNodeIdx === 'number')\r
-        options.textNodeIdx = [options.textNodeIdx];\r
-    \r
-    var container = $(this.content.find('#' + options.inside.getId()).get(0)),\r
-        containerContent = container.contents(),\r
-        idx1 = Math.min.apply(Math, options.textNodeIdx),\r
-        idx2 = Math.max.apply(Math, options.textNodeIdx),\r
-        textNode1 = $(containerContent.get(idx1)),\r
-        textNode2 = $(containerContent.get(idx2)),\r
-        sameNode = textNode1.get(0) === textNode2.get(0),\r
-        prefixOutside = textNode1.text().substr(0, options.offsetStart),\r
-        prefixInside = textNode1.text().substr(options.offsetStart),\r
-        suffixInside = textNode2.text().substr(0, options.offsetEnd),\r
-        suffixOutside = textNode2.text().substr(options.offsetEnd)\r
-    ;\r
-    \r
-    textNode1.after(options._with.dom);\r
-    textNode1.detach();\r
-    \r
-    options._with.dom.before(prefixOutside);\r
-    if(sameNode) {\r
-        var core = textNode1.text().substr(options.offsetStart, options.offsetEnd - options.offsetStart);\r
-        options._with.setContent(core);\r
-    } else {\r
-        textNode2.detach();\r
-        options._with.dom.append(prefixInside);\r
-        for(var i = idx1 + 1; i < idx2; i++) {\r
-            options._with.dom.append(containerContent[i]);\r
-        }\r
-        options._with.dom.append(suffixInside);\r
-    }\r
-    options._with.dom.after(suffixOutside);\r
-};\r
-\r
-Canvas.prototype.nodeSplit = function(options) {\r
-    options = _.extend({textNodeIdx: 0}, options);\r
-    \r
-    var nodeToSplit = $(this.content.find('#' + options.node.getId()).get(0));\r
-    \r
-    var nodeContents = nodeToSplit.contents();\r
-    if(nodeContents.length === 0 || \r
-       nodeContents.length - 1 < options.textNodeIdx || \r
-       nodeContents.get(options.textNodeIdx).nodeType != 3)\r
-        return false;\r
-    \r
-    var textNode = $(nodeContents.get(options.textNodeIdx));\r
-\r
-    var succeedingNodes = [];\r
-    var passed = false;\r
-    nodeContents.each(function() {\r
-        var node = this;\r
-        if(passed)\r
-            succeedingNodes.push(node);\r
-        if(node === textNode.get(0))\r
-            passed = true;\r
-    });\r
-    \r
-    var prefix = $.trim(textNode.text().substr(0, options.offset));\r
-    var suffix = $.trim(textNode.text().substr(options.offset));\r
-    \r
-    textNode.before(prefix);\r
-    textNode.remove();\r
-    \r
-    var newNode = canvasNode.create({tag: nodeToSplit.attr('wlxml-tag'), klass: nodeToSplit.attr('wlxml-class')});\r
-    newNode.dom.append(suffix);\r
-    succeedingNodes.forEach(function(node) {\r
-        newNode.dom.append(node);\r
-    });\r
-    nodeToSplit.after(newNode.dom);\r
-    return newNode;\r
-};\r
-\r
-Canvas.prototype.nodeRemove = function(options) {\r
-    var toRemove = $(this.content.find('#' + options.node.getId()).get(0));\r
-    toRemove.remove();\r
-};\r
-\r
-Canvas.prototype.listCreate = function(options) {\r
-    var element1 = $(this.content.find('#' + options.start.getId()).get(0));\r
-    var element2 = $(this.content.find('#' + options.end.getId()).get(0));\r
-    if(element1.parent().get(0) !== element2.parent().get(0))\r
-        return false;\r
-        \r
-    var parent = element1.parent();\r
-    \r
-    if(parent.contents().index(element1) > parent.contents().index(element2)) {\r
-        var tmp = element1;\r
-        element1 = element2;\r
-        element2 = tmp;\r
-    }\r
-    \r
-    var nodesToWrap = [];\r
-    \r
-    var place = 'before';\r
-    var canvas = this;\r
-    parent.contents().each(function() {\r
-        var node = this;\r
-        if(node === element1.get(0))\r
-            place = 'inside';\r
-        if(place === 'inside') {\r
-            var $node;\r
-            if(node.nodeType === 3) {\r
-                $node = canvasNode.create({tag: 'div', content: $.trim(node.data)}).dom; //canvas._createNode('div').text(node.data);\r
-                $(node).remove();\r
-            }\r
-            else {\r
-                $node = $(node);\r
-            }\r
-            $node.attr('wlxml-class', 'item');\r
-            nodesToWrap.push($node);\r
-        }\r
-        if(node === element2.get(0))\r
-            return false;\r
-    });\r
-    \r
-    var list = canvasNode.create({tag: 'div', klass: 'list-items' + (options.type === 'enum' ? '-enum' : '')}).dom; //this._createNode('div', 'list-items');\r
-    \r
-    var parentNode = options.start.parent();\r
-    \r
-    var toret;\r
-    if(parentNode && parentNode.isOfClass('list-items')) {\r
-        list.wrap('<div wlxml-tag="div" wlxml-class="item" class="canvas-silent-item">');\r
-        toret = list.parent();\r
-    } else {\r
-        toret = list;\r
-    }\r
-        \r
-    \r
-    element1.before(toret);\r
-    \r
-    nodesToWrap.forEach(function(node) {\r
-        node.remove();\r
-        list.append(node);\r
-    });\r
-};\r
-\r
-Canvas.prototype.listRemove = function(options) {\r
-    var pointerElement = $(this.content.find('#' + options.pointer.getId()));\r
-    var listElement = options.pointer.getClass() === 'list-items' ? pointerElement : \r
-        pointerElement.parents('[wlxml-class|="list-items"][wlxml-tag]');\r
-    \r
-    var nested = false;\r
-    if(listElement.length > 1) {\r
-        listElement = $(listElement[0]);\r
-        nested = true;\r
-    }\r
-    \r
-    if(nested) {\r
-        listElement.unwrap();\r
-    } else {\r
-        listElement.find('[wlxml-class=item]').each(function() {\r
-            $(this).removeAttr('wlxml-class');\r
-        });\r
-    }\r
-    listElement.children().unwrap();\r
-};\r
-\r
-Canvas.prototype.getPrecedingNode = function(options) {\r
-    var element = $(this.content.find('#' + options.node.getId()).get(0));\r
-    var prev = element.prev();\r
-    if(prev.length === 0)\r
-        prev = element.parent();\r
-    return canvasNode.create(prev);\r
-};\r
-\r
-Canvas.prototype.nodeInsideList = function(options) {\r
-    if(options.node) {\r
-        if(options.node.isOfClass('list-items') || options.node.isOfClass('item'))\r
-            return true;\r
-        var pointerElement = $(this.content.find('#' + options.node.getId()));\r
-        return pointerElement.parents('[wlxml-class=list-items], [wlxml-class=item]').length > 0;\r
-    }\r
-    return false;\r
-};\r
-\r
-\r
-return {\r
-    create: function(desc) { return new Canvas(desc); }\r
-};\r
-\r
+define([
+'libs/jquery-1.9.1.min',
+'libs/underscore-min',
+'modules/documentCanvas/transformations',
+'modules/documentCanvas/canvasNode',
+'libs/text!./template.html'
+], function($, _, transformations, canvasNode, template) {
+
+'use strict';
+
+var Canvas = function(html) {
+    this.dom = $(template);
+    this.content = this.dom.find('#rng-module-documentCanvas-content');
+    this.setHTML(html);
+};
+
+Canvas.prototype.setHTML = function(html) {
+    if(html) {
+        this.content.html(html);
+    }
+};
+
+Canvas.prototype.getContent = function() {
+    return this.content.contents();
+};
+
+Canvas.prototype.findNodes = function(desc) {
+    var selector = '';
+    if(typeof desc === 'string') {
+        selector = desc;
+    }
+    else {
+        if(desc.klass)
+            selector += '[wlxml-class=' + desc.klass + ']';
+        if(desc.tag)
+            selector += '[wlxml-tag=' + desc.tag + ']';
+    }
+    var toret = [];
+    this.content.find(selector).each(function() {
+        toret.push(canvasNode.create($(this)));
+    });
+    return toret;
+};
+
+Canvas.prototype.getNodeById = function(id) {
+    return canvasNode.create($(this.content.find('#' +id)));
+};
+
+Canvas.prototype.nodeAppend = function(options) {
+    var element; // = $(this.content.find('#' + options.context.id).get(0));
+    if(options.to === 'root') {
+        element = this.content;
+    } else {
+        element = $(this.content.find('#' + options.to.getId()).get(0));
+    }
+    element.append(options.node.dom);
+};
+
+Canvas.prototype.nodeInsertAfter = function(options) {
+    var element = $(this.content.find('#' + options.after.getId()).get(0));
+    element.after(options.node.dom);
+};
+
+Canvas.prototype.nodeWrap = function(options) {
+    options = _.extend({textNodeIdx: 0}, options);
+    if(typeof options.textNodeIdx === 'number')
+        options.textNodeIdx = [options.textNodeIdx];
+    
+    var container = $(this.content.find('#' + options.inside.getId()).get(0)),
+        containerContent = container.contents(),
+        idx1 = Math.min.apply(Math, options.textNodeIdx),
+        idx2 = Math.max.apply(Math, options.textNodeIdx),
+        textNode1 = $(containerContent.get(idx1)),
+        textNode2 = $(containerContent.get(idx2)),
+        sameNode = textNode1.get(0) === textNode2.get(0),
+        prefixOutside = textNode1.text().substr(0, options.offsetStart),
+        prefixInside = textNode1.text().substr(options.offsetStart),
+        suffixInside = textNode2.text().substr(0, options.offsetEnd),
+        suffixOutside = textNode2.text().substr(options.offsetEnd)
+    ;
+    
+    textNode1.after(options._with.dom);
+    textNode1.detach();
+    
+    options._with.dom.before(prefixOutside);
+    if(sameNode) {
+        var core = textNode1.text().substr(options.offsetStart, options.offsetEnd - options.offsetStart);
+        options._with.setContent(core);
+    } else {
+        textNode2.detach();
+        options._with.dom.append(prefixInside);
+        for(var i = idx1 + 1; i < idx2; i++) {
+            options._with.dom.append(containerContent[i]);
+        }
+        options._with.dom.append(suffixInside);
+    }
+    options._with.dom.after(suffixOutside);
+};
+
+Canvas.prototype.nodeSplit = function(options) {
+    options = _.extend({textNodeIdx: 0}, options);
+    
+    var nodeToSplit = $(this.content.find('#' + options.node.getId()).get(0));
+    
+    var nodeContents = nodeToSplit.contents();
+    if(nodeContents.length === 0 || 
+       nodeContents.length - 1 < options.textNodeIdx || 
+       nodeContents.get(options.textNodeIdx).nodeType != 3)
+        return false;
+    
+    var textNode = $(nodeContents.get(options.textNodeIdx));
+
+    var succeedingNodes = [];
+    var passed = false;
+    nodeContents.each(function() {
+        var node = this;
+        if(passed)
+            succeedingNodes.push(node);
+        if(node === textNode.get(0))
+            passed = true;
+    });
+    
+    var prefix = $.trim(textNode.text().substr(0, options.offset));
+    var suffix = $.trim(textNode.text().substr(options.offset));
+    
+    textNode.before(prefix);
+    textNode.remove();
+    
+    var newNode = canvasNode.create({tag: nodeToSplit.attr('wlxml-tag'), klass: nodeToSplit.attr('wlxml-class')});
+    newNode.dom.append(suffix);
+    succeedingNodes.forEach(function(node) {
+        newNode.dom.append(node);
+    });
+    nodeToSplit.after(newNode.dom);
+    return newNode;
+};
+
+Canvas.prototype.nodeRemove = function(options) {
+    var toRemove = $(this.content.find('#' + options.node.getId()).get(0));
+    toRemove.remove();
+};
+
+Canvas.prototype.listCreate = function(options) {
+    var element1 = $(this.content.find('#' + options.start.getId()).get(0));
+    var element2 = $(this.content.find('#' + options.end.getId()).get(0));
+    if(element1.parent().get(0) !== element2.parent().get(0))
+        return false;
+        
+    var parent = element1.parent();
+    
+    if(parent.contents().index(element1) > parent.contents().index(element2)) {
+        var tmp = element1;
+        element1 = element2;
+        element2 = tmp;
+    }
+    
+    var nodesToWrap = [];
+    
+    var place = 'before';
+    var canvas = this;
+    parent.contents().each(function() {
+        var node = this;
+        if(node === element1.get(0))
+            place = 'inside';
+        if(place === 'inside') {
+            var $node;
+            if(node.nodeType === 3) {
+                $node = canvasNode.create({tag: 'div', content: $.trim(node.data)}).dom; //canvas._createNode('div').text(node.data);
+                $(node).remove();
+            }
+            else {
+                $node = $(node);
+            }
+            $node.attr('wlxml-class', 'item');
+            nodesToWrap.push($node);
+        }
+        if(node === element2.get(0))
+            return false;
+    });
+    
+    var list = canvasNode.create({tag: 'div', klass: 'list-items' + (options.type === 'enum' ? '-enum' : '')}).dom; //this._createNode('div', 'list-items');
+    
+    var parentNode = options.start.parent();
+    
+    var toret;
+    if(parentNode && parentNode.isOfClass('list-items')) {
+        list.wrap('<div wlxml-tag="div" wlxml-class="item" class="canvas-silent-item">');
+        toret = list.parent();
+    } else {
+        toret = list;
+    }
+        
+    
+    element1.before(toret);
+    
+    nodesToWrap.forEach(function(node) {
+        node.remove();
+        list.append(node);
+    });
+};
+
+Canvas.prototype.listRemove = function(options) {
+    var pointerElement = $(this.content.find('#' + options.pointer.getId()));
+    var listElement = options.pointer.getClass() === 'list-items' ? pointerElement : 
+        pointerElement.parents('[wlxml-class|="list-items"][wlxml-tag]');
+    
+    var nested = false;
+    if(listElement.length > 1) {
+        listElement = $(listElement[0]);
+        nested = true;
+    }
+    
+    if(nested) {
+        listElement.unwrap();
+    } else {
+        listElement.find('[wlxml-class=item]').each(function() {
+            $(this).removeAttr('wlxml-class');
+        });
+    }
+    listElement.children().unwrap();
+};
+
+Canvas.prototype.getPrecedingNode = function(options) {
+    var element = $(this.content.find('#' + options.node.getId()).get(0));
+    var prev = element.prev();
+    if(prev.length === 0)
+        prev = element.parent();
+    return canvasNode.create(prev);
+};
+
+Canvas.prototype.nodeInsideList = function(options) {
+    if(options.node) {
+        if(options.node.isOfClass('list-items') || options.node.isOfClass('item'))
+            return true;
+        var pointerElement = $(this.content.find('#' + options.node.getId()));
+        return pointerElement.parents('[wlxml-class=list-items], [wlxml-class=item]').length > 0;
+    }
+    return false;
+};
+
+
+return {
+    create: function(desc) { return new Canvas(desc); }
+};
+
 });
\ No newline at end of file
 });
\ No newline at end of file
index 87fa834..3b7f72d 100644 (file)
-define([\r
-'libs/jquery-1.9.1.min',\r
-'./canvasNode'\r
-], function($, canvasNode) {\r
-\r
-'use strict';\r
-\r
-var getCursorPosition = function() {\r
-    var selection = window.getSelection();\r
-    var anchorNode = $(selection.anchorNode);\r
-    var parent = anchorNode.parent();\r
-    return {\r
-        textNode: anchorNode,\r
-        textNodeOffset: selection.anchorOffset,\r
-        textNodeIndex: parent.contents().index(anchorNode),\r
-        parentNode: parent,\r
-        focusNode: $(selection.focusNode).parent(),\r
-        isAtEnd: selection.anchorOffset === anchorNode.text().length\r
-    };\r
-};\r
-\r
-var Manager = function(canvas, sandbox) {\r
-    this.canvas = canvas;\r
-    this.sandbox = sandbox;\r
-    this.shownAlready = false;\r
-    this.gridToggled = false;\r
-    this.scrollbarPosition = 0;\r
-    this.currentNode = null;\r
-    var manager = this;\r
-        \r
-    canvas.dom.find('#rng-module-documentCanvas-content').on('keyup', function() {\r
-        manager.sandbox.publish('contentChanged');\r
-    });\r
-\r
-    canvas.dom.on('mouseover', '[wlxml-tag]', function(e) {\r
-        e.stopPropagation();\r
-        manager.sandbox.publish('nodeHovered', canvasNode.create($(e.target)));\r
-    });\r
-    canvas.dom.on('mouseout', '[wlxml-tag]', function(e) {\r
-        e.stopPropagation();\r
-        manager.sandbox.publish('nodeBlured', canvasNode.create($(e.target)));\r
-    });\r
-    canvas.dom.on('click', '[wlxml-tag]', function(e) {\r
-        e.stopPropagation();\r
-        console.log('clicked node type: '+e.target.nodeType);\r
-        manager.selectNode(canvasNode.create($(e.target)));\r
-    });\r
-\r
-    canvas.dom.on('keyup', '#rng-module-documentCanvas-contentWrapper', function(e) {\r
-        var anchor = $(window.getSelection().anchorNode);\r
-        \r
-        if(anchor[0].nodeType === Node.TEXT_NODE)\r
-            anchor = anchor.parent();\r
-        if(!anchor.is('[wlxml-tag]'))\r
-            return;\r
-        manager.selectNode(canvasNode.create(anchor));\r
-    });\r
-    \r
-    canvas.dom.on('keydown', '#rng-module-documentCanvas-contentWrapper', function(e) {\r
-        if(e.which === 13) { \r
-            manager.onEnterKey(e);\r
-        }\r
-        if(e.which === 8) {\r
-            manager.onBackspaceKey(e);\r
-        }\r
-    });\r
-              \r
-    canvas.dom.onShow = function() {\r
-        if(!manager.shownAlready) {\r
-            manager.shownAlready = true;\r
-            manager.selectFirstNode();\r
-        } else if(manager.currentNode) {\r
-            manager.movecaretToNode(manager.getNodeElement(manager.currentNode));\r
-            canvas.dom.find('#rng-module-documentCanvas-contentWrapper').scrollTop(manager.scrollbarPosition);\r
-        }\r
-    };\r
-    canvas.dom.onHide = function() {\r
-       manager.scrollbarPosition = canvas.dom.find('#rng-module-documentCanvas-contentWrapper').scrollTop();\r
-    };\r
-};\r
-    \r
-Manager.prototype.selectNode = function(cnode, options) {\r
-    options = options || {};\r
-    var nodeElement = this.getNodeElement(cnode);\r
-    \r
-    this.dimNode(cnode);\r
-    \r
-    this.canvas.dom.find('.rng-module-documentCanvas-currentNode').removeClass('rng-module-documentCanvas-currentNode');\r
-    nodeElement.addClass('rng-module-documentCanvas-currentNode');\r
-    \r
-    if(options.movecaret) {\r
-        this.movecaretToNode(nodeElement, options.movecaret);\r
-    }\r
-    \r
-    this.currentNode = cnode;\r
-    this.sandbox.publish('nodeSelected', cnode);\r
-};\r
-\r
-Manager.prototype.insertNewNode = function(wlxmlTag, wlxmlClass) {\r
-    var selection = window.getSelection(),\r
-        $anchorNode = $(selection.anchorNode),\r
-        $focusNode = $(selection.focusNode);\r
-        \r
-        \r
-    if(!selection.isCollapsed && $anchorNode.parent()[0] === $focusNode.parent()[0]) {\r
-        var textNodeIdx,\r
-            parent = $anchorNode.parent(),\r
-            parentContents = parent.contents(),\r
-            offsetStart = selection.anchorOffset,\r
-            offsetEnd = selection.focusOffset;\r
-        \r
-        if(selection.anchorNode === selection.focusNode) {\r
-            if(offsetStart > offsetEnd) {\r
-                var tmp = offsetStart;\r
-                offsetStart = offsetEnd;\r
-                offsetEnd = tmp;\r
-            }\r
-            textNodeIdx = parentContents.index($anchorNode);\r
-        } else {\r
-            if(parentContents.index($anchorNode) > parentContents.index($focusNode)) {\r
-                offsetStart = selection.focusOffset;\r
-                offsetEnd = selection.anchorOffset;\r
-            }\r
-            textNodeIdx = [parentContents.index($anchorNode), parentContents.index($focusNode)];\r
-        }\r
-        \r
-        var wrapper = canvasNode.create({tag: wlxmlTag, klass: wlxmlClass});\r
-        this.canvas.nodeWrap({inside: canvasNode.create(parent),\r
-                              _with: wrapper,\r
-                              offsetStart: offsetStart,\r
-                              offsetEnd: offsetEnd,\r
-                              textNodeIdx: textNodeIdx\r
-                            });\r
-        this.selectNode(wrapper, {movecaret: 'end'});\r
-    }\r
-    \r
-    \r
-};\r
-\r
-Manager.prototype.getNodeElement = function(cnode) {\r
-    return this.canvas.dom.find('#'+cnode.getId());\r
-};\r
-\r
-Manager.prototype.highlightNode = function(cnode) {\r
-    var nodeElement = this.getNodeElement(cnode);\r
-    if(!this.gridToggled) {\r
-        nodeElement.addClass('rng-common-hoveredNode');\r
-        var label = nodeElement.attr('wlxml-tag');\r
-        if(nodeElement.attr('wlxml-class'))\r
-            label += ' / ' + nodeElement.attr('wlxml-class');\r
-        var tag = $('<div>').addClass('rng-module-documentCanvas-hoveredNodeTag').text(label);\r
-        nodeElement.append(tag);\r
-    }\r
-};\r
-\r
-Manager.prototype.dimNode = function(cnode) {\r
-    var nodeElement = this.getNodeElement(cnode);\r
-    if(!this.gridToggled) {\r
-        nodeElement.removeClass('rng-common-hoveredNode');\r
-        nodeElement.find('.rng-module-documentCanvas-hoveredNodeTag').remove();\r
-    }\r
-};\r
-\r
-Manager.prototype.selectFirstNode = function() {\r
-    var firstNodeWithText = this.canvas.dom.find('[wlxml-tag]').filter(function() {\r
-        return $(this).clone().children().remove().end().text().trim() !== '';\r
-    }).first();\r
-    var node;\r
-    if(firstNodeWithText.length)\r
-        node = $(firstNodeWithText[0]);\r
-    else {\r
-        node = this.canvas.dom.find('[wlxml-class|="p"]');\r
-    }\r
-    this.selectNode(canvasNode.create(node), {movecaret: true});\r
-};\r
-\r
-Manager.prototype.movecaretToNode = function(nodeElement, where) {\r
-    if(!nodeElement.length)\r
-        return;\r
-    var range = document.createRange();\r
-    range.selectNodeContents(nodeElement[0]);\r
-    \r
-    var collapseArg = true;\r
-    if(where === 'end')\r
-        collapseArg = false;\r
-    range.collapse(collapseArg);\r
-    var selection = document.getSelection();\r
-    selection.removeAllRanges();\r
-    selection.addRange(range);\r
-};\r
-\r
-Manager.prototype.toggleGrid =  function(toggle) {\r
-    this.canvas.dom.find('[wlxml-tag]').toggleClass('rng-common-hoveredNode', toggle);\r
-    this.gridToggled = toggle;\r
-};\r
-\r
-Manager.prototype.onEnterKey = function(e) {\r
-    e.preventDefault();\r
-    var pos = getCursorPosition();\r
-    var contextNode = this.canvas.getNodeById(pos.parentNode.attr('id'));\r
-    var newNode;\r
-\r
-    if(pos.isAtEnd) {\r
-        newNode = canvasNode.create({tag: pos.parentNode.attr('wlxml-tag'), klass: pos.parentNode.attr('wlxml-class')});\r
-        this.canvas.nodeInsertAfter({node: newNode, after: this.canvas.getNodeById(pos.parentNode.attr('id'))});\r
-    } else {\r
-        newNode = this.canvas.nodeSplit({node: contextNode, textNodeIdx: pos.textNodeIndex, offset: pos.textNodeOffset});\r
-    }\r
-    if(newNode)\r
-        this.selectNode(newNode, {movecaret: true});\r
-    this.sandbox.publish('contentChanged');\r
-};\r
-\r
-Manager.prototype.onBackspaceKey = function(e) {\r
-    var pos = getCursorPosition();\r
-    var len = pos.textNode.text().length;\r
-    if(len === 1) {\r
-        // Prevent deleting node by browser after last character removed;\r
-        e.preventDefault();\r
-        pos.parentNode.text('');\r
-    }\r
-    if(len === 0) {\r
-        e.preventDefault();\r
-        var toRemove = canvasNode.create(pos.textNode);\r
-        var prevNode = this.canvas.getPrecedingNode({node:toRemove});\r
-        this.canvas.nodeRemove({node: toRemove}); // jesli nie ma tekstu, to anchor nie jest tex nodem\r
-        this.selectNode(prevNode, {movecaret: 'end'});\r
-    }\r
-};\r
-\r
-Manager.prototype.command = function(command, meta) {\r
-    var pos = getCursorPosition();\r
-    \r
-    if(command === 'createList') {\r
-        var node = canvasNode.create(pos.parentNode);\r
-        if(window.getSelection().getRangeAt(0).collapsed && this.canvas.nodeInsideList({node: node})) {\r
-            this.canvas.listRemove({pointer: node});\r
-            this.selectNode(node, {movecaret: 'end'});\r
-            this.sandbox.publish('contentChanged');\r
-        }\r
-        else {\r
-            //if(!this.canvas.nodeInsideList({node: node})) {\r
-                this.canvas.listCreate({start: node, end: canvasNode.create(pos.focusNode), type: meta});\r
-                this.selectNode(node, {movecaret: 'end'});\r
-                this.sandbox.publish('contentChanged');\r
-            //}\r
-        }\r
-    }\r
-\r
-};\r
-\r
-\r
-return Manager;\r
-    \r
+define([
+'libs/jquery-1.9.1.min',
+'./canvasNode'
+], function($, canvasNode) {
+
+'use strict';
+
+var getCursorPosition = function() {
+    var selection = window.getSelection();
+    var anchorNode = $(selection.anchorNode);
+    var parent = anchorNode.parent();
+    return {
+        textNode: anchorNode,
+        textNodeOffset: selection.anchorOffset,
+        textNodeIndex: parent.contents().index(anchorNode),
+        parentNode: parent,
+        focusNode: $(selection.focusNode).parent(),
+        isAtEnd: selection.anchorOffset === anchorNode.text().length
+    };
+};
+
+var Manager = function(canvas, sandbox) {
+    this.canvas = canvas;
+    this.sandbox = sandbox;
+    this.shownAlready = false;
+    this.gridToggled = false;
+    this.scrollbarPosition = 0;
+    this.currentNode = null;
+    var manager = this;
+        
+    canvas.dom.find('#rng-module-documentCanvas-content').on('keyup', function() {
+        manager.sandbox.publish('contentChanged');
+    });
+
+    canvas.dom.on('mouseover', '[wlxml-tag]', function(e) {
+        e.stopPropagation();
+        manager.sandbox.publish('nodeHovered', canvasNode.create($(e.target)));
+    });
+    canvas.dom.on('mouseout', '[wlxml-tag]', function(e) {
+        e.stopPropagation();
+        manager.sandbox.publish('nodeBlured', canvasNode.create($(e.target)));
+    });
+    canvas.dom.on('click', '[wlxml-tag]', function(e) {
+        e.stopPropagation();
+        console.log('clicked node type: '+e.target.nodeType);
+        manager.selectNode(canvasNode.create($(e.target)));
+    });
+
+    canvas.dom.on('keyup', '#rng-module-documentCanvas-contentWrapper', function(e) {
+        var anchor = $(window.getSelection().anchorNode);
+        
+        if(anchor[0].nodeType === Node.TEXT_NODE)
+            anchor = anchor.parent();
+        if(!anchor.is('[wlxml-tag]'))
+            return;
+        manager.selectNode(canvasNode.create(anchor));
+    });
+    
+    canvas.dom.on('keydown', '#rng-module-documentCanvas-contentWrapper', function(e) {
+        if(e.which === 13) { 
+            manager.onEnterKey(e);
+        }
+        if(e.which === 8) {
+            manager.onBackspaceKey(e);
+        }
+    });
+              
+    canvas.dom.onShow = function() {
+        if(!manager.shownAlready) {
+            manager.shownAlready = true;
+            manager.selectFirstNode();
+        } else if(manager.currentNode) {
+            manager.movecaretToNode(manager.getNodeElement(manager.currentNode));
+            canvas.dom.find('#rng-module-documentCanvas-contentWrapper').scrollTop(manager.scrollbarPosition);
+        }
+    };
+    canvas.dom.onHide = function() {
+       manager.scrollbarPosition = canvas.dom.find('#rng-module-documentCanvas-contentWrapper').scrollTop();
+    };
+};
+    
+Manager.prototype.selectNode = function(cnode, options) {
+    options = options || {};
+    var nodeElement = this.getNodeElement(cnode);
+    
+    this.dimNode(cnode);
+    
+    this.canvas.dom.find('.rng-module-documentCanvas-currentNode').removeClass('rng-module-documentCanvas-currentNode');
+    nodeElement.addClass('rng-module-documentCanvas-currentNode');
+    
+    if(options.movecaret) {
+        this.movecaretToNode(nodeElement, options.movecaret);
+    }
+    
+    this.currentNode = cnode;
+    this.sandbox.publish('nodeSelected', cnode);
+};
+
+Manager.prototype.insertNewNode = function(wlxmlTag, wlxmlClass) {
+    var selection = window.getSelection(),
+        $anchorNode = $(selection.anchorNode),
+        $focusNode = $(selection.focusNode);
+        
+        
+    if(!selection.isCollapsed && $anchorNode.parent()[0] === $focusNode.parent()[0]) {
+        var textNodeIdx,
+            parent = $anchorNode.parent(),
+            parentContents = parent.contents(),
+            offsetStart = selection.anchorOffset,
+            offsetEnd = selection.focusOffset;
+        
+        if(selection.anchorNode === selection.focusNode) {
+            if(offsetStart > offsetEnd) {
+                var tmp = offsetStart;
+                offsetStart = offsetEnd;
+                offsetEnd = tmp;
+            }
+            textNodeIdx = parentContents.index($anchorNode);
+        } else {
+            if(parentContents.index($anchorNode) > parentContents.index($focusNode)) {
+                offsetStart = selection.focusOffset;
+                offsetEnd = selection.anchorOffset;
+            }
+            textNodeIdx = [parentContents.index($anchorNode), parentContents.index($focusNode)];
+        }
+        
+        var wrapper = canvasNode.create({tag: wlxmlTag, klass: wlxmlClass});
+        this.canvas.nodeWrap({inside: canvasNode.create(parent),
+                              _with: wrapper,
+                              offsetStart: offsetStart,
+                              offsetEnd: offsetEnd,
+                              textNodeIdx: textNodeIdx
+                            });
+        this.selectNode(wrapper, {movecaret: 'end'});
+    }
+    
+    
+};
+
+Manager.prototype.getNodeElement = function(cnode) {
+    return this.canvas.dom.find('#'+cnode.getId());
+};
+
+Manager.prototype.highlightNode = function(cnode) {
+    var nodeElement = this.getNodeElement(cnode);
+    if(!this.gridToggled) {
+        nodeElement.addClass('rng-common-hoveredNode');
+        var label = nodeElement.attr('wlxml-tag');
+        if(nodeElement.attr('wlxml-class'))
+            label += ' / ' + nodeElement.attr('wlxml-class');
+        var tag = $('<div>').addClass('rng-module-documentCanvas-hoveredNodeTag').text(label);
+        nodeElement.append(tag);
+    }
+};
+
+Manager.prototype.dimNode = function(cnode) {
+    var nodeElement = this.getNodeElement(cnode);
+    if(!this.gridToggled) {
+        nodeElement.removeClass('rng-common-hoveredNode');
+        nodeElement.find('.rng-module-documentCanvas-hoveredNodeTag').remove();
+    }
+};
+
+Manager.prototype.selectFirstNode = function() {
+    var firstNodeWithText = this.canvas.dom.find('[wlxml-tag]').filter(function() {
+        return $(this).clone().children().remove().end().text().trim() !== '';
+    }).first();
+    var node;
+    if(firstNodeWithText.length)
+        node = $(firstNodeWithText[0]);
+    else {
+        node = this.canvas.dom.find('[wlxml-class|="p"]');
+    }
+    this.selectNode(canvasNode.create(node), {movecaret: true});
+};
+
+Manager.prototype.movecaretToNode = function(nodeElement, where) {
+    if(!nodeElement.length)
+        return;
+    var range = document.createRange();
+    range.selectNodeContents(nodeElement[0]);
+    
+    var collapseArg = true;
+    if(where === 'end')
+        collapseArg = false;
+    range.collapse(collapseArg);
+    var selection = document.getSelection();
+    selection.removeAllRanges();
+    selection.addRange(range);
+};
+
+Manager.prototype.toggleGrid =  function(toggle) {
+    this.canvas.dom.find('[wlxml-tag]').toggleClass('rng-common-hoveredNode', toggle);
+    this.gridToggled = toggle;
+};
+
+Manager.prototype.onEnterKey = function(e) {
+    e.preventDefault();
+    var pos = getCursorPosition();
+    var contextNode = this.canvas.getNodeById(pos.parentNode.attr('id'));
+    var newNode;
+
+    if(pos.isAtEnd) {
+        newNode = canvasNode.create({tag: pos.parentNode.attr('wlxml-tag'), klass: pos.parentNode.attr('wlxml-class')});
+        this.canvas.nodeInsertAfter({node: newNode, after: this.canvas.getNodeById(pos.parentNode.attr('id'))});
+    } else {
+        newNode = this.canvas.nodeSplit({node: contextNode, textNodeIdx: pos.textNodeIndex, offset: pos.textNodeOffset});
+    }
+    if(newNode)
+        this.selectNode(newNode, {movecaret: true});
+    this.sandbox.publish('contentChanged');
+};
+
+Manager.prototype.onBackspaceKey = function(e) {
+    var pos = getCursorPosition();
+    var len = pos.textNode.text().length;
+    if(len === 1) {
+        // Prevent deleting node by browser after last character removed;
+        e.preventDefault();
+        pos.parentNode.text('');
+    }
+    if(len === 0) {
+        e.preventDefault();
+        var toRemove = canvasNode.create(pos.textNode);
+        var prevNode = this.canvas.getPrecedingNode({node:toRemove});
+        this.canvas.nodeRemove({node: toRemove}); // jesli nie ma tekstu, to anchor nie jest tex nodem
+        this.selectNode(prevNode, {movecaret: 'end'});
+    }
+};
+
+Manager.prototype.command = function(command, meta) {
+    var pos = getCursorPosition();
+    
+    if(command === 'createList') {
+        var node = canvasNode.create(pos.parentNode);
+        if(window.getSelection().getRangeAt(0).collapsed && this.canvas.nodeInsideList({node: node})) {
+            this.canvas.listRemove({pointer: node});
+            this.selectNode(node, {movecaret: 'end'});
+            this.sandbox.publish('contentChanged');
+        }
+        else {
+            //if(!this.canvas.nodeInsideList({node: node})) {
+                this.canvas.listCreate({start: node, end: canvasNode.create(pos.focusNode), type: meta});
+                this.selectNode(node, {movecaret: 'end'});
+                this.sandbox.publish('contentChanged');
+            //}
+        }
+    }
+
+};
+
+
+return Manager;
+    
 });
\ No newline at end of file
 });
\ No newline at end of file
index 321a7ce..8cf61b1 100644 (file)
@@ -1,88 +1,88 @@
-define(['libs/jquery-1.9.1.min'], function($) {\r
-\r
-'use strict';\r
-\r
-\r
-var tagSelector = '[wlxml-tag]';\r
-\r
-var CanvasNode = function(desc) {\r
-    if(desc instanceof $) {\r
-        this.dom = desc;\r
-        if(!this.dom.attr('id')) {\r
-            this.dom.attr('id', 'xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {var r = Math.random()*16|0,v=c=='x'?r:r&0x3|0x8;return v.toString(16);}));\r
-        }\r
-    } else {\r
-        var toBlock = ['div', 'document', 'section', 'header'];\r
-        var htmlTag = _.contains(toBlock, desc.tag) ? 'div' : 'span';\r
-        this.dom = $('<' + htmlTag + '>');\r
-        this.dom.attr('wlxml-tag', desc.tag);\r
-        if(desc.klass)\r
-            this.dom.attr('wlxml-class', desc.klass);\r
-        if(desc.content)\r
-            this.dom.text(desc.content);\r
-        this.dom.attr('id', 'xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {var r = Math.random()*16|0,v=c=='x'?r:r&0x3|0x8;return v.toString(16);}));\r
-    }\r
-};\r
-\r
-CanvasNode.prototype.getTag = function() {\r
-    return this.dom.attr('wlxml-tag');\r
-};\r
-\r
-CanvasNode.prototype.getClass = function() {\r
-    return this.dom.attr('wlxml-class');\r
-};\r
-\r
-CanvasNode.prototype.getId = function() {\r
-    return this.dom.attr('id');\r
-};\r
-\r
-CanvasNode.prototype.getContent = function() {\r
-    return this.dom.text();\r
-};\r
-\r
-CanvasNode.prototype.setContent = function(content) {\r
-    this.dom.text(content);\r
-};\r
-\r
-CanvasNode.prototype.isSame = function(other) {\r
-    return (other instanceof CanvasNode) && this.dom.get(0) === other.dom.get(0);\r
-};\r
-\r
-CanvasNode.prototype.children = function() {\r
-    var list = [];\r
-    this.dom.children(tagSelector).each(function() {\r
-        list.push(new CanvasNode($(this)));\r
-    });\r
-    return $(list);\r
-};\r
-\r
-\r
-CanvasNode.prototype.parent = function() {\r
-    var node = this.dom.parent(tagSelector);\r
-    if(node.length)\r
-        return new CanvasNode(node);\r
-    return null;\r
-};\r
-\r
-CanvasNode.prototype.parents = function() {\r
-    var list = [];\r
-    this.dom.parents(tagSelector).each(function() {\r
-        list.push(new CanvasNode($(this)));\r
-    });\r
-    return $(list);\r
-};\r
-\r
-\r
-CanvasNode.prototype.isOfClass = function(klass) {\r
-    return this.getClass() && this.getClass().substr(0, klass.length) === klass;\r
-};\r
-\r
-return {\r
-    create: function(desc) {\r
-        return new CanvasNode(desc);\r
-    }\r
-\r
-};\r
-    \r
-\r
+define(['libs/jquery-1.9.1.min'], function($) {
+
+'use strict';
+
+
+var tagSelector = '[wlxml-tag]';
+
+var CanvasNode = function(desc) {
+    if(desc instanceof $) {
+        this.dom = desc;
+        if(!this.dom.attr('id')) {
+            this.dom.attr('id', 'xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {var r = Math.random()*16|0,v=c=='x'?r:r&0x3|0x8;return v.toString(16);}));
+        }
+    } else {
+        var toBlock = ['div', 'document', 'section', 'header'];
+        var htmlTag = _.contains(toBlock, desc.tag) ? 'div' : 'span';
+        this.dom = $('<' + htmlTag + '>');
+        this.dom.attr('wlxml-tag', desc.tag);
+        if(desc.klass)
+            this.dom.attr('wlxml-class', desc.klass);
+        if(desc.content)
+            this.dom.text(desc.content);
+        this.dom.attr('id', 'xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {var r = Math.random()*16|0,v=c=='x'?r:r&0x3|0x8;return v.toString(16);}));
+    }
+};
+
+CanvasNode.prototype.getTag = function() {
+    return this.dom.attr('wlxml-tag');
+};
+
+CanvasNode.prototype.getClass = function() {
+    return this.dom.attr('wlxml-class');
+};
+
+CanvasNode.prototype.getId = function() {
+    return this.dom.attr('id');
+};
+
+CanvasNode.prototype.getContent = function() {
+    return this.dom.text();
+};
+
+CanvasNode.prototype.setContent = function(content) {
+    this.dom.text(content);
+};
+
+CanvasNode.prototype.isSame = function(other) {
+    return (other instanceof CanvasNode) && this.dom.get(0) === other.dom.get(0);
+};
+
+CanvasNode.prototype.children = function() {
+    var list = [];
+    this.dom.children(tagSelector).each(function() {
+        list.push(new CanvasNode($(this)));
+    });
+    return $(list);
+};
+
+
+CanvasNode.prototype.parent = function() {
+    var node = this.dom.parent(tagSelector);
+    if(node.length)
+        return new CanvasNode(node);
+    return null;
+};
+
+CanvasNode.prototype.parents = function() {
+    var list = [];
+    this.dom.parents(tagSelector).each(function() {
+        list.push(new CanvasNode($(this)));
+    });
+    return $(list);
+};
+
+
+CanvasNode.prototype.isOfClass = function(klass) {
+    return this.getClass() && this.getClass().substr(0, klass.length) === klass;
+};
+
+return {
+    create: function(desc) {
+        return new CanvasNode(desc);
+    }
+
+};
+    
+
 });
\ No newline at end of file
 });
\ No newline at end of file
index 37e8377..deebfca 100644 (file)
@@ -1,59 +1,59 @@
-// Module that implements main WYSIWIG edit area\r
-\r
-define([\r
-'libs/underscore-min',\r
-'./transformations', \r
-'./canvas',\r
-'./canvasManager',\r
-'libs/text!./template.html'], function(_, transformations, Canvas, CanvasManager, template) {\r
-\r
-'use strict';\r
-\r
-return function(sandbox) {\r
-\r
-    var canvas = Canvas.create();\r
-    var manager = new CanvasManager(canvas, sandbox);\r
-\r
-    /* public api */\r
-    return {\r
-        start: function() { sandbox.publish('ready'); },\r
-        getView: function() { \r
-            return canvas.dom;\r
-        },\r
-        setDocument: function(xml) {\r
-            canvas.setHTML(transformations.fromXML.getHTMLTree(xml));\r
-            sandbox.publish('documentSet');\r
-        },\r
-        getDocument: function() {\r
-            return transformations.toXML.getXML(canvas.getContent());\r
-        },\r
-        modifyCurrentNode: function(attr, value) {\r
-            if(manager.currentNode) {\r
-                manager.getNodeElement(manager.currentNode).attr('wlxml-'+attr, value);\r
-                sandbox.publish('contentChanged');\r
-            }\r
-        },\r
-        highlightNode: function(canvasNode) {\r
-            manager.highlightNode(canvasNode);\r
-        },\r
-        dimNode: function(canvasNode) {\r
-            manager.dimNode(canvasNode);\r
-        },\r
-        selectNode: function(canvasNode) {\r
-            if(!canvasNode.isSame(manager.currentNode))\r
-                manager.selectNode(canvasNode, {movecaret: true});\r
-        },\r
-        toggleGrid: function(toggle) {\r
-            manager.toggleGrid(toggle);\r
-        },\r
-        insertNewNode: function(wlxmlTag, wlxmlClass) {\r
-            manager.insertNewNode(wlxmlTag, wlxmlClass);\r
-        },\r
-        command: function(command, meta) {\r
-            manager.command(command, meta);\r
-        }\r
-    };\r
-    \r
-};\r
-\r
+// Module that implements main WYSIWIG edit area
+
+define([
+'libs/underscore-min',
+'./transformations', 
+'./canvas',
+'./canvasManager',
+'libs/text!./template.html'], function(_, transformations, Canvas, CanvasManager, template) {
+
+'use strict';
+
+return function(sandbox) {
+
+    var canvas = Canvas.create();
+    var manager = new CanvasManager(canvas, sandbox);
+
+    /* public api */
+    return {
+        start: function() { sandbox.publish('ready'); },
+        getView: function() { 
+            return canvas.dom;
+        },
+        setDocument: function(xml) {
+            canvas.setHTML(transformations.fromXML.getHTMLTree(xml));
+            sandbox.publish('documentSet');
+        },
+        getDocument: function() {
+            return transformations.toXML.getXML(canvas.getContent());
+        },
+        modifyCurrentNode: function(attr, value) {
+            if(manager.currentNode) {
+                manager.getNodeElement(manager.currentNode).attr('wlxml-'+attr, value);
+                sandbox.publish('contentChanged');
+            }
+        },
+        highlightNode: function(canvasNode) {
+            manager.highlightNode(canvasNode);
+        },
+        dimNode: function(canvasNode) {
+            manager.dimNode(canvasNode);
+        },
+        selectNode: function(canvasNode) {
+            if(!canvasNode.isSame(manager.currentNode))
+                manager.selectNode(canvasNode, {movecaret: true});
+        },
+        toggleGrid: function(toggle) {
+            manager.toggleGrid(toggle);
+        },
+        insertNewNode: function(wlxmlTag, wlxmlClass) {
+            manager.insertNewNode(wlxmlTag, wlxmlClass);
+        },
+        command: function(command, meta) {
+            manager.command(command, meta);
+        }
+    };
+    
+};
+
 });
\ No newline at end of file
 });
\ No newline at end of file
index 94a8b6e..4d04285 100644 (file)
@@ -1,60 +1,60 @@
-@import 'nodes.less';\r
-\r
-#rng-module-documentCanvas {\r
-   height: 100%;\r
-}\r
-\r
-#rng-module-documentCanvas-mainArea {\r
-   height: 100%;\r
-   margin-bottom: 20px;\r
-}\r
-\r
-#rng-module-documentCanvas-contentWrapper {\r
-    border-color: #ddd;\r
-    border-style: solid;\r
-    border-width: 1px;\r
-    float:left;\r
-    width: 100%;\r
-    height: 100%;\r
-    overflow-y: scroll;\r
-    padding: 0 10px;\r
-    \r
-    &::-webkit-scrollbar {\r
-        .rng-mixin-scrollbar;\r
-    }\r
-    &::-webkit-scrollbar-track {\r
-        .rng-mixin-scrollbar-track;\r
-    }\r
-    &::-webkit-scrollbar-thumb {\r
-        .rng-mixin-scrollbar-thumb;\r
-    }\r
-    &::-webkit-scrollbar-thumb:window-inactive {\r
-        .rng-mixin-scrollbar-thumb-window-inactive;\r
-    }\r
-    \r
-    #rng-module-documentCanvas-content {\r
-        outline: 0px solid transparent;\r
-    }\r
-}\r
-\r
-.rng-module-documentCanvas-currentNode {\r
-    background: #fffacd;\r
-    border-color: grey;\r
-    border-style:dashed;\r
-    border-width:1px;\r
-}\r
-\r
-.rng-module-documentCanvas-hoveredNodeTag {\r
-    position:absolute;\r
-    height:20px;\r
-    top:-20px;\r
-    left:0;\r
-    background: #bd362f;\r
-    color: white;\r
-    font-size:9px;\r
-    font-weight: normal;\r
-    font-style: normal;\r
-    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;\r
-    padding: 0 5px;\r
-    text-indent: 0;\r
+@import 'nodes.less';
+
+#rng-module-documentCanvas {
+   height: 100%;
+}
+
+#rng-module-documentCanvas-mainArea {
+   height: 100%;
+   margin-bottom: 20px;
+}
+
+#rng-module-documentCanvas-contentWrapper {
+    border-color: #ddd;
+    border-style: solid;
+    border-width: 1px;
+    float:left;
+    width: 100%;
+    height: 100%;
+    overflow-y: scroll;
+    padding: 0 10px;
+    
+    &::-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;
+    }
+    
+    #rng-module-documentCanvas-content {
+        outline: 0px solid transparent;
+    }
+}
+
+.rng-module-documentCanvas-currentNode {
+    background: #fffacd;
+    border-color: grey;
+    border-style:dashed;
+    border-width:1px;
+}
+
+.rng-module-documentCanvas-hoveredNodeTag {
+    position:absolute;
+    height:20px;
+    top:-20px;
+    left:0;
+    background: #bd362f;
+    color: white;
+    font-size:9px;
+    font-weight: normal;
+    font-style: normal;
+    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
+    padding: 0 5px;
+    text-indent: 0;
 }
\ No newline at end of file
 }
\ No newline at end of file
index 4e6a817..3c52bce 100644 (file)
-[wlxml-tag] {\r
-    float: none !important; /* temporaty workaround for Bootstrap's influence via [class*="span"] { float: left; } */\r
-    border-color: white;\r
-    border-style:solid;\r
-    border-width:1px;\r
-    min-height:20px;\r
-    position:relative;\r
-    text-indent: 0;\r
-}\r
-\r
-span[wlxml-tag] {\r
-    display:inline-block;\r
-    min-width: 10px;\r
-}\r
-\r
-[wlxml-tag=header] {\r
-    font-size: 13px;\r
-    font-weight: bold;\r
-    margin: 10px 0;\r
-}\r
-\r
-[wlxml-tag=section] {\r
-    margin-top: 10px;\r
-    margin-bottom: 10px;\r
-}\r
-\r
-[wlxml-tag=section] [wlxml-tag=section] {\r
-    margin-left:10px;\r
-}\r
-\r
-[wlxml-class|="cite"] {\r
-    font-style: italic;\r
-}\r
-\r
-[wlxml-class|="cite-code"] {\r
-    font-family: monospace;\r
-}\r
-\r
-[wlxml-class|="cite-code-xml"] {\r
-    color: blue;\r
-}\r
-\r
-[wlxml-tag=header] > [wlxml-class=author] {\r
-    font-size: 14px;\r
-}\r
-\r
-[wlxml-tag=header] > [wlxml-class=title] {\r
-    font-size:18px;\r
-}\r
-\r
-[wlxml-class|="uri"] {\r
-    color: blue;\r
-    text-decoration: underline;\r
-}\r
-\r
-[wlxml-class|="p"] {\r
-    text-indent: 1.5em;\r
-}\r
-\r
-[wlxml-class|="emph-tech"] {\r
-    font-style: italic;\r
-}\r
-\r
-[wlxml-tag]  metadata {\r
-    display:none;\r
-}\r
-\r
-[wlxml-class="list-items"] {\r
-\r
-    > [wlxml-class="item"] {\r
-        display: list-item;\r
-        margin-left: 10px;\r
-        padding-left: 5px;\r
-    }\r
-}\r
-\r
-[wlxml-class="item"] {\r
-    > [wlxml-class="list-items"] {\r
-        display: block;\r
-    }\r
-}\r
-\r
-\r
-[wlxml-class="list-items-enum"] {\r
-\r
-    counter-reset: myitem;\r
-\r
-    > [wlxml-class="item"] {\r
-        counter-increment: myitem;\r
-        margin-left: 10px;\r
-        padding-left: 5px;\r
-        \r
-        &:before {\r
-            content: counter(myitem) '. ';\r
-            margin-right:10px;\r
-            padding-right:10px;\r
-        }\r
-    }\r
-}\r
-\r
-.canvas-silent-item {\r
-    display: block !important;\r
-    counter-increment: none !important;\r
-    &:before {\r
-        content: normal !important;\r
-    }\r
-}\r
-\r
-[wlxml-class="table"] {\r
-\r
-    display: table;\r
-    border: 1px solid black;\r
-\r
-    [wlxml-class="row"] {\r
-        display: table-row;\r
-        border: 1px solid black;\r
-    }\r
-    [wlxml-class="cell"] {\r
-        display: table-cell;\r
-        border: 1px solid black;\r
-        padding: 5px;\r
-    }\r
-\r
+[wlxml-tag] {
+    float: none !important; /* temporaty workaround for Bootstrap's influence via [class*="span"] { float: left; } */
+    border-color: white;
+    border-style:solid;
+    border-width:1px;
+    min-height:20px;
+    position:relative;
+    text-indent: 0;
+}
+
+span[wlxml-tag] {
+    display:inline-block;
+    min-width: 10px;
+}
+
+[wlxml-tag=header] {
+    font-size: 13px;
+    font-weight: bold;
+    margin: 10px 0;
+}
+
+[wlxml-tag=section] {
+    margin-top: 10px;
+    margin-bottom: 10px;
+}
+
+[wlxml-tag=section] [wlxml-tag=section] {
+    margin-left:10px;
+}
+
+[wlxml-class|="cite"] {
+    font-style: italic;
+}
+
+[wlxml-class|="cite-code"] {
+    font-family: monospace;
+}
+
+[wlxml-class|="cite-code-xml"] {
+    color: blue;
+}
+
+[wlxml-tag=header] > [wlxml-class=author] {
+    font-size: 14px;
+}
+
+[wlxml-tag=header] > [wlxml-class=title] {
+    font-size:18px;
+}
+
+[wlxml-class|="uri"] {
+    color: blue;
+    text-decoration: underline;
+}
+
+[wlxml-class|="p"] {
+    text-indent: 1.5em;
+}
+
+[wlxml-class|="emph-tech"] {
+    font-style: italic;
+}
+
+[wlxml-tag]  metadata {
+    display:none;
+}
+
+[wlxml-class="list-items"] {
+
+    > [wlxml-class="item"] {
+        display: list-item;
+        margin-left: 10px;
+        padding-left: 5px;
+    }
+}
+
+[wlxml-class="item"] {
+    > [wlxml-class="list-items"] {
+        display: block;
+    }
+}
+
+
+[wlxml-class="list-items-enum"] {
+
+    counter-reset: myitem;
+
+    > [wlxml-class="item"] {
+        counter-increment: myitem;
+        margin-left: 10px;
+        padding-left: 5px;
+        
+        &:before {
+            content: counter(myitem) '. ';
+            margin-right:10px;
+            padding-right:10px;
+        }
+    }
+}
+
+.canvas-silent-item {
+    display: block !important;
+    counter-increment: none !important;
+    &:before {
+        content: normal !important;
+    }
+}
+
+[wlxml-class="table"] {
+
+    display: table;
+    border: 1px solid black;
+
+    [wlxml-class="row"] {
+        display: table-row;
+        border: 1px solid black;
+    }
+    [wlxml-class="cell"] {
+        display: table-cell;
+        border: 1px solid black;
+        padding: 5px;
+    }
+
 }
\ No newline at end of file
 }
\ No newline at end of file
index c973f1b..5be1a42 100644 (file)
@@ -1,7 +1,7 @@
-<div id="rng-module-documentCanvas">\r
-    <div id="rng-module-documentCanvas-mainArea">\r
-        <div id="rng-module-documentCanvas-contentWrapper">\r
-            <div id="rng-module-documentCanvas-content" contenteditable="true"></div>\r
-        </div>\r
-    </div>\r
+<div id="rng-module-documentCanvas">
+    <div id="rng-module-documentCanvas-mainArea">
+        <div id="rng-module-documentCanvas-contentWrapper">
+            <div id="rng-module-documentCanvas-content" contenteditable="true"></div>
+        </div>
+    </div>
 </div>
\ No newline at end of file
 </div>
\ No newline at end of file
index ac3e69a..a9ed767 100644 (file)
-define([\r
-'libs/jquery-1.9.1.min',\r
-'libs/chai', \r
-'./utils.js',\r
-'modules/documentCanvas/canvas',\r
-'modules/documentCanvas/canvasNode'\r
-], function($, chai, utils, canvas, canvasNode) {\r
-\r
-    'use strict';\r
-\r
-    var assert = chai.assert;\r
-    var assertDomEqual = utils.assertDomEqual;\r
-    \r
-    \r
-    suite('Quering nodes', function() {\r
-        test('getting preceding node', function() {\r
-            var c = canvas.create('<div wlxml-tag="section"><div wlxml-tag="p">a</div><div wlxml-tag="p">b</div></div>');\r
-            var secondP = c.findNodes({tag: 'p'})[1];\r
-            var firstP = c.getPrecedingNode({node: secondP});\r
-            assert.equal(firstP.getContent(), 'a');\r
-        });\r
-        \r
-       test('pervious node of node without "previous siblings" is its parent', function() {\r
-            var c = canvas.create('<div wlxml-tag="section"><div wlxml-tag="p">a</div></div>');\r
-            var paragraph = c.findNodes({tag: 'p'})[0];\r
-            assert.equal(c.getPrecedingNode({node: paragraph}).getTag(), 'section');\r
-        });\r
-    \r
-    });\r
-    \r
-    \r
-    suite('Inserting nodes', function() {\r
-        test('append node to root', function() {\r
-            var c = canvas.create();\r
-            var node = canvasNode.create({tag: 'header', klass: 'some-class'});\r
-            c.nodeAppend({node: node, to: 'root'});\r
-            assertDomEqual(c.getContent(), '<div wlxml-tag="header" wlxml-class="some-class">');\r
-        }); \r
-        \r
-        test('append node to another node', function() {\r
-            var c = canvas.create('<div wlxml-tag="section"></div>');\r
-            var node = canvasNode.create({tag: 'header', klass: 'some-class'});\r
-            var to = c.findNodes('div')[0];\r
-            c.nodeAppend({node: node, to: to});\r
-            assertDomEqual(c.getContent(), '<div wlxml-tag="section"><div wlxml-tag="header" wlxml-class="some-class"></div></div>');\r
-        });\r
-        \r
-        test('insert node after another node', function() {\r
-            var c = canvas.create('<div wlxml-tag="section"></div>');\r
-            var node = canvasNode.create({tag: 'header', klass: 'some-class'});\r
-            var after = c.findNodes('div')[0];\r
-            c.nodeInsertAfter({node: node, after: after});\r
-            assertDomEqual(c.getContent(), '<div wlxml-tag="section"></div><div wlxml-tag="header" wlxml-class="some-class"></div>');        \r
-        });\r
-        \r
-        test('wrap text in node', function() {\r
-            var c = canvas.create('<div wlxml-tag="section"><div wlxml-tag="header">Header 1</div></div>');\r
-            var header = c.findNodes({tag: 'header'})[0];\r
-            var wrapper = canvasNode.create({tag: 'aside'});\r
-            c.nodeWrap({inside: header, _with: wrapper, offsetStart: 1, offsetEnd: 6});\r
-            assertDomEqual(c.getContent(), '<div wlxml-tag="section"><div wlxml-tag="header">H<span wlxml-tag="aside">eader</span> 1</div></div>');\r
-        });\r
-        \r
-        test('wrap text in node - text not a first node', function() {\r
-            var c = canvas.create('<div wlxml-tag="header">Alice <span wlxml-tag="span">has a</span> cat</div>');\r
-            var header = c.findNodes({tag: 'header'})[0];\r
-            var wrapper = canvasNode.create({tag: 'aside'});\r
-            c.nodeWrap({inside: header, _with: wrapper, offsetStart: 1, offsetEnd: 4, textNodeIdx: 2});\r
-            assertDomEqual(c.getContent(), '<div wlxml-tag="header">Alice <span wlxml-tag="span">has a</span> <span wlxml-tag="aside">cat</span></div>');\r
-        });\r
-        \r
-        test('wrap text with nodes inside', function() {\r
-            var c = canvas.create('<div wlxml-tag="header">Alice has a <span wlxml-tag="span">small</span> cat</div>');\r
-            var header = c.findNodes({tag: 'header'})[0];\r
-            var wrapper = canvasNode.create({tag: 'aside'});\r
-            c.nodeWrap({inside: header, _with: wrapper, offsetStart: 6, offsetEnd: 4, textNodeIdx: [0,2]});\r
-            assertDomEqual(c.getContent(), '<div wlxml-tag="header">Alice <span wlxml-tag="aside">has a <span wlxml-tag="span">small</span> cat</span></div>');            \r
-        });\r
-        \r
-        test('split node', function() {\r
-            var c = canvas.create('<div wlxml-tag="section"><div wlxml-tag="header">Header 1</div></div>');\r
-            var header = c.findNodes({tag: 'header'})[0];\r
-            var newNode = c.nodeSplit({node: header, offset: 4});\r
-            assertDomEqual(c.getContent(), utils.cleanUp('\\r
-                <div wlxml-tag="section">\\r
-                    <div wlxml-tag="header">Head</div>\\r
-                    <div wlxml-tag="header">er 1</div>\\r
-                </div>'));\r
-            assert.ok(newNode.isSame(c.findNodes({tag: 'header'})[1]));\r
-        });\r
-        \r
-        test('split root node', function() {\r
-            var c = canvas.create('<div wlxml-tag="header">cat</div>');\r
-            var header = c.findNodes({tag: 'header'})[0];\r
-            var newNode = c.nodeSplit({node: header, offset: 1});\r
-            assertDomEqual(c.getContent(), utils.cleanUp('\\r
-                    <div wlxml-tag="header">c</div>\\r
-                    <div wlxml-tag="header">at</div>'));\r
-            assert.ok(newNode.isSame(c.findNodes({tag: 'header'})[1]));\r
-        });\r
-        \r
-        test('split node with subnodes', function() {\r
-            var c = canvas.create(utils.cleanUp('\\r
-                <div wlxml-tag="section">\\r
-                    <div wlxml-tag="header">Fancy and nice<span wlxml-tag="aside">header</span> 1</div>\\r
-                 </div>'));\r
-            var header = c.findNodes({tag: 'header'})[0];\r
-            var newNode = c.nodeSplit({node: header, offset: 5});\r
-            assertDomEqual(c.getContent(), utils.cleanUp('\\r
-                <div wlxml-tag="section">\\r
-                    <div wlxml-tag="header">Fancy</div>\\r
-                    <div wlxml-tag="header">and nice<span wlxml-tag="aside">header</span> 1</div>\\r
-                </div>'));\r
-        });\r
-        \r
-        test('remove node', function() {\r
-            var c = canvas.create('<div wlxml-tag="section"><span wlxml-tag="span">some text</span></div>');\r
-            var span = c.findNodes({tag: 'span'})[0];\r
-            c.nodeRemove({node: span});\r
-            assertDomEqual(c.getContent(), '<div wlxml-tag="section"></div>');\r
-        });\r
-    });\r
-    \r
-    \r
-    suite('Lists', function() {\r
-        test('create from existing nodes', function() {\r
-            var c = canvas.create(utils.cleanUp('\\r
-                <div wlxml-tag="section">\\r
-                    <div wlxml-tag="div">alice</div>\\r
-                    has\\r
-                    <div wlxml-tag="div">a</div>\\r
-                    <div wlxml-tag="div">cat</div>\\r
-                    <div wlxml-tag="div">or not</div>\\r
-                </div>'\r
-            ));\r
-            \r
-            var div_alice = c.findNodes({tag: 'div'})[0];\r
-            var div_cat = c.findNodes({tag:'div'})[2];\r
-            \r
-            c.listCreate({start: div_alice, end: div_cat});\r
-            \r
-            assertDomEqual(c.getContent(), utils.cleanUp('\\r
-                <div wlxml-tag="section">\\r
-                    <div wlxml-tag="div" wlxml-class="list-items">\\r
-                        <div wlxml-tag="div" wlxml-class="item">alice</div>\\r
-                        <div wlxml-tag="div" wlxml-class="item">has</div>\\r
-                        <div wlxml-tag="div" wlxml-class="item">a</div>\\r
-                        <div wlxml-tag="div" wlxml-class="item">cat</div>\\r
-                    </div>\\r
-                    <div wlxml-tag="div">or not</div>\\r
-                </div>'));\r
-        });\r
-        \r
-        test('create from existing nodes - start/end order doesn\'t matter', function() {\r
-            var html = utils.cleanUp('\\r
-                    <div wlxml-tag="div">alice</div>\\r
-                    <div wlxml-tag="div">cat</div>');\r
-            var expected = utils.cleanUp('\\r
-                    <div wlxml-tag="div" wlxml-class="list-items">\\r
-                        <div wlxml-tag="div" wlxml-class="item">alice</div>\\r
-                        <div wlxml-tag="div" wlxml-class="item">cat</div>\\r
-                    </div>');\r
-                    \r
-            var c = canvas.create(html);\r
-            var div_alice = c.findNodes({tag: 'div'})[0];\r
-            var div_cat = c.findNodes({tag:'div'})[1];\r
-            c.listCreate({start: div_cat, end: div_alice});\r
-            assertDomEqual(c.getContent(), expected);\r
-            \r
-            c = canvas.create(html);\r
-            div_alice = c.findNodes({tag: 'div'})[0];\r
-            div_cat = c.findNodes({tag:'div'})[1];\r
-            c.listCreate({start: div_alice, end: div_cat});\r
-            assertDomEqual(c.getContent(), expected);\r
-        });\r
-        \r
-        test('remove', function() {\r
-            var c = canvas.create(utils.cleanUp('\\r
-                <div wlxml-tag="section">\\r
-                    <div wlxml-tag="div" wlxml-class="list-items">\\r
-                        <div wlxml-tag="div" wlxml-class="item">alice</div>\\r
-                        <div wlxml-tag="div" wlxml-class="item">cat</div>\\r
-                    </div>\\r
-                </div>'));\r
-            var item = c.findNodes({klass: 'item'})[1];\r
-            c.listRemove({pointer: item});\r
-            assertDomEqual(c.getContent(), utils.cleanUp('\\r
-                <div wlxml-tag="section">\\r
-                    <div wlxml-tag="div">alice</div>\\r
-                    <div wlxml-tag="div">cat</div>\\r
-                </div>'));\r
-        });\r
-        \r
-        test('checking if node is inside a list', function() {\r
-            var c = canvas.create(utils.cleanUp('\\r
-                <div wlxml-tag="section">\\r
-                    <div wlxml-tag="div" wlxml-class="list-items-enum">\\r
-                        <div wlxml-tag="div" wlxml-class="item">alice <span wlxml-tag="span"></span</div>\\r
-                        <div wlxml-tag="div" wlxml-class="item">cat</div>\\r
-                    </div>\\r
-                </div>'));\r
-            assert.ok(c.nodeInsideList({node: c.findNodes({klass: 'item'})[1]}), 'item is inside a list');\r
-            assert.ok(c.nodeInsideList({node: c.findNodes({tag: 'span'})[0]}), 'things nested in item are inside a list');\r
-        });\r
-        \r
-        test('moving items to nested list', function() {\r
-            var listHTML = utils.cleanUp('\\r
-                    <div wlxml-tag="div" wlxml-class="list-items">\\r
-                        <div wlxml-tag="div" wlxml-class="item">alice</div>\\r
-                        <div wlxml-tag="div" wlxml-class="item">cat</div>\\r
-                        <div wlxml-tag="div" wlxml-class="item">dog</div>\\r
-                        <div wlxml-tag="div" wlxml-class="item">bee</div>\\r
-                    </div>');\r
-            var c = canvas.create(listHTML);\r
-            var items = c.findNodes({klass: 'item'});\r
-            var cat_item = items[1];\r
-            var dog_item = items[2];\r
-            \r
-            c.listCreate({start: cat_item, end: dog_item});\r
-            \r
-            assertDomEqual(c.getContent(), utils.cleanUp('\\r
-                    <div wlxml-tag="div" wlxml-class="list-items">\\r
-                        <div wlxml-tag="div" wlxml-class="item">alice</div>\\r
-                        <div wlxml-tag="div" wlxml-class="item" class="canvas-silent-item">\\r
-                            <div wlxml-tag="div" wlxml-class="list-items">\\r
-                                <div wlxml-tag="div" wlxml-class="item">cat</div>\\r
-                                <div wlxml-tag="div" wlxml-class="item">dog</div>\\r
-                            </div>\\r
-                        </div>\\r
-                        <div wlxml-tag="div" wlxml-class="item">bee</div>\\r
-                    </div>'\r
-            ));\r
-        });\r
-        \r
-        test('removing nested list', function() {\r
-            var nestedList = utils.cleanUp('\\r
-                    <div wlxml-tag="div" wlxml-class="list-items">\\r
-                        <div wlxml-tag="div" wlxml-class="item">alice</div>\\r
-                        <div wlxml-tag="div" wlxml-class="item">\\r
-                            <div wlxml-tag="div" wlxml-class="list-items">\\r
-                                <div wlxml-tag="div" wlxml-class="item">cat</div>\\r
-                                <div wlxml-tag="div" wlxml-class="item">dog</div>\\r
-                            </div>\\r
-                        </div>\\r
-                        <div wlxml-tag="div" wlxml-class="item">bee</div>\\r
-                    </div>');\r
-                    \r
-            var c = canvas.create(nestedList);\r
-            var dog_item = c.findNodes('[wlxml-class=list-items] [wlxml-class=list-items] > div')[1];\r
-            assert.equal(dog_item.getContent(), 'dog');\r
-            \r
-            c.listRemove({pointer: dog_item});\r
-            \r
-            assertDomEqual(c.getContent(), utils.cleanUp('\\r
-                    <div wlxml-tag="div" wlxml-class="list-items">\\r
-                        <div wlxml-tag="div" wlxml-class="item">alice</div>\\r
-                        <div wlxml-tag="div" wlxml-class="item">cat</div>\\r
-                        <div wlxml-tag="div" wlxml-class="item">dog</div>\\r
-                        <div wlxml-tag="div" wlxml-class="item">bee</div>\\r
-                    </div>'));\r
-            \r
-            \r
-        });\r
-    });\r
+define([
+'libs/jquery-1.9.1.min',
+'libs/chai', 
+'./utils.js',
+'modules/documentCanvas/canvas',
+'modules/documentCanvas/canvasNode'
+], function($, chai, utils, canvas, canvasNode) {
+
+    'use strict';
+
+    var assert = chai.assert;
+    var assertDomEqual = utils.assertDomEqual;
+    
+    
+    suite('Quering nodes', function() {
+        test('getting preceding node', function() {
+            var c = canvas.create('<div wlxml-tag="section"><div wlxml-tag="p">a</div><div wlxml-tag="p">b</div></div>');
+            var secondP = c.findNodes({tag: 'p'})[1];
+            var firstP = c.getPrecedingNode({node: secondP});
+            assert.equal(firstP.getContent(), 'a');
+        });
+        
+       test('pervious node of node without "previous siblings" is its parent', function() {
+            var c = canvas.create('<div wlxml-tag="section"><div wlxml-tag="p">a</div></div>');
+            var paragraph = c.findNodes({tag: 'p'})[0];
+            assert.equal(c.getPrecedingNode({node: paragraph}).getTag(), 'section');
+        });
+    
+    });
+    
+    
+    suite('Inserting nodes', function() {
+        test('append node to root', function() {
+            var c = canvas.create();
+            var node = canvasNode.create({tag: 'header', klass: 'some-class'});
+            c.nodeAppend({node: node, to: 'root'});
+            assertDomEqual(c.getContent(), '<div wlxml-tag="header" wlxml-class="some-class">');
+        }); 
+        
+        test('append node to another node', function() {
+            var c = canvas.create('<div wlxml-tag="section"></div>');
+            var node = canvasNode.create({tag: 'header', klass: 'some-class'});
+            var to = c.findNodes('div')[0];
+            c.nodeAppend({node: node, to: to});
+            assertDomEqual(c.getContent(), '<div wlxml-tag="section"><div wlxml-tag="header" wlxml-class="some-class"></div></div>');
+        });
+        
+        test('insert node after another node', function() {
+            var c = canvas.create('<div wlxml-tag="section"></div>');
+            var node = canvasNode.create({tag: 'header', klass: 'some-class'});
+            var after = c.findNodes('div')[0];
+            c.nodeInsertAfter({node: node, after: after});
+            assertDomEqual(c.getContent(), '<div wlxml-tag="section"></div><div wlxml-tag="header" wlxml-class="some-class"></div>');        
+        });
+        
+        test('wrap text in node', function() {
+            var c = canvas.create('<div wlxml-tag="section"><div wlxml-tag="header">Header 1</div></div>');
+            var header = c.findNodes({tag: 'header'})[0];
+            var wrapper = canvasNode.create({tag: 'aside'});
+            c.nodeWrap({inside: header, _with: wrapper, offsetStart: 1, offsetEnd: 6});
+            assertDomEqual(c.getContent(), '<div wlxml-tag="section"><div wlxml-tag="header">H<span wlxml-tag="aside">eader</span> 1</div></div>');
+        });
+        
+        test('wrap text in node - text not a first node', function() {
+            var c = canvas.create('<div wlxml-tag="header">Alice <span wlxml-tag="span">has a</span> cat</div>');
+            var header = c.findNodes({tag: 'header'})[0];
+            var wrapper = canvasNode.create({tag: 'aside'});
+            c.nodeWrap({inside: header, _with: wrapper, offsetStart: 1, offsetEnd: 4, textNodeIdx: 2});
+            assertDomEqual(c.getContent(), '<div wlxml-tag="header">Alice <span wlxml-tag="span">has a</span> <span wlxml-tag="aside">cat</span></div>');
+        });
+        
+        test('wrap text with nodes inside', function() {
+            var c = canvas.create('<div wlxml-tag="header">Alice has a <span wlxml-tag="span">small</span> cat</div>');
+            var header = c.findNodes({tag: 'header'})[0];
+            var wrapper = canvasNode.create({tag: 'aside'});
+            c.nodeWrap({inside: header, _with: wrapper, offsetStart: 6, offsetEnd: 4, textNodeIdx: [0,2]});
+            assertDomEqual(c.getContent(), '<div wlxml-tag="header">Alice <span wlxml-tag="aside">has a <span wlxml-tag="span">small</span> cat</span></div>');            
+        });
+        
+        test('split node', function() {
+            var c = canvas.create('<div wlxml-tag="section"><div wlxml-tag="header">Header 1</div></div>');
+            var header = c.findNodes({tag: 'header'})[0];
+            var newNode = c.nodeSplit({node: header, offset: 4});
+            assertDomEqual(c.getContent(), utils.cleanUp('\
+                <div wlxml-tag="section">\
+                    <div wlxml-tag="header">Head</div>\
+                    <div wlxml-tag="header">er 1</div>\
+                </div>'));
+            assert.ok(newNode.isSame(c.findNodes({tag: 'header'})[1]));
+        });
+        
+        test('split root node', function() {
+            var c = canvas.create('<div wlxml-tag="header">cat</div>');
+            var header = c.findNodes({tag: 'header'})[0];
+            var newNode = c.nodeSplit({node: header, offset: 1});
+            assertDomEqual(c.getContent(), utils.cleanUp('\
+                    <div wlxml-tag="header">c</div>\
+                    <div wlxml-tag="header">at</div>'));
+            assert.ok(newNode.isSame(c.findNodes({tag: 'header'})[1]));
+        });
+        
+        test('split node with subnodes', function() {
+            var c = canvas.create(utils.cleanUp('\
+                <div wlxml-tag="section">\
+                    <div wlxml-tag="header">Fancy and nice<span wlxml-tag="aside">header</span> 1</div>\
+                 </div>'));
+            var header = c.findNodes({tag: 'header'})[0];
+            var newNode = c.nodeSplit({node: header, offset: 5});
+            assertDomEqual(c.getContent(), utils.cleanUp('\
+                <div wlxml-tag="section">\
+                    <div wlxml-tag="header">Fancy</div>\
+                    <div wlxml-tag="header">and nice<span wlxml-tag="aside">header</span> 1</div>\
+                </div>'));
+        });
+        
+        test('remove node', function() {
+            var c = canvas.create('<div wlxml-tag="section"><span wlxml-tag="span">some text</span></div>');
+            var span = c.findNodes({tag: 'span'})[0];
+            c.nodeRemove({node: span});
+            assertDomEqual(c.getContent(), '<div wlxml-tag="section"></div>');
+        });
+    });
+    
+    
+    suite('Lists', function() {
+        test('create from existing nodes', function() {
+            var c = canvas.create(utils.cleanUp('\
+                <div wlxml-tag="section">\
+                    <div wlxml-tag="div">alice</div>\
+                    has\
+                    <div wlxml-tag="div">a</div>\
+                    <div wlxml-tag="div">cat</div>\
+                    <div wlxml-tag="div">or not</div>\
+                </div>'
+            ));
+            
+            var div_alice = c.findNodes({tag: 'div'})[0];
+            var div_cat = c.findNodes({tag:'div'})[2];
+            
+            c.listCreate({start: div_alice, end: div_cat});
+            
+            assertDomEqual(c.getContent(), utils.cleanUp('\
+                <div wlxml-tag="section">\
+                    <div wlxml-tag="div" wlxml-class="list-items">\
+                        <div wlxml-tag="div" wlxml-class="item">alice</div>\
+                        <div wlxml-tag="div" wlxml-class="item">has</div>\
+                        <div wlxml-tag="div" wlxml-class="item">a</div>\
+                        <div wlxml-tag="div" wlxml-class="item">cat</div>\
+                    </div>\
+                    <div wlxml-tag="div">or not</div>\
+                </div>'));
+        });
+        
+        test('create from existing nodes - start/end order doesn\'t matter', function() {
+            var html = utils.cleanUp('\
+                    <div wlxml-tag="div">alice</div>\
+                    <div wlxml-tag="div">cat</div>');
+            var expected = utils.cleanUp('\
+                    <div wlxml-tag="div" wlxml-class="list-items">\
+                        <div wlxml-tag="div" wlxml-class="item">alice</div>\
+                        <div wlxml-tag="div" wlxml-class="item">cat</div>\
+                    </div>');
+                    
+            var c = canvas.create(html);
+            var div_alice = c.findNodes({tag: 'div'})[0];
+            var div_cat = c.findNodes({tag:'div'})[1];
+            c.listCreate({start: div_cat, end: div_alice});
+            assertDomEqual(c.getContent(), expected);
+            
+            c = canvas.create(html);
+            div_alice = c.findNodes({tag: 'div'})[0];
+            div_cat = c.findNodes({tag:'div'})[1];
+            c.listCreate({start: div_alice, end: div_cat});
+            assertDomEqual(c.getContent(), expected);
+        });
+        
+        test('remove', function() {
+            var c = canvas.create(utils.cleanUp('\
+                <div wlxml-tag="section">\
+                    <div wlxml-tag="div" wlxml-class="list-items">\
+                        <div wlxml-tag="div" wlxml-class="item">alice</div>\
+                        <div wlxml-tag="div" wlxml-class="item">cat</div>\
+                    </div>\
+                </div>'));
+            var item = c.findNodes({klass: 'item'})[1];
+            c.listRemove({pointer: item});
+            assertDomEqual(c.getContent(), utils.cleanUp('\
+                <div wlxml-tag="section">\
+                    <div wlxml-tag="div">alice</div>\
+                    <div wlxml-tag="div">cat</div>\
+                </div>'));
+        });
+        
+        test('checking if node is inside a list', function() {
+            var c = canvas.create(utils.cleanUp('\
+                <div wlxml-tag="section">\
+                    <div wlxml-tag="div" wlxml-class="list-items-enum">\
+                        <div wlxml-tag="div" wlxml-class="item">alice <span wlxml-tag="span"></span</div>\
+                        <div wlxml-tag="div" wlxml-class="item">cat</div>\
+                    </div>\
+                </div>'));
+            assert.ok(c.nodeInsideList({node: c.findNodes({klass: 'item'})[1]}), 'item is inside a list');
+            assert.ok(c.nodeInsideList({node: c.findNodes({tag: 'span'})[0]}), 'things nested in item are inside a list');
+        });
+        
+        test('moving items to nested list', function() {
+            var listHTML = utils.cleanUp('\
+                    <div wlxml-tag="div" wlxml-class="list-items">\
+                        <div wlxml-tag="div" wlxml-class="item">alice</div>\
+                        <div wlxml-tag="div" wlxml-class="item">cat</div>\
+                        <div wlxml-tag="div" wlxml-class="item">dog</div>\
+                        <div wlxml-tag="div" wlxml-class="item">bee</div>\
+                    </div>');
+            var c = canvas.create(listHTML);
+            var items = c.findNodes({klass: 'item'});
+            var cat_item = items[1];
+            var dog_item = items[2];
+            
+            c.listCreate({start: cat_item, end: dog_item});
+            
+            assertDomEqual(c.getContent(), utils.cleanUp('\
+                    <div wlxml-tag="div" wlxml-class="list-items">\
+                        <div wlxml-tag="div" wlxml-class="item">alice</div>\
+                        <div wlxml-tag="div" wlxml-class="item" class="canvas-silent-item">\
+                            <div wlxml-tag="div" wlxml-class="list-items">\
+                                <div wlxml-tag="div" wlxml-class="item">cat</div>\
+                                <div wlxml-tag="div" wlxml-class="item">dog</div>\
+                            </div>\
+                        </div>\
+                        <div wlxml-tag="div" wlxml-class="item">bee</div>\
+                    </div>'
+            ));
+        });
+        
+        test('removing nested list', function() {
+            var nestedList = utils.cleanUp('\
+                    <div wlxml-tag="div" wlxml-class="list-items">\
+                        <div wlxml-tag="div" wlxml-class="item">alice</div>\
+                        <div wlxml-tag="div" wlxml-class="item">\
+                            <div wlxml-tag="div" wlxml-class="list-items">\
+                                <div wlxml-tag="div" wlxml-class="item">cat</div>\
+                                <div wlxml-tag="div" wlxml-class="item">dog</div>\
+                            </div>\
+                        </div>\
+                        <div wlxml-tag="div" wlxml-class="item">bee</div>\
+                    </div>');
+                    
+            var c = canvas.create(nestedList);
+            var dog_item = c.findNodes('[wlxml-class=list-items] [wlxml-class=list-items] > div')[1];
+            assert.equal(dog_item.getContent(), 'dog');
+            
+            c.listRemove({pointer: dog_item});
+            
+            assertDomEqual(c.getContent(), utils.cleanUp('\
+                    <div wlxml-tag="div" wlxml-class="list-items">\
+                        <div wlxml-tag="div" wlxml-class="item">alice</div>\
+                        <div wlxml-tag="div" wlxml-class="item">cat</div>\
+                        <div wlxml-tag="div" wlxml-class="item">dog</div>\
+                        <div wlxml-tag="div" wlxml-class="item">bee</div>\
+                    </div>'));
+            
+            
+        });
+    });
 });
\ No newline at end of file
 });
\ No newline at end of file
index f9507d9..a1595f7 100644 (file)
@@ -1,62 +1,62 @@
-define([\r
-'libs/jquery-1.9.1.min',\r
-'libs/chai', \r
-'./utils.js',\r
-'modules/documentCanvas/canvasNode'\r
-], function($, chai, utils, canvasNode) {\r
-\r
-'use strict';\r
-\r
-var assert = chai.assert;\r
-\r
-var assertDomEqual = function(lhs, rhs) {\r
-   lhs.attr('id', '');\r
-   rhs.attr('id', '');\r
-   return assert.ok(lhs[0].isEqualNode(rhs[0]), 'nodes are equal');\r
-\r
-};\r
-\r
-suite('Create canvas node', function() {  \r
-    test('from description', function() {\r
-        var node = canvasNode.create({tag: 'header', klass: 'some-class', content: 'some text content'});\r
-        assert.equal(node.getTag(), 'header');\r
-        assert.equal(node.getClass(), 'some-class');\r
-        assert.equal(node.getContent(), 'some text content');\r
-        assertDomEqual($('<div wlxml-tag="header" wlxml-class="some-class">some text content</div>'), node.dom);\r
-    });\r
-    \r
-    test('from dom object', function() {\r
-        var node = canvasNode.create($('<div wlxml-tag="header" wlxml-class="some-class" id="1">'));\r
-        assert.equal(node.getTag(), 'header');\r
-        assert.equal(node.getClass(), 'some-class');\r
-        //assertDomEqual($('<div wlxml-tag="header" wlxml-class="some-class">'), node.dom);\r
-    });\r
-});\r
-\r
-suite('class information', function() {\r
-    test('class of', function() {\r
-        var node = canvasNode.create({tag: 'header', klass: 'a-b-c'});\r
-        assert.ok(node.isOfClass('a'), 'first level');\r
-        assert.ok(node.isOfClass('a-b'), 'second level');\r
-        assert.ok(node.isOfClass('a-b-c'), 'third level');\r
-        assert.notOk(node.isOfClass('b-c'));\r
-        \r
-        var node2 = canvasNode.create({tag: 'header'});\r
-        assert.notOk(node2.isOfClass('b'));\r
-\r
-    });\r
-\r
-});\r
-\r
-suite('comparing nodes', function() {\r
-    test('isSame', function() {\r
-        var html = '<div wlxml-class="some-class" wlxml-tag="some-tag">';\r
-        var dom1 = $(html);\r
-        var dom2 = $(html);\r
-        assert.ok(canvasNode.create(dom1).isSame(canvasNode.create(dom1)));\r
-        assert.notOk(canvasNode.create(dom1).isSame(canvasNode.create(dom2)));\r
-    });\r
-});\r
-\r
-\r
+define([
+'libs/jquery-1.9.1.min',
+'libs/chai', 
+'./utils.js',
+'modules/documentCanvas/canvasNode'
+], function($, chai, utils, canvasNode) {
+
+'use strict';
+
+var assert = chai.assert;
+
+var assertDomEqual = function(lhs, rhs) {
+   lhs.attr('id', '');
+   rhs.attr('id', '');
+   return assert.ok(lhs[0].isEqualNode(rhs[0]), 'nodes are equal');
+
+};
+
+suite('Create canvas node', function() {  
+    test('from description', function() {
+        var node = canvasNode.create({tag: 'header', klass: 'some-class', content: 'some text content'});
+        assert.equal(node.getTag(), 'header');
+        assert.equal(node.getClass(), 'some-class');
+        assert.equal(node.getContent(), 'some text content');
+        assertDomEqual($('<div wlxml-tag="header" wlxml-class="some-class">some text content</div>'), node.dom);
+    });
+    
+    test('from dom object', function() {
+        var node = canvasNode.create($('<div wlxml-tag="header" wlxml-class="some-class" id="1">'));
+        assert.equal(node.getTag(), 'header');
+        assert.equal(node.getClass(), 'some-class');
+        //assertDomEqual($('<div wlxml-tag="header" wlxml-class="some-class">'), node.dom);
+    });
+});
+
+suite('class information', function() {
+    test('class of', function() {
+        var node = canvasNode.create({tag: 'header', klass: 'a-b-c'});
+        assert.ok(node.isOfClass('a'), 'first level');
+        assert.ok(node.isOfClass('a-b'), 'second level');
+        assert.ok(node.isOfClass('a-b-c'), 'third level');
+        assert.notOk(node.isOfClass('b-c'));
+        
+        var node2 = canvasNode.create({tag: 'header'});
+        assert.notOk(node2.isOfClass('b'));
+
+    });
+
+});
+
+suite('comparing nodes', function() {
+    test('isSame', function() {
+        var html = '<div wlxml-class="some-class" wlxml-tag="some-tag">';
+        var dom1 = $(html);
+        var dom2 = $(html);
+        assert.ok(canvasNode.create(dom1).isSame(canvasNode.create(dom1)));
+        assert.notOk(canvasNode.create(dom1).isSame(canvasNode.create(dom2)));
+    });
+});
+
+
 });
\ No newline at end of file
 });
\ No newline at end of file
index 93d4c03..fcb9853 100644 (file)
@@ -1,49 +1,49 @@
-define(['libs/jquery-1.9.1.min', 'libs/chai'], function($, chai) {\r
-    return {\r
-        cleanUp: function(xml) {\r
-            var rmws = function(node) {\r
-                if(node.nodeType === 3) {\r
-                    node.data = $.trim(node.data);\r
-                }\r
-                else {\r
-                    $(node).contents().each(function() {\r
-                        rmws(this);\r
-                    });\r
-                }\r
-            };\r
-            \r
-            xml = $($.trim(xml));\r
-            xml.each(function() {\r
-                rmws(this);\r
-            });\r
-            \r
-            /*var toret = xml\r
-                .replace(/(<.*>)\s*(<.*>)/gm, '$1$2')\r
-                .replace(/(<\/.*>)\s*(<\/.*>)/gm, '$1$2')\r
-                .replace(/(<\/.*>)\s*(<.*>)/gm, '$1$2');\r
-            return $.trim(toret);*/\r
-            return $('<div>').append(xml).html();\r
-        },\r
-        \r
-        assertDomEqual: function(lhs, rhs) {\r
-            lhs = lhs.clone();\r
-            var rhsArr = $.parseHTML(rhs);\r
-            if(rhsArr.length === 1) {\r
-                rhs = $(rhsArr[0]);\r
-            } else {\r
-                rhs = $('<div>');\r
-                $.each(rhsArr, function(i, el) {\r
-                    rhs.append(el);\r
-                });            \r
-            }\r
-            if(lhs.length > 1) {\r
-                lhs = $('<div>').append(lhs);\r
-            }\r
-            lhs.attr('id', '');\r
-            rhs.attr('id', '');\r
-            lhs.find('*').each(function() {$(this).attr('id', '');});\r
-            rhs.find('*').each(function() {$(this).attr('id', '');});\r
-            return chai.assert.ok(lhs[0].isEqualNode(rhs[0]), 'nodes are equal');\r
-        }\r
-    };\r
+define(['libs/jquery-1.9.1.min', 'libs/chai'], function($, chai) {
+    return {
+        cleanUp: function(xml) {
+            var rmws = function(node) {
+                if(node.nodeType === 3) {
+                    node.data = $.trim(node.data);
+                }
+                else {
+                    $(node).contents().each(function() {
+                        rmws(this);
+                    });
+                }
+            };
+            
+            xml = $($.trim(xml));
+            xml.each(function() {
+                rmws(this);
+            });
+            
+            /*var toret = xml
+                .replace(/(<.*>)\s*(<.*>)/gm, '$1$2')
+                .replace(/(<\/.*>)\s*(<\/.*>)/gm, '$1$2')
+                .replace(/(<\/.*>)\s*(<.*>)/gm, '$1$2');
+            return $.trim(toret);*/
+            return $('<div>').append(xml).html();
+        },
+        
+        assertDomEqual: function(lhs, rhs) {
+            lhs = lhs.clone();
+            var rhsArr = $.parseHTML(rhs);
+            if(rhsArr.length === 1) {
+                rhs = $(rhsArr[0]);
+            } else {
+                rhs = $('<div>');
+                $.each(rhsArr, function(i, el) {
+                    rhs.append(el);
+                });            
+            }
+            if(lhs.length > 1) {
+                lhs = $('<div>').append(lhs);
+            }
+            lhs.attr('id', '');
+            rhs.attr('id', '');
+            lhs.find('*').each(function() {$(this).attr('id', '');});
+            rhs.find('*').each(function() {$(this).attr('id', '');});
+            return chai.assert.ok(lhs[0].isEqualNode(rhs[0]), 'nodes are equal');
+        }
+    };
 });
\ No newline at end of file
 });
\ No newline at end of file
index 7001359..c82e6fb 100644 (file)
@@ -1,29 +1,29 @@
-define(['libs/chai', './utils.js'], function(chai, utils) {\r
-\r
-'use strict';\r
-var assert = chai.assert;\r
-\r
-test('open+open', function() {\r
-    assert.equal(utils.cleanUp('<div class="class"> \n <div class="class"></div></div>'), '<div class="class"><div class="class"></div></div>');\r
-});\r
-\r
-test('close+close', function() {\r
-    assert.equal(utils.cleanUp('<div><div></div>\n </div>'), '<div><div></div></div>');\r
-});\r
-\r
-test('close+open', function() {\r
-    assert.equal(utils.cleanUp('<div></div>\n <div class="class"></div>'), '<div></div><div class="class"></div>');\r
-});\r
-\r
-test('bug', function() {\r
-    var txt = '\\r
-                <section> \\r
-                    <header class="some.class">Head</header>\\r
-                    <header class="some.class">er 1</header>\\r
-                </section>';\r
-    var txt2 = '<section><header class="some.class">Head</header><header class="some.class">er 1</header></section>';\r
-    assert.equal(utils.cleanUp(txt), txt2); \r
-});\r
-\r
-\r
+define(['libs/chai', './utils.js'], function(chai, utils) {
+
+'use strict';
+var assert = chai.assert;
+
+test('open+open', function() {
+    assert.equal(utils.cleanUp('<div class="class"> \n <div class="class"></div></div>'), '<div class="class"><div class="class"></div></div>');
+});
+
+test('close+close', function() {
+    assert.equal(utils.cleanUp('<div><div></div>\n </div>'), '<div><div></div></div>');
+});
+
+test('close+open', function() {
+    assert.equal(utils.cleanUp('<div></div>\n <div class="class"></div>'), '<div></div><div class="class"></div>');
+});
+
+test('bug', function() {
+    var txt = '\
+                <section> \
+                    <header class="some.class">Head</header>\
+                    <header class="some.class">er 1</header>\
+                </section>';
+    var txt2 = '<section><header class="some.class">Head</header><header class="some.class">er 1</header></section>';
+    assert.equal(utils.cleanUp(txt), txt2); 
+});
+
+
 });
\ No newline at end of file
 });
\ No newline at end of file
index 79c28b6..effe253 100644 (file)
-define(['libs/jquery-1.9.1.min'], function($) {\r
-\r
-    'use strict';\r
-\r
-    var transformations = {};\r
-\r
-    transformations.fromXML = {\r
-        getHTMLTree: function(xml) {\r
-            var inner = $(xml).clone();\r
-            var toret = $('<div></div>');\r
-            toret.append(inner);\r
-            \r
-            var toBlock = ['div', 'section', 'header'];\r
-            var toInline = ['aside', 'span'];\r
-            \r
-            var transform = function(tags, replacingTagName) {\r
-                tags.forEach(function(tagName) {\r
-                    tagName = tagName.toLowerCase();\r
-                    console.log('running ' + tagName);\r
-                    toret.find(tagName).replaceWith(function() {\r
-                        var currentTag = $(this);\r
-                        if(currentTag.attr('wlxml-tag'))\r
-                            return;\r
-                        var toret = $('<' + replacingTagName + '>').attr('wlxml-tag', tagName);\r
-                        toret.attr('id', 'xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {var r = Math.random()*16|0,v=c=='x'?r:r&0x3|0x8;return v.toString(16);}));\r
-                        for(var i = 0; i < this.attributes.length; i++) {\r
-                            var attr = this.attributes.item(i);\r
-                            var value = attr.name === 'class' ? attr.value.replace(/\./g, '-') : attr.value;\r
-                            toret.attr('wlxml-' + attr.name, value);\r
-                        }\r
-                        toret.append(currentTag.contents());\r
-                        return toret;\r
-                    });\r
-                });\r
-            };\r
-            \r
-            transform(toBlock, 'div');\r
-            transform(toInline, 'span');\r
-\r
-            toret.find(":not(iframe)").addBack().contents().filter(function() {\r
-                return this.nodeType == 3;} ).each(function() {\r
-                    var n = $(this); \r
-                    var hasText = /\S/g.test(n.text());\r
-                    if(!hasText) {\r
-                        n.remove();\r
-                        return;\r
-                    }\r
-                    var startSpace = /\s/g.test(n.text().substr(0,1));\r
-                    var endSpace = /\s/g.test(n.text().substr(-1)) && n.text().length > 1;\r
-                    var trimmed = $.trim(n.text());\r
-                    n.get(0).data = (startSpace ? ' ' : '') + trimmed + (endSpace ? ' ' : '');\r
-            });\r
-            \r
-            return toret.children();\r
-        },\r
-        getMetaData: function(xml) {\r
-            var toret = {};\r
-            $(xml).find('metadata').children().each(function() {\r
-                var node = $(this);\r
-                toret[this.nodeName.split(':')[1].toLowerCase()] = node.text();\r
-            });\r
-            return toret;\r
-        },\r
-        getDocumentDescription: function(xml) {\r
-            return {\r
-                HTMLTree: this.getHTMLTree(xml),\r
-                metadata: this.getMetaData(xml)\r
-            };\r
-        }\r
-    };\r
-\r
-    transformations.toXML = {\r
-        getXML: function(body) {\r
-            \r
-            var inner = body.clone();\r
-            var toret = $('<div></div>');\r
-            toret.append(inner);\r
-            \r
-            toret.find('div, span').replaceWith(function() {\r
-                var div = $(this);\r
-                var tagName = div.attr('wlxml-tag');\r
-                var toret = $('<'+tagName+'>');\r
-                                   \r
-                for(var i = 0; i < this.attributes.length; i++) {\r
-                    var attr = this.attributes.item(i);\r
-                    var split = attr.name.split('-');\r
-                    console.log(split);\r
-                    if(split[0] !== 'wlxml' || (split.length > 1 && split[1] === 'tag')) \r
-                        continue;\r
-                    var wlxmlName = split.splice(1).join('-');\r
-                    var value = wlxmlName === 'class' ? attr.value.replace(/-/g, '.') : attr.value;\r
-                    console.log(name + ': ' + value);\r
-                    if(value.length && value.length > 0)\r
-                        toret.attr(wlxmlName, value);\r
-                }\r
-                    \r
-                toret.append(div.contents());\r
-                return toret;\r
-            });\r
-\r
-            return vkbeautify.xml(toret.html());\r
-        }\r
-    };\r
-\r
-    return transformations;\r
-\r
+define(['libs/jquery-1.9.1.min'], function($) {
+
+    'use strict';
+
+    var transformations = {};
+
+    transformations.fromXML = {
+        getHTMLTree: function(xml) {
+            var inner = $(xml).clone();
+            var toret = $('<div></div>');
+            toret.append(inner);
+            
+            var toBlock = ['div', 'section', 'header'];
+            var toInline = ['aside', 'span'];
+            
+            var transform = function(tags, replacingTagName) {
+                tags.forEach(function(tagName) {
+                    tagName = tagName.toLowerCase();
+                    console.log('running ' + tagName);
+                    toret.find(tagName).replaceWith(function() {
+                        var currentTag = $(this);
+                        if(currentTag.attr('wlxml-tag'))
+                            return;
+                        var toret = $('<' + replacingTagName + '>').attr('wlxml-tag', tagName);
+                        toret.attr('id', 'xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {var r = Math.random()*16|0,v=c=='x'?r:r&0x3|0x8;return v.toString(16);}));
+                        for(var i = 0; i < this.attributes.length; i++) {
+                            var attr = this.attributes.item(i);
+                            var value = attr.name === 'class' ? attr.value.replace(/\./g, '-') : attr.value;
+                            toret.attr('wlxml-' + attr.name, value);
+                        }
+                        toret.append(currentTag.contents());
+                        return toret;
+                    });
+                });
+            };
+            
+            transform(toBlock, 'div');
+            transform(toInline, 'span');
+
+            toret.find(":not(iframe)").addBack().contents().filter(function() {
+                return this.nodeType == 3;} ).each(function() {
+                    var n = $(this); 
+                    var hasText = /\S/g.test(n.text());
+                    if(!hasText) {
+                        n.remove();
+                        return;
+                    }
+                    var startSpace = /\s/g.test(n.text().substr(0,1));
+                    var endSpace = /\s/g.test(n.text().substr(-1)) && n.text().length > 1;
+                    var trimmed = $.trim(n.text());
+                    n.get(0).data = (startSpace ? ' ' : '') + trimmed + (endSpace ? ' ' : '');
+            });
+            
+            return toret.children();
+        },
+        getMetaData: function(xml) {
+            var toret = {};
+            $(xml).find('metadata').children().each(function() {
+                var node = $(this);
+                toret[this.nodeName.split(':')[1].toLowerCase()] = node.text();
+            });
+            return toret;
+        },
+        getDocumentDescription: function(xml) {
+            return {
+                HTMLTree: this.getHTMLTree(xml),
+                metadata: this.getMetaData(xml)
+            };
+        }
+    };
+
+    transformations.toXML = {
+        getXML: function(body) {
+            
+            var inner = body.clone();
+            var toret = $('<div></div>');
+            toret.append(inner);
+            
+            toret.find('div, span').replaceWith(function() {
+                var div = $(this);
+                var tagName = div.attr('wlxml-tag');
+                var toret = $('<'+tagName+'>');
+                                   
+                for(var i = 0; i < this.attributes.length; i++) {
+                    var attr = this.attributes.item(i);
+                    var split = attr.name.split('-');
+                    console.log(split);
+                    if(split[0] !== 'wlxml' || (split.length > 1 && split[1] === 'tag')) 
+                        continue;
+                    var wlxmlName = split.splice(1).join('-');
+                    var value = wlxmlName === 'class' ? attr.value.replace(/-/g, '.') : attr.value;
+                    console.log(name + ': ' + value);
+                    if(value.length && value.length > 0)
+                        toret.attr(wlxmlName, value);
+                }
+                    
+                toret.append(div.contents());
+                return toret;
+            });
+
+            return vkbeautify.xml(toret.html());
+        }
+    };
+
+    return transformations;
+
 });
\ No newline at end of file
 });
\ No newline at end of file
index 2647ee3..8e686e6 100644 (file)
-define([\r
-'libs/jquery-1.9.1.min',\r
-'libs/underscore-min',\r
-'./restoreDialog',\r
-'libs/text!./templates/main.html',\r
-'libs/text!./templates/item.html'\r
-], function($, _, restoreDialog, mainTemplateSrc, itemTemplateSrc) {\r
-\r
-'use strict';\r
-    \r
-return function(sandbox) {\r
-    \r
-    var dom = $(_.template(mainTemplateSrc)());\r
-    var domNodes = {\r
-        itemList: dom.find('.rng-module-documentHistory-itemsList'),\r
-    };\r
-    var itemViews = [];\r
-    \r
-    \r
-    dom.find('.btn.compare').click(function(e) {\r
-        var selected = historyItems.getSelected();\r
-        sandbox.publish('compare', selected[0], selected[1]);\r
-    });\r
-    \r
-    dom.find('.btn.restore').click(function(e) {\r
-        var dialog = restoreDialog.create();\r
-        dialog.on('restore', function(event) {\r
-            sandbox.publish('restoreVersion', {version: historyItems.getSelected()[0], description: event.data.description});\r
-            event.success();\r
-        });\r
-        dialog.show();\r
-    });\r
-    \r
-    dom.find('.btn.display').click(function(e) {\r
-        sandbox.publish('displayVersion', {version: historyItems.getSelected()[0]});\r
-    });\r
-        \r
-    var addHistoryItem = function(item, options) {\r
-        historyItems.add(item);\r
-        var view = new itemView(item);\r
-        itemViews.push(view);\r
-        domNodes.itemList.prepend(view.dom);\r
-        if(options.animate) {\r
-            view.dom.hide().slideDown();\r
-        }\r
-    };\r
-    \r
-    var toggleItemViews = function(toggle) {\r
-        itemViews.forEach(function(view) {\r
-            if(!historyItems.isSelected(view.item))\r
-                view.toggle(toggle);\r
-        });\r
-    };\r
-    \r
-    var toggleButton = function(btn, toggle) {\r
-        dom.find('button.'+btn).toggleClass('disabled', !toggle);\r
-    };\r
-    \r
-    var historyItems = {\r
-        _itemsById: {},\r
-        _selected: [],\r
-        select: function(item) {\r
-            if(this._selected.length < 2) {\r
-                this._selected.push(item.version);\r
-                this._updateUI();\r
-                return true;\r
-            }\r
-            return false;\r
-        },\r
-        unselect: function(item) {\r
-            this._selected = _.without(this._selected, item.version);\r
-            this._updateUI();\r
-        },\r
-        add: function(item) {\r
-            this._itemsById[item.version] = item;\r
-        },\r
-        isSelected: function(item) {\r
-            return _.contains(this._selected, item.version);\r
-        },\r
-        getSelected: function() {\r
-            return this._selected;\r
-        },\r
-        _updateUI: function() {\r
-            var len = this._selected.length;\r
-            if(len === 0) {\r
-                toggleButton('compare', false);\r
-                toggleButton('display', false);\r
-                toggleButton('restore', false);\r
-            }\r
-            if(len === 1) {\r
-                toggleButton('compare', false);\r
-                toggleButton('display', true);\r
-                toggleButton('restore', true);\r
-            }\r
-            if(len === 2) {\r
-                toggleItemViews(false);\r
-                toggleButton('compare', true);\r
-                toggleButton('display', false);\r
-                toggleButton('restore', false);\r
-            } else {\r
-                toggleItemViews(true);\r
-            }\r
-        }\r
-    };\r
-    historyItems._updateUI();\r
-    \r
-    var itemView = function(item) {\r
-        this.item = item;\r
-        this.dom = $(this.template(item));\r
-        this.dom.on('click', _.bind(this.onItemClicked, this));\r
-    };\r
-    itemView.prototype.template = _.template(itemTemplateSrc);\r
-    itemView.prototype.onItemClicked = function() {\r
-        if(historyItems.isSelected(this.item)) {\r
-            historyItems.unselect(this.item);\r
-            this.dimItem();\r
-        } else if(historyItems.select(this.item)) {\r
-            this.highlightItem();\r
-        }            \r
-    };\r
-    itemView.prototype.highlightItem = function() {\r
-        this.dom.addClass('highlighted');\r
-    };\r
-    itemView.prototype.dimItem = function() {\r
-        this.dom.removeClass('highlighted');\r
-    };\r
-    itemView.prototype.toggle = function(toggle) {\r
-        this.dom.toggleClass('disabled', !toggle);\r
-    };\r
-\r
-    \r
-    \r
-    return {\r
+define([
+'libs/jquery-1.9.1.min',
+'libs/underscore-min',
+'./restoreDialog',
+'libs/text!./templates/main.html',
+'libs/text!./templates/item.html'
+], function($, _, restoreDialog, mainTemplateSrc, itemTemplateSrc) {
+
+'use strict';
+    
+return function(sandbox) {
+    
+    var dom = $(_.template(mainTemplateSrc)());
+    var domNodes = {
+        itemList: dom.find('.rng-module-documentHistory-itemsList'),
+    };
+    var itemViews = [];
+    
+    
+    dom.find('.btn.compare').click(function(e) {
+        var selected = historyItems.getSelected();
+        sandbox.publish('compare', selected[0], selected[1]);
+    });
+    
+    dom.find('.btn.restore').click(function(e) {
+        var dialog = restoreDialog.create();
+        dialog.on('restore', function(event) {
+            sandbox.publish('restoreVersion', {version: historyItems.getSelected()[0], description: event.data.description});
+            event.success();
+        });
+        dialog.show();
+    });
+    
+    dom.find('.btn.display').click(function(e) {
+        sandbox.publish('displayVersion', {version: historyItems.getSelected()[0]});
+    });
+        
+    var addHistoryItem = function(item, options) {
+        historyItems.add(item);
+        var view = new itemView(item);
+        itemViews.push(view);
+        domNodes.itemList.prepend(view.dom);
+        if(options.animate) {
+            view.dom.hide().slideDown();
+        }
+    };
+    
+    var toggleItemViews = function(toggle) {
+        itemViews.forEach(function(view) {
+            if(!historyItems.isSelected(view.item))
+                view.toggle(toggle);
+        });
+    };
+    
+    var toggleButton = function(btn, toggle) {
+        dom.find('button.'+btn).toggleClass('disabled', !toggle);
+    };
+    
+    var historyItems = {
+        _itemsById: {},
+        _selected: [],
+        select: function(item) {
+            if(this._selected.length < 2) {
+                this._selected.push(item.version);
+                this._updateUI();
+                return true;
+            }
+            return false;
+        },
+        unselect: function(item) {
+            this._selected = _.without(this._selected, item.version);
+            this._updateUI();
+        },
+        add: function(item) {
+            this._itemsById[item.version] = item;
+        },
+        isSelected: function(item) {
+            return _.contains(this._selected, item.version);
+        },
+        getSelected: function() {
+            return this._selected;
+        },
+        _updateUI: function() {
+            var len = this._selected.length;
+            if(len === 0) {
+                toggleButton('compare', false);
+                toggleButton('display', false);
+                toggleButton('restore', false);
+            }
+            if(len === 1) {
+                toggleButton('compare', false);
+                toggleButton('display', true);
+                toggleButton('restore', true);
+            }
+            if(len === 2) {
+                toggleItemViews(false);
+                toggleButton('compare', true);
+                toggleButton('display', false);
+                toggleButton('restore', false);
+            } else {
+                toggleItemViews(true);
+            }
+        }
+    };
+    historyItems._updateUI();
+    
+    var itemView = function(item) {
+        this.item = item;
+        this.dom = $(this.template(item));
+        this.dom.on('click', _.bind(this.onItemClicked, this));
+    };
+    itemView.prototype.template = _.template(itemTemplateSrc);
+    itemView.prototype.onItemClicked = function() {
+        if(historyItems.isSelected(this.item)) {
+            historyItems.unselect(this.item);
+            this.dimItem();
+        } else if(historyItems.select(this.item)) {
+            this.highlightItem();
+        }            
+    };
+    itemView.prototype.highlightItem = function() {
+        this.dom.addClass('highlighted');
+    };
+    itemView.prototype.dimItem = function() {
+        this.dom.removeClass('highlighted');
+    };
+    itemView.prototype.toggle = function(toggle) {
+        this.dom.toggleClass('disabled', !toggle);
+    };
+
+    
+    
+    return {
         start: function() { sandbox.publish('ready'); },
         start: function() { sandbox.publish('ready'); },
-        addHistory: function(history, options) {\r
-            history.forEach(function(historyItem) {\r
-                addHistoryItem(historyItem, options || {});\r
-            });\r
-        },\r
-        getView: function() {\r
-            return dom;\r
-        }\r
-    };\r
-};\r
-\r
+        addHistory: function(history, options) {
+            history.forEach(function(historyItem) {
+                addHistoryItem(historyItem, options || {});
+            });
+        },
+        getView: function() {
+            return dom;
+        }
+    };
+};
+
 });
\ No newline at end of file
 });
\ No newline at end of file
index 592b22a..608c9df 100644 (file)
@@ -1,62 +1,62 @@
-.rng-module-documentHistory {\r
-    \r
-    .item {\r
-        padding: 5px 5px;\r
-        margin: 0 0 15px 0;\r
-        cursor: pointer;\r
-        \r
-        .version {\r
-            float: left;\r
-            width: 30px;\r
-            font-weight: bold;\r
-        }\r
-        \r
-        .date, .author, .description {\r
-            margin: 5px 10px 0 40px;\r
-        }\r
-        \r
-        .description {\r
-            font-size: .9em;\r
-        }\r
-    }\r
-    \r
-    .item.highlighted {\r
-        background: #ffec63;\r
-    }\r
-    \r
-    .item.disabled {\r
-        cursor: default;\r
-    }\r
-    \r
-    .toolbar {\r
-        margin: 0 0 15px 0;\r
-        white-space:nowrap; \r
-        word-spacing:0;\r
-        min-height: 22px;\r
-        button {\r
-            margin-right: 10px;\r
-        }\r
-    }\r
-    \r
-    .rng-module-documentHistory-itemsList {\r
-        overflow-y: scroll;\r
-        position: absolute;\r
-        top: 30px;\r
-        bottom: 0;\r
-        left: 0;\r
-        right: 0;\r
-        &::-webkit-scrollbar {\r
-            .rng-mixin-scrollbar;\r
-        }\r
-        &::-webkit-scrollbar-track {\r
-            .rng-mixin-scrollbar-track;\r
-        }\r
-        &::-webkit-scrollbar-thumb {\r
-            .rng-mixin-scrollbar-thumb;\r
-        }\r
-        &::-webkit-scrollbar-thumb:window-inactive {\r
-            .rng-mixin-scrollbar-thumb-window-inactive;\r
-        }\r
-    }\r
-}\r
-\r
+.rng-module-documentHistory {
+    
+    .item {
+        padding: 5px 5px;
+        margin: 0 0 15px 0;
+        cursor: pointer;
+        
+        .version {
+            float: left;
+            width: 30px;
+            font-weight: bold;
+        }
+        
+        .date, .author, .description {
+            margin: 5px 10px 0 40px;
+        }
+        
+        .description {
+            font-size: .9em;
+        }
+    }
+    
+    .item.highlighted {
+        background: #ffec63;
+    }
+    
+    .item.disabled {
+        cursor: default;
+    }
+    
+    .toolbar {
+        margin: 0 0 15px 0;
+        white-space:nowrap; 
+        word-spacing:0;
+        min-height: 22px;
+        button {
+            margin-right: 10px;
+        }
+    }
+    
+    .rng-module-documentHistory-itemsList {
+        overflow-y: scroll;
+        position: absolute;
+        top: 30px;
+        bottom: 0;
+        left: 0;
+        right: 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;
+        }
+    }
+}
+
index 97ea2af..a9de353 100644 (file)
@@ -1,55 +1,55 @@
-define([\r
-'libs/text!./templates/restoreDialog.html',\r
-'libs/underscore-min',\r
-'libs/backbone-min',\r
-'libs/jquery-1.9.1.min'\r
-], function(restoreDialogTemplate, _, Backbone, $) {\r
-\r
-    var DialogView = Backbone.View.extend({\r
-        template: _.template(restoreDialogTemplate),\r
-        events: {\r
-            'click .restore-btn': 'onSave',\r
-            'click .cancel-btn': 'close',\r
-            'click .close': 'close'\r
-        },\r
-        initialize: function() {\r
-            _.bindAll(this);\r
-            this.actionsDisabled = false;\r
-        },\r
-        show: function() {           \r
-            this.setElement(this.template());\r
-            this.$el.modal({backdrop: 'static'});\r
-            this.$el.modal('show');\r
-            this.$('textarea').focus();\r
-        },\r
-        onSave: function(e) {\r
-            e.preventDefault();\r
-            var view = this;\r
-            this.trigger('restore', {\r
-                data: {description: view.$el.find('textarea').val()},\r
-                success: function() { view.actionsDisabled = false; view.close(); },\r
-                error: function() { view.actionsDisabled = false; view.close(); },\r
-            });\r
-        },\r
-        close: function(e) {\r
-            if(e)\r
-                e.preventDefault();\r
-            if(!this.actionsDisabled) {\r
-                this.$el.modal('hide');\r
-                this.$el.remove();\r
-            }\r
-        },\r
-        toggleButtons: function(toggle) {\r
-            this.$('.btn, button').toggleClass('disabled', !toggle);\r
-            this.$('textarea').attr('disabled', !toggle);\r
-            this.actionsDisabled = !toggle;\r
-        }\r
-    });\r
-\r
-    return {\r
-        create: function() {\r
-            return new DialogView();\r
-        }\r
-    };\r
-\r
+define([
+'libs/text!./templates/restoreDialog.html',
+'libs/underscore-min',
+'libs/backbone-min',
+'libs/jquery-1.9.1.min'
+], function(restoreDialogTemplate, _, Backbone, $) {
+
+    var DialogView = Backbone.View.extend({
+        template: _.template(restoreDialogTemplate),
+        events: {
+            'click .restore-btn': 'onSave',
+            'click .cancel-btn': 'close',
+            'click .close': 'close'
+        },
+        initialize: function() {
+            _.bindAll(this);
+            this.actionsDisabled = false;
+        },
+        show: function() {           
+            this.setElement(this.template());
+            this.$el.modal({backdrop: 'static'});
+            this.$el.modal('show');
+            this.$('textarea').focus();
+        },
+        onSave: function(e) {
+            e.preventDefault();
+            var view = this;
+            this.trigger('restore', {
+                data: {description: view.$el.find('textarea').val()},
+                success: function() { view.actionsDisabled = false; view.close(); },
+                error: function() { view.actionsDisabled = false; view.close(); },
+            });
+        },
+        close: function(e) {
+            if(e)
+                e.preventDefault();
+            if(!this.actionsDisabled) {
+                this.$el.modal('hide');
+                this.$el.remove();
+            }
+        },
+        toggleButtons: function(toggle) {
+            this.$('.btn, button').toggleClass('disabled', !toggle);
+            this.$('textarea').attr('disabled', !toggle);
+            this.actionsDisabled = !toggle;
+        }
+    });
+
+    return {
+        create: function() {
+            return new DialogView();
+        }
+    };
+
 });
\ No newline at end of file
 });
\ No newline at end of file
index f3afb3d..1629226 100644 (file)
@@ -1,6 +1,6 @@
-<div class="item">\r
-    <div class="version"><%= version %></div>\r
-    <div class="date"><%= date %></div>\r
-    <div class="author"><%= author %></div>\r
-    <div class="description"><%= description %></div>\r
+<div class="item">
+    <div class="version"><%= version %></div>
+    <div class="date"><%= date %></div>
+    <div class="author"><%= author %></div>
+    <div class="description"><%= description %></div>
 </div>
\ No newline at end of file
 </div>
\ No newline at end of file
index 0e581f6..83cd627 100644 (file)
@@ -1,11 +1,11 @@
-<div class="rng-module-documentHistory">\r
-    <div class="toolbar">\r
-        <div class="group">\r
-            <button class="btn btn-mini compare">Porównaj</button>\r
-            <button class="btn btn-mini restore">Przywróć</button>\r
-            <button class="btn btn-mini display">Zobacz</button>\r
-        </div>\r
-    </div>\r
-    <div style="clear:both;"></div>\r
-    <div class="rng-module-documentHistory-itemsList"></div>\r
+<div class="rng-module-documentHistory">
+    <div class="toolbar">
+        <div class="group">
+            <button class="btn btn-mini compare">Porównaj</button>
+            <button class="btn btn-mini restore">Przywróć</button>
+            <button class="btn btn-mini display">Zobacz</button>
+        </div>
+    </div>
+    <div style="clear:both;"></div>
+    <div class="rng-module-documentHistory-itemsList"></div>
 <div>
\ No newline at end of file
 <div>
\ No newline at end of file
index 72fea22..ded0a11 100644 (file)
@@ -1,14 +1,14 @@
-<div class="rng-module-data-saveDialog modal hide static">\r
-    <div class="modal-header">\r
-        <button type="button" class="close">&times;</button>\r
-        <h1>Przywróć wersję</h1>\r
-    </div>\r
-    <div class="modal-body">\r
-        <label>Opisz powód przywrócenia</label>\r
-        <textarea rows="5"></textarea>\r
-    </div>\r
-    <div class="modal-footer">\r
-        <a href="#" class="btn btn-info btn-mini restore-btn">Przywróć</a>\r
-        <a href="#" class="btn btn-danger btn-mini cancel-btn">Anuluj</a>\r
-    </div>\r
+<div class="rng-module-data-saveDialog modal hide static">
+    <div class="modal-header">
+        <button type="button" class="close">&times;</button>
+        <h1>Przywróć wersję</h1>
+    </div>
+    <div class="modal-body">
+        <label>Opisz powód przywrócenia</label>
+        <textarea rows="5"></textarea>
+    </div>
+    <div class="modal-footer">
+        <a href="#" class="btn btn-info btn-mini restore-btn">Przywróć</a>
+        <a href="#" class="btn btn-danger btn-mini cancel-btn">Anuluj</a>
+    </div>
 </div>
\ No newline at end of file
 </div>
\ No newline at end of file
index a6dd0be..2d963d2 100644 (file)
@@ -1,57 +1,57 @@
-define(['libs/jquery-1.9.1.min', 'libs/underscore-min', 'libs/text!./template.html'], function($, _, template) {\r
-\r
-'use strict';\r
-\r
-return function(sandbox) {\r
-    \r
-    var view = {\r
-        node: $(_.template(template)()),\r
-        setup: function() {\r
-            var view = this;\r
-            \r
-            this.node.find('button').click(function(e) {\r
-                e.stopPropagation();\r
-                var btn = $(e.currentTarget);\r
-                if(btn.attr('data-btn-type') === 'toggle') {\r
-                    btn.toggleClass('active');\r
-                    var event;\r
-                    var btnId = btn.attr('data-btn');\r
-                    if(btnId === 'grid')\r
-                        event = 'toggleGrid';\r
-                    if(btnId === 'tags')\r
-                        event = 'toggleTags';\r
-                    sandbox.publish(event, btn.hasClass('active'));\r
-                }\r
-                if(btn.attr('data-btn-type') === 'cmd') {\r
-                    var command = btn.attr('data-btn');\r
-                    var meta = btn.attr('data-meta');\r
-                    if(command === 'new-node') {\r
-                        var wlxmlTag = view.getOption('newTag-tag');\r
-                        var wlxmlClass = view.getOption('newTag-class');\r
-                        if(meta) {\r
-                            var split = meta.split('/');\r
-                            wlxmlTag = split[0];\r
-                            wlxmlClass = split[1];\r
-                        }\r
-                        sandbox.publish('newNodeRequested', wlxmlTag, wlxmlClass);\r
-                    } else {\r
-                        sandbox.publish('command', btn.attr('data-btn'), btn.attr('data-meta'));\r
-                    }\r
-                }\r
-            });\r
-        },\r
-        getOption: function(option) {\r
-            return this.node.find('.rng-module-documentToolbar-toolbarOption[data-option=' + option +']').val();\r
-        }\r
-    };\r
-    \r
-    view.setup();\r
-\r
-    return {\r
-        start: function() { sandbox.publish('ready'); },\r
-        getView: function() { return view.node; },\r
-        getOption: function(option) { return view.getOption(option); }\r
-    };\r
-};\r
-\r
+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
 });
\ No newline at end of file
index 6189f32..91d45c9 100644 (file)
@@ -1,28 +1,28 @@
-.rng-module-documentToolbar {\r
-    margin: 0 0 10px 0;\r
-    white-space:nowrap; \r
-    word-spacing:0;\r
-    \r
-    select {\r
-        line-height: 14px;\r
-        font-size:9px;\r
-        height: auto;\r
-        width: 50px;\r
-        padding: 1px;\r
-    -webkit-appearance: button;\r
-    -moz-appearance: button;\r
-    appearance: button;\r
-        margin-bottom: 0;\r
-    }\r
-\r
-    .rng-module-documentToolbar-toolbarGroup {\r
-        border-width: 0 1px 0 0;\r
-        border-style: solid;\r
-        border-color: #ddd;\r
-        padding: 0 8px 0 0;\r
-        margin: 0 8px 0 0;\r
-        float:left;\r
-    }\r
-    \r
-}\r
-\r
+.rng-module-documentToolbar {
+    margin: 0 0 10px 0;
+    white-space:nowrap; 
+    word-spacing:0;
+    
+    select {
+        line-height: 14px;
+        font-size:9px;
+        height: auto;
+        width: 50px;
+        padding: 1px;
+    -webkit-appearance: button;
+    -moz-appearance: button;
+    appearance: button;
+        margin-bottom: 0;
+    }
+
+    .rng-module-documentToolbar-toolbarGroup {
+        border-width: 0 1px 0 0;
+        border-style: solid;
+        border-color: #ddd;
+        padding: 0 8px 0 0;
+        margin: 0 8px 0 0;
+        float:left;
+    }
+    
+}
+
index f10459f..31ecbf6 100644 (file)
@@ -1,30 +1,30 @@
-<div class="rng-module-documentToolbar">\r
-    <div class="rng-module-documentToolbar-toolbarGroup">\r
-        <button data-btn="new-node" data-meta="header/" data-btn-type="cmd" class="btn btn-mini">header</button>\r
-        <button data-btn="new-node" data-meta="div/p" data-btn-type="cmd" class="btn btn-mini">div/p</button>\r
-        <button data-btn="new-node" data-meta="span/cite" data-btn-type="cmd" class="btn btn-mini">span/cite</i></button>\r
-        <button data-btn="new-node" data-meta="span/uri" data-btn-type="cmd" class="btn btn-mini">span/uri</i></button>\r
-        <select class="rng-module-documentToolbar-toolbarOption" data-option="newTag-tag">\r
-            <% var options = ['', 'section', 'header', 'div', 'span', 'aside']; %>\r
-            <% options.forEach(function(option) { %>\r
-                <option value="<%= option %>" <% if(option==='span') { %>selected<% } %>><%= option %></option>\r
-            <% }); %>\r
-        </select>\r
-        <select class="rng-module-documentToolbar-toolbarOption" data-option="newTag-class">\r
-            <% var options = ['', 'author', 'title', 'cite', 'cite.code', 'cite.code.xml', 'list', 'list.items', 'item', 'uri', 'p', 'footnote', 'todo', 'emp', 'emph.tech'] %>\r
-            <% options.forEach(function(option) { %>\r
-                <option value="<%= option.replace(/\./g, '-') %>" <% if(option==='cite') { %>selected<% } %>><%= option %></option>\r
-            <% }); %>\r
-        </select>\r
-        <button data-btn="new-node" data-btn-type="cmd" class="btn btn-mini"><i class="icon-plus"></i></button>\r
-    </div>\r
-    <div class="rng-module-documentToolbar-toolbarGroup">\r
-        <button data-btn="grid" data-btn-type="toggle" class="btn btn-mini"><i class="icon-th-large"></i></button>\r
-        <button data-btn="tags" data-btn-type="toggle" class="btn btn-mini"><i class="icon-tag"></i></button>\r
-    </div>\r
-    <div class="rng-module-documentToolbar-toolbarGroup">\r
-        <button data-btn="createList" data-btn-type="cmd" data-meta="bullets" class="btn btn-mini"><i class="icon-list"></i></button>\r
-        <button data-btn="createList" data-btn-type="cmd" data-meta="enum" class="btn btn-mini"><i class="icon-th-list"></i></button>\r
-    </div>\r
-    <div style="clear: both;"></div>\r
+<div class="rng-module-documentToolbar">
+    <div class="rng-module-documentToolbar-toolbarGroup">
+        <button data-btn="new-node" data-meta="header/" data-btn-type="cmd" class="btn btn-mini">header</button>
+        <button data-btn="new-node" data-meta="div/p" data-btn-type="cmd" class="btn btn-mini">div/p</button>
+        <button data-btn="new-node" data-meta="span/cite" data-btn-type="cmd" class="btn btn-mini">span/cite</i></button>
+        <button data-btn="new-node" data-meta="span/uri" data-btn-type="cmd" class="btn btn-mini">span/uri</i></button>
+        <select class="rng-module-documentToolbar-toolbarOption" data-option="newTag-tag">
+            <% var options = ['', 'section', 'header', 'div', 'span', 'aside']; %>
+            <% options.forEach(function(option) { %>
+                <option value="<%= option %>" <% if(option==='span') { %>selected<% } %>><%= option %></option>
+            <% }); %>
+        </select>
+        <select class="rng-module-documentToolbar-toolbarOption" data-option="newTag-class">
+            <% var options = ['', 'author', 'title', 'cite', 'cite.code', 'cite.code.xml', 'list', 'list.items', 'item', 'uri', 'p', 'footnote', 'todo', 'emp', 'emph.tech'] %>
+            <% options.forEach(function(option) { %>
+                <option value="<%= option.replace(/\./g, '-') %>" <% if(option==='cite') { %>selected<% } %>><%= option %></option>
+            <% }); %>
+        </select>
+        <button data-btn="new-node" data-btn-type="cmd" class="btn btn-mini"><i class="icon-plus"></i></button>
+    </div>
+    <div class="rng-module-documentToolbar-toolbarGroup">
+        <button data-btn="grid" data-btn-type="toggle" class="btn btn-mini"><i class="icon-th-large"></i></button>
+        <button data-btn="tags" data-btn-type="toggle" class="btn btn-mini"><i class="icon-tag"></i></button>
+    </div>
+    <div class="rng-module-documentToolbar-toolbarGroup">
+        <button data-btn="createList" data-btn-type="cmd" data-meta="bullets" class="btn btn-mini"><i class="icon-list"></i></button>
+        <button data-btn="createList" data-btn-type="cmd" data-meta="enum" class="btn btn-mini"><i class="icon-th-list"></i></button>
+    </div>
+    <div style="clear: both;"></div>
 </div>
\ No newline at end of file
 </div>
\ No newline at end of file
index 007dcff..d98fe04 100644 (file)
@@ -1,35 +1,35 @@
-define([\r
-'libs/jquery-1.9.1.min',\r
-'libs/underscore-min',\r
-'libs/text!./template.html'\r
-], function($, _, template) {\r
-\r
-'use strict';\r
-\r
-return function(sandbox) {\r
-\r
-    var view = {\r
-        dom: $(_.template(template)()),\r
-        setup: function() {\r
-        \r
-        }\r
-    };\r
-\r
-    return {\r
-        start: function() { sandbox.publish('ready'); },\r
-        getView: function() { return view.dom; },\r
-        showMessage: function(msg) {\r
-            view.dom.html('<span>' + msg + '</span>').show();\r
-        },\r
-        clearMessage: function(report) {\r
-            view.dom.empty();\r
-            if(report && report.message) {\r
-                view.dom.html('<span class="success">' + report.message + '</span>').show().fadeOut(4000);\r
-            }\r
-        }\r
-        \r
-    };\r
-\r
-};\r
-\r
-});\r
+define([
+'libs/jquery-1.9.1.min',
+'libs/underscore-min',
+'libs/text!./template.html'
+], function($, _, template) {
+
+'use strict';
+
+return function(sandbox) {
+
+    var view = {
+        dom: $(_.template(template)()),
+        setup: function() {
+        
+        }
+    };
+
+    return {
+        start: function() { sandbox.publish('ready'); },
+        getView: function() { return view.dom; },
+        showMessage: function(msg) {
+            view.dom.html('<span>' + msg + '</span>').show();
+        },
+        clearMessage: function(report) {
+            view.dom.empty();
+            if(report && report.message) {
+                view.dom.html('<span class="success">' + report.message + '</span>').show().fadeOut(4000);
+            }
+        }
+        
+    };
+
+};
+
+});
index 909cede..48f6e3b 100644 (file)
@@ -1,14 +1,14 @@
-.rng-module-indicator {\r
-     span {\r
-        font-weight: bold;\r
-        background: #f9edbe;\r
-        padding: 2px 5px;\r
-        border: solid 1px #f6e39c;\r
-        font-size:12px;\r
-    }\r
-    \r
-    span.success {\r
-        background: #cef9be;\r
-        border-color: darken(#cef9be, 10%);\r
-    }\r
+.rng-module-indicator {
+     span {
+        font-weight: bold;
+        background: #f9edbe;
+        padding: 2px 5px;
+        border: solid 1px #f6e39c;
+        font-size:12px;
+    }
+    
+    span.success {
+        background: #cef9be;
+        border-color: darken(#cef9be, 10%);
+    }
 }
\ No newline at end of file
 }
\ No newline at end of file
index 48933d9..e4e449b 100644 (file)
@@ -1,3 +1,3 @@
-<div class="rng-module-indicator">\r
-\r
+<div class="rng-module-indicator">
+
 </div>
\ No newline at end of file
 </div>
\ No newline at end of file
index 6966e4a..85551fc 100644 (file)
@@ -1,29 +1,29 @@
-define([\r
-'libs/jquery-1.9.1.min',\r
-'libs/underscore-min',\r
-'libs/text!./template.html'], function($, _, template) {\r
-\r
-'use strict';\r
-\r
-return function(sandbox) {\r
-\r
-    var view = $(_.template(template)());\r
-    view.find('button').click(function(e) {\r
-        e.preventDefault();\r
-        sandbox.publish('cmd.' + $(e.target).attr('data-cmd'));\r
-    });\r
-\r
-    return {\r
-        start: function() { sandbox.publish('ready'); },\r
-        getView: function() {return view;},\r
-        setCommandEnabled: function(cmd, enabled) {\r
-            view.find('[data-cmd='+cmd+']').toggleClass('disabled', !enabled);\r
-        },\r
-        setVersion: function(version) {\r
-            view.find('.version').text(version);\r
-        }\r
-    };\r
-\r
-};\r
-\r
+define([
+'libs/jquery-1.9.1.min',
+'libs/underscore-min',
+'libs/text!./template.html'], function($, _, template) {
+
+'use strict';
+
+return function(sandbox) {
+
+    var view = $(_.template(template)());
+    view.find('button').click(function(e) {
+        e.preventDefault();
+        sandbox.publish('cmd.' + $(e.target).attr('data-cmd'));
+    });
+
+    return {
+        start: function() { sandbox.publish('ready'); },
+        getView: function() {return view;},
+        setCommandEnabled: function(cmd, enabled) {
+            view.find('[data-cmd='+cmd+']').toggleClass('disabled', !enabled);
+        },
+        setVersion: function(version) {
+            view.find('.version').text(version);
+        }
+    };
+
+};
+
 });
\ No newline at end of file
 });
\ No newline at end of file
index 327fa56..0e2a899 100644 (file)
@@ -1,21 +1,21 @@
-/*#rng-skelton-menu {\r
-    float: right;\r
-}*/\r
-\r
-.rng-module-mainBar {\r
-\r
-    font-size: 10px;\r
-\r
-    li {\r
-        display: inline;\r
-        border-width: 0 1px 0 0;\r
-        border-color: #ddd;\r
-        border-style: solid;\r
-        margin: 0 5px 0 0;\r
-        padding: 0 5px 0 0;\r
-    }\r
-\r
-    ul {\r
-        list-style-type: none;\r
-    }\r
+/*#rng-skelton-menu {
+    float: right;
+}*/
+
+.rng-module-mainBar {
+
+    font-size: 10px;
+
+    li {
+        display: inline;
+        border-width: 0 1px 0 0;
+        border-color: #ddd;
+        border-style: solid;
+        margin: 0 5px 0 0;
+        padding: 0 5px 0 0;
+    }
+
+    ul {
+        list-style-type: none;
+    }
 }
\ No newline at end of file
 }
\ No newline at end of file
index f8d4641..3c43ee6 100644 (file)
@@ -1,7 +1,7 @@
-<div class="rng-module-mainBar">\r
-    <ul>\r
-        <li>wersja: <span class="version"></span></li>\r
-        <li><button class="btn btn-mini btn-info" data-cmd="save">Zapisz</button></li>\r
-        <li><a class="btn btn-mini btn-danger" href="/">Wyjdź</a></li>\r
-    </ul>\r
+<div class="rng-module-mainBar">
+    <ul>
+        <li>wersja: <span class="version"></span></li>
+        <li><button class="btn btn-mini btn-info" data-cmd="save">Zapisz</button></li>
+        <li><a class="btn btn-mini btn-danger" href="/">Wyjdź</a></li>
+    </ul>
 </div>
\ No newline at end of file
 </div>
\ No newline at end of file
index 12578ba..63b2404 100644 (file)
-define([\r
-'libs/jquery-1.9.1.min',\r
-'libs/underscore-min',\r
-'./transformations',\r
-'libs/text!./templates/main.html',\r
-'libs/text!./templates/item.html'\r
-], function($, _, transformations, mainTemplate, itemTemplate) {\r
-\r
-'use strict';\r
-\r
-return function(sandbox) {\r
-\r
-    \r
-    var view = {\r
-        node: $(_.template(mainTemplate)()),\r
-        setup: function() {\r
-            var view = this;\r
-            var metaTable = this.metaTable = this.node.find('table');\r
-            \r
-            this.node.find('.rng-module-metadataEditor-addBtn').click(function() {\r
-                var newRow = view._addMetaRow('', '');\r
-                $(newRow.find('td div')[0]).focus();\r
-                sandbox.publish('metadataChanged', view.getMetadata());\r
-            });\r
-            \r
-            this.metaTable.on('click', '.rng-visualEditor-metaRemoveBtn', function(e) {\r
-                $(e.target).closest('tr').remove();\r
-                sandbox.publish('metadataChanged', view.getMetadata());\r
-            });\r
-            \r
-            this.metaTable.on('keydown', '[contenteditable]', function(e) {\r
-                console.log(e.which);\r
-                if(e.which === 13) { \r
-                    if($(document.activeElement).hasClass('rng-module-metadataEditor-metaItemKey')) {\r
-                        metaTable.find('.rng-module-metadataEditor-metaItemValue').focus();\r
-                    } else {\r
-                        var input = $('<input>');\r
-                        input.appendTo('body').focus();\r
-                        view.node.find('.rng-module-metadataEditor-addBtn').focus();\r
-                        input.remove();\r
-                    }\r
-                    e.preventDefault();\r
-                }\r
-            });\r
-            \r
-            \r
-            var onKeyUp = function(e) {\r
-                if(e.which !== 13)\r
-                    sandbox.publish('metadataChanged', view.getMetadata());\r
-            };\r
-            this.metaTable.on('keyup', '[contenteditable]', _.throttle(onKeyUp, 500));\r
-        },\r
-        getMetadata: function() {\r
-            var toret = {};\r
-            this.node.find('tr').each(function() {\r
-                var tr = $(this);\r
-                var inputs = $(this).find('td [contenteditable]');\r
-                var key = $(inputs[0]).text();\r
-                var value = $(inputs[1]).text();\r
-                toret[key] = value;\r
-            });\r
-            return toret;\r
-        },\r
-        setMetadata: function(metadata) {\r
-            var view = this;\r
-            this.metaTable.find('tr').remove();\r
-            _.each(_.keys(metadata), function(key) {    \r
-                view._addMetaRow(key, metadata[key]);\r
-            });\r
-        },\r
-        _addMetaRow: function(key, value) {\r
-            var newRow = $(_.template(itemTemplate)({key: key || '', value: value || ''}));\r
-            newRow.appendTo(this.metaTable);\r
-            return newRow;\r
-        }\r
-    };\r
-    \r
-    view.setup();\r
-    \r
-    return {\r
-        start: function() {\r
-            sandbox.publish('ready');\r
-        },\r
-        setDocument: function(xml) {\r
-            view.setMetadata(transformations.getMetadata(xml));\r
-            sandbox.publish('metadataSet');\r
-        },\r
-        getMetadata: function() {\r
-            return transformations.getXML(view.getMetadata());\r
-        },\r
-        getView: function() {\r
-            return view.node;\r
-        },\r
-        attachMetadata: function(document) {\r
-            var toret = $('<div>');\r
-            toret.append($(document));\r
-            var meta = $('<metadata></metadata>\n').append(transformations.getXML(view.getMetadata()));\r
-            \r
-            var metadata = toret.find('metadata');\r
-            if(metadata.length === 0) {\r
-                var section = toret.find('section');\r
-                section = section.length ? $(section[0]) : null;\r
-                if(section) {\r
-                    section.prepend(meta);\r
-                }\r
-            } else {\r
-                metadata.replaceWith(meta);\r
-            }\r
-            return toret.html();\r
-        }\r
-        \r
-    };\r
-};\r
-\r
+define([
+'libs/jquery-1.9.1.min',
+'libs/underscore-min',
+'./transformations',
+'libs/text!./templates/main.html',
+'libs/text!./templates/item.html'
+], function($, _, transformations, mainTemplate, itemTemplate) {
+
+'use strict';
+
+return function(sandbox) {
+
+    
+    var view = {
+        node: $(_.template(mainTemplate)()),
+        setup: function() {
+            var view = this;
+            var metaTable = this.metaTable = this.node.find('table');
+            
+            this.node.find('.rng-module-metadataEditor-addBtn').click(function() {
+                var newRow = view._addMetaRow('', '');
+                $(newRow.find('td div')[0]).focus();
+                sandbox.publish('metadataChanged', view.getMetadata());
+            });
+            
+            this.metaTable.on('click', '.rng-visualEditor-metaRemoveBtn', function(e) {
+                $(e.target).closest('tr').remove();
+                sandbox.publish('metadataChanged', view.getMetadata());
+            });
+            
+            this.metaTable.on('keydown', '[contenteditable]', function(e) {
+                console.log(e.which);
+                if(e.which === 13) { 
+                    if($(document.activeElement).hasClass('rng-module-metadataEditor-metaItemKey')) {
+                        metaTable.find('.rng-module-metadataEditor-metaItemValue').focus();
+                    } else {
+                        var input = $('<input>');
+                        input.appendTo('body').focus();
+                        view.node.find('.rng-module-metadataEditor-addBtn').focus();
+                        input.remove();
+                    }
+                    e.preventDefault();
+                }
+            });
+            
+            
+            var onKeyUp = function(e) {
+                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();
+                toret[key] = value;
+            });
+            return toret;
+        },
+        setMetadata: function(metadata) {
+            var view = this;
+            this.metaTable.find('tr').remove();
+            _.each(_.keys(metadata), function(key) {    
+                view._addMetaRow(key, metadata[key]);
+            });
+        },
+        _addMetaRow: function(key, value) {
+            var newRow = $(_.template(itemTemplate)({key: key || '', value: value || ''}));
+            newRow.appendTo(this.metaTable);
+            return newRow;
+        }
+    };
+    
+    view.setup();
+    
+    return {
+        start: function() {
+            sandbox.publish('ready');
+        },
+        setDocument: function(xml) {
+            view.setMetadata(transformations.getMetadata(xml));
+            sandbox.publish('metadataSet');
+        },
+        getMetadata: function() {
+            return transformations.getXML(view.getMetadata());
+        },
+        getView: function() {
+            return view.node;
+        },
+        attachMetadata: function(document) {
+            var toret = $('<div>');
+            toret.append($(document));
+            var meta = $('<metadata></metadata>\n').append(transformations.getXML(view.getMetadata()));
+            
+            var metadata = toret.find('metadata');
+            if(metadata.length === 0) {
+                var section = toret.find('section');
+                section = section.length ? $(section[0]) : null;
+                if(section) {
+                    section.prepend(meta);
+                }
+            } else {
+                metadata.replaceWith(meta);
+            }
+            return toret.html();
+        }
+        
+    };
+};
+
 });
\ No newline at end of file
 });
\ No newline at end of file
index 8a9446c..42bf5c0 100644 (file)
@@ -1,32 +1,32 @@
-.rng-module-metadataEditor {\r
-\r
-    table {\r
-        margin-bottom:10px;\r
-    \r
-        [contenteditable] {\r
-            cursor: pointer;\r
-        }\r
-\r
-        li:last-child {\r
-            border-bottom: none !important;\r
-        }\r
-\r
-        tr td:nth-child(1){\r
-            width: 20%;\r
-        }\r
-\r
-        tr td:nth-child(2)  {\r
-            width:80%;\r
-        }\r
-    }\r
-\r
-    .rng-module-metadataEditor-addBtn {\r
-        float:right;\r
-        margin-right:6px;\r
-    }\r
-\r
-    .btn {\r
-        padding:3px;\r
-        line-height:10px;\r
-    }\r
+.rng-module-metadataEditor {
+
+    table {
+        margin-bottom:10px;
+    
+        [contenteditable] {
+            cursor: pointer;
+        }
+
+        li:last-child {
+            border-bottom: none !important;
+        }
+
+        tr td:nth-child(1){
+            width: 20%;
+        }
+
+        tr td:nth-child(2)  {
+            width:80%;
+        }
+    }
+
+    .rng-module-metadataEditor-addBtn {
+        float:right;
+        margin-right:6px;
+    }
+
+    .btn {
+        padding:3px;
+        line-height:10px;
+    }
 }
\ No newline at end of file
 }
\ No newline at end of file
index ef91cab..3920f68 100644 (file)
@@ -1,5 +1,5 @@
-<tr>\r
-    <td><div contenteditable="true" class="rng-module-metadataEditor-metaItemKey"><%= key %></div></td>\r
-    <td><div contenteditable="true" class="rng-module-metadataEditor-metaItemValue"><%= value %></div></td>\r
-    <td><button class="rng-visualEditor-metaRemoveBtn btn btn-mini btn-danger">x</button></td>\r
+<tr>
+    <td><div contenteditable="true" class="rng-module-metadataEditor-metaItemKey"><%= key %></div></td>
+    <td><div contenteditable="true" class="rng-module-metadataEditor-metaItemValue"><%= value %></div></td>
+    <td><button class="rng-visualEditor-metaRemoveBtn btn btn-mini btn-danger">x</button></td>
 </tr>
\ No newline at end of file
 </tr>
\ No newline at end of file
index e163cbb..5826f82 100644 (file)
@@ -1,8 +1,8 @@
-<div class="rng-module-metadataEditor">\r
-    <fieldset>\r
-    <legend>Meta dane</legend>\r
-    <table class="table table-condensed table-bordered">\r
-    </table>\r
-    <button class="rng-module-metadataEditor-addBtn btn btn-mini btn-info">+</button></td>\r
-    </fieldset>\r
+<div class="rng-module-metadataEditor">
+    <fieldset>
+    <legend>Meta dane</legend>
+    <table class="table table-condensed table-bordered">
+    </table>
+    <button class="rng-module-metadataEditor-addBtn btn btn-mini btn-info">+</button></td>
+    </fieldset>
 </div>
\ No newline at end of file
 </div>
\ No newline at end of file
index ba7092e..4b55488 100644 (file)
@@ -1,24 +1,24 @@
-define(['libs/jquery-1.9.1.min'], function($) {\r
-\r
-    'use strict';\r
-\r
-    return {\r
-        getMetadata: function(xml) {\r
-            var toret = {};\r
-            $(xml).find('metadata').children().each(function() {\r
-                var node = $(this);\r
-                toret[this.nodeName.split(':')[1].toLowerCase()] = node.text();\r
-            });\r
-            return toret;\r
-        },\r
-        getXML: function(metadata) {\r
-            var meta = $('<metadata></metadata>\n');\r
-            _.each(_.keys(metadata), function(key) {\r
-                meta.append('\n\t<dc:'+key+'>' + metadata[key] + '</dc:'+key+'>');\r
-            });\r
-            meta.append('\n');\r
-            return vkbeautify.xml(meta.html());\r
-        }\r
-    };\r
-\r
+define(['libs/jquery-1.9.1.min'], function($) {
+
+    'use strict';
+
+    return {
+        getMetadata: function(xml) {
+            var toret = {};
+            $(xml).find('metadata').children().each(function() {
+                var node = $(this);
+                toret[this.nodeName.split(':')[1].toLowerCase()] = node.text();
+            });
+            return toret;
+        },
+        getXML: function(metadata) {
+            var meta = $('<metadata></metadata>\n');
+            _.each(_.keys(metadata), function(key) {
+                meta.append('\n\t<dc:'+key+'>' + metadata[key] + '</dc:'+key+'>');
+            });
+            meta.append('\n');
+            return vkbeautify.xml(meta.html());
+        }
+    };
+
 });
\ No newline at end of file
 });
\ No newline at end of file
index 7331def..e9fc107 100644 (file)
@@ -1,67 +1,67 @@
-define([\r
-'libs/jquery-1.9.1.min',\r
-'libs/underscore-min',\r
-'libs/text!./template.html'], function($, _, templateSrc) {\r
-\r
-'use strict';\r
-\r
-return function(sandbox) {\r
-    \r
-    var template = _.template(templateSrc);\r
-    \r
-    var view = {\r
-        dom: $('<div>' + template({node:null, parents: null}) + '</div>'),\r
-        setup: function() {\r
-            var view = this;\r
-            this.dom.on('mouseenter', 'a', function(e) {\r
-                var target = $(e.target);\r
-                sandbox.publish('nodeHighlighted', view.nodes[target.attr('data-id')]);\r
-            });\r
-            this.dom.on('mouseleave', 'a', function(e) {\r
-                var target = $(e.target);\r
-                sandbox.publish('nodeDimmed', view.nodes[target.attr('data-id')]);\r
-            });\r
-            this.dom.on('click', 'a', function(e) {\r
-                e.preventDefault();\r
-                var target = $(e.target);\r
-                sandbox.publish('nodeSelected', view.nodes[target.attr('data-id')]);\r
-            });\r
-        },\r
-        \r
-        setNode: function(node) {\r
-            this.dom.empty();\r
-            var nodes = this.nodes = {};\r
-            this.currentNode = node;\r
-            this.nodes[node.getId()] = node;\r
-            var parents = node.parents();\r
-            parents.each(function() {\r
-                var parent = this;\r
-                nodes[parent.getId()] = parent;\r
-            });\r
-            this.dom.html(template({node: node, parents: parents}));\r
-        },\r
-        \r
-        highlightNode: function(node) {\r
-            this.dom.find('a[data-id="'+node.id+'"]').addClass('rng-common-hoveredNode');\r
-        },\r
-        dimNode: function(node) {\r
-            this.dom.find('a[data-id="'+node.id+'"]').removeClass('rng-common-hoveredNode');\r
-        }\r
-    };\r
-    \r
-    view.setup();\r
-    \r
-    return {\r
-        start: function() { sandbox.publish('ready'); },\r
-        getView: function() { return view.dom; },\r
-        setNode: function(canvasNode) {\r
-            if(!canvasNode.isSame(view.currentNode)) {\r
-                view.setNode(canvasNode);\r
-            }\r
-        },\r
-        highlightNode: function(id) { view.highlightNode(id); },\r
-        dimNode: function(id) { view.dimNode(id); }\r
-    };\r
-};\r
-\r
+define([
+'libs/jquery-1.9.1.min',
+'libs/underscore-min',
+'libs/text!./template.html'], function($, _, templateSrc) {
+
+'use strict';
+
+return function(sandbox) {
+    
+    var template = _.template(templateSrc);
+    
+    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('nodeHighlighted', view.nodes[target.attr('data-id')]);
+            });
+            this.dom.on('mouseleave', 'a', function(e) {
+                var target = $(e.target);
+                sandbox.publish('nodeDimmed', view.nodes[target.attr('data-id')]);
+            });
+            this.dom.on('click', 'a', function(e) {
+                e.preventDefault();
+                var target = $(e.target);
+                sandbox.publish('nodeSelected', view.nodes[target.attr('data-id')]);
+            });
+        },
+        
+        setNode: function(node) {
+            this.dom.empty();
+            var nodes = this.nodes = {};
+            this.currentNode = node;
+            this.nodes[node.getId()] = node;
+            var parents = node.parents();
+            parents.each(function() {
+                var parent = this;
+                nodes[parent.getId()] = parent;
+            });
+            this.dom.html(template({node: node, parents: parents}));
+        },
+        
+        highlightNode: function(node) {
+            this.dom.find('a[data-id="'+node.id+'"]').addClass('rng-common-hoveredNode');
+        },
+        dimNode: function(node) {
+            this.dom.find('a[data-id="'+node.id+'"]').removeClass('rng-common-hoveredNode');
+        }
+    };
+    
+    view.setup();
+    
+    return {
+        start: function() { sandbox.publish('ready'); },
+        getView: function() { return view.dom; },
+        setNode: function(canvasNode) {
+            if(!canvasNode.isSame(view.currentNode)) {
+                view.setNode(canvasNode);
+            }
+        },
+        highlightNode: function(id) { view.highlightNode(id); },
+        dimNode: function(id) { view.dimNode(id); }
+    };
+};
+
 });
\ No newline at end of file
 });
\ No newline at end of file
index 049352e..39ea20f 100644 (file)
@@ -1,85 +1,85 @@
-define([\r
-'libs/jquery-1.9.1.min',\r
-'libs/underscore-min',\r
-'libs/text!./template.html'\r
-], function($, _, templateSrc) {\r
-\r
-'use strict';\r
-\r
-return function(sandbox) {\r
-    \r
-    var template = _.template(templateSrc);\r
-    \r
-    var view = {\r
-        dom: $('<div>' + template({children: null, parent: null}) + '</div>'),\r
-        setup: function() {\r
-            var view = this;\r
-            this.dom.on('click', 'a', function(e) {\r
-                var target = $(e.target);\r
-                sandbox.publish('nodeSelected', view.nodes[target.attr('data-id')]);\r
-            });\r
-            \r
-            this.dom.on('mouseenter', 'a', function(e) {\r
-                var target = $(e.target);\r
-                sandbox.publish('nodeEntered', view.nodes[target.attr('data-id')]);\r
-            });\r
-            this.dom.on('mouseleave', 'a', function(e) {\r
-                var target = $(e.target);\r
-                sandbox.publish('nodeLeft', view.nodes[target.attr('data-id')]);\r
-            });\r
-        },\r
-        setNode: function(node) {\r
-            console.log('familyTree sets node');\r
-            var nodes = this.nodes = {};\r
-            this.currentNode = node;\r
-            var parentNode = node.parent();\r
-            var parent;\r
-            \r
-            if(parentNode) {\r
-                parent = {\r
-                    repr: parentNode.getTag() + (parentNode.getClass() ? ' / ' + parentNode.getClass() : ''),\r
-                    id: parentNode.getId()\r
-                };\r
-                this.nodes[parentNode.getId()] = parentNode;\r
-            }\r
-        \r
-            var children = [];\r
-            node.children().each(function() {\r
-                var child = this;\r
-                children.push({repr: child.getTag() + (child.getClass() ? ' / ' + child.getClass() : ''), id: child.getId()});\r
-                nodes[child.getId()] = child;\r
-            });\r
-            this.dom.empty();\r
-            this.dom.append($(template({parent: parent, children: children})));\r
-        },\r
-        highlightNode: function(canvasNode) {\r
-            this.dom.find('a[data-id="'+canvasNode.getId()+'"]').addClass('rng-common-hoveredNode');\r
-        },\r
-        dimNode: function(canvasNode) {\r
-            this.dom.find('a[data-id="'+canvasNode.getId()+'"]').removeClass('rng-common-hoveredNode');\r
-        }\r
-    };\r
-    \r
-    view.setup();\r
-    \r
-    return {\r
-        start: function() {\r
-            sandbox.publish('ready');\r
-        },\r
-        setNode: function(canvasNode) {\r
-            if(!canvasNode.isSame(view.currentNode))\r
-                view.setNode(canvasNode);\r
-        },\r
-        getView: function() {\r
-            return view.dom;\r
-        },\r
-        highlightNode: function(canvasNode) {\r
-            view.highlightNode(canvasNode);\r
-        },\r
-        dimNode: function(canvasNode) {\r
-            view.dimNode(canvasNode);\r
-        }\r
-    };\r
-};\r
-\r
+define([
+'libs/jquery-1.9.1.min',
+'libs/underscore-min',
+'libs/text!./template.html'
+], function($, _, templateSrc) {
+
+'use strict';
+
+return function(sandbox) {
+    
+    var template = _.template(templateSrc);
+    
+    var view = {
+        dom: $('<div>' + template({children: null, parent: null}) + '</div>'),
+        setup: function() {
+            var view = this;
+            this.dom.on('click', 'a', function(e) {
+                var target = $(e.target);
+                sandbox.publish('nodeSelected', view.nodes[target.attr('data-id')]);
+            });
+            
+            this.dom.on('mouseenter', 'a', function(e) {
+                var target = $(e.target);
+                sandbox.publish('nodeEntered', view.nodes[target.attr('data-id')]);
+            });
+            this.dom.on('mouseleave', 'a', function(e) {
+                var target = $(e.target);
+                sandbox.publish('nodeLeft', view.nodes[target.attr('data-id')]);
+            });
+        },
+        setNode: function(node) {
+            console.log('familyTree sets node');
+            var nodes = this.nodes = {};
+            this.currentNode = node;
+            var parentNode = node.parent();
+            var parent;
+            
+            if(parentNode) {
+                parent = {
+                    repr: parentNode.getTag() + (parentNode.getClass() ? ' / ' + parentNode.getClass() : ''),
+                    id: parentNode.getId()
+                };
+                this.nodes[parentNode.getId()] = parentNode;
+            }
+        
+            var children = [];
+            node.children().each(function() {
+                var child = this;
+                children.push({repr: child.getTag() + (child.getClass() ? ' / ' + child.getClass() : ''), id: child.getId()});
+                nodes[child.getId()] = child;
+            });
+            this.dom.empty();
+            this.dom.append($(template({parent: parent, children: children})));
+        },
+        highlightNode: function(canvasNode) {
+            this.dom.find('a[data-id="'+canvasNode.getId()+'"]').addClass('rng-common-hoveredNode');
+        },
+        dimNode: function(canvasNode) {
+            this.dom.find('a[data-id="'+canvasNode.getId()+'"]').removeClass('rng-common-hoveredNode');
+        }
+    };
+    
+    view.setup();
+    
+    return {
+        start: function() {
+            sandbox.publish('ready');
+        },
+        setNode: function(canvasNode) {
+            if(!canvasNode.isSame(view.currentNode))
+                view.setNode(canvasNode);
+        },
+        getView: function() {
+            return view.dom;
+        },
+        highlightNode: function(canvasNode) {
+            view.highlightNode(canvasNode);
+        },
+        dimNode: function(canvasNode) {
+            view.dimNode(canvasNode);
+        }
+    };
+};
+
 });
\ No newline at end of file
 });
\ No newline at end of file
index b2a734f..6b4dc77 100644 (file)
@@ -1,38 +1,38 @@
-.rng-module-nodeFamilyTree {\r
-    overflow-y: scroll;\r
-    max-height: 150px;\r
-    width:100%;\r
-    margin-top:10px;\r
-\r
-    table {\r
-        width: 90%;\r
-        margin: 0;\r
-    \r
-        tr {\r
-            td:nth-child(1) {\r
-                width: 30%;\r
-            }\r
-            td:nth-child(2) {\r
-                width: 70%;\r
-            }\r
-            td ul {\r
-                list-style-type: none;\r
-                margin: 0;\r
-            }\r
-            \r
-        }\r
-    }\r
-    \r
-    &::-webkit-scrollbar {\r
-        .rng-mixin-scrollbar;\r
-    }\r
-    &::-webkit-scrollbar-track {\r
-        .rng-mixin-scrollbar-track;\r
-    }\r
-    &::-webkit-scrollbar-thumb {\r
-        .rng-mixin-scrollbar-thumb;\r
-    }\r
-    &::-webkit-scrollbar-thumb:window-inactive {\r
-        .rng-mixin-scrollbar-thumb-window-inactive;\r
-    }\r
+.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
 }
\ No newline at end of file
index 021709a..8a7df5c 100644 (file)
@@ -1,19 +1,19 @@
-<div class="rng-module-nodeFamilyTree">\r
-    <table class="table table-bordered">\r
-        <tr>\r
-            <td>powyżej</td>\r
-            <td><% if(parent) { %><a href="#" class="rng-module-nodeFamilyTree-parent" data-id="<%= parent.id %>"><%= parent.repr %></a><% } else { %>-<% } %></td>\r
-        </tr>\r
-        <tr>\r
-            <td rowspan="0">poniżej</td>\r
-            <td>\r
-                <ul>\r
-                <% if(!children || children.length === 0) { %>-<% } else { %>\r
-                    <% children.forEach(function(child) { %>\r
-                        <li><a href="#" data-id="<%= child.id %>"><%= child.repr %></a></li>\r
-                    <% }); %>\r
-                <% } %>\r
-                </ul>\r
-            </td>\r
-        </tr>\r
+<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" data-id="<%= parent.id %>"><%= parent.repr %></a><% } else { %>-<% } %></td>
+        </tr>
+        <tr>
+            <td rowspan="0">poniżej</td>
+            <td>
+                <ul>
+                <% if(!children || children.length === 0) { %>-<% } else { %>
+                    <% children.forEach(function(child) { %>
+                        <li><a href="#" data-id="<%= child.id %>"><%= child.repr %></a></li>
+                    <% }); %>
+                <% } %>
+                </ul>
+            </td>
+        </tr>
 </div>
\ No newline at end of file
 </div>
\ No newline at end of file
index cc71d35..57f5c17 100644 (file)
@@ -1,35 +1,35 @@
-define([\r
-'libs/text!./template.html',\r
-'libs/jquery-1.9.1.min',\r
-'libs/underscore-min',\r
-\r
-], function(templateSrc, $, _) {\r
-\r
-'use strict';\r
-\r
-return function(sandbox) {\r
-    \r
-    var view = $(_.template(templateSrc)());\r
-    \r
-    view.on('change', 'select', function(e) {\r
-        var target = $(e.target);\r
-        var attr = target.attr('class').split('-')[3] === 'tagSelect' ? 'tag' : 'class';\r
-        sandbox.publish('nodeChanged', attr, target.val());\r
-    });\r
-    \r
-    return {\r
-        start: function() {\r
-            sandbox.publish('ready');\r
-        },\r
-        getView: function() {\r
-            return view;\r
-        },\r
-        setNode: function(canvasNode) {\r
-            view.find('.rng-module-nodePane-tagSelect').val(canvasNode.getTag());\r
-            view.find('.rng-module-nodePane-classSelect').val(canvasNode.getClass());\r
-        }\r
-    };\r
-    \r
-};\r
-\r
+define([
+'libs/text!./template.html',
+'libs/jquery-1.9.1.min',
+'libs/underscore-min',
+
+], function(templateSrc, $, _) {
+
+'use strict';
+
+return function(sandbox) {
+    
+    var view = $(_.template(templateSrc)());
+    
+    view.on('change', 'select', function(e) {
+        var target = $(e.target);
+        var attr = target.attr('class').split('-')[3] === 'tagSelect' ? 'tag' : 'class';
+        sandbox.publish('nodeChanged', attr, target.val());
+    });
+    
+    return {
+        start: function() {
+            sandbox.publish('ready');
+        },
+        getView: function() {
+            return view;
+        },
+        setNode: function(canvasNode) {
+            view.find('.rng-module-nodePane-tagSelect').val(canvasNode.getTag());
+            view.find('.rng-module-nodePane-classSelect').val(canvasNode.getClass());
+        }
+    };
+    
+};
+
 });
\ No newline at end of file
 });
\ No newline at end of file
index 5dfd252..771fbd5 100644 (file)
@@ -1,9 +1,9 @@
-.rng-module-nodePane {\r
-    label {\r
-        width: 50px;\r
-        display: inline-block;\r
-    }\r
-    select {\r
-        width: 100px;\r
-    }\r
+.rng-module-nodePane {
+    label {
+        width: 50px;
+        display: inline-block;
+    }
+    select {
+        width: 100px;
+    }
 }
\ No newline at end of file
 }
\ No newline at end of file
index c0733cd..d1e8ab2 100644 (file)
@@ -1,23 +1,23 @@
-<div class="rng-module-nodePane">\r
-    <fieldset>\r
-        <legend><%= gettext('Current node') %></legend>\r
-        <div>\r
-            <label>Tag</label>\r
-            <select class="rng-module-nodePane-tagSelect">\r
-                <% var options = ['', 'section', 'header', 'div', 'span', 'aside']; %>\r
-                <% options.forEach(function(option) { %>\r
-                    <option value="<%= option %>" <% if(option === '') { %>selected<% } %>><%= option %></option>\r
-                <% }); %>\r
-            </select>\r
-        </div>\r
-        <div>\r
-            <label>Klasa</label>\r
-            <select  class="rng-module-nodePane-classSelect">\r
-                <% var options = ['', 'author', 'title', 'cite', 'cite.code', 'cite.code.xml', 'list', 'list.items', 'list.items.enum', 'item', 'uri', 'p', 'footnote', 'todo', 'emp', 'emph.tech'] %>\r
-                <% options.forEach(function(option) { %>\r
-                    <option value="<%= option.replace(/\./g, '-') %>" <% if(option === '') { %>selected<% } %>><%= option %></option>\r
-                <% }); %>\r
-            </select>\r
-        </div>\r
-    </fieldset>\r
+<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<% } %>><%= option %></option>
+                <% }); %>
+            </select>
+        </div>
+        <div>
+            <label>Klasa</label>
+            <select  class="rng-module-nodePane-classSelect">
+                <% var options = ['', 'author', 'title', 'cite', 'cite.code', 'cite.code.xml', 'list', 'list.items', 'list.items.enum', 'item', 'uri', 'p', 'footnote', 'todo', 'emp', 'emph.tech'] %>
+                <% options.forEach(function(option) { %>
+                    <option value="<%= option.replace(/\./g, '-') %>" <% if(option === '') { %>selected<% } %>><%= option %></option>
+                <% }); %>
+            </select>
+        </div>
+    </fieldset>
 </div>
\ No newline at end of file
 </div>
\ No newline at end of file
index c07dd77..8b03929 100644 (file)
@@ -1,4 +1,4 @@
-<div class="rng-module-rng-diffLayout">\r
-    <div fnpjs-place="left"></div>\r
-    <div fnpjs-place="right"></div>\r
+<div class="rng-module-rng-diffLayout">
+    <div fnpjs-place="left"></div>
+    <div fnpjs-place="right"></div>
 </div>
\ No newline at end of file
 </div>
\ No newline at end of file
index cd03dcd..0f51948 100644 (file)
@@ -1,20 +1,20 @@
-.rng-module-rng-diffLayout {\r
-    [fnpjs-place=left] {\r
-        width: 300px;\r
-        margin: 0 20px 0 0px;\r
-        left: 0;\r
-    }\r
-    [fnpjs-place=right] {\r
-        left: 320px;\r
-        right: 0;\r
-    }\r
-    \r
-    [fnpjs-place=left], [fnpjs-place=right] {\r
-        position: absolute;\r
-        top: 0;\r
-        bottom: 0;\r
-        \r
-\r
-    }\r
-\r
+.rng-module-rng-diffLayout {
+    [fnpjs-place=left] {
+        width: 300px;
+        margin: 0 20px 0 0px;
+        left: 0;
+    }
+    [fnpjs-place=right] {
+        left: 320px;
+        right: 0;
+    }
+    
+    [fnpjs-place=left], [fnpjs-place=right] {
+        position: absolute;
+        top: 0;
+        bottom: 0;
+        
+
+    }
+
 }
\ No newline at end of file
 }
\ No newline at end of file
index 752a973..54a29aa 100644 (file)
@@ -1,7 +1,7 @@
-<div class="fnp-module-rng-editingLayout">\r
-    <div fnpjs-place="toolbar"></div>\r
-    <div class="rng-module-rng2-left" fnpjs-place="leftColumn"></div>\r
-    <div class="rng-module-rng2-right" fnpjs-place="rightColumn"></div>\r
-    <div style="clear:both;"></div>\r
-    <div class="rng-module-rng2-statusBar" fnpjs-place="statusBar"></div>\r
+<div class="fnp-module-rng-editingLayout">
+    <div fnpjs-place="toolbar"></div>
+    <div class="rng-module-rng2-left" fnpjs-place="leftColumn"></div>
+    <div class="rng-module-rng2-right" fnpjs-place="rightColumn"></div>
+    <div style="clear:both;"></div>
+    <div class="rng-module-rng2-statusBar" fnpjs-place="statusBar"></div>
 </div>
\ No newline at end of file
 </div>
\ No newline at end of file
index dcaead2..19d165f 100644 (file)
@@ -1,88 +1,88 @@
-.rng-module-rng2-left {\r
-    /*float: left;\r
-    width: 600px;*/\r
-}\r
-\r
-.rng-module-rng2-right {\r
-    /*float: right;\r
-    position: relative;\r
-    width: 258px;\r
-    margin-left: 50px;*/\r
-\r
-    border-width: 1px 1px 1px 1px;\r
-    border-style: solid;\r
-    border-color: #ddd;\r
-    padding: 5px 15px;\r
-    \r
-    p, td, label, input, select {\r
-        font-size: 11px;\r
-        line-height:13px;\r
-    }\r
-    \r
-    select {\r
-        -webkit-appearance: button;\r
-        -moz-appearance: button;\r
-        appearance: button;\r
-        height: auto;\r
-        line-height: 14px;\r
-    }\r
-    \r
-    legend {\r
-        font-size:11px;\r
-        height:30px;\r
-    }\r
-    \r
-    \r
-    .rng-view-tabs-tabBar {\r
-        position:absolute;\r
-        top:-1px;\r
-        right:-50px;\r
-        border-width: 1px 1px 1px 0px;\r
-        border-style: solid;\r
-        border-color: #ddd;\r
-        padding: 5px;\r
-        background: #ededed;\r
-    }\r
-    \r
-    label + select {\r
-        position:relative;\r
-        top: 5px;\r
-    }\r
-\r
-}\r
-\r
-.rng-module-rng2-statusBar {\r
-    margin: 10px 5px;\r
-    font-size:0.9em;\r
-}\r
-\r
-.fnp-module-rng-editingLayout {\r
-\r
-    [fnpjs-place="statusBar"] {\r
-        position: absolute;\r
-        bottom: 0;\r
-        left: 0;\r
-        right: 0;\r
-        height: 30px;\r
-        \r
-    }\r
-    \r
-    [fnpjs-place="leftColumn"], [fnpjs-place="rightColumn"] {\r
-        position: absolute;\r
-        top: 30px; //\r
-        bottom: 50px; //\r
-    }\r
-    \r
-    [fnpjs-place="leftColumn"] {\r
-        left:0;\r
-        right: 320px;\r
-    }\r
-    \r
-    [fnpjs-place="rightColumn"] {\r
-        right: 0px;\r
-        width: 250px;\r
-        \r
-    }\r
-\r
-\r
+.rng-module-rng2-left {
+    /*float: left;
+    width: 600px;*/
+}
+
+.rng-module-rng2-right {
+    /*float: right;
+    position: relative;
+    width: 258px;
+    margin-left: 50px;*/
+
+    border-width: 1px 1px 1px 1px;
+    border-style: solid;
+    border-color: #ddd;
+    padding: 5px 15px;
+    
+    p, td, label, input, select {
+        font-size: 11px;
+        line-height:13px;
+    }
+    
+    select {
+        -webkit-appearance: button;
+        -moz-appearance: button;
+        appearance: button;
+        height: auto;
+        line-height: 14px;
+    }
+    
+    legend {
+        font-size:11px;
+        height:30px;
+    }
+    
+    
+    .rng-view-tabs-tabBar {
+        position:absolute;
+        top:-1px;
+        right:-50px;
+        border-width: 1px 1px 1px 0px;
+        border-style: solid;
+        border-color: #ddd;
+        padding: 5px;
+        background: #ededed;
+    }
+    
+    label + select {
+        position:relative;
+        top: 5px;
+    }
+
+}
+
+.rng-module-rng2-statusBar {
+    margin: 10px 5px;
+    font-size:0.9em;
+}
+
+.fnp-module-rng-editingLayout {
+
+    [fnpjs-place="statusBar"] {
+        position: absolute;
+        bottom: 0;
+        left: 0;
+        right: 0;
+        height: 30px;
+        
+    }
+    
+    [fnpjs-place="leftColumn"], [fnpjs-place="rightColumn"] {
+        position: absolute;
+        top: 30px; //
+        bottom: 50px; //
+    }
+    
+    [fnpjs-place="leftColumn"] {
+        left:0;
+        right: 320px;
+    }
+    
+    [fnpjs-place="rightColumn"] {
+        right: 0px;
+        width: 250px;
+        
+    }
+
+
 }
\ No newline at end of file
 }
\ No newline at end of file
index 160fa13..0cccb9c 100644 (file)
@@ -1,8 +1,8 @@
-<div id="rng-module-rng-mainLayout">\r
-    <div fnpjs-place="messages"></div>\r
-    <div fnpjs-place="topPanel">\r
-    </div>\r
-    <div style="clear:both"></div>\r
-    <div fnpjs-place="mainView">\r
-    </div>\r
+<div id="rng-module-rng-mainLayout">
+    <div fnpjs-place="messages"></div>
+    <div fnpjs-place="topPanel">
+    </div>
+    <div style="clear:both"></div>
+    <div fnpjs-place="mainView">
+    </div>
 </div>
\ No newline at end of file
 </div>
\ No newline at end of file
index a2b553c..ac28f02 100644 (file)
@@ -1,43 +1,43 @@
-#rng-module-rng-mainLayout {\r
-    position: fixed;\r
-    top: 5px;\r
-    bottom: 5px;\r
-    left: 80px;\r
-    right: 80px;\r
-    \r
-    [fnpjs-place="messages"] {\r
-        position: absolute;\r
-        top: 5px;\r
-        width:100%;\r
-        text-align:center;\r
-    }\r
-    \r
-    [fnpjs-place="topPanel"] {\r
-        float: right;\r
-        position: relative;\r
-        z-index: 2;\r
-    }\r
-    \r
-    [fnpjs-place="mainView"] {\r
-        position: absolute;\r
-        top: 0;\r
-        left:0;\r
-        right:0;\r
-        bottom:0;\r
-        z-index: 1;\r
-        \r
-        > .rng-view-tabs {\r
-            position: relative;\r
-            height: 100%;\r
-\r
-            > .rng-view-tabs-content {\r
-                position: absolute;\r
-                top: 45px;\r
-                left: 0;\r
-                right: 0;\r
-                bottom: 0;\r
-            }    \r
-        }\r
-        \r
-    }\r
+#rng-module-rng-mainLayout {
+    position: fixed;
+    top: 5px;
+    bottom: 5px;
+    left: 80px;
+    right: 80px;
+    
+    [fnpjs-place="messages"] {
+        position: absolute;
+        top: 5px;
+        width:100%;
+        text-align:center;
+    }
+    
+    [fnpjs-place="topPanel"] {
+        float: right;
+        position: relative;
+        z-index: 2;
+    }
+    
+    [fnpjs-place="mainView"] {
+        position: absolute;
+        top: 0;
+        left:0;
+        right:0;
+        bottom:0;
+        z-index: 1;
+        
+        > .rng-view-tabs {
+            position: relative;
+            height: 100%;
+
+            > .rng-view-tabs-content {
+                position: absolute;
+                top: 45px;
+                left: 0;
+                right: 0;
+                bottom: 0;
+            }    
+        }
+        
+    }
 }
\ No newline at end of file
 }
\ No newline at end of file
index 980e6ff..469a6fc 100644 (file)
-define([\r
-'fnpjs/layout',\r
-'fnpjs/vbox',\r
-'views/tabs/tabs',\r
-'libs/text!./mainLayout.html',\r
-'libs/text!./editingLayout.html',\r
-'libs/text!./diffLayout.html',\r
-], function(layout, vbox, tabs, mainLayoutTemplate, visualEditingLayoutTemplate, diffLayoutTemplate) {\r
-\r
-'use strict';\r
-\r
-return function(sandbox) {\r
-    \r
-    function addMainTab(title, slug, view) {\r
-        views.mainTabs.addTab(title, slug, view);\r
-    }\r
-    \r
-    var dirty = {\r
-        sourceEditor: false,\r
-        documentCanvas: false,\r
-        metadataEditor: false,\r
-    };\r
-    \r
-    var synchronizeTab = function(slug) {\r
-        function tabIsDirty(slug) {\r
-            if(slug === 'editor' && (dirty.documentCanvas || dirty.metadataEditor))\r
-                return true;\r
-            if(slug === 'sourceEditor' && dirty.sourceEditor)\r
-                return true;\r
-            return false;\r
-        }\r
-    \r
-        if(tabIsDirty(slug)) {\r
-            var reason, doc;\r
-            if(slug === 'sourceEditor') {\r
-                doc = sandbox.getModule('sourceEditor').getDocument();\r
-                reason = 'source_edit';\r
-                dirty.sourceEditor = false;\r
-            }\r
-            if(slug === 'editor') {\r
-                doc = dirty.documentCanvas ? sandbox.getModule('documentCanvas').getDocument() : sandbox.getModule('data').getDocument();\r
-                if(dirty.metadataEditor) {\r
-                    doc = sandbox.getModule('metadataEditor').attachMetadata(doc);\r
-                }\r
-                reason = 'edit';\r
-                dirty.documentCanvas = dirty.metadataEditor = false;\r
-            }\r
-            sandbox.getModule('data').commitDocument(doc, reason);\r
-        }\r
-    };\r
-    \r
-    var commands = {\r
-        highlightDocumentNode: function(canvasNode, origin) {\r
-            ['documentCanvas', 'nodeBreadCrumbs', 'nodeFamilyTree'].forEach(function(moduleName) {\r
-                if(!origin || moduleName != origin)\r
-                    sandbox.getModule(moduleName).highlightNode(canvasNode);\r
-            });\r
-        },\r
-        dimDocumentNode: function(canvasNode, origin) {\r
-            ['documentCanvas', 'nodeBreadCrumbs', 'nodeFamilyTree'].forEach(function(moduleName) {\r
-                if(!origin || moduleName != origin)\r
-                    sandbox.getModule(moduleName).dimNode(canvasNode);\r
-            });\r
-        },\r
-        selectNode: function(canvasNode, origin) {\r
-            sandbox.getModule('documentCanvas').selectNode(canvasNode);\r
-            sandbox.getModule('nodePane').setNode(canvasNode);\r
-            sandbox.getModule('nodeFamilyTree').setNode(canvasNode);\r
-            sandbox.getModule('nodeBreadCrumbs').setNode(canvasNode);\r
-            \r
-        },\r
-        resetDocument: function(document, reason) {\r
-            var modules = [];\r
-            if(reason === 'source_edit')\r
-                modules = ['documentCanvas', 'metadataEditor'];\r
-            else if (reason === 'edit')\r
-                modules = ['sourceEditor'];\r
-            else if (reason === 'revert')\r
-                modules = ['documentCanvas', 'metadataEditor', 'sourceEditor'];\r
-                \r
-            modules.forEach(function(moduleName) {\r
-                sandbox.getModule(moduleName).setDocument(document);\r
-            });\r
-        }\r
-    };\r
-    \r
-\r
-    var views = {\r
-        mainLayout: new layout.Layout(mainLayoutTemplate),\r
-        mainTabs: (new tabs.View()).render(),\r
-        visualEditing: new layout.Layout(visualEditingLayoutTemplate),\r
-        visualEditingSidebar: (new tabs.View({stacked: true})).render(),\r
-        currentNodePaneLayout: new vbox.VBox(),\r
-        diffLayout: new layout.Layout(diffLayoutTemplate)\r
-    };\r
-    \r
-    views.visualEditing.setView('rightColumn', views.visualEditingSidebar.getAsView());\r
-    addMainTab('Edytor', 'editor', views.visualEditing.getAsView());\r
-    addMainTab(gettext('Source'), 'sourceEditor',  '');\r
-    addMainTab('Historia', 'history', views.diffLayout.getAsView());\r
-    \r
-    sandbox.getDOM().append(views.mainLayout.getAsView());\r
-    \r
-    views.visualEditingSidebar.addTab({icon: 'pencil'}, 'edit', views.currentNodePaneLayout.getAsView());\r
-\r
-    views.mainTabs.on('tabSelected', function(event) {\r
-        if(event.prevSlug) {\r
-            synchronizeTab(event.prevSlug);\r
-        }\r
-    });\r
-    \r
-    /* Events handling */\r
-    \r
-    var eventHandlers = {};\r
-     \r
-    eventHandlers.sourceEditor = {\r
-        ready: function() {\r
-            addMainTab(gettext('Source'), 'sourceEditor',  sandbox.getModule('sourceEditor').getView());\r
-            sandbox.getModule('sourceEditor').setDocument(sandbox.getModule('data').getDocument());\r
-        },\r
-        xmlChanged: function() {\r
-            dirty.sourceEditor = true;\r
-        },\r
-        documentSet: function() {\r
-            dirty.sourceEditor = false;\r
-        }\r
-    };\r
-    \r
-    eventHandlers.data = {\r
-        ready: function() {\r
-            views.mainLayout.setView('mainView', views.mainTabs.getAsView());\r
-            \r
-            _.each(['sourceEditor', 'documentCanvas', 'documentToolbar', 'nodePane', 'metadataEditor', 'nodeFamilyTree', 'nodeBreadCrumbs', 'mainBar', 'indicator', 'documentHistory', 'diffViewer'], function(moduleName) {\r
-                sandbox.getModule(moduleName).start();\r
-            });\r
-        },\r
-        documentChanged: function(document, reason) {\r
-            commands.resetDocument(document, reason);\r
-        },\r
-        savingStarted: function() {\r
-            sandbox.getModule('mainBar').setCommandEnabled('save', false);\r
-            sandbox.getModule('indicator').showMessage(gettext('Saving...'));\r
-        },\r
-        savingEnded: function(status) {\r
-            sandbox.getModule('mainBar').setCommandEnabled('save', true);\r
-            sandbox.getModule('indicator').clearMessage({message:'Dokument zapisany'});\r
-        },\r
-        restoringStarted: function(event) {\r
-            sandbox.getModule('mainBar').setCommandEnabled('save', false);\r
-            sandbox.getModule('indicator').showMessage(gettext('Restoring version ') + event.version + '...');\r
-        },\r
-        historyItemAdded: function(item) {\r
-            sandbox.getModule('documentHistory').addHistory([item], {animate: true});\r
-        },\r
-        diffFetched: function(diff) {\r
-            sandbox.getModule('diffViewer').setDiff(diff);\r
-        },\r
-        documentReverted: function(event) {\r
-            commands.resetDocument(event.document, 'revert');\r
-            sandbox.getModule('mainBar').setCommandEnabled('save', true);\r
-            sandbox.getModule('indicator').clearMessage({message:'Wersja ' + event.reverted_version + ' przywrócona'});\r
-            sandbox.getModule('mainBar').setVersion(event.current_version);\r
-        }\r
-    };\r
-    \r
-    eventHandlers.mainBar = {\r
-        ready: function() {\r
-            sandbox.getModule('mainBar').setVersion(sandbox.getModule('data').getDocumentVersion());\r
-            views.mainLayout.setView('topPanel', sandbox.getModule('mainBar').getView());\r
-        },\r
-        'cmd.save': function() {\r
-            synchronizeTab(views.mainTabs.getCurrentSlug());\r
-            sandbox.getModule('data').saveDocument();\r
-        }\r
-    };\r
-    \r
-    eventHandlers.indicator = {\r
-        ready: function() {\r
-            views.mainLayout.setView('messages', sandbox.getModule('indicator').getView());\r
-        }\r
-    };\r
-    \r
-\r
-    \r
-    eventHandlers.documentCanvas = {\r
-        ready: function() {\r
-            sandbox.getModule('documentCanvas').setDocument(sandbox.getModule('data').getDocument());\r
-            views.visualEditing.setView('leftColumn', sandbox.getModule('documentCanvas').getView());\r
-        },\r
-        documentSet: function() {\r
-            dirty.documentCanvas = false;\r
-        },\r
-        \r
-        nodeSelected: function(canvasNode) {\r
-            commands.selectNode(canvasNode);\r
-        },\r
-        \r
-        contentChanged: function() {\r
-            dirty.documentCanvas = true;\r
-        },\r
-        \r
-        nodeHovered: function(canvasNode) {\r
-            commands.highlightDocumentNode(canvasNode);\r
-        },\r
-        \r
-        nodeBlured: function(canvasNode) {\r
-            commands.dimDocumentNode(canvasNode);\r
-        }\r
-    };\r
-\r
-    eventHandlers.nodePane = {\r
-        ready: function() {\r
-            views.currentNodePaneLayout.appendView(sandbox.getModule('nodePane').getView());\r
-        },\r
-        \r
-        nodeChanged: function(attr, value) {\r
-            sandbox.getModule('documentCanvas').modifyCurrentNode(attr, value);\r
-        }\r
-    };\r
-    \r
-    eventHandlers.metadataEditor = {\r
-        ready: function() {\r
-            sandbox.getModule('metadataEditor').setDocument(sandbox.getModule('data').getDocument());\r
-            views.visualEditingSidebar.addTab({icon: 'info-sign'}, 'metadataEditor', sandbox.getModule('metadataEditor').getView());\r
-        },\r
-        metadataChanged: function(metadata) {\r
-            dirty.metadataEditor = true;\r
-        },\r
-        metadataSet: function() {\r
-            dirty.metadataEditor = false;\r
-        },\r
-    };\r
-    \r
-    eventHandlers.nodeFamilyTree = {\r
-        ready: function() {\r
-            views.currentNodePaneLayout.appendView(sandbox.getModule('nodeFamilyTree').getView());\r
-        },\r
-        nodeEntered: function(canvasNode) {\r
-            commands.highlightDocumentNode(canvasNode, 'nodeFamilyTree');\r
-        },\r
-        nodeLeft: function(canvasNode) {\r
-            commands.dimDocumentNode(canvasNode, 'nodeFamilyTree');\r
-        },\r
-        nodeSelected: function(canvasNode) {\r
-            commands.selectNode(canvasNode);\r
-        }\r
-    };\r
-    \r
-    eventHandlers.documentToolbar = {\r
-        ready: function() {\r
-            views.visualEditing.setView('toolbar', sandbox.getModule('documentToolbar').getView());\r
-        },\r
-        toggleGrid: function(toggle) {\r
-            sandbox.getModule('documentCanvas').toggleGrid(toggle);\r
-        },\r
-        newNodeRequested: function(wlxmlTag, wlxmlClass) {\r
-                sandbox.getModule('documentCanvas').insertNewNode(wlxmlTag, wlxmlClass);\r
-        },\r
-        command: function(cmd, meta) {\r
-            sandbox.getModule('documentCanvas').command(cmd, meta);\r
-        }\r
-    };\r
-    \r
-    eventHandlers.nodeBreadCrumbs = {\r
-        ready: function() {\r
-            views.visualEditing.setView('statusBar', sandbox.getModule('nodeBreadCrumbs').getView());\r
-        },\r
-        nodeHighlighted: function(canvasNode) {\r
-            commands.highlightDocumentNode(canvasNode, 'nodeBreadCrumbs');\r
-        },\r
-        nodeDimmed: function(canvasNode) {\r
-            commands.dimDocumentNode(canvasNode, 'nodeBreadCrumbs');\r
-        },\r
-        nodeSelected: function(canvasNode) {\r
-            commands.selectNode(canvasNode);\r
-        }        \r
-    };\r
-    \r
-    eventHandlers.documentHistory = {\r
-        ready: function() {\r
-            sandbox.getModule('documentHistory').addHistory(sandbox.getModule('data').getHistory());\r
-            views.diffLayout.setView('left', sandbox.getModule('documentHistory').getView());\r
-        },\r
-        compare: function(ver1, ver2) {\r
-            sandbox.getModule('data').fetchDiff(ver1, ver2);\r
-        },\r
-        restoreVersion: function(event) {\r
-            sandbox.getModule('data').restoreVersion(event);\r
-        },\r
-        displayVersion: function(event) {\r
-            window.open('/' + gettext('editor') + '/' + sandbox.getModule('data').getDocumentId() + '?version=' + event.version, _.uniqueId());\r
-        }\r
-    };\r
-    \r
-    eventHandlers.diffViewer = {\r
-        ready: function() {\r
-            views.diffLayout.setView('right', sandbox.getModule('diffViewer').getView());\r
-        }\r
-    };\r
-    \r
-    /* api */\r
-    \r
-    return {\r
-        start: function() {\r
-            sandbox.getModule('data').start();\r
-        },\r
-        handleEvent: function(moduleName, eventName, args) {\r
-            if('')\r
-                wysiwigHandler.handleEvent(moduleName, eventName, args);\r
-            else if(eventHandlers[moduleName] && eventHandlers[moduleName][eventName]) {\r
-                eventHandlers[moduleName][eventName].apply(eventHandlers, args);\r
-            }\r
-        }\r
-    };\r
-};\r
-\r
+define([
+'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) {
+
+'use strict';
+
+return function(sandbox) {
+    
+    function addMainTab(title, slug, view) {
+        views.mainTabs.addTab(title, slug, view);
+    }
+    
+    var dirty = {
+        sourceEditor: false,
+        documentCanvas: false,
+        metadataEditor: false,
+    };
+    
+    var synchronizeTab = function(slug) {
+        function tabIsDirty(slug) {
+            if(slug === 'editor' && (dirty.documentCanvas || dirty.metadataEditor))
+                return true;
+            if(slug === 'sourceEditor' && dirty.sourceEditor)
+                return true;
+            return false;
+        }
+    
+        if(tabIsDirty(slug)) {
+            var reason, doc;
+            if(slug === 'sourceEditor') {
+                doc = sandbox.getModule('sourceEditor').getDocument();
+                reason = 'source_edit';
+                dirty.sourceEditor = false;
+            }
+            if(slug === 'editor') {
+                doc = dirty.documentCanvas ? sandbox.getModule('documentCanvas').getDocument() : sandbox.getModule('data').getDocument();
+                if(dirty.metadataEditor) {
+                    doc = sandbox.getModule('metadataEditor').attachMetadata(doc);
+                }
+                reason = 'edit';
+                dirty.documentCanvas = dirty.metadataEditor = false;
+            }
+            sandbox.getModule('data').commitDocument(doc, reason);
+        }
+    };
+    
+    var commands = {
+        highlightDocumentNode: function(canvasNode, origin) {
+            ['documentCanvas', 'nodeBreadCrumbs', 'nodeFamilyTree'].forEach(function(moduleName) {
+                if(!origin || moduleName != origin)
+                    sandbox.getModule(moduleName).highlightNode(canvasNode);
+            });
+        },
+        dimDocumentNode: function(canvasNode, origin) {
+            ['documentCanvas', 'nodeBreadCrumbs', 'nodeFamilyTree'].forEach(function(moduleName) {
+                if(!origin || moduleName != origin)
+                    sandbox.getModule(moduleName).dimNode(canvasNode);
+            });
+        },
+        selectNode: function(canvasNode, origin) {
+            sandbox.getModule('documentCanvas').selectNode(canvasNode);
+            sandbox.getModule('nodePane').setNode(canvasNode);
+            sandbox.getModule('nodeFamilyTree').setNode(canvasNode);
+            sandbox.getModule('nodeBreadCrumbs').setNode(canvasNode);
+            
+        },
+        resetDocument: function(document, reason) {
+            var modules = [];
+            if(reason === 'source_edit')
+                modules = ['documentCanvas', 'metadataEditor'];
+            else if (reason === 'edit')
+                modules = ['sourceEditor'];
+            else if (reason === 'revert')
+                modules = ['documentCanvas', 'metadataEditor', 'sourceEditor'];
+                
+            modules.forEach(function(moduleName) {
+                sandbox.getModule(moduleName).setDocument(document);
+            });
+        }
+    };
+    
+
+    var views = {
+        mainLayout: new layout.Layout(mainLayoutTemplate),
+        mainTabs: (new tabs.View()).render(),
+        visualEditing: new layout.Layout(visualEditingLayoutTemplate),
+        visualEditingSidebar: (new tabs.View({stacked: true})).render(),
+        currentNodePaneLayout: new vbox.VBox(),
+        diffLayout: new layout.Layout(diffLayoutTemplate)
+    };
+    
+    views.visualEditing.setView('rightColumn', views.visualEditingSidebar.getAsView());
+    addMainTab('Edytor', 'editor', views.visualEditing.getAsView());
+    addMainTab(gettext('Source'), 'sourceEditor',  '');
+    addMainTab('Historia', 'history', views.diffLayout.getAsView());
+    
+    sandbox.getDOM().append(views.mainLayout.getAsView());
+    
+    views.visualEditingSidebar.addTab({icon: 'pencil'}, 'edit', views.currentNodePaneLayout.getAsView());
+
+    views.mainTabs.on('tabSelected', function(event) {
+        if(event.prevSlug) {
+            synchronizeTab(event.prevSlug);
+        }
+    });
+    
+    /* Events handling */
+    
+    var eventHandlers = {};
+     
+    eventHandlers.sourceEditor = {
+        ready: function() {
+            addMainTab(gettext('Source'), 'sourceEditor',  sandbox.getModule('sourceEditor').getView());
+            sandbox.getModule('sourceEditor').setDocument(sandbox.getModule('data').getDocument());
+        },
+        xmlChanged: function() {
+            dirty.sourceEditor = true;
+        },
+        documentSet: function() {
+            dirty.sourceEditor = false;
+        }
+    };
+    
+    eventHandlers.data = {
+        ready: function() {
+            views.mainLayout.setView('mainView', views.mainTabs.getAsView());
+            
+            _.each(['sourceEditor', 'documentCanvas', 'documentToolbar', 'nodePane', 'metadataEditor', 'nodeFamilyTree', 'nodeBreadCrumbs', 'mainBar', 'indicator', 'documentHistory', 'diffViewer'], function(moduleName) {
+                sandbox.getModule(moduleName).start();
+            });
+        },
+        documentChanged: function(document, reason) {
+            commands.resetDocument(document, reason);
+        },
+        savingStarted: function() {
+            sandbox.getModule('mainBar').setCommandEnabled('save', false);
+            sandbox.getModule('indicator').showMessage(gettext('Saving...'));
+        },
+        savingEnded: function(status) {
+            sandbox.getModule('mainBar').setCommandEnabled('save', true);
+            sandbox.getModule('indicator').clearMessage({message:'Dokument zapisany'});
+        },
+        restoringStarted: function(event) {
+            sandbox.getModule('mainBar').setCommandEnabled('save', false);
+            sandbox.getModule('indicator').showMessage(gettext('Restoring version ') + event.version + '...');
+        },
+        historyItemAdded: function(item) {
+            sandbox.getModule('documentHistory').addHistory([item], {animate: true});
+        },
+        diffFetched: function(diff) {
+            sandbox.getModule('diffViewer').setDiff(diff);
+        },
+        documentReverted: function(event) {
+            commands.resetDocument(event.document, 'revert');
+            sandbox.getModule('mainBar').setCommandEnabled('save', true);
+            sandbox.getModule('indicator').clearMessage({message:'Wersja ' + event.reverted_version + ' przywrócona'});
+            sandbox.getModule('mainBar').setVersion(event.current_version);
+        }
+    };
+    
+    eventHandlers.mainBar = {
+        ready: function() {
+            sandbox.getModule('mainBar').setVersion(sandbox.getModule('data').getDocumentVersion());
+            views.mainLayout.setView('topPanel', sandbox.getModule('mainBar').getView());
+        },
+        'cmd.save': function() {
+            synchronizeTab(views.mainTabs.getCurrentSlug());
+            sandbox.getModule('data').saveDocument();
+        }
+    };
+    
+    eventHandlers.indicator = {
+        ready: function() {
+            views.mainLayout.setView('messages', sandbox.getModule('indicator').getView());
+        }
+    };
+    
+
+    
+    eventHandlers.documentCanvas = {
+        ready: function() {
+            sandbox.getModule('documentCanvas').setDocument(sandbox.getModule('data').getDocument());
+            views.visualEditing.setView('leftColumn', sandbox.getModule('documentCanvas').getView());
+        },
+        documentSet: function() {
+            dirty.documentCanvas = false;
+        },
+        
+        nodeSelected: function(canvasNode) {
+            commands.selectNode(canvasNode);
+        },
+        
+        contentChanged: function() {
+            dirty.documentCanvas = true;
+        },
+        
+        nodeHovered: function(canvasNode) {
+            commands.highlightDocumentNode(canvasNode);
+        },
+        
+        nodeBlured: function(canvasNode) {
+            commands.dimDocumentNode(canvasNode);
+        }
+    };
+
+    eventHandlers.nodePane = {
+        ready: function() {
+            views.currentNodePaneLayout.appendView(sandbox.getModule('nodePane').getView());
+        },
+        
+        nodeChanged: function(attr, value) {
+            sandbox.getModule('documentCanvas').modifyCurrentNode(attr, value);
+        }
+    };
+    
+    eventHandlers.metadataEditor = {
+        ready: function() {
+            sandbox.getModule('metadataEditor').setDocument(sandbox.getModule('data').getDocument());
+            views.visualEditingSidebar.addTab({icon: 'info-sign'}, 'metadataEditor', sandbox.getModule('metadataEditor').getView());
+        },
+        metadataChanged: function(metadata) {
+            dirty.metadataEditor = true;
+        },
+        metadataSet: function() {
+            dirty.metadataEditor = false;
+        },
+    };
+    
+    eventHandlers.nodeFamilyTree = {
+        ready: function() {
+            views.currentNodePaneLayout.appendView(sandbox.getModule('nodeFamilyTree').getView());
+        },
+        nodeEntered: function(canvasNode) {
+            commands.highlightDocumentNode(canvasNode, 'nodeFamilyTree');
+        },
+        nodeLeft: function(canvasNode) {
+            commands.dimDocumentNode(canvasNode, 'nodeFamilyTree');
+        },
+        nodeSelected: function(canvasNode) {
+            commands.selectNode(canvasNode);
+        }
+    };
+    
+    eventHandlers.documentToolbar = {
+        ready: function() {
+            views.visualEditing.setView('toolbar', sandbox.getModule('documentToolbar').getView());
+        },
+        toggleGrid: function(toggle) {
+            sandbox.getModule('documentCanvas').toggleGrid(toggle);
+        },
+        newNodeRequested: function(wlxmlTag, wlxmlClass) {
+                sandbox.getModule('documentCanvas').insertNewNode(wlxmlTag, wlxmlClass);
+        },
+        command: function(cmd, meta) {
+            sandbox.getModule('documentCanvas').command(cmd, meta);
+        }
+    };
+    
+    eventHandlers.nodeBreadCrumbs = {
+        ready: function() {
+            views.visualEditing.setView('statusBar', sandbox.getModule('nodeBreadCrumbs').getView());
+        },
+        nodeHighlighted: function(canvasNode) {
+            commands.highlightDocumentNode(canvasNode, 'nodeBreadCrumbs');
+        },
+        nodeDimmed: function(canvasNode) {
+            commands.dimDocumentNode(canvasNode, 'nodeBreadCrumbs');
+        },
+        nodeSelected: function(canvasNode) {
+            commands.selectNode(canvasNode);
+        }        
+    };
+    
+    eventHandlers.documentHistory = {
+        ready: function() {
+            sandbox.getModule('documentHistory').addHistory(sandbox.getModule('data').getHistory());
+            views.diffLayout.setView('left', sandbox.getModule('documentHistory').getView());
+        },
+        compare: function(ver1, ver2) {
+            sandbox.getModule('data').fetchDiff(ver1, ver2);
+        },
+        restoreVersion: function(event) {
+            sandbox.getModule('data').restoreVersion(event);
+        },
+        displayVersion: function(event) {
+            window.open('/' + gettext('editor') + '/' + sandbox.getModule('data').getDocumentId() + '?version=' + event.version, _.uniqueId());
+        }
+    };
+    
+    eventHandlers.diffViewer = {
+        ready: function() {
+            views.diffLayout.setView('right', sandbox.getModule('diffViewer').getView());
+        }
+    };
+    
+    /* api */
+    
+    return {
+        start: function() {
+            sandbox.getModule('data').start();
+        },
+        handleEvent: function(moduleName, eventName, args) {
+            if('')
+                wysiwigHandler.handleEvent(moduleName, eventName, args);
+            else if(eventHandlers[moduleName] && eventHandlers[moduleName][eventName]) {
+                eventHandlers[moduleName][eventName].apply(eventHandlers, args);
+            }
+        }
+    };
+};
+
 });
\ No newline at end of file
 });
\ No newline at end of file
index 79ae6a2..196be1f 100644 (file)
@@ -1,3 +1,3 @@
-@import 'mainLayout.less';\r
-@import 'editingLayout.less';\r
+@import 'mainLayout.less';
+@import 'editingLayout.less';
 @import 'diffLayout.less';
\ No newline at end of file
 @import 'diffLayout.less';
\ No newline at end of file
index 1c18e75..2fca370 100644 (file)
@@ -1,37 +1,37 @@
-define(function() {\r
-\r
-'use strict';\r
-\r
-return function(sandbox) {\r
-\r
-    var view = $(sandbox.getTemplate('main')());\r
-    \r
-    var editor = ace.edit(view.find('#rng-sourceEditor-editor')[0]);\r
-    editor.setTheme("ace/theme/chrome");\r
-    editor.getSession().setMode("ace/mode/xml");\r
-    $('textarea', view).on('keyup', function() {\r
-        sandbox.publish('xmlChanged');\r
-    });\r
-    \r
-    editor.getSession().on('change', function() {\r
-        sandbox.publish('xmlChanged');\r
-    });\r
-    return {\r
-        start: function() {\r
-            sandbox.publish('ready');\r
-        },\r
-        getView: function() {\r
-            return view;\r
-        },\r
-        setDocument: function(document) {\r
-            editor.setValue(document);\r
-            editor.gotoLine(0);\r
-            sandbox.publish('documentSet');\r
-        },\r
-        getDocument: function() {\r
-            return editor.getValue();\r
-        }\r
-    };\r
-};\r
-\r
+define(function() {
+
+'use strict';
+
+return function(sandbox) {
+
+    var view = $(sandbox.getTemplate('main')());
+    
+    var editor = ace.edit(view.find('#rng-sourceEditor-editor')[0]);
+    editor.setTheme("ace/theme/chrome");
+    editor.getSession().setMode("ace/mode/xml");
+    $('textarea', view).on('keyup', function() {
+        sandbox.publish('xmlChanged');
+    });
+    
+    editor.getSession().on('change', function() {
+        sandbox.publish('xmlChanged');
+    });
+    return {
+        start: function() {
+            sandbox.publish('ready');
+        },
+        getView: function() {
+            return view;
+        },
+        setDocument: function(document) {
+            editor.setValue(document);
+            editor.gotoLine(0);
+            sandbox.publish('documentSet');
+        },
+        getDocument: function() {
+            return editor.getValue();
+        }
+    };
+};
+
 });
\ No newline at end of file
 });
\ No newline at end of file
index 47ebeec..003ee6e 100644 (file)
@@ -1,7 +1,7 @@
-#rng-sourceEditor-editor {\r
-    position: absolute;\r
-    top: 0;\r
-    bottom: 0;\r
-    left: 0;\r
-    right: 0;\r
+#rng-sourceEditor-editor {
+    position: absolute;
+    top: 0;
+    bottom: 0;
+    left: 0;
+    right: 0;
 }
\ No newline at end of file
 }
\ No newline at end of file
index e7767a3..00e1525 100644 (file)
@@ -1,10 +1,10 @@
-body {\r
-    padding-top: 5px;\r
-}\r
-\r
-.rng-common-hoveredNode {\r
-    border-color: red !important;\r
-    border-style:solid;\r
-    border-width:1px;\r
-}\r
-\r
+body {
+    padding-top: 5px;
+}
+
+.rng-common-hoveredNode {
+    border-color: red !important;
+    border-style:solid;
+    border-width:1px;
+}
+
index da38074..48fcda9 100644 (file)
@@ -1,15 +1,15 @@
-@import 'mixins.less';\r
-@import 'common.less';\r
-\r
-@import '../modules/data/data.less';\r
-@import '../modules/rng/rng.less';\r
-@import '../modules/documentCanvas/documentCanvas.less';\r
-@import '../modules/sourceEditor/sourceEditor.less';\r
-@import '../modules/mainBar/mainBar.less';\r
-@import '../modules/documentToolbar/documentToolbar.less';\r
-@import '../modules/documentHistory/documentHistory.less';\r
-@import '../modules/indicator/indicator.less';\r
-@import '../modules/nodePane/nodePane.less';\r
-@import '../modules/nodeFamilyTree/nodeFamilyTree.less';\r
-@import '../modules/metadataEditor/metadataEditor.less';\r
-@import '../modules/diffViewer/diffViewer.less';\r
+@import 'mixins.less';
+@import 'common.less';
+
+@import '../modules/data/data.less';
+@import '../modules/rng/rng.less';
+@import '../modules/documentCanvas/documentCanvas.less';
+@import '../modules/sourceEditor/sourceEditor.less';
+@import '../modules/mainBar/mainBar.less';
+@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';
index d2c08f4..3a14f31 100644 (file)
@@ -1,20 +1,20 @@
-.rng-mixin-scrollbar {\r
-    width: 9px;\r
-}\r
-\r
-.rng-mixin-scrollbar-track {\r
-    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3); \r
-    -webkit-border-radius: 10px;\r
-    border-radius: 10px;\r
-}\r
-\r
-.rng-mixin-scrollbar-thumb {\r
-    -webkit-border-radius: 10px;\r
-    border-radius: 10px;\r
-    background: rgba(73,175,205,0.8); \r
-    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5); \r
-}\r
-\r
-.rng-mixin-scrollbar-thumb-window-inactive {\r
-    background: rgba(73,175,205,0.4); \r
+.rng-mixin-scrollbar {
+    width: 9px;
+}
+
+.rng-mixin-scrollbar-track {
+    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3); 
+    -webkit-border-radius: 10px;
+    border-radius: 10px;
+}
+
+.rng-mixin-scrollbar-thumb {
+    -webkit-border-radius: 10px;
+    border-radius: 10px;
+    background: rgba(73,175,205,0.8); 
+    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5); 
+}
+
+.rng-mixin-scrollbar-thumb-window-inactive {
+    background: rgba(73,175,205,0.4); 
 }
\ No newline at end of file
 }
\ No newline at end of file
index 9614d72..8e17cdc 100644 (file)
@@ -1,30 +1,30 @@
-(function() {\r
-\r
-    mocha.setup('tdd');\r
-\r
-    var tests = Object.keys(window.__karma__.files).filter(function (file) {\r
-      return /\.test\.js$/.test(file);\r
-    });\r
-\r
-    require({\r
-      baseUrl: '/base/',\r
-      deps: tests,\r
-      callback: window.__karma__.start,\r
-        shim: {\r
-            'libs/jquery-1.9.1.min': {\r
-                exports: '$',\r
-            },\r
-            'libs/underscore-min': {\r
-                exports: '_'\r
-            },\r
-            'libs/bootstrap/js/bootstrap.min': {\r
-                deps: ['libs/jquery-1.9.1.min']\r
-            },\r
-            'libs/backbone-min': {\r
-                exports: 'Backbone',\r
-                deps: ['libs/jquery-1.9.1.min', 'libs/underscore-min']\r
-            }\r
-        }\r
-    });\r
-\r
+(function() {
+
+    mocha.setup('tdd');
+
+    var tests = Object.keys(window.__karma__.files).filter(function (file) {
+      return /\.test\.js$/.test(file);
+    });
+
+    require({
+      baseUrl: '/base/',
+      deps: tests,
+      callback: window.__karma__.start,
+        shim: {
+            'libs/jquery-1.9.1.min': {
+                exports: '$',
+            },
+            'libs/underscore-min': {
+                exports: '_'
+            },
+            'libs/bootstrap/js/bootstrap.min': {
+                deps: ['libs/jquery-1.9.1.min']
+            },
+            'libs/backbone-min': {
+                exports: 'Backbone',
+                deps: ['libs/jquery-1.9.1.min', 'libs/underscore-min']
+            }
+        }
+    });
+
 })();
\ No newline at end of file
 })();
\ No newline at end of file
index 2a0bfb9..8c92b0f 100644 (file)
-define([\r
-'libs/text!./templates/main.html',\r
-'libs/text!./templates/handle.html',\r
-'libs/underscore-min',\r
-'libs/backbone-min',\r
-], function(mainTemplate, handleTemplate, _, Backbone) {\r
-    'use strict';\r
-    \r
-    var View = Backbone.View.extend({\r
-        className: 'rng-view-tabs',\r
-        \r
-        events: {\r
-            'click ul a, i': '_onTabTitleClicked'\r
-        },\r
-        \r
-        initialize: function(options) {\r
-            this.options = options || {};\r
-            this.template = _.template(mainTemplate),\r
-            this.handleTemplate = _.template(handleTemplate);\r
-            this.contents = {};\r
-            this.selectedTab = null;\r
-        },\r
-        \r
-        render: function() {\r
-            this.$el.html(this.template());\r
-            this.nodes = {\r
-                tabBar: this.$('.rng-view-tabs-tabBar'),\r
-                content: this.$('.rng-view-tabs-content')\r
-            };\r
-            \r
-            if(this.options.stacked) {\r
-                this.nodes.tabBar.addClass('nav-stacked nav-pills').removeClass('nav-tabs');\r
-            }\r
-            if(this.options.position === 'right') {\r
-                this.$el.addClass('tabs-right');\r
-                this.nodes.content.addClass('tab-content');\r
-            }\r
-            return this;\r
-        },\r
-        \r
-        addTab: function(title, slug, content) {\r
-            if(this.contents[slug]) {\r
-                this.contents[slug].detach();\r
-            }\r
-            this.contents[slug] = content;\r
-            \r
-            var text = (typeof title === 'string') ? title : (title.text || '');\r
-            var icon = title.icon || null;\r
-            \r
-            if(!this.tabExists(slug))\r
-                this.nodes.tabBar.append(this.handleTemplate({text: text, icon: icon, slug: slug}));\r
-            if(!this.selectedTab)\r
-                this.selectTab(slug);\r
-        },\r
-        \r
-        selectTab: function(slug) {\r
-            if(slug !== this.selectedTab && this.contents[slug]) {\r
-                this.trigger('leaving', this.selectedTab);\r
-                \r
-                if(this.selectedTab) {\r
-                    var toDetach = this.contents[this.selectedTab];\r
-                    if(toDetach.onHide)\r
-                        toDetach.onHide();\r
-                    toDetach.detach();\r
-                }\r
-                this.nodes.content.append(this.contents[slug]);\r
-                if(this.contents[slug].onShow) {\r
-                    this.contents[slug].onShow();\r
-                }\r
-                this.nodes.tabBar.find('.active').removeClass('active');\r
-                this.nodes.tabBar.find('a[href="#'+slug+'"]').parent().addClass('active');\r
-                \r
-                var prevSlug = this.selectedTab;\r
-                this.selectedTab = slug;\r
-                this.trigger('tabSelected', {slug: slug, prevSlug: prevSlug});\r
-            }\r
-        },\r
-        \r
-        getAsView: function() {\r
-            return this.$el;\r
-        },\r
-        \r
-        getCurrentSlug: function() {\r
-            return this.selectedTab;\r
-        },\r
-        \r
-        tabExists: function(slug) {\r
-            return this.nodes.tabBar.find('a[href="#'+ slug + '"]').length > 0;\r
-        },\r
-        \r
-        /* Events */\r
-        \r
-        _onTabTitleClicked: function(e) {\r
-            e.preventDefault();\r
-            var target = $(e.target);\r
-            if(target.is('i'))\r
-                target = target.parent();\r
-            var slug = target.attr('href').substr(1);\r
-            this.selectTab(slug);\r
-        }\r
-    });\r
-\r
-    \r
-    return {\r
-        View: View\r
-    };\r
-    \r
-\r
+define([
+'libs/text!./templates/main.html',
+'libs/text!./templates/handle.html',
+'libs/underscore-min',
+'libs/backbone-min',
+], function(mainTemplate, handleTemplate, _, Backbone) {
+    'use strict';
+    
+    var View = Backbone.View.extend({
+        className: 'rng-view-tabs',
+        
+        events: {
+            'click ul a, i': '_onTabTitleClicked'
+        },
+        
+        initialize: function(options) {
+            this.options = options || {};
+            this.template = _.template(mainTemplate),
+            this.handleTemplate = _.template(handleTemplate);
+            this.contents = {};
+            this.selectedTab = null;
+        },
+        
+        render: function() {
+            this.$el.html(this.template());
+            this.nodes = {
+                tabBar: this.$('.rng-view-tabs-tabBar'),
+                content: this.$('.rng-view-tabs-content')
+            };
+            
+            if(this.options.stacked) {
+                this.nodes.tabBar.addClass('nav-stacked nav-pills').removeClass('nav-tabs');
+            }
+            if(this.options.position === 'right') {
+                this.$el.addClass('tabs-right');
+                this.nodes.content.addClass('tab-content');
+            }
+            return this;
+        },
+        
+        addTab: function(title, slug, content) {
+            if(this.contents[slug]) {
+                this.contents[slug].detach();
+            }
+            this.contents[slug] = content;
+            
+            var text = (typeof title === 'string') ? title : (title.text || '');
+            var icon = title.icon || null;
+            
+            if(!this.tabExists(slug))
+                this.nodes.tabBar.append(this.handleTemplate({text: text, icon: icon, slug: slug}));
+            if(!this.selectedTab)
+                this.selectTab(slug);
+        },
+        
+        selectTab: function(slug) {
+            if(slug !== this.selectedTab && this.contents[slug]) {
+                this.trigger('leaving', this.selectedTab);
+                
+                if(this.selectedTab) {
+                    var toDetach = this.contents[this.selectedTab];
+                    if(toDetach.onHide)
+                        toDetach.onHide();
+                    toDetach.detach();
+                }
+                this.nodes.content.append(this.contents[slug]);
+                if(this.contents[slug].onShow) {
+                    this.contents[slug].onShow();
+                }
+                this.nodes.tabBar.find('.active').removeClass('active');
+                this.nodes.tabBar.find('a[href="#'+slug+'"]').parent().addClass('active');
+                
+                var prevSlug = this.selectedTab;
+                this.selectedTab = slug;
+                this.trigger('tabSelected', {slug: slug, prevSlug: prevSlug});
+            }
+        },
+        
+        getAsView: function() {
+            return this.$el;
+        },
+        
+        getCurrentSlug: function() {
+            return this.selectedTab;
+        },
+        
+        tabExists: function(slug) {
+            return this.nodes.tabBar.find('a[href="#'+ slug + '"]').length > 0;
+        },
+        
+        /* Events */
+        
+        _onTabTitleClicked: function(e) {
+            e.preventDefault();
+            var target = $(e.target);
+            if(target.is('i'))
+                target = target.parent();
+            var slug = target.attr('href').substr(1);
+            this.selectTab(slug);
+        }
+    });
+
+    
+    return {
+        View: View
+    };
+    
+
 });
\ No newline at end of file
 });
\ No newline at end of file
index a8f2aca..66efc99 100644 (file)
@@ -1,4 +1,4 @@
-<ul class="rng-view-tabs-tabBar nav nav-tabs">\r
-</ul>\r
-<div class="rng-view-tabs-content">\r
-</div>\r
+<ul class="rng-view-tabs-tabBar nav nav-tabs">
+</ul>
+<div class="rng-view-tabs-content">
+</div>