First working version
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/8f4b1e49 Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/8f4b1e49 Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/8f4b1e49 Branch: refs/heads/fauxton-file-reorder Commit: 8f4b1e49c7f173fc968d405c16242678e5b239e4 Parents: 0fdccca Author: Garren Smith <[email protected]> Authored: Wed Jan 15 15:33:07 2014 +0200 Committer: Garren Smith <[email protected]> Committed: Mon Jan 27 08:41:30 2014 +0200 ---------------------------------------------------------------------- src/fauxton/app/addons/documents/views.js | 2 +- src/fauxton/app/addons/fauxton/base.js | 68 ++++++++++++-- src/fauxton/app/addons/fauxton/layout.js | 15 +--- src/fauxton/app/addons/fauxton/resizeColumns.js | 87 ++++++++++++++++++ src/fauxton/app/addons/fauxton/resizeCoumns.js | 87 ------------------ src/fauxton/app/app.js | 91 +++++-------------- src/fauxton/app/core/api.js | 30 +++---- src/fauxton/app/core/base.js | 1 - src/fauxton/app/core/resources.js | 18 +--- src/fauxton/app/core/utils.js | 94 ++++++++++++++++++++ src/fauxton/app/main.js | 10 ++- src/fauxton/app/router.js | 4 +- src/fauxton/app/utils.js | 66 -------------- src/fauxton/settings.json.default | 1 + 14 files changed, 291 insertions(+), 283 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/8f4b1e49/src/fauxton/app/addons/documents/views.js ---------------------------------------------------------------------- diff --git a/src/fauxton/app/addons/documents/views.js b/src/fauxton/app/addons/documents/views.js index d5319f3..451b1e9 100644 --- a/src/fauxton/app/addons/documents/views.js +++ b/src/fauxton/app/addons/documents/views.js @@ -21,7 +21,7 @@ define([ "addons/pouchdb/base", // Libs - "resizeColumns", + "addons/Fauxton/resizeColumns", // Plugins "plugins/prettify" http://git-wip-us.apache.org/repos/asf/couchdb/blob/8f4b1e49/src/fauxton/app/addons/fauxton/base.js ---------------------------------------------------------------------- diff --git a/src/fauxton/app/addons/fauxton/base.js b/src/fauxton/app/addons/fauxton/base.js index e2b8c5d..ee6b794 100644 --- a/src/fauxton/app/addons/fauxton/base.js +++ b/src/fauxton/app/addons/fauxton/base.js @@ -11,13 +11,62 @@ // the License. define([ + "app", "api", "addons/fauxton/resizeColumns" ], -function(FauxtonAPI, resizeColumns) { +function(app, FauxtonAPI, resizeColumns) { - var Fauxton = {}; + var Fauxton = FauxtonAPI.addon(); + FauxtonAPI.addNotification = function (options) { + options = _.extend({ + msg: "Notification Event Triggered!", + type: "info", + selector: "#global-notifications" + }, options); + + var view = new Fauxton.Notification(options); + return view.renderNotification(); + }; + + Fauxton.initialize = function () { + app.footer = new Fauxton.Footer({el: "#footer-content"}), + app.navBar = new Fauxton.NavBar(); + app.apiBar = new Fauxton.ApiBar(); + + FauxtonAPI.when.apply(null, app.footer.establish()).done(function() { + FauxtonAPI.masterLayout.layout.setView("#primary-navbar", app.navBar); + FauxtonAPI.masterLayout.layout.setView("#api-navbar", app.apiBar); + app.navBar.render(); + app.apiBar.render(); + + app.footer.render(); + }); + + FauxtonAPI.masterLayout.navBar = app.navBar; + FauxtonAPI.masterLayout.apiBar = app.apiBar; + + FauxtonAPI.RouteObject.on('beforeFullRender', function (routeObject) { + $('#primary-navbar li').removeClass('active'); + + if (routeObject.selectedHeader) { + app.selectedHeader = routeObject.selectedHeader; + $('#primary-navbar li[data-nav-name="' + routeObject.selectedHeader + '"]').addClass('active'); + } + }); + + FauxtonAPI.RouteObject.on('beforeEstablish', function (routeObject) { + FauxtonAPI.masterLayout.clearBreadcrumbs(); + var crumbs = routeObject.get('crumbs'); + + if (crumbs.length) { + FauxtonAPI.masterLayout.setBreadcrumbs(new Fauxton.Breadcrumbs({ + crumbs: crumbs + })); + } + }); + }; Fauxton.Breadcrumbs = Backbone.View.extend({ template: "templates/fauxton/breadcrumbs", @@ -36,7 +85,7 @@ function(FauxtonAPI, resizeColumns) { Fauxton.VersionInfo = Backbone.Model.extend({ url: function () { - return FauxtonAPI.host; + return app.host; } }); @@ -73,10 +122,12 @@ function(FauxtonAPI, resizeColumns) { footerNavLinks: [], initialize: function () { + _.bindAll(this); //resizeAnimation this.resizeColumns = new resizeColumns({}); this.resizeColumns.onResizeHandler(); - + + FauxtonAPI.extensions.on('add:navbar:addHeaderLink', this.addLink); }, serialize: function() { @@ -102,6 +153,8 @@ function(FauxtonAPI, resizeColumns) { } else { this.navLinks.push(link); } + + //this.render(); }, removeLink: function (removeLink) { @@ -127,7 +180,6 @@ function(FauxtonAPI, resizeColumns) { }, afterRender: function(){ - $('#primary-navbar li[data-nav-name="' + app.selectedHeader + '"]').addClass('active'); var menuOpen = true; @@ -146,13 +198,14 @@ function(FauxtonAPI, resizeColumns) { menuOpen = $selectorList.hasClass('closeMenu'); this.resizeColumns.onResizeHandler(); } - + + var that = this; $('#primary-navbar').on("click", ".nav a", function(){ if (!($selectorList.hasClass('closeMenu'))){ setTimeout( function(){ $selectorList.addClass('closeMenu'); - this.resizeColumns.onResizeHandler(); + that.resizeColumns.onResizeHandler(); },3000); } @@ -268,6 +321,5 @@ function(FauxtonAPI, resizeColumns) { } }); - return Fauxton; }); http://git-wip-us.apache.org/repos/asf/couchdb/blob/8f4b1e49/src/fauxton/app/addons/fauxton/layout.js ---------------------------------------------------------------------- diff --git a/src/fauxton/app/addons/fauxton/layout.js b/src/fauxton/app/addons/fauxton/layout.js index 1422241..3810c84 100644 --- a/src/fauxton/app/addons/fauxton/layout.js +++ b/src/fauxton/app/addons/fauxton/layout.js @@ -20,25 +20,12 @@ function(Backbone) { // navBar -> the top navigation bar // dashboardContent -> Main display view // breadcrumbs -> Breadcrumbs navigation section - var Layout = function (navBar, apiBar) { - this.navBar = navBar; - this.apiBar = apiBar; - + var Layout = function () { this.layout = new Backbone.Layout({ template: "templates/layouts/with_sidebar", - - views: { - "#primary-navbar": this.navBar, - "#api-navbar": this.apiBar - }, - afterRender: function(){ - - } }); this.layoutViews = {}; - //this.hooks = {}; - this.el = this.layout.el; }; http://git-wip-us.apache.org/repos/asf/couchdb/blob/8f4b1e49/src/fauxton/app/addons/fauxton/resizeColumns.js ---------------------------------------------------------------------- diff --git a/src/fauxton/app/addons/fauxton/resizeColumns.js b/src/fauxton/app/addons/fauxton/resizeColumns.js new file mode 100644 index 0000000..abfcd2f --- /dev/null +++ b/src/fauxton/app/addons/fauxton/resizeColumns.js @@ -0,0 +1,87 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); you may not +// use this file except in compliance with the License. You may obtain a copy of +// the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations under +// the License. + + +// This file creates a set of helper functions that will be loaded for all html +// templates. These functions should be self contained and not rely on any +// external dependencies as they are loaded prior to the application. We may +// want to change this later, but for now this should be thought of as a +// "purely functional" helper system. + +define([ + "api" +], + +function(FauxtonAPI) { + + var Resize = function(options){ + this.options = options; + this.options.selectorElements = options.selectorElements || ".window-resizeable"; + }; + + Resize.prototype = { + getPrimaryNavWidth: function(){ + var primaryNavWidth = $('body').hasClass('closeMenu')? 64:224; + return primaryNavWidth; + }, + getPanelWidth: function(){ + var sidebarWidth = $('#sidebar-content').length > 0 ? $('#sidebar-content').width(): 0; + return (this.getPrimaryNavWidth() + sidebarWidth); + }, + initialize: function(){ + // $(window).off('resize'); + var that = this; + //add throttler :) + this.lazyLayout = _.debounce(that.onResizeHandler, 300).bind(this); + FauxtonAPI.utils.addWindowResize(this.lazyLayout,"animation"); + FauxtonAPI.utils.initWindowResize(); + this.onResizeHandler(); + }, + updateOptions:function(options){ + this.options = {}; + this.options = options; + this.options.selectorElements = options.selectorElements || ".window-resizeable"; + }, + turnOff:function(){ + FauxtonAPI.utils.removeWindowResize("animation"); + }, + cleanupCallback: function(){ + this.callback = null; + }, + onResizeHandler: function (){ + //if there is an override, do that instead + if (this.options.onResizeHandler){ + this.options.onResizeHandler(); + } else { + var combinedWidth = window.innerWidth - this.getPanelWidth(), + smallWidthConstraint = ($('#sidebar-content').length > 0)? 470:800, + panelWidth; + + if( combinedWidth > smallWidthConstraint && combinedWidth < 1400){ + panelWidth = window.innerWidth - this.getPanelWidth(); + } else if (combinedWidth < smallWidthConstraint){ + panelWidth = smallWidthConstraint; + } else if(combinedWidth > 1400){ + panelWidth = 1400; + } + + $(this.options.selectorElements).innerWidth(panelWidth); + } + //if there is a callback, run that + if(this.options.callback) { + this.options.callback(); + } + } + }; + + return Resize; +}); http://git-wip-us.apache.org/repos/asf/couchdb/blob/8f4b1e49/src/fauxton/app/addons/fauxton/resizeCoumns.js ---------------------------------------------------------------------- diff --git a/src/fauxton/app/addons/fauxton/resizeCoumns.js b/src/fauxton/app/addons/fauxton/resizeCoumns.js deleted file mode 100644 index bb50767..0000000 --- a/src/fauxton/app/addons/fauxton/resizeCoumns.js +++ /dev/null @@ -1,87 +0,0 @@ -// Licensed under the Apache License, Version 2.0 (the "License"); you may not -// use this file except in compliance with the License. You may obtain a copy of -// the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -// License for the specific language governing permissions and limitations under -// the License. - - -// This file creates a set of helper functions that will be loaded for all html -// templates. These functions should be self contained and not rely on any -// external dependencies as they are loaded prior to the application. We may -// want to change this later, but for now this should be thought of as a -// "purely functional" helper system. - -define([ - "utils" -], - -function(utils) { - - var Resize = function(options){ - this.options = options; - this.options.selectorElements = options.selectorElements || ".window-resizeable"; - }; - - Resize.prototype = { - getPrimaryNavWidth: function(){ - var primaryNavWidth = $('body').hasClass('closeMenu')? 64:224; - return primaryNavWidth; - }, - getPanelWidth: function(){ - var sidebarWidth = $('#sidebar-content').length > 0 ? $('#sidebar-content').width(): 0; - return (this.getPrimaryNavWidth() + sidebarWidth); - }, - initialize: function(){ - // $(window).off('resize'); - var that = this; - //add throttler :) - this.lazyLayout = _.debounce(that.onResizeHandler, 300).bind(this); - utils.addWindowResize(this.lazyLayout,"animation"); - utils.initWindowResize(); - this.onResizeHandler(); - }, - updateOptions:function(options){ - this.options = {}; - this.options = options; - this.options.selectorElements = options.selectorElements || ".window-resizeable"; - }, - turnOff:function(){ - utils.removeWindowResize("animation"); - }, - cleanupCallback: function(){ - this.callback = null; - }, - onResizeHandler: function (){ - //if there is an override, do that instead - if (this.options.onResizeHandler){ - this.options.onResizeHandler(); - } else { - var combinedWidth = window.innerWidth - this.getPanelWidth(), - smallWidthConstraint = ($('#sidebar-content').length > 0)? 470:800, - panelWidth; - - if( combinedWidth > smallWidthConstraint && combinedWidth < 1400){ - panelWidth = window.innerWidth - this.getPanelWidth(); - } else if (combinedWidth < smallWidthConstraint){ - panelWidth = smallWidthConstraint; - } else if(combinedWidth > 1400){ - panelWidth = 1400; - } - - $(this.options.selectorElements).innerWidth(panelWidth); - } - //if there is a callback, run that - if(this.options.callback) { - this.options.callback(); - } - } - }; - - return Resize; -}); http://git-wip-us.apache.org/repos/asf/couchdb/blob/8f4b1e49/src/fauxton/app/app.js ---------------------------------------------------------------------- diff --git a/src/fauxton/app/app.js b/src/fauxton/app/app.js index 3b25be8..23a72c7 100644 --- a/src/fauxton/app/app.js +++ b/src/fauxton/app/app.js @@ -21,90 +21,33 @@ define([ "bootstrap", "helpers", - "utils", + "core/utils", // Modules - "resizeColumns", "core/api", - "addons/fauxton/base", - // Plugins. + "addons/Fauxton/layout", + // Plugins. "plugins/backbone.layoutmanager", "plugins/jquery.form" ], -function(app, $, _, Backbone, Bootstrap, Helpers, Utils, resizeColumns, FauxtonAPI, Fauxton) { - - // Make sure we have a console.log +function(app, $, _, Backbone, Bootstrap, Helpers, Utils, FauxtonAPI, Layout, LoadAddons) { + // Make sure we have a console.log if (typeof console == "undefined") { console = { - log: function(){} + log: function(){}, + trace: function(){}, + debug: function(){} }; } // Provide a global location to place configuration settings and module // creation also mix in Backbone.Events - _.extend(app, Backbone.Events, { + _.extend(app, { utils: Utils, - - // Thanks to: http://stackoverflow.com/a/2880929 - getParams: function(queryString) { - if (queryString) { - // I think this could be combined into one if - if (queryString.substring(0,1) === "?") { - queryString = queryString.substring(1); - } else if (queryString.indexOf('?') > -1) { - queryString = queryString.split('?')[1]; - } - } - var hash = window.location.hash.split('?')[1]; - queryString = queryString || hash || window.location.search.substring(1); - var match, - urlParams = {}, - pl = /\+/g, // Regex for replacing addition symbol with a space - search = /([^&=]+)=?([^&]*)/g, - decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); }, - query = queryString; - - if (queryString) { - while ((match = search.exec(query))) { - urlParams[decode(match[1])] = decode(match[2]); - } - } - - return urlParams; - } - + getParams: FauxtonAPI.utils.getParams }); - //MOVE THIS ELSEWHERE - app.footer = new Fauxton.Footer({el: "#footer-content"}); - // TODO: move this to a proper Fauxton.View - $.when.apply(null, app.footer.establish()).done(function() { - app.footer.render(); - }); - app.navBar = new Fauxton.NavBar(); - app.apiBar = new Fauxton.ApiBar(); - // Define your master router on the application namespace and trigger all - // navigation from this instance. - app.router = new FauxtonAPI.Router(); - FauxtonAPI.config({ - router: app.router, - masterLayout: new Layout(app.navBar, app.apiBar), - addNotification: function (options) { - options = _.extend({ - msg: "Notification Event Triggered!", - type: "info", - selector: "#global-notifications" - }, options); - - var view = new Fauxton.Notification(options); - return view.renderNotification(); - } - }); - // Trigger the initial route and enable HTML5 History API support, set the - // root folder to '/' by default. Change in app.js. - Backbone.history.start({ pushState: false, root: app.root }); - // Localize or create a new JavaScript Template object. var JST = window.JST = window.JST || {}; @@ -141,6 +84,20 @@ function(app, $, _, Backbone, Bootstrap, Helpers, Utils, resizeColumns, FauxtonA } }); + // Define your master router on the application namespace and trigger all + // navigation from this instance. + FauxtonAPI.config({ + el: "#app-container", + masterLayout: new Layout(), + + addHeaderLink: function(link) { + FauxtonAPI.registerExtension('navbar:addHeaderLink', link); + }, + + removeHeaderLink: function(link) { + // TODO add remove to extensions + } + }); return app; }); http://git-wip-us.apache.org/repos/asf/couchdb/blob/8f4b1e49/src/fauxton/app/core/api.js ---------------------------------------------------------------------- diff --git a/src/fauxton/app/core/api.js b/src/fauxton/app/core/api.js index 5f5cbf8..81e9aa4 100644 --- a/src/fauxton/app/core/api.js +++ b/src/fauxton/app/core/api.js @@ -12,11 +12,11 @@ define([ "core/resources", - // Modules + "core/utils" ], -function(FauxtonAPI, Fauxton) { - +function(FauxtonAPI, utils) { + FauxtonAPI.utils = utils; FauxtonAPI.navigate = function(url, _opts) { var options = _.extend({trigger: true}, _opts ); FauxtonAPI.router.navigate(url,options); @@ -30,14 +30,6 @@ function(FauxtonAPI, Fauxton) { FauxtonAPI.router.removeBeforeUnload.apply(FauxtonAPI.router, arguments); }; - FauxtonAPI.addHeaderLink = function(link) { - FauxtonAPI.masterLayout.navBar.addLink(link); - }; - - FauxtonAPI.removeHeaderLink = function(link) { - FauxtonAPI.masterLayout.navBar.removeLink(link); - }; - FauxtonAPI.addRoute = function(route) { FauxtonAPI.router.route(route.route, route.name, route.callback); }; @@ -83,7 +75,7 @@ function(FauxtonAPI, Fauxton) { this.route(route, route.toString(), function() { var args = Array.prototype.slice.call(arguments), roles = RouteObject.prototype.getRouteRoles(route), - authPromise = app.auth.checkAccess(roles); + authPromise = FauxtonAPI.auth.checkAccess(roles); authPromise.then(function () { if (!that.activeRouteObject || !that.activeRouteObject.hasRoute(route)) { @@ -104,8 +96,8 @@ function(FauxtonAPI, Fauxton) { }, this); }, - setModuleRoutes: function() { - _.each(LoadAddons.addons, function(module) { + setModuleRoutes: function(addons) { + _.each(addons, function(module) { if (module){ module.initialize(); // This is pure routes the addon provides @@ -116,14 +108,14 @@ function(FauxtonAPI, Fauxton) { }, this); }, - initialize: function() { - //TODO: It would be nice to handle this with a router - this.auth = app.auth = FauxtonAPI.auth; + initialize: function(addons) { + this.addons = addons; + this.auth = FauxtonAPI.auth; // NOTE: This must be below creation of the layout // FauxtonAPI header links and others depend on existence of the layout - this.setModuleRoutes(); + this.setModuleRoutes(addons); - $("#app-container").html(FauxtonAPI.masterLayout.el); + $(FauxtonAPI.el).html(FauxtonAPI.masterLayout.el); FauxtonAPI.masterLayout.render(); }, http://git-wip-us.apache.org/repos/asf/couchdb/blob/8f4b1e49/src/fauxton/app/core/base.js ---------------------------------------------------------------------- diff --git a/src/fauxton/app/core/base.js b/src/fauxton/app/core/base.js index f9bb065..4601386 100644 --- a/src/fauxton/app/core/base.js +++ b/src/fauxton/app/core/base.js @@ -109,7 +109,6 @@ function() { FauxtonAPI.extensions = extensions; - return FauxtonAPI; }); http://git-wip-us.apache.org/repos/asf/couchdb/blob/8f4b1e49/src/fauxton/app/core/resources.js ---------------------------------------------------------------------- diff --git a/src/fauxton/app/core/resources.js b/src/fauxton/app/core/resources.js index 249d7fc..3a29077 100644 --- a/src/fauxton/app/core/resources.js +++ b/src/fauxton/app/core/resources.js @@ -13,10 +13,9 @@ define([ "app", "core/couchdbSession", - "addons/fauxton/base", "backbone" ], -function(app, FauxtonAPI, Fauxton) { +function(app, FauxtonAPI) { // This is not exposed externally as it should not need to be accessed or overridden var Auth = function (options) { @@ -139,21 +138,6 @@ function(app, FauxtonAPI, Fauxton) { if (!this.renderedState) { masterLayout.setTemplate(this.layout); triggerBroadcast('beforeFullRender'); - $('#primary-navbar li').removeClass('active'); - - if (this.selectedHeader) { - app.selectedHeader = this.selectedHeader; - $('#primary-navbar li[data-nav-name="' + this.selectedHeader + '"]').addClass('active'); - } - } - - masterLayout.clearBreadcrumbs(); - var crumbs = this.get('crumbs'); - - if (crumbs.length) { - masterLayout.setBreadcrumbs(new Fauxton.Breadcrumbs({ - crumbs: crumbs - })); } triggerBroadcast('beforeEstablish'); http://git-wip-us.apache.org/repos/asf/couchdb/blob/8f4b1e49/src/fauxton/app/core/utils.js ---------------------------------------------------------------------- diff --git a/src/fauxton/app/core/utils.js b/src/fauxton/app/core/utils.js new file mode 100644 index 0000000..44945e8 --- /dev/null +++ b/src/fauxton/app/core/utils.js @@ -0,0 +1,94 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); you may not +// use this file except in compliance with the License. You may obtain a copy of +// the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations under +// the License. + + +// This file creates a set of helper functions that will be loaded for all html +// templates. These functions should be self contained and not rely on any +// external dependencies as they are loaded prior to the application. We may +// want to change this later, but for now this should be thought of as a +// "purely functional" helper system. + + +define([ + "jquery", + "lodash" +], + +function($, _ ) { + + var onWindowResize = {}; + + var utils = { + // Thanks to: http://stackoverflow.com/a/2880929 + getParams: function(queryString) { + if (queryString) { + // I think this could be combined into one if + if (queryString.substring(0,1) === "?") { + queryString = queryString.substring(1); + } else if (queryString.indexOf('?') > -1) { + queryString = queryString.split('?')[1]; + } + } + var hash = window.location.hash.split('?')[1]; + queryString = queryString || hash || window.location.search.substring(1); + var match, + urlParams = {}, + pl = /\+/g, // Regex for replacing addition symbol with a space + search = /([^&=]+)=?([^&]*)/g, + decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); }, + query = queryString; + + if (queryString) { + while ((match = search.exec(query))) { + urlParams[decode(match[1])] = decode(match[2]); + } + } + + return urlParams; + }, + + addWindowResize: function(fun, key){ + onWindowResize[key]=fun; + // You shouldn't need to call it here. Just define it at startup and each time it will loop + // through all the functions in the hash. + //app.initWindowResize(); + }, + + removeWindowResize: function(key){ + delete onWindowResize[key]; + utils.initWindowResize(); + }, + + initWindowResize: function(){ + //when calling this it should be overriding what was called previously + window.onresize = function(e) { + // could do this instead of the above for loop + _.each(onWindowResize, function (fn) { + fn(); + }); + }; + }, + + removeSpecialCharacters: function(name){ + return name.replace(/[^\w\s]/gi,""); + }, + + safeURLName: function(name){ + var testName = name || ""; + var checkforBad = testName.match(/[\$\-/_,+-]/g); + return (checkforBad !== null)?encodeURIComponent(name):name; + } + }; + + return utils; +}); + http://git-wip-us.apache.org/repos/asf/couchdb/blob/8f4b1e49/src/fauxton/app/main.js ---------------------------------------------------------------------- diff --git a/src/fauxton/app/main.js b/src/fauxton/app/main.js index 13b8370..9df15c5 100644 --- a/src/fauxton/app/main.js +++ b/src/fauxton/app/main.js @@ -13,9 +13,17 @@ require([ // Application. "app", + "api", + "load_addons" ], -function(app) { +function(app, FauxtonAPI, LoadAddons) { + + app.addons = LoadAddons.addons; + FauxtonAPI.router = app.router = new FauxtonAPI.Router(app.addons); + // Trigger the initial route and enable HTML5 History API support, set the + // root folder to '/' by default. Change in app.js. + Backbone.history.start({ pushState: false, root: app.root }); // All navigation that is relative should be passed through the navigate // method, to be processed by the router. If the link has a `data-bypass` http://git-wip-us.apache.org/repos/asf/couchdb/blob/8f4b1e49/src/fauxton/app/router.js ---------------------------------------------------------------------- diff --git a/src/fauxton/app/router.js b/src/fauxton/app/router.js index 51b98ea..1e0caac 100644 --- a/src/fauxton/app/router.js +++ b/src/fauxton/app/router.js @@ -25,9 +25,9 @@ define([ "core/api", // Modules - "addons/fauxton/base", + //"addons/fauxton/base", // Layout - "addons/fauxton/layout", + //"addons/fauxton/layout", "load_addons" ], http://git-wip-us.apache.org/repos/asf/couchdb/blob/8f4b1e49/src/fauxton/app/utils.js ---------------------------------------------------------------------- diff --git a/src/fauxton/app/utils.js b/src/fauxton/app/utils.js deleted file mode 100644 index ded7dac..0000000 --- a/src/fauxton/app/utils.js +++ /dev/null @@ -1,66 +0,0 @@ -// Licensed under the Apache License, Version 2.0 (the "License"); you may not -// use this file except in compliance with the License. You may obtain a copy of -// the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -// License for the specific language governing permissions and limitations under -// the License. - - -// This file creates a set of helper functions that will be loaded for all html -// templates. These functions should be self contained and not rely on any -// external dependencies as they are loaded prior to the application. We may -// want to change this later, but for now this should be thought of as a -// "purely functional" helper system. - - -define([ - "jquery", - "lodash" -], - -function($, _ ) { - - var utils = {}; - - var onWindowResize = {}; - - utils.addWindowResize = function(fun, key){ - onWindowResize[key]=fun; - // You shouldn't need to call it here. Just define it at startup and each time it will loop - // through all the functions in the hash. - //app.initWindowResize(); - }; - - utils.removeWindowResize = function(key){ - delete onWindowResize[key]; - utils.initWindowResize(); - }; - - utils.initWindowResize = function(){ - //when calling this it should be overriding what was called previously - window.onresize = function(e) { - // could do this instead of the above for loop - _.each(onWindowResize, function (fn) { - fn(); - }); - }; - }; - - utils.removeSpecialCharacters = function(name){ - return name.replace(/[^\w\s]/gi,""); - }; - - utils.safeURLName = function(name){ - var testName = name || ""; - var checkforBad = testName.match(/[\$\-/_,+-]/g); - return (checkforBad !== null)?encodeURIComponent(name):name; - }; - - return utils; -}); - http://git-wip-us.apache.org/repos/asf/couchdb/blob/8f4b1e49/src/fauxton/settings.json.default ---------------------------------------------------------------------- diff --git a/src/fauxton/settings.json.default b/src/fauxton/settings.json.default index cb09eb2..807f6bf 100644 --- a/src/fauxton/settings.json.default +++ b/src/fauxton/settings.json.default @@ -3,6 +3,7 @@ { "name": "databases" }, { "name": "documents" }, { "name": "pouchdb" }, + { "name": "fauxton" }, { "name": "activetasks" }, { "name": "config" }, { "name": "logs" },
