You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ro...@apache.org on 2014/10/28 17:38:09 UTC

fauxton commit: updated refs/heads/master to 1fdc807

Repository: couchdb-fauxton
Updated Branches:
  refs/heads/master 87a02b0eb -> 1fdc80785


Added constants.js file to core

Closes COUCHDB-2400


Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/1fdc8078
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/1fdc8078
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/1fdc8078

Branch: refs/heads/master
Commit: 1fdc807851e2121004ffcc3ca5b8b68c5d617ec5
Parents: 87a02b0
Author: Benjamin Keen <be...@gmail.com>
Authored: Thu Oct 23 12:51:06 2014 -0700
Committer: Robert Kowalski <ro...@apache.org>
Committed: Tue Oct 28 17:37:43 2014 +0100

----------------------------------------------------------------------
 app/addons/documents/views-queryoptions.js |  4 +-
 app/app.js                                 | 61 +++++++++++++------------
 app/constants.js                           | 20 ++++++++
 app/core/api.js                            | 18 ++++----
 4 files changed, 64 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/1fdc8078/app/addons/documents/views-queryoptions.js
----------------------------------------------------------------------
diff --git a/app/addons/documents/views-queryoptions.js b/app/addons/documents/views-queryoptions.js
index 1b459df..174d2a6 100644
--- a/app/addons/documents/views-queryoptions.js
+++ b/app/addons/documents/views-queryoptions.js
@@ -105,7 +105,7 @@ define([
 
       toggleQueryOptionsTray: function () {
         if (!this.trayIsVisible()) {
-          $("#query-options-tray").velocity("transition.slideDownIn", 250); // TODO constant
+          $("#query-options-tray").velocity("transition.slideDownIn", FauxtonAPI.constants.TRAY_TOGGLE_SPEED);
           FauxtonAPI.Events.trigger("APIbar:closeTray");
 
           // make sure the query button is active again. As we can only expand for completed results, this is sufficient
@@ -197,7 +197,7 @@ define([
       },
 
       closeTray: function () {
-        $("#query-options-tray").velocity("reverse", 250, function () { // TODO constant
+        $("#query-options-tray").velocity("reverse", FauxtonAPI.constants.TRAY_TOGGLE_SPEED, function () {
           $("#query-options-tray").hide();
         });
         this.$('.query-options-btn').removeClass('enabled');

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/1fdc8078/app/app.js
----------------------------------------------------------------------
diff --git a/app/app.js b/app/app.js
index 0d140a4..a4108c5 100644
--- a/app/app.js
+++ b/app/app.js
@@ -11,32 +11,35 @@
 // the License.
 
 define([
-  // Application.
-  "initialize",
-
-  // Libraries
-  "jquery",
-  "lodash",
-  "backbone",
-  "bootstrap",
-
-  "helpers",
-  "core/utils",
-  // Modules
-  "core/api",
-  "core/couchdbSession",
-  // Plugins.
-  "plugins/backbone.layoutmanager",
-  "plugins/jquery.form"
+  // application.
+  'initialize',
+
+  // libraries
+  'jquery',
+  'lodash',
+  'backbone',
+  'bootstrap',
+  'helpers',
+  'constants',
+  'core/utils',
+
+  // modules
+  'core/api',
+  'core/couchdbSession',
+
+  // plugins
+  'plugins/backbone.layoutmanager',
+  'plugins/jquery.form'
 ],
 
-function(app, $, _, Backbone, Bootstrap, Helpers, Utils, FauxtonAPI, Couchdb) {
+function(app, $, _, Backbone, Bootstrap, Helpers, constants, Utils, FauxtonAPI, Couchdb) {
+
   // Make sure we have a console.log
-  if (typeof console == "undefined") {
+  if (_.isUndefined(console)) {
     console = {
-      log: function(){},
-      trace: function(){},
-      debug: function(){}
+      log: function () {},
+      trace: function () {},
+      debug: function () {}
     };
   }
 
@@ -47,15 +50,17 @@ function(app, $, _, Backbone, Bootstrap, Helpers, Utils, FauxtonAPI, Couchdb) {
     getParams: FauxtonAPI.utils.getParams
   });
 
-  // Localize or create a new JavaScript Template object.
+  // Localize or create a new JavaScript Template object
   var JST = window.JST = window.JST || {};
 
-  // Configure LayoutManager with Backbone Boilerplate defaults.
+  // Pass along all constants
+  FauxtonAPI.constants = constants;
+
+  // Configure LayoutManager with Backbone Boilerplate defaults
   FauxtonAPI.Layout.configure({
     // Allow LayoutManager to augment Backbone.View.prototype.
     manage: true,
-
-    prefix: "app/",
+    prefix: 'app/',
 
     // Inject app/helper.js for shared functionality across all html templates
     renderTemplate: function(template, context) {
@@ -67,7 +72,7 @@ function(app, $, _, Backbone, Bootstrap, Helpers, Utils, FauxtonAPI, Couchdb) {
       var done;
 
       // Concatenate the file extension.
-      path = path + ".html";
+      path = path + '.html';
 
       // If cached, use the compiled template.
       if (JST[path]) {
@@ -88,7 +93,7 @@ function(app, $, _, Backbone, Bootstrap, Helpers, Utils, FauxtonAPI, Couchdb) {
   // Define your master router on the application namespace and trigger all
   // navigation from this instance.
   FauxtonAPI.config({
-    el: "#app-container",
+    el: '#app-container',
     masterLayout: new FauxtonAPI.Layout(),
     
     addHeaderLink: function(link) {

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/1fdc8078/app/constants.js
----------------------------------------------------------------------
diff --git a/app/constants.js b/app/constants.js
new file mode 100644
index 0000000..e52e379
--- /dev/null
+++ b/app/constants.js
@@ -0,0 +1,20 @@
+// 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.
+
+define([], function() {
+
+  var constants = {
+    TRAY_TOGGLE_SPEED: 250
+  };
+
+  return constants;
+});

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/1fdc8078/app/core/api.js
----------------------------------------------------------------------
diff --git a/app/core/api.js b/app/core/api.js
index 9007195..a144521 100644
--- a/app/core/api.js
+++ b/app/core/api.js
@@ -11,14 +11,14 @@
 // the License.
 
 define([
-       "core/base",
-       "core/layout",
-       "core/router",
-       "core/routeObject",
-       "core/utils"
+  'core/base',
+  'core/layout',
+  'core/router',
+  'core/routeObject',
+  'core/utils'
 ],
 
-function(FauxtonAPI, Layout, Router, RouteObject, utils) {
+function(FauxtonAPI, Layout, Router, RouteObject, utils, constants) {
   FauxtonAPI = _.extend(FauxtonAPI, {
     Layout: Layout,
     Router: Router,
@@ -28,7 +28,7 @@ function(FauxtonAPI, Layout, Router, RouteObject, utils) {
 
   FauxtonAPI.Events = _.extend({}, Backbone.Events);
 
-  FauxtonAPI.navigate = function(url, _opts) {
+  FauxtonAPI.navigate = function (url, _opts) {
     var options = _.extend({trigger: true}, _opts );
     FauxtonAPI.router.navigate(url,options);
   };
@@ -41,12 +41,12 @@ function(FauxtonAPI, Layout, Router, RouteObject, utils) {
     FauxtonAPI.router.removeBeforeUnload.apply(FauxtonAPI.router, arguments);
   };
 
-  FauxtonAPI.addRoute = function(route) {
+  FauxtonAPI.addRoute = function (route) {
     FauxtonAPI.router.route(route.route, route.name, route.callback);
   };
 
   FauxtonAPI.triggerRouteEvent = function (routeEvent, args) {
-    FauxtonAPI.router.triggerRouteEvent("route:"+routeEvent, args);
+    FauxtonAPI.router.triggerRouteEvent("route:" + routeEvent, args);
   };