From: Aleksander Łukasz Date: Mon, 1 Jul 2013 07:48:16 +0000 (+0200) Subject: Converting end of lines from crlf to lf X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/a398f2a96740ebe6dd60559d90e74c648e7009af Converting end of lines from crlf to lf --- diff --git a/entrypoint.js b/entrypoint.js index 6f81c94..f15a832 100644 --- a/entrypoint.js +++ b/entrypoint.js @@ -1,7 +1,7 @@ (function() { 'use strict'; - requirejs.config({ + requirejs.config({ baseUrl: '/static/editor', shim: { @@ -19,7 +19,7 @@ deps: ['libs/jquery-1.9.1.min', 'libs/underscore-min'] } } - + }); requirejs([ diff --git a/fnpjs/layout.js b/fnpjs/layout.js index d5fa098..05252fb 100644 --- a/fnpjs/layout.js +++ b/fnpjs/layout.js @@ -1,37 +1,37 @@ -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}; +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 diff --git a/fnpjs/runner.js b/fnpjs/runner.js index 817011d..d8dcda9 100644 --- a/fnpjs/runner.js +++ b/fnpjs/runner.js @@ -1,77 +1,77 @@ -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 -}; - +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 diff --git a/fnpjs/vbox.js b/fnpjs/vbox.js index 84ac6db..569bf16 100644 --- a/fnpjs/vbox.js +++ b/fnpjs/vbox.js @@ -1,13 +1,13 @@ -define(['libs/jquery-1.9.1.min', './layout'], function($, layout) { - - var VBox = function() {}; - - VBox.prototype = new layout.Layout('
'); - VBox.prototype.appendView = function(view) { - var item = $('
').addClass('fnpjs-vbox-item').append(view); - this.dom.append(item); - }; - - return {VBox: VBox}; - +define(['libs/jquery-1.9.1.min', './layout'], function($, layout) { + + var VBox = function() {}; + + VBox.prototype = new layout.Layout('
'); + VBox.prototype.appendView = function(view) { + var item = $('
').addClass('fnpjs-vbox-item').append(view); + this.dom.append(item); + }; + + return {VBox: VBox}; + }); \ No newline at end of file diff --git a/karma.conf.js b/karma.conf.js index 9f3fa53..5153a22 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,42 +1,42 @@ -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; - - - - - - - - - +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; + + + + + + + + + diff --git a/modules.js b/modules.js index 46d787e..bb4d439 100644 --- a/modules.js +++ b/modules.js @@ -1,28 +1,28 @@ -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') - - } +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 diff --git a/modules/data/data.js b/modules/data/data.js index 8bd553c..9b2f163 100644 --- a/modules/data/data.js +++ b/modules/data/data.js @@ -1,133 +1,133 @@ -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 = '\n\ - \n\ - \n\ -
\n\ - '; - } - - - 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; - } - }; -}; - +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 = '\n\ + \n\ + \n\ +
\n\ + '; + } + + + 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 diff --git a/modules/data/saveDialog.html b/modules/data/saveDialog.html index 496d886..0846910 100644 --- a/modules/data/saveDialog.html +++ b/modules/data/saveDialog.html @@ -1,14 +1,14 @@ -