You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by dj...@apache.org on 2013/08/07 18:04:32 UTC
[01/26] git commit: updated refs/heads/1.4.x to 81b1601
Updated Branches:
refs/heads/1.4.x af7ed0c06 -> 81b1601a3
Add empty line to LICENSE for readability.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/4bd7cadd
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/4bd7cadd
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/4bd7cadd
Branch: refs/heads/1.4.x
Commit: 4bd7caddaaf847732a03a19ecfbf300250b091b2
Parents: af7ed0c
Author: Dirkjan Ochtman <dj...@apache.org>
Authored: Wed Aug 7 17:57:18 2013 +0200
Committer: Dirkjan Ochtman <dj...@apache.org>
Committed: Wed Aug 7 17:57:18 2013 +0200
----------------------------------------------------------------------
LICENSE | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/4bd7cadd/LICENSE
----------------------------------------------------------------------
diff --git a/LICENSE b/LICENSE
index 2426853..3ab16a8 100644
--- a/LICENSE
+++ b/LICENSE
@@ -895,6 +895,7 @@ For the src/couch_dbupdates component
2009-2012 (c) BenoƮt Chesneau <be...@e-engura.org>
Apache 2 License, see above.
+
For src/fauxton/test/mocha/mocha.js and src/fauxton/test/mocha/mocha.js
Copyright (c) 2011-2013 TJ Holowaychuk <tj...@vision-media.ca>
[08/26] Remove fauxton from 1.4.x branch.
Posted by dj...@apache.org.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/test/mocha/chai.js
----------------------------------------------------------------------
diff --git a/src/fauxton/test/mocha/chai.js b/src/fauxton/test/mocha/chai.js
deleted file mode 100644
index 2a67f98..0000000
--- a/src/fauxton/test/mocha/chai.js
+++ /dev/null
@@ -1,4330 +0,0 @@
-;(function(){
-
-/**
- * Require the given path.
- *
- * @param {String} path
- * @return {Object} exports
- * @api public
- */
-
-function require(path, parent, orig) {
- var resolved = require.resolve(path);
-
- // lookup failed
- if (null == resolved) {
- orig = orig || path;
- parent = parent || 'root';
- var err = new Error('Failed to require "' + orig + '" from "' + parent + '"');
- err.path = orig;
- err.parent = parent;
- err.require = true;
- throw err;
- }
-
- var module = require.modules[resolved];
-
- // perform real require()
- // by invoking the module's
- // registered function
- if (!module.exports) {
- module.exports = {};
- module.client = module.component = true;
- module.call(this, module.exports, require.relative(resolved), module);
- }
-
- return module.exports;
-}
-
-/**
- * Registered modules.
- */
-
-require.modules = {};
-
-/**
- * Registered aliases.
- */
-
-require.aliases = {};
-
-/**
- * Resolve `path`.
- *
- * Lookup:
- *
- * - PATH/index.js
- * - PATH.js
- * - PATH
- *
- * @param {String} path
- * @return {String} path or null
- * @api private
- */
-
-require.resolve = function(path) {
- if (path.charAt(0) === '/') path = path.slice(1);
-
- var paths = [
- path,
- path + '.js',
- path + '.json',
- path + '/index.js',
- path + '/index.json'
- ];
-
- for (var i = 0; i < paths.length; i++) {
- var path = paths[i];
- if (require.modules.hasOwnProperty(path)) return path;
- if (require.aliases.hasOwnProperty(path)) return require.aliases[path];
- }
-};
-
-/**
- * Normalize `path` relative to the current path.
- *
- * @param {String} curr
- * @param {String} path
- * @return {String}
- * @api private
- */
-
-require.normalize = function(curr, path) {
- var segs = [];
-
- if ('.' != path.charAt(0)) return path;
-
- curr = curr.split('/');
- path = path.split('/');
-
- for (var i = 0; i < path.length; ++i) {
- if ('..' == path[i]) {
- curr.pop();
- } else if ('.' != path[i] && '' != path[i]) {
- segs.push(path[i]);
- }
- }
-
- return curr.concat(segs).join('/');
-};
-
-/**
- * Register module at `path` with callback `definition`.
- *
- * @param {String} path
- * @param {Function} definition
- * @api private
- */
-
-require.register = function(path, definition) {
- require.modules[path] = definition;
-};
-
-/**
- * Alias a module definition.
- *
- * @param {String} from
- * @param {String} to
- * @api private
- */
-
-require.alias = function(from, to) {
- if (!require.modules.hasOwnProperty(from)) {
- throw new Error('Failed to alias "' + from + '", it does not exist');
- }
- require.aliases[to] = from;
-};
-
-/**
- * Return a require function relative to the `parent` path.
- *
- * @param {String} parent
- * @return {Function}
- * @api private
- */
-
-require.relative = function(parent) {
- var p = require.normalize(parent, '..');
-
- /**
- * lastIndexOf helper.
- */
-
- function lastIndexOf(arr, obj) {
- var i = arr.length;
- while (i--) {
- if (arr[i] === obj) return i;
- }
- return -1;
- }
-
- /**
- * The relative require() itself.
- */
-
- function localRequire(path) {
- var resolved = localRequire.resolve(path);
- return require(resolved, parent, path);
- }
-
- /**
- * Resolve relative to the parent.
- */
-
- localRequire.resolve = function(path) {
- var c = path.charAt(0);
- if ('/' == c) return path.slice(1);
- if ('.' == c) return require.normalize(p, path);
-
- // resolve deps by returning
- // the dep in the nearest "deps"
- // directory
- var segs = parent.split('/');
- var i = lastIndexOf(segs, 'deps') + 1;
- if (!i) i = 0;
- path = segs.slice(0, i + 1).join('/') + '/deps/' + path;
- return path;
- };
-
- /**
- * Check if module is defined at `path`.
- */
-
- localRequire.exists = function(path) {
- return require.modules.hasOwnProperty(localRequire.resolve(path));
- };
-
- return localRequire;
-};
-require.register("chaijs-assertion-error/index.js", function(exports, require, module){
-/*!
- * assertion-error
- * Copyright(c) 2013 Jake Luer <ja...@qualiancy.com>
- * MIT Licensed
- */
-
-/*!
- * Return a function that will copy properties from
- * one object to another excluding any originally
- * listed. Returned function will create a new `{}`.
- *
- * @param {String} excluded properties ...
- * @return {Function}
- */
-
-function exclude () {
- var excludes = [].slice.call(arguments);
-
- function excludeProps (res, obj) {
- Object.keys(obj).forEach(function (key) {
- if (!~excludes.indexOf(key)) res[key] = obj[key];
- });
- }
-
- return function extendExclude () {
- var args = [].slice.call(arguments)
- , i = 0
- , res = {};
-
- for (; i < args.length; i++) {
- excludeProps(res, args[i]);
- }
-
- return res;
- };
-};
-
-/*!
- * Primary Exports
- */
-
-module.exports = AssertionError;
-
-/**
- * ### AssertionError
- *
- * An extension of the JavaScript `Error` constructor for
- * assertion and validation scenarios.
- *
- * @param {String} message
- * @param {Object} properties to include (optional)
- * @param {callee} start stack function (optional)
- */
-
-function AssertionError (message, _props, ssf) {
- var extend = exclude('name', 'message', 'stack', 'constructor', 'toJSON')
- , props = extend(_props || {});
-
- // default values
- this.message = message || 'Unspecified AssertionError';
- this.showDiff = false;
-
- // copy from properties
- for (var key in props) {
- this[key] = props[key];
- }
-
- // capture stack trace
- ssf = ssf || arguments.callee;
- if (ssf && Error.captureStackTrace) {
- Error.captureStackTrace(this, ssf);
- }
-}
-
-/*!
- * Inherit from Error.prototype
- */
-
-AssertionError.prototype = Object.create(Error.prototype);
-
-/*!
- * Statically set name
- */
-
-AssertionError.prototype.name = 'AssertionError';
-
-/*!
- * Ensure correct constructor
- */
-
-AssertionError.prototype.constructor = AssertionError;
-
-/**
- * Allow errors to be converted to JSON for static transfer.
- *
- * @param {Boolean} include stack (default: `true`)
- * @return {Object} object that can be `JSON.stringify`
- */
-
-AssertionError.prototype.toJSON = function (stack) {
- var extend = exclude('constructor', 'toJSON', 'stack')
- , props = extend({ name: this.name }, this);
-
- // include stack if exists and not turned off
- if (false !== stack && this.stack) {
- props.stack = this.stack;
- }
-
- return props;
-};
-
-});
-require.register("chai/index.js", function(exports, require, module){
-module.exports = require('./lib/chai');
-
-});
-require.register("chai/lib/chai.js", function(exports, require, module){
-/*!
- * chai
- * Copyright(c) 2011-2013 Jake Luer <ja...@alogicalparadox.com>
- * MIT Licensed
- */
-
-var used = []
- , exports = module.exports = {};
-
-/*!
- * Chai version
- */
-
-exports.version = '1.7.2';
-
-/*!
- * Assertion Error
- */
-
-exports.AssertionError = require('assertion-error');
-
-/*!
- * Utils for plugins (not exported)
- */
-
-var util = require('./chai/utils');
-
-/**
- * # .use(function)
- *
- * Provides a way to extend the internals of Chai
- *
- * @param {Function}
- * @returns {this} for chaining
- * @api public
- */
-
-exports.use = function (fn) {
- if (!~used.indexOf(fn)) {
- fn(this, util);
- used.push(fn);
- }
-
- return this;
-};
-
-/*!
- * Primary `Assertion` prototype
- */
-
-var assertion = require('./chai/assertion');
-exports.use(assertion);
-
-/*!
- * Core Assertions
- */
-
-var core = require('./chai/core/assertions');
-exports.use(core);
-
-/*!
- * Expect interface
- */
-
-var expect = require('./chai/interface/expect');
-exports.use(expect);
-
-/*!
- * Should interface
- */
-
-var should = require('./chai/interface/should');
-exports.use(should);
-
-/*!
- * Assert interface
- */
-
-var assert = require('./chai/interface/assert');
-exports.use(assert);
-
-});
-require.register("chai/lib/chai/assertion.js", function(exports, require, module){
-/*!
- * chai
- * http://chaijs.com
- * Copyright(c) 2011-2013 Jake Luer <ja...@alogicalparadox.com>
- * MIT Licensed
- */
-
-module.exports = function (_chai, util) {
- /*!
- * Module dependencies.
- */
-
- var AssertionError = _chai.AssertionError
- , flag = util.flag;
-
- /*!
- * Module export.
- */
-
- _chai.Assertion = Assertion;
-
- /*!
- * Assertion Constructor
- *
- * Creates object for chaining.
- *
- * @api private
- */
-
- function Assertion (obj, msg, stack) {
- flag(this, 'ssfi', stack || arguments.callee);
- flag(this, 'object', obj);
- flag(this, 'message', msg);
- }
-
- /*!
- * ### Assertion.includeStack
- *
- * User configurable property, influences whether stack trace
- * is included in Assertion error message. Default of false
- * suppresses stack trace in the error message
- *
- * Assertion.includeStack = true; // enable stack on error
- *
- * @api public
- */
-
- Assertion.includeStack = false;
-
- /*!
- * ### Assertion.showDiff
- *
- * User configurable property, influences whether or not
- * the `showDiff` flag should be included in the thrown
- * AssertionErrors. `false` will always be `false`; `true`
- * will be true when the assertion has requested a diff
- * be shown.
- *
- * @api public
- */
-
- Assertion.showDiff = true;
-
- Assertion.addProperty = function (name, fn) {
- util.addProperty(this.prototype, name, fn);
- };
-
- Assertion.addMethod = function (name, fn) {
- util.addMethod(this.prototype, name, fn);
- };
-
- Assertion.addChainableMethod = function (name, fn, chainingBehavior) {
- util.addChainableMethod(this.prototype, name, fn, chainingBehavior);
- };
-
- Assertion.overwriteProperty = function (name, fn) {
- util.overwriteProperty(this.prototype, name, fn);
- };
-
- Assertion.overwriteMethod = function (name, fn) {
- util.overwriteMethod(this.prototype, name, fn);
- };
-
- /*!
- * ### .assert(expression, message, negateMessage, expected, actual)
- *
- * Executes an expression and check expectations. Throws AssertionError for reporting if test doesn't pass.
- *
- * @name assert
- * @param {Philosophical} expression to be tested
- * @param {String} message to display if fails
- * @param {String} negatedMessage to display if negated expression fails
- * @param {Mixed} expected value (remember to check for negation)
- * @param {Mixed} actual (optional) will default to `this.obj`
- * @api private
- */
-
- Assertion.prototype.assert = function (expr, msg, negateMsg, expected, _actual, showDiff) {
- var ok = util.test(this, arguments);
- if (true !== showDiff) showDiff = false;
- if (true !== Assertion.showDiff) showDiff = false;
-
- if (!ok) {
- var msg = util.getMessage(this, arguments)
- , actual = util.getActual(this, arguments);
- throw new AssertionError(msg, {
- actual: actual
- , expected: expected
- , showDiff: showDiff
- }, (Assertion.includeStack) ? this.assert : flag(this, 'ssfi'));
- }
- };
-
- /*!
- * ### ._obj
- *
- * Quick reference to stored `actual` value for plugin developers.
- *
- * @api private
- */
-
- Object.defineProperty(Assertion.prototype, '_obj',
- { get: function () {
- return flag(this, 'object');
- }
- , set: function (val) {
- flag(this, 'object', val);
- }
- });
-};
-
-});
-require.register("chai/lib/chai/core/assertions.js", function(exports, require, module){
-/*!
- * chai
- * http://chaijs.com
- * Copyright(c) 2011-2013 Jake Luer <ja...@alogicalparadox.com>
- * MIT Licensed
- */
-
-module.exports = function (chai, _) {
- var Assertion = chai.Assertion
- , toString = Object.prototype.toString
- , flag = _.flag;
-
- /**
- * ### Language Chains
- *
- * The following are provide as chainable getters to
- * improve the readability of your assertions. They
- * do not provide an testing capability unless they
- * have been overwritten by a plugin.
- *
- * **Chains**
- *
- * - to
- * - be
- * - been
- * - is
- * - that
- * - and
- * - have
- * - with
- * - at
- * - of
- * - same
- *
- * @name language chains
- * @api public
- */
-
- [ 'to', 'be', 'been'
- , 'is', 'and', 'have'
- , 'with', 'that', 'at'
- , 'of', 'same' ].forEach(function (chain) {
- Assertion.addProperty(chain, function () {
- return this;
- });
- });
-
- /**
- * ### .not
- *
- * Negates any of assertions following in the chain.
- *
- * expect(foo).to.not.equal('bar');
- * expect(goodFn).to.not.throw(Error);
- * expect({ foo: 'baz' }).to.have.property('foo')
- * .and.not.equal('bar');
- *
- * @name not
- * @api public
- */
-
- Assertion.addProperty('not', function () {
- flag(this, 'negate', true);
- });
-
- /**
- * ### .deep
- *
- * Sets the `deep` flag, later used by the `equal` and
- * `property` assertions.
- *
- * expect(foo).to.deep.equal({ bar: 'baz' });
- * expect({ foo: { bar: { baz: 'quux' } } })
- * .to.have.deep.property('foo.bar.baz', 'quux');
- *
- * @name deep
- * @api public
- */
-
- Assertion.addProperty('deep', function () {
- flag(this, 'deep', true);
- });
-
- /**
- * ### .a(type)
- *
- * The `a` and `an` assertions are aliases that can be
- * used either as language chains or to assert a value's
- * type.
- *
- * // typeof
- * expect('test').to.be.a('string');
- * expect({ foo: 'bar' }).to.be.an('object');
- * expect(null).to.be.a('null');
- * expect(undefined).to.be.an('undefined');
- *
- * // language chain
- * expect(foo).to.be.an.instanceof(Foo);
- *
- * @name a
- * @alias an
- * @param {String} type
- * @param {String} message _optional_
- * @api public
- */
-
- function an (type, msg) {
- if (msg) flag(this, 'message', msg);
- type = type.toLowerCase();
- var obj = flag(this, 'object')
- , article = ~[ 'a', 'e', 'i', 'o', 'u' ].indexOf(type.charAt(0)) ? 'an ' : 'a ';
-
- this.assert(
- type === _.type(obj)
- , 'expected #{this} to be ' + article + type
- , 'expected #{this} not to be ' + article + type
- );
- }
-
- Assertion.addChainableMethod('an', an);
- Assertion.addChainableMethod('a', an);
-
- /**
- * ### .include(value)
- *
- * The `include` and `contain` assertions can be used as either property
- * based language chains or as methods to assert the inclusion of an object
- * in an array or a substring in a string. When used as language chains,
- * they toggle the `contain` flag for the `keys` assertion.
- *
- * expect([1,2,3]).to.include(2);
- * expect('foobar').to.contain('foo');
- * expect({ foo: 'bar', hello: 'universe' }).to.include.keys('foo');
- *
- * @name include
- * @alias contain
- * @param {Object|String|Number} obj
- * @param {String} message _optional_
- * @api public
- */
-
- function includeChainingBehavior () {
- flag(this, 'contains', true);
- }
-
- function include (val, msg) {
- if (msg) flag(this, 'message', msg);
- var obj = flag(this, 'object')
- this.assert(
- ~obj.indexOf(val)
- , 'expected #{this} to include ' + _.inspect(val)
- , 'expected #{this} to not include ' + _.inspect(val));
- }
-
- Assertion.addChainableMethod('include', include, includeChainingBehavior);
- Assertion.addChainableMethod('contain', include, includeChainingBehavior);
-
- /**
- * ### .ok
- *
- * Asserts that the target is truthy.
- *
- * expect('everthing').to.be.ok;
- * expect(1).to.be.ok;
- * expect(false).to.not.be.ok;
- * expect(undefined).to.not.be.ok;
- * expect(null).to.not.be.ok;
- *
- * @name ok
- * @api public
- */
-
- Assertion.addProperty('ok', function () {
- this.assert(
- flag(this, 'object')
- , 'expected #{this} to be truthy'
- , 'expected #{this} to be falsy');
- });
-
- /**
- * ### .true
- *
- * Asserts that the target is `true`.
- *
- * expect(true).to.be.true;
- * expect(1).to.not.be.true;
- *
- * @name true
- * @api public
- */
-
- Assertion.addProperty('true', function () {
- this.assert(
- true === flag(this, 'object')
- , 'expected #{this} to be true'
- , 'expected #{this} to be false'
- , this.negate ? false : true
- );
- });
-
- /**
- * ### .false
- *
- * Asserts that the target is `false`.
- *
- * expect(false).to.be.false;
- * expect(0).to.not.be.false;
- *
- * @name false
- * @api public
- */
-
- Assertion.addProperty('false', function () {
- this.assert(
- false === flag(this, 'object')
- , 'expected #{this} to be false'
- , 'expected #{this} to be true'
- , this.negate ? true : false
- );
- });
-
- /**
- * ### .null
- *
- * Asserts that the target is `null`.
- *
- * expect(null).to.be.null;
- * expect(undefined).not.to.be.null;
- *
- * @name null
- * @api public
- */
-
- Assertion.addProperty('null', function () {
- this.assert(
- null === flag(this, 'object')
- , 'expected #{this} to be null'
- , 'expected #{this} not to be null'
- );
- });
-
- /**
- * ### .undefined
- *
- * Asserts that the target is `undefined`.
- *
- * expect(undefined).to.be.undefined;
- * expect(null).to.not.be.undefined;
- *
- * @name undefined
- * @api public
- */
-
- Assertion.addProperty('undefined', function () {
- this.assert(
- undefined === flag(this, 'object')
- , 'expected #{this} to be undefined'
- , 'expected #{this} not to be undefined'
- );
- });
-
- /**
- * ### .exist
- *
- * Asserts that the target is neither `null` nor `undefined`.
- *
- * var foo = 'hi'
- * , bar = null
- * , baz;
- *
- * expect(foo).to.exist;
- * expect(bar).to.not.exist;
- * expect(baz).to.not.exist;
- *
- * @name exist
- * @api public
- */
-
- Assertion.addProperty('exist', function () {
- this.assert(
- null != flag(this, 'object')
- , 'expected #{this} to exist'
- , 'expected #{this} to not exist'
- );
- });
-
-
- /**
- * ### .empty
- *
- * Asserts that the target's length is `0`. For arrays, it checks
- * the `length` property. For objects, it gets the count of
- * enumerable keys.
- *
- * expect([]).to.be.empty;
- * expect('').to.be.empty;
- * expect({}).to.be.empty;
- *
- * @name empty
- * @api public
- */
-
- Assertion.addProperty('empty', function () {
- var obj = flag(this, 'object')
- , expected = obj;
-
- if (Array.isArray(obj) || 'string' === typeof object) {
- expected = obj.length;
- } else if (typeof obj === 'object') {
- expected = Object.keys(obj).length;
- }
-
- this.assert(
- !expected
- , 'expected #{this} to be empty'
- , 'expected #{this} not to be empty'
- );
- });
-
- /**
- * ### .arguments
- *
- * Asserts that the target is an arguments object.
- *
- * function test () {
- * expect(arguments).to.be.arguments;
- * }
- *
- * @name arguments
- * @alias Arguments
- * @api public
- */
-
- function checkArguments () {
- var obj = flag(this, 'object')
- , type = Object.prototype.toString.call(obj);
- this.assert(
- '[object Arguments]' === type
- , 'expected #{this} to be arguments but got ' + type
- , 'expected #{this} to not be arguments'
- );
- }
-
- Assertion.addProperty('arguments', checkArguments);
- Assertion.addProperty('Arguments', checkArguments);
-
- /**
- * ### .equal(value)
- *
- * Asserts that the target is strictly equal (`===`) to `value`.
- * Alternately, if the `deep` flag is set, asserts that
- * the target is deeply equal to `value`.
- *
- * expect('hello').to.equal('hello');
- * expect(42).to.equal(42);
- * expect(1).to.not.equal(true);
- * expect({ foo: 'bar' }).to.not.equal({ foo: 'bar' });
- * expect({ foo: 'bar' }).to.deep.equal({ foo: 'bar' });
- *
- * @name equal
- * @alias equals
- * @alias eq
- * @alias deep.equal
- * @param {Mixed} value
- * @param {String} message _optional_
- * @api public
- */
-
- function assertEqual (val, msg) {
- if (msg) flag(this, 'message', msg);
- var obj = flag(this, 'object');
- if (flag(this, 'deep')) {
- return this.eql(val);
- } else {
- this.assert(
- val === obj
- , 'expected #{this} to equal #{exp}'
- , 'expected #{this} to not equal #{exp}'
- , val
- , this._obj
- , true
- );
- }
- }
-
- Assertion.addMethod('equal', assertEqual);
- Assertion.addMethod('equals', assertEqual);
- Assertion.addMethod('eq', assertEqual);
-
- /**
- * ### .eql(value)
- *
- * Asserts that the target is deeply equal to `value`.
- *
- * expect({ foo: 'bar' }).to.eql({ foo: 'bar' });
- * expect([ 1, 2, 3 ]).to.eql([ 1, 2, 3 ]);
- *
- * @name eql
- * @alias eqls
- * @param {Mixed} value
- * @param {String} message _optional_
- * @api public
- */
-
- function assertEql(obj, msg) {
- if (msg) flag(this, 'message', msg);
- this.assert(
- _.eql(obj, flag(this, 'object'))
- , 'expected #{this} to deeply equal #{exp}'
- , 'expected #{this} to not deeply equal #{exp}'
- , obj
- , this._obj
- , true
- );
- }
-
- Assertion.addMethod('eql', assertEql);
- Assertion.addMethod('eqls', assertEql);
-
- /**
- * ### .above(value)
- *
- * Asserts that the target is greater than `value`.
- *
- * expect(10).to.be.above(5);
- *
- * Can also be used in conjunction with `length` to
- * assert a minimum length. The benefit being a
- * more informative error message than if the length
- * was supplied directly.
- *
- * expect('foo').to.have.length.above(2);
- * expect([ 1, 2, 3 ]).to.have.length.above(2);
- *
- * @name above
- * @alias gt
- * @alias greaterThan
- * @param {Number} value
- * @param {String} message _optional_
- * @api public
- */
-
- function assertAbove (n, msg) {
- if (msg) flag(this, 'message', msg);
- var obj = flag(this, 'object');
- if (flag(this, 'doLength')) {
- new Assertion(obj, msg).to.have.property('length');
- var len = obj.length;
- this.assert(
- len > n
- , 'expected #{this} to have a length above #{exp} but got #{act}'
- , 'expected #{this} to not have a length above #{exp}'
- , n
- , len
- );
- } else {
- this.assert(
- obj > n
- , 'expected #{this} to be above ' + n
- , 'expected #{this} to be at most ' + n
- );
- }
- }
-
- Assertion.addMethod('above', assertAbove);
- Assertion.addMethod('gt', assertAbove);
- Assertion.addMethod('greaterThan', assertAbove);
-
- /**
- * ### .least(value)
- *
- * Asserts that the target is greater than or equal to `value`.
- *
- * expect(10).to.be.at.least(10);
- *
- * Can also be used in conjunction with `length` to
- * assert a minimum length. The benefit being a
- * more informative error message than if the length
- * was supplied directly.
- *
- * expect('foo').to.have.length.of.at.least(2);
- * expect([ 1, 2, 3 ]).to.have.length.of.at.least(3);
- *
- * @name least
- * @alias gte
- * @param {Number} value
- * @param {String} message _optional_
- * @api public
- */
-
- function assertLeast (n, msg) {
- if (msg) flag(this, 'message', msg);
- var obj = flag(this, 'object');
- if (flag(this, 'doLength')) {
- new Assertion(obj, msg).to.have.property('length');
- var len = obj.length;
- this.assert(
- len >= n
- , 'expected #{this} to have a length at least #{exp} but got #{act}'
- , 'expected #{this} to have a length below #{exp}'
- , n
- , len
- );
- } else {
- this.assert(
- obj >= n
- , 'expected #{this} to be at least ' + n
- , 'expected #{this} to be below ' + n
- );
- }
- }
-
- Assertion.addMethod('least', assertLeast);
- Assertion.addMethod('gte', assertLeast);
-
- /**
- * ### .below(value)
- *
- * Asserts that the target is less than `value`.
- *
- * expect(5).to.be.below(10);
- *
- * Can also be used in conjunction with `length` to
- * assert a maximum length. The benefit being a
- * more informative error message than if the length
- * was supplied directly.
- *
- * expect('foo').to.have.length.below(4);
- * expect([ 1, 2, 3 ]).to.have.length.below(4);
- *
- * @name below
- * @alias lt
- * @alias lessThan
- * @param {Number} value
- * @param {String} message _optional_
- * @api public
- */
-
- function assertBelow (n, msg) {
- if (msg) flag(this, 'message', msg);
- var obj = flag(this, 'object');
- if (flag(this, 'doLength')) {
- new Assertion(obj, msg).to.have.property('length');
- var len = obj.length;
- this.assert(
- len < n
- , 'expected #{this} to have a length below #{exp} but got #{act}'
- , 'expected #{this} to not have a length below #{exp}'
- , n
- , len
- );
- } else {
- this.assert(
- obj < n
- , 'expected #{this} to be below ' + n
- , 'expected #{this} to be at least ' + n
- );
- }
- }
-
- Assertion.addMethod('below', assertBelow);
- Assertion.addMethod('lt', assertBelow);
- Assertion.addMethod('lessThan', assertBelow);
-
- /**
- * ### .most(value)
- *
- * Asserts that the target is less than or equal to `value`.
- *
- * expect(5).to.be.at.most(5);
- *
- * Can also be used in conjunction with `length` to
- * assert a maximum length. The benefit being a
- * more informative error message than if the length
- * was supplied directly.
- *
- * expect('foo').to.have.length.of.at.most(4);
- * expect([ 1, 2, 3 ]).to.have.length.of.at.most(3);
- *
- * @name most
- * @alias lte
- * @param {Number} value
- * @param {String} message _optional_
- * @api public
- */
-
- function assertMost (n, msg) {
- if (msg) flag(this, 'message', msg);
- var obj = flag(this, 'object');
- if (flag(this, 'doLength')) {
- new Assertion(obj, msg).to.have.property('length');
- var len = obj.length;
- this.assert(
- len <= n
- , 'expected #{this} to have a length at most #{exp} but got #{act}'
- , 'expected #{this} to have a length above #{exp}'
- , n
- , len
- );
- } else {
- this.assert(
- obj <= n
- , 'expected #{this} to be at most ' + n
- , 'expected #{this} to be above ' + n
- );
- }
- }
-
- Assertion.addMethod('most', assertMost);
- Assertion.addMethod('lte', assertMost);
-
- /**
- * ### .within(start, finish)
- *
- * Asserts that the target is within a range.
- *
- * expect(7).to.be.within(5,10);
- *
- * Can also be used in conjunction with `length` to
- * assert a length range. The benefit being a
- * more informative error message than if the length
- * was supplied directly.
- *
- * expect('foo').to.have.length.within(2,4);
- * expect([ 1, 2, 3 ]).to.have.length.within(2,4);
- *
- * @name within
- * @param {Number} start lowerbound inclusive
- * @param {Number} finish upperbound inclusive
- * @param {String} message _optional_
- * @api public
- */
-
- Assertion.addMethod('within', function (start, finish, msg) {
- if (msg) flag(this, 'message', msg);
- var obj = flag(this, 'object')
- , range = start + '..' + finish;
- if (flag(this, 'doLength')) {
- new Assertion(obj, msg).to.have.property('length');
- var len = obj.length;
- this.assert(
- len >= start && len <= finish
- , 'expected #{this} to have a length within ' + range
- , 'expected #{this} to not have a length within ' + range
- );
- } else {
- this.assert(
- obj >= start && obj <= finish
- , 'expected #{this} to be within ' + range
- , 'expected #{this} to not be within ' + range
- );
- }
- });
-
- /**
- * ### .instanceof(constructor)
- *
- * Asserts that the target is an instance of `constructor`.
- *
- * var Tea = function (name) { this.name = name; }
- * , Chai = new Tea('chai');
- *
- * expect(Chai).to.be.an.instanceof(Tea);
- * expect([ 1, 2, 3 ]).to.be.instanceof(Array);
- *
- * @name instanceof
- * @param {Constructor} constructor
- * @param {String} message _optional_
- * @alias instanceOf
- * @api public
- */
-
- function assertInstanceOf (constructor, msg) {
- if (msg) flag(this, 'message', msg);
- var name = _.getName(constructor);
- this.assert(
- flag(this, 'object') instanceof constructor
- , 'expected #{this} to be an instance of ' + name
- , 'expected #{this} to not be an instance of ' + name
- );
- };
-
- Assertion.addMethod('instanceof', assertInstanceOf);
- Assertion.addMethod('instanceOf', assertInstanceOf);
-
- /**
- * ### .property(name, [value])
- *
- * Asserts that the target has a property `name`, optionally asserting that
- * the value of that property is strictly equal to `value`.
- * If the `deep` flag is set, you can use dot- and bracket-notation for deep
- * references into objects and arrays.
- *
- * // simple referencing
- * var obj = { foo: 'bar' };
- * expect(obj).to.have.property('foo');
- * expect(obj).to.have.property('foo', 'bar');
- *
- * // deep referencing
- * var deepObj = {
- * green: { tea: 'matcha' }
- * , teas: [ 'chai', 'matcha', { tea: 'konacha' } ]
- * };
-
- * expect(deepObj).to.have.deep.property('green.tea', 'matcha');
- * expect(deepObj).to.have.deep.property('teas[1]', 'matcha');
- * expect(deepObj).to.have.deep.property('teas[2].tea', 'konacha');
- *
- * You can also use an array as the starting point of a `deep.property`
- * assertion, or traverse nested arrays.
- *
- * var arr = [
- * [ 'chai', 'matcha', 'konacha' ]
- * , [ { tea: 'chai' }
- * , { tea: 'matcha' }
- * , { tea: 'konacha' } ]
- * ];
- *
- * expect(arr).to.have.deep.property('[0][1]', 'matcha');
- * expect(arr).to.have.deep.property('[1][2].tea', 'konacha');
- *
- * Furthermore, `property` changes the subject of the assertion
- * to be the value of that property from the original object. This
- * permits for further chainable assertions on that property.
- *
- * expect(obj).to.have.property('foo')
- * .that.is.a('string');
- * expect(deepObj).to.have.property('green')
- * .that.is.an('object')
- * .that.deep.equals({ tea: 'matcha' });
- * expect(deepObj).to.have.property('teas')
- * .that.is.an('array')
- * .with.deep.property('[2]')
- * .that.deep.equals({ tea: 'konacha' });
- *
- * @name property
- * @alias deep.property
- * @param {String} name
- * @param {Mixed} value (optional)
- * @param {String} message _optional_
- * @returns value of property for chaining
- * @api public
- */
-
- Assertion.addMethod('property', function (name, val, msg) {
- if (msg) flag(this, 'message', msg);
-
- var descriptor = flag(this, 'deep') ? 'deep property ' : 'property '
- , negate = flag(this, 'negate')
- , obj = flag(this, 'object')
- , value = flag(this, 'deep')
- ? _.getPathValue(name, obj)
- : obj[name];
-
- if (negate && undefined !== val) {
- if (undefined === value) {
- msg = (msg != null) ? msg + ': ' : '';
- throw new Error(msg + _.inspect(obj) + ' has no ' + descriptor + _.inspect(name));
- }
- } else {
- this.assert(
- undefined !== value
- , 'expected #{this} to have a ' + descriptor + _.inspect(name)
- , 'expected #{this} to not have ' + descriptor + _.inspect(name));
- }
-
- if (undefined !== val) {
- this.assert(
- val === value
- , 'expected #{this} to have a ' + descriptor + _.inspect(name) + ' of #{exp}, but got #{act}'
- , 'expected #{this} to not have a ' + descriptor + _.inspect(name) + ' of #{act}'
- , val
- , value
- );
- }
-
- flag(this, 'object', value);
- });
-
-
- /**
- * ### .ownProperty(name)
- *
- * Asserts that the target has an own property `name`.
- *
- * expect('test').to.have.ownProperty('length');
- *
- * @name ownProperty
- * @alias haveOwnProperty
- * @param {String} name
- * @param {String} message _optional_
- * @api public
- */
-
- function assertOwnProperty (name, msg) {
- if (msg) flag(this, 'message', msg);
- var obj = flag(this, 'object');
- this.assert(
- obj.hasOwnProperty(name)
- , 'expected #{this} to have own property ' + _.inspect(name)
- , 'expected #{this} to not have own property ' + _.inspect(name)
- );
- }
-
- Assertion.addMethod('ownProperty', assertOwnProperty);
- Assertion.addMethod('haveOwnProperty', assertOwnProperty);
-
- /**
- * ### .length(value)
- *
- * Asserts that the target's `length` property has
- * the expected value.
- *
- * expect([ 1, 2, 3]).to.have.length(3);
- * expect('foobar').to.have.length(6);
- *
- * Can also be used as a chain precursor to a value
- * comparison for the length property.
- *
- * expect('foo').to.have.length.above(2);
- * expect([ 1, 2, 3 ]).to.have.length.above(2);
- * expect('foo').to.have.length.below(4);
- * expect([ 1, 2, 3 ]).to.have.length.below(4);
- * expect('foo').to.have.length.within(2,4);
- * expect([ 1, 2, 3 ]).to.have.length.within(2,4);
- *
- * @name length
- * @alias lengthOf
- * @param {Number} length
- * @param {String} message _optional_
- * @api public
- */
-
- function assertLengthChain () {
- flag(this, 'doLength', true);
- }
-
- function assertLength (n, msg) {
- if (msg) flag(this, 'message', msg);
- var obj = flag(this, 'object');
- new Assertion(obj, msg).to.have.property('length');
- var len = obj.length;
-
- this.assert(
- len == n
- , 'expected #{this} to have a length of #{exp} but got #{act}'
- , 'expected #{this} to not have a length of #{act}'
- , n
- , len
- );
- }
-
- Assertion.addChainableMethod('length', assertLength, assertLengthChain);
- Assertion.addMethod('lengthOf', assertLength, assertLengthChain);
-
- /**
- * ### .match(regexp)
- *
- * Asserts that the target matches a regular expression.
- *
- * expect('foobar').to.match(/^foo/);
- *
- * @name match
- * @param {RegExp} RegularExpression
- * @param {String} message _optional_
- * @api public
- */
-
- Assertion.addMethod('match', function (re, msg) {
- if (msg) flag(this, 'message', msg);
- var obj = flag(this, 'object');
- this.assert(
- re.exec(obj)
- , 'expected #{this} to match ' + re
- , 'expected #{this} not to match ' + re
- );
- });
-
- /**
- * ### .string(string)
- *
- * Asserts that the string target contains another string.
- *
- * expect('foobar').to.have.string('bar');
- *
- * @name string
- * @param {String} string
- * @param {String} message _optional_
- * @api public
- */
-
- Assertion.addMethod('string', function (str, msg) {
- if (msg) flag(this, 'message', msg);
- var obj = flag(this, 'object');
- new Assertion(obj, msg).is.a('string');
-
- this.assert(
- ~obj.indexOf(str)
- , 'expected #{this} to contain ' + _.inspect(str)
- , 'expected #{this} to not contain ' + _.inspect(str)
- );
- });
-
-
- /**
- * ### .keys(key1, [key2], [...])
- *
- * Asserts that the target has exactly the given keys, or
- * asserts the inclusion of some keys when using the
- * `include` or `contain` modifiers.
- *
- * expect({ foo: 1, bar: 2 }).to.have.keys(['foo', 'bar']);
- * expect({ foo: 1, bar: 2, baz: 3 }).to.contain.keys('foo', 'bar');
- *
- * @name keys
- * @alias key
- * @param {String...|Array} keys
- * @api public
- */
-
- function assertKeys (keys) {
- var obj = flag(this, 'object')
- , str
- , ok = true;
-
- keys = keys instanceof Array
- ? keys
- : Array.prototype.slice.call(arguments);
-
- if (!keys.length) throw new Error('keys required');
-
- var actual = Object.keys(obj)
- , len = keys.length;
-
- // Inclusion
- ok = keys.every(function(key){
- return ~actual.indexOf(key);
- });
-
- // Strict
- if (!flag(this, 'negate') && !flag(this, 'contains')) {
- ok = ok && keys.length == actual.length;
- }
-
- // Key string
- if (len > 1) {
- keys = keys.map(function(key){
- return _.inspect(key);
- });
- var last = keys.pop();
- str = keys.join(', ') + ', and ' + last;
- } else {
- str = _.inspect(keys[0]);
- }
-
- // Form
- str = (len > 1 ? 'keys ' : 'key ') + str;
-
- // Have / include
- str = (flag(this, 'contains') ? 'contain ' : 'have ') + str;
-
- // Assertion
- this.assert(
- ok
- , 'expected #{this} to ' + str
- , 'expected #{this} to not ' + str
- );
- }
-
- Assertion.addMethod('keys', assertKeys);
- Assertion.addMethod('key', assertKeys);
-
- /**
- * ### .throw(constructor)
- *
- * Asserts that the function target will throw a specific error, or specific type of error
- * (as determined using `instanceof`), optionally with a RegExp or string inclusion test
- * for the error's message.
- *
- * var err = new ReferenceError('This is a bad function.');
- * var fn = function () { throw err; }
- * expect(fn).to.throw(ReferenceError);
- * expect(fn).to.throw(Error);
- * expect(fn).to.throw(/bad function/);
- * expect(fn).to.not.throw('good function');
- * expect(fn).to.throw(ReferenceError, /bad function/);
- * expect(fn).to.throw(err);
- * expect(fn).to.not.throw(new RangeError('Out of range.'));
- *
- * Please note that when a throw expectation is negated, it will check each
- * parameter independently, starting with error constructor type. The appropriate way
- * to check for the existence of a type of error but for a message that does not match
- * is to use `and`.
- *
- * expect(fn).to.throw(ReferenceError)
- * .and.not.throw(/good function/);
- *
- * @name throw
- * @alias throws
- * @alias Throw
- * @param {ErrorConstructor} constructor
- * @param {String|RegExp} expected error message
- * @param {String} message _optional_
- * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
- * @api public
- */
-
- function assertThrows (constructor, errMsg, msg) {
- if (msg) flag(this, 'message', msg);
- var obj = flag(this, 'object');
- new Assertion(obj, msg).is.a('function');
-
- var thrown = false
- , desiredError = null
- , name = null
- , thrownError = null;
-
- if (arguments.length === 0) {
- errMsg = null;
- constructor = null;
- } else if (constructor && (constructor instanceof RegExp || 'string' === typeof constructor)) {
- errMsg = constructor;
- constructor = null;
- } else if (constructor && constructor instanceof Error) {
- desiredError = constructor;
- constructor = null;
- errMsg = null;
- } else if (typeof constructor === 'function') {
- name = (new constructor()).name;
- } else {
- constructor = null;
- }
-
- try {
- obj();
- } catch (err) {
- // first, check desired error
- if (desiredError) {
- this.assert(
- err === desiredError
- , 'expected #{this} to throw #{exp} but #{act} was thrown'
- , 'expected #{this} to not throw #{exp}'
- , desiredError
- , err
- );
-
- return this;
- }
- // next, check constructor
- if (constructor) {
- this.assert(
- err instanceof constructor
- , 'expected #{this} to throw #{exp} but #{act} was thrown'
- , 'expected #{this} to not throw #{exp} but #{act} was thrown'
- , name
- , err
- );
-
- if (!errMsg) return this;
- }
- // next, check message
- var message = 'object' === _.type(err) && "message" in err
- ? err.message
- : '' + err;
-
- if ((message != null) && errMsg && errMsg instanceof RegExp) {
- this.assert(
- errMsg.exec(message)
- , 'expected #{this} to throw error matching #{exp} but got #{act}'
- , 'expected #{this} to throw error not matching #{exp}'
- , errMsg
- , message
- );
-
- return this;
- } else if ((message != null) && errMsg && 'string' === typeof errMsg) {
- this.assert(
- ~message.indexOf(errMsg)
- , 'expected #{this} to throw error including #{exp} but got #{act}'
- , 'expected #{this} to throw error not including #{act}'
- , errMsg
- , message
- );
-
- return this;
- } else {
- thrown = true;
- thrownError = err;
- }
- }
-
- var actuallyGot = ''
- , expectedThrown = name !== null
- ? name
- : desiredError
- ? '#{exp}' //_.inspect(desiredError)
- : 'an error';
-
- if (thrown) {
- actuallyGot = ' but #{act} was thrown'
- }
-
- this.assert(
- thrown === true
- , 'expected #{this} to throw ' + expectedThrown + actuallyGot
- , 'expected #{this} to not throw ' + expectedThrown + actuallyGot
- , desiredError
- , thrownError
- );
- };
-
- Assertion.addMethod('throw', assertThrows);
- Assertion.addMethod('throws', assertThrows);
- Assertion.addMethod('Throw', assertThrows);
-
- /**
- * ### .respondTo(method)
- *
- * Asserts that the object or class target will respond to a method.
- *
- * Klass.prototype.bar = function(){};
- * expect(Klass).to.respondTo('bar');
- * expect(obj).to.respondTo('bar');
- *
- * To check if a constructor will respond to a static function,
- * set the `itself` flag.
- *
- * Klass.baz = function(){};
- * expect(Klass).itself.to.respondTo('baz');
- *
- * @name respondTo
- * @param {String} method
- * @param {String} message _optional_
- * @api public
- */
-
- Assertion.addMethod('respondTo', function (method, msg) {
- if (msg) flag(this, 'message', msg);
- var obj = flag(this, 'object')
- , itself = flag(this, 'itself')
- , context = ('function' === _.type(obj) && !itself)
- ? obj.prototype[method]
- : obj[method];
-
- this.assert(
- 'function' === typeof context
- , 'expected #{this} to respond to ' + _.inspect(method)
- , 'expected #{this} to not respond to ' + _.inspect(method)
- );
- });
-
- /**
- * ### .itself
- *
- * Sets the `itself` flag, later used by the `respondTo` assertion.
- *
- * function Foo() {}
- * Foo.bar = function() {}
- * Foo.prototype.baz = function() {}
- *
- * expect(Foo).itself.to.respondTo('bar');
- * expect(Foo).itself.not.to.respondTo('baz');
- *
- * @name itself
- * @api public
- */
-
- Assertion.addProperty('itself', function () {
- flag(this, 'itself', true);
- });
-
- /**
- * ### .satisfy(method)
- *
- * Asserts that the target passes a given truth test.
- *
- * expect(1).to.satisfy(function(num) { return num > 0; });
- *
- * @name satisfy
- * @param {Function} matcher
- * @param {String} message _optional_
- * @api public
- */
-
- Assertion.addMethod('satisfy', function (matcher, msg) {
- if (msg) flag(this, 'message', msg);
- var obj = flag(this, 'object');
- this.assert(
- matcher(obj)
- , 'expected #{this} to satisfy ' + _.objDisplay(matcher)
- , 'expected #{this} to not satisfy' + _.objDisplay(matcher)
- , this.negate ? false : true
- , matcher(obj)
- );
- });
-
- /**
- * ### .closeTo(expected, delta)
- *
- * Asserts that the target is equal `expected`, to within a +/- `delta` range.
- *
- * expect(1.5).to.be.closeTo(1, 0.5);
- *
- * @name closeTo
- * @param {Number} expected
- * @param {Number} delta
- * @param {String} message _optional_
- * @api public
- */
-
- Assertion.addMethod('closeTo', function (expected, delta, msg) {
- if (msg) flag(this, 'message', msg);
- var obj = flag(this, 'object');
- this.assert(
- Math.abs(obj - expected) <= delta
- , 'expected #{this} to be close to ' + expected + ' +/- ' + delta
- , 'expected #{this} not to be close to ' + expected + ' +/- ' + delta
- );
- });
-
- function isSubsetOf(subset, superset) {
- return subset.every(function(elem) {
- return superset.indexOf(elem) !== -1;
- })
- }
-
- /**
- * ### .members(set)
- *
- * Asserts that the target is a superset of `set`,
- * or that the target and `set` have the same members.
- *
- * expect([1, 2, 3]).to.include.members([3, 2]);
- * expect([1, 2, 3]).to.not.include.members([3, 2, 8]);
- *
- * expect([4, 2]).to.have.members([2, 4]);
- * expect([5, 2]).to.not.have.members([5, 2, 1]);
- *
- * @name members
- * @param {Array} set
- * @param {String} message _optional_
- * @api public
- */
-
- Assertion.addMethod('members', function (subset, msg) {
- if (msg) flag(this, 'message', msg);
- var obj = flag(this, 'object');
-
- new Assertion(obj).to.be.an('array');
- new Assertion(subset).to.be.an('array');
-
- if (flag(this, 'contains')) {
- return this.assert(
- isSubsetOf(subset, obj)
- , 'expected #{this} to be a superset of #{act}'
- , 'expected #{this} to not be a superset of #{act}'
- , obj
- , subset
- );
- }
-
- this.assert(
- isSubsetOf(obj, subset) && isSubsetOf(subset, obj)
- , 'expected #{this} to have the same members as #{act}'
- , 'expected #{this} to not have the same members as #{act}'
- , obj
- , subset
- );
- });
-};
-
-});
-require.register("chai/lib/chai/interface/assert.js", function(exports, require, module){
-/*!
- * chai
- * Copyright(c) 2011-2013 Jake Luer <ja...@alogicalparadox.com>
- * MIT Licensed
- */
-
-
-module.exports = function (chai, util) {
-
- /*!
- * Chai dependencies.
- */
-
- var Assertion = chai.Assertion
- , flag = util.flag;
-
- /*!
- * Module export.
- */
-
- /**
- * ### assert(expression, message)
- *
- * Write your own test expressions.
- *
- * assert('foo' !== 'bar', 'foo is not bar');
- * assert(Array.isArray([]), 'empty arrays are arrays');
- *
- * @param {Mixed} expression to test for truthiness
- * @param {String} message to display on error
- * @name assert
- * @api public
- */
-
- var assert = chai.assert = function (express, errmsg) {
- var test = new Assertion(null);
- test.assert(
- express
- , errmsg
- , '[ negation message unavailable ]'
- );
- };
-
- /**
- * ### .fail(actual, expected, [message], [operator])
- *
- * Throw a failure. Node.js `assert` module-compatible.
- *
- * @name fail
- * @param {Mixed} actual
- * @param {Mixed} expected
- * @param {String} message
- * @param {String} operator
- * @api public
- */
-
- assert.fail = function (actual, expected, message, operator) {
- throw new chai.AssertionError({
- actual: actual
- , expected: expected
- , message: message
- , operator: operator
- , stackStartFunction: assert.fail
- });
- };
-
- /**
- * ### .ok(object, [message])
- *
- * Asserts that `object` is truthy.
- *
- * assert.ok('everything', 'everything is ok');
- * assert.ok(false, 'this will fail');
- *
- * @name ok
- * @param {Mixed} object to test
- * @param {String} message
- * @api public
- */
-
- assert.ok = function (val, msg) {
- new Assertion(val, msg).is.ok;
- };
-
- /**
- * ### .notOk(object, [message])
- *
- * Asserts that `object` is falsy.
- *
- * assert.notOk('everything', 'this will fail');
- * assert.notOk(false, 'this will pass');
- *
- * @name notOk
- * @param {Mixed} object to test
- * @param {String} message
- * @api public
- */
-
- assert.notOk = function (val, msg) {
- new Assertion(val, msg).is.not.ok;
- };
-
- /**
- * ### .equal(actual, expected, [message])
- *
- * Asserts non-strict equality (`==`) of `actual` and `expected`.
- *
- * assert.equal(3, '3', '== coerces values to strings');
- *
- * @name equal
- * @param {Mixed} actual
- * @param {Mixed} expected
- * @param {String} message
- * @api public
- */
-
- assert.equal = function (act, exp, msg) {
- var test = new Assertion(act, msg);
-
- test.assert(
- exp == flag(test, 'object')
- , 'expected #{this} to equal #{exp}'
- , 'expected #{this} to not equal #{act}'
- , exp
- , act
- );
- };
-
- /**
- * ### .notEqual(actual, expected, [message])
- *
- * Asserts non-strict inequality (`!=`) of `actual` and `expected`.
- *
- * assert.notEqual(3, 4, 'these numbers are not equal');
- *
- * @name notEqual
- * @param {Mixed} actual
- * @param {Mixed} expected
- * @param {String} message
- * @api public
- */
-
- assert.notEqual = function (act, exp, msg) {
- var test = new Assertion(act, msg);
-
- test.assert(
- exp != flag(test, 'object')
- , 'expected #{this} to not equal #{exp}'
- , 'expected #{this} to equal #{act}'
- , exp
- , act
- );
- };
-
- /**
- * ### .strictEqual(actual, expected, [message])
- *
- * Asserts strict equality (`===`) of `actual` and `expected`.
- *
- * assert.strictEqual(true, true, 'these booleans are strictly equal');
- *
- * @name strictEqual
- * @param {Mixed} actual
- * @param {Mixed} expected
- * @param {String} message
- * @api public
- */
-
- assert.strictEqual = function (act, exp, msg) {
- new Assertion(act, msg).to.equal(exp);
- };
-
- /**
- * ### .notStrictEqual(actual, expected, [message])
- *
- * Asserts strict inequality (`!==`) of `actual` and `expected`.
- *
- * assert.notStrictEqual(3, '3', 'no coercion for strict equality');
- *
- * @name notStrictEqual
- * @param {Mixed} actual
- * @param {Mixed} expected
- * @param {String} message
- * @api public
- */
-
- assert.notStrictEqual = function (act, exp, msg) {
- new Assertion(act, msg).to.not.equal(exp);
- };
-
- /**
- * ### .deepEqual(actual, expected, [message])
- *
- * Asserts that `actual` is deeply equal to `expected`.
- *
- * assert.deepEqual({ tea: 'green' }, { tea: 'green' });
- *
- * @name deepEqual
- * @param {Mixed} actual
- * @param {Mixed} expected
- * @param {String} message
- * @api public
- */
-
- assert.deepEqual = function (act, exp, msg) {
- new Assertion(act, msg).to.eql(exp);
- };
-
- /**
- * ### .notDeepEqual(actual, expected, [message])
- *
- * Assert that `actual` is not deeply equal to `expected`.
- *
- * assert.notDeepEqual({ tea: 'green' }, { tea: 'jasmine' });
- *
- * @name notDeepEqual
- * @param {Mixed} actual
- * @param {Mixed} expected
- * @param {String} message
- * @api public
- */
-
- assert.notDeepEqual = function (act, exp, msg) {
- new Assertion(act, msg).to.not.eql(exp);
- };
-
- /**
- * ### .isTrue(value, [message])
- *
- * Asserts that `value` is true.
- *
- * var teaServed = true;
- * assert.isTrue(teaServed, 'the tea has been served');
- *
- * @name isTrue
- * @param {Mixed} value
- * @param {String} message
- * @api public
- */
-
- assert.isTrue = function (val, msg) {
- new Assertion(val, msg).is['true'];
- };
-
- /**
- * ### .isFalse(value, [message])
- *
- * Asserts that `value` is false.
- *
- * var teaServed = false;
- * assert.isFalse(teaServed, 'no tea yet? hmm...');
- *
- * @name isFalse
- * @param {Mixed} value
- * @param {String} message
- * @api public
- */
-
- assert.isFalse = function (val, msg) {
- new Assertion(val, msg).is['false'];
- };
-
- /**
- * ### .isNull(value, [message])
- *
- * Asserts that `value` is null.
- *
- * assert.isNull(err, 'there was no error');
- *
- * @name isNull
- * @param {Mixed} value
- * @param {String} message
- * @api public
- */
-
- assert.isNull = function (val, msg) {
- new Assertion(val, msg).to.equal(null);
- };
-
- /**
- * ### .isNotNull(value, [message])
- *
- * Asserts that `value` is not null.
- *
- * var tea = 'tasty chai';
- * assert.isNotNull(tea, 'great, time for tea!');
- *
- * @name isNotNull
- * @param {Mixed} value
- * @param {String} message
- * @api public
- */
-
- assert.isNotNull = function (val, msg) {
- new Assertion(val, msg).to.not.equal(null);
- };
-
- /**
- * ### .isUndefined(value, [message])
- *
- * Asserts that `value` is `undefined`.
- *
- * var tea;
- * assert.isUndefined(tea, 'no tea defined');
- *
- * @name isUndefined
- * @param {Mixed} value
- * @param {String} message
- * @api public
- */
-
- assert.isUndefined = function (val, msg) {
- new Assertion(val, msg).to.equal(undefined);
- };
-
- /**
- * ### .isDefined(value, [message])
- *
- * Asserts that `value` is not `undefined`.
- *
- * var tea = 'cup of chai';
- * assert.isDefined(tea, 'tea has been defined');
- *
- * @name isDefined
- * @param {Mixed} value
- * @param {String} message
- * @api public
- */
-
- assert.isDefined = function (val, msg) {
- new Assertion(val, msg).to.not.equal(undefined);
- };
-
- /**
- * ### .isFunction(value, [message])
- *
- * Asserts that `value` is a function.
- *
- * function serveTea() { return 'cup of tea'; };
- * assert.isFunction(serveTea, 'great, we can have tea now');
- *
- * @name isFunction
- * @param {Mixed} value
- * @param {String} message
- * @api public
- */
-
- assert.isFunction = function (val, msg) {
- new Assertion(val, msg).to.be.a('function');
- };
-
- /**
- * ### .isNotFunction(value, [message])
- *
- * Asserts that `value` is _not_ a function.
- *
- * var serveTea = [ 'heat', 'pour', 'sip' ];
- * assert.isNotFunction(serveTea, 'great, we have listed the steps');
- *
- * @name isNotFunction
- * @param {Mixed} value
- * @param {String} message
- * @api public
- */
-
- assert.isNotFunction = function (val, msg) {
- new Assertion(val, msg).to.not.be.a('function');
- };
-
- /**
- * ### .isObject(value, [message])
- *
- * Asserts that `value` is an object (as revealed by
- * `Object.prototype.toString`).
- *
- * var selection = { name: 'Chai', serve: 'with spices' };
- * assert.isObject(selection, 'tea selection is an object');
- *
- * @name isObject
- * @param {Mixed} value
- * @param {String} message
- * @api public
- */
-
- assert.isObject = function (val, msg) {
- new Assertion(val, msg).to.be.a('object');
- };
-
- /**
- * ### .isNotObject(value, [message])
- *
- * Asserts that `value` is _not_ an object.
- *
- * var selection = 'chai'
- * assert.isObject(selection, 'tea selection is not an object');
- * assert.isObject(null, 'null is not an object');
- *
- * @name isNotObject
- * @param {Mixed} value
- * @param {String} message
- * @api public
- */
-
- assert.isNotObject = function (val, msg) {
- new Assertion(val, msg).to.not.be.a('object');
- };
-
- /**
- * ### .isArray(value, [message])
- *
- * Asserts that `value` is an array.
- *
- * var menu = [ 'green', 'chai', 'oolong' ];
- * assert.isArray(menu, 'what kind of tea do we want?');
- *
- * @name isArray
- * @param {Mixed} value
- * @param {String} message
- * @api public
- */
-
- assert.isArray = function (val, msg) {
- new Assertion(val, msg).to.be.an('array');
- };
-
- /**
- * ### .isNotArray(value, [message])
- *
- * Asserts that `value` is _not_ an array.
- *
- * var menu = 'green|chai|oolong';
- * assert.isNotArray(menu, 'what kind of tea do we want?');
- *
- * @name isNotArray
- * @param {Mixed} value
- * @param {String} message
- * @api public
- */
-
- assert.isNotArray = function (val, msg) {
- new Assertion(val, msg).to.not.be.an('array');
- };
-
- /**
- * ### .isString(value, [message])
- *
- * Asserts that `value` is a string.
- *
- * var teaOrder = 'chai';
- * assert.isString(teaOrder, 'order placed');
- *
- * @name isString
- * @param {Mixed} value
- * @param {String} message
- * @api public
- */
-
- assert.isString = function (val, msg) {
- new Assertion(val, msg).to.be.a('string');
- };
-
- /**
- * ### .isNotString(value, [message])
- *
- * Asserts that `value` is _not_ a string.
- *
- * var teaOrder = 4;
- * assert.isNotString(teaOrder, 'order placed');
- *
- * @name isNotString
- * @param {Mixed} value
- * @param {String} message
- * @api public
- */
-
- assert.isNotString = function (val, msg) {
- new Assertion(val, msg).to.not.be.a('string');
- };
-
- /**
- * ### .isNumber(value, [message])
- *
- * Asserts that `value` is a number.
- *
- * var cups = 2;
- * assert.isNumber(cups, 'how many cups');
- *
- * @name isNumber
- * @param {Number} value
- * @param {String} message
- * @api public
- */
-
- assert.isNumber = function (val, msg) {
- new Assertion(val, msg).to.be.a('number');
- };
-
- /**
- * ### .isNotNumber(value, [message])
- *
- * Asserts that `value` is _not_ a number.
- *
- * var cups = '2 cups please';
- * assert.isNotNumber(cups, 'how many cups');
- *
- * @name isNotNumber
- * @param {Mixed} value
- * @param {String} message
- * @api public
- */
-
- assert.isNotNumber = function (val, msg) {
- new Assertion(val, msg).to.not.be.a('number');
- };
-
- /**
- * ### .isBoolean(value, [message])
- *
- * Asserts that `value` is a boolean.
- *
- * var teaReady = true
- * , teaServed = false;
- *
- * assert.isBoolean(teaReady, 'is the tea ready');
- * assert.isBoolean(teaServed, 'has tea been served');
- *
- * @name isBoolean
- * @param {Mixed} value
- * @param {String} message
- * @api public
- */
-
- assert.isBoolean = function (val, msg) {
- new Assertion(val, msg).to.be.a('boolean');
- };
-
- /**
- * ### .isNotBoolean(value, [message])
- *
- * Asserts that `value` is _not_ a boolean.
- *
- * var teaReady = 'yep'
- * , teaServed = 'nope';
- *
- * assert.isNotBoolean(teaReady, 'is the tea ready');
- * assert.isNotBoolean(teaServed, 'has tea been served');
- *
- * @name isNotBoolean
- * @param {Mixed} value
- * @param {String} message
- * @api public
- */
-
- assert.isNotBoolean = function (val, msg) {
- new Assertion(val, msg).to.not.be.a('boolean');
- };
-
- /**
- * ### .typeOf(value, name, [message])
- *
- * Asserts that `value`'s type is `name`, as determined by
- * `Object.prototype.toString`.
- *
- * assert.typeOf({ tea: 'chai' }, 'object', 'we have an object');
- * assert.typeOf(['chai', 'jasmine'], 'array', 'we have an array');
- * assert.typeOf('tea', 'string', 'we have a string');
- * assert.typeOf(/tea/, 'regexp', 'we have a regular expression');
- * assert.typeOf(null, 'null', 'we have a null');
- * assert.typeOf(undefined, 'undefined', 'we have an undefined');
- *
- * @name typeOf
- * @param {Mixed} value
- * @param {String} name
- * @param {String} message
- * @api public
- */
-
- assert.typeOf = function (val, type, msg) {
- new Assertion(val, msg).to.be.a(type);
- };
-
- /**
- * ### .notTypeOf(value, name, [message])
- *
- * Asserts that `value`'s type is _not_ `name`, as determined by
- * `Object.prototype.toString`.
- *
- * assert.notTypeOf('tea', 'number', 'strings are not numbers');
- *
- * @name notTypeOf
- * @param {Mixed} value
- * @param {String} typeof name
- * @param {String} message
- * @api public
- */
-
- assert.notTypeOf = function (val, type, msg) {
- new Assertion(val, msg).to.not.be.a(type);
- };
-
- /**
- * ### .instanceOf(object, constructor, [message])
- *
- * Asserts that `value` is an instance of `constructor`.
- *
- * var Tea = function (name) { this.name = name; }
- * , chai = new Tea('chai');
- *
- * assert.instanceOf(chai, Tea, 'chai is an instance of tea');
- *
- * @name instanceOf
- * @param {Object} object
- * @param {Constructor} constructor
- * @param {String} message
- * @api public
- */
-
- assert.instanceOf = function (val, type, msg) {
- new Assertion(val, msg).to.be.instanceOf(type);
- };
-
- /**
- * ### .notInstanceOf(object, constructor, [message])
- *
- * Asserts `value` is not an instance of `constructor`.
- *
- * var Tea = function (name) { this.name = name; }
- * , chai = new String('chai');
- *
- * assert.notInstanceOf(chai, Tea, 'chai is not an instance of tea');
- *
- * @name notInstanceOf
- * @param {Object} object
- * @param {Constructor} constructor
- * @param {String} message
- * @api public
- */
-
- assert.notInstanceOf = function (val, type, msg) {
- new Assertion(val, msg).to.not.be.instanceOf(type);
- };
-
- /**
- * ### .include(haystack, needle, [message])
- *
- * Asserts that `haystack` includes `needle`. Works
- * for strings and arrays.
- *
- * assert.include('foobar', 'bar', 'foobar contains string "bar"');
- * assert.include([ 1, 2, 3 ], 3, 'array contains value');
- *
- * @name include
- * @param {Array|String} haystack
- * @param {Mixed} needle
- * @param {String} message
- * @api public
- */
-
- assert.include = function (exp, inc, msg) {
- var obj = new Assertion(exp, msg);
-
- if (Array.isArray(exp)) {
- obj.to.include(inc);
- } else if ('string' === typeof exp) {
- obj.to.contain.string(inc);
- } else {
- throw new chai.AssertionError(
- 'expected an array or string'
- , null
- , assert.include
- );
- }
- };
-
- /**
- * ### .notInclude(haystack, needle, [message])
- *
- * Asserts that `haystack` does not include `needle`. Works
- * for strings and arrays.
- *i
- * assert.notInclude('foobar', 'baz', 'string not include substring');
- * assert.notInclude([ 1, 2, 3 ], 4, 'array not include contain value');
- *
- * @name notInclude
- * @param {Array|String} haystack
- * @param {Mixed} needle
- * @param {String} message
- * @api public
- */
-
- assert.notInclude = function (exp, inc, msg) {
- var obj = new Assertion(exp, msg);
-
- if (Array.isArray(exp)) {
- obj.to.not.include(inc);
- } else if ('string' === typeof exp) {
- obj.to.not.contain.string(inc);
- } else {
- throw new chai.AssertionError(
- 'expected an array or string'
- , null
- , assert.notInclude
- );
- }
- };
-
- /**
- * ### .match(value, regexp, [message])
- *
- * Asserts that `value` matches the regular expression `regexp`.
- *
- * assert.match('foobar', /^foo/, 'regexp matches');
- *
- * @name match
- * @param {Mixed} value
- * @param {RegExp} regexp
- * @param {String} message
- * @api public
- */
-
- assert.match = function (exp, re, msg) {
- new Assertion(exp, msg).to.match(re);
- };
-
- /**
- * ### .notMatch(value, regexp, [message])
- *
- * Asserts that `value` does not match the regular expression `regexp`.
- *
- * assert.notMatch('foobar', /^foo/, 'regexp does not match');
- *
- * @name notMatch
- * @param {Mixed} value
- * @param {RegExp} regexp
- * @param {String} message
- * @api public
- */
-
- assert.notMatch = function (exp, re, msg) {
- new Assertion(exp, msg).to.not.match(re);
- };
-
- /**
- * ### .property(object, property, [message])
- *
- * Asserts that `object` has a property named by `property`.
- *
- * assert.property({ tea: { green: 'matcha' }}, 'tea');
- *
- * @name property
- * @param {Object} object
- * @param {String} property
- * @param {String} message
- * @api public
- */
-
- assert.property = function (obj, prop, msg) {
- new Assertion(obj, msg).to.have.property(prop);
- };
-
- /**
- * ### .notProperty(object, property, [message])
- *
- * Asserts that `object` does _not_ have a property named by `property`.
- *
- * assert.notProperty({ tea: { green: 'matcha' }}, 'coffee');
- *
- * @name notProperty
- * @param {Object} object
- * @param {String} property
- * @param {String} message
- * @api public
- */
-
- assert.notProperty = function (obj, prop, msg) {
- new Assertion(obj, msg).to.not.have.property(prop);
- };
-
- /**
- * ### .deepProperty(object, property, [message])
- *
- * Asserts that `object` has a property named by `property`, which can be a
- * string using dot- and bracket-notation for deep reference.
- *
- * assert.deepProperty({ tea: { green: 'matcha' }}, 'tea.green');
- *
- * @name deepProperty
- * @param {Object} object
- * @param {String} property
- * @param {String} message
- * @api public
- */
-
- assert.deepProperty = function (obj, prop, msg) {
- new Assertion(obj, msg).to.have.deep.property(prop);
- };
-
- /**
- * ### .notDeepProperty(object, property, [message])
- *
- * Asserts that `object` does _not_ have a property named by `property`, which
- * can be a string using dot- and bracket-notation for deep reference.
- *
- * assert.notDeepProperty({ tea: { green: 'matcha' }}, 'tea.oolong');
- *
- * @name notDeepProperty
- * @param {Object} object
- * @param {String} property
- * @param {String} message
- * @api public
- */
-
- assert.notDeepProperty = function (obj, prop, msg) {
- new Assertion(obj, msg).to.not.have.deep.property(prop);
- };
-
- /**
- * ### .propertyVal(object, property, value, [message])
- *
- * Asserts that `object` has a property named by `property` with value given
- * by `value`.
- *
- * assert.propertyVal({ tea: 'is good' }, 'tea', 'is good');
- *
- * @name propertyVal
- * @param {Object} object
- * @param {String} property
- * @param {Mixed} value
- * @param {String} message
- * @api public
- */
-
- assert.propertyVal = function (obj, prop, val, msg) {
- new Assertion(obj, msg).to.have.property(prop, val);
- };
-
- /**
- * ### .propertyNotVal(object, property, value, [message])
- *
- * Asserts that `object` has a property named by `property`, but with a value
- * different from that given by `value`.
- *
- * assert.propertyNotVal({ tea: 'is good' }, 'tea', 'is bad');
- *
- * @name propertyNotVal
- * @param {Object} object
- * @param {String} property
- * @param {Mixed} value
- * @param {String} message
- * @api public
- */
-
- assert.propertyNotVal = function (obj, prop, val, msg) {
- new Assertion(obj, msg).to.not.have.property(prop, val);
- };
-
- /**
- * ### .deepPropertyVal(object, property, value, [message])
- *
- * Asserts that `object` has a property named by `property` with value given
- * by `value`. `property` can use dot- and bracket-notation for deep
- * reference.
- *
- * assert.deepPropertyVal({ tea: { green: 'matcha' }}, 'tea.green', 'matcha');
- *
- * @name deepPropertyVal
- * @param {Object} object
- * @param {String} property
- * @param {Mixed} value
- * @param {String} message
- * @api public
- */
-
- assert.deepPropertyVal = function (obj, prop, val, msg) {
- new Assertion(obj, msg).to.have.deep.property(prop, val);
- };
-
- /**
- * ### .deepPropertyNotVal(object, property, value, [message])
- *
- * Asserts that `object` has a property named by `property`, but with a value
- * different from that given by `value`. `property` can use dot- and
- * bracket-notation for deep reference.
- *
- * assert.deepPropertyNotVal({ tea: { green: 'matcha' }}, 'tea.green', 'konacha');
- *
- * @name deepPropertyNotVal
- * @param {Object} object
- * @param {String} property
- * @param {Mixed} value
- * @param {String} message
- * @api public
- */
-
- assert.deepPropertyNotVal = function (obj, prop, val, msg) {
- new Assertion(obj, msg).to.not.have.deep.property(prop, val);
- };
-
- /**
- * ### .lengthOf(object, length, [message])
- *
- * Asserts that `object` has a `length` property with the expected value.
- *
- * assert.lengthOf([1,2,3], 3, 'array has length of 3');
- * assert.lengthOf('foobar', 5, 'string has length of 6');
- *
- * @name lengthOf
- * @param {Mixed} object
- * @param {Number} length
- * @param {String} message
- * @api public
- */
-
- assert.lengthOf = function (exp, len, msg) {
- new Assertion(exp, msg).to.have.length(len);
- };
-
- /**
- * ### .throws(function, [constructor/string/regexp], [string/regexp], [message])
- *
- * Asserts that `function` will throw an error that is an instance of
- * `constructor`, or alternately that it will throw an error with message
- * matching `regexp`.
- *
- * assert.throw(fn, 'function throws a reference error');
- * assert.throw(fn, /function throws a reference error/);
- * assert.throw(fn, ReferenceError);
- * assert.throw(fn, ReferenceError, 'function throws a reference error');
- * assert.throw(fn, ReferenceError, /function throws a reference error/);
- *
- * @name throws
- * @alias throw
- * @alias Throw
- * @param {Function} function
- * @param {ErrorConstructor} constructor
- * @param {RegExp} regexp
- * @param {String} message
- * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
- * @api public
- */
-
- assert.Throw = function (fn, errt, errs, msg) {
- if ('string' === typeof errt || errt instanceof RegExp) {
- errs = errt;
- errt = null;
- }
-
- new Assertion(fn, msg).to.Throw(errt, errs);
- };
-
- /**
- * ### .doesNotThrow(function, [constructor/regexp], [message])
- *
- * Asserts that `function` will _not_ throw an error that is an instance of
- * `constructor`, or alternately that it will not throw an error with message
- * matching `regexp`.
- *
- * assert.doesNotThrow(fn, Error, 'function does not throw');
- *
- * @name doesNotThrow
- * @param {Function} function
- * @param {ErrorConstructor} constructor
- * @param {RegExp} regexp
- * @param {String} message
- * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
- * @api public
- */
-
- assert.doesNotThrow = function (fn, type, msg) {
- if ('string' === typeof type) {
- msg = type;
- type = null;
- }
-
- new Assertion(fn, msg).to.not.Throw(type);
- };
-
- /**
- * ### .operator(val1, operator, val2, [message])
- *
- * Compares two values using `operator`.
- *
- * assert.operator(1, '<', 2, 'everything is ok');
- * assert.operator(1, '>', 2, 'this will fail');
- *
- * @name operator
- * @param {Mixed} val1
- * @param {String} operator
- * @param {Mixed} val2
- * @param {String} message
- * @api public
- */
-
- assert.operator = function (val, operator, val2, msg) {
- if (!~['==', '===', '>', '>=', '<', '<=', '!=', '!=='].indexOf(operator)) {
- throw new Error('Invalid operator "' + operator + '"');
- }
- var test = new Assertion(eval(val + operator + val2), msg);
- test.assert(
- true === flag(test, 'object')
- , 'expected ' + util.inspect(val) + ' to be ' + operator + ' ' + util.inspect(val2)
- , 'expected ' + util.inspect(val) + ' to not be ' + operator + ' ' + util.inspect(val2) );
- };
-
- /**
- * ### .closeTo(actual, expected, delta, [message])
- *
- * Asserts that the target is equal `expected`, to within a +/- `delta` range.
- *
- * assert.closeTo(1.5, 1, 0.5, 'numbers are close');
- *
- * @name closeTo
- * @param {Number} actual
- * @param {Number} expected
- * @param {Number} delta
- * @param {String} message
- * @api public
- */
-
- assert.closeTo = function (act, exp, delta, msg) {
- new Assertion(act, msg).to.be.closeTo(exp, delta);
- };
-
- /**
- * ### .sameMembers(set1, set2, [message])
- *
- * Asserts that `set1` and `set2` have the same members.
- * Order is not taken into account.
- *
- * assert.sameMembers([ 1, 2, 3 ], [ 2, 1, 3 ], 'same members');
- *
- * @name sameMembers
- * @param {Array} superset
- * @param {Array} subset
- * @param {String} message
- * @api public
- */
-
- assert.sameMembers = function (set1, set2, msg) {
- new Assertion(set1, msg).to.have.same.members(set2);
- }
-
- /**
- * ### .includeMembers(superset, subset, [message])
- *
- * Asserts that `subset` is included in `superset`.
- * Order is not taken into account.
- *
- * assert.includeMembers([ 1, 2, 3 ], [ 2, 1 ], 'include members');
- *
- * @name includeMembers
- * @param {Array} superset
- * @param {Array} subset
- * @param {String} message
- * @api public
- */
-
- assert.includeMembers = function (superset, subset, msg) {
- new Assertion(superset, msg).to.include.members(subset);
- }
-
- /*!
- * Undocumented / untested
- */
-
- assert.ifError = function (val, msg) {
- new Assertion(val, msg).to.not.be.ok;
- };
-
- /*!
- * Aliases.
- */
-
- (function alias(name, as){
- assert[as] = assert[name];
- return alias;
- })
- ('Throw', 'throw')
- ('Throw', 'throws');
-};
-
-});
-require.register("chai/lib/chai/interface/expect.js", function(exports, require, module){
-/*!
- * chai
- * Copyright(c) 2011-2013 Jake Luer <ja...@alogicalparadox.com>
- * MIT Licensed
- */
-
-module.exports = function (chai, util) {
- chai.expect = function (val, message) {
- return new chai.Assertion(val, message);
- };
-};
-
-
-});
-require.register("chai/lib/chai/interface/should.js", function(exports, require, module){
-/*!
- * chai
- * Copyright(c) 2011-2013 Jake Luer <ja...@alogicalparadox.com>
- * MIT Licensed
- */
-
-module.exports = function (chai, util) {
- var Assertion = chai.Assertion;
-
- function loadShould () {
- // modify Object.prototype to have `should`
- Object.defineProperty(Object.prototype, 'should',
- {
- set: function (value) {
- // See https://github.com/chaijs/chai/issues/86: this makes
- // `whatever.should = someValue` actually set `someValue`, which is
- // especially useful for `global.should = require('chai').should()`.
- //
- // Note that we have to use [[DefineProperty]] instead of [[Put]]
- // since otherwise we would trigger this very setter!
- Object.defineProperty(this, 'should', {
- value: value,
- enumerable: true,
- configurable: true,
- writable: true
- });
- }
- , get: function(){
- if (this instanceof String || this instanceof Number) {
- return new Assertion(this.constructor(this));
- } else if (this instanceof Boolean) {
- return new Assertion(this == true);
- }
- return new Assertion(this);
- }
- , configurable: true
- });
-
- var should = {};
-
- should.equal = function (val1, val2, msg) {
- new Assertion(val1, msg).to.equal(val2);
- };
-
- should.Throw = function (fn, errt, errs, msg) {
- new Assertion(fn, msg).to.Throw(errt, errs);
- };
-
- should.exist = function (val, msg) {
- new Assertion(val, msg).to.exist;
- }
-
- // negation
- should.not = {}
-
- should.not.equal = function (val1, val2, msg) {
- new Assertion(val1, msg).to.not.equal(val2);
- };
-
- should.not.Throw = function (fn, errt, errs, msg) {
- new Assertion(fn, msg).to.not.Throw(errt, errs);
- };
-
- should.not.exist = function (val, msg) {
- new Assertion(val, msg).to.not.exist;
- }
-
- should['throw'] = should['Throw'];
- should.not['throw'] = should.not['Throw'];
-
- return should;
- };
-
- chai.should = loadShould;
- chai.Should = loadShould;
-};
-
-});
-require.register("chai/lib/chai/utils/addChainableMethod.js", function(exports, require, module){
-/*!
- * Chai - addChainingMethod utility
- * Copyright(c) 2012-2013 Jake Luer <ja...@alogicalparadox.com>
- * MIT Licensed
- */
-
-/*!
- * Module dependencies
- */
-
-var transferFlags = require('./transferFlags');
-
-/*!
- * Module variables
- */
-
-// Check whether `__proto__` is supported
-var hasProtoSupport = '__proto__' in Object;
-
-// Without `__proto__` support, this module will need to add properties to a function.
-// However, some Function.prototype methods cannot be overwritten,
-// and there seems no easy cross-platform way to detect them (@see chaijs/chai/issues/69).
-var excludeNames = /^(?:length|name|arguments|caller)$/;
-
-// Cache `Function` properties
-var call = Function.prototype.call,
- apply = Function.prototype.apply;
-
-/**
- * ### addChainableMethod (ctx, name, method, chainingBehavior)
- *
- * Adds a method to an object, such that the method can also be chained.
- *
- * utils.addChainableMethod(chai.Assertion.prototype, 'foo', function (str) {
- * var obj = utils.flag(this, 'object');
- * new chai.Assertion(obj).to.be.equal(str);
- * });
- *
- * Can also be accessed directly from `chai.Assertion`.
- *
- * chai.Assertion.addChainableMethod('foo', fn, chainingBehavior);
- *
- * The result can then be used as both a method assertion, executing both `method` and
- * `chainingBehavior`, or as a language chain, which only executes `chainingBehavior`.
- *
- * expect(fooStr).to.be.foo('bar');
- * expect(fooStr).to.be.foo.equal('foo');
- *
- * @param {Object} ctx object to which the method is added
- * @param {String} name of method to add
- * @param {Function} method function to be used for `name`, when called
- * @param {Function} chainingBehavior function to be called every time the property is accessed
- * @name addChainableMethod
- * @api public
- */
-
-module.exports = function (ctx, name, method, chainingBehavior) {
- if (typeof chainingBehavior !== 'function')
- chainingBehavior = function () { };
-
- Object.defineProperty(ctx, name,
- { get: function () {
- chainingBehavior.call(this);
-
- var assert = function () {
- var result = method.apply(this, arguments);
- return result === undefined ? this : result;
- };
-
- // Use `__proto__` if available
- if (hasProtoSupport) {
- // Inherit all properties from the object by replacing the `Function` prototype
- var prototype = assert.__proto__ = Object.create(this);
- // Restore the `call` and `apply` methods from `Function`
- prototype.call = call;
- prototype.apply = apply;
- }
- // Otherwise, redefine all properties (slow!)
- else {
- var asserterNames = Object.getOwnPropertyNames(ctx);
- asserterNames.forEach(function (asserterName) {
- if (!excludeNames.test(asserterName)) {
- var pd = Object.getOwnPropertyDescriptor(ctx, asserterName);
- Object.defineProperty(assert, asserterName, pd);
- }
- });
- }
-
- transferFlags(this, assert);
- return assert;
- }
- , configurable: true
- });
-};
-
-});
-require.register("chai/lib/chai/utils/addMethod.js", function(exports, require, module){
-/*!
- * Chai - addMethod utility
- * Copyright(c) 2012-2013 Jake Luer <ja...@alogicalparadox.com>
- * MIT Licensed
- */
-
-/**
- * ### .addMethod (ctx, name, method)
- *
- * Adds a method to the prototype of an object.
- *
- * utils.addMethod(chai.Assertion.prototype, 'foo', function (str) {
- * var obj = utils.flag(this, 'object');
- * new chai.Assertion(obj).to.be.equal(str);
- * });
- *
- * Can also be accessed directly from `chai.Assertion`.
- *
- * chai.Assertion.addMethod('foo', fn);
- *
- * Then can be used as any other assertion.
- *
- * expect(fooStr).to.be.foo('bar');
- *
- * @param {Object} ctx object to which the method is added
- * @param {String} name of method to add
- * @param {Function} method function to be used for name
- * @name addMethod
- * @api public
- */
-
-module.exports = function (ctx, name, method) {
- ctx[name] = function () {
- var result = method.apply(this, arguments);
- return result === undefined ? this : result;
- };
-};
-
-});
-require.register("chai/lib/chai/utils/addProperty.js", function(exports, require, module){
-/*!
- * Chai - addProperty utility
- * Copyright(c) 2012-2013 Jake Luer <ja...@alogicalparadox.com>
- * MIT Licensed
- */
-
-/**
- * ### addProperty (ctx, name, getter)
- *
- * Adds a property to the prototype of an object.
- *
- * utils.addProperty(chai.Assertion.prototype, 'foo', function () {
- * var obj = utils.flag(this, 'object');
- * new chai.Assertion(obj).to.be.instanceof(Foo);
- * });
- *
- * Can also be accessed directly from `chai.Assertion`.
- *
- * chai.Assertion.addProperty('foo', fn);
- *
- * Then can be used as any other assertion.
- *
- * expect(myFoo).to.be.foo;
- *
- * @param {Object} ctx object to which the property is added
- * @param {String} name of property to add
- * @param {Function} getter function to be used for name
- * @name addProperty
- * @api public
- */
-
-module.exports = function (ctx, name, getter) {
- Object.defineProperty(ctx, name,
- { get: function () {
- var result = getter.call(this);
- return result === undefined ? this : result;
- }
- , configurable: true
- });
-};
-
-});
-require.register("chai/lib/chai/utils/eql.js", function(exports, require, module){
-// This is (almost) directly from Node.js assert
-// https://github.com/joyent/node/blob/f8c335d0caf47f16d31413f89aa28eda3878e3aa/lib/assert.js
-
-module.exports = _deepEqual;
-
-var getEnumerableProperties = require('./getEnumerableProperties');
-
-// for the browser
-var Buffer;
-try {
- Buffer = require('buffer').Buffer;
-} catch (ex) {
- Buffer = {
- isBuffer: function () { return false; }
- };
-}
-
-function _deepEqual(actual, expected, memos) {
-
- // 7.1. All identical values are equivalent, as determined by ===.
- if (actual === expected) {
- return true;
-
- } else if (Buffer.isBuffer(actual) && Buffer.isBuffer(expected)) {
- if (actual.length != expected.length) return false;
-
- for (var i = 0; i < actual.length; i++) {
- if (actual[i] !== expected[i]) return false;
- }
-
- return true;
-
- // 7.2. If the expected value is a Date object, the actual value is
- // equivalent if it is also a Date object that refers to the same time.
- } else if (expected instanceof Date) {
- if (!(actual instanceof Date)) return false;
- return actual.getTime() === expected.getTime();
-
- // 7.3. Other pairs that do not both pass typeof value == 'object',
- // equivalence is determined by ==.
- } else if (typeof actual != 'object' && typeof expected != 'object') {
- return actual === expected;
-
- } else if (expected instanceof RegExp) {
- if (!(actual instanceof RegExp)) return false;
- return actual.toString() === expected.toString();
-
- // 7.4. For all other Object pairs, including Array objects, equivalence is
- // determined by having the same number of owned properties (as verified
- // with Object.prototype.hasOwnProperty.call), the same set of keys
- // (although not necessarily the same order), equivalent values for every
- // corresponding key, and an identical 'prototype' property. Note: this
- // accounts for both named and indexed properties on Arrays.
- } else {
- return objEquiv(actual, expected, memos);
- }
-}
-
-function isUndefinedOrNull(value) {
- return value === null || value === undefined;
-}
-
-function isArguments(object) {
- return Object.prototype.toString.call(object) == '[object Arguments]';
-}
-
-function objEquiv(a, b, memos) {
- if (isUndefinedOrNull(a) || isUndefinedOrNull(b))
- return false;
-
- // an identical 'prototype' property.
- if (a.prototype !== b.prototype) return false;
-
- // check if we have already compared a and b
- var i;
- if (memos) {
- for(i = 0; i < memos.length; i++) {
- if ((memos[i][0] === a && memos[i][1] === b) ||
- (memos[i][0] === b && memos[i][1] === a))
- return true;
- }
- } else {
- memos = [];
- }
-
- //~~~I've managed to break Object.keys through screwy arguments passing.
- // Converting to array solves the problem.
- if (isArguments(a)) {
- if (!isArguments(b)) {
- return false;
- }
- a = pSlice.call(a);
- b = pSlice.call(b);
- return _deepEqual(a, b, memos);
- }
- try {
- var ka = getEnumerableProperties(a),
- kb = getEnumerableProperties(b),
- key;
- } catch (e) {//happens when one is a string literal and the other isn't
- return false;
- }
-
- // having the same number of owned properties (keys incorporates
- // hasOwnProperty)
- if (ka.length != kb.length)
- return false;
-
- //the same set of keys (although not necessarily the same order),
- ka.sort();
- kb.sort();
- //~~~cheap key test
- for (i = ka.length - 1; i >= 0; i--) {
- if (ka[i] != kb[i])
- return false;
- }
-
- // remember objects we have compared to guard against circular references
- memos.push([ a, b ]);
-
- //equivalent values for every corresponding key, and
- //~~~possibly expensive deep test
- for (i = ka.length - 1; i >= 0; i--) {
- key = ka[i];
- if (!_deepEqual(a[key], b[key], memos)) return false;
- }
-
- return true;
-}
-
-});
-require.register("chai/lib/chai/utils/flag.js", function(exports, require, module){
-/*!
- * Chai - flag utility
- * Copyright(c) 2012-2013 Jake Luer <ja...@alogicalparadox.com>
- * MIT Licensed
- */
-
-/**
- * ### flag(object ,key, [value])
- *
- * Get or set a flag value on an object. If a
- * value is provided it will be set, else it will
- * return the currently set value or `undefined` if
- * the value is not set.
- *
- * utils.flag(this, 'foo', 'bar'); // setter
- * utils.flag(this, 'foo'); // getter, returns `bar`
- *
- * @param {Object} object (constructed Assertion
- * @param {String} key
- * @param {Mixed} value (optional)
- * @name flag
- * @api private
- */
-
-module.exports = function (obj, key, value) {
- var flags = obj.__flags || (obj.__flags = Object.create(null));
- if (arguments.length === 3) {
- flags[key] = value;
- } else {
- return flags[key];
- }
-};
-
-});
-require.register("chai/lib/chai/utils/getActual.js", function(exports, require, module){
-/*!
- * Chai - getActual utility
- * Copyright(c) 2012-2013 Jake Luer <ja...@alogicalparadox.com>
- * MIT Licensed
- */
-
-/**
- * # getActual(object, [actual])
- *
- * Returns the `actual` value for an Assertion
- *
- * @param {Object} object (constructed Assertion)
- * @param {Arguments} chai.Assertion.prototype.assert arguments
- */
-
-module.exports = function (obj, args) {
- var actual = args[4];
- return 'undefined' !== typeof actual ? actual : obj._obj;
-};
-
-});
-require.register("chai/lib/chai/utils/getEnumerableProperties.js", function(exports, require, module){
-/*!
- * Chai - getEnumerableProperties utility
- * Copyright(c) 2012-2013 Jake Luer <ja...@alogicalparadox.com>
- * MIT Licensed
- */
-
-/**
- * ### .getEnumerableProperties(object)
- *
- * This allows the retrieval of enumerable property names of an object,
- * inherited or not.
- *
- * @param {Object} object
- * @returns {Array}
- * @name getEnumerableProperties
- * @api public
- */
-
-module.exports = function getEnumerableProperties(object) {
- var result = [];
- for (var name in object) {
- result.push(name);
- }
- return result;
-};
-
-});
-require.register("chai/lib/chai/utils/getMessage.js", function(exports, require, module){
-/*!
- * Chai - message composition utility
-
<TRUNCATED>
[09/26] Remove fauxton from 1.4.x branch.
Posted by dj...@apache.org.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/tables.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/tables.less b/src/fauxton/assets/less/bootstrap/tables.less
deleted file mode 100644
index 3f2c7f7..0000000
--- a/src/fauxton/assets/less/bootstrap/tables.less
+++ /dev/null
@@ -1,236 +0,0 @@
-//
-// Tables
-// --------------------------------------------------
-
-
-// BASE TABLES
-// -----------------
-
-table {
- max-width: 100%;
- background-color: @tableBackground;
- border-collapse: collapse;
- border-spacing: 0;
-}
-
-// BASELINE STYLES
-// ---------------
-
-.table {
- width: 100%;
- margin-bottom: @baseLineHeight;
- // Cells
- th,
- td {
- padding: 8px;
- line-height: @baseLineHeight;
- text-align: left;
- vertical-align: top;
- border-top: 1px solid @tableBorder;
- }
- th {
- font-weight: bold;
- }
- // Bottom align for column headings
- thead th {
- vertical-align: bottom;
- }
- // Remove top border from thead by default
- caption + thead tr:first-child th,
- caption + thead tr:first-child td,
- colgroup + thead tr:first-child th,
- colgroup + thead tr:first-child td,
- thead:first-child tr:first-child th,
- thead:first-child tr:first-child td {
- border-top: 0;
- }
- // Account for multiple tbody instances
- tbody + tbody {
- border-top: 2px solid @tableBorder;
- }
-}
-
-
-
-// CONDENSED TABLE W/ HALF PADDING
-// -------------------------------
-
-.table-condensed {
- th,
- td {
- padding: 4px 5px;
- }
-}
-
-
-// BORDERED VERSION
-// ----------------
-
-.table-bordered {
- border: 1px solid @tableBorder;
- border-collapse: separate; // Done so we can round those corners!
- *border-collapse: collapse; // IE7 can't round corners anyway
- border-left: 0;
- .border-radius(@baseBorderRadius);
- th,
- td {
- border-left: 1px solid @tableBorder;
- }
- // Prevent a double border
- caption + thead tr:first-child th,
- caption + tbody tr:first-child th,
- caption + tbody tr:first-child td,
- colgroup + thead tr:first-child th,
- colgroup + tbody tr:first-child th,
- colgroup + tbody tr:first-child td,
- thead:first-child tr:first-child th,
- tbody:first-child tr:first-child th,
- tbody:first-child tr:first-child td {
- border-top: 0;
- }
- // For first th or td in the first row in the first thead or tbody
- thead:first-child tr:first-child th:first-child,
- tbody:first-child tr:first-child td:first-child {
- -webkit-border-top-left-radius: 4px;
- border-top-left-radius: 4px;
- -moz-border-radius-topleft: 4px;
- }
- thead:first-child tr:first-child th:last-child,
- tbody:first-child tr:first-child td:last-child {
- -webkit-border-top-right-radius: 4px;
- border-top-right-radius: 4px;
- -moz-border-radius-topright: 4px;
- }
- // For first th or td in the first row in the first thead or tbody
- thead:last-child tr:last-child th:first-child,
- tbody:last-child tr:last-child td:first-child,
- tfoot:last-child tr:last-child td:first-child {
- .border-radius(0 0 0 4px);
- -webkit-border-bottom-left-radius: 4px;
- border-bottom-left-radius: 4px;
- -moz-border-radius-bottomleft: 4px;
- }
- thead:last-child tr:last-child th:last-child,
- tbody:last-child tr:last-child td:last-child,
- tfoot:last-child tr:last-child td:last-child {
- -webkit-border-bottom-right-radius: 4px;
- border-bottom-right-radius: 4px;
- -moz-border-radius-bottomright: 4px;
- }
-
- // Special fixes to round the left border on the first td/th
- caption + thead tr:first-child th:first-child,
- caption + tbody tr:first-child td:first-child,
- colgroup + thead tr:first-child th:first-child,
- colgroup + tbody tr:first-child td:first-child {
- -webkit-border-top-left-radius: 4px;
- border-top-left-radius: 4px;
- -moz-border-radius-topleft: 4px;
- }
- caption + thead tr:first-child th:last-child,
- caption + tbody tr:first-child td:last-child,
- colgroup + thead tr:first-child th:last-child,
- colgroup + tbody tr:first-child td:last-child {
- -webkit-border-top-right-radius: 4px;
- border-top-right-radius: 4px;
- -moz-border-radius-topright: 4px;
- }
-
-}
-
-
-
-
-// ZEBRA-STRIPING
-// --------------
-
-// Default zebra-stripe styles (alternating gray and transparent backgrounds)
-.table-striped {
- tbody {
- tr:nth-child(odd) td,
- tr:nth-child(odd) th {
- background-color: @tableBackgroundAccent;
- }
- }
-}
-
-
-// HOVER EFFECT
-// ------------
-// Placed here since it has to come after the potential zebra striping
-.table-hover {
- tbody {
- tr:hover td,
- tr:hover th {
- background-color: @tableBackgroundHover;
- }
- }
-}
-
-
-// TABLE CELL SIZING
-// -----------------
-
-// Reset default grid behavior
-table td[class*="span"],
-table th[class*="span"],
-.row-fluid table td[class*="span"],
-.row-fluid table th[class*="span"] {
- display: table-cell;
- float: none; // undo default grid column styles
- margin-left: 0; // undo default grid column styles
-}
-
-// Change the column widths to account for td/th padding
-.table td,
-.table th {
- &.span1 { .tableColumns(1); }
- &.span2 { .tableColumns(2); }
- &.span3 { .tableColumns(3); }
- &.span4 { .tableColumns(4); }
- &.span5 { .tableColumns(5); }
- &.span6 { .tableColumns(6); }
- &.span7 { .tableColumns(7); }
- &.span8 { .tableColumns(8); }
- &.span9 { .tableColumns(9); }
- &.span10 { .tableColumns(10); }
- &.span11 { .tableColumns(11); }
- &.span12 { .tableColumns(12); }
-}
-
-
-
-// TABLE BACKGROUNDS
-// -----------------
-// Exact selectors below required to override .table-striped
-
-.table tbody tr {
- &.success td {
- background-color: @successBackground;
- }
- &.error td {
- background-color: @errorBackground;
- }
- &.warning td {
- background-color: @warningBackground;
- }
- &.info td {
- background-color: @infoBackground;
- }
-}
-
-// Hover states for .table-hover
-.table-hover tbody tr {
- &.success:hover td {
- background-color: darken(@successBackground, 5%);
- }
- &.error:hover td {
- background-color: darken(@errorBackground, 5%);
- }
- &.warning:hover td {
- background-color: darken(@warningBackground, 5%);
- }
- &.info:hover td {
- background-color: darken(@infoBackground, 5%);
- }
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/thumbnails.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/thumbnails.less b/src/fauxton/assets/less/bootstrap/thumbnails.less
deleted file mode 100644
index a84a7d3..0000000
--- a/src/fauxton/assets/less/bootstrap/thumbnails.less
+++ /dev/null
@@ -1,52 +0,0 @@
-//
-// Thumbnails
-// --------------------------------------------------
-
-
-// Note: `.thumbnails` and `.thumbnails > li` are overriden in responsive files
-
-// Make wrapper ul behave like the grid
-.thumbnails {
- margin-left: -@gridGutterWidth;
- list-style: none;
- .clearfix();
-}
-// Fluid rows have no left margin
-.row-fluid .thumbnails {
- margin-left: 0;
-}
-
-// Float li to make thumbnails appear in a row
-.thumbnails > li {
- float: left; // Explicity set the float since we don't require .span* classes
- margin-bottom: @baseLineHeight;
- margin-left: @gridGutterWidth;
-}
-
-// The actual thumbnail (can be `a` or `div`)
-.thumbnail {
- display: block;
- padding: 4px;
- line-height: @baseLineHeight;
- border: 1px solid #ddd;
- .border-radius(@baseBorderRadius);
- .box-shadow(0 1px 3px rgba(0,0,0,.055));
- .transition(all .2s ease-in-out);
-}
-// Add a hover state for linked versions only
-a.thumbnail:hover {
- border-color: @linkColor;
- .box-shadow(0 1px 4px rgba(0,105,214,.25));
-}
-
-// Images and captions
-.thumbnail > img {
- display: block;
- max-width: 100%;
- margin-left: auto;
- margin-right: auto;
-}
-.thumbnail .caption {
- padding: 9px;
- color: @gray;
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/tooltip.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/tooltip.less b/src/fauxton/assets/less/bootstrap/tooltip.less
deleted file mode 100644
index 93fac8d..0000000
--- a/src/fauxton/assets/less/bootstrap/tooltip.less
+++ /dev/null
@@ -1,70 +0,0 @@
-//
-// Tooltips
-// --------------------------------------------------
-
-
-// Base class
-.tooltip {
- position: absolute;
- z-index: @zindexTooltip;
- display: block;
- visibility: visible;
- padding: 5px;
- font-size: 11px;
- .opacity(0);
- &.in { .opacity(80); }
- &.top { margin-top: -3px; }
- &.right { margin-left: 3px; }
- &.bottom { margin-top: 3px; }
- &.left { margin-left: -3px; }
-}
-
-// Wrapper for the tooltip content
-.tooltip-inner {
- max-width: 200px;
- padding: 3px 8px;
- color: @tooltipColor;
- text-align: center;
- text-decoration: none;
- background-color: @tooltipBackground;
- .border-radius(@baseBorderRadius);
-}
-
-// Arrows
-.tooltip-arrow {
- position: absolute;
- width: 0;
- height: 0;
- border-color: transparent;
- border-style: solid;
-}
-.tooltip {
- &.top .tooltip-arrow {
- bottom: 0;
- left: 50%;
- margin-left: -@tooltipArrowWidth;
- border-width: @tooltipArrowWidth @tooltipArrowWidth 0;
- border-top-color: @tooltipArrowColor;
- }
- &.right .tooltip-arrow {
- top: 50%;
- left: 0;
- margin-top: -@tooltipArrowWidth;
- border-width: @tooltipArrowWidth @tooltipArrowWidth @tooltipArrowWidth 0;
- border-right-color: @tooltipArrowColor;
- }
- &.left .tooltip-arrow {
- top: 50%;
- right: 0;
- margin-top: -@tooltipArrowWidth;
- border-width: @tooltipArrowWidth 0 @tooltipArrowWidth @tooltipArrowWidth;
- border-left-color: @tooltipArrowColor;
- }
- &.bottom .tooltip-arrow {
- top: 0;
- left: 50%;
- margin-left: -@tooltipArrowWidth;
- border-width: 0 @tooltipArrowWidth @tooltipArrowWidth;
- border-bottom-color: @tooltipArrowColor;
- }
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/type.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/type.less b/src/fauxton/assets/less/bootstrap/type.less
deleted file mode 100644
index 3b428e7..0000000
--- a/src/fauxton/assets/less/bootstrap/type.less
+++ /dev/null
@@ -1,227 +0,0 @@
-//
-// Typography
-// --------------------------------------------------
-
-
-// Body text
-// -------------------------
-
-p {
- margin: 0 0 @baseLineHeight / 2;
-}
-.lead {
- margin-bottom: @baseLineHeight;
- font-size: @baseFontSize * 1.5;
- font-weight: 200;
- line-height: @baseLineHeight * 1.5;
-}
-
-
-// Emphasis & misc
-// -------------------------
-
-small {
- font-size: 85%; // Ex: 14px base font * 85% = about 12px
-}
-strong {
- font-weight: bold;
-}
-em {
- font-style: italic;
-}
-cite {
- font-style: normal;
-}
-
-// Utility classes
-.muted {
- color: @grayLight;
-}
-.text-warning { color: @warningText; }
-a.text-warning:hover { color: darken(@warningText, 10%); }
-
-.text-error { color: @errorText; }
-a.text-error:hover { color: darken(@errorText, 10%); }
-
-.text-info { color: @infoText; }
-a.text-info:hover { color: darken(@infoText, 10%); }
-
-.text-success { color: @successText; }
-a.text-success:hover { color: darken(@successText, 10%); }
-
-
-// Headings
-// -------------------------
-
-h1, h2, h3, h4, h5, h6 {
- margin: (@baseLineHeight / 2) 0;
- font-family: @headingsFontFamily;
- font-weight: @headingsFontWeight;
- line-height: @baseLineHeight;
- color: @headingsColor;
- text-rendering: optimizelegibility; // Fix the character spacing for headings
- small {
- font-weight: normal;
- line-height: 1;
- color: @grayLight;
- }
-}
-
-h1,
-h2,
-h3 { line-height: @baseLineHeight * 2; }
-
-h1 { font-size: @baseFontSize * 2.75; } // ~38px
-h2 { font-size: @baseFontSize * 2.25; } // ~32px
-h3 { font-size: @baseFontSize * 1.75; } // ~24px
-h4 { font-size: @baseFontSize * 1.25; } // ~18px
-h5 { font-size: @baseFontSize; }
-h6 { font-size: @baseFontSize * 0.85; } // ~12px
-
-h1 small { font-size: @baseFontSize * 1.75; } // ~24px
-h2 small { font-size: @baseFontSize * 1.25; } // ~18px
-h3 small { font-size: @baseFontSize; }
-h4 small { font-size: @baseFontSize; }
-
-
-// Page header
-// -------------------------
-
-.page-header {
- padding-bottom: (@baseLineHeight / 2) - 1;
- margin: @baseLineHeight 0 (@baseLineHeight * 1.5);
- border-bottom: 1px solid @grayLighter;
-}
-
-
-
-// Lists
-// --------------------------------------------------
-
-// Unordered and Ordered lists
-ul, ol {
- padding: 0;
- margin: 0 0 @baseLineHeight / 2 25px;
-}
-ul ul,
-ul ol,
-ol ol,
-ol ul {
- margin-bottom: 0;
-}
-li {
- line-height: @baseLineHeight;
-}
-ul.unstyled,
-ol.unstyled {
- margin-left: 0;
- list-style: none;
-}
-
-// Description Lists
-dl {
- margin-bottom: @baseLineHeight;
-}
-dt,
-dd {
- line-height: @baseLineHeight;
-}
-dt {
- font-weight: bold;
-}
-dd {
- margin-left: @baseLineHeight / 2;
-}
-// Horizontal layout (like forms)
-.dl-horizontal {
- .clearfix(); // Ensure dl clears floats if empty dd elements present
- dt {
- float: left;
- width: @horizontalComponentOffset - 20;
- clear: left;
- text-align: right;
- .text-overflow();
- }
- dd {
- margin-left: @horizontalComponentOffset;
- }
-}
-
-// MISC
-// ----
-
-// Horizontal rules
-hr {
- margin: @baseLineHeight 0;
- border: 0;
- border-top: 1px solid @hrBorder;
- border-bottom: 1px solid @white;
-}
-
-// Abbreviations and acronyms
-abbr[title],
-// Added data-* attribute to help out our tooltip plugin, per https://github.com/twitter/bootstrap/issues/5257
-abbr[data-original-title] {
- cursor: help;
- border-bottom: 1px dotted @grayLight;
-}
-abbr.initialism {
- font-size: 90%;
- text-transform: uppercase;
-}
-
-// Blockquotes
-blockquote {
- padding: 0 0 0 15px;
- margin: 0 0 @baseLineHeight;
- border-left: 5px solid @grayLighter;
- p {
- margin-bottom: 0;
- #font > .shorthand(16px,300,@baseLineHeight * 1.25);
- }
- small {
- display: block;
- line-height: @baseLineHeight;
- color: @grayLight;
- &:before {
- content: '\2014 \00A0';
- }
- }
-
- // Float right with text-align: right
- &.pull-right {
- float: right;
- padding-right: 15px;
- padding-left: 0;
- border-right: 5px solid @grayLighter;
- border-left: 0;
- p,
- small {
- text-align: right;
- }
- small {
- &:before {
- content: '';
- }
- &:after {
- content: '\00A0 \2014';
- }
- }
- }
-}
-
-// Quotes
-q:before,
-q:after,
-blockquote:before,
-blockquote:after {
- content: "";
-}
-
-// Addresses
-address {
- display: block;
- margin-bottom: @baseLineHeight;
- font-style: normal;
- line-height: @baseLineHeight;
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/utilities.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/utilities.less b/src/fauxton/assets/less/bootstrap/utilities.less
deleted file mode 100644
index 314b4ff..0000000
--- a/src/fauxton/assets/less/bootstrap/utilities.less
+++ /dev/null
@@ -1,30 +0,0 @@
-//
-// Utility classes
-// --------------------------------------------------
-
-
-// Quick floats
-.pull-right {
- float: right;
-}
-.pull-left {
- float: left;
-}
-
-// Toggling content
-.hide {
- display: none;
-}
-.show {
- display: block;
-}
-
-// Visibility
-.invisible {
- visibility: hidden;
-}
-
-// For Affix plugin
-.affix {
- position: fixed;
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/variables.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/variables.less b/src/fauxton/assets/less/bootstrap/variables.less
deleted file mode 100644
index 3fb5274..0000000
--- a/src/fauxton/assets/less/bootstrap/variables.less
+++ /dev/null
@@ -1,301 +0,0 @@
-//
-// Variables
-// --------------------------------------------------
-
-
-// Global values
-// --------------------------------------------------
-
-
-// Grays
-// -------------------------
-@black: #000;
-@grayDarker: #222;
-@grayDark: #333;
-@gray: #555;
-@grayLight: #999;
-@grayLighter: #eee;
-@white: #fff;
-
-
-// Accent colors
-// -------------------------
-@blue: #049cdb;
-@blueDark: #0064cd;
-@green: #46a546;
-@red: #9d261d;
-@yellow: #ffc40d;
-@orange: #f89406;
-@pink: #c3325f;
-@purple: #7a43b6;
-
-
-// Scaffolding
-// -------------------------
-@bodyBackground: @white;
-@textColor: @grayDark;
-
-
-// Links
-// -------------------------
-@linkColor: #08c;
-@linkColorHover: darken(@linkColor, 15%);
-
-
-// Typography
-// -------------------------
-@sansFontFamily: "Helvetica Neue", Helvetica, Arial, sans-serif;
-@serifFontFamily: Georgia, "Times New Roman", Times, serif;
-@monoFontFamily: Monaco, Menlo, Consolas, "Courier New", monospace;
-
-@baseFontSize: 14px;
-@baseFontFamily: @sansFontFamily;
-@baseLineHeight: 20px;
-@altFontFamily: @serifFontFamily;
-
-@headingsFontFamily: inherit; // empty to use BS default, @baseFontFamily
-@headingsFontWeight: bold; // instead of browser default, bold
-@headingsColor: inherit; // empty to use BS default, @textColor
-
-
-// Component sizing
-// -------------------------
-// Based on 14px font-size and 20px line-height
-
-@fontSizeLarge: @baseFontSize * 1.25; // ~18px
-@fontSizeSmall: @baseFontSize * 0.85; // ~12px
-@fontSizeMini: @baseFontSize * 0.75; // ~11px
-
-@paddingLarge: 11px 19px; // 44px
-@paddingSmall: 2px 10px; // 26px
-@paddingMini: 1px 6px; // 24px
-
-@baseBorderRadius: 4px;
-@borderRadiusLarge: 6px;
-@borderRadiusSmall: 3px;
-
-
-// Tables
-// -------------------------
-@tableBackground: transparent; // overall background-color
-@tableBackgroundAccent: #f9f9f9; // for striping
-@tableBackgroundHover: #f5f5f5; // for hover
-@tableBorder: #ddd; // table and cell border
-
-// Buttons
-// -------------------------
-@btnBackground: @white;
-@btnBackgroundHighlight: darken(@white, 10%);
-@btnBorder: #bbb;
-
-@btnPrimaryBackground: @linkColor;
-@btnPrimaryBackgroundHighlight: spin(@btnPrimaryBackground, 20%);
-
-@btnInfoBackground: #5bc0de;
-@btnInfoBackgroundHighlight: #2f96b4;
-
-@btnSuccessBackground: #62c462;
-@btnSuccessBackgroundHighlight: #51a351;
-
-@btnWarningBackground: lighten(@orange, 15%);
-@btnWarningBackgroundHighlight: @orange;
-
-@btnDangerBackground: #ee5f5b;
-@btnDangerBackgroundHighlight: #bd362f;
-
-@btnInverseBackground: #444;
-@btnInverseBackgroundHighlight: @grayDarker;
-
-
-// Forms
-// -------------------------
-@inputBackground: @white;
-@inputBorder: #ccc;
-@inputBorderRadius: @baseBorderRadius;
-@inputDisabledBackground: @grayLighter;
-@formActionsBackground: #f5f5f5;
-@inputHeight: @baseLineHeight + 10px; // base line-height + 8px vertical padding + 2px top/bottom border
-
-
-// Dropdowns
-// -------------------------
-@dropdownBackground: @white;
-@dropdownBorder: rgba(0,0,0,.2);
-@dropdownDividerTop: #e5e5e5;
-@dropdownDividerBottom: @white;
-
-@dropdownLinkColor: @grayDark;
-@dropdownLinkColorHover: @white;
-@dropdownLinkColorActive: @dropdownLinkColor;
-
-@dropdownLinkBackgroundActive: @linkColor;
-@dropdownLinkBackgroundHover: @dropdownLinkBackgroundActive;
-
-
-
-// COMPONENT VARIABLES
-// --------------------------------------------------
-
-
-// Z-index master list
-// -------------------------
-// Used for a bird's eye view of components dependent on the z-axis
-// Try to avoid customizing these :)
-@zindexDropdown: 1000;
-@zindexPopover: 1010;
-@zindexTooltip: 1030;
-@zindexFixedNavbar: 1030;
-@zindexModalBackdrop: 1040;
-@zindexModal: 1050;
-
-
-// Sprite icons path
-// -------------------------
-@iconSpritePath: "../img/glyphicons-halflings.png";
-@iconWhiteSpritePath: "../img/glyphicons-halflings-white.png";
-
-
-// Input placeholder text color
-// -------------------------
-@placeholderText: @grayLight;
-
-
-// Hr border color
-// -------------------------
-@hrBorder: @grayLighter;
-
-
-// Horizontal forms & lists
-// -------------------------
-@horizontalComponentOffset: 180px;
-
-
-// Wells
-// -------------------------
-@wellBackground: #f5f5f5;
-
-
-// Navbar
-// -------------------------
-@navbarCollapseWidth: 979px;
-@navbarCollapseDesktopWidth: @navbarCollapseWidth + 1;
-
-@navbarHeight: 40px;
-@navbarBackgroundHighlight: #ffffff;
-@navbarBackground: darken(@navbarBackgroundHighlight, 5%);
-@navbarBorder: darken(@navbarBackground, 12%);
-
-@navbarText: #777;
-@navbarLinkColor: #777;
-@navbarLinkColorHover: @grayDark;
-@navbarLinkColorActive: @gray;
-@navbarLinkBackgroundHover: transparent;
-@navbarLinkBackgroundActive: darken(@navbarBackground, 5%);
-
-@navbarBrandColor: @navbarLinkColor;
-
-// Inverted navbar
-@navbarInverseBackground: #111111;
-@navbarInverseBackgroundHighlight: #222222;
-@navbarInverseBorder: #252525;
-
-@navbarInverseText: @grayLight;
-@navbarInverseLinkColor: @grayLight;
-@navbarInverseLinkColorHover: @white;
-@navbarInverseLinkColorActive: @navbarInverseLinkColorHover;
-@navbarInverseLinkBackgroundHover: transparent;
-@navbarInverseLinkBackgroundActive: @navbarInverseBackground;
-
-@navbarInverseSearchBackground: lighten(@navbarInverseBackground, 25%);
-@navbarInverseSearchBackgroundFocus: @white;
-@navbarInverseSearchBorder: @navbarInverseBackground;
-@navbarInverseSearchPlaceholderColor: #ccc;
-
-@navbarInverseBrandColor: @navbarInverseLinkColor;
-
-
-// Pagination
-// -------------------------
-@paginationBackground: #fff;
-@paginationBorder: #ddd;
-@paginationActiveBackground: #f5f5f5;
-
-
-// Hero unit
-// -------------------------
-@heroUnitBackground: @grayLighter;
-@heroUnitHeadingColor: inherit;
-@heroUnitLeadColor: inherit;
-
-
-// Form states and alerts
-// -------------------------
-@warningText: #c09853;
-@warningBackground: #fcf8e3;
-@warningBorder: darken(spin(@warningBackground, -10), 3%);
-
-@errorText: #b94a48;
-@errorBackground: #f2dede;
-@errorBorder: darken(spin(@errorBackground, -10), 3%);
-
-@successText: #468847;
-@successBackground: #dff0d8;
-@successBorder: darken(spin(@successBackground, -10), 5%);
-
-@infoText: #3a87ad;
-@infoBackground: #d9edf7;
-@infoBorder: darken(spin(@infoBackground, -10), 7%);
-
-
-// Tooltips and popovers
-// -------------------------
-@tooltipColor: #fff;
-@tooltipBackground: #000;
-@tooltipArrowWidth: 5px;
-@tooltipArrowColor: @tooltipBackground;
-
-@popoverBackground: #fff;
-@popoverArrowWidth: 10px;
-@popoverArrowColor: #fff;
-@popoverTitleBackground: darken(@popoverBackground, 3%);
-
-// Special enhancement for popovers
-@popoverArrowOuterWidth: @popoverArrowWidth + 1;
-@popoverArrowOuterColor: rgba(0,0,0,.25);
-
-
-
-// GRID
-// --------------------------------------------------
-
-
-// Default 940px grid
-// -------------------------
-@gridColumns: 12;
-@gridColumnWidth: 60px;
-@gridGutterWidth: 20px;
-@gridRowWidth: (@gridColumns * @gridColumnWidth) + (@gridGutterWidth * (@gridColumns - 1));
-
-// 1200px min
-@gridColumnWidth1200: 70px;
-@gridGutterWidth1200: 30px;
-@gridRowWidth1200: (@gridColumns * @gridColumnWidth1200) + (@gridGutterWidth1200 * (@gridColumns - 1));
-
-// 768px-979px
-@gridColumnWidth768: 42px;
-@gridGutterWidth768: 20px;
-@gridRowWidth768: (@gridColumns * @gridColumnWidth768) + (@gridGutterWidth768 * (@gridColumns - 1));
-
-
-// Fluid grid
-// -------------------------
-@fluidGridColumnWidth: percentage(@gridColumnWidth/@gridRowWidth);
-@fluidGridGutterWidth: percentage(@gridGutterWidth/@gridRowWidth);
-
-// 1200px min
-@fluidGridColumnWidth1200: percentage(@gridColumnWidth1200/@gridRowWidth1200);
-@fluidGridGutterWidth1200: percentage(@gridGutterWidth1200/@gridRowWidth1200);
-
-// 768px-979px
-@fluidGridColumnWidth768: percentage(@gridColumnWidth768/@gridRowWidth768);
-@fluidGridGutterWidth768: percentage(@gridGutterWidth768/@gridRowWidth768);
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/wells.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/wells.less b/src/fauxton/assets/less/bootstrap/wells.less
deleted file mode 100644
index 84a744b..0000000
--- a/src/fauxton/assets/less/bootstrap/wells.less
+++ /dev/null
@@ -1,29 +0,0 @@
-//
-// Wells
-// --------------------------------------------------
-
-
-// Base class
-.well {
- min-height: 20px;
- padding: 19px;
- margin-bottom: 20px;
- background-color: @wellBackground;
- border: 1px solid darken(@wellBackground, 7%);
- .border-radius(@baseBorderRadius);
- .box-shadow(inset 0 1px 1px rgba(0,0,0,.05));
- blockquote {
- border-color: #ddd;
- border-color: rgba(0,0,0,.15);
- }
-}
-
-// Sizes
-.well-large {
- padding: 24px;
- .border-radius(@borderRadiusLarge);
-}
-.well-small {
- padding: 9px;
- .border-radius(@borderRadiusSmall);
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/config.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/config.less b/src/fauxton/assets/less/config.less
deleted file mode 100644
index fe03796..0000000
--- a/src/fauxton/assets/less/config.less
+++ /dev/null
@@ -1,46 +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.
- */
-
-.config-item {
- height: 41px;
-
- .edit-button {
- float: right;
- .btn;
- .btn-mini;
- display:none;
- }
-
- td:hover .edit-button {
- display: block;
- }
-
- .value-input {
- width: 98%;
- }
-
- #delete-value {
- cursor: pointer;
- }
-}
-
-.button-margin {
- margin-bottom: 15px;
-}
-
-#add-section-modal {
- width: 400px;
-}
-
-
-
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/couchdb.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/couchdb.less b/src/fauxton/assets/less/couchdb.less
deleted file mode 100644
index 20da486..0000000
--- a/src/fauxton/assets/less/couchdb.less
+++ /dev/null
@@ -1,72 +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.
- */
-
-/*!
- *
- * CouchDB less style files
- *
- */
-@import "bootstrap/bootstrap.less";
-
-//
-// Variables
-// --------------------------------------------------
-
-
-// Global values
-// --------------------------------------------------
-
-// Links
-@linkColor: #CA2530;
-@linkColorHover: darken(@linkColor, 15%);
-
-// Grays
-@black: #0C0C0C;
-@grayDark: #5A5A5A;
-@grayDarker: darken(@grayDark, 10%);
-@gray: #F80507;
-@grayLight: #E27B81;
-@grayLighter: #B95D40;
-@white: #FDFBFB;
-
-// Accent colors
-// -------------------------
-@blue: #049cdb;
-@blueDark: #0064cd;
-@green: #46a546;
-@red: #9d261d;
-@yellow: #ffc40d;
-@orange: #f89406;
-@pink: #c3325f;
-@purple: #7a43b6;
-
-
-// Scaffolding
-// -------------------------
-@bodyBackground: @white;
-@textColor: @grayDark;
-
-// Typography
-// -------------------------
-@sansFontFamily: "Helvetica Neue", Helvetica, Arial, sans-serif;
-@serifFontFamily: Georgia, "Times New Roman", Times, serif;
-@monoFontFamily: Monaco, Menlo, Consolas, "Courier New", monospace;
-
-@baseFontSize: 14px;
-@baseFontFamily: @sansFontFamily;
-@baseLineHeight: 20px;
-@altFontFamily: @serifFontFamily;
-
-@headingsFontFamily: inherit; // empty to use BS default, @baseFontFamily
-@headingsFontWeight: bold; // instead of browser default, bold
-@headingsColor: inherit; // empty to use BS default, @textColor
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/database.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/database.less b/src/fauxton/assets/less/database.less
deleted file mode 100644
index b96e730..0000000
--- a/src/fauxton/assets/less/database.less
+++ /dev/null
@@ -1,174 +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.
- */
-
-/* =database
- ---------------------------------------------------------------------- */
-#db-tools {
- position: absolute;
- top: -7px;
- right: 0;
- width: 390px;
-
- .btn-group {
- position: absolute;
- left: 0;
- top: 6px;
- }
-
- form {
- position: absolute;
- right: 0;
- top: 0;
- }
-}
-
-.tools .nav {
- margin-bottom: 10px;
-}
-
-#sidenav {
- padding-top: 10px;
-
- h3 {
- margin: 10px 0;
- }
-
- li a span.divider {
- background: none;
- color: #ccc;
- padding: 0 2px;
- }
-
- li.nav-header a {
- display: inline
- }
-
- div.btn-group {
- display: inline-block;
- }
-
- li.nav-header, #sidenav li a {
- padding-left: 4px;
- }
-
- li.active a {
- background-color: #ddd;
- color: #333;
- text-shadow: none;
- }
-
- li.active a i {
- background-image: url("../img/glyphicons-halflings.png");
- }
-}
-
-.edit {
- display: none;
-
- form {
- margin-bottom: 0;
- }
-
- h3 {
- border-bottom: 1px solid #ccc;
- font-size: 100%;
- line-height: 1;
- margin-bottom: 18px;
- }
-
- textarea {
- height: 100px;
- width: 95%;
- }
-
- .btn-toolbar {
- margin-bottom: 0;
- }
-
- .preview {
- width: 100px;
- }
-
- .save {
- }
-}
-
-#new-view-index {
- .confirm {
- display: none;
- }
-
- .confirm .progress {
- display: none;
- margin: 20px;
- }
-
- textarea {
- height: 100px;
- width: 95%;
- }
-}
-
-.view {
- display: none;
-
- .result-tools {
- float: left;
- width: 100%;
- margin-bottom: 10px;
- }
-
- table td div {
- position: relative;
- }
-
- table td div div {
- display: none;
- line-height: 1;
- position: absolute;
- right: 4px;
- top: 4px;
- }
-
- table td div:hover div a.edits {
- padding-left: 16px;
- padding-right: 16px;
- }
-
- table td div:hover div {
- display: block;
- }
-
-}
-.view.show {
- display: block;
-}
-.view.show.hidden-by-params {
- display: none;
-}
-#database .view table tr td {
- padding: 0;
-}
-
-.loading {display: none;}
-
-.view-request-duration {
- padding-right: 10px;
- float: right;
-}
-
-table.active-tasks{
- th {
- cursor: pointer;
- }
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/fauxton.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/fauxton.less b/src/fauxton/assets/less/fauxton.less
deleted file mode 100644
index cef1638..0000000
--- a/src/fauxton/assets/less/fauxton.less
+++ /dev/null
@@ -1,102 +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.
- */
-
-/*!
- *
- * Fauxton less style files
- *
- */
-@import "bootstrap/bootstrap.less";
-@import "config.less";
-@import "logs.less";
-@import "prettyprint.less";
-@import "database.less";
-
-/*!
- *
- * OVERRIDES
- *
- * Override styles from included less files here. Record where the style is
- * originally defined.
- *
- */
-
-//
-// Breadcrumbs
-
-.breadcrumb {
- background-color: transparent;
- padding-left: 0px;
- li {
- color: @grayLight;
- background-color: transparent;
- a {
- color: @grayLight;
- }
- }
- .divider {
- padding: 0 5px;
- color: @grayLight; //ccc
- }
- .active {
- color: @black;
- font-weight: bold;
- }
-}
-
-
-// Navs
-// ------
-
-.nav-tabs > li > a {
- background-color: @grayLighter;
-}
-
-.dropdown-menu li > a {
- font-size: 12px;
-}
-
-.nav-list .divider {
- color: @grayLight;
- // This function is defined in mixins
- .nav-divider(transparent, @white);
-}
-
-
-// Misc
-// ------
-
-pre.view-code-error {
- color: red !important; // yuck
-}
-
-.CodeMirror-scroll {
- height: auto;
- overflow-y: visible;
-}
-
-#define-view form textarea.js-editor {
- width: 95%;
-}
-
-#define-view .CodeMirror-scroll {
- height: auto;
- min-height: 50px;
-}
-
-.loader {
- background: url('../img/loader.gif') center center no-repeat;
- min-height: 100px;
-}
-
-
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/logs.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/logs.less b/src/fauxton/assets/less/logs.less
deleted file mode 100644
index e50f903..0000000
--- a/src/fauxton/assets/less/logs.less
+++ /dev/null
@@ -1,24 +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.
- */
-
-#log-sidebar {
-
- ul {
- margin-left: 0px;
- list-style: none;
- }
-
- .remove-filter {
- opacity: 0.2;
- }
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/prettyprint.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/prettyprint.less b/src/fauxton/assets/less/prettyprint.less
deleted file mode 100644
index 8ed512c..0000000
--- a/src/fauxton/assets/less/prettyprint.less
+++ /dev/null
@@ -1,38 +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.
- */
-
-pre.prettyprint {
- background: #000;
- border-radius: 0;
- font-size: 83%;
- line-height: 1.4;
- margin: 0;
- padding: 16px;
-}
-.prettyprint {
- .pln, .pun, .typ {
- color: #f8f8f8;
- }
- .kwd {
- color: #ff8300;
- }
- .str {
- color: #ff8300;
- }
- .lit {
- color: #00ff00;
- }
- .com {
- color: #666;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/bin/grunt
----------------------------------------------------------------------
diff --git a/src/fauxton/bin/grunt b/src/fauxton/bin/grunt
deleted file mode 100755
index 2c52393..0000000
--- a/src/fauxton/bin/grunt
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/sh
-
-# 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.
-
-REL_PATH="`dirname \"$0\"`"
-GRUNT_PATH="$REL_PATH/../node_modules/.bin/grunt"
-
-$GRUNT_PATH $*
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/couchapp.js
----------------------------------------------------------------------
diff --git a/src/fauxton/couchapp.js b/src/fauxton/couchapp.js
deleted file mode 100644
index 63ea297..0000000
--- a/src/fauxton/couchapp.js
+++ /dev/null
@@ -1,27 +0,0 @@
-var couchapp = require('couchapp'),
- path = require('path'),
- ddoc;
-
-ddoc = {
- _id: '_design/fauxton',
- rewrites: [
- { "from": "_db" , "to" : "../.." },
- { "from": "_db/*" , "to" : "../../*" },
- { "from": "_ddoc" , "to" : "" },
- { "from": "_ddoc/*", "to" : "*"},
- {from: '/', to: 'index.html'},
- {from: '/*', to: '*'}
- ],
- views: {},
- shows: {},
- lists: {},
- validate_doc_update: function(newDoc, oldDoc, userCtx) {
- /*if (newDoc._deleted === true && userCtx.roles.indexOf('_admin') === -1) {
- throw "Only admin can delete documents on this database.";
- }*/
- }
-};
-
-
-couchapp.loadAttachments(ddoc, path.join(__dirname, 'dist', 'release'));
-module.exports = ddoc;
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/favicon.ico
----------------------------------------------------------------------
diff --git a/src/fauxton/favicon.ico b/src/fauxton/favicon.ico
deleted file mode 100644
index 0baa6f3..0000000
Binary files a/src/fauxton/favicon.ico and /dev/null differ
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/index.html
----------------------------------------------------------------------
diff --git a/src/fauxton/index.html b/src/fauxton/index.html
deleted file mode 100644
index 892f499..0000000
--- a/src/fauxton/index.html
+++ /dev/null
@@ -1,53 +0,0 @@
-<!doctype html>
-
-<!--
-// 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.
--->
-
-<html lang="en">
-<head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <meta name="viewport" content="width=device-width,initial-scale=1">
-
- <title>Project Fauxton</title>
-
- <!-- Application styles. -->
- <link rel="stylesheet" href="/css/index.css">
- <style type="text/css">
- body {
- padding-top: 60px;
- padding-bottom: 40px;
- }
- </style>
- <base href="/"></base>
-</head>
-
-<body id="home">
- <!-- Main container. -->
- <div role="main" id="main">
- <div id="global-notifications" class="container errors-container"></div>
- <div id="app-container"></div>
- <hr>
-
- <footer>
- <div id="footer-content" class="container">
- <p>© Project Fauxton 2012</p>
- </div>
- </footer>
- </div>
-
- <!-- Application source. -->
- <script data-main="/app/config" src="/assets/js/libs/require.js"></script>
-</body>
-</html>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/package.json
----------------------------------------------------------------------
diff --git a/src/fauxton/package.json b/src/fauxton/package.json
deleted file mode 100644
index fd5e3d3..0000000
--- a/src/fauxton/package.json
+++ /dev/null
@@ -1,48 +0,0 @@
-{
- "name": "fauxton",
- "version": "0.1.0",
- "description": "Fauxton is a modular CouchDB dashboard and Futon replacement.",
- "main": "grunt.js",
- "directories": {
- "test": "test"
- },
- "dependencies": {
- "async": "~0.2.6",
- "grunt": "~0.4.1",
- "grunt-cli": "~0.1.6",
- "couchapp": "~0.9.1",
- "grunt-contrib-cssmin": "~0.5.0",
- "grunt-contrib-clean": "~0.4.1",
- "grunt-contrib-jshint": "~0.6.0",
- "grunt-contrib-concat": "~0.3.0",
- "grunt-contrib-less": "~0.5.0",
- "grunt-contrib-jst": "~0.5.0",
- "grunt-contrib-watch": "~0.4.4",
- "grunt-contrib-uglify": "~0.2.0",
- "grunt-contrib-copy": "~0.4.1",
- "grunt-couchapp": "~0.1.0",
- "grunt-exec": "~0.4.0",
- "grunt-init": "~0.2.0",
- "grunt-contrib-requirejs": "~0.4.1",
- "underscore": "~1.4.2",
- "url": "~0.7.9",
- "urls": "~0.0.3",
- "http-proxy": "~0.10.2",
- "send": "~0.1.1",
- "grunt-mocha-phantomjs": "~0.3.0"
- },
- "scripts": {
- "test": "echo \"Error: no test specified\" && exit 1"
- },
- "repository": {
- "type": "git",
- "url": "https://git-wip-us.apache.org/repos/asf/couchdb.git"
- },
- "keywords": [
- "couchdb",
- "futon",
- "fauxton"
- ],
- "author": "",
- "license": "Apache V2"
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/readme.md
----------------------------------------------------------------------
diff --git a/src/fauxton/readme.md b/src/fauxton/readme.md
deleted file mode 100644
index 2ee3293..0000000
--- a/src/fauxton/readme.md
+++ /dev/null
@@ -1,69 +0,0 @@
-Fauxton
-=======
-
-This is the initial implementation of Fauxton, focused on fleshing out
-the various pieces of functionality and as a test bed for new ideas.
-Full functionality and design considerations will be added later.
-
-
-
-Current items of interest:
-
- * Live JSON editor with dynamic JS Hinting and error popups
- * Initial plugin system
- * Minimal externally loadable plugin example
- * Data popups for additional db info on \_all_dbs page
- * CouchDB API compliant urls
-
-## Setup Fauxton ##
-
-A recent of [node.js](http://nodejs.org/) and npm is required.
-
-### CouchDB Setup ###
-
- 1. Clone the Couchdb repo: https://github.com/apache/couchdb.git or http://git-wip-us.apache.org/repos/asf/couchdb.git
- cd couchdb
-
-### Fauxton Setup ###
-
- cd src/fauxton
-
- # Install all dependencies
- npm install
-
-#### (Optional) To avoid a npm global install
- # Add node_modules/.bin to your path
- # export PATH=./node_modules/.bin:$PATH
- # Or just use the wrappers in ./bin/
-
- # Development mode, non minified files
- ./bin/grunt couchdebug
-
- # Or fully compiled install
- # ./bin/grunt couchdb
-
-### Dev Server
- Using the dev server is the easiest way to use fauxton, specially when developing for it.
-
- grunt dev
-
-### Running Tests
- There are two ways to run the tests. `grunt test` will run the tests via the commandline. It is also possible to view them via the url
- `http://localhost:8000/testrunner` when the dev server is running. Refreshing the url will rerun the tests via phantomjs and in the browser.
-
-### To Deploy Fauxton
-
- ./bin/grunt couchapp_deploy - to deploy to your local [Couchdb instance] (http://localhost:5984/fauxton/_design/fauxton/index.html)
-
-## Understang Fauxton Code layout
-
-Each bit of functionality is its own seperate module or addon. All core modules are stored under `app/module` and any addons that are optional are under `app/addons`.
-We use [backbone.js](http://backbonejs.org/) and [Backbone.layoutmanager](https://github.com/tbranyen/backbone.layoutmanager) quite heavily, so best to get an idea how they work.
-Its best at this point to read through a couple of the modules and addons to get an idea of how they work. Two good starting points are `app/addon/config` and `app/modules/databases`.
-Each module must have a `base.js` file, this is read and compile when Fauxton is deployed. A `resource.js` file is usually for your Backbone.Models and Backbone.Collections,
-`view.js` for your Backbone.Views. The `routes.js` is used to register a url path for your view along with what layout, data, breadcrumbs and api point is required for the view.
-
-## Todo items
-
-Checkout [Jira](https://issues.apache.org/jira/browse/COUCHDB/component/12320406) for a list of items to do.
-
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/settings.json.default
----------------------------------------------------------------------
diff --git a/src/fauxton/settings.json.default b/src/fauxton/settings.json.default
deleted file mode 100644
index 2b7fe89..0000000
--- a/src/fauxton/settings.json.default
+++ /dev/null
@@ -1,40 +0,0 @@
-{
- "deps": [
- { "name": "activetasks" },
- { "name": "config" },
- { "name": "logs" },
- { "name": "stats" },
- { "name": "contribute" },
- { "name": "auth" }
- ],
- "template": {
- "development": {
- "src": "assets/index.underscore",
- "dest": "dist/debug/index.html",
- "variables": {
- "requirejs": "/assets/js/libs/require.js",
- "css": "./css/index.css",
- "base": null
- }
- },
- "release": {
- "src": "assets/index.underscore",
- "dest": "dist/debug/index.html",
- "variables": {
- "requirejs": "./js/require.js",
- "css": "./css/index.css",
- "base": null
- }
- }
- },
-
- "couch_config": {
- "fauxton": {
- "db": "http://localhost:5984/fauxton",
- "app": "./couchapp.js",
- "options": {
- "okay_if_missing": true
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/settings.json.sample_external
----------------------------------------------------------------------
diff --git a/src/fauxton/settings.json.sample_external b/src/fauxton/settings.json.sample_external
deleted file mode 100644
index 71c45b4..0000000
--- a/src/fauxton/settings.json.sample_external
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "deps": [
- {
- "name": "fauxton-demo-plugin",
- "url": "git://github.com/chewbranca/fauxton-demo-plugin.git"
- },
- { "name": "config" },
- { "name": "logs" }
- ]
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/tasks/addon/rename.json
----------------------------------------------------------------------
diff --git a/src/fauxton/tasks/addon/rename.json b/src/fauxton/tasks/addon/rename.json
deleted file mode 100644
index 1f326e9..0000000
--- a/src/fauxton/tasks/addon/rename.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "route.js.underscore": "{%= path %}/{%= name.toLowerCase() %}/route.js",
- "resources.js.underscore": "{%= path %}/{%= name.toLowerCase() %}/resources.js",
- "base.js.underscore": "{%= path %}/{%= name.toLowerCase() %}/base.js"
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/tasks/addon/root/base.js.underscore
----------------------------------------------------------------------
diff --git a/src/fauxton/tasks/addon/root/base.js.underscore b/src/fauxton/tasks/addon/root/base.js.underscore
deleted file mode 100644
index d002cd5..0000000
--- a/src/fauxton/tasks/addon/root/base.js.underscore
+++ /dev/null
@@ -1,21 +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.
-
-define([
- "app",
- "api",
- "addons/{%= name.toLowerCase() %}/routes"
-],
-
-function(app, FauxtonAPI, {%= name %}) {
- return {%= name %};
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/tasks/addon/root/resources.js.underscore
----------------------------------------------------------------------
diff --git a/src/fauxton/tasks/addon/root/resources.js.underscore b/src/fauxton/tasks/addon/root/resources.js.underscore
deleted file mode 100644
index 8d0ef32..0000000
--- a/src/fauxton/tasks/addon/root/resources.js.underscore
+++ /dev/null
@@ -1,21 +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.
-
-define([
- "app",
- "api"
-],
-
-function (app, FauxtonAPI) {
- var {%= name %} = FauxtonAPI.addon();
- return {%= name %};
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/tasks/addon/root/route.js.underscore
----------------------------------------------------------------------
diff --git a/src/fauxton/tasks/addon/root/route.js.underscore b/src/fauxton/tasks/addon/root/route.js.underscore
deleted file mode 100644
index 859e5bb..0000000
--- a/src/fauxton/tasks/addon/root/route.js.underscore
+++ /dev/null
@@ -1,21 +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.
-
-define([
- "app",
- "api",
- "addons/{%= name.toLowerCase() %}/resources"
-],
-function(app, FauxtonAPI, {%= name %}) {
- {%= name %}.Routes = {};
- return {%= name %};
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/tasks/addon/template.js
----------------------------------------------------------------------
diff --git a/src/fauxton/tasks/addon/template.js b/src/fauxton/tasks/addon/template.js
deleted file mode 100644
index 459ff34..0000000
--- a/src/fauxton/tasks/addon/template.js
+++ /dev/null
@@ -1,70 +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.
-
-'use strict';
-
-exports.description = 'Generate a skeleton for an addon.';
-
-exports.notes = '';
-
-exports.after = "Created your addon! Don't forget to update your"+
- " settings.json for it to be compiled and deployed";
-
-// Any existing file or directory matching this wildcard will cause a warning.
-// exports.warnOn = '*';
-
-// The actual init template.
-exports.template = function(grunt, init, done) {
-
- // destpath
- init.process(
- {},
- [
- {
- name: "name",
- message: "Add on Name",
- validator: /^[\w\-\.]+$/,
- default: "WickedCool"
- },
- {
- name: "path",
- message: "Location of add ons",
- default: "app/addons"
- },
- {
- name: "assets",
- message: "Do you need an assets folder? (for .less)",
- default: 'y/N'
- }
- ],
- function (err, props) {
- // Files to copy (and process).
- var files = init.filesToCopy(props);
-
- // Actually copy and process (apply the template props) files.
- init.copyAndProcess(files, props);
-
- // Make the assets dir if requested
- if (props.assets == "y"){
- var asspath = props.path + "/" + props.name.toLowerCase() + "/assets";
- grunt.file.mkdir(asspath);
- grunt.log.writeln("Created " + asspath);
- }
-
- var tmplpath = props.path + "/" + props.name.toLowerCase() + "/templates";
- grunt.file.mkdir(tmplpath);
- grunt.log.writeln("Created " + tmplpath);
- // All done!
- done();
- }
- )
-};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/tasks/couchserver.js
----------------------------------------------------------------------
diff --git a/src/fauxton/tasks/couchserver.js b/src/fauxton/tasks/couchserver.js
deleted file mode 100644
index 562318b..0000000
--- a/src/fauxton/tasks/couchserver.js
+++ /dev/null
@@ -1,102 +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.
-
-module.exports = function (grunt) {
- var log = grunt.log;
-
- grunt.registerTask("couchserver", 'Run a couch dev proxy server', function () {
- var fs = require("fs"),
- path = require("path"),
- http = require("http"),
- httpProxy = require('http-proxy'),
- send = require('send'),
- options = grunt.config('couchserver');
-
- // Options
- var dist_dir = options.dist || './dist/debug/',
- app_dir = './app',
- port = options.port || 8000;
-
- // Proxy options with default localhost
- var proxy_settings = options.proxy || {
- target: {
- host: 'localhost',
- port: 5984,
- https: false
- }
- };
-
- // inform grunt that this task is async
- var done = this.async();
-
- // create proxy to couch for all couch requests
- var proxy = new httpProxy.HttpProxy(proxy_settings);
-
- http.createServer(function (req, res) {
- var url = req.url.replace('app/',''),
- accept = req.headers.accept.split(','),
- filePath;
-
- if (!!url.match(/assets/)) {
- // serve any javascript or css files from here assets dir
- filePath = path.join('./',url);
- } else if (!!url.match(/mocha|\/test\/core\/|test\.config/)) {
- filePath = path.join('./test', url.replace('/test/',''));
- } else if (!!url.match(/\.css|img/)) {
- filePath = path.join(dist_dir,url);
- /*} else if (!!url.match(/\/js\//)) {
- // serve any javascript or files from dist debug dir
- filePath = path.join(dist_dir,req.url);*/
- } else if (!!url.match(/\.js$|\.html$/)) {
- // server js from app directory
- filePath = path.join(app_dir, url.replace('/_utils/fauxton/',''));
- } else if (!!url.match(/testrunner/)) {
- var testSetup = grunt.util.spawn({cmd: 'grunt', grunt: true, args: ['mochaSetup']}, function (error, result, code) {/* log.writeln(String(result));*/ });
- testSetup.stdout.pipe(process.stdout);
- testSetup.stderr.pipe(process.stderr);
- filePath = path.join('./test/runner.html');
- } else if (url === '/' && accept[0] !== 'application/json') {
- // serve main index file from here
- filePath = path.join(dist_dir, 'index.html');
- };
-
- if (filePath) {
- return send(req, filePath)
- .on('error', function (err) {
- if (err.status === 404) {
- log.writeln('Could not locate', filePath);
- } else {
- log.writeln('ERROR', filePath, err);
- }
-
- res.end(err.message);
- })
- .pipe(res);
- }
-
- proxy.proxyRequest(req, res);
- }).listen(port);
-
- // Fail this task if any errors have been logged
- if (grunt.errors) {
- return false;
- }
-
- var watch = grunt.util.spawn({cmd: 'grunt', grunt: true, args: ['watch']}, function (error, result, code) {/* log.writeln(String(result));*/ });
-
- watch.stdout.pipe(process.stdout);
- watch.stderr.pipe(process.stderr);
-
- log.writeln('Listening on ' + port);
- });
-
-};
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/tasks/fauxton.js
----------------------------------------------------------------------
diff --git a/src/fauxton/tasks/fauxton.js b/src/fauxton/tasks/fauxton.js
deleted file mode 100644
index 833a86d..0000000
--- a/src/fauxton/tasks/fauxton.js
+++ /dev/null
@@ -1,117 +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.
-
-module.exports = function(grunt) {
- var _ = grunt.util._;
-
- grunt.registerMultiTask('template', 'generates an html file from a specified template', function(){
- var data = this.data;
- var _ = grunt.util._;
- var tmpl = _.template(grunt.file.read(data.src), null, data.variables);
- grunt.file.write(data.dest, tmpl(data.variables));
- });
-
- grunt.registerMultiTask('get_deps', 'Fetch external dependencies', function(version) {
- grunt.log.writeln("Fetching external dependencies");
-
- var path = require('path');
- var done = this.async();
- var data = this.data;
- var target = data.target || "app/addons/";
- var settingsFile = path.existsSync(data.src) ? data.src : "settings.json.default";
- var settings = grunt.file.readJSON(settingsFile);
- var _ = grunt.util._;
-
- // This should probably be a helper, though they seem to have been removed
- var fetch = function(deps, command){
- var child_process = require('child_process');
- var async = require('async');
- async.forEach(deps, function(dep, cb) {
- var path = target + dep.name;
- var location = dep.url || dep.path;
- grunt.log.writeln("Fetching: " + dep.name + " (" + location + ")");
-
- child_process.exec(command(dep, path), function(error, stdout, stderr) {
- grunt.log.writeln(stderr);
- grunt.log.writeln(stdout);
- cb(error);
- });
- }, function(error) {
- if (error) {
- grunt.log.writeln("ERROR: " + error.message);
- return false;
- } else {
- return true;
- }
- });
- };
-
- var remoteDeps = _.filter(settings.deps, function(dep) { return !! dep.url; });
- grunt.log.writeln(remoteDeps.length + " remote dependencies");
- var remote = fetch(remoteDeps, function(dep, destination){
- return "git clone " + dep.url + " " + destination;
- });
-
- var localDeps = _.filter(settings.deps, function(dep) { return !! dep.path; });
- grunt.log.writeln(localDeps.length + " local dependencies");
- var local = fetch(localDeps, function(dep, destination){
- // TODO: Windows
- var command = "cp -r " + dep.path + " " + destination;
- grunt.log.writeln(command);
- return command;
- });
-
- done(remote && local);
-
- });
-
- grunt.registerMultiTask('gen_load_addons', 'Generate the load_addons.js file', function() {
- var path = require('path');
- var data = this.data;
- var _ = grunt.util._;
- var settingsFile = path.existsSync(data.src) ? data.src : "settings.json.default";
- var settings = grunt.file.readJSON(settingsFile);
- var template = "app/load_addons.js.underscore";
- var dest = "app/load_addons.js";
- var deps = _.map(settings.deps, function(dep) {
- return "addons/" + dep.name + "/base";
- });
- var tmpl = _.template(grunt.file.read(template));
- grunt.file.write(dest, tmpl({deps: deps}));
- });
-
- grunt.registerMultiTask('mochaSetup','Generate a config.js and runner.html for tests', function(){
- var data = this.data,
- configInfo,
- _ = grunt.util._,
- configTemplateSrc = data.template,
- testFiles = grunt.file.expand(data.files.src);
-
- var configTemplate = _.template(grunt.file.read(configTemplateSrc));
- // a bit of a nasty hack to read our current config.js and get the info so we can change it
- // for our testing setup
- var require = {
- config: function (args) {
- configInfo = args;
- configInfo.paths['chai'] = "../test/mocha/chai";
- configInfo.paths['sinon-chai'] = "../test/mocha/sinon-chai";
- configInfo.paths['testUtils'] = "../test/mocha/testUtils";
- configInfo.baseUrl = '../app';
- delete configInfo.deps;
- }
- };
-
- eval(grunt.file.read(data.config) +'');
-
- grunt.file.write('./test/test.config.js', configTemplate({configInfo: configInfo, testFiles: testFiles}));
- });
-};
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/tasks/helper.js
----------------------------------------------------------------------
diff --git a/src/fauxton/tasks/helper.js b/src/fauxton/tasks/helper.js
deleted file mode 100644
index 4b66e55..0000000
--- a/src/fauxton/tasks/helper.js
+++ /dev/null
@@ -1,45 +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.
-
-var fs = require('fs'),
- path = require('path');
-
-exports.init = function(grunt) {
- var _ = grunt.util._;
-
- return {
- readSettingsFile: function () {
- if (fs.existsSync("settings.json")) {
- return grunt.file.readJSON("settings.json");
- } else if (fs.existsSync("settings.json.default")) {
- return grunt.file.readJSON("settings.json.default");
- } else {
- return {deps: []};
- }
- },
-
- processAddons: function (callback) {
- this.readSettingsFile().deps.forEach(callback);
- },
-
- watchFiles: function (fileExtensions, defaults) {
- return _.reduce(this.readSettingsFile().deps, function (files, dep) {
- if (dep.path) {
- _.each(fileExtensions, function (fileExtension) {
- files.push(path.join(dep.path, '**/*' + fileExtension ));
- });
- }
- return files
- }, defaults);
- }
- };
-};
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/test/core/routeObjectSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/test/core/routeObjectSpec.js b/src/fauxton/test/core/routeObjectSpec.js
deleted file mode 100644
index 45d95ac..0000000
--- a/src/fauxton/test/core/routeObjectSpec.js
+++ /dev/null
@@ -1,91 +0,0 @@
-define([
- 'api',
- 'testUtils'
-], function (FauxtonAPI, testUtils) {
- var assert = testUtils.assert,
- RouteObject = FauxtonAPI.RouteObject;
-
- describe('RouteObjects', function () {
-
- describe('renderWith', function () {
- var TestRouteObject, testRouteObject, mockLayout;
-
- beforeEach(function () {
- TestRouteObject = RouteObject.extend({
- crumbs: ['mycrumbs']
- });
-
- testRouteObject = new TestRouteObject();
-
- // Need to find a better way of doing this
- mockLayout = {
- setTemplate: sinon.spy(),
- clearBreadcrumbs: sinon.spy(),
- setView: sinon.spy(),
- renderView: sinon.spy(),
- hooks: [],
- setBreadcrumbs: sinon.spy()
- };
-
- });
-
- it('Should set template for first render ', function () {
- testRouteObject.renderWith('the-route', mockLayout, 'args');
-
- assert.ok(mockLayout.setTemplate.calledOnce, 'setTempalte was called');
- });
-
- it('Should not set template after first render', function () {
- testRouteObject.renderWith('the-route', mockLayout, 'args');
-
- testRouteObject.renderWith('the-route', mockLayout, 'args');
-
- assert.ok(mockLayout.setTemplate.calledOnce, 'SetTemplate not meant to be called');
- });
-
- it('Should clear breadcrumbs', function () {
- testRouteObject.renderWith('the-route', mockLayout, 'args');
- assert.ok(mockLayout.clearBreadcrumbs.calledOnce, 'Clear Breadcrumbs called');
- });
-
- it('Should set breadcrumbs when breadcrumbs exist', function () {
- testRouteObject.renderWith('the-route', mockLayout, 'args');
- assert.ok(mockLayout.setBreadcrumbs.calledOnce, 'Set Breadcrumbs was called');
- });
-
- it("Should call establish of routeObject", function () {
- var establishSpy = sinon.spy(testRouteObject,"establish");
-
- testRouteObject.renderWith('the-route', mockLayout, 'args');
- assert.ok(establishSpy.calledOnce, 'Calls establish');
- });
-
- it("Should render views", function () {
- var view = new FauxtonAPI.View(),
- getViewsSpy = sinon.stub(testRouteObject,"getViews"),
- viewSpy = sinon.stub(view, "establish");
-
- sinon.stub(view, "hasRendered").returns(false);
- getViewsSpy.returns({'#view': view});
-
- testRouteObject.renderWith('the-route', mockLayout, 'args');
- assert.ok(viewSpy.calledOnce, 'Should render view');
- });
-
- it("Should not re-render a view", function () {
- var view = new FauxtonAPI.View(),
- getViewsSpy = sinon.stub(testRouteObject,"getViews"),
- viewSpy = sinon.stub(view, "establish");
-
- sinon.stub(view, "hasRendered").returns(true);
- getViewsSpy.returns({'#view': view});
-
- testRouteObject.renderWith('the-route', mockLayout, 'args');
- assert.notOk(viewSpy.calledOnce, 'Should render view');
- });
- });
-
- });
-
-
-});
[06/26] Remove fauxton from 1.4.x branch.
Posted by dj...@apache.org.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/test/mocha/mocha.js
----------------------------------------------------------------------
diff --git a/src/fauxton/test/mocha/mocha.js b/src/fauxton/test/mocha/mocha.js
deleted file mode 100755
index a55115a..0000000
--- a/src/fauxton/test/mocha/mocha.js
+++ /dev/null
@@ -1,5428 +0,0 @@
-;(function(){
-
-// CommonJS require()
-
-function require(p){
- var path = require.resolve(p)
- , mod = require.modules[path];
- if (!mod) throw new Error('failed to require "' + p + '"');
- if (!mod.exports) {
- mod.exports = {};
- mod.call(mod.exports, mod, mod.exports, require.relative(path));
- }
- return mod.exports;
- }
-
-require.modules = {};
-
-require.resolve = function (path){
- var orig = path
- , reg = path + '.js'
- , index = path + '/index.js';
- return require.modules[reg] && reg
- || require.modules[index] && index
- || orig;
- };
-
-require.register = function (path, fn){
- require.modules[path] = fn;
- };
-
-require.relative = function (parent) {
- return function(p){
- if ('.' != p.charAt(0)) return require(p);
-
- var path = parent.split('/')
- , segs = p.split('/');
- path.pop();
-
- for (var i = 0; i < segs.length; i++) {
- var seg = segs[i];
- if ('..' == seg) path.pop();
- else if ('.' != seg) path.push(seg);
- }
-
- return require(path.join('/'));
- };
- };
-
-
-require.register("browser/debug.js", function(module, exports, require){
-
-module.exports = function(type){
- return function(){
- }
-};
-
-}); // module: browser/debug.js
-
-require.register("browser/diff.js", function(module, exports, require){
-/* See license.txt for terms of usage */
-
-/*
- * Text diff implementation.
- *
- * This library supports the following APIS:
- * JsDiff.diffChars: Character by character diff
- * JsDiff.diffWords: Word (as defined by \b regex) diff which ignores whitespace
- * JsDiff.diffLines: Line based diff
- *
- * JsDiff.diffCss: Diff targeted at CSS content
- *
- * These methods are based on the implementation proposed in
- * "An O(ND) Difference Algorithm and its Variations" (Myers, 1986).
- * http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.6927
- */
-var JsDiff = (function() {
- function clonePath(path) {
- return { newPos: path.newPos, components: path.components.slice(0) };
- }
- function removeEmpty(array) {
- var ret = [];
- for (var i = 0; i < array.length; i++) {
- if (array[i]) {
- ret.push(array[i]);
- }
- }
- return ret;
- }
- function escapeHTML(s) {
- var n = s;
- n = n.replace(/&/g, "&");
- n = n.replace(/</g, "<");
- n = n.replace(/>/g, ">");
- n = n.replace(/"/g, """);
-
- return n;
- }
-
-
- var fbDiff = function(ignoreWhitespace) {
- this.ignoreWhitespace = ignoreWhitespace;
- };
- fbDiff.prototype = {
- diff: function(oldString, newString) {
- // Handle the identity case (this is due to unrolling editLength == 0
- if (newString == oldString) {
- return [{ value: newString }];
- }
- if (!newString) {
- return [{ value: oldString, removed: true }];
- }
- if (!oldString) {
- return [{ value: newString, added: true }];
- }
-
- newString = this.tokenize(newString);
- oldString = this.tokenize(oldString);
-
- var newLen = newString.length, oldLen = oldString.length;
- var maxEditLength = newLen + oldLen;
- var bestPath = [{ newPos: -1, components: [] }];
-
- // Seed editLength = 0
- var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
- if (bestPath[0].newPos+1 >= newLen && oldPos+1 >= oldLen) {
- return bestPath[0].components;
- }
-
- for (var editLength = 1; editLength <= maxEditLength; editLength++) {
- for (var diagonalPath = -1*editLength; diagonalPath <= editLength; diagonalPath+=2) {
- var basePath;
- var addPath = bestPath[diagonalPath-1],
- removePath = bestPath[diagonalPath+1];
- oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
- if (addPath) {
- // No one else is going to attempt to use this value, clear it
- bestPath[diagonalPath-1] = undefined;
- }
-
- var canAdd = addPath && addPath.newPos+1 < newLen;
- var canRemove = removePath && 0 <= oldPos && oldPos < oldLen;
- if (!canAdd && !canRemove) {
- bestPath[diagonalPath] = undefined;
- continue;
- }
-
- // Select the diagonal that we want to branch from. We select the prior
- // path whose position in the new string is the farthest from the origin
- // and does not pass the bounds of the diff graph
- if (!canAdd || (canRemove && addPath.newPos < removePath.newPos)) {
- basePath = clonePath(removePath);
- this.pushComponent(basePath.components, oldString[oldPos], undefined, true);
- } else {
- basePath = clonePath(addPath);
- basePath.newPos++;
- this.pushComponent(basePath.components, newString[basePath.newPos], true, undefined);
- }
-
- var oldPos = this.extractCommon(basePath, newString, oldString, diagonalPath);
-
- if (basePath.newPos+1 >= newLen && oldPos+1 >= oldLen) {
- return basePath.components;
- } else {
- bestPath[diagonalPath] = basePath;
- }
- }
- }
- },
-
- pushComponent: function(components, value, added, removed) {
- var last = components[components.length-1];
- if (last && last.added === added && last.removed === removed) {
- // We need to clone here as the component clone operation is just
- // as shallow array clone
- components[components.length-1] =
- {value: this.join(last.value, value), added: added, removed: removed };
- } else {
- components.push({value: value, added: added, removed: removed });
- }
- },
- extractCommon: function(basePath, newString, oldString, diagonalPath) {
- var newLen = newString.length,
- oldLen = oldString.length,
- newPos = basePath.newPos,
- oldPos = newPos - diagonalPath;
- while (newPos+1 < newLen && oldPos+1 < oldLen && this.equals(newString[newPos+1], oldString[oldPos+1])) {
- newPos++;
- oldPos++;
-
- this.pushComponent(basePath.components, newString[newPos], undefined, undefined);
- }
- basePath.newPos = newPos;
- return oldPos;
- },
-
- equals: function(left, right) {
- var reWhitespace = /\S/;
- if (this.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right)) {
- return true;
- } else {
- return left == right;
- }
- },
- join: function(left, right) {
- return left + right;
- },
- tokenize: function(value) {
- return value;
- }
- };
-
- var CharDiff = new fbDiff();
-
- var WordDiff = new fbDiff(true);
- WordDiff.tokenize = function(value) {
- return removeEmpty(value.split(/(\s+|\b)/));
- };
-
- var CssDiff = new fbDiff(true);
- CssDiff.tokenize = function(value) {
- return removeEmpty(value.split(/([{}:;,]|\s+)/));
- };
-
- var LineDiff = new fbDiff();
- LineDiff.tokenize = function(value) {
- return value.split(/^/m);
- };
-
- return {
- diffChars: function(oldStr, newStr) { return CharDiff.diff(oldStr, newStr); },
- diffWords: function(oldStr, newStr) { return WordDiff.diff(oldStr, newStr); },
- diffLines: function(oldStr, newStr) { return LineDiff.diff(oldStr, newStr); },
-
- diffCss: function(oldStr, newStr) { return CssDiff.diff(oldStr, newStr); },
-
- createPatch: function(fileName, oldStr, newStr, oldHeader, newHeader) {
- var ret = [];
-
- ret.push("Index: " + fileName);
- ret.push("===================================================================");
- ret.push("--- " + fileName + (typeof oldHeader === "undefined" ? "" : "\t" + oldHeader));
- ret.push("+++ " + fileName + (typeof newHeader === "undefined" ? "" : "\t" + newHeader));
-
- var diff = LineDiff.diff(oldStr, newStr);
- if (!diff[diff.length-1].value) {
- diff.pop(); // Remove trailing newline add
- }
- diff.push({value: "", lines: []}); // Append an empty value to make cleanup easier
-
- function contextLines(lines) {
- return lines.map(function(entry) { return ' ' + entry; });
- }
- function eofNL(curRange, i, current) {
- var last = diff[diff.length-2],
- isLast = i === diff.length-2,
- isLastOfType = i === diff.length-3 && (current.added === !last.added || current.removed === !last.removed);
-
- // Figure out if this is the last line for the given file and missing NL
- if (!/\n$/.test(current.value) && (isLast || isLastOfType)) {
- curRange.push('\\ No newline at end of file');
- }
- }
-
- var oldRangeStart = 0, newRangeStart = 0, curRange = [],
- oldLine = 1, newLine = 1;
- for (var i = 0; i < diff.length; i++) {
- var current = diff[i],
- lines = current.lines || current.value.replace(/\n$/, "").split("\n");
- current.lines = lines;
-
- if (current.added || current.removed) {
- if (!oldRangeStart) {
- var prev = diff[i-1];
- oldRangeStart = oldLine;
- newRangeStart = newLine;
-
- if (prev) {
- curRange = contextLines(prev.lines.slice(-4));
- oldRangeStart -= curRange.length;
- newRangeStart -= curRange.length;
- }
- }
- curRange.push.apply(curRange, lines.map(function(entry) { return (current.added?"+":"-") + entry; }));
- eofNL(curRange, i, current);
-
- if (current.added) {
- newLine += lines.length;
- } else {
- oldLine += lines.length;
- }
- } else {
- if (oldRangeStart) {
- // Close out any changes that have been output (or join overlapping)
- if (lines.length <= 8 && i < diff.length-2) {
- // Overlapping
- curRange.push.apply(curRange, contextLines(lines));
- } else {
- // end the range and output
- var contextSize = Math.min(lines.length, 4);
- ret.push(
- "@@ -" + oldRangeStart + "," + (oldLine-oldRangeStart+contextSize)
- + " +" + newRangeStart + "," + (newLine-newRangeStart+contextSize)
- + " @@");
- ret.push.apply(ret, curRange);
- ret.push.apply(ret, contextLines(lines.slice(0, contextSize)));
- if (lines.length <= 4) {
- eofNL(ret, i, current);
- }
-
- oldRangeStart = 0; newRangeStart = 0; curRange = [];
- }
- }
- oldLine += lines.length;
- newLine += lines.length;
- }
- }
-
- return ret.join('\n') + '\n';
- },
-
- convertChangesToXML: function(changes){
- var ret = [];
- for ( var i = 0; i < changes.length; i++) {
- var change = changes[i];
- if (change.added) {
- ret.push("<ins>");
- } else if (change.removed) {
- ret.push("<del>");
- }
-
- ret.push(escapeHTML(change.value));
-
- if (change.added) {
- ret.push("</ins>");
- } else if (change.removed) {
- ret.push("</del>");
- }
- }
- return ret.join("");
- }
- };
-})();
-
-if (typeof module !== "undefined") {
- module.exports = JsDiff;
-}
-
-}); // module: browser/diff.js
-
-require.register("browser/events.js", function(module, exports, require){
-
-/**
- * Module exports.
- */
-
-exports.EventEmitter = EventEmitter;
-
-/**
- * Check if `obj` is an array.
- */
-
-function isArray(obj) {
- return '[object Array]' == {}.toString.call(obj);
-}
-
-/**
- * Event emitter constructor.
- *
- * @api public
- */
-
-function EventEmitter(){};
-
-/**
- * Adds a listener.
- *
- * @api public
- */
-
-EventEmitter.prototype.on = function (name, fn) {
- if (!this.$events) {
- this.$events = {};
- }
-
- if (!this.$events[name]) {
- this.$events[name] = fn;
- } else if (isArray(this.$events[name])) {
- this.$events[name].push(fn);
- } else {
- this.$events[name] = [this.$events[name], fn];
- }
-
- return this;
-};
-
-EventEmitter.prototype.addListener = EventEmitter.prototype.on;
-
-/**
- * Adds a volatile listener.
- *
- * @api public
- */
-
-EventEmitter.prototype.once = function (name, fn) {
- var self = this;
-
- function on () {
- self.removeListener(name, on);
- fn.apply(this, arguments);
- };
-
- on.listener = fn;
- this.on(name, on);
-
- return this;
-};
-
-/**
- * Removes a listener.
- *
- * @api public
- */
-
-EventEmitter.prototype.removeListener = function (name, fn) {
- if (this.$events && this.$events[name]) {
- var list = this.$events[name];
-
- if (isArray(list)) {
- var pos = -1;
-
- for (var i = 0, l = list.length; i < l; i++) {
- if (list[i] === fn || (list[i].listener && list[i].listener === fn)) {
- pos = i;
- break;
- }
- }
-
- if (pos < 0) {
- return this;
- }
-
- list.splice(pos, 1);
-
- if (!list.length) {
- delete this.$events[name];
- }
- } else if (list === fn || (list.listener && list.listener === fn)) {
- delete this.$events[name];
- }
- }
-
- return this;
-};
-
-/**
- * Removes all listeners for an event.
- *
- * @api public
- */
-
-EventEmitter.prototype.removeAllListeners = function (name) {
- if (name === undefined) {
- this.$events = {};
- return this;
- }
-
- if (this.$events && this.$events[name]) {
- this.$events[name] = null;
- }
-
- return this;
-};
-
-/**
- * Gets all listeners for a certain event.
- *
- * @api public
- */
-
-EventEmitter.prototype.listeners = function (name) {
- if (!this.$events) {
- this.$events = {};
- }
-
- if (!this.$events[name]) {
- this.$events[name] = [];
- }
-
- if (!isArray(this.$events[name])) {
- this.$events[name] = [this.$events[name]];
- }
-
- return this.$events[name];
-};
-
-/**
- * Emits an event.
- *
- * @api public
- */
-
-EventEmitter.prototype.emit = function (name) {
- if (!this.$events) {
- return false;
- }
-
- var handler = this.$events[name];
-
- if (!handler) {
- return false;
- }
-
- var args = [].slice.call(arguments, 1);
-
- if ('function' == typeof handler) {
- handler.apply(this, args);
- } else if (isArray(handler)) {
- var listeners = handler.slice();
-
- for (var i = 0, l = listeners.length; i < l; i++) {
- listeners[i].apply(this, args);
- }
- } else {
- return false;
- }
-
- return true;
-};
-}); // module: browser/events.js
-
-require.register("browser/fs.js", function(module, exports, require){
-
-}); // module: browser/fs.js
-
-require.register("browser/path.js", function(module, exports, require){
-
-}); // module: browser/path.js
-
-require.register("browser/progress.js", function(module, exports, require){
-
-/**
- * Expose `Progress`.
- */
-
-module.exports = Progress;
-
-/**
- * Initialize a new `Progress` indicator.
- */
-
-function Progress() {
- this.percent = 0;
- this.size(0);
- this.fontSize(11);
- this.font('helvetica, arial, sans-serif');
-}
-
-/**
- * Set progress size to `n`.
- *
- * @param {Number} n
- * @return {Progress} for chaining
- * @api public
- */
-
-Progress.prototype.size = function(n){
- this._size = n;
- return this;
-};
-
-/**
- * Set text to `str`.
- *
- * @param {String} str
- * @return {Progress} for chaining
- * @api public
- */
-
-Progress.prototype.text = function(str){
- this._text = str;
- return this;
-};
-
-/**
- * Set font size to `n`.
- *
- * @param {Number} n
- * @return {Progress} for chaining
- * @api public
- */
-
-Progress.prototype.fontSize = function(n){
- this._fontSize = n;
- return this;
-};
-
-/**
- * Set font `family`.
- *
- * @param {String} family
- * @return {Progress} for chaining
- */
-
-Progress.prototype.font = function(family){
- this._font = family;
- return this;
-};
-
-/**
- * Update percentage to `n`.
- *
- * @param {Number} n
- * @return {Progress} for chaining
- */
-
-Progress.prototype.update = function(n){
- this.percent = n;
- return this;
-};
-
-/**
- * Draw on `ctx`.
- *
- * @param {CanvasRenderingContext2d} ctx
- * @return {Progress} for chaining
- */
-
-Progress.prototype.draw = function(ctx){
- var percent = Math.min(this.percent, 100)
- , size = this._size
- , half = size / 2
- , x = half
- , y = half
- , rad = half - 1
- , fontSize = this._fontSize;
-
- ctx.font = fontSize + 'px ' + this._font;
-
- var angle = Math.PI * 2 * (percent / 100);
- ctx.clearRect(0, 0, size, size);
-
- // outer circle
- ctx.strokeStyle = '#9f9f9f';
- ctx.beginPath();
- ctx.arc(x, y, rad, 0, angle, false);
- ctx.stroke();
-
- // inner circle
- ctx.strokeStyle = '#eee';
- ctx.beginPath();
- ctx.arc(x, y, rad - 1, 0, angle, true);
- ctx.stroke();
-
- // text
- var text = this._text || (percent | 0) + '%'
- , w = ctx.measureText(text).width;
-
- ctx.fillText(
- text
- , x - w / 2 + 1
- , y + fontSize / 2 - 1);
-
- return this;
-};
-
-}); // module: browser/progress.js
-
-require.register("browser/tty.js", function(module, exports, require){
-
-exports.isatty = function(){
- return true;
-};
-
-exports.getWindowSize = function(){
- if ('innerHeight' in global) {
- return [global.innerHeight, global.innerWidth];
- } else {
- // In a Web Worker, the DOM Window is not available.
- return [640, 480];
- }
-};
-
-}); // module: browser/tty.js
-
-require.register("context.js", function(module, exports, require){
-
-/**
- * Expose `Context`.
- */
-
-module.exports = Context;
-
-/**
- * Initialize a new `Context`.
- *
- * @api private
- */
-
-function Context(){}
-
-/**
- * Set or get the context `Runnable` to `runnable`.
- *
- * @param {Runnable} runnable
- * @return {Context}
- * @api private
- */
-
-Context.prototype.runnable = function(runnable){
- if (0 == arguments.length) return this._runnable;
- this.test = this._runnable = runnable;
- return this;
-};
-
-/**
- * Set test timeout `ms`.
- *
- * @param {Number} ms
- * @return {Context} self
- * @api private
- */
-
-Context.prototype.timeout = function(ms){
- this.runnable().timeout(ms);
- return this;
-};
-
-/**
- * Set test slowness threshold `ms`.
- *
- * @param {Number} ms
- * @return {Context} self
- * @api private
- */
-
-Context.prototype.slow = function(ms){
- this.runnable().slow(ms);
- return this;
-};
-
-/**
- * Inspect the context void of `._runnable`.
- *
- * @return {String}
- * @api private
- */
-
-Context.prototype.inspect = function(){
- return JSON.stringify(this, function(key, val){
- if ('_runnable' == key) return;
- if ('test' == key) return;
- return val;
- }, 2);
-};
-
-}); // module: context.js
-
-require.register("hook.js", function(module, exports, require){
-
-/**
- * Module dependencies.
- */
-
-var Runnable = require('./runnable');
-
-/**
- * Expose `Hook`.
- */
-
-module.exports = Hook;
-
-/**
- * Initialize a new `Hook` with the given `title` and callback `fn`.
- *
- * @param {String} title
- * @param {Function} fn
- * @api private
- */
-
-function Hook(title, fn) {
- Runnable.call(this, title, fn);
- this.type = 'hook';
-}
-
-/**
- * Inherit from `Runnable.prototype`.
- */
-
-function F(){};
-F.prototype = Runnable.prototype;
-Hook.prototype = new F;
-Hook.prototype.constructor = Hook;
-
-
-/**
- * Get or set the test `err`.
- *
- * @param {Error} err
- * @return {Error}
- * @api public
- */
-
-Hook.prototype.error = function(err){
- if (0 == arguments.length) {
- var err = this._error;
- this._error = null;
- return err;
- }
-
- this._error = err;
-};
-
-}); // module: hook.js
-
-require.register("interfaces/bdd.js", function(module, exports, require){
-
-/**
- * Module dependencies.
- */
-
-var Suite = require('../suite')
- , Test = require('../test');
-
-/**
- * BDD-style interface:
- *
- * describe('Array', function(){
- * describe('#indexOf()', function(){
- * it('should return -1 when not present', function(){
- *
- * });
- *
- * it('should return the index when present', function(){
- *
- * });
- * });
- * });
- *
- */
-
-module.exports = function(suite){
- var suites = [suite];
-
- suite.on('pre-require', function(context, file, mocha){
-
- /**
- * Execute before running tests.
- */
-
- context.before = function(fn){
- suites[0].beforeAll(fn);
- };
-
- /**
- * Execute after running tests.
- */
-
- context.after = function(fn){
- suites[0].afterAll(fn);
- };
-
- /**
- * Execute before each test case.
- */
-
- context.beforeEach = function(fn){
- suites[0].beforeEach(fn);
- };
-
- /**
- * Execute after each test case.
- */
-
- context.afterEach = function(fn){
- suites[0].afterEach(fn);
- };
-
- /**
- * Describe a "suite" with the given `title`
- * and callback `fn` containing nested suites
- * and/or tests.
- */
-
- context.describe = context.context = function(title, fn){
- var suite = Suite.create(suites[0], title);
- suites.unshift(suite);
- fn.call(suite);
- suites.shift();
- return suite;
- };
-
- /**
- * Pending describe.
- */
-
- context.xdescribe =
- context.xcontext =
- context.describe.skip = function(title, fn){
- var suite = Suite.create(suites[0], title);
- suite.pending = true;
- suites.unshift(suite);
- fn.call(suite);
- suites.shift();
- };
-
- /**
- * Exclusive suite.
- */
-
- context.describe.only = function(title, fn){
- var suite = context.describe(title, fn);
- mocha.grep(suite.fullTitle());
- };
-
- /**
- * Describe a specification or test-case
- * with the given `title` and callback `fn`
- * acting as a thunk.
- */
-
- context.it = context.specify = function(title, fn){
- var suite = suites[0];
- if (suite.pending) var fn = null;
- var test = new Test(title, fn);
- suite.addTest(test);
- return test;
- };
-
- /**
- * Exclusive test-case.
- */
-
- context.it.only = function(title, fn){
- var test = context.it(title, fn);
- mocha.grep(test.fullTitle());
- };
-
- /**
- * Pending test case.
- */
-
- context.xit =
- context.xspecify =
- context.it.skip = function(title){
- context.it(title);
- };
- });
-};
-
-}); // module: interfaces/bdd.js
-
-require.register("interfaces/exports.js", function(module, exports, require){
-
-/**
- * Module dependencies.
- */
-
-var Suite = require('../suite')
- , Test = require('../test');
-
-/**
- * TDD-style interface:
- *
- * exports.Array = {
- * '#indexOf()': {
- * 'should return -1 when the value is not present': function(){
- *
- * },
- *
- * 'should return the correct index when the value is present': function(){
- *
- * }
- * }
- * };
- *
- */
-
-module.exports = function(suite){
- var suites = [suite];
-
- suite.on('require', visit);
-
- function visit(obj) {
- var suite;
- for (var key in obj) {
- if ('function' == typeof obj[key]) {
- var fn = obj[key];
- switch (key) {
- case 'before':
- suites[0].beforeAll(fn);
- break;
- case 'after':
- suites[0].afterAll(fn);
- break;
- case 'beforeEach':
- suites[0].beforeEach(fn);
- break;
- case 'afterEach':
- suites[0].afterEach(fn);
- break;
- default:
- suites[0].addTest(new Test(key, fn));
- }
- } else {
- var suite = Suite.create(suites[0], key);
- suites.unshift(suite);
- visit(obj[key]);
- suites.shift();
- }
- }
- }
-};
-
-}); // module: interfaces/exports.js
-
-require.register("interfaces/index.js", function(module, exports, require){
-
-exports.bdd = require('./bdd');
-exports.tdd = require('./tdd');
-exports.qunit = require('./qunit');
-exports.exports = require('./exports');
-
-}); // module: interfaces/index.js
-
-require.register("interfaces/qunit.js", function(module, exports, require){
-
-/**
- * Module dependencies.
- */
-
-var Suite = require('../suite')
- , Test = require('../test');
-
-/**
- * QUnit-style interface:
- *
- * suite('Array');
- *
- * test('#length', function(){
- * var arr = [1,2,3];
- * ok(arr.length == 3);
- * });
- *
- * test('#indexOf()', function(){
- * var arr = [1,2,3];
- * ok(arr.indexOf(1) == 0);
- * ok(arr.indexOf(2) == 1);
- * ok(arr.indexOf(3) == 2);
- * });
- *
- * suite('String');
- *
- * test('#length', function(){
- * ok('foo'.length == 3);
- * });
- *
- */
-
-module.exports = function(suite){
- var suites = [suite];
-
- suite.on('pre-require', function(context, file, mocha){
-
- /**
- * Execute before running tests.
- */
-
- context.before = function(fn){
- suites[0].beforeAll(fn);
- };
-
- /**
- * Execute after running tests.
- */
-
- context.after = function(fn){
- suites[0].afterAll(fn);
- };
-
- /**
- * Execute before each test case.
- */
-
- context.beforeEach = function(fn){
- suites[0].beforeEach(fn);
- };
-
- /**
- * Execute after each test case.
- */
-
- context.afterEach = function(fn){
- suites[0].afterEach(fn);
- };
-
- /**
- * Describe a "suite" with the given `title`.
- */
-
- context.suite = function(title){
- if (suites.length > 1) suites.shift();
- var suite = Suite.create(suites[0], title);
- suites.unshift(suite);
- return suite;
- };
-
- /**
- * Exclusive test-case.
- */
-
- context.suite.only = function(title, fn){
- var suite = context.suite(title, fn);
- mocha.grep(suite.fullTitle());
- };
-
- /**
- * Describe a specification or test-case
- * with the given `title` and callback `fn`
- * acting as a thunk.
- */
-
- context.test = function(title, fn){
- var test = new Test(title, fn);
- suites[0].addTest(test);
- return test;
- };
-
- /**
- * Exclusive test-case.
- */
-
- context.test.only = function(title, fn){
- var test = context.test(title, fn);
- mocha.grep(test.fullTitle());
- };
-
- /**
- * Pending test case.
- */
-
- context.test.skip = function(title){
- context.test(title);
- };
- });
-};
-
-}); // module: interfaces/qunit.js
-
-require.register("interfaces/tdd.js", function(module, exports, require){
-
-/**
- * Module dependencies.
- */
-
-var Suite = require('../suite')
- , Test = require('../test');
-
-/**
- * TDD-style interface:
- *
- * suite('Array', function(){
- * suite('#indexOf()', function(){
- * suiteSetup(function(){
- *
- * });
- *
- * test('should return -1 when not present', function(){
- *
- * });
- *
- * test('should return the index when present', function(){
- *
- * });
- *
- * suiteTeardown(function(){
- *
- * });
- * });
- * });
- *
- */
-
-module.exports = function(suite){
- var suites = [suite];
-
- suite.on('pre-require', function(context, file, mocha){
-
- /**
- * Execute before each test case.
- */
-
- context.setup = function(fn){
- suites[0].beforeEach(fn);
- };
-
- /**
- * Execute after each test case.
- */
-
- context.teardown = function(fn){
- suites[0].afterEach(fn);
- };
-
- /**
- * Execute before the suite.
- */
-
- context.suiteSetup = function(fn){
- suites[0].beforeAll(fn);
- };
-
- /**
- * Execute after the suite.
- */
-
- context.suiteTeardown = function(fn){
- suites[0].afterAll(fn);
- };
-
- /**
- * Describe a "suite" with the given `title`
- * and callback `fn` containing nested suites
- * and/or tests.
- */
-
- context.suite = function(title, fn){
- var suite = Suite.create(suites[0], title);
- suites.unshift(suite);
- fn.call(suite);
- suites.shift();
- return suite;
- };
-
- /**
- * Pending suite.
- */
- context.suite.skip = function(title, fn) {
- var suite = Suite.create(suites[0], title);
- suite.pending = true;
- suites.unshift(suite);
- fn.call(suite);
- suites.shift();
- };
-
- /**
- * Exclusive test-case.
- */
-
- context.suite.only = function(title, fn){
- var suite = context.suite(title, fn);
- mocha.grep(suite.fullTitle());
- };
-
- /**
- * Describe a specification or test-case
- * with the given `title` and callback `fn`
- * acting as a thunk.
- */
-
- context.test = function(title, fn){
- var suite = suites[0];
- if (suite.pending) var fn = null;
- var test = new Test(title, fn);
- suite.addTest(test);
- return test;
- };
-
- /**
- * Exclusive test-case.
- */
-
- context.test.only = function(title, fn){
- var test = context.test(title, fn);
- mocha.grep(test.fullTitle());
- };
-
- /**
- * Pending test case.
- */
-
- context.test.skip = function(title){
- context.test(title);
- };
- });
-};
-
-}); // module: interfaces/tdd.js
-
-require.register("mocha.js", function(module, exports, require){
-/*!
- * mocha
- * Copyright(c) 2011 TJ Holowaychuk <tj...@vision-media.ca>
- * MIT Licensed
- */
-
-/**
- * Module dependencies.
- */
-
-var path = require('browser/path')
- , utils = require('./utils');
-
-/**
- * Expose `Mocha`.
- */
-
-exports = module.exports = Mocha;
-
-/**
- * Expose internals.
- */
-
-exports.utils = utils;
-exports.interfaces = require('./interfaces');
-exports.reporters = require('./reporters');
-exports.Runnable = require('./runnable');
-exports.Context = require('./context');
-exports.Runner = require('./runner');
-exports.Suite = require('./suite');
-exports.Hook = require('./hook');
-exports.Test = require('./test');
-
-/**
- * Return image `name` path.
- *
- * @param {String} name
- * @return {String}
- * @api private
- */
-
-function image(name) {
- return __dirname + '/../images/' + name + '.png';
-}
-
-/**
- * Setup mocha with `options`.
- *
- * Options:
- *
- * - `ui` name "bdd", "tdd", "exports" etc
- * - `reporter` reporter instance, defaults to `mocha.reporters.Dot`
- * - `globals` array of accepted globals
- * - `timeout` timeout in milliseconds
- * - `bail` bail on the first test failure
- * - `slow` milliseconds to wait before considering a test slow
- * - `ignoreLeaks` ignore global leaks
- * - `grep` string or regexp to filter tests with
- *
- * @param {Object} options
- * @api public
- */
-
-function Mocha(options) {
- options = options || {};
- this.files = [];
- this.options = options;
- this.grep(options.grep);
- this.suite = new exports.Suite('', new exports.Context);
- this.ui(options.ui);
- this.bail(options.bail);
- this.reporter(options.reporter);
- if (options.timeout) this.timeout(options.timeout);
- if (options.slow) this.slow(options.slow);
-}
-
-/**
- * Enable or disable bailing on the first failure.
- *
- * @param {Boolean} [bail]
- * @api public
- */
-
-Mocha.prototype.bail = function(bail){
- if (0 == arguments.length) bail = true;
- this.suite.bail(bail);
- return this;
-};
-
-/**
- * Add test `file`.
- *
- * @param {String} file
- * @api public
- */
-
-Mocha.prototype.addFile = function(file){
- this.files.push(file);
- return this;
-};
-
-/**
- * Set reporter to `reporter`, defaults to "dot".
- *
- * @param {String|Function} reporter name or constructor
- * @api public
- */
-
-Mocha.prototype.reporter = function(reporter){
- if ('function' == typeof reporter) {
- this._reporter = reporter;
- } else {
- reporter = reporter || 'dot';
- try {
- this._reporter = require('./reporters/' + reporter);
- } catch (err) {
- this._reporter = require(reporter);
- }
- if (!this._reporter) throw new Error('invalid reporter "' + reporter + '"');
- }
- return this;
-};
-
-/**
- * Set test UI `name`, defaults to "bdd".
- *
- * @param {String} bdd
- * @api public
- */
-
-Mocha.prototype.ui = function(name){
- name = name || 'bdd';
- this._ui = exports.interfaces[name];
- if (!this._ui) throw new Error('invalid interface "' + name + '"');
- this._ui = this._ui(this.suite);
- return this;
-};
-
-/**
- * Load registered files.
- *
- * @api private
- */
-
-Mocha.prototype.loadFiles = function(fn){
- var self = this;
- var suite = this.suite;
- var pending = this.files.length;
- this.files.forEach(function(file){
- file = path.resolve(file);
- suite.emit('pre-require', global, file, self);
- suite.emit('require', require(file), file, self);
- suite.emit('post-require', global, file, self);
- --pending || (fn && fn());
- });
-};
-
-/**
- * Enable growl support.
- *
- * @api private
- */
-
-Mocha.prototype._growl = function(runner, reporter) {
- var notify = require('growl');
-
- runner.on('end', function(){
- var stats = reporter.stats;
- if (stats.failures) {
- var msg = stats.failures + ' of ' + runner.total + ' tests failed';
- notify(msg, { name: 'mocha', title: 'Failed', image: image('error') });
- } else {
- notify(stats.passes + ' tests passed in ' + stats.duration + 'ms', {
- name: 'mocha'
- , title: 'Passed'
- , image: image('ok')
- });
- }
- });
-};
-
-/**
- * Add regexp to grep, if `re` is a string it is escaped.
- *
- * @param {RegExp|String} re
- * @return {Mocha}
- * @api public
- */
-
-Mocha.prototype.grep = function(re){
- this.options.grep = 'string' == typeof re
- ? new RegExp(utils.escapeRegexp(re))
- : re;
- return this;
-};
-
-/**
- * Invert `.grep()` matches.
- *
- * @return {Mocha}
- * @api public
- */
-
-Mocha.prototype.invert = function(){
- this.options.invert = true;
- return this;
-};
-
-/**
- * Ignore global leaks.
- *
- * @param {Boolean} ignore
- * @return {Mocha}
- * @api public
- */
-
-Mocha.prototype.ignoreLeaks = function(ignore){
- this.options.ignoreLeaks = !!ignore;
- return this;
-};
-
-/**
- * Enable global leak checking.
- *
- * @return {Mocha}
- * @api public
- */
-
-Mocha.prototype.checkLeaks = function(){
- this.options.ignoreLeaks = false;
- return this;
-};
-
-/**
- * Enable growl support.
- *
- * @return {Mocha}
- * @api public
- */
-
-Mocha.prototype.growl = function(){
- this.options.growl = true;
- return this;
-};
-
-/**
- * Ignore `globals` array or string.
- *
- * @param {Array|String} globals
- * @return {Mocha}
- * @api public
- */
-
-Mocha.prototype.globals = function(globals){
- this.options.globals = (this.options.globals || []).concat(globals);
- return this;
-};
-
-/**
- * Set the timeout in milliseconds.
- *
- * @param {Number} timeout
- * @return {Mocha}
- * @api public
- */
-
-Mocha.prototype.timeout = function(timeout){
- this.suite.timeout(timeout);
- return this;
-};
-
-/**
- * Set slowness threshold in milliseconds.
- *
- * @param {Number} slow
- * @return {Mocha}
- * @api public
- */
-
-Mocha.prototype.slow = function(slow){
- this.suite.slow(slow);
- return this;
-};
-
-/**
- * Makes all tests async (accepting a callback)
- *
- * @return {Mocha}
- * @api public
- */
-
-Mocha.prototype.asyncOnly = function(){
- this.options.asyncOnly = true;
- return this;
-};
-
-/**
- * Run tests and invoke `fn()` when complete.
- *
- * @param {Function} fn
- * @return {Runner}
- * @api public
- */
-
-Mocha.prototype.run = function(fn){
- if (this.files.length) this.loadFiles();
- var suite = this.suite;
- var options = this.options;
- var runner = new exports.Runner(suite);
- var reporter = new this._reporter(runner);
- runner.ignoreLeaks = false !== options.ignoreLeaks;
- runner.asyncOnly = options.asyncOnly;
- if (options.grep) runner.grep(options.grep, options.invert);
- if (options.globals) runner.globals(options.globals);
- if (options.growl) this._growl(runner, reporter);
- return runner.run(fn);
-};
-
-}); // module: mocha.js
-
-require.register("ms.js", function(module, exports, require){
-
-/**
- * Helpers.
- */
-
-var s = 1000;
-var m = s * 60;
-var h = m * 60;
-var d = h * 24;
-
-/**
- * Parse or format the given `val`.
- *
- * @param {String|Number} val
- * @return {String|Number}
- * @api public
- */
-
-module.exports = function(val){
- if ('string' == typeof val) return parse(val);
- return format(val);
-}
-
-/**
- * Parse the given `str` and return milliseconds.
- *
- * @param {String} str
- * @return {Number}
- * @api private
- */
-
-function parse(str) {
- var m = /^((?:\d+)?\.?\d+) *(ms|seconds?|s|minutes?|m|hours?|h|days?|d|years?|y)?$/i.exec(str);
- if (!m) return;
- var n = parseFloat(m[1]);
- var type = (m[2] || 'ms').toLowerCase();
- switch (type) {
- case 'years':
- case 'year':
- case 'y':
- return n * 31557600000;
- case 'days':
- case 'day':
- case 'd':
- return n * 86400000;
- case 'hours':
- case 'hour':
- case 'h':
- return n * 3600000;
- case 'minutes':
- case 'minute':
- case 'm':
- return n * 60000;
- case 'seconds':
- case 'second':
- case 's':
- return n * 1000;
- case 'ms':
- return n;
- }
-}
-
-/**
- * Format the given `ms`.
- *
- * @param {Number} ms
- * @return {String}
- * @api public
- */
-
-function format(ms) {
- if (ms == d) return Math.round(ms / d) + ' day';
- if (ms > d) return Math.round(ms / d) + ' days';
- if (ms == h) return Math.round(ms / h) + ' hour';
- if (ms > h) return Math.round(ms / h) + ' hours';
- if (ms == m) return Math.round(ms / m) + ' minute';
- if (ms > m) return Math.round(ms / m) + ' minutes';
- if (ms == s) return Math.round(ms / s) + ' second';
- if (ms > s) return Math.round(ms / s) + ' seconds';
- return ms + ' ms';
-}
-}); // module: ms.js
-
-require.register("reporters/base.js", function(module, exports, require){
-
-/**
- * Module dependencies.
- */
-
-var tty = require('browser/tty')
- , diff = require('browser/diff')
- , ms = require('../ms');
-
-/**
- * Save timer references to avoid Sinon interfering (see GH-237).
- */
-
-var Date = global.Date
- , setTimeout = global.setTimeout
- , setInterval = global.setInterval
- , clearTimeout = global.clearTimeout
- , clearInterval = global.clearInterval;
-
-/**
- * Check if both stdio streams are associated with a tty.
- */
-
-var isatty = tty.isatty(1) && tty.isatty(2);
-
-/**
- * Expose `Base`.
- */
-
-exports = module.exports = Base;
-
-/**
- * Enable coloring by default.
- */
-
-exports.useColors = isatty;
-
-/**
- * Default color map.
- */
-
-exports.colors = {
- 'pass': 90
- , 'fail': 31
- , 'bright pass': 92
- , 'bright fail': 91
- , 'bright yellow': 93
- , 'pending': 36
- , 'suite': 0
- , 'error title': 0
- , 'error message': 31
- , 'error stack': 90
- , 'checkmark': 32
- , 'fast': 90
- , 'medium': 33
- , 'slow': 31
- , 'green': 32
- , 'light': 90
- , 'diff gutter': 90
- , 'diff added': 42
- , 'diff removed': 41
-};
-
-/**
- * Default symbol map.
- */
-
-exports.symbols = {
- ok: 'ā',
- err: 'ā',
- dot: 'ā¤'
-};
-
-// With node.js on Windows: use symbols available in terminal default fonts
-if ('win32' == process.platform) {
- exports.symbols.ok = '\u221A';
- exports.symbols.err = '\u00D7';
- exports.symbols.dot = '.';
-}
-
-/**
- * Color `str` with the given `type`,
- * allowing colors to be disabled,
- * as well as user-defined color
- * schemes.
- *
- * @param {String} type
- * @param {String} str
- * @return {String}
- * @api private
- */
-
-var color = exports.color = function(type, str) {
- if (!exports.useColors) return str;
- return '\u001b[' + exports.colors[type] + 'm' + str + '\u001b[0m';
-};
-
-/**
- * Expose term window size, with some
- * defaults for when stderr is not a tty.
- */
-
-exports.window = {
- width: isatty
- ? process.stdout.getWindowSize
- ? process.stdout.getWindowSize(1)[0]
- : tty.getWindowSize()[1]
- : 75
-};
-
-/**
- * Expose some basic cursor interactions
- * that are common among reporters.
- */
-
-exports.cursor = {
- hide: function(){
- process.stdout.write('\u001b[?25l');
- },
-
- show: function(){
- process.stdout.write('\u001b[?25h');
- },
-
- deleteLine: function(){
- process.stdout.write('\u001b[2K');
- },
-
- beginningOfLine: function(){
- process.stdout.write('\u001b[0G');
- },
-
- CR: function(){
- exports.cursor.deleteLine();
- exports.cursor.beginningOfLine();
- }
-};
-
-/**
- * Outut the given `failures` as a list.
- *
- * @param {Array} failures
- * @api public
- */
-
-exports.list = function(failures){
- console.error();
- failures.forEach(function(test, i){
- // format
- var fmt = color('error title', ' %s) %s:\n')
- + color('error message', ' %s')
- + color('error stack', '\n%s\n');
-
- // msg
- var err = test.err
- , message = err.message || ''
- , stack = err.stack || message
- , index = stack.indexOf(message) + message.length
- , msg = stack.slice(0, index)
- , actual = err.actual
- , expected = err.expected
- , escape = true;
-
- // uncaught
- if (err.uncaught) {
- msg = 'Uncaught ' + msg;
- }
-
- // explicitly show diff
- if (err.showDiff && sameType(actual, expected)) {
- escape = false;
- err.actual = actual = stringify(actual);
- err.expected = expected = stringify(expected);
- }
-
- // actual / expected diff
- if ('string' == typeof actual && 'string' == typeof expected) {
- msg = errorDiff(err, 'Words', escape);
-
- // linenos
- var lines = msg.split('\n');
- if (lines.length > 4) {
- var width = String(lines.length).length;
- msg = lines.map(function(str, i){
- return pad(++i, width) + ' |' + ' ' + str;
- }).join('\n');
- }
-
- // legend
- msg = '\n'
- + color('diff removed', 'actual')
- + ' '
- + color('diff added', 'expected')
- + '\n\n'
- + msg
- + '\n';
-
- // indent
- msg = msg.replace(/^/gm, ' ');
-
- fmt = color('error title', ' %s) %s:\n%s')
- + color('error stack', '\n%s\n');
- }
-
- // indent stack trace without msg
- stack = stack.slice(index ? index + 1 : index)
- .replace(/^/gm, ' ');
-
- console.error(fmt, (i + 1), test.fullTitle(), msg, stack);
- });
-};
-
-/**
- * Initialize a new `Base` reporter.
- *
- * All other reporters generally
- * inherit from this reporter, providing
- * stats such as test duration, number
- * of tests passed / failed etc.
- *
- * @param {Runner} runner
- * @api public
- */
-
-function Base(runner) {
- var self = this
- , stats = this.stats = { suites: 0, tests: 0, passes: 0, pending: 0, failures: 0 }
- , failures = this.failures = [];
-
- if (!runner) return;
- this.runner = runner;
-
- runner.stats = stats;
-
- runner.on('start', function(){
- stats.start = new Date;
- });
-
- runner.on('suite', function(suite){
- stats.suites = stats.suites || 0;
- suite.root || stats.suites++;
- });
-
- runner.on('test end', function(test){
- stats.tests = stats.tests || 0;
- stats.tests++;
- });
-
- runner.on('pass', function(test){
- stats.passes = stats.passes || 0;
-
- var medium = test.slow() / 2;
- test.speed = test.duration > test.slow()
- ? 'slow'
- : test.duration > medium
- ? 'medium'
- : 'fast';
-
- stats.passes++;
- });
-
- runner.on('fail', function(test, err){
- stats.failures = stats.failures || 0;
- stats.failures++;
- test.err = err;
- failures.push(test);
- });
-
- runner.on('end', function(){
- stats.end = new Date;
- stats.duration = new Date - stats.start;
- });
-
- runner.on('pending', function(){
- stats.pending++;
- });
-}
-
-/**
- * Output common epilogue used by many of
- * the bundled reporters.
- *
- * @api public
- */
-
-Base.prototype.epilogue = function(){
- var stats = this.stats;
- var tests;
- var fmt;
-
- console.log();
-
- // passes
- fmt = color('bright pass', ' ')
- + color('green', ' %d passing')
- + color('light', ' (%s)');
-
- console.log(fmt,
- stats.passes || 0,
- ms(stats.duration));
-
- // pending
- if (stats.pending) {
- fmt = color('pending', ' ')
- + color('pending', ' %d pending');
-
- console.log(fmt, stats.pending);
- }
-
- // failures
- if (stats.failures) {
- fmt = color('fail', ' %d failing');
-
- console.error(fmt,
- stats.failures);
-
- Base.list(this.failures);
- console.error();
- }
-
- console.log();
-};
-
-/**
- * Pad the given `str` to `len`.
- *
- * @param {String} str
- * @param {String} len
- * @return {String}
- * @api private
- */
-
-function pad(str, len) {
- str = String(str);
- return Array(len - str.length + 1).join(' ') + str;
-}
-
-/**
- * Return a character diff for `err`.
- *
- * @param {Error} err
- * @return {String}
- * @api private
- */
-
-function errorDiff(err, type, escape) {
- return diff['diff' + type](err.actual, err.expected).map(function(str){
- if (escape) {
- str.value = str.value
- .replace(/\t/g, '<tab>')
- .replace(/\r/g, '<CR>')
- .replace(/\n/g, '<LF>\n');
- }
- if (str.added) return colorLines('diff added', str.value);
- if (str.removed) return colorLines('diff removed', str.value);
- return str.value;
- }).join('');
-}
-
-/**
- * Color lines for `str`, using the color `name`.
- *
- * @param {String} name
- * @param {String} str
- * @return {String}
- * @api private
- */
-
-function colorLines(name, str) {
- return str.split('\n').map(function(str){
- return color(name, str);
- }).join('\n');
-}
-
-/**
- * Stringify `obj`.
- *
- * @param {Mixed} obj
- * @return {String}
- * @api private
- */
-
-function stringify(obj) {
- if (obj instanceof RegExp) return obj.toString();
- return JSON.stringify(obj, null, 2);
-}
-
-/**
- * Check that a / b have the same type.
- *
- * @param {Object} a
- * @param {Object} b
- * @return {Boolean}
- * @api private
- */
-
-function sameType(a, b) {
- a = Object.prototype.toString.call(a);
- b = Object.prototype.toString.call(b);
- return a == b;
-}
-
-}); // module: reporters/base.js
-
-require.register("reporters/doc.js", function(module, exports, require){
-
-/**
- * Module dependencies.
- */
-
-var Base = require('./base')
- , utils = require('../utils');
-
-/**
- * Expose `Doc`.
- */
-
-exports = module.exports = Doc;
-
-/**
- * Initialize a new `Doc` reporter.
- *
- * @param {Runner} runner
- * @api public
- */
-
-function Doc(runner) {
- Base.call(this, runner);
-
- var self = this
- , stats = this.stats
- , total = runner.total
- , indents = 2;
-
- function indent() {
- return Array(indents).join(' ');
- }
-
- runner.on('suite', function(suite){
- if (suite.root) return;
- ++indents;
- console.log('%s<section class="suite">', indent());
- ++indents;
- console.log('%s<h1>%s</h1>', indent(), utils.escape(suite.title));
- console.log('%s<dl>', indent());
- });
-
- runner.on('suite end', function(suite){
- if (suite.root) return;
- console.log('%s</dl>', indent());
- --indents;
- console.log('%s</section>', indent());
- --indents;
- });
-
- runner.on('pass', function(test){
- console.log('%s <dt>%s</dt>', indent(), utils.escape(test.title));
- var code = utils.escape(utils.clean(test.fn.toString()));
- console.log('%s <dd><pre><code>%s</code></pre></dd>', indent(), code);
- });
-}
-
-}); // module: reporters/doc.js
-
-require.register("reporters/dot.js", function(module, exports, require){
-
-/**
- * Module dependencies.
- */
-
-var Base = require('./base')
- , color = Base.color;
-
-/**
- * Expose `Dot`.
- */
-
-exports = module.exports = Dot;
-
-/**
- * Initialize a new `Dot` matrix test reporter.
- *
- * @param {Runner} runner
- * @api public
- */
-
-function Dot(runner) {
- Base.call(this, runner);
-
- var self = this
- , stats = this.stats
- , width = Base.window.width * .75 | 0
- , n = 0;
-
- runner.on('start', function(){
- process.stdout.write('\n ');
- });
-
- runner.on('pending', function(test){
- process.stdout.write(color('pending', Base.symbols.dot));
- });
-
- runner.on('pass', function(test){
- if (++n % width == 0) process.stdout.write('\n ');
- if ('slow' == test.speed) {
- process.stdout.write(color('bright yellow', Base.symbols.dot));
- } else {
- process.stdout.write(color(test.speed, Base.symbols.dot));
- }
- });
-
- runner.on('fail', function(test, err){
- if (++n % width == 0) process.stdout.write('\n ');
- process.stdout.write(color('fail', Base.symbols.dot));
- });
-
- runner.on('end', function(){
- console.log();
- self.epilogue();
- });
-}
-
-/**
- * Inherit from `Base.prototype`.
- */
-
-function F(){};
-F.prototype = Base.prototype;
-Dot.prototype = new F;
-Dot.prototype.constructor = Dot;
-
-}); // module: reporters/dot.js
-
-require.register("reporters/html-cov.js", function(module, exports, require){
-
-/**
- * Module dependencies.
- */
-
-var JSONCov = require('./json-cov')
- , fs = require('browser/fs');
-
-/**
- * Expose `HTMLCov`.
- */
-
-exports = module.exports = HTMLCov;
-
-/**
- * Initialize a new `JsCoverage` reporter.
- *
- * @param {Runner} runner
- * @api public
- */
-
-function HTMLCov(runner) {
- var jade = require('jade')
- , file = __dirname + '/templates/coverage.jade'
- , str = fs.readFileSync(file, 'utf8')
- , fn = jade.compile(str, { filename: file })
- , self = this;
-
- JSONCov.call(this, runner, false);
-
- runner.on('end', function(){
- process.stdout.write(fn({
- cov: self.cov
- , coverageClass: coverageClass
- }));
- });
-}
-
-/**
- * Return coverage class for `n`.
- *
- * @return {String}
- * @api private
- */
-
-function coverageClass(n) {
- if (n >= 75) return 'high';
- if (n >= 50) return 'medium';
- if (n >= 25) return 'low';
- return 'terrible';
-}
-}); // module: reporters/html-cov.js
-
-require.register("reporters/html.js", function(module, exports, require){
-
-/**
- * Module dependencies.
- */
-
-var Base = require('./base')
- , utils = require('../utils')
- , Progress = require('../browser/progress')
- , escape = utils.escape;
-
-/**
- * Save timer references to avoid Sinon interfering (see GH-237).
- */
-
-var Date = global.Date
- , setTimeout = global.setTimeout
- , setInterval = global.setInterval
- , clearTimeout = global.clearTimeout
- , clearInterval = global.clearInterval;
-
-/**
- * Expose `Doc`.
- */
-
-exports = module.exports = HTML;
-
-/**
- * Stats template.
- */
-
-var statsTemplate = '<ul id="mocha-stats">'
- + '<li class="progress"><canvas width="40" height="40"></canvas></li>'
- + '<li class="passes"><a href="#">passes:</a> <em>0</em></li>'
- + '<li class="failures"><a href="#">failures:</a> <em>0</em></li>'
- + '<li class="duration">duration: <em>0</em>s</li>'
- + '</ul>';
-
-/**
- * Initialize a new `Doc` reporter.
- *
- * @param {Runner} runner
- * @api public
- */
-
-function HTML(runner, root) {
- Base.call(this, runner);
-
- var self = this
- , stats = this.stats
- , total = runner.total
- , stat = fragment(statsTemplate)
- , items = stat.getElementsByTagName('li')
- , passes = items[1].getElementsByTagName('em')[0]
- , passesLink = items[1].getElementsByTagName('a')[0]
- , failures = items[2].getElementsByTagName('em')[0]
- , failuresLink = items[2].getElementsByTagName('a')[0]
- , duration = items[3].getElementsByTagName('em')[0]
- , canvas = stat.getElementsByTagName('canvas')[0]
- , report = fragment('<ul id="mocha-report"></ul>')
- , stack = [report]
- , progress
- , ctx
-
- root = root || document.getElementById('mocha');
-
- if (canvas.getContext) {
- var ratio = window.devicePixelRatio || 1;
- canvas.style.width = canvas.width;
- canvas.style.height = canvas.height;
- canvas.width *= ratio;
- canvas.height *= ratio;
- ctx = canvas.getContext('2d');
- ctx.scale(ratio, ratio);
- progress = new Progress;
- }
-
- if (!root) return error('#mocha div missing, add it to your document');
-
- // pass toggle
- on(passesLink, 'click', function(){
- unhide();
- var name = /pass/.test(report.className) ? '' : ' pass';
- report.className = report.className.replace(/fail|pass/g, '') + name;
- if (report.className.trim()) hideSuitesWithout('test pass');
- });
-
- // failure toggle
- on(failuresLink, 'click', function(){
- unhide();
- var name = /fail/.test(report.className) ? '' : ' fail';
- report.className = report.className.replace(/fail|pass/g, '') + name;
- if (report.className.trim()) hideSuitesWithout('test fail');
- });
-
- root.appendChild(stat);
- root.appendChild(report);
-
- if (progress) progress.size(40);
-
- runner.on('suite', function(suite){
- if (suite.root) return;
-
- // suite
- var url = '?grep=' + encodeURIComponent(suite.fullTitle());
- var el = fragment('<li class="suite"><h1><a href="%s">%s</a></h1></li>', url, escape(suite.title));
-
- // container
- stack[0].appendChild(el);
- stack.unshift(document.createElement('ul'));
- el.appendChild(stack[0]);
- });
-
- runner.on('suite end', function(suite){
- if (suite.root) return;
- stack.shift();
- });
-
- runner.on('fail', function(test, err){
- if ('hook' == test.type) runner.emit('test end', test);
- });
-
- runner.on('test end', function(test){
- // TODO: add to stats
- var percent = stats.tests / this.total * 100 | 0;
- if (progress) progress.update(percent).draw(ctx);
-
- // update stats
- var ms = new Date - stats.start;
- text(passes, stats.passes);
- text(failures, stats.failures);
- text(duration, (ms / 1000).toFixed(2));
-
- // test
- if ('passed' == test.state) {
- var el = fragment('<li class="test pass %e"><h2>%e<span class="duration">%ems</span> <a href="?grep=%e" class="replay">ā£</a></h2></li>', test.speed, test.title, test.duration, encodeURIComponent(test.fullTitle()));
- } else if (test.pending) {
- var el = fragment('<li class="test pass pending"><h2>%e</h2></li>', test.title);
- } else {
- var el = fragment('<li class="test fail"><h2>%e <a href="?grep=%e" class="replay">ā£</a></h2></li>', test.title, encodeURIComponent(test.fullTitle()));
- var str = test.err.stack || test.err.toString();
-
- // FF / Opera do not add the message
- if (!~str.indexOf(test.err.message)) {
- str = test.err.message + '\n' + str;
- }
-
- // <=IE7 stringifies to [Object Error]. Since it can be overloaded, we
- // check for the result of the stringifying.
- if ('[object Error]' == str) str = test.err.message;
-
- // Safari doesn't give you a stack. Let's at least provide a source line.
- if (!test.err.stack && test.err.sourceURL && test.err.line !== undefined) {
- str += "\n(" + test.err.sourceURL + ":" + test.err.line + ")";
- }
-
- el.appendChild(fragment('<pre class="error">%e</pre>', str));
- }
-
- // toggle code
- // TODO: defer
- if (!test.pending) {
- var h2 = el.getElementsByTagName('h2')[0];
-
- on(h2, 'click', function(){
- pre.style.display = 'none' == pre.style.display
- ? 'block'
- : 'none';
- });
-
- var pre = fragment('<pre><code>%e</code></pre>', utils.clean(test.fn.toString()));
- el.appendChild(pre);
- pre.style.display = 'none';
- }
-
- // Don't call .appendChild if #mocha-report was already .shift()'ed off the stack.
- if (stack[0]) stack[0].appendChild(el);
- });
-}
-
-/**
- * Display error `msg`.
- */
-
-function error(msg) {
- document.body.appendChild(fragment('<div id="mocha-error">%s</div>', msg));
-}
-
-/**
- * Return a DOM fragment from `html`.
- */
-
-function fragment(html) {
- var args = arguments
- , div = document.createElement('div')
- , i = 1;
-
- div.innerHTML = html.replace(/%([se])/g, function(_, type){
- switch (type) {
- case 's': return String(args[i++]);
- case 'e': return escape(args[i++]);
- }
- });
-
- return div.firstChild;
-}
-
-/**
- * Check for suites that do not have elements
- * with `classname`, and hide them.
- */
-
-function hideSuitesWithout(classname) {
- var suites = document.getElementsByClassName('suite');
- for (var i = 0; i < suites.length; i++) {
- var els = suites[i].getElementsByClassName(classname);
- if (0 == els.length) suites[i].className += ' hidden';
- }
-}
-
-/**
- * Unhide .hidden suites.
- */
-
-function unhide() {
- var els = document.getElementsByClassName('suite hidden');
- for (var i = 0; i < els.length; ++i) {
- els[i].className = els[i].className.replace('suite hidden', 'suite');
- }
-}
-
-/**
- * Set `el` text to `str`.
- */
-
-function text(el, str) {
- if (el.textContent) {
- el.textContent = str;
- } else {
- el.innerText = str;
- }
-}
-
-/**
- * Listen on `event` with callback `fn`.
- */
-
-function on(el, event, fn) {
- if (el.addEventListener) {
- el.addEventListener(event, fn, false);
- } else {
- el.attachEvent('on' + event, fn);
- }
-}
-
-}); // module: reporters/html.js
-
-require.register("reporters/index.js", function(module, exports, require){
-
-exports.Base = require('./base');
-exports.Dot = require('./dot');
-exports.Doc = require('./doc');
-exports.TAP = require('./tap');
-exports.JSON = require('./json');
-exports.HTML = require('./html');
-exports.List = require('./list');
-exports.Min = require('./min');
-exports.Spec = require('./spec');
-exports.Nyan = require('./nyan');
-exports.XUnit = require('./xunit');
-exports.Markdown = require('./markdown');
-exports.Progress = require('./progress');
-exports.Landing = require('./landing');
-exports.JSONCov = require('./json-cov');
-exports.HTMLCov = require('./html-cov');
-exports.JSONStream = require('./json-stream');
-exports.Teamcity = require('./teamcity');
-
-}); // module: reporters/index.js
-
-require.register("reporters/json-cov.js", function(module, exports, require){
-
-/**
- * Module dependencies.
- */
-
-var Base = require('./base');
-
-/**
- * Expose `JSONCov`.
- */
-
-exports = module.exports = JSONCov;
-
-/**
- * Initialize a new `JsCoverage` reporter.
- *
- * @param {Runner} runner
- * @param {Boolean} output
- * @api public
- */
-
-function JSONCov(runner, output) {
- var self = this
- , output = 1 == arguments.length ? true : output;
-
- Base.call(this, runner);
-
- var tests = []
- , failures = []
- , passes = [];
-
- runner.on('test end', function(test){
- tests.push(test);
- });
-
- runner.on('pass', function(test){
- passes.push(test);
- });
-
- runner.on('fail', function(test){
- failures.push(test);
- });
-
- runner.on('end', function(){
- var cov = global._$jscoverage || {};
- var result = self.cov = map(cov);
- result.stats = self.stats;
- result.tests = tests.map(clean);
- result.failures = failures.map(clean);
- result.passes = passes.map(clean);
- if (!output) return;
- process.stdout.write(JSON.stringify(result, null, 2 ));
- });
-}
-
-/**
- * Map jscoverage data to a JSON structure
- * suitable for reporting.
- *
- * @param {Object} cov
- * @return {Object}
- * @api private
- */
-
-function map(cov) {
- var ret = {
- instrumentation: 'node-jscoverage'
- , sloc: 0
- , hits: 0
- , misses: 0
- , coverage: 0
- , files: []
- };
-
- for (var filename in cov) {
- var data = coverage(filename, cov[filename]);
- ret.files.push(data);
- ret.hits += data.hits;
- ret.misses += data.misses;
- ret.sloc += data.sloc;
- }
-
- ret.files.sort(function(a, b) {
- return a.filename.localeCompare(b.filename);
- });
-
- if (ret.sloc > 0) {
- ret.coverage = (ret.hits / ret.sloc) * 100;
- }
-
- return ret;
-};
-
-/**
- * Map jscoverage data for a single source file
- * to a JSON structure suitable for reporting.
- *
- * @param {String} filename name of the source file
- * @param {Object} data jscoverage coverage data
- * @return {Object}
- * @api private
- */
-
-function coverage(filename, data) {
- var ret = {
- filename: filename,
- coverage: 0,
- hits: 0,
- misses: 0,
- sloc: 0,
- source: {}
- };
-
- data.source.forEach(function(line, num){
- num++;
-
- if (data[num] === 0) {
- ret.misses++;
- ret.sloc++;
- } else if (data[num] !== undefined) {
- ret.hits++;
- ret.sloc++;
- }
-
- ret.source[num] = {
- source: line
- , coverage: data[num] === undefined
- ? ''
- : data[num]
- };
- });
-
- ret.coverage = ret.hits / ret.sloc * 100;
-
- return ret;
-}
-
-/**
- * Return a plain-object representation of `test`
- * free of cyclic properties etc.
- *
- * @param {Object} test
- * @return {Object}
- * @api private
- */
-
-function clean(test) {
- return {
- title: test.title
- , fullTitle: test.fullTitle()
- , duration: test.duration
- }
-}
-
-}); // module: reporters/json-cov.js
-
-require.register("reporters/json-stream.js", function(module, exports, require){
-
-/**
- * Module dependencies.
- */
-
-var Base = require('./base')
- , color = Base.color;
-
-/**
- * Expose `List`.
- */
-
-exports = module.exports = List;
-
-/**
- * Initialize a new `List` test reporter.
- *
- * @param {Runner} runner
- * @api public
- */
-
-function List(runner) {
- Base.call(this, runner);
-
- var self = this
- , stats = this.stats
- , total = runner.total;
-
- runner.on('start', function(){
- console.log(JSON.stringify(['start', { total: total }]));
- });
-
- runner.on('pass', function(test){
- console.log(JSON.stringify(['pass', clean(test)]));
- });
-
- runner.on('fail', function(test, err){
- console.log(JSON.stringify(['fail', clean(test)]));
- });
-
- runner.on('end', function(){
- process.stdout.write(JSON.stringify(['end', self.stats]));
- });
-}
-
-/**
- * Return a plain-object representation of `test`
- * free of cyclic properties etc.
- *
- * @param {Object} test
- * @return {Object}
- * @api private
- */
-
-function clean(test) {
- return {
- title: test.title
- , fullTitle: test.fullTitle()
- , duration: test.duration
- }
-}
-}); // module: reporters/json-stream.js
-
-require.register("reporters/json.js", function(module, exports, require){
-
-/**
- * Module dependencies.
- */
-
-var Base = require('./base')
- , cursor = Base.cursor
- , color = Base.color;
-
-/**
- * Expose `JSON`.
- */
-
-exports = module.exports = JSONReporter;
-
-/**
- * Initialize a new `JSON` reporter.
- *
- * @param {Runner} runner
- * @api public
- */
-
-function JSONReporter(runner) {
- var self = this;
- Base.call(this, runner);
-
- var tests = []
- , failures = []
- , passes = [];
-
- runner.on('test end', function(test){
- tests.push(test);
- });
-
- runner.on('pass', function(test){
- passes.push(test);
- });
-
- runner.on('fail', function(test){
- failures.push(test);
- });
-
- runner.on('end', function(){
- var obj = {
- stats: self.stats
- , tests: tests.map(clean)
- , failures: failures.map(clean)
- , passes: passes.map(clean)
- };
-
- process.stdout.write(JSON.stringify(obj, null, 2));
- });
-}
-
-/**
- * Return a plain-object representation of `test`
- * free of cyclic properties etc.
- *
- * @param {Object} test
- * @return {Object}
- * @api private
- */
-
-function clean(test) {
- return {
- title: test.title
- , fullTitle: test.fullTitle()
- , duration: test.duration
- }
-}
-}); // module: reporters/json.js
-
-require.register("reporters/landing.js", function(module, exports, require){
-
-/**
- * Module dependencies.
- */
-
-var Base = require('./base')
- , cursor = Base.cursor
- , color = Base.color;
-
-/**
- * Expose `Landing`.
- */
-
-exports = module.exports = Landing;
-
-/**
- * Airplane color.
- */
-
-Base.colors.plane = 0;
-
-/**
- * Airplane crash color.
- */
-
-Base.colors['plane crash'] = 31;
-
-/**
- * Runway color.
- */
-
-Base.colors.runway = 90;
-
-/**
- * Initialize a new `Landing` reporter.
- *
- * @param {Runner} runner
- * @api public
- */
-
-function Landing(runner) {
- Base.call(this, runner);
-
- var self = this
- , stats = this.stats
- , width = Base.window.width * .75 | 0
- , total = runner.total
- , stream = process.stdout
- , plane = color('plane', 'ā')
- , crashed = -1
- , n = 0;
-
- function runway() {
- var buf = Array(width).join('-');
- return ' ' + color('runway', buf);
- }
-
- runner.on('start', function(){
- stream.write('\n ');
- cursor.hide();
- });
-
- runner.on('test end', function(test){
- // check if the plane crashed
- var col = -1 == crashed
- ? width * ++n / total | 0
- : crashed;
-
- // show the crash
- if ('failed' == test.state) {
- plane = color('plane crash', 'ā');
- crashed = col;
- }
-
- // render landing strip
- stream.write('\u001b[4F\n\n');
- stream.write(runway());
- stream.write('\n ');
- stream.write(color('runway', Array(col).join('ā
')));
- stream.write(plane)
- stream.write(color('runway', Array(width - col).join('ā
') + '\n'));
- stream.write(runway());
- stream.write('\u001b[0m');
- });
-
- runner.on('end', function(){
- cursor.show();
- console.log();
- self.epilogue();
- });
-}
-
-/**
- * Inherit from `Base.prototype`.
- */
-
-function F(){};
-F.prototype = Base.prototype;
-Landing.prototype = new F;
-Landing.prototype.constructor = Landing;
-
-}); // module: reporters/landing.js
-
-require.register("reporters/list.js", function(module, exports, require){
-
-/**
- * Module dependencies.
- */
-
-var Base = require('./base')
- , cursor = Base.cursor
- , color = Base.color;
-
-/**
- * Expose `List`.
- */
-
-exports = module.exports = List;
-
-/**
- * Initialize a new `List` test reporter.
- *
- * @param {Runner} runner
- * @api public
- */
-
-function List(runner) {
- Base.call(this, runner);
-
- var self = this
- , stats = this.stats
- , n = 0;
-
- runner.on('start', function(){
- console.log();
- });
-
- runner.on('test', function(test){
- process.stdout.write(color('pass', ' ' + test.fullTitle() + ': '));
- });
-
- runner.on('pending', function(test){
- var fmt = color('checkmark', ' -')
- + color('pending', ' %s');
- console.log(fmt, test.fullTitle());
- });
-
- runner.on('pass', function(test){
- var fmt = color('checkmark', ' '+Base.symbols.dot)
- + color('pass', ' %s: ')
- + color(test.speed, '%dms');
- cursor.CR();
- console.log(fmt, test.fullTitle(), test.duration);
- });
-
- runner.on('fail', function(test, err){
- cursor.CR();
- console.log(color('fail', ' %d) %s'), ++n, test.fullTitle());
- });
-
- runner.on('end', self.epilogue.bind(self));
-}
-
-/**
- * Inherit from `Base.prototype`.
- */
-
-function F(){};
-F.prototype = Base.prototype;
-List.prototype = new F;
-List.prototype.constructor = List;
-
-
-}); // module: reporters/list.js
-
-require.register("reporters/markdown.js", function(module, exports, require){
-/**
- * Module dependencies.
- */
-
-var Base = require('./base')
- , utils = require('../utils');
-
-/**
- * Expose `Markdown`.
- */
-
-exports = module.exports = Markdown;
-
-/**
- * Initialize a new `Markdown` reporter.
- *
- * @param {Runner} runner
- * @api public
- */
-
-function Markdown(runner) {
- Base.call(this, runner);
-
- var self = this
- , stats = this.stats
- , level = 0
- , buf = '';
-
- function title(str) {
- return Array(level).join('#') + ' ' + str;
- }
-
- function indent() {
- return Array(level).join(' ');
- }
-
- function mapTOC(suite, obj) {
- var ret = obj;
- obj = obj[suite.title] = obj[suite.title] || { suite: suite };
- suite.suites.forEach(function(suite){
- mapTOC(suite, obj);
- });
- return ret;
- }
-
- function stringifyTOC(obj, level) {
- ++level;
- var buf = '';
- var link;
- for (var key in obj) {
- if ('suite' == key) continue;
- if (key) link = ' - [' + key + '](#' + utils.slug(obj[key].suite.fullTitle()) + ')\n';
- if (key) buf += Array(level).join(' ') + link;
- buf += stringifyTOC(obj[key], level);
- }
- --level;
- return buf;
- }
-
- function generateTOC(suite) {
- var obj = mapTOC(suite, {});
- return stringifyTOC(obj, 0);
- }
-
- generateTOC(runner.suite);
-
- runner.on('suite', function(suite){
- ++level;
- var slug = utils.slug(suite.fullTitle());
- buf += '<a name="' + slug + '"></a>' + '\n';
- buf += title(suite.title) + '\n';
- });
-
- runner.on('suite end', function(suite){
- --level;
- });
-
- runner.on('pass', function(test){
- var code = utils.clean(test.fn.toString());
- buf += test.title + '.\n';
- buf += '\n```js\n';
- buf += code + '\n';
- buf += '```\n\n';
- });
-
- runner.on('end', function(){
- process.stdout.write('# TOC\n');
- process.stdout.write(generateTOC(runner.suite));
- process.stdout.write(buf);
- });
-}
-}); // module: reporters/markdown.js
-
-require.register("reporters/min.js", function(module, exports, require){
-
-/**
- * Module dependencies.
- */
-
-var Base = require('./base');
-
-/**
- * Expose `Min`.
- */
-
-exports = module.exports = Min;
-
-/**
- * Initialize a new `Min` minimal test reporter (best used with --watch).
- *
- * @param {Runner} runner
- * @api public
- */
-
-function Min(runner) {
- Base.call(this, runner);
-
- runner.on('start', function(){
- // clear screen
- process.stdout.write('\u001b[2J');
- // set cursor position
- process.stdout.write('\u001b[1;3H');
- });
-
- runner.on('end', this.epilogue.bind(this));
-}
-
-/**
- * Inherit from `Base.prototype`.
- */
-
-function F(){};
-F.prototype = Base.prototype;
-Min.prototype = new F;
-Min.prototype.constructor = Min;
-
-
-}); // module: reporters/min.js
-
-require.register("reporters/nyan.js", function(module, exports, require){
-/**
- * Module dependencies.
- */
-
-var Base = require('./base')
- , color = Base.color;
-
-/**
- * Expose `Dot`.
- */
-
-exports = module.exports = NyanCat;
-
-/**
- * Initialize a new `Dot` matrix test reporter.
- *
- * @param {Runner} runner
- * @api public
- */
-
-function NyanCat(runner) {
- Base.call(this, runner);
-
- var self = this
- , stats = this.stats
- , width = Base.window.width * .75 | 0
- , rainbowColors = this.rainbowColors = self.generateColors()
- , colorIndex = this.colorIndex = 0
- , numerOfLines = this.numberOfLines = 4
- , trajectories = this.trajectories = [[], [], [], []]
- , nyanCatWidth = this.nyanCatWidth = 11
- , trajectoryWidthMax = this.trajectoryWidthMax = (width - nyanCatWidth)
- , scoreboardWidth = this.scoreboardWidth = 5
- , tick = this.tick = 0
- , n = 0;
-
- runner.on('start', function(){
- Base.cursor.hide();
- self.draw('start');
- });
-
- runner.on('pending', function(test){
- self.draw('pending');
- });
-
- runner.on('pass', function(test){
- self.draw('pass');
- });
-
- runner.on('fail', function(test, err){
- self.draw('fail');
- });
-
- runner.on('end', function(){
- Base.cursor.show();
- for (var i = 0; i < self.numberOfLines; i++) write('\n');
- self.epilogue();
- });
-}
-
-/**
- * Draw the nyan cat with runner `status`.
- *
- * @param {String} status
- * @api private
- */
-
-NyanCat.prototype.draw = function(status){
- this.appendRainbow();
- this.drawScoreboard();
- this.drawRainbow();
- this.drawNyanCat(status);
- this.tick = !this.tick;
-};
-
-/**
- * Draw the "scoreboard" showing the number
- * of passes, failures and pending tests.
- *
- * @api private
- */
-
-NyanCat.prototype.drawScoreboard = function(){
- var stats = this.stats;
- var colors = Base.colors;
-
- function draw(color, n) {
- write(' ');
- write('\u001b[' + color + 'm' + n + '\u001b[0m');
- write('\n');
- }
-
- draw(colors.green, stats.passes);
- draw(colors.fail, stats.failures);
- draw(colors.pending, stats.pending);
- write('\n');
-
- this.cursorUp(this.numberOfLines);
-};
-
-/**
- * Append the rainbow.
- *
- * @api private
- */
-
-NyanCat.prototype.appendRainbow = function(){
- var segment = this.tick ? '_' : '-';
- var rainbowified = this.rainbowify(segment);
-
- for (var index = 0; index < this.numberOfLines; index++) {
- var trajectory = this.trajectories[index];
- if (trajectory.length >= this.trajectoryWidthMax) trajectory.shift();
- trajectory.push(rainbowified);
- }
-};
-
-/**
- * Draw the rainbow.
- *
- * @api private
- */
-
-NyanCat.prototype.drawRainbow = function(){
- var self = this;
-
- this.trajectories.forEach(function(line, index) {
- write('\u001b[' + self.scoreboardWidth + 'C');
- write(line.join(''));
- write('\n');
- });
-
- this.cursorUp(this.numberOfLines);
-};
-
-/**
- * Draw the nyan cat with `status`.
- *
- * @param {String} status
- * @api private
- */
-
-NyanCat.prototype.drawNyanCat = function(status) {
- var self = this;
- var startWidth = this.scoreboardWidth + this.trajectories[0].length;
- var color = '\u001b[' + startWidth + 'C';
- var padding = '';
-
- write(color);
- write('_,------,');
- write('\n');
-
- write(color);
- padding = self.tick ? ' ' : ' ';
- write('_|' + padding + '/\\_/\\ ');
- write('\n');
-
- write(color);
- padding = self.tick ? '_' : '__';
- var tail = self.tick ? '~' : '^';
- var face;
- switch (status) {
- case 'pass':
- face = '( ^ .^)';
- break;
- case 'fail':
- face = '( o .o)';
- break;
- default:
- face = '( - .-)';
- }
- write(tail + '|' + padding + face + ' ');
- write('\n');
-
- write(color);
- padding = self.tick ? ' ' : ' ';
- write(padding + '"" "" ');
- write('\n');
-
- this.cursorUp(this.numberOfLines);
-};
-
-/**
- * Move cursor up `n`.
- *
- * @param {Number} n
- * @api private
- */
-
-NyanCat.prototype.cursorUp = function(n) {
- write('\u001b[' + n + 'A');
-};
-
-/**
- * Move cursor down `n`.
- *
- * @param {Number} n
- * @api private
- */
-
-NyanCat.prototype.cursorDown = function(n) {
- write('\u001b[' + n + 'B');
-};
-
-/**
- * Generate rainbow colors.
- *
- * @return {Array}
- * @api private
- */
-
-NyanCat.prototype.generateColors = function(){
- var colors = [];
-
- for (var i = 0; i < (6 * 7); i++) {
- var pi3 = Math.floor(Math.PI / 3);
- var n = (i * (1.0 / 6));
- var r = Math.floor(3 * Math.sin(n) + 3);
- var g = Math.floor(3 * Math.sin(n + 2 * pi3) + 3);
- var b = Math.floor(3 * Math.sin(n + 4 * pi3) + 3);
- colors.push(36 * r + 6 * g + b + 16);
- }
-
- return colors;
-};
-
-/**
- * Apply rainbow to the given `str`.
- *
- * @param {String} str
- * @return {String}
- * @api private
- */
-
-NyanCat.prototype.rainbowify = function(str){
- var color = this.rainbowColors[this.colorIndex % this.rainbowColors.length];
- this.colorIndex += 1;
- return '\u001b[38;5;' + color + 'm' + str + '\u001b[0m';
-};
-
-/**
- * Stdout helper.
- */
-
-function write(string) {
- process.stdout.write(string);
-}
-
-/**
- * Inherit from `Base.prototype`.
- */
-
-function F(){};
-F.prototype = Base.prototype;
-NyanCat.prototype = new F;
-NyanCat.prototype.constructor = NyanCat;
-
-
-}); // module: reporters/nyan.js
-
-require.register("reporters/progress.js", function(module, exports, require){
-
-/**
- * Module dependencies.
- */
-
-var Base = require('./base')
- , cursor = Base.cursor
- , color = Base.color;
-
-/**
- * Expose `Progress`.
- */
-
-exports = module.exports = Progress;
-
-/**
- * General progress bar color.
- */
-
-Base.colors.progress = 90;
-
-/**
- * Initialize a new `Progress` bar test reporter.
- *
- * @param {Runner} runner
- * @param {Object} options
- * @api public
- */
-
-function Progress(runner, options) {
- Base.call(this, runner);
-
- var self = this
- , options = options || {}
- , stats = this.stats
- , width = Base.window.width * .50 | 0
- , total = runner.total
- , complete = 0
- , max = Math.max;
-
- // default chars
- options.open = options.open || '[';
- options.complete = options.complete || 'ā¬';
- options.incomplete = options.incomplete || Base.symbols.dot;
- options.close = options.close || ']';
- options.verbose = false;
-
- // tests started
- runner.on('start', function(){
- console.log();
- cursor.hide();
- });
-
- // tests complete
- runner.on('test end', function(){
- complete++;
- var incomplete = total - complete
- , percent = complete / total
- , n = width * percent | 0
- , i = width - n;
-
- cursor.CR();
- process.stdout.write('\u001b[J');
- process.stdout.write(color('progress', ' ' + options.open));
- process.stdout.write(Array(n).join(options.complete));
- process.stdout.write(Array(i).join(options.incomplete));
- process.stdout.write(color('progress', options.close));
- if (options.verbose) {
- process.stdout.write(color('progress', ' ' + complete + ' of ' + total));
- }
- });
-
- // tests are complete, output some stats
- // and the failures if any
- runner.on('end', function(){
- cursor.show();
- console.log();
- self.epilogue();
- });
-}
-
-/**
- * Inherit from `Base.prototype`.
- */
-
-function F(){};
-F.prototype = Base.prototype;
-Progress.prototype = new F;
-Progress.prototype.constructor = Progress;
-
-
-}); // module: reporters/progress.js
-
-require.register("reporters/spec.js", function(module, exports, require){
-
-/**
- * Module dependencies.
- */
-
-var Base = require('./base')
- , cursor = Base.cursor
- , color = Base.color;
-
-/**
- * Expose `Spec`.
- */
-
-exports = module.exports = Spec;
-
-/**
- * Initialize a new `Spec` test reporter.
- *
- * @param {Runner} runner
- * @api public
- */
-
-function Spec(runner) {
- Base.call(this, runner);
-
- var self = this
- , stats = this.stats
- , indents = 0
- , n = 0;
-
- function indent() {
- return Array(indents).join(' ')
- }
-
- runner.on('start', function(){
- console.log();
- });
-
- runner.on('suite', function(suite){
- ++indents;
- console.log(color('suite', '%s%s'), indent(), suite.title);
- });
-
- runner.on('suite end', function(suite){
- --indents;
- if (1 == indents) console.log();
- });
-
- runner.on('test', function(test){
- process.stdout.write(indent() + color('pass', ' ā¦ ' + test.title + ': '));
- });
-
- runner.on('pending', function(test){
- var fmt = indent() + color('pending', ' - %s');
- console.log(fmt, test.title);
- });
-
- runner.on('pass', function(test){
- if ('fast' == test.speed) {
- var fmt = indent()
- + color('checkmark', ' ' + Base.symbols.ok)
- + color('pass', ' %s ');
- cursor.CR();
- console.log(fmt, test.title);
- } else {
- var fmt = indent()
- + color('checkmark', ' ' + Base.symbols.ok)
- + color('pass', ' %s ')
- + color(test.speed, '(%dms)');
- cursor.CR();
- console.log(fmt, test.title, test.duration);
- }
- });
-
- runner.on('fail', function(test, err){
- cursor.CR();
- console.log(indent() + color('fail', ' %d) %s'), ++n, test.title);
- });
-
- runner.on('end', self.epilogue.bind(self));
-}
-
-/**
- * Inherit from `Base.prototype`.
- */
-
-function F(){};
-F.prototype = Base.prototype;
-Spec.prototype = new F;
-Spec.prototype.constructor = Spec;
-
-
-}); // module: reporters/spec.js
-
-require.register("reporters/tap.js", function(module, exports, require){
-
-/**
- * Module dependencies.
- */
-
-var Base = require('./base')
- , cursor = Base.cursor
- , color = Base.color;
-
-/**
- * Expose `TAP`.
- */
-
-exports = module.exports = TAP;
-
-/**
- * Initialize a new `TAP` reporter.
- *
- * @param {Runner} runner
- * @api public
- */
-
-function TAP(runner) {
- Base.call(this, runner);
-
- var self = this
- , stats = this.stats
- , n = 1
- , passes = 0
- , failures = 0;
-
- runner.on('start', function(){
- var total = runner.grepTotal(runner.suite);
- console.log('%d..%d', 1, total);
- });
-
- runner.on('test end', function(){
- ++n;
- });
-
- runner.on('pending', function(test){
- console.log('ok %d %s # SKIP -', n, title(test));
- });
-
- runner.on('pass', function(test){
- passes++;
- console.log('ok %d %s', n, title(test));
- });
-
- runner.on('fail', function(test, err){
- failures++;
- console.log('not ok %d %s', n, title(test));
- if (err.stack) console.log(err.stack.replace(/^/gm, ' '));
- });
-
- runner.on('end', function(){
- console.log('# tests ' + (passes + failures));
- console.log('# pass ' + passes);
- console.log('# fail ' + failures);
- });
-}
-
-/**
- * Return a TAP-safe title of `test`
- *
- * @param {Object} test
- * @return {String}
- * @api private
- */
-
-function title(test) {
- return test.fullTitle().replace(/#/g, '');
-}
-
-}); // module: reporters/tap.js
-
-require.register("reporters/teamcity.js", function(module, exports, require){
-
-/**
- * Module dependencies.
- */
-
-var Base = require('./base');
-
-/**
- * Expose `Teamcity`.
- */
-
-exports = module.exports = Teamcity;
-
-/**
- * Initialize a new `Teamcity` reporter.
- *
- * @param {Runner} runner
- * @api public
- */
-
-function Teamcity(runner) {
- Base.call(this, runner);
- var stats = this.stats;
-
- runner.on('start', function() {
- console.log("##teamcity[testSuiteStarted name='mocha.suite']");
- });
-
- runner.on('test', function(test) {
- console.log("##teamcity[testStarted name='" + escape(test.fullTitle()) + "']");
- });
-
- runner.on('fail', function(test, err) {
- console.log("##teamcity[testFailed name='" + escape(test.fullTitle()) + "' message='" + escape(err.message) + "']");
- });
-
- runner.on('pending', function(test) {
- console.log("##teamcity[testIgnored name='" + escape(test.fullTitle()) + "' message='pending']");
- });
-
- runner.on('test end', function(test) {
- console.log("##teamcity[testFinished name='" + escape(test.fullTitle()) + "' duration='" + test.duration + "']");
- });
-
- runner.on('end', function() {
- console.log("##teamcity[testSuiteFinished name='mocha.suite' duration='" + stats.duration + "']");
- });
-}
-
-/**
- * Escape the given `str`.
- */
-
-function escape(str) {
- return str
- .replace(/\|/g, "||")
- .replace(/\n/g, "|n")
- .replace(/\r/g, "|r")
- .replace(/\[/g, "|[")
- .replace(/\]/g, "|]")
- .replace(/\u0085/g, "|x")
- .replace(/\u2028/g, "|l")
- .replace(/\u2029/g, "|p")
- .replace(/'/g, "|'");
-}
-
-}); // module: reporters/teamcity.js
-
-require.register("reporters/xunit.js", function(module, exports, require){
-
-/**
- * Module dependencies.
- */
-
-var Base = require('./base')
- , utils = require('../utils')
- , escape = utils.escape;
-
-/**
- * Save timer references to avoid Sinon interfering (see GH-237).
- */
-
-var Date = global.Date
- , setTimeout = global.setTimeout
- , setInterval = global.setInterval
- , clearTimeout = global.clearTimeout
- , clearInterval = global.clearInterval;
-
-/**
- * Expose `XUnit`.
- */
-
-exports = module.exports = XUnit;
-
-/**
- * Initialize a new `XUnit` reporter.
- *
- * @param {Runner} runner
- * @api public
- */
-
-function XUnit(runner) {
- Base.call(this, runner);
- var stats = this.stats
- , tests = []
- , self = this;
-
- runner.on('pass', function(test){
- tests.push(test);
- });
-
- runner.on('fail', function(test){
- tests.push(test);
- });
-
- runner.on('end', function(){
- console.log(tag('testsuite', {
- name: 'Mocha Tests'
- , tests: stats.tests
- , failures: stats.failures
- , errors: stats.failures
- , skipped: stats.tests - stats.failures - stats.passes
- , timestamp: (new Date).toUTCString()
- , time: (stats.duration / 1000) || 0
- }, false));
-
- tests.forEach(test);
- console.log('</testsuite>');
- });
-}
-
-/**
- * Inherit from `Base.prototype`.
- */
-
-function F(){};
-F.prototype = Base.prototype;
-XUnit.prototype = new F;
-XUnit.prototype.constructor = XUnit;
-
-
-/**
- * Output tag for the given `test.`
- */
-
-function test(test) {
- var attrs = {
- classname: test.parent.fullTitle()
- , name: test.title
- , time: test.duration / 1000
- };
-
- if ('failed' == test.state) {
- var err = test.err;
- attrs.message = escape(err.message);
- console.log(tag('testcase', attrs, false, tag('failure', attrs, false, cdata(err.stack))));
- } else if (test.pending) {
- console.log(tag('testcase', attrs, false, tag('skipped', {}, true)));
- } else {
- console.log(tag('testcase', attrs, true) );
- }
-}
-
-/**
- * HTML tag helper.
- */
-
-function tag(name, attrs, close, content) {
- var end = close ? '/>' : '>'
- , pairs = []
- , tag;
-
- for (var key in attrs) {
- pairs.push(key + '="' + escape(attrs[key]) + '"');
- }
-
- tag = '<' + name + (pairs.length ? ' ' + pairs.join(' ') : '') + end;
- if (content) tag += content + '</' + name + end;
- return tag;
-}
-
-/**
- * Return cdata escaped CDATA `str`.
- */
-
-function cdata(str) {
- return '<![CDATA[' + escape(str) + ']]>';
-}
-
-}); // module: reporters/xunit.js
-
-require.register("runnable.js", function(module, exports, require){
-
-/**
- * Module dependencies.
- */
-
-var EventEmitter = require('browser/events').EventEmitter
- , debug = require('browser/debug')('mocha:runnable')
- , milliseconds = require('./ms');
-
-/**
- * Save timer references to avoid Sinon interfering (see GH-237).
- */
-
-var Date = global.Date
- , setTimeout = global.setTimeout
- , setInterval = global.setInterval
- , clearTimeout = global.clearTimeout
- , clearInterval = global.clearInterval;
-
-/**
- * Object#toString().
- */
-
-var toString = Object.prototype.toString;
-
-/**
- * Expose `Runnable`.
- */
-
-module.exports = Runnable;
-
-/**
- * Initialize a new `Runnable` with the given `title` and callback `fn`.
- *
- * @param {String} title
- * @param {Function} fn
- * @api private
- */
-
-function Runnable(title, fn) {
- this.title = title;
- this.fn = fn;
- this.async = fn && fn.length;
- this.sync = ! this.async;
- this._timeout = 2000;
- this._slow = 75;
- this.timedOut = false;
-}
-
-/**
- * Inherit from `EventEmitter.prototype`.
- */
-
-function F(){};
-F.prototype = EventEmitter.prototype;
-Runnable.prototype = new F;
-Runnable.prototype.constructor = Runnable;
-
-
-/**
- * Set & get timeout `ms`.
- *
- * @param {Number|String} ms
- * @return {Runnable|Number} ms or self
- * @api private
- */
-
-Runnable.prototype.timeout = function(ms){
- if (0 == arguments.length) return this._timeout;
- if ('string' == typeof ms) ms = milliseconds(ms);
- debug('timeout %d', ms);
- this._timeout = ms;
- if (this.timer) this.resetTimeout();
- return this;
-};
-
-/**
- * Set & get slow `ms`.
- *
- * @param {Number|String} ms
- * @return {Runnable|Number} ms or self
- * @api private
- */
-
-Runnable.prototype.slow = function(ms){
- if (0 === arguments.length) return this._slow;
- if ('string' == typeof ms) ms = milliseconds(ms);
- debug('timeout %d', ms);
- this._slow = ms;
- return this;
-};
-
-/**
- * Return the full title generated by recursively
- * concatenating the parent's full title.
- *
- * @return {String}
- * @api public
- */
-
-Runnable.prototype.fullTitle = function(){
- return this.parent.fullTitle() + ' ' + this.title;
-};
-
-/**
- * Clear the timeout.
- *
- * @api private
- */
-
-Runnable.prototype.clearTimeout = function(){
- clearTimeout(this.timer);
-};
-
-/**
- * Inspect the runnable void of private properties.
- *
- * @return {String}
- * @api private
- */
-
-Runnable.prototype.inspect = function(){
- return JSON.stringify(this, function(key, val){
- if ('_' == key[0]) return;
- if ('parent' == key) return '#<Suite>';
- if ('ctx' == key) return '#<Context>';
- return val;
- }, 2);
-};
-
-/**
- * Reset the timeout.
- *
- * @api private
- */
-
-Runnable.prototype.resetTimeout = function(){
- var self = this;
- var ms = this.timeout() || 1e9;
-
- this.clearTimeout();
- this.timer = setTimeout(function(){
- self.callback(new Error('timeout of ' + ms + 'ms exceeded'));
- self.timedOut = true;
- }, ms);
-};
-
-/**
- * Run the test and invoke `fn(err)`.
- *
- * @param {Function} fn
- * @api private
- */
-
-Runnable.prototype.run = function(fn){
- var self = this
- , ms = this.timeout()
- , start = new Date
- , ctx = this.ctx
- , finished
- , emitted;
-
- if
<TRUNCATED>
[26/26] git commit: updated refs/heads/1.4.x to 81b1601
Posted by dj...@apache.org.
Add missing etap file.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/81b1601a
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/81b1601a
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/81b1601a
Branch: refs/heads/1.4.x
Commit: 81b1601a382aa19bfd4d780d4ccab24665b43f32
Parents: a2b7d6a
Author: Dirkjan Ochtman <dj...@apache.org>
Authored: Wed Aug 7 18:04:05 2013 +0200
Committer: Dirkjan Ochtman <dj...@apache.org>
Committed: Wed Aug 7 18:04:05 2013 +0200
----------------------------------------------------------------------
test/etap/Makefile.am | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/81b1601a/test/etap/Makefile.am
----------------------------------------------------------------------
diff --git a/test/etap/Makefile.am b/test/etap/Makefile.am
index 529cf27..66048a9 100644
--- a/test/etap/Makefile.am
+++ b/test/etap/Makefile.am
@@ -63,6 +63,7 @@ tap_files = \
074-doc-update-conflicts.t \
075-auth-cache.t \
076-file-compression.t \
+ 077-couch-db-fast-db-delete-create.t \
080-config-get-set.t \
081-config-override.1.ini \
081-config-override.2.ini \
[25/26] git commit: updated refs/heads/1.4.x to 81b1601
Posted by dj...@apache.org.
Remove fauxton from 1.4.x branch.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/a2b7d6a1
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/a2b7d6a1
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/a2b7d6a1
Branch: refs/heads/1.4.x
Commit: a2b7d6a1cb2f1abac632587925fafa2c279b984f
Parents: 1769fb7
Author: Dirkjan Ochtman <dj...@apache.org>
Authored: Wed Aug 7 18:02:05 2013 +0200
Committer: Dirkjan Ochtman <dj...@apache.org>
Committed: Wed Aug 7 18:02:05 2013 +0200
----------------------------------------------------------------------
src/fauxton/Gruntfile.js | 413 -
src/fauxton/TODO.md | 26 -
.../activetasks/assets/less/activetasks.less | 4 -
src/fauxton/app/addons/activetasks/base.js | 26 -
src/fauxton/app/addons/activetasks/resources.js | 108 -
src/fauxton/app/addons/activetasks/routes.js | 52 -
.../addons/activetasks/templates/detail.html | 21 -
.../app/addons/activetasks/templates/table.html | 52 -
.../activetasks/templates/tabledetail.html | 36 -
.../app/addons/activetasks/templates/tabs.html | 28 -
src/fauxton/app/addons/activetasks/views.js | 165 -
src/fauxton/app/addons/auth/base.js | 58 -
src/fauxton/app/addons/auth/resources.js | 404 -
src/fauxton/app/addons/auth/routes.js | 22 -
.../auth/templates/change_password_modal.html | 35 -
.../auth/templates/create_admin_modal.html | 46 -
.../app/addons/auth/templates/login_modal.html | 35 -
.../app/addons/auth/templates/nav_dropdown.html | 26 -
.../app/addons/auth/templates/nav_link.html | 19 -
.../addons/auth/templates/nav_link_title.html | 24 -
.../app/addons/auth/templates/noAccess.html | 19 -
src/fauxton/app/addons/config/base.js | 28 -
src/fauxton/app/addons/config/resources.js | 175 -
src/fauxton/app/addons/config/routes.js | 59 -
.../app/addons/config/templates/dashboard.html | 52 -
.../app/addons/config/templates/item.html | 31 -
src/fauxton/app/addons/contribute/base.js | 33 -
src/fauxton/app/addons/exampleAuth/base.js | 59 -
.../addons/exampleAuth/templates/noAccess.html | 19 -
src/fauxton/app/addons/logs/base.js | 28 -
src/fauxton/app/addons/logs/resources.js | 223 -
src/fauxton/app/addons/logs/routes.js | 58 -
.../app/addons/logs/templates/dashboard.html | 46 -
.../app/addons/logs/templates/filterItem.html | 16 -
.../app/addons/logs/templates/sidebar.html | 27 -
src/fauxton/app/addons/logs/tests/logSpec.js | 38 -
.../app/addons/stats/assets/less/stats.less | 20 -
src/fauxton/app/addons/stats/base.js | 26 -
src/fauxton/app/addons/stats/resources.js | 37 -
src/fauxton/app/addons/stats/routes.js | 56 -
.../app/addons/stats/templates/by_method.html | 16 -
.../app/addons/stats/templates/pie_table.html | 56 -
.../app/addons/stats/templates/stats.html | 16 -
.../app/addons/stats/templates/statselect.html | 22 -
src/fauxton/app/addons/stats/views.js | 171 -
src/fauxton/app/api.js | 390 -
src/fauxton/app/app.js | 75 -
src/fauxton/app/config.js | 56 -
src/fauxton/app/helpers.js | 54 -
src/fauxton/app/initialize.js | 66 -
src/fauxton/app/load_addons.js.underscore | 27 -
src/fauxton/app/main.js | 38 -
src/fauxton/app/modules/databases/base.js | 36 -
src/fauxton/app/modules/databases/resources.js | 148 -
src/fauxton/app/modules/databases/routes.js | 84 -
src/fauxton/app/modules/databases/views.js | 190 -
src/fauxton/app/modules/documents/base.js | 24 -
src/fauxton/app/modules/documents/resources.js | 435 -
src/fauxton/app/modules/documents/routes.js | 367 -
src/fauxton/app/modules/documents/views.js | 1399 --
src/fauxton/app/modules/fauxton/base.js | 191 -
src/fauxton/app/modules/fauxton/layout.js | 96 -
src/fauxton/app/modules/pouchdb/base.js | 60 -
.../app/modules/pouchdb/pouch.collate.js | 115 -
.../app/modules/pouchdb/pouchdb.mapreduce.js | 324 -
src/fauxton/app/router.js | 147 -
src/fauxton/app/templates/databases/item.html | 20 -
src/fauxton/app/templates/databases/list.html | 30 -
.../app/templates/databases/sidebar.html | 31 -
.../app/templates/documents/all_docs_item.html | 26 -
.../app/templates/documents/all_docs_list.html | 59 -
.../app/templates/documents/changes.html | 38 -
.../app/templates/documents/ddoc_info.html | 21 -
src/fauxton/app/templates/documents/doc.html | 41 -
.../templates/documents/doc_field_editor.html | 74 -
.../documents/doc_field_editor_tabs.html | 30 -
.../documents/duplicate_doc_modal.html | 36 -
.../templates/documents/index_menu_item.html | 17 -
.../templates/documents/index_row_docular.html | 26 -
.../templates/documents/index_row_tabular.html | 25 -
src/fauxton/app/templates/documents/search.html | 15 -
.../app/templates/documents/sidebar.html | 41 -
src/fauxton/app/templates/documents/tabs.html | 39 -
.../app/templates/documents/upload_modal.html | 42 -
.../app/templates/documents/view_editor.html | 195 -
src/fauxton/app/templates/fauxton/api_bar.html | 30 -
.../app/templates/fauxton/breadcrumbs.html | 24 -
src/fauxton/app/templates/fauxton/footer.html | 15 -
src/fauxton/app/templates/fauxton/nav_bar.html | 35 -
.../app/templates/fauxton/notification.html | 18 -
.../app/templates/fauxton/pagination.html | 31 -
src/fauxton/app/templates/layouts/one_pane.html | 28 -
src/fauxton/app/templates/layouts/two_pane.html | 29 -
.../templates/layouts/with_right_sidebar.html | 27 -
.../app/templates/layouts/with_sidebar.html | 27 -
.../app/templates/layouts/with_tabs.html | 27 -
.../templates/layouts/with_tabs_sidebar.html | 31 -
src/fauxton/assets/css/codemirror.css | 169 -
src/fauxton/assets/css/nv.d3.css | 656 -
src/fauxton/assets/img/couchdblogo.png | Bin 2738 -> 0 bytes
.../assets/img/glyphicons-halflings-white.png | Bin 8777 -> 0 bytes
src/fauxton/assets/img/glyphicons-halflings.png | Bin 13826 -> 0 bytes
src/fauxton/assets/img/loader.gif | Bin 5193 -> 0 bytes
src/fauxton/assets/index.underscore | 54 -
src/fauxton/assets/js/libs/almond.js | 314 -
src/fauxton/assets/js/libs/backbone.js | 1571 --
src/fauxton/assets/js/libs/bootstrap.js | 2025 ---
src/fauxton/assets/js/libs/codemirror.js | 3231 ----
src/fauxton/assets/js/libs/d3.js | 7026 ---------
src/fauxton/assets/js/libs/jquery.js | 9597 ------------
src/fauxton/assets/js/libs/jshint.js | 4529 ------
src/fauxton/assets/js/libs/lodash.js | 4355 ------
src/fauxton/assets/js/libs/nv.d3.js | 13048 -----------------
src/fauxton/assets/js/libs/require.js | 2045 ---
.../assets/js/plugins/backbone.layoutmanager.js | 875 --
.../assets/js/plugins/codemirror-javascript.js | 361 -
src/fauxton/assets/js/plugins/jquery.form.js | 1190 --
src/fauxton/assets/js/plugins/prettify.js | 28 -
.../assets/less/bootstrap/accordion.less | 34 -
src/fauxton/assets/less/bootstrap/alerts.less | 65 -
.../assets/less/bootstrap/bootstrap.less | 63 -
.../assets/less/bootstrap/breadcrumbs.less | 24 -
.../assets/less/bootstrap/button-groups.less | 242 -
src/fauxton/assets/less/bootstrap/buttons.less | 232 -
src/fauxton/assets/less/bootstrap/carousel.less | 131 -
src/fauxton/assets/less/bootstrap/close.less | 31 -
src/fauxton/assets/less/bootstrap/code.less | 58 -
.../less/bootstrap/component-animations.less | 22 -
.../assets/less/bootstrap/dropdowns.less | 237 -
src/fauxton/assets/less/bootstrap/forms.less | 683 -
src/fauxton/assets/less/bootstrap/grid.less | 21 -
.../assets/less/bootstrap/hero-unit.less | 25 -
.../assets/less/bootstrap/labels-badges.less | 74 -
src/fauxton/assets/less/bootstrap/layouts.less | 16 -
src/fauxton/assets/less/bootstrap/media.less | 55 -
src/fauxton/assets/less/bootstrap/mixins.less | 686 -
src/fauxton/assets/less/bootstrap/modals.less | 94 -
src/fauxton/assets/less/bootstrap/navbar.less | 475 -
src/fauxton/assets/less/bootstrap/navs.less | 385 -
src/fauxton/assets/less/bootstrap/pager.less | 41 -
.../assets/less/bootstrap/pagination.less | 121 -
src/fauxton/assets/less/bootstrap/popovers.less | 117 -
.../assets/less/bootstrap/progress-bars.less | 122 -
src/fauxton/assets/less/bootstrap/reset.less | 138 -
.../less/bootstrap/responsive-1200px-min.less | 28 -
.../less/bootstrap/responsive-767px-max.less | 193 -
.../less/bootstrap/responsive-768px-979px.less | 19 -
.../less/bootstrap/responsive-navbar.less | 185 -
.../less/bootstrap/responsive-utilities.less | 43 -
.../assets/less/bootstrap/responsive.less | 48 -
.../assets/less/bootstrap/scaffolding.less | 52 -
src/fauxton/assets/less/bootstrap/sprites.less | 193 -
src/fauxton/assets/less/bootstrap/tables.less | 236 -
.../assets/less/bootstrap/thumbnails.less | 52 -
src/fauxton/assets/less/bootstrap/tooltip.less | 70 -
src/fauxton/assets/less/bootstrap/type.less | 227 -
.../assets/less/bootstrap/utilities.less | 30 -
.../assets/less/bootstrap/variables.less | 301 -
src/fauxton/assets/less/bootstrap/wells.less | 29 -
src/fauxton/assets/less/config.less | 46 -
src/fauxton/assets/less/couchdb.less | 72 -
src/fauxton/assets/less/database.less | 174 -
src/fauxton/assets/less/fauxton.less | 102 -
src/fauxton/assets/less/logs.less | 24 -
src/fauxton/assets/less/prettyprint.less | 38 -
src/fauxton/bin/grunt | 18 -
src/fauxton/couchapp.js | 27 -
src/fauxton/favicon.ico | Bin 1150 -> 0 bytes
src/fauxton/index.html | 53 -
src/fauxton/package.json | 48 -
src/fauxton/readme.md | 69 -
src/fauxton/settings.json.default | 40 -
src/fauxton/settings.json.sample_external | 10 -
src/fauxton/tasks/addon/rename.json | 5 -
src/fauxton/tasks/addon/root/base.js.underscore | 21 -
.../tasks/addon/root/resources.js.underscore | 21 -
.../tasks/addon/root/route.js.underscore | 21 -
src/fauxton/tasks/addon/template.js | 70 -
src/fauxton/tasks/couchserver.js | 102 -
src/fauxton/tasks/fauxton.js | 117 -
src/fauxton/tasks/helper.js | 45 -
src/fauxton/test/core/routeObjectSpec.js | 91 -
src/fauxton/test/mocha/chai.js | 4330 ------
src/fauxton/test/mocha/mocha.css | 251 -
src/fauxton/test/mocha/mocha.js | 5428 -------
src/fauxton/test/mocha/sinon-chai.js | 109 -
src/fauxton/test/mocha/sinon.js | 4290 ------
src/fauxton/test/mocha/testUtils.js | 25 -
src/fauxton/test/runner.html | 17 -
src/fauxton/test/test.config.js | 71 -
src/fauxton/test/test.config.underscore | 15 -
src/fauxton/writing_addons.md | 163 -
192 files changed, 81266 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/Gruntfile.js
----------------------------------------------------------------------
diff --git a/src/fauxton/Gruntfile.js b/src/fauxton/Gruntfile.js
deleted file mode 100644
index a0c2232..0000000
--- a/src/fauxton/Gruntfile.js
+++ /dev/null
@@ -1,413 +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 is the main application configuration file. It is a Grunt
-// configuration file, which you can learn more about here:
-// https://github.com/cowboy/grunt/blob/master/docs/configuring.md
-
-module.exports = function(grunt) {
- var helper = require('./tasks/helper').init(grunt),
- _ = grunt.util._,
- path = require('path');
-
- var couch_config = function () {
-
- var default_couch_config = {
- fauxton: {
- db: 'http://localhost:5984/fauxton',
- app: './couchapp.js',
- options: {
- okay_if_missing: true
- }
- }
- };
-
- var settings_couch_config = helper.readSettingsFile().couch_config;
- return settings_couch_config || default_couch_config;
- }();
-
- var cleanableAddons = function () {
- var theListToClean = [];
- helper.processAddons(function(addon){
- // Only clean addons that are included from a local dir
- if (addon.path){
- theListToClean.push("app/addons/" + addon.name);
- }
- });
-
- return theListToClean;
- }();
-
- var cleanable = function(){
- // Whitelist files and directories to be cleaned
- // You'll always want to clean these two directories
- // Now find the external addons you have and add them for cleaning up
- return _.union(["dist/", "app/load_addons.js"], cleanableAddons);
- }();
-
- var assets = function(){
- // Base assets
- var theAssets = {
- less:{
- paths: ["assets/less"],
- files: {
- "dist/debug/css/fauxton.css": "assets/less/fauxton.less"
- }
- },
- img: ["assets/img/**"]
- };
- helper.processAddons(function(addon){
- // Less files from addons
- var root = addon.path || "app/addons/" + addon.name;
- var lessPath = root + "/assets/less";
- if(path.existsSync(lessPath)){
- // .less files exist for this addon
- theAssets.less.paths.push(lessPath);
- theAssets.less.files["dist/debug/css/" + addon.name + ".css"] =
- lessPath + "/" + addon.name + ".less";
- }
- // Images
- root = addon.path || "app/addons/" + addon.name;
- var imgPath = root + "/assets/img";
- if(path.existsSync(imgPath)){
- theAssets.img.push(imgPath + "/**");
- }
- });
- return theAssets;
- }();
-
- var templateSettings = function(){
- var defaultSettings = {
- "development": {
- "src": "assets/index.underscore",
- "dest": "dist/debug/index.html",
- "variables": {
- "requirejs": "/assets/js/libs/require.js",
- "css": "./css/index.css",
- "base": null
- }
- },
- "release": {
- "src": "assets/index.underscore",
- "dest": "dist/debug/index.html",
- "variables": {
- "requirejs": "./js/require.js",
- "css": "./css/index.css",
- "base": null
- }
- }
- };
-
- var settings = helper.readSettingsFile();
- return settings.template || defaultSettings;
- }();
-
- grunt.initConfig({
-
- // The clean task ensures all files are removed from the dist/ directory so
- // that no files linger from previous builds.
- clean: {
- release: cleanable,
- watch: cleanableAddons
- },
-
- // The lint task will run the build configuration and the application
- // JavaScript through JSHint and report any errors. You can change the
- // options for this task, by reading this:
- // https://github.com/cowboy/grunt/blob/master/docs/task_lint.md
- lint: {
- files: [
- "build/config.js", "app/**/*.js"
- ]
- },
-
- less: {
- compile: {
- options: {
- paths: assets.less.paths
- },
- files: assets.less.files
- }
- },
-
- // The jshint option for scripturl is set to lax, because the anchor
- // override inside main.js needs to test for them so as to not accidentally
- // route.
- jshint: {
- all: ['app/**/*.js', 'Gruntfile.js', "test/core/*.js"],
- options: {
- scripturl: true,
- evil: true
- }
- },
-
- // The jst task compiles all application templates into JavaScript
- // functions with the underscore.js template function from 1.2.4. You can
- // change the namespace and the template options, by reading this:
- // https://github.com/gruntjs/grunt-contrib/blob/master/docs/jst.md
- //
- // The concat task depends on this file to exist, so if you decide to
- // remove this, ensure concat is updated accordingly.
- jst: {
- "dist/debug/templates.js": [
- "app/templates/**/*.html",
- "app/addons/**/templates/**/*.html"
- ]
- },
-
- template: templateSettings,
-
- // The concatenate task is used here to merge the almond require/define
- // shim and the templates into the application code. It's named
- // dist/debug/require.js, because we want to only load one script file in
- // index.html.
- concat: {
- requirejs: {
- src: [ "assets/js/libs/require.js", "dist/debug/templates.js", "dist/debug/require.js"],
- dest: "dist/debug/js/require.js"
- },
-
- index_css: {
- src: ["dist/debug/css/*.css", 'assets/css/*.css'],
- dest: 'dist/debug/css/index.css'
- }
-
- },
-
- cssmin: {
- compress: {
- files: {
- "dist/release/css/index.css": [
- "dist/debug/css/index.css", 'assets/css/*.css',
- "app/addons/**/assets/css/*.css"
- ]
- },
- options: {
- report: 'min'
- }
- }
- },
-
- uglify: {
- release: {
- files: {
- "dist/release/js/require.js": [
- "dist/debug/js/require.js"
- ]
- }
- }
- },
-
- // Runs a proxy server for easier development, no need to keep deploying to couchdb
- couchserver: {
- dist: './dist/debug/',
- port: 8000,
- proxy: {
- target: {
- host: 'localhost',
- port: 5984,
- https: false
- },
- // This sets the Host header in the proxy so that you can use external
- // CouchDB instances and not have the Host set to 'localhost'
- changeOrigin: true
- }
- },
-
- watch: {
- js: {
- files: helper.watchFiles(['.js'], ["./app/**/*.js", '!./app/load_addons.js',"./assets/**/*.js", "./test/**/*.js"]),
- tasks: ['watchRun'],
- },
- style: {
- files: helper.watchFiles(['.less','.css'],["./app/**/*.css","./app/**/*.less","./assets/**/*.css", "./assets/**/*.less"]),
- tasks: ['less', 'concat:index_css'],
- },
- options: {
- nospawn: true,
- }
- },
-
- requirejs: {
- compile: {
- options: {
- baseUrl: 'app',
- // Include the main configuration file.
- mainConfigFile: "app/config.js",
-
- // Output file.
- out: "dist/debug/require.js",
-
- // Root application module.
- name: "config",
-
- // Do not wrap everything in an IIFE.
- wrap: false,
- optimize: "none",
- }
- }
- },
-
- // Copy build artifacts and library code into the distribution
- // see - http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically
- copy: {
- couchdb: {
- files: [
- // this gets built in the template task
- {src: "dist/release/index.html", dest: "../../share/www/fauxton/index.html"},
- {src: ["**"], dest: "../../share/www/fauxton/js/", cwd:'dist/release/js/', expand: true},
- {src: ["**"], dest: "../../share/www/fauxton/img/", cwd:'dist/release/img/', expand: true},
- {src: ["**"], dest: "../../share/www/fauxton/css/", cwd:"dist/release/css/", expand: true}
- ]
- },
- couchdebug: {
- files: [
- // this gets built in the template task
- {src: "dist/debug/index.html", dest: "../../share/www/fauxton/index.html"},
- {src: ["**"], dest: "../../share/www/fauxton/js/", cwd:'dist/debug/js/', expand: true},
- {src: ["**"], dest: "../../share/www/fauxton/img/", cwd:'dist/debug/img/', expand: true},
- {src: ["**"], dest: "../../share/www/fauxton/css/", cwd:"dist/debug/css/", expand: true}
- ]
- },
- dist:{
- files:[
- {src: "dist/debug/index.html", dest: "dist/release/index.html"},
- {src: assets.img, dest: "dist/release/img/", flatten: true, expand: true}
- ]
- },
- debug:{
- files:[
- {src: assets.img, dest: "dist/debug/img/", flatten: true, expand: true}
- ]
- }
- },
-
- get_deps: {
- "default": {
- src: "settings.json"
- }
- },
-
- gen_load_addons: {
- "default": {
- src: "settings.json"
- }
- },
-
- mkcouchdb: couch_config,
- rmcouchdb: couch_config,
- couchapp: couch_config,
-
- mochaSetup: {
- default: {
- files: { src: helper.watchFiles(['[Ss]pec.js'], ['./test/core/**/*[Ss]pec.js', './app/**/*[Ss]pec.js'])},
- template: 'test/test.config.underscore',
- config: './app/config.js'
- }
- },
-
- mocha_phantomjs: {
- all: ['test/runner.html']
- }
-
- });
-
- // on watch events configure jshint:all to only run on changed file
- grunt.event.on('watch', function(action, filepath) {
- if (!!filepath.match(/.js$/)) {
- grunt.config(['jshint', 'all'], filepath);
- }
-
- console.log(filepath);
- if (!!filepath.match(/[Ss]pec.js$/)) {
- grunt.task.run(['mochaSetup','mocha_phantomjs']);
- }
- });
-
- /*
- * Load Grunt plugins
- */
- // Load fauxton specific tasks
- grunt.loadTasks('tasks');
- // Load the couchapp task
- grunt.loadNpmTasks('grunt-couchapp');
- // Load the copy task
- grunt.loadNpmTasks('grunt-contrib-watch');
- // Load the exec task
- grunt.loadNpmTasks('grunt-exec');
- // Load Require.js task
- grunt.loadNpmTasks('grunt-contrib-requirejs');
- // Load Copy task
- grunt.loadNpmTasks('grunt-contrib-copy');
- // Load Clean task
- grunt.loadNpmTasks('grunt-contrib-clean');
- // Load jshint task
- grunt.loadNpmTasks('grunt-contrib-jshint');
- // Load jst task
- grunt.loadNpmTasks('grunt-contrib-jst');
- // Load less task
- grunt.loadNpmTasks('grunt-contrib-less');
- // Load concat task
- grunt.loadNpmTasks('grunt-contrib-concat');
- // Load UglifyJS task
- grunt.loadNpmTasks('grunt-contrib-uglify');
- // Load CSSMin task
- grunt.loadNpmTasks('grunt-contrib-cssmin');
- grunt.loadNpmTasks('grunt-mocha-phantomjs');
-
- /*
- * Default task
- */
- // defult task - install minified app to local CouchDB
- grunt.registerTask('default', 'couchdb');
-
- /*
- * Transformation tasks
- */
- // clean out previous build artefactsa and lint
- grunt.registerTask('lint', ['clean', 'jshint']);
- grunt.registerTask('test', ['lint', 'mochaSetup', 'mocha_phantomjs']);
- // Fetch dependencies (from git or local dir), lint them and make load_addons
- grunt.registerTask('dependencies', ['get_deps', 'jshint', 'gen_load_addons:default']);
- // build templates, js and css
- grunt.registerTask('build', ['less', 'concat:index_css', 'jst', 'requirejs', 'concat:requirejs', 'template:release']);
- // minify code and css, ready for release.
- grunt.registerTask('minify', ['uglify', 'cssmin:compress']);
-
- /*
- * Build the app in either dev, debug, or release mode
- */
- // dev server
- grunt.registerTask('dev', ['debugDev', 'couchserver']);
- // build a debug release
- grunt.registerTask('debug', ['lint', 'dependencies', 'concat:requirejs','less', 'concat:index_css', 'template:development', 'copy:debug']);
- grunt.registerTask('debugDev', ['lint', 'dependencies', 'less', 'concat:index_css', 'template:development', 'copy:debug']);
-
- grunt.registerTask('watchRun', ['clean:watch', 'dependencies']);
- // build a release
- grunt.registerTask('release', ['lint' ,'dependencies', 'build', 'minify', 'copy:dist']);
-
- /*
- * Install into CouchDB in either debug, release, or couchapp mode
- */
- // make a development install that is server by mochiweb under _utils
- grunt.registerTask('couchdebug', ['debug', 'copy:couchdebug']);
- // make a minimized install that is server by mochiweb under _utils
- grunt.registerTask('couchdb', ['release', 'copy:couchdb']);
- // make an install that can be deployed as a couchapp
- grunt.registerTask('couchapp_setup', ['release']);
- // install fauxton as couchapp
- grunt.registerTask('couchapp_install', ['rmcouchdb:fauxton', 'mkcouchdb:fauxton', 'couchapp:fauxton']);
- // setup and install fauxton as couchapp
- grunt.registerTask('couchapp_deploy', ['couchapp_setup', 'couchapp_install']);
-};
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/TODO.md
----------------------------------------------------------------------
diff --git a/src/fauxton/TODO.md b/src/fauxton/TODO.md
deleted file mode 100644
index b929e05..0000000
--- a/src/fauxton/TODO.md
+++ /dev/null
@@ -1,26 +0,0 @@
-# Fauxton todo
-In no particular order
-
-- [ ] docco docs
-- [ ] user management
-- [ ] view options
-- [ ] view editor
-- [ ] visual view builder
-- [ ] new db as modal
-- [ ] new view button
-- [ ] show design docs only
-- [ ] fix delete doc button UI bug
-- [ ] delete multiple docs via _bulk_docs
-- [x] show change events in database view
-- [ ] pouchdb addon
-- [ ] bespoke bootstrap style
-- [ ] responsive interface
-- [ ] sticky subnav for some UI components on _all_docs
-- [ ] "show me" button in API bar doesn't
-- [ ] edit index button doesn't
-- [ ] replicate UI
-- [x] delete database
-- [x] format dates better (e.g. in logs plugin)
-- [ ] format log entry better
-- [ ] filter logs by method
-- [ ] restore unfiltered data in logs UI
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/activetasks/assets/less/activetasks.less
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/activetasks/assets/less/activetasks.less b/src/fauxton/app/addons/activetasks/assets/less/activetasks.less
deleted file mode 100644
index 5cb9d47..0000000
--- a/src/fauxton/app/addons/activetasks/assets/less/activetasks.less
+++ /dev/null
@@ -1,4 +0,0 @@
-.task-tabs li {
- cursor: pointer;
- padding: 5px 0;
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/activetasks/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/activetasks/base.js b/src/fauxton/app/addons/activetasks/base.js
deleted file mode 100644
index c7b8fb0..0000000
--- a/src/fauxton/app/addons/activetasks/base.js
+++ /dev/null
@@ -1,26 +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.
-
-define([
- "app",
- "api",
- "addons/activetasks/routes"
-],
-
-function (app, FauxtonAPI, Activetasks) {
-
- Activetasks.initialize = function() {
- FauxtonAPI.addHeaderLink({title: "Active Tasks", href: "#/activetasks"});
- };
-
- return Activetasks;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/activetasks/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/activetasks/resources.js b/src/fauxton/app/addons/activetasks/resources.js
deleted file mode 100644
index 6d892dd..0000000
--- a/src/fauxton/app/addons/activetasks/resources.js
+++ /dev/null
@@ -1,108 +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.
-
-define([
- "app",
- "backbone",
- "modules/fauxton/base",
- "d3"
-],
-
-function (app, backbone, Fauxton) {
- var Active = {},
- apiv = app.versionAPI;
- app.taskSortBy = 'type';
-
- Active.Task = Backbone.Model.extend({
- initialize: function() {
- this.set({"id": this.get('pid')});
- }
- });
-
-// ALL THE TASKS
- Active.Tasks = Backbone.Model.extend({
- alltypes: {
- "all": "All tasks",
- "replication": "Replication",
- "database_compaction":" Database Compaction",
- "indexer": "Indexer",
- "view_compaction": "View Compaction"
- },
- url: function () {
- return app.host + '/_active_tasks';
- },
- parse: function(resp){
- var types = this.getUniqueTypes(resp),
- that = this;
-
- var typeCollections = _.reduce(types, function (collection, val, key) {
- collection[key] = new Active.AllTasks(that.sortThis(resp, key));
- return collection;
- }, {});
-
- typeCollections.all = new Active.AllTasks(resp);
-
- this.set(typeCollections); //now set them all to the model
- },
- getUniqueTypes: function(resp){
- var types = this.alltypes;
-
- _.each(resp, function(type){
- if( typeof(types[type.type]) === "undefined"){
- types[type.type] = type.type.replace(/_/g,' ');
- }
- },this);
-
- this.alltypes = types;
- return types;
- },
- sortThis: function(resp, type){
- return _.filter(resp, function(item) { return item.type === type; });
- },
- changeView: function (view){
- this.set({
- "currentView": view
- });
- },
- getCurrentViewData: function(){
- var currentView = this.get('currentView');
- return this.get(currentView);
- },
- getDatabaseCompactions: function(){
- return this.get('databaseCompactions');
- },
- getIndexes: function(){
- return this.get('indexes');
- },
- getViewCompactions: function(){
- return this.get('viewCompactions');
- }
- });
-
-//ALL TASKS
-
-//NEW IDEA. Lets make this extremely generic, so if there are new weird tasks, they get sorted and collected.
-
- Active.AllTasks = Backbone.Collection.extend({
- model: Active.Task,
- sortByColumn: function(colName) {
- app.taskSortBy = colName;
- this.sort();
- },
- comparator: function(item) {
- return item.get(app.taskSortBy);
- }
- });
-
-
- return Active;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/activetasks/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/activetasks/routes.js b/src/fauxton/app/addons/activetasks/routes.js
deleted file mode 100644
index 027beee..0000000
--- a/src/fauxton/app/addons/activetasks/routes.js
+++ /dev/null
@@ -1,52 +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.
-
-define([
- "app",
- "api",
- "addons/activetasks/resources",
- "addons/activetasks/views"
-],
-
-function (app, FauxtonAPI, Activetasks, Views) {
-
- var ActiveTasksRouteObject = FauxtonAPI.RouteObject.extend({
- layout: "with_sidebar",
- routes: {
- "activetasks/:id": "defaultView",
- "activetasks": "defaultView"
- },
- crumbs: [],
- apiUrl: function(){
- return app.host+"/_active_tasks";
- },
- defaultView: function(id){
- var newtasks = new Activetasks.Tasks({
- currentView: "all",
- id:'activeTasks'
- });
- this.setView("#sidebar-content", new Views.TabMenu({
- currentView: "all",
- model: newtasks
- }));
-
- this.setView("#dashboard-content", new Views.DataSection({
- model: newtasks,
- currentView: "all"
- }));
- }
- });
-
- Activetasks.RouteObjects = [ActiveTasksRouteObject];
-
- return Activetasks;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/activetasks/templates/detail.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/activetasks/templates/detail.html b/src/fauxton/app/addons/activetasks/templates/detail.html
deleted file mode 100644
index 5e53129..0000000
--- a/src/fauxton/app/addons/activetasks/templates/detail.html
+++ /dev/null
@@ -1,21 +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.
--->
-
-<div class="progress progress-striped active">
- <div class="bar" style="width: <%=model.get("progress")%>%;"><%=model.get("progress")%>%</div>
-</div>
-<p>
- <%= model.get("type").replace('_',' ')%> on
- <%= model.get("node")%>
-</p>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/activetasks/templates/table.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/activetasks/templates/table.html b/src/fauxton/app/addons/activetasks/templates/table.html
deleted file mode 100644
index ee88e75..0000000
--- a/src/fauxton/app/addons/activetasks/templates/table.html
+++ /dev/null
@@ -1,52 +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.
--->
-
-<!--
-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.
--->
-
-<% if (collection.length === 0){%>
- <tr>
- <td>
- <p>There are no active tasks for <%=currentView%> right now.</p>
- </td>
- </tr>
-<%}else{%>
-
- <thead>
- <tr>
- <th data-type="type">Type</th>
- <th data-type="node">Object</th>
- <th data-type="started_on">Started on</th>
- <th data-type="updated_on">Last updated on</th>
- <th data-type="pid">PID</th>
- <th data-type="progress" width="200">Status</th>
- </tr>
- </thead>
-
- <tbody id="tasks_go_here">
-
- </tbody>
-
-<% } %>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/activetasks/templates/tabledetail.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/activetasks/templates/tabledetail.html b/src/fauxton/app/addons/activetasks/templates/tabledetail.html
deleted file mode 100644
index 67c0dc8..0000000
--- a/src/fauxton/app/addons/activetasks/templates/tabledetail.html
+++ /dev/null
@@ -1,36 +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.
--->
-
-<td>
- <%= model.get("type")%>
-</td>
-<td>
- <%= objectField %>
-</td>
-<td>
- <%= formatDate(model.get("started_on")) %>
-</td>
-<td>
- <%= formatDate(model.get("updated_on")) %>
-</td>
-<td>
- <%= model.get("pid")%>
-</td>
-<td>
- <div class="progress progress-striped active">
- <div class="bar" style="width: <%=model.get("progress")%>%;"><%=model.get("progress")%>%</div>
-
- </div>
- <p><%=progress%> </p>
-</td>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/activetasks/templates/tabs.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/activetasks/templates/tabs.html b/src/fauxton/app/addons/activetasks/templates/tabs.html
deleted file mode 100644
index 47c5843..0000000
--- a/src/fauxton/app/addons/activetasks/templates/tabs.html
+++ /dev/null
@@ -1,28 +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.
--->
-
-<h3>Filter by: </h3>
-<ul class="task-tabs nav nav-tabs nav-stacked">
- <% for (var filter in filters) { %>
- <li data-type="<%=filter%>"><%=filters[filter]%></li>
- <% } %>
-</ul>
-
-<h4>Polling interval</h4>
-<input id="pollingRange" type="range"
- min="1"
- max="30"
- step="1"
- value="5"/>
-<label for="pollingRange"><span>5</span> second(s)</label>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/activetasks/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/activetasks/views.js b/src/fauxton/app/addons/activetasks/views.js
deleted file mode 100644
index f38aea2..0000000
--- a/src/fauxton/app/addons/activetasks/views.js
+++ /dev/null
@@ -1,165 +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.
-
-define([
- "app",
- "api",
- "addons/activetasks/resources"
-],
-
-function (app, FauxtonAPI, activetasks) {
-
- var Views = {},
- Events = {},
- pollingInfo ={
- rate: "5",
- intervalId: null
- };
-
-
- _.extend(Events, Backbone.Events);
-
- Views.TabMenu = FauxtonAPI.View.extend({
- template: "addons/activetasks/templates/tabs",
- events: {
- "click .task-tabs li": "requestByType",
- "change #pollingRange": "changePollInterval"
- },
- establish: function(){
- return [this.model.fetch({reset: true})];
- },
- serialize: function(){
- return {
- filters: this.model.alltypes
- };
- },
- afterRender: function(){
- $('.task-tabs').find('li').eq(0).addClass('active');
- },
- changePollInterval: function(e){
- var range = $(e.currentTarget).val();
- $('label[for="pollingRange"] span').text(range);
- pollingInfo.rate = range;
- clearInterval(pollingInfo.intervalId);
- Events.trigger('update:poll');
- },
- requestByType: function(e){
- var currentTarget = e.currentTarget;
- datatype = $(currentTarget).attr("data-type");
-
- $('.task-tabs').find('li').removeClass('active');
- $(currentTarget).addClass('active');
- this.model.changeView(datatype);
- }
- });
-
- Views.DataSection = FauxtonAPI.View.extend({
- initialize: function(){
- this.listenToOnce(this.model, "change", this.showData); //check why I needed to do this
- },
- showData: function(){
- var that = this,
- currentData = this.model.getCurrentViewData();
- //remove the old stuff in a nice clean way
- if (this.dataView) {
- this.dataView.remove();
- }
-
- //add the new stuff
- this.dataView = that.insertView( new Views.tableData({
- collection: currentData,
- currentView: this.model.get('currentView').replace('_',' ')
- }));
-
- this.dataView.render();
- },
- establish: function(){
- return [this.model.fetch()];
- },
- setPolling: function(){
- var that = this;
- pollingInfo.intervalId = setInterval(function() {
- that.establish();
- }, pollingInfo.rate*1000);
- },
- afterRender: function(){
- this.listenTo(this.model, "change", this.showData);
- Events.bind('update:poll', this.setPolling, this);
- this.setPolling();
- }
- });
-
- Views.tableData = FauxtonAPI.View.extend({
- tagName: "table",
- className: "table table-bordered table-striped active-tasks",
- template: "addons/activetasks/templates/table",
- events: {
- "click th": "sortByType"
- },
- initialize: function(){
- currentView = this.options.currentView;
- },
- sortByType: function(e){
- var currentTarget = e.currentTarget;
- datatype = $(currentTarget).attr("data-type");
- this.collection.sortByColumn(datatype);
- this.render();
- },
- serialize: function(){
- return {
- currentView: currentView,
- collection: this.collection
- };
- },
- beforeRender: function(){
- //iterate over the collection to add each
- this.collection.forEach(function(item) {
- this.insertView("#tasks_go_here", new Views.TableDetail({
- model: item
- }));
- }, this);
- }
- });
-
- Views.TableDetail = FauxtonAPI.View.extend({
- tagName: 'tr',
- template: "addons/activetasks/templates/tabledetail",
- initialize: function(){
- this.type = this.model.get('type');
- },
- getObject: function(){
- var objectField = this.model.get('database');
- if (this.type === "replication"){
- objectField = this.model.get('source') + " to " + this.model.get('target');
- }
- return objectField;
- },
- getProgress: function(){
- var progress = "";
- if (this.type === "indexer"){
- progress = "Processed " +this.model.get('changes_done')+ " of "+this.model.get('total_changes')+ ' changes';
- }
- return progress;
- },
- serialize: function(){
- return {
- model: this.model,
- objectField: this.getObject(),
- progress: this.getProgress()
- };
- }
- });
-
-
-
- return Views;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/auth/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/auth/base.js b/src/fauxton/app/addons/auth/base.js
deleted file mode 100644
index acbbcd2..0000000
--- a/src/fauxton/app/addons/auth/base.js
+++ /dev/null
@@ -1,58 +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.
-
-define([
- "app",
- "api",
- "addons/auth/routes"
-],
-
-function(app, FauxtonAPI, Auth) {
-
- Auth.session = new Auth.Session();
- FauxtonAPI.setSession(Auth.session);
-
- Auth.initialize = function() {
- Auth.navLink = new Auth.NavLink({model: Auth.session});
-
- FauxtonAPI.addHeaderLink({
- title: "Auth",
- href: "#_auth",
- view: Auth.navLink,
- establish: [FauxtonAPI.session.fetchUser()]
- });
-
- var auth = function (session, roles) {
- var deferred = $.Deferred();
-
- if (session.isAdminParty()) {
- deferred.resolve();
- } else if(session.matchesRoles(roles)) {
- deferred.resolve();
- } else {
- deferred.reject();
- }
-
- return [deferred];
- };
-
- var authDenied = function () {
- app.masterLayout.setView('#dashboard', new Auth.NoAccessView());
- app.masterLayout.renderView('#dashboard');
- };
-
- FauxtonAPI.auth.registerAuth(auth);
- FauxtonAPI.auth.registerAuthDenied(authDenied);
- };
-
- return Auth;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/auth/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/auth/resources.js b/src/fauxton/app/addons/auth/resources.js
deleted file mode 100644
index 7118c70..0000000
--- a/src/fauxton/app/addons/auth/resources.js
+++ /dev/null
@@ -1,404 +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.
-
-define([
- "app",
- "api"
-],
-
-function (app, FauxtonAPI) {
-
- var Auth = new FauxtonAPI.addon();
-
- var Admin = Backbone.Model.extend({
-
- url: function () {
- return app.host + '/_config/admins/' + this.get("name");
- },
-
- isNew: function () { return false; },
-
- sync: function (method, model, options) {
-
- var params = {
- url: model.url(),
- contentType: 'application/json',
- dataType: 'json',
- data: JSON.stringify(model.get('value'))
- };
-
- if (method === 'delete') {
- params.type = 'DELETE';
- } else {
- params.type = 'PUT';
- }
-
- return $.ajax(params);
- }
- });
-
- Auth.Session = FauxtonAPI.Session.extend({
- url: '/_session',
-
- initialize: function (options) {
- if (!options) { options = {}; }
-
- this.messages = _.extend({}, {
- missingCredentials: 'Username or password cannot be blank.',
- passwordsNotMatch: 'Passwords do not match.'
- }, options.messages);
- },
-
- isAdminParty: function () {
- var userCtx = this.get('userCtx');
-
- if (!userCtx.name && userCtx.roles.indexOf("_admin") > -1) {
- return true;
- }
-
- return false;
- },
-
- userRoles: function () {
- var user = this.user();
-
- if (user && user.roles) {
- return user.roles;
- }
-
- return [];
- },
-
- matchesRoles: function (roles) {
- if (roles.length === 0) {
- return true;
- }
-
- var numberMatchingRoles = _.intersection(this.userRoles(), roles).length;
-
- if (numberMatchingRoles > 0) {
- return true;
- }
-
- return false;
- },
-
- validateUser: function (username, password, msg) {
- if (_.isEmpty(username) || _.isEmpty(password)) {
- var deferred = FauxtonAPI.Deferred();
-
- deferred.rejectWith(this, [msg]);
- return deferred;
- }
- },
-
- validatePasswords: function (password, password_confirm, msg) {
- if (_.isEmpty(password) || _.isEmpty(password_confirm) || (password !== password_confirm)) {
- var deferred = FauxtonAPI.Deferred();
-
- deferred.rejectWith(this, [msg]);
- return deferred;
- }
-
- },
-
- createAdmin: function (username, password, login) {
- var that = this,
- error_promise = this.validateUser(username, password, this.messages.missingCredentials);
-
- if (error_promise) { return error_promise; }
-
- var admin = new Admin({
- name: username,
- value: password
- });
-
- return admin.save().then(function () {
- if (login) {
- return that.login(username, password);
- } else {
- return that.fetchUser({forceFetch: true});
- }
- });
- },
-
- login: function (username, password) {
- var error_promise = this.validateUser(username, password, this.messages.missingCredentials);
-
- if (error_promise) { return error_promise; }
-
- var that = this;
-
- return $.ajax({
- type: "POST",
- url: "/_session",
- dataType: "json",
- data: {name: username, password: password}
- }).then(function () {
- return that.fetchUser({forceFetch: true});
- });
- },
-
- logout: function () {
- var that = this;
-
- return $.ajax({
- type: "DELETE",
- url: "/_session",
- dataType: "json",
- username : "_",
- password : "_"
- }).then(function () {
- return that.fetchUser({forceFetch: true });
- });
- },
-
- changePassword: function (password, password_confirm) {
- var error_promise = this.validatePasswords(password, password_confirm, this.messages.passwordsNotMatch);
-
- if (error_promise) { return error_promise; }
-
- var that = this,
- info = this.get('info'),
- userCtx = this.get('userCtx');
-
- var admin = new Admin({
- name: userCtx.name,
- value: password
- });
-
- return admin.save().then(function () {
- return that.login(userCtx.name, password);
- });
- }
- });
-
- Auth.ModalView = FauxtonAPI.View.extend({
-
- show_modal: function () {
- this.clear_error_msg();
- this.$('.modal').modal();
- // hack to get modal visible
- $('.modal-backdrop').css('z-index',1025);
- },
-
- hide_modal: function () {
- this.$('.modal').modal('hide');
- // force this removal as the navbar
- //$('.modal-backdrop').remove();
- },
-
- set_error_msg: function (msg) {
- var text;
- if (typeof(msg) == 'string') {
- text = msg;
- } else {
- text = JSON.parse(msg.responseText).reason;
- }
-
- this.$('#modal-error').text(text).removeClass('hide');
- },
-
- clear_error_msg: function () {
- this.$('#modal-error').text(' ').addClass('hide');
- }
-
- });
-
- Auth.CreateAdminModal = Auth.ModalView.extend({
- template: 'addons/auth/templates/create_admin_modal',
-
- initialize: function (options) {
- this.login_after = options.login_after || true;
- },
-
- events: {
- "click #create-admin": "createAdmin"
- },
-
- createAdmin: function (event) {
- event.preventDefault();
- this.clear_error_msg();
-
- var that = this,
- username = this.$('#username').val(),
- password = this.$('#password').val();
-
- var promise = this.model.createAdmin(username, password, this.login_after);
-
- promise.then(function () {
- that.$('.modal').modal('hide');
- that.hide_modal();
- });
-
- promise.fail(function (rsp) {
- that.set_error_msg(rsp);
- });
- }
-
- });
-
- Auth.LoginModal = Auth.ModalView.extend({
- template: 'addons/auth/templates/login_modal',
-
- events: {
- "click #login": "login"
- },
-
- login: function () {
- event.preventDefault();
- this.clear_error_msg();
-
- var that = this,
- username = this.$('#username').val(),
- password = this.$('#password').val(),
- promise = this.model.login(username, password);
-
- promise.then(function () {
- that.hide_modal();
- });
-
- promise.fail(function (rsp) {
- that.set_error_msg(rsp);
- });
- }
-
- });
-
- Auth.ChangePasswordModal = Auth.ModalView.extend({
- template: 'addons/auth/templates/change_password_modal',
-
- events: {
- "click #change-password": "changePassword"
- },
-
- changePassword: function () {
- event.preventDefault();
- this.clear_error_msg();
-
- var that = this,
- new_password = this.$('#password').val(),
- password_confirm = this.$('#password-confirm').val();
-
- var promise = this.model.changePassword(new_password, password_confirm);
-
- promise.done(function () {
- that.hide_modal();
- });
-
- promise.fail(function (rsp) {
- that.set_error_msg(rsp);
- });
- }
- });
-
- Auth.NavLinkTitle = FauxtonAPI.View.extend({
- template: 'addons/auth/templates/nav_link_title',
- tagName: 'a',
- attributes: {
- id: "user-drop",
- "class": "dropdown-toggle",
- role: "button",
- "data-toggle": "dropdown",
- href:"#"
- },
-
- beforeRender: function () {
- this.listenTo(this.model, 'change', this.render);
- },
-
- serialize: function () {
- return {
- admin_party: this.model.isAdminParty(),
- user: this.model.user()
- };
- }
- });
-
- Auth.NavDropDown = FauxtonAPI.View.extend({
- template: 'addons/auth/templates/nav_dropdown',
- tagName: 'ul',
- attributes: {
- "class": "dropdown-menu",
- role:"menu",
- "aria-labelledby":"user-drop"
- },
-
- beforeRender: function () {
- this.listenTo(this.model, 'change', this.render);
- },
-
- serialize: function () {
- return {
- admin_party: this.model.isAdminParty(),
- user: this.model.user()
- };
- }
- });
-
- Auth.NavLink = FauxtonAPI.View.extend({
- template: 'addons/auth/templates/nav_link',
-
- tagName: "li",
- className: "dropdown",
-
- events: {
- "click #user-create-admin": 'show_admin_modal',
- "click #user-create-more-admin": 'show_create_more_admin_modal',
- "click #user-login": 'show_login_modal',
- "click #user-change-password": 'show_change_password_modal',
- "click #user-logout": 'logout_user'
- },
-
- beforeRender: function () {
- this.nav_link_name = this.insertView(new Auth.NavLinkTitle({model: this.model}));
- this.nav_link_name = this.insertView(new Auth.NavDropDown({model: this.model}));
- this.create_admin_modal = this.setView('#user-create-admin-modal', new Auth.CreateAdminModal({model: this.model}));
- this.login_modal = this.setView('#login-modal', new Auth.LoginModal({model: this.model}));
- this.change_password_modal = this.setView('#change-password-modal', new Auth.ChangePasswordModal({model: this.model}));
- },
-
- show_admin_modal: function (event) {
- event.preventDefault();
- this.create_admin_modal.show_modal();
- },
-
- show_create_more_admin_modal: function (event) {
- event.preventDefault();
- this.create_admin_modal.login_after = false;
- this.create_admin_modal.show_modal();
- },
-
- show_login_modal: function (event) {
- event.preventDefault();
- this.login_modal.show_modal();
- },
-
- show_change_password_modal: function (event) {
- event.preventDefault();
- this.change_password_modal.show_modal();
- },
-
- logout_user: function () {
- event.preventDefault();
- this.model.logout();
- }
- });
-
- Auth.NoAccessView = FauxtonAPI.View.extend({
- template: "addons/auth/templates/noAccess"
-
- });
-
-
- return Auth;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/auth/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/auth/routes.js b/src/fauxton/app/addons/auth/routes.js
deleted file mode 100644
index 6ff7502..0000000
--- a/src/fauxton/app/addons/auth/routes.js
+++ /dev/null
@@ -1,22 +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.
-
-define([
- "app",
- "api",
- "addons/auth/resources"
-],
-
-function(app, FauxtonAPI, Auth) {
-
- return Auth;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/auth/templates/change_password_modal.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/auth/templates/change_password_modal.html b/src/fauxton/app/addons/auth/templates/change_password_modal.html
deleted file mode 100644
index 5e3db38..0000000
--- a/src/fauxton/app/addons/auth/templates/change_password_modal.html
+++ /dev/null
@@ -1,35 +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.
--->
-
-<div class="modal hide fade">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
- <h3>Change Password</h3>
- </div>
- <div class="modal-body">
- <div id="modal-error" class="hide alert alert-error"/>
- <form>
- <p class="help-block">
- Enter your new password.
- </p>
- <input id="password" type="password" name="password" placeholder= "New Password:" size="24">
- <br/>
- <input id="password-confirm" type="password" name="password_confirm" placeholder= "Verify New Password" size="24">
- </form>
- </div>
- <div class="modal-footer">
- <a href="#" data-dismiss="modal" class="btn">Cancel</a>
- <a href="#" id="change-password" class="btn btn-primary">Change</a>
- </div>
-</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/auth/templates/create_admin_modal.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/auth/templates/create_admin_modal.html b/src/fauxton/app/addons/auth/templates/create_admin_modal.html
deleted file mode 100644
index 0d16ca1..0000000
--- a/src/fauxton/app/addons/auth/templates/create_admin_modal.html
+++ /dev/null
@@ -1,46 +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.
--->
-
-<div class="modal hide fade">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
- <h3>Create Server Admin</h3>
- </div>
- <div class="modal-body">
- <div id="modal-error" class="hide alert alert-error"/>
- <form>
- <input id="username" type="text" name="name" placeholder= "Username:" size="24">
- <br/>
- <input id="password" type="password" name="password" placeholder= "Password" size="24">
- </form>
- <p class="help-block">
- Before a server admin is configured, all clients have admin privileges.
- This is fine when HTTP access is restricted
- to trusted users. <strong>If end-users will be accessing this CouchDB, you must
- create an admin account to prevent accidental (or malicious) data loss.</strong>
- </p>
- <p class="help-block">Server admins can create and destroy databases, install
- and update _design documents, run the test suite, and edit all aspects of CouchDB
- configuration.
- </p>
- <p class="help-block">Non-admin users have read and write access to all databases, which
- are controlled by validation functions. CouchDB can be configured to block all
- access to anonymous users.
- </p>
- </div>
- <div class="modal-footer">
- <a href="#" data-dismiss="modal" class="btn">Cancel</a>
- <a href="#" id="create-admin" class="btn btn-primary">Create Admin</a>
- </div>
-</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/auth/templates/login_modal.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/auth/templates/login_modal.html b/src/fauxton/app/addons/auth/templates/login_modal.html
deleted file mode 100644
index e0395da..0000000
--- a/src/fauxton/app/addons/auth/templates/login_modal.html
+++ /dev/null
@@ -1,35 +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.
--->
-
-<div class="modal hide fade">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
- <h3>Login</h3>
- </div>
- <div class="modal-body">
- <div id="modal-error" class="hide alert alert-error"/>
- <form>
- <p class="help-block">
- Login to CouchDB with your name and password.
- </p>
- <input id="username" type="text" name="name" placeholder= "Username:" size="24">
- <br/>
- <input id="password" type="password" name="password" placeholder= "Password" size="24">
- </form>
- </div>
- <div class="modal-footer">
- <a href="#" data-dismiss="modal" class="btn">Cancel</a>
- <a href="#" id="login" class="btn btn-primary">Login</a>
- </div>
-</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/auth/templates/nav_dropdown.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/auth/templates/nav_dropdown.html b/src/fauxton/app/addons/auth/templates/nav_dropdown.html
deleted file mode 100644
index 5e07ca0..0000000
--- a/src/fauxton/app/addons/auth/templates/nav_dropdown.html
+++ /dev/null
@@ -1,26 +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.
--->
-
-<!-- dropdown menu links -->
- <% if (admin_party) { %>
- <li> <a id="user-create-admin" href="#"> Create Admin </a> </li>
- <% } else if (user) { %>
- <li> <a id="user-create-more-admin" href="#"> Create Admins </a> </li>
- <li> <a id="user-change-password" href="#"> Change Password </a> </li>
- <li> <a id="user-logout" href="#"> Logout </a> </li>
- <% } else { %>
- <li> <a id="user-login" href="#"> Login </a> </li>
- <!--<li> <a id="user-sign-up"> Sign up </a> </li>-->
- <% } %>
-
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/auth/templates/nav_link.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/auth/templates/nav_link.html b/src/fauxton/app/addons/auth/templates/nav_link.html
deleted file mode 100644
index add5b89..0000000
--- a/src/fauxton/app/addons/auth/templates/nav_link.html
+++ /dev/null
@@ -1,19 +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.
--->
-
-<div id="nav-link-title"> </div>
-<div id="user-create-admin-modal"> </div>
-<div id="login-modal"> </div>
-<div id="change-password-modal"> </div>
-<div id="signup-modal"> </div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/auth/templates/nav_link_title.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/auth/templates/nav_link_title.html b/src/fauxton/app/addons/auth/templates/nav_link_title.html
deleted file mode 100644
index 90004f3..0000000
--- a/src/fauxton/app/addons/auth/templates/nav_link_title.html
+++ /dev/null
@@ -1,24 +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.
--->
-
- <% if (admin_party) { %>
- Admin Party!
- <% } else if (user) { %>
- <%= user.name %>
- <% } else { %>
- Login
- <% } %>
- <b class="caret"></b>
-
-
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/auth/templates/noAccess.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/auth/templates/noAccess.html b/src/fauxton/app/addons/auth/templates/noAccess.html
deleted file mode 100644
index f1a9506..0000000
--- a/src/fauxton/app/addons/auth/templates/noAccess.html
+++ /dev/null
@@ -1,19 +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.
--->
-
-<div class="row-fluid" >
- <div class="span6 offset4">
- <h3> You do not have permission to view this page </h3>
-</div>
-</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/config/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/base.js b/src/fauxton/app/addons/config/base.js
deleted file mode 100644
index f589b16..0000000
--- a/src/fauxton/app/addons/config/base.js
+++ /dev/null
@@ -1,28 +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.
-
-define([
- "app",
-
- "api",
-
- // Modules
- "addons/config/routes"
-],
-
-function(app, FauxtonAPI, Config) {
- Config.initialize = function() {
- FauxtonAPI.addHeaderLink({title: "Config", href: "#_config"});
- };
-
- return Config;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/config/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/resources.js b/src/fauxton/app/addons/config/resources.js
deleted file mode 100644
index db26bb7..0000000
--- a/src/fauxton/app/addons/config/resources.js
+++ /dev/null
@@ -1,175 +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.
-
-define([
- "app",
- "api"
-],
-
-function (app, FauxtonAPI) {
-
- var Config = FauxtonAPI.addon();
-
- Config.Model = Backbone.Model.extend({});
- Config.OptionModel = Backbone.Model.extend({
-
- url: function () {
- return app.host + '/_config/' + this.get("section") + '/' + this.get("name");
- },
-
- isNew: function () { return false; },
-
- sync: function (method, model, options) {
-
- var params = {
- url: model.url(),
- contentType: 'application/json',
- dataType: 'json',
- data: JSON.stringify(model.get('value'))
- };
-
- if (method === 'delete') {
- params.type = 'DELETE';
- } else {
- params.type = 'PUT';
- }
-
- return $.ajax(params);
- }
- });
-
- Config.Collection = Backbone.Collection.extend({
- model: Config.Model,
-
- url: function () {
- return app.host + '/_config';
- },
-
- parse: function (resp) {
- return _.map(resp, function (section, section_name) {
- return {
- section: section_name,
- options: _.map(section, function (option, option_name) {
- return {
- name: option_name,
- value: option
- };
- })
- };
- });
- }
- });
-
- Config.ViewItem = FauxtonAPI.View.extend({
- tagName: "tr",
- className: "config-item",
- template: "addons/config/templates/item",
-
- events: {
- "click .edit-button": "editValue",
- "click #delete-value": "deleteValue",
- "click #cancel-value": "cancelEdit",
- "click #save-value": "saveValue"
- },
-
- deleteValue: function (event) {
- var result = confirm("Are you sure you want to delete this configuration value?");
-
- if (!result) { return; }
-
- this.model.destroy();
- this.remove();
- },
-
- editValue: function (event) {
- this.$("#show-value").hide();
- this.$("#edit-value-form").show();
- },
-
- saveValue: function (event) {
- this.model.save({value: this.$(".value-input").val()});
- this.render();
- },
-
- cancelEdit: function (event) {
- this.$("#edit-value-form").hide();
- this.$("#show-value").show();
- },
-
- serialize: function () {
- return {option: this.model.toJSON()};
- }
-
- });
-
- Config.View = FauxtonAPI.View.extend({
- template: "addons/config/templates/dashboard",
-
- events: {
- "click #add-section": "addSection",
- "submit #add-section-form": "submitForm"
- },
-
- submitForm: function (event) {
- event.preventDefault();
- var option = new Config.OptionModel({
- section: this.$('input[name="section"]').val(),
- name: this.$('input[name="name"]').val(),
- value: this.$('input[name="value"]').val()
- });
-
- option.save();
-
- var section = this.collection.find(function (section) {
- return section.get("section") === option.get("section");
- });
-
- if (section) {
- section.get("options").push(option.attributes);
- } else {
- this.collection.add({
- section: option.get("section"),
- options: [option.attributes]
- });
- }
-
- this.$("#add-section-modal").modal('hide');
- this.render();
- },
-
- addSection: function (event) {
- event.preventDefault();
- this.$("#add-section-modal").modal({show:true});
- },
-
- beforeRender: function() {
- this.collection.each(function(config) {
- _.each(config.get("options"), function (option, index) {
- this.insertView("table.config tbody", new Config.ViewItem({
- model: new Config.OptionModel({
- section: config.get("section"),
- name: option.name,
- value: option.value,
- index: index
- })
- }));
- }, this);
- }, this);
- },
-
- establish: function() {
- return [this.collection.fetch()];
- }
- });
-
- return Config;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/config/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/routes.js b/src/fauxton/app/addons/config/routes.js
deleted file mode 100644
index f521c53..0000000
--- a/src/fauxton/app/addons/config/routes.js
+++ /dev/null
@@ -1,59 +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.
-
-define([
- "app",
-
- "api",
-
- // Modules
- "addons/config/resources"
-],
-
-function(app, FauxtonAPI, Config) {
-
- var ConfigRouteObject = FauxtonAPI.RouteObject.extend({
- layout: "one_pane",
-
- initialize: function () {
- this.configs = new Config.Collection();
- },
-
- roles: ["_admin"],
-
- selectedHeader: "Config",
-
- crumbs: [
- {"name": "Config","link": "_config"}
- ],
-
- apiUrl: function () {
- this.configs.url();
- },
-
- routes: {
- "_config": "config"
- },
-
- config: function () {
- this.setView("#dashboard-content", new Config.View({collection: this.configs}));
- },
-
- establish: function () {
- return [this.configs.fetch()];
- }
- });
-
-
- Config.RouteObjects = [ConfigRouteObject];
- return Config;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/config/templates/dashboard.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/templates/dashboard.html b/src/fauxton/app/addons/config/templates/dashboard.html
deleted file mode 100644
index 7cff90a..0000000
--- a/src/fauxton/app/addons/config/templates/dashboard.html
+++ /dev/null
@@ -1,52 +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.
--->
-
-<div class="row">
- <div class="span2 offset10">
- <button id="add-section" href="#" class="btn btn-primary button-margin">
- <i class="icon-plus icon-white"> </i>
- Add Section
- </button>
- </div>
-</div>
-<table class="config table table-striped table-bordered">
- <thead>
- <th> Section </th>
- <th> Option </th>
- <th> Value </th>
- <th></th>
- </thead>
- <tbody>
- </tbody>
-</table>
-<div id="add-section-modal" class="modal hide fade">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
- <h3>Create Config Option</h3>
- </div>
- <div class="modal-body">
- <form id="add-section-form" class="form well">
- <label>Section</label>
- <input type="text" name="section" placeholder="Section">
- <span class="help-block">Enter an existing section name to add to it.</span>
- <input type="text" name="name" placeholder="Name">
- <br/>
- <input type="text" name="value" placeholder="Value">
- <div class="modal-footer">
- <button type="button" class="btn" data-dismiss="modal">Cancel</button>
- <button type="submit" class="btn btn-primary"> Save </button>
- </div>
- </form>
- </div>
-</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/config/templates/item.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/templates/item.html b/src/fauxton/app/addons/config/templates/item.html
deleted file mode 100644
index 3e6e4ee..0000000
--- a/src/fauxton/app/addons/config/templates/item.html
+++ /dev/null
@@ -1,31 +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.
--->
-
-<% if (option.index === 0) {%>
-<th> <%= option.section %> </th>
-<% } else { %>
-<td></td>
-<% } %>
-<td> <%= option.name %> </td>
-<td>
- <div id="show-value">
- <%= option.value %> <button class="edit-button"> Edit </button>
- </div>
- <div id="edit-value-form" style="display:none">
- <input class="value-input" type="text" value="<%= option.value %>" />
- <button id="save-value" class="btn btn-success btn-small"> Save </button>
- <button id="cancel-value" class="btn btn-danger btn-small"> Cancel </button>
- </div>
-</td>
-<td id="delete-value"> <i class="icon-trash"> </i> </td>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/contribute/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/contribute/base.js b/src/fauxton/app/addons/contribute/base.js
deleted file mode 100644
index 8f622fe..0000000
--- a/src/fauxton/app/addons/contribute/base.js
+++ /dev/null
@@ -1,33 +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.
-
-define([
- // Libraries.
- "jquery",
- "lodash"
-],
-function($, _){
- $.contribute = function(message, file){
- /*
- var JST = window.JST = window.JST || {};
- var template = JST['app/addons/contribute/templates/modal.html'];
- console.log(template);
- var compiled = template({message: message, file: file});
- */
- console.log('contribute!contribute!monorail!contribute!');
- /*
- console.log(compiled);
- var elem = $(compiled);
- elem.modal('show');
- */
- };
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/exampleAuth/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/exampleAuth/base.js b/src/fauxton/app/addons/exampleAuth/base.js
deleted file mode 100644
index aa99670..0000000
--- a/src/fauxton/app/addons/exampleAuth/base.js
+++ /dev/null
@@ -1,59 +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.
-
-define([
- "app",
-
- "api"
-],
-
-function(app, FauxtonAPI) {
- // This is an example module of using the new auth module.
-
- var noAccessView = FauxtonAPI.View.extend({
- template: "addons/exampleAuth/templates/noAccess"
-
- });
-
- // To utilise the authentication - all that is required, is one callback
- // that is registered with the auth api. This function can return an array
- // of deferred objects.
- // The roles argument that is passed in is the required roles for the current user
- // to be allowed to access the current page.
- // The layout is the main layout for use when you want to render a view onto the page
- var auth = function (roles) {
- var deferred = $.Deferred();
-
- if (roles.indexOf('_admin') > -1) {
- deferred.reject();
- } else {
- deferred.resolve();
- }
-
- return [deferred];
- };
-
- // If you would like to do something with when access is denied you can register this callback.
- // It will be called is access has been denied on the previous page.
- var authFail = function () {
- app.masterLayout.setView('#dashboard', new noAccessView());
- app.masterLayout.renderView('#dashboard');
- };
-
- // Register the auth call back. This will be called before new route rendered
- FauxtonAPI.auth.registerAuth(auth);
- // Register a failed route request callback. This is called if access is denied.
- FauxtonAPI.auth.registerAuthDenied(authFail);
-
-
-
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/exampleAuth/templates/noAccess.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/exampleAuth/templates/noAccess.html b/src/fauxton/app/addons/exampleAuth/templates/noAccess.html
deleted file mode 100644
index f1a9506..0000000
--- a/src/fauxton/app/addons/exampleAuth/templates/noAccess.html
+++ /dev/null
@@ -1,19 +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.
--->
-
-<div class="row-fluid" >
- <div class="span6 offset4">
- <h3> You do not have permission to view this page </h3>
-</div>
-</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/logs/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/logs/base.js b/src/fauxton/app/addons/logs/base.js
deleted file mode 100644
index c17e159..0000000
--- a/src/fauxton/app/addons/logs/base.js
+++ /dev/null
@@ -1,28 +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.
-
-define([
- "app",
-
- "api",
-
- // Modules
- "addons/logs/routes"
-],
-
-function(app, FauxtonAPI, Log) {
- Log.initialize = function() {
- FauxtonAPI.addHeaderLink({title: "Log", href: "#_log"});
- };
-
- return Log;
-});
[10/26] Remove fauxton from 1.4.x branch.
Posted by dj...@apache.org.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/mixins.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/mixins.less b/src/fauxton/assets/less/bootstrap/mixins.less
deleted file mode 100644
index 98aa2b8..0000000
--- a/src/fauxton/assets/less/bootstrap/mixins.less
+++ /dev/null
@@ -1,686 +0,0 @@
-//
-// Mixins
-// --------------------------------------------------
-
-
-// UTILITY MIXINS
-// --------------------------------------------------
-
-// Clearfix
-// --------
-// For clearing floats like a boss h5bp.com/q
-.clearfix {
- *zoom: 1;
- &:before,
- &:after {
- display: table;
- content: "";
- // Fixes Opera/contenteditable bug:
- // http://nicolasgallagher.com/micro-clearfix-hack/#comment-36952
- line-height: 0;
- }
- &:after {
- clear: both;
- }
-}
-
-// Webkit-style focus
-// ------------------
-.tab-focus() {
- // Default
- outline: thin dotted #333;
- // Webkit
- outline: 5px auto -webkit-focus-ring-color;
- outline-offset: -2px;
-}
-
-// Center-align a block level element
-// ----------------------------------
-.center-block() {
- display: block;
- margin-left: auto;
- margin-right: auto;
-}
-
-// IE7 inline-block
-// ----------------
-.ie7-inline-block() {
- *display: inline; /* IE7 inline-block hack */
- *zoom: 1;
-}
-
-// IE7 likes to collapse whitespace on either side of the inline-block elements.
-// Ems because we're attempting to match the width of a space character. Left
-// version is for form buttons, which typically come after other elements, and
-// right version is for icons, which come before. Applying both is ok, but it will
-// mean that space between those elements will be .6em (~2 space characters) in IE7,
-// instead of the 1 space in other browsers.
-.ie7-restore-left-whitespace() {
- *margin-left: .3em;
-
- &:first-child {
- *margin-left: 0;
- }
-}
-
-.ie7-restore-right-whitespace() {
- *margin-right: .3em;
-}
-
-// Sizing shortcuts
-// -------------------------
-.size(@height, @width) {
- width: @width;
- height: @height;
-}
-.square(@size) {
- .size(@size, @size);
-}
-
-// Placeholder text
-// -------------------------
-.placeholder(@color: @placeholderText) {
- &:-moz-placeholder {
- color: @color;
- }
- &:-ms-input-placeholder {
- color: @color;
- }
- &::-webkit-input-placeholder {
- color: @color;
- }
-}
-
-// Text overflow
-// -------------------------
-// Requires inline-block or block for proper styling
-.text-overflow() {
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-
-// CSS image replacement
-// -------------------------
-// Source: https://github.com/h5bp/html5-boilerplate/commit/aa0396eae757
-.hide-text {
- font: 0/0 a;
- color: transparent;
- text-shadow: none;
- background-color: transparent;
- border: 0;
-}
-
-
-// FONTS
-// --------------------------------------------------
-
-#font {
- #family {
- .serif() {
- font-family: @serifFontFamily;
- }
- .sans-serif() {
- font-family: @sansFontFamily;
- }
- .monospace() {
- font-family: @monoFontFamily;
- }
- }
- .shorthand(@size: @baseFontSize, @weight: normal, @lineHeight: @baseLineHeight) {
- font-size: @size;
- font-weight: @weight;
- line-height: @lineHeight;
- }
- .serif(@size: @baseFontSize, @weight: normal, @lineHeight: @baseLineHeight) {
- #font > #family > .serif;
- #font > .shorthand(@size, @weight, @lineHeight);
- }
- .sans-serif(@size: @baseFontSize, @weight: normal, @lineHeight: @baseLineHeight) {
- #font > #family > .sans-serif;
- #font > .shorthand(@size, @weight, @lineHeight);
- }
- .monospace(@size: @baseFontSize, @weight: normal, @lineHeight: @baseLineHeight) {
- #font > #family > .monospace;
- #font > .shorthand(@size, @weight, @lineHeight);
- }
-}
-
-
-// FORMS
-// --------------------------------------------------
-
-// Block level inputs
-.input-block-level {
- display: block;
- width: 100%;
- min-height: @inputHeight; // Make inputs at least the height of their button counterpart (base line-height + padding + border)
- .box-sizing(border-box); // Makes inputs behave like true block-level elements
-}
-
-
-
-// Mixin for form field states
-.formFieldState(@textColor: #555, @borderColor: #ccc, @backgroundColor: #f5f5f5) {
- // Set the text color
- > label,
- .help-block,
- .help-inline {
- color: @textColor;
- }
- // Style inputs accordingly
- .checkbox,
- .radio,
- input,
- select,
- textarea {
- color: @textColor;
- }
- input,
- select,
- textarea {
- border-color: @borderColor;
- .box-shadow(inset 0 1px 1px rgba(0,0,0,.075)); // Redeclare so transitions work
- &:focus {
- border-color: darken(@borderColor, 10%);
- @shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 6px lighten(@borderColor, 20%);
- .box-shadow(@shadow);
- }
- }
- // Give a small background color for input-prepend/-append
- .input-prepend .add-on,
- .input-append .add-on {
- color: @textColor;
- background-color: @backgroundColor;
- border-color: @textColor;
- }
-}
-
-
-
-// CSS3 PROPERTIES
-// --------------------------------------------------
-
-// Border Radius
-.border-radius(@radius) {
- -webkit-border-radius: @radius;
- -moz-border-radius: @radius;
- border-radius: @radius;
-}
-
-// Single Corner Border Radius
-.border-top-left-radius(@radius) {
- -webkit-border-top-left-radius: @radius;
- -moz-border-radius-topleft: @radius;
- border-top-left-radius: @radius;
-}
-.border-top-right-radius(@radius) {
- -webkit-border-top-right-radius: @radius;
- -moz-border-radius-topright: @radius;
- border-top-right-radius: @radius;
-}
-.border-bottom-right-radius(@radius) {
- -webkit-border-bottom-right-radius: @radius;
- -moz-border-radius-bottomright: @radius;
- border-bottom-right-radius: @radius;
-}
-.border-bottom-left-radius(@radius) {
- -webkit-border-bottom-left-radius: @radius;
- -moz-border-radius-bottomleft: @radius;
- border-bottom-left-radius: @radius;
-}
-
-// Single Side Border Radius
-.border-top-radius(@radius) {
- .border-top-right-radius(@radius);
- .border-top-left-radius(@radius);
-}
-.border-right-radius(@radius) {
- .border-top-right-radius(@radius);
- .border-bottom-right-radius(@radius);
-}
-.border-bottom-radius(@radius) {
- .border-bottom-right-radius(@radius);
- .border-bottom-left-radius(@radius);
-}
-.border-left-radius(@radius) {
- .border-top-left-radius(@radius);
- .border-bottom-left-radius(@radius);
-}
-
-// Drop shadows
-.box-shadow(@shadow) {
- -webkit-box-shadow: @shadow;
- -moz-box-shadow: @shadow;
- box-shadow: @shadow;
-}
-
-// Transitions
-.transition(@transition) {
- -webkit-transition: @transition;
- -moz-transition: @transition;
- -o-transition: @transition;
- transition: @transition;
-}
-.transition-delay(@transition-delay) {
- -webkit-transition-delay: @transition-delay;
- -moz-transition-delay: @transition-delay;
- -o-transition-delay: @transition-delay;
- transition-delay: @transition-delay;
-}
-
-// Transformations
-.rotate(@degrees) {
- -webkit-transform: rotate(@degrees);
- -moz-transform: rotate(@degrees);
- -ms-transform: rotate(@degrees);
- -o-transform: rotate(@degrees);
- transform: rotate(@degrees);
-}
-.scale(@ratio) {
- -webkit-transform: scale(@ratio);
- -moz-transform: scale(@ratio);
- -ms-transform: scale(@ratio);
- -o-transform: scale(@ratio);
- transform: scale(@ratio);
-}
-.translate(@x, @y) {
- -webkit-transform: translate(@x, @y);
- -moz-transform: translate(@x, @y);
- -ms-transform: translate(@x, @y);
- -o-transform: translate(@x, @y);
- transform: translate(@x, @y);
-}
-.skew(@x, @y) {
- -webkit-transform: skew(@x, @y);
- -moz-transform: skew(@x, @y);
- -ms-transform: skewX(@x) skewY(@y); // See https://github.com/twitter/bootstrap/issues/4885
- -o-transform: skew(@x, @y);
- transform: skew(@x, @y);
- -webkit-backface-visibility: hidden; // See https://github.com/twitter/bootstrap/issues/5319
-}
-.translate3d(@x, @y, @z) {
- -webkit-transform: translate3d(@x, @y, @z);
- -moz-transform: translate3d(@x, @y, @z);
- -o-transform: translate3d(@x, @y, @z);
- transform: translate3d(@x, @y, @z);
-}
-
-// Backface visibility
-// Prevent browsers from flickering when using CSS 3D transforms.
-// Default value is `visible`, but can be changed to `hidden
-// See git pull https://github.com/dannykeane/bootstrap.git backface-visibility for examples
-.backface-visibility(@visibility){
- -webkit-backface-visibility: @visibility;
- -moz-backface-visibility: @visibility;
- backface-visibility: @visibility;
-}
-
-// Background clipping
-// Heads up: FF 3.6 and under need "padding" instead of "padding-box"
-.background-clip(@clip) {
- -webkit-background-clip: @clip;
- -moz-background-clip: @clip;
- background-clip: @clip;
-}
-
-// Background sizing
-.background-size(@size) {
- -webkit-background-size: @size;
- -moz-background-size: @size;
- -o-background-size: @size;
- background-size: @size;
-}
-
-
-// Box sizing
-.box-sizing(@boxmodel) {
- -webkit-box-sizing: @boxmodel;
- -moz-box-sizing: @boxmodel;
- box-sizing: @boxmodel;
-}
-
-// User select
-// For selecting text on the page
-.user-select(@select) {
- -webkit-user-select: @select;
- -moz-user-select: @select;
- -ms-user-select: @select;
- -o-user-select: @select;
- user-select: @select;
-}
-
-// Resize anything
-.resizable(@direction) {
- resize: @direction; // Options: horizontal, vertical, both
- overflow: auto; // Safari fix
-}
-
-// CSS3 Content Columns
-.content-columns(@columnCount, @columnGap: @gridGutterWidth) {
- -webkit-column-count: @columnCount;
- -moz-column-count: @columnCount;
- column-count: @columnCount;
- -webkit-column-gap: @columnGap;
- -moz-column-gap: @columnGap;
- column-gap: @columnGap;
-}
-
-// Optional hyphenation
-.hyphens(@mode: auto) {
- word-wrap: break-word;
- -webkit-hyphens: @mode;
- -moz-hyphens: @mode;
- -ms-hyphens: @mode;
- -o-hyphens: @mode;
- hyphens: @mode;
-}
-
-// Opacity
-.opacity(@opacity) {
- opacity: @opacity / 100;
- filter: ~"alpha(opacity=@{opacity})";
-}
-
-
-
-// BACKGROUNDS
-// --------------------------------------------------
-
-// Add an alphatransparency value to any background or border color (via Elyse Holladay)
-#translucent {
- .background(@color: @white, @alpha: 1) {
- background-color: hsla(hue(@color), saturation(@color), lightness(@color), @alpha);
- }
- .border(@color: @white, @alpha: 1) {
- border-color: hsla(hue(@color), saturation(@color), lightness(@color), @alpha);
- .background-clip(padding-box);
- }
-}
-
-// Gradient Bar Colors for buttons and alerts
-.gradientBar(@primaryColor, @secondaryColor, @textColor: #fff, @textShadow: 0 -1px 0 rgba(0,0,0,.25)) {
- color: @textColor;
- text-shadow: @textShadow;
- #gradient > .vertical(@primaryColor, @secondaryColor);
- border-color: @secondaryColor @secondaryColor darken(@secondaryColor, 15%);
- border-color: rgba(0,0,0,.1) rgba(0,0,0,.1) fadein(rgba(0,0,0,.1), 15%);
-}
-
-// Gradients
-#gradient {
- .horizontal(@startColor: #555, @endColor: #333) {
- background-color: @endColor;
- background-image: -moz-linear-gradient(left, @startColor, @endColor); // FF 3.6+
- background-image: -webkit-gradient(linear, 0 0, 100% 0, from(@startColor), to(@endColor)); // Safari 4+, Chrome 2+
- background-image: -webkit-linear-gradient(left, @startColor, @endColor); // Safari 5.1+, Chrome 10+
- background-image: -o-linear-gradient(left, @startColor, @endColor); // Opera 11.10
- background-image: linear-gradient(to right, @startColor, @endColor); // Standard, IE10
- background-repeat: repeat-x;
- filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=1)",argb(@startColor),argb(@endColor))); // IE9 and down
- }
- .vertical(@startColor: #555, @endColor: #333) {
- background-color: mix(@startColor, @endColor, 60%);
- background-image: -moz-linear-gradient(top, @startColor, @endColor); // FF 3.6+
- background-image: -webkit-gradient(linear, 0 0, 0 100%, from(@startColor), to(@endColor)); // Safari 4+, Chrome 2+
- background-image: -webkit-linear-gradient(top, @startColor, @endColor); // Safari 5.1+, Chrome 10+
- background-image: -o-linear-gradient(top, @startColor, @endColor); // Opera 11.10
- background-image: linear-gradient(to bottom, @startColor, @endColor); // Standard, IE10
- background-repeat: repeat-x;
- filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",argb(@startColor),argb(@endColor))); // IE9 and down
- }
- .directional(@startColor: #555, @endColor: #333, @deg: 45deg) {
- background-color: @endColor;
- background-repeat: repeat-x;
- background-image: -moz-linear-gradient(@deg, @startColor, @endColor); // FF 3.6+
- background-image: -webkit-linear-gradient(@deg, @startColor, @endColor); // Safari 5.1+, Chrome 10+
- background-image: -o-linear-gradient(@deg, @startColor, @endColor); // Opera 11.10
- background-image: linear-gradient(@deg, @startColor, @endColor); // Standard, IE10
- }
- .vertical-three-colors(@startColor: #00b3ee, @midColor: #7a43b6, @colorStop: 50%, @endColor: #c3325f) {
- background-color: mix(@midColor, @endColor, 80%);
- background-image: -webkit-gradient(linear, 0 0, 0 100%, from(@startColor), color-stop(@colorStop, @midColor), to(@endColor));
- background-image: -webkit-linear-gradient(@startColor, @midColor @colorStop, @endColor);
- background-image: -moz-linear-gradient(top, @startColor, @midColor @colorStop, @endColor);
- background-image: -o-linear-gradient(@startColor, @midColor @colorStop, @endColor);
- background-image: linear-gradient(@startColor, @midColor @colorStop, @endColor);
- background-repeat: no-repeat;
- filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",argb(@startColor),argb(@endColor))); // IE9 and down, gets no color-stop at all for proper fallback
- }
- .radial(@innerColor: #555, @outerColor: #333) {
- background-color: @outerColor;
- background-image: -webkit-gradient(radial, center center, 0, center center, 460, from(@innerColor), to(@outerColor));
- background-image: -webkit-radial-gradient(circle, @innerColor, @outerColor);
- background-image: -moz-radial-gradient(circle, @innerColor, @outerColor);
- background-image: -o-radial-gradient(circle, @innerColor, @outerColor);
- background-repeat: no-repeat;
- }
- .striped(@color: #555, @angle: 45deg) {
- background-color: @color;
- background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(.25, rgba(255,255,255,.15)), color-stop(.25, transparent), color-stop(.5, transparent), color-stop(.5, rgba(255,255,255,.15)), color-stop(.75, rgba(255,255,255,.15)), color-stop(.75, transparent), to(transparent));
- background-image: -webkit-linear-gradient(@angle, rgba(255,255,255,.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.15) 50%, rgba(255,255,255,.15) 75%, transparent 75%, transparent);
- background-image: -moz-linear-gradient(@angle, rgba(255,255,255,.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.15) 50%, rgba(255,255,255,.15) 75%, transparent 75%, transparent);
- background-image: -o-linear-gradient(@angle, rgba(255,255,255,.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.15) 50%, rgba(255,255,255,.15) 75%, transparent 75%, transparent);
- background-image: linear-gradient(@angle, rgba(255,255,255,.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.15) 50%, rgba(255,255,255,.15) 75%, transparent 75%, transparent);
- }
-}
-// Reset filters for IE
-.reset-filter() {
- filter: e(%("progid:DXImageTransform.Microsoft.gradient(enabled = false)"));
-}
-
-
-
-// COMPONENT MIXINS
-// --------------------------------------------------
-
-// Horizontal dividers
-// -------------------------
-// Dividers (basically an hr) within dropdowns and nav lists
-.nav-divider(@top: #e5e5e5, @bottom: @white) {
- // IE7 needs a set width since we gave a height. Restricting just
- // to IE7 to keep the 1px left/right space in other browsers.
- // It is unclear where IE is getting the extra space that we need
- // to negative-margin away, but so it goes.
- *width: 100%;
- height: 1px;
- margin: ((@baseLineHeight / 2) - 1) 1px; // 8px 1px
- *margin: -5px 0 5px;
- overflow: hidden;
- background-color: @top;
- border-bottom: 1px solid @bottom;
-}
-
-// Button backgrounds
-// ------------------
-.buttonBackground(@startColor, @endColor, @textColor: #fff, @textShadow: 0 -1px 0 rgba(0,0,0,.25)) {
- // gradientBar will set the background to a pleasing blend of these, to support IE<=9
- .gradientBar(@startColor, @endColor, @textColor, @textShadow);
- *background-color: @endColor; /* Darken IE7 buttons by default so they stand out more given they won't have borders */
- .reset-filter();
-
- // in these cases the gradient won't cover the background, so we override
- &:hover, &:active, &.active, &.disabled, &[disabled] {
- color: @textColor;
- background-color: @endColor;
- *background-color: darken(@endColor, 5%);
- }
-
- // IE 7 + 8 can't handle box-shadow to show active, so we darken a bit ourselves
- &:active,
- &.active {
- background-color: darken(@endColor, 10%) e("\9");
- }
-}
-
-// Navbar vertical align
-// -------------------------
-// Vertically center elements in the navbar.
-// Example: an element has a height of 30px, so write out `.navbarVerticalAlign(30px);` to calculate the appropriate top margin.
-.navbarVerticalAlign(@elementHeight) {
- margin-top: (@navbarHeight - @elementHeight) / 2;
-}
-
-
-
-// Grid System
-// -----------
-
-// Centered container element
-.container-fixed() {
- margin-right: auto;
- margin-left: auto;
- .clearfix();
-}
-
-// Table columns
-.tableColumns(@columnSpan: 1) {
- float: none; // undo default grid column styles
- width: ((@gridColumnWidth) * @columnSpan) + (@gridGutterWidth * (@columnSpan - 1)) - 16; // 16 is total padding on left and right of table cells
- margin-left: 0; // undo default grid column styles
-}
-
-// Make a Grid
-// Use .makeRow and .makeColumn to assign semantic layouts grid system behavior
-.makeRow() {
- margin-left: @gridGutterWidth * -1;
- .clearfix();
-}
-.makeColumn(@columns: 1, @offset: 0) {
- float: left;
- margin-left: (@gridColumnWidth * @offset) + (@gridGutterWidth * (@offset - 1)) + (@gridGutterWidth * 2);
- width: (@gridColumnWidth * @columns) + (@gridGutterWidth * (@columns - 1));
-}
-
-// The Grid
-#grid {
-
- .core (@gridColumnWidth, @gridGutterWidth) {
-
- .spanX (@index) when (@index > 0) {
- (~".span@{index}") { .span(@index); }
- .spanX(@index - 1);
- }
- .spanX (0) {}
-
- .offsetX (@index) when (@index > 0) {
- (~".offset@{index}") { .offset(@index); }
- .offsetX(@index - 1);
- }
- .offsetX (0) {}
-
- .offset (@columns) {
- margin-left: (@gridColumnWidth * @columns) + (@gridGutterWidth * (@columns + 1));
- }
-
- .span (@columns) {
- width: (@gridColumnWidth * @columns) + (@gridGutterWidth * (@columns - 1));
- }
-
- .row {
- margin-left: @gridGutterWidth * -1;
- .clearfix();
- }
-
- [class*="span"] {
- float: left;
- min-height: 1px; // prevent collapsing columns
- margin-left: @gridGutterWidth;
- }
-
- // Set the container width, and override it for fixed navbars in media queries
- .container,
- .navbar-static-top .container,
- .navbar-fixed-top .container,
- .navbar-fixed-bottom .container { .span(@gridColumns); }
-
- // generate .spanX and .offsetX
- .spanX (@gridColumns);
- .offsetX (@gridColumns);
-
- }
-
- .fluid (@fluidGridColumnWidth, @fluidGridGutterWidth) {
-
- .spanX (@index) when (@index > 0) {
- (~".span@{index}") { .span(@index); }
- .spanX(@index - 1);
- }
- .spanX (0) {}
-
- .offsetX (@index) when (@index > 0) {
- (~'.offset@{index}') { .offset(@index); }
- (~'.offset@{index}:first-child') { .offsetFirstChild(@index); }
- .offsetX(@index - 1);
- }
- .offsetX (0) {}
-
- .offset (@columns) {
- margin-left: (@fluidGridColumnWidth * @columns) + (@fluidGridGutterWidth * (@columns - 1)) + (@fluidGridGutterWidth*2);
- *margin-left: (@fluidGridColumnWidth * @columns) + (@fluidGridGutterWidth * (@columns - 1)) - (.5 / @gridRowWidth * 100 * 1%) + (@fluidGridGutterWidth*2) - (.5 / @gridRowWidth * 100 * 1%);
- }
-
- .offsetFirstChild (@columns) {
- margin-left: (@fluidGridColumnWidth * @columns) + (@fluidGridGutterWidth * (@columns - 1)) + (@fluidGridGutterWidth);
- *margin-left: (@fluidGridColumnWidth * @columns) + (@fluidGridGutterWidth * (@columns - 1)) - (.5 / @gridRowWidth * 100 * 1%) + @fluidGridGutterWidth - (.5 / @gridRowWidth * 100 * 1%);
- }
-
- .span (@columns) {
- width: (@fluidGridColumnWidth * @columns) + (@fluidGridGutterWidth * (@columns - 1));
- *width: (@fluidGridColumnWidth * @columns) + (@fluidGridGutterWidth * (@columns - 1)) - (.5 / @gridRowWidth * 100 * 1%);
- }
-
- .row-fluid {
- width: 100%;
- .clearfix();
- [class*="span"] {
- .input-block-level();
- float: left;
- margin-left: @fluidGridGutterWidth;
- *margin-left: @fluidGridGutterWidth - (.5 / @gridRowWidth * 100 * 1%);
- }
- [class*="span"]:first-child {
- margin-left: 0;
- }
-
- // Space grid-sized controls properly if multiple per line
- .controls-row [class*="span"] + [class*="span"] {
- margin-left: @fluidGridGutterWidth;
- }
-
- // generate .spanX and .offsetX
- .spanX (@gridColumns);
- .offsetX (@gridColumns);
- }
-
- }
-
- .input(@gridColumnWidth, @gridGutterWidth) {
-
- .spanX (@index) when (@index > 0) {
- (~"input.span@{index}, textarea.span@{index}, .uneditable-input.span@{index}") { .span(@index); }
- .spanX(@index - 1);
- }
- .spanX (0) {}
-
- .span(@columns) {
- width: ((@gridColumnWidth) * @columns) + (@gridGutterWidth * (@columns - 1)) - 14;
- }
-
- input,
- textarea,
- .uneditable-input {
- margin-left: 0; // override margin-left from core grid system
- }
-
- // Space grid-sized controls properly if multiple per line
- .controls-row [class*="span"] + [class*="span"] {
- margin-left: @gridGutterWidth;
- }
-
- // generate .spanX
- .spanX (@gridColumns);
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/modals.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/modals.less b/src/fauxton/assets/less/bootstrap/modals.less
deleted file mode 100644
index 90b8667..0000000
--- a/src/fauxton/assets/less/bootstrap/modals.less
+++ /dev/null
@@ -1,94 +0,0 @@
-//
-// Modals
-// --------------------------------------------------
-
-// Background
-.modal-backdrop {
- position: fixed;
- top: 0;
- right: 0;
- bottom: 0;
- left: 0;
- z-index: @zindexModalBackdrop;
- background-color: @black;
- // Fade for backdrop
- &.fade { opacity: 0; }
-}
-
-.modal-backdrop,
-.modal-backdrop.fade.in {
- .opacity(80);
-}
-
-// Base modal
-.modal {
- position: fixed;
- top: 50%;
- left: 50%;
- z-index: @zindexModal;
- width: 560px;
- margin: -250px 0 0 -280px;
- background-color: @white;
- border: 1px solid #999;
- border: 1px solid rgba(0,0,0,.3);
- *border: 1px solid #999; /* IE6-7 */
- .border-radius(6px);
- .box-shadow(0 3px 7px rgba(0,0,0,0.3));
- .background-clip(padding-box);
- // Remove focus outline from opened modal
- outline: none;
-
- &.fade {
- .transition(e('opacity .3s linear, top .3s ease-out'));
- top: -25%;
- }
- &.fade.in { top: 50%; }
-}
-.modal-header {
- padding: 9px 15px;
- border-bottom: 1px solid #eee;
- // Close icon
- .close { margin-top: 2px; }
- // Heading
- h3 {
- margin: 0;
- line-height: 30px;
- }
-}
-
-// Body (where all modal content resides)
-.modal-body {
- overflow-y: auto;
- max-height: 400px;
- padding: 15px;
-}
-// Remove bottom margin if need be
-.modal-form {
- margin-bottom: 0;
-}
-
-// Footer (for actions)
-.modal-footer {
- padding: 14px 15px 15px;
- margin-bottom: 0;
- text-align: right; // right align buttons
- background-color: #f5f5f5;
- border-top: 1px solid #ddd;
- .border-radius(0 0 6px 6px);
- .box-shadow(inset 0 1px 0 @white);
- .clearfix(); // clear it in case folks use .pull-* classes on buttons
-
- // Properly space out buttons
- .btn + .btn {
- margin-left: 5px;
- margin-bottom: 0; // account for input[type="submit"] which gets the bottom margin like all other inputs
- }
- // but override that for button groups
- .btn-group .btn + .btn {
- margin-left: -1px;
- }
- // and override it for block buttons as well
- .btn-block + .btn-block {
- margin-left: 0;
- }
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/navbar.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/navbar.less b/src/fauxton/assets/less/bootstrap/navbar.less
deleted file mode 100644
index f69e048..0000000
--- a/src/fauxton/assets/less/bootstrap/navbar.less
+++ /dev/null
@@ -1,475 +0,0 @@
-//
-// Navbars (Redux)
-// --------------------------------------------------
-
-
-// COMMON STYLES
-// -------------
-
-// Base class and wrapper
-.navbar {
- overflow: visible;
- margin-bottom: @baseLineHeight;
- color: @navbarText;
-
- // Fix for IE7's bad z-indexing so dropdowns don't appear below content that follows the navbar
- *position: relative;
- *z-index: 2;
-}
-
-// Inner for background effects
-// Gradient is applied to its own element because overflow visible is not honored by IE when filter is present
-.navbar-inner {
- min-height: @navbarHeight;
- padding-left: 20px;
- padding-right: 20px;
- #gradient > .vertical(@navbarBackgroundHighlight, @navbarBackground);
- border: 1px solid @navbarBorder;
- .border-radius(@baseBorderRadius);
- .box-shadow(0 1px 4px rgba(0,0,0,.065));
-
- // Prevent floats from breaking the navbar
- .clearfix();
-}
-
-// Set width to auto for default container
-// We then reset it for fixed navbars in the #gridSystem mixin
-.navbar .container {
- width: auto;
-}
-
-// Override the default collapsed state
-.nav-collapse.collapse {
- height: auto;
- overflow: visible;
-}
-
-
-// Brand: website or project name
-// -------------------------
-.navbar .brand {
- float: left;
- display: block;
- // Vertically center the text given @navbarHeight
- padding: ((@navbarHeight - @baseLineHeight) / 2) 20px ((@navbarHeight - @baseLineHeight) / 2);
- margin-left: -20px; // negative indent to left-align the text down the page
- font-size: 20px;
- font-weight: 200;
- color: @navbarBrandColor;
- text-shadow: 0 1px 0 @navbarBackgroundHighlight;
- &:hover {
- text-decoration: none;
- }
-}
-
-// Plain text in topbar
-// -------------------------
-.navbar-text {
- margin-bottom: 0;
- line-height: @navbarHeight;
-}
-
-// Janky solution for now to account for links outside the .nav
-// -------------------------
-.navbar-link {
- color: @navbarLinkColor;
- &:hover {
- color: @navbarLinkColorHover;
- }
-}
-
-// Dividers in navbar
-// -------------------------
-.navbar .divider-vertical {
- height: @navbarHeight;
- margin: 0 9px;
- border-left: 1px solid @navbarBackground;
- border-right: 1px solid @navbarBackgroundHighlight;
-}
-
-// Buttons in navbar
-// -------------------------
-.navbar .btn,
-.navbar .btn-group {
- .navbarVerticalAlign(30px); // Vertically center in navbar
-}
-.navbar .btn-group .btn,
-.navbar .input-prepend .btn,
-.navbar .input-append .btn {
- margin-top: 0; // then undo the margin here so we don't accidentally double it
-}
-
-// Navbar forms
-// -------------------------
-.navbar-form {
- margin-bottom: 0; // remove default bottom margin
- .clearfix();
- input,
- select,
- .radio,
- .checkbox {
- .navbarVerticalAlign(30px); // Vertically center in navbar
- }
- input,
- select,
- .btn {
- display: inline-block;
- margin-bottom: 0;
- }
- input[type="image"],
- input[type="checkbox"],
- input[type="radio"] {
- margin-top: 3px;
- }
- .input-append,
- .input-prepend {
- margin-top: 6px;
- white-space: nowrap; // preven two items from separating within a .navbar-form that has .pull-left
- input {
- margin-top: 0; // remove the margin on top since it's on the parent
- }
- }
-}
-
-// Navbar search
-// -------------------------
-.navbar-search {
- position: relative;
- float: left;
- .navbarVerticalAlign(30px); // Vertically center in navbar
- margin-bottom: 0;
- .search-query {
- margin-bottom: 0;
- padding: 4px 14px;
- #font > .sans-serif(13px, normal, 1);
- .border-radius(15px); // redeclare because of specificity of the type attribute
- }
-}
-
-
-
-// Static navbar
-// -------------------------
-
-.navbar-static-top {
- position: static;
- margin-bottom: 0; // remove 18px margin for default navbar
- .navbar-inner {
- .border-radius(0);
- }
-}
-
-
-
-// Fixed navbar
-// -------------------------
-
-// Shared (top/bottom) styles
-.navbar-fixed-top,
-.navbar-fixed-bottom {
- position: fixed;
- right: 0;
- left: 0;
- z-index: @zindexFixedNavbar;
- margin-bottom: 0; // remove 18px margin for default navbar
-}
-.navbar-fixed-top .navbar-inner,
-.navbar-static-top .navbar-inner {
- border-width: 0 0 1px;
-}
-.navbar-fixed-bottom .navbar-inner {
- border-width: 1px 0 0;
-}
-.navbar-fixed-top .navbar-inner,
-.navbar-fixed-bottom .navbar-inner {
- padding-left: 0;
- padding-right: 0;
- .border-radius(0);
-}
-
-// Reset container width
-// Required here as we reset the width earlier on and the grid mixins don't override early enough
-.navbar-static-top .container,
-.navbar-fixed-top .container,
-.navbar-fixed-bottom .container {
- #grid > .core > .span(@gridColumns);
-}
-
-// Fixed to top
-.navbar-fixed-top {
- top: 0;
-}
-.navbar-fixed-top,
-.navbar-static-top {
- .navbar-inner {
- .box-shadow(~"0 1px 10px rgba(0,0,0,.1)");
- }
-}
-
-// Fixed to bottom
-.navbar-fixed-bottom {
- bottom: 0;
- .navbar-inner {
- .box-shadow(~"0 -1px 10px rgba(0,0,0,.1)");
- }
-}
-
-
-
-// NAVIGATION
-// ----------
-
-.navbar .nav {
- position: relative;
- left: 0;
- display: block;
- float: left;
- margin: 0 10px 0 0;
-}
-.navbar .nav.pull-right {
- float: right; // redeclare due to specificity
- margin-right: 0; // remove margin on float right nav
-}
-.navbar .nav > li {
- float: left;
-}
-
-// Links
-.navbar .nav > li > a {
- float: none;
- // Vertically center the text given @navbarHeight
- padding: ((@navbarHeight - @baseLineHeight) / 2) 15px ((@navbarHeight - @baseLineHeight) / 2);
- color: @navbarLinkColor;
- text-decoration: none;
- text-shadow: 0 1px 0 @navbarBackgroundHighlight;
-}
-.navbar .nav .dropdown-toggle .caret {
- margin-top: 8px;
-}
-
-// Hover
-.navbar .nav > li > a:focus,
-.navbar .nav > li > a:hover {
- background-color: @navbarLinkBackgroundHover; // "transparent" is default to differentiate :hover from .active
- color: @navbarLinkColorHover;
- text-decoration: none;
-}
-
-// Active nav items
-.navbar .nav > .active > a,
-.navbar .nav > .active > a:hover,
-.navbar .nav > .active > a:focus {
- color: @navbarLinkColorActive;
- text-decoration: none;
- background-color: @navbarLinkBackgroundActive;
- .box-shadow(inset 0 3px 8px rgba(0,0,0,.125));
-}
-
-// Navbar button for toggling navbar items in responsive layouts
-// These definitions need to come after '.navbar .btn'
-.navbar .btn-navbar {
- display: none;
- float: right;
- padding: 7px 10px;
- margin-left: 5px;
- margin-right: 5px;
- .buttonBackground(darken(@navbarBackgroundHighlight, 5%), darken(@navbarBackground, 5%));
- .box-shadow(~"inset 0 1px 0 rgba(255,255,255,.1), 0 1px 0 rgba(255,255,255,.075)");
-}
-.navbar .btn-navbar .icon-bar {
- display: block;
- width: 18px;
- height: 2px;
- background-color: #f5f5f5;
- .border-radius(1px);
- .box-shadow(0 1px 0 rgba(0,0,0,.25));
-}
-.btn-navbar .icon-bar + .icon-bar {
- margin-top: 3px;
-}
-
-
-
-// Dropdown menus
-// --------------
-
-// Menu position and menu carets
-.navbar .nav > li > .dropdown-menu {
- &:before {
- content: '';
- display: inline-block;
- border-left: 7px solid transparent;
- border-right: 7px solid transparent;
- border-bottom: 7px solid #ccc;
- border-bottom-color: @dropdownBorder;
- position: absolute;
- top: -7px;
- left: 9px;
- }
- &:after {
- content: '';
- display: inline-block;
- border-left: 6px solid transparent;
- border-right: 6px solid transparent;
- border-bottom: 6px solid @dropdownBackground;
- position: absolute;
- top: -6px;
- left: 10px;
- }
-}
-// Menu position and menu caret support for dropups via extra dropup class
-.navbar-fixed-bottom .nav > li > .dropdown-menu {
- &:before {
- border-top: 7px solid #ccc;
- border-top-color: @dropdownBorder;
- border-bottom: 0;
- bottom: -7px;
- top: auto;
- }
- &:after {
- border-top: 6px solid @dropdownBackground;
- border-bottom: 0;
- bottom: -6px;
- top: auto;
- }
-}
-
-// Remove background color from open dropdown
-.navbar .nav li.dropdown.open > .dropdown-toggle,
-.navbar .nav li.dropdown.active > .dropdown-toggle,
-.navbar .nav li.dropdown.open.active > .dropdown-toggle {
- background-color: @navbarLinkBackgroundActive;
- color: @navbarLinkColorActive;
-}
-.navbar .nav li.dropdown > .dropdown-toggle .caret {
- border-top-color: @navbarLinkColor;
- border-bottom-color: @navbarLinkColor;
-}
-.navbar .nav li.dropdown.open > .dropdown-toggle .caret,
-.navbar .nav li.dropdown.active > .dropdown-toggle .caret,
-.navbar .nav li.dropdown.open.active > .dropdown-toggle .caret {
- border-top-color: @navbarLinkColorActive;
- border-bottom-color: @navbarLinkColorActive;
-}
-
-// Right aligned menus need alt position
-.navbar .pull-right > li > .dropdown-menu,
-.navbar .nav > li > .dropdown-menu.pull-right {
- left: auto;
- right: 0;
- &:before {
- left: auto;
- right: 12px;
- }
- &:after {
- left: auto;
- right: 13px;
- }
- .dropdown-menu {
- left: auto;
- right: 100%;
- margin-left: 0;
- margin-right: -1px;
- .border-radius(6px 0 6px 6px);
- }
-}
-
-
-// Inverted navbar
-// -------------------------
-
-.navbar-inverse {
- color: @navbarInverseText;
-
- .navbar-inner {
- #gradient > .vertical(@navbarInverseBackgroundHighlight, @navbarInverseBackground);
- border-color: @navbarInverseBorder;
- }
-
- .brand,
- .nav > li > a {
- color: @navbarInverseLinkColor;
- text-shadow: 0 -1px 0 rgba(0,0,0,.25);
- &:hover {
- color: @navbarInverseLinkColorHover;
- }
- }
-
- .nav > li > a:focus,
- .nav > li > a:hover {
- background-color: @navbarInverseLinkBackgroundHover;
- color: @navbarInverseLinkColorHover;
- }
-
- .nav .active > a,
- .nav .active > a:hover,
- .nav .active > a:focus {
- color: @navbarInverseLinkColorActive;
- background-color: @navbarInverseLinkBackgroundActive;
- }
-
- // Inline text links
- .navbar-link {
- color: @navbarInverseLinkColor;
- &:hover {
- color: @navbarInverseLinkColorHover;
- }
- }
-
- // Dividers in navbar
- .divider-vertical {
- border-left-color: @navbarInverseBackground;
- border-right-color: @navbarInverseBackgroundHighlight;
- }
-
- // Dropdowns
- .nav li.dropdown.open > .dropdown-toggle,
- .nav li.dropdown.active > .dropdown-toggle,
- .nav li.dropdown.open.active > .dropdown-toggle {
- background-color: @navbarInverseLinkBackgroundActive;
- color: @navbarInverseLinkColorActive;
- }
- .nav li.dropdown > .dropdown-toggle .caret {
- border-top-color: @navbarInverseLinkColor;
- border-bottom-color: @navbarInverseLinkColor;
- }
- .nav li.dropdown.open > .dropdown-toggle .caret,
- .nav li.dropdown.active > .dropdown-toggle .caret,
- .nav li.dropdown.open.active > .dropdown-toggle .caret {
- border-top-color: @navbarInverseLinkColorActive;
- border-bottom-color: @navbarInverseLinkColorActive;
- }
-
- // Navbar search
- .navbar-search {
- .search-query {
- color: @white;
- background-color: @navbarInverseSearchBackground;
- border-color: @navbarInverseSearchBorder;
- .box-shadow(~"inset 0 1px 2px rgba(0,0,0,.1), 0 1px 0 rgba(255,255,255,.15)");
- .transition(none);
- .placeholder(@navbarInverseSearchPlaceholderColor);
-
- // Focus states (we use .focused since IE7-8 and down doesn't support :focus)
- &:focus,
- &.focused {
- padding: 5px 15px;
- color: @grayDark;
- text-shadow: 0 1px 0 @white;
- background-color: @navbarInverseSearchBackgroundFocus;
- border: 0;
- .box-shadow(0 0 3px rgba(0,0,0,.15));
- outline: 0;
- }
- }
- }
-
- // Navbar collapse button
- .btn-navbar {
- .buttonBackground(darken(@navbarInverseBackgroundHighlight, 5%), darken(@navbarInverseBackground, 5%));
- }
-
-}
-
-
-
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/navs.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/navs.less b/src/fauxton/assets/less/bootstrap/navs.less
deleted file mode 100644
index 1944f84..0000000
--- a/src/fauxton/assets/less/bootstrap/navs.less
+++ /dev/null
@@ -1,385 +0,0 @@
-//
-// Navs
-// --------------------------------------------------
-
-
-// BASE CLASS
-// ----------
-
-.nav {
- margin-left: 0;
- margin-bottom: @baseLineHeight;
- list-style: none;
-}
-
-// Make links block level
-.nav > li > a {
- display: block;
-}
-.nav > li > a:hover {
- text-decoration: none;
- background-color: @grayLighter;
-}
-
-// Redeclare pull classes because of specifity
-.nav > .pull-right {
- float: right;
-}
-
-// Nav headers (for dropdowns and lists)
-.nav-header {
- display: block;
- padding: 3px 15px;
- font-size: 11px;
- font-weight: bold;
- line-height: @baseLineHeight;
- color: @grayLight;
- text-shadow: 0 1px 0 rgba(255,255,255,.5);
- text-transform: uppercase;
-}
-// Space them out when they follow another list item (link)
-.nav li + .nav-header {
- margin-top: 9px;
-}
-
-
-
-// NAV LIST
-// --------
-
-.nav-list {
- padding-left: 15px;
- padding-right: 15px;
- margin-bottom: 0;
-}
-.nav-list > li > a,
-.nav-list .nav-header {
- margin-left: -15px;
- margin-right: -15px;
- text-shadow: 0 1px 0 rgba(255,255,255,.5);
-}
-.nav-list > li > a {
- padding: 3px 15px;
-}
-.nav-list > .active > a,
-.nav-list > .active > a:hover {
- color: @white;
- text-shadow: 0 -1px 0 rgba(0,0,0,.2);
- background-color: @linkColor;
-}
-.nav-list [class^="icon-"],
-.nav-list [class*=" icon-"] {
- margin-right: 2px;
-}
-// Dividers (basically an hr) within the dropdown
-.nav-list .divider {
- .nav-divider();
-}
-
-
-
-// TABS AND PILLS
-// -------------
-
-// Common styles
-.nav-tabs,
-.nav-pills {
- .clearfix();
-}
-.nav-tabs > li,
-.nav-pills > li {
- float: left;
-}
-.nav-tabs > li > a,
-.nav-pills > li > a {
- padding-right: 12px;
- padding-left: 12px;
- margin-right: 2px;
- line-height: 14px; // keeps the overall height an even number
-}
-
-// TABS
-// ----
-
-// Give the tabs something to sit on
-.nav-tabs {
- border-bottom: 1px solid #ddd;
-}
-// Make the list-items overlay the bottom border
-.nav-tabs > li {
- margin-bottom: -1px;
-}
-// Actual tabs (as links)
-.nav-tabs > li > a {
- padding-top: 8px;
- padding-bottom: 8px;
- line-height: @baseLineHeight;
- border: 1px solid transparent;
- .border-radius(4px 4px 0 0);
- &:hover {
- border-color: @grayLighter @grayLighter #ddd;
- }
-}
-// Active state, and it's :hover to override normal :hover
-.nav-tabs > .active > a,
-.nav-tabs > .active > a:hover {
- color: @gray;
- background-color: @bodyBackground;
- border: 1px solid #ddd;
- border-bottom-color: transparent;
- cursor: default;
-}
-
-
-// PILLS
-// -----
-
-// Links rendered as pills
-.nav-pills > li > a {
- padding-top: 8px;
- padding-bottom: 8px;
- margin-top: 2px;
- margin-bottom: 2px;
- .border-radius(5px);
-}
-
-// Active state
-.nav-pills > .active > a,
-.nav-pills > .active > a:hover {
- color: @white;
- background-color: @linkColor;
-}
-
-
-
-// STACKED NAV
-// -----------
-
-// Stacked tabs and pills
-.nav-stacked > li {
- float: none;
-}
-.nav-stacked > li > a {
- margin-right: 0; // no need for the gap between nav items
-}
-
-// Tabs
-.nav-tabs.nav-stacked {
- border-bottom: 0;
-}
-.nav-tabs.nav-stacked > li > a {
- border: 1px solid #ddd;
- .border-radius(0);
-}
-.nav-tabs.nav-stacked > li:first-child > a {
- .border-top-radius(4px);
-}
-.nav-tabs.nav-stacked > li:last-child > a {
- .border-bottom-radius(4px);
-}
-.nav-tabs.nav-stacked > li > a:hover {
- border-color: #ddd;
- z-index: 2;
-}
-
-// Pills
-.nav-pills.nav-stacked > li > a {
- margin-bottom: 3px;
-}
-.nav-pills.nav-stacked > li:last-child > a {
- margin-bottom: 1px; // decrease margin to match sizing of stacked tabs
-}
-
-
-
-// DROPDOWNS
-// ---------
-
-.nav-tabs .dropdown-menu {
- .border-radius(0 0 6px 6px); // remove the top rounded corners here since there is a hard edge above the menu
-}
-.nav-pills .dropdown-menu {
- .border-radius(6px); // make rounded corners match the pills
-}
-
-// Default dropdown links
-// -------------------------
-// Make carets use linkColor to start
-.nav .dropdown-toggle .caret {
- border-top-color: @linkColor;
- border-bottom-color: @linkColor;
- margin-top: 6px;
-}
-.nav .dropdown-toggle:hover .caret {
- border-top-color: @linkColorHover;
- border-bottom-color: @linkColorHover;
-}
-/* move down carets for tabs */
-.nav-tabs .dropdown-toggle .caret {
- margin-top: 8px;
-}
-
-// Active dropdown links
-// -------------------------
-.nav .active .dropdown-toggle .caret {
- border-top-color: #fff;
- border-bottom-color: #fff;
-}
-.nav-tabs .active .dropdown-toggle .caret {
- border-top-color: @gray;
- border-bottom-color: @gray;
-}
-
-// Active:hover dropdown links
-// -------------------------
-.nav > .dropdown.active > a:hover {
- cursor: pointer;
-}
-
-// Open dropdowns
-// -------------------------
-.nav-tabs .open .dropdown-toggle,
-.nav-pills .open .dropdown-toggle,
-.nav > li.dropdown.open.active > a:hover {
- color: @white;
- background-color: @grayLight;
- border-color: @grayLight;
-}
-.nav li.dropdown.open .caret,
-.nav li.dropdown.open.active .caret,
-.nav li.dropdown.open a:hover .caret {
- border-top-color: @white;
- border-bottom-color: @white;
- .opacity(100);
-}
-
-// Dropdowns in stacked tabs
-.tabs-stacked .open > a:hover {
- border-color: @grayLight;
-}
-
-
-
-// TABBABLE
-// --------
-
-
-// COMMON STYLES
-// -------------
-
-// Clear any floats
-.tabbable {
- .clearfix();
-}
-.tab-content {
- overflow: auto; // prevent content from running below tabs
-}
-
-// Remove border on bottom, left, right
-.tabs-below > .nav-tabs,
-.tabs-right > .nav-tabs,
-.tabs-left > .nav-tabs {
- border-bottom: 0;
-}
-
-// Show/hide tabbable areas
-.tab-content > .tab-pane,
-.pill-content > .pill-pane {
- display: none;
-}
-.tab-content > .active,
-.pill-content > .active {
- display: block;
-}
-
-
-// BOTTOM
-// ------
-
-.tabs-below > .nav-tabs {
- border-top: 1px solid #ddd;
-}
-.tabs-below > .nav-tabs > li {
- margin-top: -1px;
- margin-bottom: 0;
-}
-.tabs-below > .nav-tabs > li > a {
- .border-radius(0 0 4px 4px);
- &:hover {
- border-bottom-color: transparent;
- border-top-color: #ddd;
- }
-}
-.tabs-below > .nav-tabs > .active > a,
-.tabs-below > .nav-tabs > .active > a:hover {
- border-color: transparent #ddd #ddd #ddd;
-}
-
-// LEFT & RIGHT
-// ------------
-
-// Common styles
-.tabs-left > .nav-tabs > li,
-.tabs-right > .nav-tabs > li {
- float: none;
-}
-.tabs-left > .nav-tabs > li > a,
-.tabs-right > .nav-tabs > li > a {
- min-width: 74px;
- margin-right: 0;
- margin-bottom: 3px;
-}
-
-// Tabs on the left
-.tabs-left > .nav-tabs {
- float: left;
- margin-right: 19px;
- border-right: 1px solid #ddd;
-}
-.tabs-left > .nav-tabs > li > a {
- margin-right: -1px;
- .border-radius(4px 0 0 4px);
-}
-.tabs-left > .nav-tabs > li > a:hover {
- border-color: @grayLighter #ddd @grayLighter @grayLighter;
-}
-.tabs-left > .nav-tabs .active > a,
-.tabs-left > .nav-tabs .active > a:hover {
- border-color: #ddd transparent #ddd #ddd;
- *border-right-color: @white;
-}
-
-// Tabs on the right
-.tabs-right > .nav-tabs {
- float: right;
- margin-left: 19px;
- border-left: 1px solid #ddd;
-}
-.tabs-right > .nav-tabs > li > a {
- margin-left: -1px;
- .border-radius(0 4px 4px 0);
-}
-.tabs-right > .nav-tabs > li > a:hover {
- border-color: @grayLighter @grayLighter @grayLighter #ddd;
-}
-.tabs-right > .nav-tabs .active > a,
-.tabs-right > .nav-tabs .active > a:hover {
- border-color: #ddd #ddd #ddd transparent;
- *border-left-color: @white;
-}
-
-
-
-// DISABLED STATES
-// ---------------
-
-// Gray out text
-.nav > .disabled > a {
- color: @grayLight;
-}
-// Nuke hover effects
-.nav > .disabled > a:hover {
- text-decoration: none;
- background-color: transparent;
- cursor: default;
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/pager.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/pager.less b/src/fauxton/assets/less/bootstrap/pager.less
deleted file mode 100644
index da24253..0000000
--- a/src/fauxton/assets/less/bootstrap/pager.less
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// Pager pagination
-// --------------------------------------------------
-
-
-.pager {
- margin: @baseLineHeight 0;
- list-style: none;
- text-align: center;
- .clearfix();
-}
-.pager li {
- display: inline;
-}
-.pager li > a,
-.pager li > span {
- display: inline-block;
- padding: 5px 14px;
- background-color: #fff;
- border: 1px solid #ddd;
- .border-radius(15px);
-}
-.pager li > a:hover {
- text-decoration: none;
- background-color: #f5f5f5;
-}
-.pager .next > a,
-.pager .next > span {
- float: right;
-}
-.pager .previous > a,
-.pager .previous > span {
- float: left;
-}
-.pager .disabled > a,
-.pager .disabled > a:hover,
-.pager .disabled > span {
- color: @grayLight;
- background-color: #fff;
- cursor: default;
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/pagination.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/pagination.less b/src/fauxton/assets/less/bootstrap/pagination.less
deleted file mode 100644
index e35d3f4..0000000
--- a/src/fauxton/assets/less/bootstrap/pagination.less
+++ /dev/null
@@ -1,121 +0,0 @@
-//
-// Pagination (multiple pages)
-// --------------------------------------------------
-
-// Space out pagination from surrounding content
-.pagination {
- margin: @baseLineHeight 0;
-}
-
-.pagination ul {
- // Allow for text-based alignment
- display: inline-block;
- .ie7-inline-block();
- // Reset default ul styles
- margin-left: 0;
- margin-bottom: 0;
- // Visuals
- .border-radius(@baseBorderRadius);
- .box-shadow(0 1px 2px rgba(0,0,0,.05));
-}
-.pagination ul > li {
- display: inline; // Remove list-style and block-level defaults
-}
-.pagination ul > li > a,
-.pagination ul > li > span {
- float: left; // Collapse white-space
- padding: 4px 12px;
- line-height: @baseLineHeight;
- text-decoration: none;
- background-color: @paginationBackground;
- border: 1px solid @paginationBorder;
- border-left-width: 0;
-}
-.pagination ul > li > a:hover,
-.pagination ul > .active > a,
-.pagination ul > .active > span {
- background-color: @paginationActiveBackground;
-}
-.pagination ul > .active > a,
-.pagination ul > .active > span {
- color: @grayLight;
- cursor: default;
-}
-.pagination ul > .disabled > span,
-.pagination ul > .disabled > a,
-.pagination ul > .disabled > a:hover {
- color: @grayLight;
- background-color: transparent;
- cursor: default;
-}
-.pagination ul > li:first-child > a,
-.pagination ul > li:first-child > span {
- border-left-width: 1px;
- .border-left-radius(@baseBorderRadius);
-}
-.pagination ul > li:last-child > a,
-.pagination ul > li:last-child > span {
- .border-right-radius(@baseBorderRadius);
-}
-
-
-// Alignment
-// --------------------------------------------------
-
-.pagination-centered {
- text-align: center;
-}
-.pagination-right {
- text-align: right;
-}
-
-
-// Sizing
-// --------------------------------------------------
-
-// Large
-.pagination-large {
- ul > li > a,
- ul > li > span {
- padding: @paddingLarge;
- font-size: @fontSizeLarge;
- }
- ul > li:first-child > a,
- ul > li:first-child > span {
- .border-left-radius(@borderRadiusLarge);
- }
- ul > li:last-child > a,
- ul > li:last-child > span {
- .border-right-radius(@borderRadiusLarge);
- }
-}
-
-// Small and mini
-.pagination-mini,
-.pagination-small {
- ul > li:first-child > a,
- ul > li:first-child > span {
- .border-left-radius(@borderRadiusSmall);
- }
- ul > li:last-child > a,
- ul > li:last-child > span {
- .border-right-radius(@borderRadiusSmall);
- }
-}
-
-// Small
-.pagination-small {
- ul > li > a,
- ul > li > span {
- padding: @paddingSmall;
- font-size: @fontSizeSmall;
- }
-}
-// Mini
-.pagination-mini {
- ul > li > a,
- ul > li > span {
- padding: @paddingMini;
- font-size: @fontSizeMini;
- }
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/popovers.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/popovers.less b/src/fauxton/assets/less/bootstrap/popovers.less
deleted file mode 100644
index a4c4bb0..0000000
--- a/src/fauxton/assets/less/bootstrap/popovers.less
+++ /dev/null
@@ -1,117 +0,0 @@
-//
-// Popovers
-// --------------------------------------------------
-
-
-.popover {
- position: absolute;
- top: 0;
- left: 0;
- z-index: @zindexPopover;
- display: none;
- width: 236px;
- padding: 1px;
- background-color: @popoverBackground;
- -webkit-background-clip: padding-box;
- -moz-background-clip: padding;
- background-clip: padding-box;
- border: 1px solid #ccc;
- border: 1px solid rgba(0,0,0,.2);
- .border-radius(6px);
- .box-shadow(0 5px 10px rgba(0,0,0,.2));
-
- // Offset the popover to account for the popover arrow
- &.top { margin-top: -10px; }
- &.right { margin-left: 10px; }
- &.bottom { margin-top: 10px; }
- &.left { margin-left: -10px; }
-
-}
-
-.popover-title {
- margin: 0; // reset heading margin
- padding: 8px 14px;
- font-size: 14px;
- font-weight: normal;
- line-height: 18px;
- background-color: @popoverTitleBackground;
- border-bottom: 1px solid darken(@popoverTitleBackground, 5%);
- .border-radius(5px 5px 0 0);
-}
-
-.popover-content {
- padding: 9px 14px;
- p, ul, ol {
- margin-bottom: 0;
- }
-}
-
-// Arrows
-.popover .arrow,
-.popover .arrow:after {
- position: absolute;
- display: inline-block;
- width: 0;
- height: 0;
- border-color: transparent;
- border-style: solid;
-}
-.popover .arrow:after {
- content: "";
- z-index: -1;
-}
-
-.popover {
- &.top .arrow {
- bottom: -@popoverArrowWidth;
- left: 50%;
- margin-left: -@popoverArrowWidth;
- border-width: @popoverArrowWidth @popoverArrowWidth 0;
- border-top-color: @popoverArrowColor;
- &:after {
- border-width: @popoverArrowOuterWidth @popoverArrowOuterWidth 0;
- border-top-color: @popoverArrowOuterColor;
- bottom: -1px;
- left: -@popoverArrowOuterWidth;
- }
- }
- &.right .arrow {
- top: 50%;
- left: -@popoverArrowWidth;
- margin-top: -@popoverArrowWidth;
- border-width: @popoverArrowWidth @popoverArrowWidth @popoverArrowWidth 0;
- border-right-color: @popoverArrowColor;
- &:after {
- border-width: @popoverArrowOuterWidth @popoverArrowOuterWidth @popoverArrowOuterWidth 0;
- border-right-color: @popoverArrowOuterColor;
- bottom: -@popoverArrowOuterWidth;
- left: -1px;
- }
- }
- &.bottom .arrow {
- top: -@popoverArrowWidth;
- left: 50%;
- margin-left: -@popoverArrowWidth;
- border-width: 0 @popoverArrowWidth @popoverArrowWidth;
- border-bottom-color: @popoverArrowColor;
- &:after {
- border-width: 0 @popoverArrowOuterWidth @popoverArrowOuterWidth;
- border-bottom-color: @popoverArrowOuterColor;
- top: -1px;
- left: -@popoverArrowOuterWidth;
- }
- }
- &.left .arrow {
- top: 50%;
- right: -@popoverArrowWidth;
- margin-top: -@popoverArrowWidth;
- border-width: @popoverArrowWidth 0 @popoverArrowWidth @popoverArrowWidth;
- border-left-color: @popoverArrowColor;
- &:after {
- border-width: @popoverArrowOuterWidth 0 @popoverArrowOuterWidth @popoverArrowOuterWidth;
- border-left-color: @popoverArrowOuterColor;
- bottom: -@popoverArrowOuterWidth;
- right: -1px;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/progress-bars.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/progress-bars.less b/src/fauxton/assets/less/bootstrap/progress-bars.less
deleted file mode 100644
index 5e0c3dd..0000000
--- a/src/fauxton/assets/less/bootstrap/progress-bars.less
+++ /dev/null
@@ -1,122 +0,0 @@
-//
-// Progress bars
-// --------------------------------------------------
-
-
-// ANIMATIONS
-// ----------
-
-// Webkit
-@-webkit-keyframes progress-bar-stripes {
- from { background-position: 40px 0; }
- to { background-position: 0 0; }
-}
-
-// Firefox
-@-moz-keyframes progress-bar-stripes {
- from { background-position: 40px 0; }
- to { background-position: 0 0; }
-}
-
-// IE9
-@-ms-keyframes progress-bar-stripes {
- from { background-position: 40px 0; }
- to { background-position: 0 0; }
-}
-
-// Opera
-@-o-keyframes progress-bar-stripes {
- from { background-position: 0 0; }
- to { background-position: 40px 0; }
-}
-
-// Spec
-@keyframes progress-bar-stripes {
- from { background-position: 40px 0; }
- to { background-position: 0 0; }
-}
-
-
-
-// THE BARS
-// --------
-
-// Outer container
-.progress {
- overflow: hidden;
- height: @baseLineHeight;
- margin-bottom: @baseLineHeight;
- #gradient > .vertical(#f5f5f5, #f9f9f9);
- .box-shadow(inset 0 1px 2px rgba(0,0,0,.1));
- .border-radius(@baseBorderRadius);
-}
-
-// Bar of progress
-.progress .bar {
- width: 0%;
- height: 100%;
- color: @white;
- float: left;
- font-size: 12px;
- text-align: center;
- text-shadow: 0 -1px 0 rgba(0,0,0,.25);
- #gradient > .vertical(#149bdf, #0480be);
- .box-shadow(inset 0 -1px 0 rgba(0,0,0,.15));
- .box-sizing(border-box);
- .transition(width .6s ease);
-}
-.progress .bar + .bar {
- .box-shadow(~"inset 1px 0 0 rgba(0,0,0,.15), inset 0 -1px 0 rgba(0,0,0,.15)");
-}
-
-// Striped bars
-.progress-striped .bar {
- #gradient > .striped(#149bdf);
- .background-size(40px 40px);
-}
-
-// Call animation for the active one
-.progress.active .bar {
- -webkit-animation: progress-bar-stripes 2s linear infinite;
- -moz-animation: progress-bar-stripes 2s linear infinite;
- -ms-animation: progress-bar-stripes 2s linear infinite;
- -o-animation: progress-bar-stripes 2s linear infinite;
- animation: progress-bar-stripes 2s linear infinite;
-}
-
-
-
-// COLORS
-// ------
-
-// Danger (red)
-.progress-danger .bar, .progress .bar-danger {
- #gradient > .vertical(#ee5f5b, #c43c35);
-}
-.progress-danger.progress-striped .bar, .progress-striped .bar-danger {
- #gradient > .striped(#ee5f5b);
-}
-
-// Success (green)
-.progress-success .bar, .progress .bar-success {
- #gradient > .vertical(#62c462, #57a957);
-}
-.progress-success.progress-striped .bar, .progress-striped .bar-success {
- #gradient > .striped(#62c462);
-}
-
-// Info (teal)
-.progress-info .bar, .progress .bar-info {
- #gradient > .vertical(#5bc0de, #339bb9);
-}
-.progress-info.progress-striped .bar, .progress-striped .bar-info {
- #gradient > .striped(#5bc0de);
-}
-
-// Warning (orange)
-.progress-warning .bar, .progress .bar-warning {
- #gradient > .vertical(lighten(@orange, 15%), @orange);
-}
-.progress-warning.progress-striped .bar, .progress-striped .bar-warning {
- #gradient > .striped(lighten(@orange, 15%));
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/reset.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/reset.less b/src/fauxton/assets/less/bootstrap/reset.less
deleted file mode 100644
index 2abdee4..0000000
--- a/src/fauxton/assets/less/bootstrap/reset.less
+++ /dev/null
@@ -1,138 +0,0 @@
-//
-// Modals
-// Adapted from http://github.com/necolas/normalize.css
-// --------------------------------------------------
-
-
-// Display in IE6-9 and FF3
-// -------------------------
-
-article,
-aside,
-details,
-figcaption,
-figure,
-footer,
-header,
-hgroup,
-nav,
-section {
- display: block;
-}
-
-// Display block in IE6-9 and FF3
-// -------------------------
-
-audio,
-canvas,
-video {
- display: inline-block;
- *display: inline;
- *zoom: 1;
-}
-
-// Prevents modern browsers from displaying 'audio' without controls
-// -------------------------
-
-audio:not([controls]) {
- display: none;
-}
-
-// Base settings
-// -------------------------
-
-html {
- font-size: 100%;
- -webkit-text-size-adjust: 100%;
- -ms-text-size-adjust: 100%;
-}
-// Focus states
-a:focus {
- .tab-focus();
-}
-// Hover & Active
-a:hover,
-a:active {
- outline: 0;
-}
-
-// Prevents sub and sup affecting line-height in all browsers
-// -------------------------
-
-sub,
-sup {
- position: relative;
- font-size: 75%;
- line-height: 0;
- vertical-align: baseline;
-}
-sup {
- top: -0.5em;
-}
-sub {
- bottom: -0.25em;
-}
-
-// Img border in a's and image quality
-// -------------------------
-
-img {
- /* Responsive images (ensure images don't scale beyond their parents) */
- max-width: 100%; /* Part 1: Set a maxium relative to the parent */
- width: auto\9; /* IE7-8 need help adjusting responsive images */
- height: auto; /* Part 2: Scale the height according to the width, otherwise you get stretching */
-
- vertical-align: middle;
- border: 0;
- -ms-interpolation-mode: bicubic;
-}
-
-// Prevent max-width from affecting Google Maps
-#map_canvas img,
-.google-maps img {
- max-width: none;
-}
-
-// Forms
-// -------------------------
-
-// Font size in all browsers, margin changes, misc consistency
-button,
-input,
-select,
-textarea {
- margin: 0;
- font-size: 100%;
- vertical-align: middle;
-}
-button,
-input {
- *overflow: visible; // Inner spacing ie IE6/7
- line-height: normal; // FF3/4 have !important on line-height in UA stylesheet
-}
-button::-moz-focus-inner,
-input::-moz-focus-inner { // Inner padding and border oddities in FF3/4
- padding: 0;
- border: 0;
-}
-button,
-html input[type="button"], // Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` and `video` controls.
-input[type="reset"],
-input[type="submit"] {
- -webkit-appearance: button; // Corrects inability to style clickable `input` types in iOS.
- cursor: pointer; // Improves usability and consistency of cursor style between image-type `input` and others.
-}
-input[type="search"] { // Appearance in Safari/Chrome
- -webkit-box-sizing: content-box;
- -moz-box-sizing: content-box;
- box-sizing: content-box;
- -webkit-appearance: textfield;
-}
-input[type="search"]::-webkit-search-decoration,
-input[type="search"]::-webkit-search-cancel-button {
- -webkit-appearance: none; // Inner-padding issues in Chrome OSX, Safari 5
-}
-textarea {
- overflow: auto; // Remove vertical scrollbar in IE6-9
- vertical-align: top; // Readability and alignment cross-browser
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/responsive-1200px-min.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/responsive-1200px-min.less b/src/fauxton/assets/less/bootstrap/responsive-1200px-min.less
deleted file mode 100644
index 4f35ba6..0000000
--- a/src/fauxton/assets/less/bootstrap/responsive-1200px-min.less
+++ /dev/null
@@ -1,28 +0,0 @@
-//
-// Responsive: Large desktop and up
-// --------------------------------------------------
-
-
-@media (min-width: 1200px) {
-
- // Fixed grid
- #grid > .core(@gridColumnWidth1200, @gridGutterWidth1200);
-
- // Fluid grid
- #grid > .fluid(@fluidGridColumnWidth1200, @fluidGridGutterWidth1200);
-
- // Input grid
- #grid > .input(@gridColumnWidth1200, @gridGutterWidth1200);
-
- // Thumbnails
- .thumbnails {
- margin-left: -@gridGutterWidth1200;
- }
- .thumbnails > li {
- margin-left: @gridGutterWidth1200;
- }
- .row-fluid .thumbnails {
- margin-left: 0;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/responsive-767px-max.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/responsive-767px-max.less b/src/fauxton/assets/less/bootstrap/responsive-767px-max.less
deleted file mode 100644
index 1d5c123..0000000
--- a/src/fauxton/assets/less/bootstrap/responsive-767px-max.less
+++ /dev/null
@@ -1,193 +0,0 @@
-//
-// Responsive: Landscape phone to desktop/tablet
-// --------------------------------------------------
-
-
-@media (max-width: 767px) {
-
- // Padding to set content in a bit
- body {
- padding-left: 20px;
- padding-right: 20px;
- }
- // Negative indent the now static "fixed" navbar
- .navbar-fixed-top,
- .navbar-fixed-bottom,
- .navbar-static-top {
- margin-left: -20px;
- margin-right: -20px;
- }
- // Remove padding on container given explicit padding set on body
- .container-fluid {
- padding: 0;
- }
-
- // TYPOGRAPHY
- // ----------
- // Reset horizontal dl
- .dl-horizontal {
- dt {
- float: none;
- clear: none;
- width: auto;
- text-align: left;
- }
- dd {
- margin-left: 0;
- }
- }
-
- // GRID & CONTAINERS
- // -----------------
- // Remove width from containers
- .container {
- width: auto;
- }
- // Fluid rows
- .row-fluid {
- width: 100%;
- }
- // Undo negative margin on rows and thumbnails
- .row,
- .thumbnails {
- margin-left: 0;
- }
- .thumbnails > li {
- float: none;
- margin-left: 0; // Reset the default margin for all li elements when no .span* classes are present
- }
- // Make all grid-sized elements block level again
- [class*="span"],
- .uneditable-input[class*="span"], // Makes uneditable inputs full-width when using grid sizing
- .row-fluid [class*="span"] {
- float: none;
- display: block;
- width: 100%;
- margin-left: 0;
- .box-sizing(border-box);
- }
- .span12,
- .row-fluid .span12 {
- width: 100%;
- .box-sizing(border-box);
- }
- .row-fluid [class*="offset"]:first-child {
- margin-left: 0;
- }
-
- // FORM FIELDS
- // -----------
- // Make span* classes full width
- .input-large,
- .input-xlarge,
- .input-xxlarge,
- input[class*="span"],
- select[class*="span"],
- textarea[class*="span"],
- .uneditable-input {
- .input-block-level();
- }
- // But don't let it screw up prepend/append inputs
- .input-prepend input,
- .input-append input,
- .input-prepend input[class*="span"],
- .input-append input[class*="span"] {
- display: inline-block; // redeclare so they don't wrap to new lines
- width: auto;
- }
- .controls-row [class*="span"] + [class*="span"] {
- margin-left: 0;
- }
-
- // Modals
- .modal {
- position: fixed;
- top: 20px;
- left: 20px;
- right: 20px;
- width: auto;
- margin: 0;
- &.fade { top: -100px; }
- &.fade.in { top: 20px; }
- }
-
-}
-
-
-
-// UP TO LANDSCAPE PHONE
-// ---------------------
-
-@media (max-width: 480px) {
-
- // Smooth out the collapsing/expanding nav
- .nav-collapse {
- -webkit-transform: translate3d(0, 0, 0); // activate the GPU
- }
-
- // Block level the page header small tag for readability
- .page-header h1 small {
- display: block;
- line-height: @baseLineHeight;
- }
-
- // Update checkboxes for iOS
- input[type="checkbox"],
- input[type="radio"] {
- border: 1px solid #ccc;
- }
-
- // Remove the horizontal form styles
- .form-horizontal {
- .control-label {
- float: none;
- width: auto;
- padding-top: 0;
- text-align: left;
- }
- // Move over all input controls and content
- .controls {
- margin-left: 0;
- }
- // Move the options list down to align with labels
- .control-list {
- padding-top: 0; // has to be padding because margin collaspes
- }
- // Move over buttons in .form-actions to align with .controls
- .form-actions {
- padding-left: 10px;
- padding-right: 10px;
- }
- }
-
- // Medias
- // Reset float and spacing to stack
- .media .pull-left,
- .media .pull-right {
- float: none;
- display: block;
- margin-bottom: 10px;
- }
- // Remove side margins since we stack instead of indent
- .media-object {
- margin-right: 0;
- margin-left: 0;
- }
-
- // Modals
- .modal {
- top: 10px;
- left: 10px;
- right: 10px;
- }
- .modal-header .close {
- padding: 10px;
- margin: -10px;
- }
-
- // Carousel
- .carousel-caption {
- position: static;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/responsive-768px-979px.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/responsive-768px-979px.less b/src/fauxton/assets/less/bootstrap/responsive-768px-979px.less
deleted file mode 100644
index 8e8c486..0000000
--- a/src/fauxton/assets/less/bootstrap/responsive-768px-979px.less
+++ /dev/null
@@ -1,19 +0,0 @@
-//
-// Responsive: Tablet to desktop
-// --------------------------------------------------
-
-
-@media (min-width: 768px) and (max-width: 979px) {
-
- // Fixed grid
- #grid > .core(@gridColumnWidth768, @gridGutterWidth768);
-
- // Fluid grid
- #grid > .fluid(@fluidGridColumnWidth768, @fluidGridGutterWidth768);
-
- // Input grid
- #grid > .input(@gridColumnWidth768, @gridGutterWidth768);
-
- // No need to reset .thumbnails here since it's the same @gridGutterWidth
-
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/responsive-navbar.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/responsive-navbar.less b/src/fauxton/assets/less/bootstrap/responsive-navbar.less
deleted file mode 100644
index 2a0b0c0..0000000
--- a/src/fauxton/assets/less/bootstrap/responsive-navbar.less
+++ /dev/null
@@ -1,185 +0,0 @@
-//
-// Responsive: Navbar
-// --------------------------------------------------
-
-
-// TABLETS AND BELOW
-// -----------------
-@media (max-width: @navbarCollapseWidth) {
-
- // UNFIX THE TOPBAR
- // ----------------
- // Remove any padding from the body
- body {
- padding-top: 0;
- }
- // Unfix the navbars
- .navbar-fixed-top,
- .navbar-fixed-bottom {
- position: static;
- }
- .navbar-fixed-top {
- margin-bottom: @baseLineHeight;
- }
- .navbar-fixed-bottom {
- margin-top: @baseLineHeight;
- }
- .navbar-fixed-top .navbar-inner,
- .navbar-fixed-bottom .navbar-inner {
- padding: 5px;
- }
- .navbar .container {
- width: auto;
- padding: 0;
- }
- // Account for brand name
- .navbar .brand {
- padding-left: 10px;
- padding-right: 10px;
- margin: 0 0 0 -5px;
- }
-
- // COLLAPSIBLE NAVBAR
- // ------------------
- // Nav collapse clears brand
- .nav-collapse {
- clear: both;
- }
- // Block-level the nav
- .nav-collapse .nav {
- float: none;
- margin: 0 0 (@baseLineHeight / 2);
- }
- .nav-collapse .nav > li {
- float: none;
- }
- .nav-collapse .nav > li > a {
- margin-bottom: 2px;
- }
- .nav-collapse .nav > .divider-vertical {
- display: none;
- }
- .nav-collapse .nav .nav-header {
- color: @navbarText;
- text-shadow: none;
- }
- // Nav and dropdown links in navbar
- .nav-collapse .nav > li > a,
- .nav-collapse .dropdown-menu a {
- padding: 9px 15px;
- font-weight: bold;
- color: @navbarLinkColor;
- .border-radius(3px);
- }
- // Buttons
- .nav-collapse .btn {
- padding: 4px 10px 4px;
- font-weight: normal;
- .border-radius(@baseBorderRadius);
- }
- .nav-collapse .dropdown-menu li + li a {
- margin-bottom: 2px;
- }
- .nav-collapse .nav > li > a:hover,
- .nav-collapse .dropdown-menu a:hover {
- background-color: @navbarBackground;
- }
- .navbar-inverse .nav-collapse .nav > li > a,
- .navbar-inverse .nav-collapse .dropdown-menu a {
- color: @navbarInverseLinkColor;
- }
- .navbar-inverse .nav-collapse .nav > li > a:hover,
- .navbar-inverse .nav-collapse .dropdown-menu a:hover {
- background-color: @navbarInverseBackground;
- }
- // Buttons in the navbar
- .nav-collapse.in .btn-group {
- margin-top: 5px;
- padding: 0;
- }
- // Dropdowns in the navbar
- .nav-collapse .dropdown-menu {
- position: static;
- top: auto;
- left: auto;
- float: none;
- display: none;
- max-width: none;
- margin: 0 15px;
- padding: 0;
- background-color: transparent;
- border: none;
- .border-radius(0);
- .box-shadow(none);
- }
- .nav-collapse .open > .dropdown-menu {
- display: block;
- }
-
- .nav-collapse .dropdown-menu:before,
- .nav-collapse .dropdown-menu:after {
- display: none;
- }
- .nav-collapse .dropdown-menu .divider {
- display: none;
- }
- .nav-collapse .nav > li > .dropdown-menu {
- &:before,
- &:after {
- display: none;
- }
- }
- // Forms in navbar
- .nav-collapse .navbar-form,
- .nav-collapse .navbar-search {
- float: none;
- padding: (@baseLineHeight / 2) 15px;
- margin: (@baseLineHeight / 2) 0;
- border-top: 1px solid @navbarBackground;
- border-bottom: 1px solid @navbarBackground;
- .box-shadow(~"inset 0 1px 0 rgba(255,255,255,.1), 0 1px 0 rgba(255,255,255,.1)");
- }
- .navbar-inverse .nav-collapse .navbar-form,
- .navbar-inverse .nav-collapse .navbar-search {
- border-top-color: @navbarInverseBackground;
- border-bottom-color: @navbarInverseBackground;
- }
- // Pull right (secondary) nav content
- .navbar .nav-collapse .nav.pull-right {
- float: none;
- margin-left: 0;
- }
- // Hide everything in the navbar save .brand and toggle button */
- .nav-collapse,
- .nav-collapse.collapse {
- overflow: hidden;
- height: 0;
- }
- // Navbar button
- .navbar .btn-navbar {
- display: block;
- }
-
- // STATIC NAVBAR
- // -------------
- .navbar-static .navbar-inner {
- padding-left: 10px;
- padding-right: 10px;
- }
-
-
-}
-
-
-// DEFAULT DESKTOP
-// ---------------
-
-@media (min-width: @navbarCollapseDesktopWidth) {
-
- // Required to make the collapsing navbar work on regular desktops
- .nav-collapse.collapse {
- height: auto !important;
- overflow: visible !important;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/responsive-utilities.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/responsive-utilities.less b/src/fauxton/assets/less/bootstrap/responsive-utilities.less
deleted file mode 100644
index 2c3f6c1..0000000
--- a/src/fauxton/assets/less/bootstrap/responsive-utilities.less
+++ /dev/null
@@ -1,43 +0,0 @@
-//
-// Responsive: Utility classes
-// --------------------------------------------------
-
-
-// Hide from screenreaders and browsers
-// Credit: HTML5 Boilerplate
-.hidden {
- display: none;
- visibility: hidden;
-}
-
-// Visibility utilities
-
-// For desktops
-.visible-phone { display: none !important; }
-.visible-tablet { display: none !important; }
-.hidden-phone { }
-.hidden-tablet { }
-.hidden-desktop { display: none !important; }
-.visible-desktop { display: inherit !important; }
-
-// Tablets & small desktops only
-@media (min-width: 768px) and (max-width: 979px) {
- // Hide everything else
- .hidden-desktop { display: inherit !important; }
- .visible-desktop { display: none !important ; }
- // Show
- .visible-tablet { display: inherit !important; }
- // Hide
- .hidden-tablet { display: none !important; }
-}
-
-// Phones only
-@media (max-width: 767px) {
- // Hide everything else
- .hidden-desktop { display: inherit !important; }
- .visible-desktop { display: none !important; }
- // Show
- .visible-phone { display: inherit !important; } // Use inherit to restore previous behavior
- // Hide
- .hidden-phone { display: none !important; }
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/responsive.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/responsive.less b/src/fauxton/assets/less/bootstrap/responsive.less
deleted file mode 100644
index aa28baa..0000000
--- a/src/fauxton/assets/less/bootstrap/responsive.less
+++ /dev/null
@@ -1,48 +0,0 @@
-/*!
- * Bootstrap Responsive v2.2.1
- *
- * Copyright 2012 Twitter, Inc
- * Licensed under the Apache License v2.0
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Designed and built with all the love in the world @twitter by @mdo and @fat.
- */
-
-
-// Responsive.less
-// For phone and tablet devices
-// -------------------------------------------------------------
-
-
-// REPEAT VARIABLES & MIXINS
-// -------------------------
-// Required since we compile the responsive stuff separately
-
-@import "variables.less"; // Modify this for custom colors, font-sizes, etc
-@import "mixins.less";
-
-
-// RESPONSIVE CLASSES
-// ------------------
-
-@import "responsive-utilities.less";
-
-
-// MEDIA QUERIES
-// ------------------
-
-// Large desktops
-@import "responsive-1200px-min.less";
-
-// Tablets to regular desktops
-@import "responsive-768px-979px.less";
-
-// Phones to portrait tablets and narrow desktops
-@import "responsive-767px-max.less";
-
-
-// RESPONSIVE NAVBAR
-// ------------------
-
-// From 979px and below, show a button to toggle navbar contents
-@import "responsive-navbar.less";
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/scaffolding.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/scaffolding.less b/src/fauxton/assets/less/bootstrap/scaffolding.less
deleted file mode 100644
index 7a7496a..0000000
--- a/src/fauxton/assets/less/bootstrap/scaffolding.less
+++ /dev/null
@@ -1,52 +0,0 @@
-//
-// Scaffolding
-// --------------------------------------------------
-
-
-// Body reset
-// -------------------------
-
-body {
- margin: 0;
- font-family: @baseFontFamily;
- font-size: @baseFontSize;
- line-height: @baseLineHeight;
- color: @textColor;
- background-color: @bodyBackground;
-}
-
-
-// Links
-// -------------------------
-
-a {
- color: @linkColor;
- text-decoration: none;
-}
-a:hover {
- color: @linkColorHover;
- text-decoration: underline;
-}
-
-
-// Images
-// -------------------------
-
-// Rounded corners
-.img-rounded {
- .border-radius(6px);
-}
-
-// Add polaroid-esque trim
-.img-polaroid {
- padding: 4px;
- background-color: #fff;
- border: 1px solid #ccc;
- border: 1px solid rgba(0,0,0,.2);
- .box-shadow(0 1px 3px rgba(0,0,0,.1));
-}
-
-// Perfect circle
-.img-circle {
- .border-radius(500px); // crank the border-radius so it works with most reasonably sized images
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/sprites.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/sprites.less b/src/fauxton/assets/less/bootstrap/sprites.less
deleted file mode 100644
index 9cd2ae3..0000000
--- a/src/fauxton/assets/less/bootstrap/sprites.less
+++ /dev/null
@@ -1,193 +0,0 @@
-//
-// Sprites
-// --------------------------------------------------
-
-
-// ICONS
-// -----
-
-// All icons receive the styles of the <i> tag with a base class
-// of .i and are then given a unique class to add width, height,
-// and background-position. Your resulting HTML will look like
-// <i class="icon-inbox"></i>.
-
-// For the white version of the icons, just add the .icon-white class:
-// <i class="icon-inbox icon-white"></i>
-
-[class^="icon-"],
-[class*=" icon-"] {
- display: inline-block;
- width: 14px;
- height: 14px;
- .ie7-restore-right-whitespace();
- line-height: 14px;
- vertical-align: text-top;
- background-image: url("@{iconSpritePath}");
- background-position: 14px 14px;
- background-repeat: no-repeat;
- margin-top: 1px;
-}
-
-/* White icons with optional class, or on hover/active states of certain elements */
-.icon-white,
-.nav-pills > .active > a > [class^="icon-"],
-.nav-pills > .active > a > [class*=" icon-"],
-.nav-list > .active > a > [class^="icon-"],
-.nav-list > .active > a > [class*=" icon-"],
-.navbar-inverse .nav > .active > a > [class^="icon-"],
-.navbar-inverse .nav > .active > a > [class*=" icon-"],
-.dropdown-menu > li > a:hover > [class^="icon-"],
-.dropdown-menu > li > a:hover > [class*=" icon-"],
-.dropdown-menu > .active > a > [class^="icon-"],
-.dropdown-menu > .active > a > [class*=" icon-"],
-.dropdown-submenu:hover > a > [class^="icon-"],
-.dropdown-submenu:hover > a > [class*=" icon-"] {
- background-image: url("@{iconWhiteSpritePath}");
-}
-
-.icon-glass { background-position: 0 0; }
-.icon-music { background-position: -24px 0; }
-.icon-search { background-position: -48px 0; }
-.icon-envelope { background-position: -72px 0; }
-.icon-heart { background-position: -96px 0; }
-.icon-star { background-position: -120px 0; }
-.icon-star-empty { background-position: -144px 0; }
-.icon-user { background-position: -168px 0; }
-.icon-film { background-position: -192px 0; }
-.icon-th-large { background-position: -216px 0; }
-.icon-th { background-position: -240px 0; }
-.icon-th-list { background-position: -264px 0; }
-.icon-ok { background-position: -288px 0; }
-.icon-remove { background-position: -312px 0; }
-.icon-zoom-in { background-position: -336px 0; }
-.icon-zoom-out { background-position: -360px 0; }
-.icon-off { background-position: -384px 0; }
-.icon-signal { background-position: -408px 0; }
-.icon-cog { background-position: -432px 0; }
-.icon-trash { background-position: -456px 0; }
-
-.icon-home { background-position: 0 -24px; }
-.icon-file { background-position: -24px -24px; }
-.icon-time { background-position: -48px -24px; }
-.icon-road { background-position: -72px -24px; }
-.icon-download-alt { background-position: -96px -24px; }
-.icon-download { background-position: -120px -24px; }
-.icon-upload { background-position: -144px -24px; }
-.icon-inbox { background-position: -168px -24px; }
-.icon-play-circle { background-position: -192px -24px; }
-.icon-repeat { background-position: -216px -24px; }
-.icon-refresh { background-position: -240px -24px; }
-.icon-list-alt { background-position: -264px -24px; }
-.icon-lock { background-position: -287px -24px; } // 1px off
-.icon-flag { background-position: -312px -24px; }
-.icon-headphones { background-position: -336px -24px; }
-.icon-volume-off { background-position: -360px -24px; }
-.icon-volume-down { background-position: -384px -24px; }
-.icon-volume-up { background-position: -408px -24px; }
-.icon-qrcode { background-position: -432px -24px; }
-.icon-barcode { background-position: -456px -24px; }
-
-.icon-tag { background-position: 0 -48px; }
-.icon-tags { background-position: -25px -48px; } // 1px off
-.icon-book { background-position: -48px -48px; }
-.icon-bookmark { background-position: -72px -48px; }
-.icon-print { background-position: -96px -48px; }
-.icon-camera { background-position: -120px -48px; }
-.icon-font { background-position: -144px -48px; }
-.icon-bold { background-position: -167px -48px; } // 1px off
-.icon-italic { background-position: -192px -48px; }
-.icon-text-height { background-position: -216px -48px; }
-.icon-text-width { background-position: -240px -48px; }
-.icon-align-left { background-position: -264px -48px; }
-.icon-align-center { background-position: -288px -48px; }
-.icon-align-right { background-position: -312px -48px; }
-.icon-align-justify { background-position: -336px -48px; }
-.icon-list { background-position: -360px -48px; }
-.icon-indent-left { background-position: -384px -48px; }
-.icon-indent-right { background-position: -408px -48px; }
-.icon-facetime-video { background-position: -432px -48px; }
-.icon-picture { background-position: -456px -48px; }
-
-.icon-pencil { background-position: 0 -72px; }
-.icon-map-marker { background-position: -24px -72px; }
-.icon-adjust { background-position: -48px -72px; }
-.icon-tint { background-position: -72px -72px; }
-.icon-edit { background-position: -96px -72px; }
-.icon-share { background-position: -120px -72px; }
-.icon-check { background-position: -144px -72px; }
-.icon-move { background-position: -168px -72px; }
-.icon-step-backward { background-position: -192px -72px; }
-.icon-fast-backward { background-position: -216px -72px; }
-.icon-backward { background-position: -240px -72px; }
-.icon-play { background-position: -264px -72px; }
-.icon-pause { background-position: -288px -72px; }
-.icon-stop { background-position: -312px -72px; }
-.icon-forward { background-position: -336px -72px; }
-.icon-fast-forward { background-position: -360px -72px; }
-.icon-step-forward { background-position: -384px -72px; }
-.icon-eject { background-position: -408px -72px; }
-.icon-chevron-left { background-position: -432px -72px; }
-.icon-chevron-right { background-position: -456px -72px; }
-
-.icon-plus-sign { background-position: 0 -96px; }
-.icon-minus-sign { background-position: -24px -96px; }
-.icon-remove-sign { background-position: -48px -96px; }
-.icon-ok-sign { background-position: -72px -96px; }
-.icon-question-sign { background-position: -96px -96px; }
-.icon-info-sign { background-position: -120px -96px; }
-.icon-screenshot { background-position: -144px -96px; }
-.icon-remove-circle { background-position: -168px -96px; }
-.icon-ok-circle { background-position: -192px -96px; }
-.icon-ban-circle { background-position: -216px -96px; }
-.icon-arrow-left { background-position: -240px -96px; }
-.icon-arrow-right { background-position: -264px -96px; }
-.icon-arrow-up { background-position: -289px -96px; } // 1px off
-.icon-arrow-down { background-position: -312px -96px; }
-.icon-share-alt { background-position: -336px -96px; }
-.icon-resize-full { background-position: -360px -96px; }
-.icon-resize-small { background-position: -384px -96px; }
-.icon-plus { background-position: -408px -96px; }
-.icon-minus { background-position: -433px -96px; }
-.icon-asterisk { background-position: -456px -96px; }
-
-.icon-exclamation-sign { background-position: 0 -120px; }
-.icon-gift { background-position: -24px -120px; }
-.icon-leaf { background-position: -48px -120px; }
-.icon-fire { background-position: -72px -120px; }
-.icon-eye-open { background-position: -96px -120px; }
-.icon-eye-close { background-position: -120px -120px; }
-.icon-warning-sign { background-position: -144px -120px; }
-.icon-plane { background-position: -168px -120px; }
-.icon-calendar { background-position: -192px -120px; }
-.icon-random { background-position: -216px -120px; width: 16px; }
-.icon-comment { background-position: -240px -120px; }
-.icon-magnet { background-position: -264px -120px; }
-.icon-chevron-up { background-position: -288px -120px; }
-.icon-chevron-down { background-position: -313px -119px; } // 1px, 1px off
-.icon-retweet { background-position: -336px -120px; }
-.icon-shopping-cart { background-position: -360px -120px; }
-.icon-folder-close { background-position: -384px -120px; }
-.icon-folder-open { background-position: -408px -120px; width: 16px; }
-.icon-resize-vertical { background-position: -432px -119px; } // 1px, 1px off
-.icon-resize-horizontal { background-position: -456px -118px; } // 1px, 2px off
-
-.icon-hdd { background-position: 0 -144px; }
-.icon-bullhorn { background-position: -24px -144px; }
-.icon-bell { background-position: -48px -144px; }
-.icon-certificate { background-position: -72px -144px; }
-.icon-thumbs-up { background-position: -96px -144px; }
-.icon-thumbs-down { background-position: -120px -144px; }
-.icon-hand-right { background-position: -144px -144px; }
-.icon-hand-left { background-position: -168px -144px; }
-.icon-hand-up { background-position: -192px -144px; }
-.icon-hand-down { background-position: -216px -144px; }
-.icon-circle-arrow-right { background-position: -240px -144px; }
-.icon-circle-arrow-left { background-position: -264px -144px; }
-.icon-circle-arrow-up { background-position: -288px -144px; }
-.icon-circle-arrow-down { background-position: -312px -144px; }
-.icon-globe { background-position: -336px -144px; }
-.icon-wrench { background-position: -360px -144px; }
-.icon-tasks { background-position: -384px -144px; }
-.icon-filter { background-position: -408px -144px; }
-.icon-briefcase { background-position: -432px -144px; }
-.icon-fullscreen { background-position: -456px -144px; }
[23/26] Remove fauxton from 1.4.x branch.
Posted by dj...@apache.org.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/modules/documents/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/documents/routes.js b/src/fauxton/app/modules/documents/routes.js
deleted file mode 100644
index 9e68ae3..0000000
--- a/src/fauxton/app/modules/documents/routes.js
+++ /dev/null
@@ -1,367 +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.
-
-define([
- "app",
-
- "api",
-
- // Modules
- "modules/documents/views",
- "modules/databases/base"
-],
-
-function(app, FauxtonAPI, Documents, Databases) {
- // TODO: look at using:
- // var Documents = require("modules/documents/models_collections");
- // var Databases = require("modules/databases/module");
-
- var DocEditorRouteObject = FauxtonAPI.RouteObject.extend({
- layout: "one_pane",
-
- initialize: function(route, masterLayout, options) {
- var databaseName = options[0], docID = options[1];
-
- this.database = this.database || new Databases.Model({id: databaseName});
- this.doc = new Documents.Doc({
- _id: docID
- }, {
- database: this.database
- });
-
- this.tabsView = this.setView("#tabs", new Documents.Views.FieldEditorTabs({
- selected: "code_editor",
- model: this.doc
- }));
-
- },
-
- routes: {
- "database/:database/:doc/field_editor": "field_editor",
- "database/:database/:doc/code_editor": "code_editor",
- "database/:database/:doc": "code_editor"
- },
-
- events: {
- "route:reRenderDoc": "reRenderDoc",
- "route:duplicateDoc": "duplicateDoc"
- },
-
- crumbs: function() {
- return [
- {"name": "Databases", "link": "/_all_dbs"},
- {"name": this.database.id, "link": Databases.databaseUrl(this.database)},
- {"name": this.docID, "link": "#"}
- ];
- },
-
- code_editor: function (database, doc) {
- this.tabsView.updateSelected('code_editor');
-
- this.docView = this.setView("#dashboard-content", new Documents.Views.Doc({
- model: this.doc,
- database: this.database
- }));
- },
-
- reRenderDoc: function () {
- this.docView.forceRender();
- },
-
- field_editor: function(events) {
- this.tabsView.updateSelected('field_editor');
- this.docView = this.setView("#dashboard-content", new Documents.Views.DocFieldEditor({
- model: this.doc
- }));
- },
-
- duplicateDoc: function (newId) {
- var doc = this.doc,
- docView = this.docView,
- database = this.database;
-
- doc.copy(newId).then(function () {
- doc.set({_id: newId});
- docView.forceRender();
- FauxtonAPI.navigate('/database/' + database.id + '/' + newId, {trigger: true});
- FauxtonAPI.addNotification({
- msg: "Document has been duplicated."
- });
-
- }, function (error) {
- var errorMsg = "Could not duplicate document, reason: " + error.responseText + ".";
- FauxtonAPI.addNotification({
- msg: errorMsg,
- type: "error"
- });
- });
- },
-
- apiUrl: function() {
- return this.doc.url();
- }
- });
-
- var NewDocEditorRouteObject = DocEditorRouteObject.extend({
- initialize: function (route, masterLayout, options) {
- var databaseName = options[0];
-
- this.database = this.database || new Databases.Model({id: databaseName});
- this.doc = new Documents.NewDoc(null,{
- database: this.database
- });
-
- this.tabsView = this.setView("#tabs", new Documents.Views.FieldEditorTabs({
- selected: "code_editor",
- model: this.doc
- }));
-
- },
-
- routes: {
- "database/:database/new": "code_editor"
- },
-
- });
-
- var DocumentsRouteObject = FauxtonAPI.RouteObject.extend({
- layout: "with_tabs_sidebar",
-
- routes: {
- "database/:database/_all_docs(:extra)": "allDocs",
- "database/:database/_design/:ddoc/_view/:view": {
- route: "viewFn",
- roles: ['_admin']
- },
- "database/:database/new_view": "newViewEditor"
- },
-
- events: {
- "route:updateAllDocs": "updateAllDocsFromView",
- "route:updatePreviewDocs": "updateAllDocsFromPreview",
- "route:reloadDesignDocs": "reloadDesignDocs"
- },
-
- initialize: function (route, masterLayout, options) {
- var docOptions = app.getParams();
- docOptions.include_docs = true;
-
- this.databaseName = options[0];
-
- this.data = {
- database: new Databases.Model({id:this.databaseName})
- };
-
- this.data.designDocs = new Documents.AllDocs(null, {
- database: this.data.database,
- params: {startkey: '"_design"',
- endkey: '"_design1"',
- include_docs: true}
- });
-
- this.sidebar = this.setView("#sidebar-content", new Documents.Views.Sidebar({
- collection: this.data.designDocs,
- database: this.data.database
- }));
-
- this.setView("#tabs", new Documents.Views.Tabs({
- collection: this.data.designDocs,
- database: this.data.database
- }));
- },
-
- establish: function () {
- return this.data.designDocs.fetch();
- },
-
- allDocs: function(databaseName, options) {
- var docOptions = app.getParams(options);
-
- docOptions.include_docs = true;
- this.data.database.buildAllDocs(docOptions);
-
- if (docOptions.startkey && docOptions.startkey.indexOf('_design') > -1) {
- this.sidebar.setSelectedTab('design-docs');
- } else {
- this.sidebar.setSelectedTab('all-docs');
- }
-
- if (this.viewEditor) { this.viewEditor.remove(); }
-
- this.documentsView = this.setView("#dashboard-lower-content", new Documents.Views.AllDocsList({
- collection: this.data.database.allDocs
- }));
-
- this.crumbs = [
- {"name": "Databases", "link": "/_all_dbs"},
- {"name": this.data.database.id, "link": Databases.databaseUrl(this.data.database)}
- ];
-
- this.apiUrl = this.data.database.allDocs.url();
- },
-
- viewFn: function (databaseName, ddoc, view) {
- var params = app.getParams();
-
- view = view.replace(/\?.*$/,'');
-
- this.data.indexedDocs = new Documents.IndexCollection(null, {
- database: this.data.database,
- design: ddoc,
- view: view,
- params: params
- });
-
- var ddocInfo = {
- id: "_design/" + ddoc,
- currView: view,
- designDocs: this.data.designDocs
- };
-
- this.viewEditor = this.setView("#dashboard-upper-content", new Documents.Views.ViewEditor({
- model: this.data.database,
- ddocs: this.data.designDocs,
- viewName: view,
- params: params,
- newView: false,
- database: this.data.database,
- ddocInfo: ddocInfo
- }));
-
- this.documentsView = this.setView("#dashboard-lower-content", new Documents.Views.AllDocsList({
- database: this.data.database,
- collection: this.data.indexedDocs,
- nestedView: Documents.Views.Row,
- viewList: true,
- ddocInfo: ddocInfo
- }));
-
- this.sidebar.setSelectedTab(ddoc + '_' + view);
-
- this.crumbs = function () {
- return [
- {"name": "Databases", "link": "/_all_dbs"},
- {"name": this.data.database.id, "link": Databases.databaseUrl(this.data.database)},
- {"name": ddoc + "/" + view, "link": this.data.indexedDocs.url()}
- ];
- };
-
- this.apiUrl = this.data.indexedDocs.url();
- },
-
- newViewEditor: function () {
- var params = app.getParams();
-
- this.viewEditor = this.setView("#dashboard-upper-content", new Documents.Views.ViewEditor({
- ddocs: this.data.designDocs,
- params: params,
- database: this.data.database,
- newView: true
- }));
-
- this.sidebar.setSelectedTab('new-view');
- },
-
- updateAllDocsFromView: function (event) {
- var view = event.view,
- ddoc = event.ddoc;
-
- this.data.indexedDocs = new Documents.IndexCollection(null, {
- database: this.data.database,
- design: ddoc,
- view: view,
- params: app.getParams()
- });
-
- this.documentsView = this.setView("#dashboard-lower-content", new Documents.Views.AllDocsList({
- database: this.data.database,
- collection: this.data.indexedDocs,
- nestedView: Documents.Views.Row,
- viewList: true
- }));
- },
-
- updateAllDocsFromPreview: function (event) {
- var view = event.view,
- rows = event.rows,
- ddoc = event.ddoc;
-
- this.data.indexedDocs = new Documents.PouchIndexCollection(null, {
- database: this.data.database,
- design: ddoc,
- view: view,
- rows: rows
- });
-
- this.documentsView = this.setView("#dashboard-lower-content", new Documents.Views.AllDocsList({
- database: this.data.database,
- collection: this.data.indexedDocs,
- nestedView: Documents.Views.Row,
- viewList: true
- }));
- },
-
- reloadDesignDocs: function (event) {
- this.sidebar.forceRender();
-
- if (event && event.selectedTab) {
- this.sidebar.setSelectedTab(event.selectedTab);
- }
- }
- });
-
- var ChangesRouteObject = FauxtonAPI.RouteObject.extend({
- layout: "with_tabs",
-
- crumbs: function () {
- return [
- {"name": "Databases", "link": "/_all_dbs"},
- {"name": this.database.id, "link": Databases.databaseUrl(this.database)},
- {"name": "_changes", "link": "/_changes"}
- ];
- },
-
- routes: {
- "database/:database/_changes(:params)": "changes"
- },
-
- initialize: function (route, masterLayout, options) {
- this.databaseName = options[0];
- this.database = new Databases.Model({id: this.databaseName});
-
- var docOptions = app.getParams();
-
- this.database.buildChanges(docOptions);
-
- this.setView("#tabs", new Documents.Views.Tabs({
- collection: this.designDocs,
- database: this.database,
- active_id: 'changes'
- }));
- },
-
- changes: function (event) {
- this.setView("#dashboard-content", new Documents.Views.Changes({
- model: this.database
- }));
- },
-
- apiUrl: function() {
- return this.database.changes.url();
- }
-
- });
-
- Documents.RouteObjects = [DocEditorRouteObject, NewDocEditorRouteObject, DocumentsRouteObject, ChangesRouteObject];
-
- return Documents;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/modules/documents/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/documents/views.js b/src/fauxton/app/modules/documents/views.js
deleted file mode 100644
index 2ef4d41..0000000
--- a/src/fauxton/app/modules/documents/views.js
+++ /dev/null
@@ -1,1399 +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.
-
-define([
- "app",
-
- "api",
-
- "modules/documents/resources",
- "modules/pouchdb/base",
-
- // Libs
- "codemirror",
- "jshint",
-
- // Plugins
- "plugins/codemirror-javascript",
- "plugins/prettify"
-
-],
-
-function(app, FauxtonAPI, Documents, pouchdb, Codemirror, JSHint) {
- var Views = {};
-
- Views.Tabs = FauxtonAPI.View.extend({
- template: "templates/documents/tabs",
- initialize: function(options){
- this.collection = options.collection;
- this.database = options.database;
- this.active_id = options.active_id;
- },
-
- events: {
- "click #delete-database": "delete_database"
- },
-
- serialize: function () {
- return {
- // TODO make this not hard coded here
- changes_url: '#' + this.database.url('changes'),
- db_url: '#' + this.database.url('index') + '?limit=100'
- };
- },
-
- beforeRender: function(manage) {
- this.insertView("#search", new Views.SearchBox({
- collection: this.collection,
- database: this.database.id
- }));
- },
-
- afterRender: function () {
- if (this.active_id) {
- this.$('.active').removeClass('active');
- this.$('#'+this.active_id).addClass('active');
- }
- },
-
- delete_database: function (event) {
- event.preventDefault();
-
- var result = confirm("Are you sure you want to delete this database?");
-
- if (!result) { return; }
-
- return this.database.destroy().done(function () {
- app.router.navigate('/', {trigger: true});
- });
- }
- });
-
- Views.SearchBox = FauxtonAPI.View.extend({
- template: "templates/documents/search",
- tagName: "form",
- initialize: function(options){
- this.collection = options.collection;
- this.database = options.database;
- },
- afterRender: function(){
- var collection = this.collection;
- var form = this.$el;
- var searchbox = form.find("input#searchbox");
- var database = this.database;
-
- form.submit(function(evt){
- evt.preventDefault();
- var viewname = form.find("input#view").val().split('/');
- var url = "#database/" + database + "/_design/";
- url += viewname[0] + "/_view/" + viewname[1];
- if (searchbox.val() !== ""){
- // TODO: this'll need to work when val() is a number etc.
- url += '?startkey="' + searchbox.val() + '"';
- }
- FauxtonAPI.navigate(url);
- });
-
- searchbox.typeahead({
- source: function(query, process) {
- // TODO: include _all_docs and view keys somehow
- var views = _.map(collection.pluck('doc'), function(d){
- return _.map(_.keys(d.views), function(view){
- return d._id.split('/')[1] + "/" + view;
- });
- });
- return _.flatten(views);
- },
- minLength: 3,
- updater: function(item){
- // TODO: some way to return the original search box
- this.$element.removeClass('span12');
- this.$element.addClass('span6');
- this.$element.attr('placeholder', 'Search by view key');
- $('<span class="add-on span6">' + item +'</span>').insertBefore(this.$element);
- $('<input type="hidden" id="view" value="' + item +'"/>').insertBefore(this.$element);
- // Remove the type ahead for now
- $('.typehead').unbind();
- }
- });
- }
- });
-
- Views.UploadModal = FauxtonAPI.View.extend({
- template: "templates/documents/upload_modal",
-
- initialize: function (options) {
- _.bindAll(this);
- },
-
- events: {
- "click a#upload-btn": "uploadFile"
- },
-
- uploadFile: function (event) {
- event.preventDefault();
-
- var docRev = this.model.get('_rev'),
- $form = this.$('#file-upload');
-
- if (!docRev) {
- return this.set_error_msg('The document needs to be saved before adding an attachment.');
- }
-
- if ($('input[type="file"]')[0].files.length === 0) {
- return this.set_error_msg('Selected a file to be uploaded.');
- }
-
- this.$('#_rev').val(docRev);
-
- $form.ajaxSubmit({
- url: this.model.url(),
- type: 'POST',
- beforeSend: this.beforeSend,
- uploadProgress: this.uploadProgress,
- success: this.success,
- error: function () {
- console.log('ERR on upload', arguments);
- }
- });
- },
-
- success: function (resp) {
- var hideModal = this.hideModal,
- $form = this.$('#file-upload');
-
- FauxtonAPI.triggerRouteEvent('reRenderDoc');
- //slight delay to make this transistion a little more fluid and less jumpy
- setTimeout(function () {
- $form.clearForm();
- hideModal();
- }, 1000);
- },
-
- uploadProgress: function(event, position, total, percentComplete) {
- this.$('.bar').css({width: percentComplete + '%'});
- },
-
- beforeSend: function () {
- this.$('.progress').removeClass('hide');
- },
-
- showModal: function () {
- this.$('.bar').css({width: '0%'});
- this.$('.progress').addClass('hide');
- this.clear_error_msg();
- this.$('.modal').modal();
- // hack to get modal visible
- $('.modal-backdrop').css('z-index',1025);
- },
-
- hideModal: function () {
- this.$('.modal').modal('hide');
- },
-
- set_error_msg: function (msg) {
- var text;
- if (typeof(msg) == 'string') {
- text = msg;
- } else {
- text = JSON.parse(msg.responseText).reason;
- }
- this.$('#modal-error').text(text).removeClass('hide');
- },
-
- clear_error_msg: function () {
- this.$('#modal-error').text(' ').addClass('hide');
- },
-
- serialize: function () {
- return this.model.toJSON();
- }
- });
-
- Views.DuplicateDocModal = FauxtonAPI.View.extend({
- template: "templates/documents/duplicate_doc_modal",
-
- initialize: function () {
- _.bindAll(this);
- },
-
- events: {
- "click #duplicate-btn":"duplicate"
-
- },
-
- duplicate: function (event) {
- event.preventDefault();
- var newId = this.$('#dup-id').val();
-
- this.hideModal();
- FauxtonAPI.triggerRouteEvent('duplicateDoc', newId);
- },
-
- _showModal: function () {
- this.$('.bar').css({width: '0%'});
- this.$('.progress').addClass('hide');
- this.clear_error_msg();
- this.$('.modal').modal();
- // hack to get modal visible
- $('.modal-backdrop').css('z-index',1025);
- },
-
- showModal: function () {
- var showModal = this._showModal,
- setDefaultIdValue = this.setDefaultIdValue,
- uuid = new FauxtonAPI.UUID();
-
- uuid.fetch().then(function () {
- setDefaultIdValue(uuid.next());
- showModal();
- });
- },
-
- setDefaultIdValue: function (id) {
- this.$('#dup-id').val(id);
- },
-
- hideModal: function () {
- this.$('.modal').modal('hide');
- },
-
- set_error_msg: function (msg) {
- var text;
- if (typeof(msg) == 'string') {
- text = msg;
- } else {
- text = JSON.parse(msg.responseText).reason;
- }
- this.$('#modal-error').text(text).removeClass('hide');
- },
-
- clear_error_msg: function () {
- this.$('#modal-error').text(' ').addClass('hide');
- },
-
- serialize: function () {
- return this.model.toJSON();
- }
-
- });
-
- Views.FieldEditorTabs = FauxtonAPI.View.extend({
- template: "templates/documents/doc_field_editor_tabs",
-
- disableLoader: true,
-
- initialize: function(options) {
- this.selected = options.selected;
- },
-
- events: {
- "click button.delete": "destroy",
- "click button.duplicate": "duplicate",
- "click button.upload": "upload"
- },
-
- destroy: function(event) {
- if (!window.confirm("Are you sure you want to delete this doc?")) {
- return false;
- }
-
- var database = this.model.database;
-
- this.model.destroy().then(function(resp) {
- FauxtonAPI.addNotification({
- msg: "Succesfully destroyed your doc"
- });
- FauxtonAPI.navigate(database.url("index"));
- }, function(resp) {
- FauxtonAPI.addNotification({
- msg: "Failed to destroy your doc!",
- type: "error"
- });
- });
- },
-
- beforeRender: function () {
- this.uploadModal = this.setView('#upload-modal', new Views.UploadModal({model: this.model}));
- this.uploadModal.render();
-
- this.duplicateModal = this.setView('#duplicate-modal', new Views.DuplicateDocModal({model: this.model}));
- this.duplicateModal.render();
- },
-
- upload: function (event) {
- event.preventDefault();
- if (this.model.isNewDoc()) {
- FauxtonAPI.addNotification({
- msg: 'Please save the document before uploading an attachment.',
- type: 'warning'
- });
- return;
- }
- this.uploadModal.showModal();
- },
-
- duplicate: function(event) {
- event.preventDefault();
- this.duplicateModal.showModal();
- },
-
- updateSelected: function (selected) {
- this.selected = selected;
- this.$('.active').removeClass('active');
- this.$('#'+this.selected).addClass('active');
- },
-
- serialize: function() {
- var selected = this.selected;
- return {
- doc: this.model,
- isNewDoc: this.model.isNewDoc(),
- isSelectedClass: function(item) {
- return item && item === selected ? "active" : "";
- }
- };
- },
-
- establish: function() {
- return [this.model.fetch()];
- }
- });
-
- Views.Document = FauxtonAPI.View.extend({
- template: "templates/documents/all_docs_item",
- tagName: "tr",
- className: "all-docs-item",
-
- events: {
- "click button.delete": "destroy"
- },
-
- attributes: function() {
- return {
- "data-id": this.model.id
- };
- },
-
- serialize: function() {
- return {
- doc: this.model
- };
- },
-
- establish: function() {
- return [this.model.fetch()];
- },
-
- destroy: function(event) {
- event.preventDefault();
- var that = this;
-
- if (!window.confirm("Are you sure you want to delete this doc?")) {
- return false;
- }
-
- this.model.destroy().then(function(resp) {
- FauxtonAPI.addNotification({
- msg: "Succesfully destroyed your doc"
- });
- that.$el.fadeOut();
- that.model.collection.remove(that.id);
- }, function(resp) {
- FauxtonAPI.addNotification({
- msg: "Failed to destroy your doc!",
- type: "error"
- });
- });
- }
- });
-
- Views.Row = FauxtonAPI.View.extend({
- template: "templates/documents/index_row_docular",
- tagName: "tr",
-
- serialize: function() {
- return {
- doc: this.model
- };
- }
- });
-
- Views.IndexItem = FauxtonAPI.View.extend({
- template: "templates/documents/index_menu_item",
- tagName: "li",
-
- initialize: function(options){
- this.index = options.index;
- this.ddoc = options.ddoc;
- this.database = options.database;
- this.selected = !! options.selected;
- },
-
- serialize: function() {
- return {
- index: this.index,
- ddoc: this.ddoc,
- database: this.database,
- selected: this.selected
- };
- },
-
- afterRender: function() {
- if (this.selected) {
- $("#sidenav ul.nav-list li").removeClass("active");
- this.$el.addClass("active");
- }
- }
- });
-
- // TODO: Rename to reflect that this is a list of rows or documents
- Views.AllDocsList = FauxtonAPI.View.extend({
- template: "templates/documents/all_docs_list",
- events: {
- "click button.all": "selectAll",
- "click button.bulk-delete": "bulkDelete"
- },
-
- initialize: function(options){
- this.nestedView = options.nestedView || Views.Document;
- this.rows = {};
- this.viewList = !! options.viewList;
- this.database = options.database;
- if (options.ddocInfo) {
- this.designDocs = options.ddocInfo.designDocs;
- this.ddocID = options.ddocInfo.id;
- }
- this.newView = options.newView || false;
- },
-
- establish: function() {
- if (this.newView) { return null; }
-
- return this.collection.fetch().fail(function() {
- // TODO: handle error requests that slip through
- // This should just throw a notification, not break the page
- console.log("ERROR: ", arguments);
- });
- },
-
- selectAll: function(evt){
- $("input:checkbox").attr('checked', !$(evt.target).hasClass('active'));
- },
-
- serialize: function() {
- var totalRows = 0,
- updateSeq = false;
-
- if (!this.newView) {
- totalRows = this.collection.totalRows();
- updateSeq = this.collection.updateSeq();
- }
-
- var info = {
- updateSeq: updateSeq,
- totalRows: totalRows,
- numModels: this.collection.models.length,
- viewList: this.viewList,
- requestDuration: null
- };
-
- if (this.collection.requestDurationInString) {
- info.requestDuration = this.collection.requestDurationInString();
- }
-
- return info;
- },
-
- /*
- * TODO: this should be reconsidered
- * This currently performs delete operations on the model level,
- * when we could be using bulk docs with _deleted = true. Using
- * individual models is cleaner from a backbone standpoint, but
- * not from the couchdb api.
- * Also, the delete method is naive and leaves the body intact,
- * when we should switch the doc to only having id/rev/deleted.
- */
- bulkDelete: function() {
- var that = this;
- // yuck, data binding ftw?
- var eles = this.$el.find("input.row-select:checked").parents("tr.all-docs-item").map(function(e) { return $(this).attr("data-id"); }).get();
-
- if (!window.confirm("Are you sure you want to delete these " + eles.length + " docs?")) {
- return false;
- }
-
- _.each(eles, function(ele) {
- var model = this.collection.get(ele);
-
- model.destroy().then(function(resp) {
- that.rows[ele].$el.fadeOut();
-
- model.collection.remove(model.id);
- }, function(resp) {
- FauxtonAPI.addNotification({
- msg: "Failed to destroy your doc!",
- type: "error"
- });
- });
- }, this);
- },
-
- beforeRender: function() {
- this.collection.each(function(doc) {
- this.rows[doc.id] = this.insertView("table.all-docs tbody", new this.nestedView({
- model: doc
- }));
- }, this);
- },
-
- afterRender: function(){
- prettyPrint();
- }
- });
-
- Views.Doc = FauxtonAPI.View.extend({
- template: "templates/documents/doc",
-
- events: {
- "click button.save-doc": "saveDoc"
- },
-
- initialize: function (options) {
- this.database = options.database;
- },
-
- updateValues: function() {
- var notification;
- if (this.model.changedAttributes()) {
- notification = FauxtonAPI.addNotification({
- msg: "Document saved successfully.",
- type: "success",
- clear: true
- });
- this.editor.setValue(this.model.prettyJSON());
- }
- },
-
- establish: function() {
- return [this.model.fetch()];
- },
-
- saveDoc: function(event) {
- var json, notification,
- that = this,
- validDoc = this.getDocFromEditor();
-
- if (validDoc) {
- this.getDocFromEditor();
-
- notification = FauxtonAPI.addNotification({msg: "Saving document."});
-
- this.model.save().then(function () {
- FauxtonAPI.navigate('/database/' + that.database.id + '/' + that.model.id);
- }).fail(function(xhr) {
- var responseText = JSON.parse(xhr.responseText).reason;
- notification = FauxtonAPI.addNotification({
- msg: "Save failed: " + responseText,
- type: "error",
- clear: true
- });
- });
- } else {
- notification = FauxtonAPI.addNotification({
- msg: "Please fix the JSON errors and try again.",
- type: "error",
- selector: "#doc .errors-container"
- });
- }
- },
-
- getDocFromEditor: function () {
- if (!this.hasValidCode()) {
- return false;
- }
-
- json = JSON.parse(this.editor.getValue());
- this.model.clear({silent:true});
- this.model.set(json);
-
- return this.model;
- },
-
- hasValidCode: function() {
- return JSHINT(this.editor.getValue()) !== false;
- },
-
- runJSHint: function() {
- var json = this.editor.getValue();
- var output = JSHint(json);
-
- // Clear existing markers
- for (var i = 0, l = this.editor.lineCount(); i < l; i++) {
- this.editor.clearMarker(i);
- }
-
- if (output === false) {
- _.map(JSHint.errors, function(error) {
- var line = error.line - 1;
- var className = "view-code-error-line-" + line;
- this.editor.setMarker(line, "ā", "view-code-error "+className);
-
- setTimeout(function() {
- $(".CodeMirror ."+className).tooltip({
- title: "ERROR: " + error.reason
- });
- }, 0);
- }, this);
- }
- },
-
- serialize: function() {
- return {
- doc: this.model,
- attachments: this.getAttachments()
- };
- },
-
- getAttachments: function () {
- var attachments = this.model.get('_attachments');
-
- if (!attachments) { return false; }
-
- return _.map(attachments, function (att, key) {
- return {
- fileName: key,
- size: att.length,
- contentType: att.content_type,
- url: this.model.url() + '/' + key
- };
- }, this);
- },
-
- afterRender: function() {
- this.model.on("sync", this.updateValues, this);
- var that = this;
- this.editor = Codemirror.fromTextArea(this.$el.find("textarea.doc-code").get()[0], {
- mode: "application/json",
- json: false,
- lineNumbers: true,
- matchBrackets: true,
- lineWrapping: true,
- onChange: function() {
- try {
- that.runJSHint();
- } catch (e) {
- console.log('ERROR for jshint',e);
- }
- },
- extraKeys: {
- "Ctrl-S": function(instance) { that.saveDoc(); },
- "Ctrl-/": "undo"
- }
- });
- }
- });
-
- Views.DocFieldEditor = FauxtonAPI.View.extend({
- template: "templates/documents/doc_field_editor",
-
- events: {
- "click button.save": "saveDoc"
- },
-
- saveDoc: function(event) {
- FauxtonAPI.addNotification({
- type: "warning",
- msg: "Save functionality coming soon."
- });
- },
-
- serialize: function() {
- return {
- doc: this.getModelWithoutAttachments(),
- attachments: this.getAttachments()
- };
- },
-
- getModelWithoutAttachments: function() {
- var model = this.model.toJSON();
- delete model._attachments;
- return model;
- },
-
- getAttachments: function () {
- var attachments = this.model.get('_attachments');
-
- if (!attachments) { return []; }
-
- return _.map(attachments, function (att, key) {
- return {
- fileName: key,
- size: att.length,
- contentType: att.content_type,
- url: this.model.url() + '/' + key
- };
- }, this);
- },
-
- establish: function() {
- return [this.model.fetch()];
- }
- });
-
- //TODO split this into two smaller views, one for advance query options and other for index editing
- Views.ViewEditor = FauxtonAPI.View.extend({
- template: "templates/documents/view_editor",
- builtinReduces: ['_sum', '_count', '_stats'],
-
- events: {
- "click button.save": "saveView",
- "click button.preview": "previewView",
- "click button.delete": "deleteView",
- "change select#reduce-function-selector": "updateReduce",
- "change form.view-query-update input": "updateFilters",
- "change form.view-query-update select": "updateFilters",
- "change select#ddoc": "updateDesignDoc",
- "submit form.view-query-update": "updateView"
- },
-
- langTemplates: {
- "javascript": {
- map: "function(doc) {\n emit(doc.id, 1);\n}",
- reduce: "function(keys, values, rereduce){\n if (rereduce){\n return sum(values);\n } else {\n return values.length;\n }\n}"
- }
- },
-
- defaultLang: "javascript",
-
- initialize: function(options) {
- this.newView = options.newView || false;
- this.ddocs = options.ddocs;
- this.params = options.params;
- this.database = options.database;
- if (this.newView) {
- this.viewName = 'newView';
- } else {
- this.ddocID = options.ddocInfo.id;
- this.viewName = options.viewName;
- this.ddocInfo = new Documents.DdocInfo({_id: this.ddocID},{database: this.database});
- }
- },
-
- establish: function () {
- if (this.ddocInfo) {
- return this.ddocInfo.fetch();
- }
- },
-
- updateDesignDoc: function () {
-
- if (this.$('#ddoc :selected').prop('id') === 'new-doc') {
- this.$('#new-ddoc-section').show();
-
- } else {
- this.$('#new-ddoc-section').hide();
- }
-
- },
-
- updateValues: function() {
- var notification;
- if (this.model.changedAttributes()) {
- notification = FauxtonAPI.addNotification({
- msg: "Document saved successfully.",
- type: "success",
- clear: true
- });
- this.editor.setValue(this.model.prettyJSON());
- }
- },
-
- updateReduce: function(event) {
- var $ele = $("#reduce-function-selector");
- var $reduceContainer = $(".control-group.reduce-function");
- if ($ele.val() == "CUSTOM") {
- $reduceContainer.show();
- } else {
- $reduceContainer.hide();
- }
- },
-
- queryParams: function () {
- var $form = $(".view-query-update");
- // Ignore params without a value
- var params = _.filter($form.serializeArray(), function(param) {
- return param.value;
- });
-
- // Validate *key* params to ensure they're valid JSON
- var keyParams = ["key","keys","startkey","endkey"];
- var errorParams = _.filter(params, function(param) {
- if (_.contains(keyParams, param.name)) {
- try {
- JSON.parse(param.value);
- return false;
- } catch(e) {
- return true;
- }
- } else {
- return false;
- }
- });
-
- return {params: params, errorParams: errorParams};
- },
-
- deleteView: function (event) {
- event.preventDefault();
-
- if (this.newView) { return alert('Cannot delete a new view.'); }
- if (!confirm('Are you sure you want to delete this view?')) {return;}
-
- var that = this,
- promise,
- viewName = this.$('#index-name').val(),
- ddocName = this.$('#ddoc :selected').val(),
- ddoc = this.getCurrentDesignDoc();
-
- ddoc.removeDdocView(viewName);
-
- if (ddoc.hasViews()) {
- promise = ddoc.save();
- } else {
- promise = ddoc.destroy();
- }
-
- promise.then(function () {
- FauxtonAPI.navigate('/database/' + that.database.id + '/_all_docs?limit=100');
- FauxtonAPI.triggerRouteEvent('reloadDesignDocs');
- });
- },
-
- updateView: function(event) {
- event.preventDefault();
-
- if (this.newView) { return alert('Please save this new view before querying it.'); }
-
- var paramInfo = this.queryParams(),
- errorParams = paramInfo.errorParams,
- params = paramInfo.params;
-
- if (_.any(errorParams)) {
- _.map(errorParams, function(param) {
-
- // TODO: Where to add this error?
- // bootstrap wants the error on a control-group div, but we're not using that
- //$('form.view-query-update input[name='+param+'], form.view-query-update select[name='+param+']').addClass('error');
-
- return FauxtonAPI.addNotification({
- msg: "JSON Parse Error on field: "+param.name,
- type: "error",
- selector: ".view.show .all-docs-list.errors-container"
- });
- });
-
- FauxtonAPI.addNotification({
- msg: "Make sure that strings are properly quoted and any other values are valid JSON structures",
- type: "warning",
- selector: ".view.show .all-docs-list.errors-container"
- });
-
- return false;
- }
-
- var fragment = window.location.hash.replace(/\?.*$/, '');
- fragment = fragment + '?' + $.param(params);
- FauxtonAPI.navigate(fragment, {trigger: false});
-
- FauxtonAPI.triggerRouteEvent('updateAllDocs', {ddoc: this.ddocID, view: this.viewName});
- },
-
- updateFilters: function(event) {
- event.preventDefault();
- var $ele = $(event.currentTarget);
- var name = $ele.attr('name');
- this.updateFiltersFor(name, $ele);
- },
-
- updateFiltersFor: function(name, $ele) {
- var $form = $ele.parents("form.view-query-update:first");
- switch (name) {
- // Reduce constraints
- // - Can't include_docs for reduce=true
- // - can't include group_level for reduce=false
- case "reduce":
- if ($ele.prop('checked') === true) {
- if ($form.find("input[name=include_docs]").prop("checked") === true) {
- $form.find("input[name=include_docs]").prop("checked", false);
- var notification = FauxtonAPI.addNotification({
- msg: "include_docs has been disabled as you cannot include docs on a reduced view",
- type: "warn",
- selector: ".view.show .all-docs-list.errors-container"
- });
- }
- $form.find("input[name=include_docs]").prop("disabled", true);
- $form.find("select[name=group_level]").prop("disabled", false);
- } else {
- $form.find("select[name=group_level]").prop("disabled", true);
- $form.find("input[name=include_docs]").prop("disabled", false);
- }
- break;
- case "include_docs":
- break;
- }
- },
-
- previewView: function(event) {
- var that = this,
- mapVal = this.mapEditor.getValue(),
- reduceVal = this.reduceVal(),
- paramsArr = this.queryParams().params;
-
- var params = _.reduce(paramsArr, function (params, param) {
- params[param.name] = param.value;
- return params;
- }, {reduce: false});
-
- event.preventDefault();
-
- FauxtonAPI.addNotification({
- msg: "<strong>Warning!</strong> Preview executes the Map/Reduce functions in your browser, and may behave differently from CouchDB.",
- type: "warning",
- selector: "#define-view .errors-container",
- fade: true
- });
-
- var promise = FauxtonAPI.Deferred();
-
- if (!this.database.allDocs) {
- this.database.buildAllDocs({limit: "100", include_docs: true});
- promise = this.database.allDocs.fetch();
- } else {
- promise.resolve();
- }
-
- promise.then(function () {
- params.docs = that.database.allDocs.map(function (model) { return model.get('doc');});
-
- var queryPromise = pouchdb.runViewQuery({map: mapVal, reduce: reduceVal}, params);
- queryPromise.then(function (results) {
- FauxtonAPI.triggerRouteEvent('updatePreviewDocs', {rows: results.rows, ddoc: that.getCurrentDesignDoc().id, view: that.viewName});
- });
- });
- },
-
- saveView: function(event) {
- var json, notification,
- that = this;
-
- event.preventDefault();
-
- if (this.hasValidCode()) {
- var mapVal = this.mapEditor.getValue(),
- reduceVal = this.reduceVal(),
- viewName = this.$('#index-name').val(),
- ddoc = this.getCurrentDesignDoc(),
- ddocName = ddoc.id;
-
- this.viewName = viewName;
-
- notification = FauxtonAPI.addNotification({
- msg: "Saving document.",
- selector: "#define-view .errors-container"
- });
-
- ddoc.setDdocView(viewName, mapVal, reduceVal);
-
- ddoc.save().then(function () {
- FauxtonAPI.addNotification({
- msg: "View has been saved.",
- type: "success",
- selector: "#define-view .errors-container"
- });
-
- if (that.newView) {
- var fragment = '/database/' + that.database.id +'/' + ddocName + '/_view/' + viewName;
-
- FauxtonAPI.navigate(fragment, {trigger: false});
- FauxtonAPI.triggerRouteEvent('reloadDesignDocs',{selectedTab: ddocName.replace('_design/','') + '_' + viewName});
-
- that.newView = false;
- }
-
- FauxtonAPI.triggerRouteEvent('updateAllDocs', {ddoc: ddocName, view: viewName});
-
- }, function(xhr) {
- var responseText = JSON.parse(xhr.responseText).reason;
- notification = FauxtonAPI.addNotification({
- msg: "Save failed: " + responseText,
- type: "error",
- clear: true
- });
- });
- } else {
- notification = FauxtonAPI.addNotification({
- msg: "Please fix the Javascript errors and try again.",
- type: "error",
- selector: "#define-view .errors-container"
- });
- }
- },
-
- getCurrentDesignDoc: function () {
- if (this.newDesignDoc()) {
- var doc = {
- _id: '_design/' + this.$('#new-ddoc').val(),
- views: {},
- language: "javascript"
- };
- return new Documents.Doc(doc, {database: this.database});
- } else {
- var ddocName = this.$('#ddoc').val();
- return this.ddocs.find(function (ddoc) {
- return ddoc.id === ddocName;
- }).dDocModel();
- }
-
- },
-
- newDesignDoc: function () {
- return this.$('#ddoc :selected').prop('id') === 'new-doc';
- },
-
- isCustomReduceEnabled: function() {
- return $("#reduce-function-selector").val() == "CUSTOM";
- },
-
- reduceVal: function() {
- var reduceOption = this.$('#reduce-function-selector :selected').val(),
- reduceVal = "";
-
- if (reduceOption === 'CUSTOM') {
- reduceVal = this.reduceEditor.getValue();
- } else if ( reduceOption !== 'NONE') {
- reduceVal = reduceOption;
- }
-
- return reduceVal;
- },
-
- hasValidCode: function() {
- return _.every(["mapEditor", "reduceEditor"], function(editorName) {
- var editor = this[editorName];
- if (editorName == "reduceEditor" && ! this.isCustomReduceEnabled()) {
- return true;
- } else if (JSHINT(editor.getValue()) !== false) {
- return true;
- } else {
- // By default CouchDB view functions don't pass lint
- return _.every(JSHINT.errors, function(error) {
- return FauxtonAPI.isIgnorableError(error.raw);
- });
- }
- }, this);
- },
-
- runJSHint: function(editorName) {
- var editor = this[editorName];
- var json = editor.getValue();
- var output = JSHint(json);
-
- // Clear existing markers
- for (var i = 0, l = editor.lineCount(); i < l; i++) {
- editor.clearMarker(i);
- }
-
- if (output === false) {
- _.map(JSHint.errors, function(error) {
- // By default CouchDB view functions don't pass lint
- if (FauxtonAPI.isIgnorableError(error.reason)) return true;
-
- var line = error.line - 1;
- var className = "view-code-error-line-" + line;
- editor.setMarker(line, "ā", "view-code-error "+className);
-
- setTimeout(function() {
- $(".CodeMirror ."+className).tooltip({
- title: "ERROR: " + error.reason
- });
- }, 0);
- }, this);
- }
- },
-
- serialize: function() {
- return {
- ddocs: this.ddocs,
- ddoc: this.model,
- ddocName: this.model.id,
- viewName: this.viewName,
- reduceFunStr: this.reduceFunStr,
- hasReduce: this.reduceFunStr,
- isCustomReduce: this.hasCustomReduce(),
- newView: this.newView,
- langTemplates: this.langTemplates.javascript
- };
- },
-
- hasCustomReduce: function() {
- return this.reduceFunStr && ! _.contains(this.builtinReduces, this.reduceFunStr);
- },
-
- beforeRender: function () {
-
- if (this.newView) {
- this.reduceFunStr = '_sum';
- if (this.ddocs.length === 0) {
- this.model = new Documents.Doc(null, {database: this.database});
- } else {
- this.model = this.ddocs.first().dDocModel();
- }
- this.ddocID = this.model.id;
- } else {
- this.model = this.ddocs.get(this.ddocID).dDocModel();
- this.reduceFunStr = this.model.viewHasReduce(this.viewName);
- this.setView('#ddoc-info', new Views.DdocInfo({model: this.ddocInfo }));
- }
- },
-
- afterRender: function() {
- var that = this;
- var mapFun = $("#map-function");
- var reduceFun = $("#reduce-function");
- if (this.newView) {
- mapFun.val(this.langTemplates[this.defaultLang].map);
- reduceFun.val(this.langTemplates[this.defaultLang].reduce);
- }
-
- this.updateDesignDoc();
-
- this.mapEditor = Codemirror.fromTextArea(mapFun.get()[0], {
- mode: "javascript",
- lineNumbers: true,
- matchBrackets: true,
- lineWrapping: true,
- onChange: function() {
- try {
- that.runJSHint("mapEditor");
- } catch (e) {
- console.log('ERROR for jshint',e);
- }
- },
- extraKeys: {
- "Ctrl-S": function(instance) { that.saveView(); },
- "Ctrl-/": "undo"
- }
- });
- this.reduceEditor = Codemirror.fromTextArea(reduceFun.get()[0], {
- mode: "javascript",
- lineNumbers: true,
- matchBrackets: true,
- lineWrapping: true,
- onChange: function() {
- try {
- that.runJSHint("reduceEditor");
- } catch (e) {
- console.log('ERROR for jshint',e);
- }
- },
- extraKeys: {
- "Ctrl-S": function(instance) { that.saveView(); },
- "Ctrl-/": "undo"
- }
- });
- // HACK: this should be in the html
- // but CodeMirror's head explodes and it won't set the hight properly.
- // So render it first, set the editor, then hide.
- if ( ! this.hasCustomReduce()) {
- $(".control-group.reduce-function").hide();
- }
-
- if (this.params) {
- var $form = this.$el.find("form.view-query-update");
- _.each(this.params, function(val, key) {
- var $ele;
- switch (key) {
- case "limit":
- case "group_level":
- $form.find("select[name='"+key+"']").val(val);
- break;
- case "include_docs":
- case "stale":
- case "descending":
- case "inclusive_end":
- $form.find("input[name='"+key+"']").prop('checked', true);
- break;
- case "reduce":
- $ele = $form.find("input[name='"+key+"']");
- if (val == "true") {
- $ele.prop('checked', true);
- }
- this.updateFiltersFor(key, $ele);
- break;
- default:
- $form.find("input[name='"+key+"']").val(val);
- break;
- }
- }, this);
- }
-
- }
- });
-
- Views.Sidebar = FauxtonAPI.View.extend({
- template: "templates/documents/sidebar",
- events: {
- "click a.new#index": "newIndex",
- "submit #jump-to-doc": "jumpToDoc"
- },
-
- initialize: function(options) {
- this.database = options.database;
- if (options.ddocInfo) {
- this.ddocID = options.ddocInfo.id;
- this.currView = options.ddocInfo.currView;
- }
- },
-
- serialize: function() {
- return {
- index: [1,2,3],
- view: [1,2],
- database: this.collection.database
- };
- },
-
- newIndex: function(event){
- event.preventDefault();
- $.contribute(
- 'Create a new view.',
- 'app/addons/documents/views.js'
- );
- },
-
- toggleView: function(event){
- event.preventDefault();
- $.contribute(
- 'Filter data by type or view',
- 'app/addons/databases/views.js'
- );
- url = event.currentTarget.href.split('#')[1];
- app.router.navigate(url);
- },
-
- jumpToDoc: function (event) {
- event.preventDefault();
- var docId = this.$('#jump-to-doc-id').val();
- FauxtonAPI.navigate('/database/' + this.database.id +'/' + docId, {trigger: true});
- },
-
- buildIndexList: function(collection, selector, design){
-
- _.each(_.keys(collection), function(key){
- var selected = this.ddocID == "_design/"+design;
- this.insertView("ul.nav." + selector, new Views.IndexItem({
- ddoc: design,
- index: key,
- database: this.collection.database.id,
- selected: selected && key == this.currView
- }));
- }, this);
- },
-
- beforeRender: function(manage) {
- this.collection.each(function(design) {
- if (design.has('doc')){
- var ddoc = design.id.split('/')[1];
- if (design.get('doc').views){
- this.buildIndexList(design.get('doc').views, "views", ddoc);
- }
- }
- }, this);
- },
-
- afterRender: function () {
- if (this.selectedTab) {
- this.setSelectedTab(this.selectedTab);
- }
- },
-
- setSelectedTab: function (selectedTab) {
- this.selectedTab = selectedTab;
- this.$('li').removeClass('active');
- this.$('#' + selectedTab).parent().addClass('active');
- }
-
- });
-
- Views.Indexed = FauxtonAPI.View.extend({});
-
- Views.Changes = FauxtonAPI.View.extend({
- template: "templates/documents/changes",
-
- establish: function() {
- return [ this.model.changes.fetch()];
- },
-
- serialize: function () {
- return {
- changes: this.model.changes.toJSON(),
- database: this.model
- };
- },
-
- afterRender: function(){
- prettyPrint();
- }
- });
-
- Views.DdocInfo = FauxtonAPI.View.extend({
- template: "templates/documents/ddoc_info",
-
- initialize: function (options) {
- this.refreshTime = options.refreshTime || 5000;
- this.listenTo(this.model, 'change', this.render);
- },
-
- serialize: function () {
- return {
- view_index: this.model.get('view_index')
- };
- },
-
- afterRender: function () {
- this.startRefreshInterval();
- },
-
- startRefreshInterval: function () {
- var model = this.model;
-
- // Interval already set
- if (this.intervalId) { return ; }
-
- this.intervalId = setInterval(function () {
- model.fetch();
- }, this.refreshTime);
- },
-
- stopRefreshInterval: function () {
- clearInterval(this.intervalId);
- },
-
- cleanup: function () {
- this.stopRefreshInterval();
- }
- });
-
- Documents.Views = Views;
- return Documents;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/modules/fauxton/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/fauxton/base.js b/src/fauxton/app/modules/fauxton/base.js
deleted file mode 100644
index 716e9e7..0000000
--- a/src/fauxton/app/modules/fauxton/base.js
+++ /dev/null
@@ -1,191 +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.
-
-define([
- "app",
- // Libs
- "backbone"
-
-],
-
-function(app, Backbone) {
- var Fauxton = app.module();
-
- Fauxton.Breadcrumbs = Backbone.View.extend({
- template: "templates/fauxton/breadcrumbs",
-
- serialize: function() {
- var crumbs = _.clone(this.crumbs);
- return {
- crumbs: crumbs
- };
- },
-
- initialize: function(options) {
- this.crumbs = options.crumbs;
- }
- });
-
- Fauxton.VersionInfo = Backbone.Model.extend({
- url: app.host
- });
-
- // TODO: this View should extend from FauxtonApi.View.
- // Chicken and egg problem, api.js extends fauxton/base.js.
- // Need to sort the loading order.
- Fauxton.Footer = Backbone.View.extend({
- template: "templates/fauxton/footer",
-
- initialize: function() {
- this.versionInfo = new Fauxton.VersionInfo();
- },
-
- establish: function() {
- return [this.versionInfo.fetch()];
- },
-
- serialize: function() {
- return {
- version: this.versionInfo.get("version")
- };
- }
- });
-
- Fauxton.NavBar = Backbone.View.extend({
- template: "templates/fauxton/nav_bar",
- // TODO: can we generate this list from the router?
- navLinks: [
- {href:"#/_all_dbs", title:"Databases"}
- ],
-
- initialize: function() {
- },
-
- serialize: function() {
- return {navLinks: this.navLinks};
- },
-
- addLink: function(link) {
- if (link.top){
- this.navLinks.unshift(link);
- } else {
- this.navLinks.push(link);
- }
- this.trigger("link:add");
-
- this.render();
- },
-
- beforeRender: function () {
- this.addLinkViews();
- },
-
- addLinkViews: function () {
- var that = this;
-
- _.each(this.navLinks, function (link) {
- if (!link.view) { return; }
-
- //TODO check if establish is a function
- var establish = link.establish || [];
- $.when.apply(null, establish).then( function () {
- that.insertView('#nav-links', link.view).render();
- });
- }, this);
- }
-
- // TODO: ADD ACTIVE CLASS
- });
-
- Fauxton.ApiBar = Backbone.View.extend({
- template: "templates/fauxton/api_bar",
- endpoint: '_all_docs',
-
- serialize: function() {
- return {endpoint: this.endpoint};
- },
-
- update: function(endpoint) {
- // Take endpoint and write it into the api bar.
- console.log('ApiBar endpoint: ' + endpoint);
- this.endpoint = endpoint;
- this.render();
- }
-
- });
-
- Fauxton.Notification = Backbone.View.extend({
- fadeTimer: 5000,
-
- initialize: function(options) {
- this.msg = options.msg;
- this.type = options.type || "info";
- this.selector = options.selector;
- this.fade = options.fade === undefined ? true : options.fade;
- this.clear = options.clear;
- this.data = options.data || "";
- this.template = options.template || "templates/fauxton/notification";
- },
-
- serialize: function() {
- return {
- data: this.data,
- msg: this.msg,
- type: this.type
- };
- },
-
- delayedFade: function() {
- var that = this;
- if (this.fade) {
- setTimeout(function() {
- that.$el.fadeOut();
- }, this.fadeTimer);
- }
- },
-
- renderNotification: function(selector) {
- selector = selector || this.selector;
- if (this.clear) {
- $(selector).html('');
- }
- this.render().view.$el.appendTo(selector);
- this.delayedFade();
- return this;
- }
- });
-
- Fauxton.Pagination = Backbone.View.extend({
- template: "templates/fauxton/pagination",
-
- initialize: function(options) {
- this.page = options.page;
- this.perPage = options.perPage;
- this.total = options.total;
- this.totalPages = Math.ceil(this.total / this.perPage);
- this.urlFun = options.urlFun;
-
- },
-
- serialize: function() {
- return {
- page: this.page,
- perPage: this.perPage,
- total: this.total,
- totalPages: this.totalPages,
- urlFun: this.urlFun
- };
- }
- });
-
- return Fauxton;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/modules/fauxton/layout.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/fauxton/layout.js b/src/fauxton/app/modules/fauxton/layout.js
deleted file mode 100644
index d964b7b..0000000
--- a/src/fauxton/app/modules/fauxton/layout.js
+++ /dev/null
@@ -1,96 +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.
-
-define(["backbone"],
-
-function(Backbone) {
-
- // A wrapper of the main Backbone.layoutmanager
- // Allows the main layout of the page to be changed by any plugin.
- // Exposes the different views:
- // navBar -> the top navigation bar
- // dashboardContent -> Main display view
- // breadcrumbs -> Breadcrumbs navigation section
- var Layout = function (navBar, apiBar) {
- this.navBar = navBar;
- this.apiBar = apiBar;
-
- this.layout = new Backbone.Layout({
- template: "templates/layouts/with_sidebar",
-
- views: {
- "#primary-navbar": this.navBar,
- "#api-navbar": this.apiBar
- }
- });
-
- this.layoutViews = {};
- this.hooks = {};
-
- this.el = this.layout.el;
- };
-
- // creatings the dashboard object same way backbone does
- _.extend(Layout.prototype, {
-
- render: function () {
- return this.layout.render();
- },
-
- setTemplate: function(template) {
- if (template.prefix){
- this.layout.template = template.prefix + template.name;
- } else{
- this.layout.template = "templates/layouts/" + template;
- }
- // If we're changing layouts all bets are off, so kill off all the
- // existing views in the layout.
- _.each(this.layoutViews, function(view){view.remove();});
- this.layoutViews = {};
- this.render();
- },
-
- setTabs: function(view){
- // TODO: Not sure I like this - seems fragile/repetitive
- this.tabs = this.layout.setView("#tabs", view);
- this.tabs.render();
- },
-
- setBreadcrumbs: function(view) {
- this.breadcrumbs = this.layout.setView("#breadcrumbs", view);
- this.breadcrumbs.render();
- },
-
- clearBreadcrumbs: function () {
- if (!this.breadcrumbs) {return ;}
-
- this.breadcrumbs.remove();
- },
-
- setView: function(selector, view) {
- this.layoutViews[selector] = this.layout.setView(selector, view, false);
- },
-
- renderView: function(selector) {
- var view = this.layoutViews[selector];
- if (!view) {
- return false;
- } else {
- return view.render();
- }
- }
-
- });
-
- return Layout;
-
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/modules/pouchdb/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/pouchdb/base.js b/src/fauxton/app/modules/pouchdb/base.js
deleted file mode 100644
index ddaf06d..0000000
--- a/src/fauxton/app/modules/pouchdb/base.js
+++ /dev/null
@@ -1,60 +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.
-
-
-/*
- * NOTE:
- * This temporarily uses the PouchDB map reduce implementation
- * These files are modified locally until we make a more general version and
- * push it back upstream.
- */
-
-define([
- "app",
-
- "api",
-
- // Modules
- "modules/pouchdb/pouchdb.mapreduce.js"
-],
-
-function(app, FauxtonAPI, MapReduce) {
- var Pouch = {};
- Pouch.MapReduce = MapReduce;
-
- Pouch.runViewQuery = function(fun, opts) {
- /*docs = [
- {_id: 'test_doc_1', foo: 'bar-1'},
- {_id: 'test_doc_2', foo: 'bar-2'},
- {_id: 'test_doc_3', foo: 'bar-3'},
- {_id: 'test_doc_4', foo: 'bar-4'},
- {_id: 'test_doc_5', foo: 'bar-5'},
- {_id: 'test_doc_6', foo: 'bar-6'},
- {_id: 'test_doc_7', foo: 'bar-7'},
- {_id: 'test_doc_8', foo: 'bar-8'},
- {_id: 'test_doc_9', foo: 'bar-9'},
- {_id: 'test_doc_10', foo: 'bar-10'}
- ];*/
-
- var deferred = FauxtonAPI.Deferred();
- var complete = function(resp, rows) {
- deferred.resolve(rows);
- };
-
- var options = _.extend(opts, {complete: complete});
-
- Pouch.MapReduce.query(fun, options);
- return deferred;
- };
- //pdb.runViewQuery({map:function(doc) { emit(doc._id, doc.foo) }})
- return Pouch;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/modules/pouchdb/pouch.collate.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/pouchdb/pouch.collate.js b/src/fauxton/app/modules/pouchdb/pouch.collate.js
deleted file mode 100644
index 7cc5f9c..0000000
--- a/src/fauxton/app/modules/pouchdb/pouch.collate.js
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * NOTE:
- * This temporarily uses the PouchDB map reduce implementation
- * These files are modified locally until we make a more general version and
- * push it back upstream.
- * Original file:
- * https://github.com/daleharvey/pouchdb/blob/master/src/pouch.collate.js
- */
-
-/*
-(function() {
- // a few hacks to get things in the right place for node.js
- if (typeof module !== 'undefined' && module.exports) {
- module.exports = Pouch;
- }
-*/
-
-define([
- "app",
-
- "api",
-
- // Modules
- "modules/pouchdb/pouch.collate.js"
-],
-
-function(app, FauxtonAPI, Collate) {
- var Pouch = {};
-
- Pouch.collate = function(a, b) {
- var ai = collationIndex(a);
- var bi = collationIndex(b);
- if ((ai - bi) !== 0) {
- return ai - bi;
- }
- if (a === null) {
- return 0;
- }
- if (typeof a === 'number') {
- return a - b;
- }
- if (typeof a === 'boolean') {
- return a < b ? -1 : 1;
- }
- if (typeof a === 'string') {
- return stringCollate(a, b);
- }
- if (Array.isArray(a)) {
- return arrayCollate(a, b);
- }
- if (typeof a === 'object') {
- return objectCollate(a, b);
- }
- };
-
- var stringCollate = function(a, b) {
- // See: https://github.com/daleharvey/pouchdb/issues/40
- // This is incompatible with the CouchDB implementation, but its the
- // best we can do for now
- return (a === b) ? 0 : ((a > b) ? 1 : -1);
- };
-
- var objectCollate = function(a, b) {
- var ak = Object.keys(a), bk = Object.keys(b);
- var len = Math.min(ak.length, bk.length);
- for (var i = 0; i < len; i++) {
- // First sort the keys
- var sort = Pouch.collate(ak[i], bk[i]);
- if (sort !== 0) {
- return sort;
- }
- // if the keys are equal sort the values
- sort = Pouch.collate(a[ak[i]], b[bk[i]]);
- if (sort !== 0) {
- return sort;
- }
-
- }
- return (ak.length === bk.length) ? 0 :
- (ak.length > bk.length) ? 1 : -1;
- };
-
- var arrayCollate = function(a, b) {
- var len = Math.min(a.length, b.length);
- for (var i = 0; i < len; i++) {
- var sort = Pouch.collate(a[i], b[i]);
- if (sort !== 0) {
- return sort;
- }
- }
- return (a.length === b.length) ? 0 :
- (a.length > b.length) ? 1 : -1;
- };
-
- // The collation is defined by erlangs ordered terms
- // the atoms null, true, false come first, then numbers, strings,
- // arrays, then objects
- var collationIndex = function(x) {
- var id = ['boolean', 'number', 'string', 'object'];
- if (id.indexOf(typeof x) !== -1) {
- if (x === null) {
- return 1;
- }
- return id.indexOf(typeof x) + 2;
- }
- if (Array.isArray(x)) {
- return 4.5;
- }
- };
-
- return Pouch;
-
-//}).call(this);
-
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/modules/pouchdb/pouchdb.mapreduce.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/pouchdb/pouchdb.mapreduce.js b/src/fauxton/app/modules/pouchdb/pouchdb.mapreduce.js
deleted file mode 100644
index a2d0b91..0000000
--- a/src/fauxton/app/modules/pouchdb/pouchdb.mapreduce.js
+++ /dev/null
@@ -1,324 +0,0 @@
-/*
- * NOTE:
- * This temporarily uses the PouchDB map reduce implementation
- * These files are modified locally until we make a more general version and
- * push it back upstream.
- * Original file:
- * https://github.com/daleharvey/pouchdb/blob/master/src/plugins/pouchdb.mapreduce.js
- */
-
-/*global Pouch: true */
-
-//"use strict";
-
-// This is the first implementation of a basic plugin, we register the
-// plugin object with pouch and it is mixin'd to each database created
-// (regardless of adapter), adapters can override plugins by providing
-// their own implementation. functions on the plugin object that start
-// with _ are reserved function that are called by pouchdb for special
-// notifications.
-
-// If we wanted to store incremental views we can do it here by listening
-// to the changes feed (keeping track of our last update_seq between page loads)
-// and storing the result of the map function (possibly using the upcoming
-// extracted adapter functions)
-
-define([
- "app",
-
- "api",
-
- // Modules
- "modules/pouchdb/pouch.collate.js"
-],
-
-function(app, FauxtonAPI, Collate) {
- var Pouch = {};
- Pouch.collate = Collate.collate;
-
- //var MapReduce = function(db) {
- var MapReduce = function() {
-
- var builtInReduce = {
- "_sum": function(keys, values){
- return sum(values);
- },
-
- "_count": function(keys, values, rereduce){
- if (rereduce){
- return sum(values);
- } else {
- return values.length;
- }
- },
-
- "_stats": function(keys, values, rereduce){
- return {
- 'sum': sum(values),
- 'min': Math.min.apply(null, values),
- 'max': Math.max.apply(null, values),
- 'count': values.length,
- 'sumsqr': (function(){
- _sumsqr = 0;
- for(var idx in values){
- _sumsqr += values[idx] * values[idx];
- }
- return _sumsqr;
- })()
- };
- }
- };
-
- function viewQuery(fun, options) {
- console.log("IN VIEW QUERY");
- if (!options.complete) {
- return;
- }
-
- function sum(values) {
- return values.reduce(function(a, b) { return a + b; }, 0);
- }
-
- var results = [];
- var current = null;
- var num_started= 0;
- var completed= false;
-
- var emit = function(key, val) {
- //console.log("IN EMIT: ", key, val, current);
- var viewRow = {
- id: current.doc._id,
- key: key,
- value: val
- };
- //console.log("VIEW ROW: ", viewRow);
-
- if (options.startkey && Pouch.collate(key, options.startkey) < 0) return;
- if (options.endkey && Pouch.collate(key, options.endkey) > 0) return;
- if (options.key && Pouch.collate(key, options.key) !== 0) return;
- num_started++;
- if (options.include_docs) {
- // TODO:: FIX
- throw({error: "Include Docs not supported"});
- /*
-
- //in this special case, join on _id (issue #106)
- if (val && typeof val === 'object' && val._id){
- db.get(val._id,
- function(_, joined_doc){
- if (joined_doc) {
- viewRow.doc = joined_doc;
- }
- results.push(viewRow);
- checkComplete();
- });
- return;
- } else {
- viewRow.doc = current.doc;
- }
- */
- }
- console.log("EMITTING: ", viewRow);
- results.push(viewRow);
- };
-
- // ugly way to make sure references to 'emit' in map/reduce bind to the
- // above emit
- eval('fun.map = ' + fun.map.toString() + ';');
- if (fun.reduce && options.reduce) {
- if (builtInReduce[fun.reduce]) {
- console.log('built in reduce');
- fun.reduce = builtInReduce[fun.reduce];
- }
- eval('fun.reduce = ' + fun.reduce.toString() + ';');
- }
-
- // exclude _conflicts key by default
- // or to use options.conflicts if it's set when called by db.query
- var conflicts = ('conflicts' in options ? options.conflicts : false);
-
- //only proceed once all documents are mapped and joined
- var checkComplete= function(){
- console.log('check');
- if (completed && results.length == num_started){
- results.sort(function(a, b) {
- return Pouch.collate(a.key, b.key);
- });
- if (options.descending) {
- results.reverse();
- }
- if (options.reduce === false) {
- return options.complete(null, {rows: results});
- }
-
- console.log('reducing', options);
- var groups = [];
- results.forEach(function(e) {
- var last = groups[groups.length-1] || null;
- if (last && Pouch.collate(last.key[0][0], e.key) === 0) {
- last.key.push([e.key, e.id]);
- last.value.push(e.value);
- return;
- }
- groups.push({key: [[e.key, e.id]], value: [e.value]});
- });
- groups.forEach(function(e) {
- e.value = fun.reduce(e.key, e.value) || null;
- e.key = e.key[0][0];
- });
- console.log('GROUPs', groups);
- options.complete(null, {rows: groups});
- }
- };
-
- if (options.docs) {
- //console.log("RUNNING MR ON DOCS: ", options.docs);
- _.each(options.docs, function(doc) {
- current = {doc: doc};
- fun.map.call(this, doc);
- }, this);
- completed = true;
- return checkComplete();//options.complete(null, {rows: results});
- } else {
- //console.log("COULD NOT FIND DOCS");
- return false;
- }
-
- /*
- db.changes({
- conflicts: conflicts,
- include_docs: true,
- onChange: function(doc) {
- if (!('deleted' in doc)) {
- current = {doc: doc.doc};
- fun.map.call(this, doc.doc);
- }
- },
- complete: function() {
- completed= true;
- checkComplete();
- }
- });
- */
- }
-
- /*
- function httpQuery(fun, opts, callback) {
-
- // List of parameters to add to the PUT request
- var params = [];
- var body = undefined;
- var method = 'GET';
-
- // If opts.reduce exists and is defined, then add it to the list
- // of parameters.
- // If reduce=false then the results are that of only the map function
- // not the final result of map and reduce.
- if (typeof opts.reduce !== 'undefined') {
- params.push('reduce=' + opts.reduce);
- }
- if (typeof opts.include_docs !== 'undefined') {
- params.push('include_docs=' + opts.include_docs);
- }
- if (typeof opts.limit !== 'undefined') {
- params.push('limit=' + opts.limit);
- }
- if (typeof opts.descending !== 'undefined') {
- params.push('descending=' + opts.descending);
- }
- if (typeof opts.startkey !== 'undefined') {
- params.push('startkey=' + encodeURIComponent(JSON.stringify(opts.startkey)));
- }
- if (typeof opts.endkey !== 'undefined') {
- params.push('endkey=' + encodeURIComponent(JSON.stringify(opts.endkey)));
- }
- if (typeof opts.key !== 'undefined') {
- params.push('key=' + encodeURIComponent(JSON.stringify(opts.key)));
- }
-
- // If keys are supplied, issue a POST request to circumvent GET query string limits
- // see http://wiki.apache.org/couchdb/HTTP_view_API#Querying_Options
- if (typeof opts.keys !== 'undefined') {
- method = 'POST';
- body = JSON.stringify({keys:opts.keys});
- }
-
- // Format the list of parameters into a valid URI query string
- params = params.join('&');
- params = params === '' ? '' : '?' + params;
-
- // We are referencing a query defined in the design doc
- if (typeof fun === 'string') {
- var parts = fun.split('/');
- db.request({
- method: method,
- url: '_design/' + parts[0] + '/_view/' + parts[1] + params,
- body: body
- }, callback);
- return;
- }
-
- // We are using a temporary view, terrible for performance but good for testing
- var queryObject = JSON.parse(JSON.stringify(fun, function(key, val) {
- if (typeof val === 'function') {
- return val + ''; // implicitly `toString` it
- }
- return val;
- }));
-
- db.request({
- method:'POST',
- url: '_temp_view' + params,
- body: queryObject
- }, callback);
- }
- */
-
- function query(fun, opts, callback) {
- if (typeof opts === 'function') {
- callback = opts;
- opts = {};
- }
-
- if (callback) {
- opts.complete = callback;
- }
-
- /*
- if (db.type() === 'http') {
- return httpQuery(fun, opts, callback);
- }
- */
-
- if (typeof fun === 'object') {
- console.log("RUNNING VIEW QUERY", fun, opts, arguments);
- return viewQuery(fun, opts);
- }
-
- throw({error: "Shouldn't have gotten here"});
-
- /*
- var parts = fun.split('/');
- db.get('_design/' + parts[0], function(err, doc) {
- if (err) {
- if (callback) callback(err);
- return;
- }
- viewQuery({
- map: doc.views[parts[1]].map,
- reduce: doc.views[parts[1]].reduce
- }, opts);
- });
- */
- }
-
- return {'query': query};
- };
-
- // Deletion is a noop since we dont store the results of the view
- MapReduce._delete = function() { };
-
- //Pouch.plugin('mapreduce', MapReduce);
-
- return MapReduce();
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/router.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/router.js b/src/fauxton/app/router.js
deleted file mode 100644
index c12d951..0000000
--- a/src/fauxton/app/router.js
+++ /dev/null
@@ -1,147 +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.
-
-define([
- // Load require for use in nested requiring
- // as per the note in: http://requirejs.org/docs/api.html#multiversion
- "require",
-
- // Application.
- "app",
-
- // Initialize application
- "initialize",
-
- // Load Fauxton API
- "api",
-
- // Modules
- "modules/fauxton/base",
- // Layout
- "modules/fauxton/layout",
-
- // Routes return the module that they define routes for
- "modules/databases/base",
- "modules/documents/base",
- "modules/pouchdb/base",
-
-
- // this needs to be added as a plugin later
- // "modules/logs/base",
- // "modules/config/base",
-
- "load_addons"
-],
-
-function(req, app, Initialize, FauxtonAPI, Fauxton, Layout, Databases, Documents, Pouch, LoadAddons) {
-
- // TODO: auto generate this list if possible
- var modules = [Databases, Documents];
-
- var Router = app.router = Backbone.Router.extend({
- routes: {},
-
- addModuleRouteObject: function(RouteObject) {
- var that = this; //change that to that
- var masterLayout = this.masterLayout,
- routeUrls = RouteObject.prototype.getRouteUrls();
-
- _.each(routeUrls, function(route) {
- this.route(route, route.toString(), function() {
- var args = Array.prototype.slice.call(arguments),
- roles = RouteObject.prototype.getRouteRoles(route),
- authPromise = app.auth.checkAccess(roles);
-
- authPromise.then(function () {
- if (!that.activeRouteObject || !that.activeRouteObject.hasRoute(route)) {
- that.activeRouteObject = new RouteObject(route, masterLayout, args);
- }
-
- var routeObject = that.activeRouteObject;
- routeObject.routeCallback(route, args);
- routeObject.renderWith(route, masterLayout, args);
- }, function () {
- FauxtonAPI.auth.authDeniedCb();
- });
-
- });
- }, this);
- },
-
- setModuleRoutes: function() {
- _.each(modules, function(module) {
- if (module){
- _.each(module.RouteObjects, this.addModuleRouteObject, this);
- }
- }, this);
- _.each(LoadAddons.addons, function(module) {
- if (module){
- module.initialize();
- // This is pure routes the addon provides
- if (module.RouteObjects) {
- _.each(module.RouteObjects, this.addModuleRouteObject, this);
- }
- }
- }, this);
- },
-
- setAddonHooks: function() {
- _.each(LoadAddons.addons, function(module) {
- // This is updates to views by the addon
- if (module && module.hooks){
- _.each(module.hooks, function(callback, route){
- if (this.masterLayout.hooks[route]) {
- this.masterLayout.hooks[route].push(callback);
- } else {
- this.masterLayout.hooks[route] = [callback];
- }
- }, this);
- }
- }, this);
- },
-
- initialize: function() {
- //TODO: It would be nice to handle this with a router
- this.navBar = app.navBar = new Fauxton.NavBar();
- this.apiBar = app.apiBar = new Fauxton.ApiBar();
- this.auth = app.auth = FauxtonAPI.auth;
- app.session = FauxtonAPI.session;
-
- app.masterLayout = this.masterLayout = new Layout(this.navBar, this.apiBar);
- app.footer = new Fauxton.Footer({el: "#footer-content"});
-
- // NOTE: This must be below creation of the layout
- // FauxtonAPI header links and others depend on existence of the layout
- this.setAddonHooks();
- this.setModuleRoutes();
-
- $("#app-container").html(this.masterLayout.el);
- this.masterLayout.render();
-
- // TODO: move this to a proper Fauxton.View
- $.when.apply(null, app.footer.establish()).done(function() {
- app.footer.render();
- });
- },
-
- triggerRouteEvent: function(event, args) {
- if (this.activeRouteObject) {
- var eventArgs = [event].concat(args);
- this.activeRouteObject.trigger.apply(this.activeRouteObject, eventArgs );
- this.activeRouteObject.renderWith(eventArgs, this.masterLayout, args);
- }
- }
- });
-
- return Router;
-
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/templates/databases/item.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/databases/item.html b/src/fauxton/app/templates/databases/item.html
deleted file mode 100644
index 32a749a..0000000
--- a/src/fauxton/app/templates/databases/item.html
+++ /dev/null
@@ -1,20 +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.
--->
-
-<td>
- <a href="#/database/<%= database.get("name") %>/_all_docs?limit=100"><%= database.get("name") %></a>
-</td>
-<td><%= database.status.humanSize() %></td>
-<td><%= database.status.numDocs() %></td>
-<td><%= database.status.updateSeq() %></td>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/templates/databases/list.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/databases/list.html b/src/fauxton/app/templates/databases/list.html
deleted file mode 100644
index 808c950..0000000
--- a/src/fauxton/app/templates/databases/list.html
+++ /dev/null
@@ -1,30 +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.
--->
-
-<div class="result-tools" style="">
- <form class="navbar-form pull-right database-search">
- <input type="text" class="search-query" placeholder="Search by database name">
- </form>
-</div>
-<table class="databases table table-striped">
- <thead>
- <th>Name</th>
- <th>Size</th>
- <th>Number of Documents</th>
- <th>Update Seq</th>
- </thead>
- <tbody>
- </tbody>
-</table>
-<div id="database-pagination"></div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/templates/databases/sidebar.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/databases/sidebar.html b/src/fauxton/app/templates/databases/sidebar.html
deleted file mode 100644
index a8bbd89..0000000
--- a/src/fauxton/app/templates/databases/sidebar.html
+++ /dev/null
@@ -1,31 +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.
--->
-
-<div class="row-fluid">
- <a href="http://couchdb.org" target="_blank"><img src="img/couchdblogo.png"/></a>
- <br/>
-</div>
-<hr>
-<ul class="nav nav-list">
- <!-- <li class="nav-header">Database types</li> -->
- <li class="active"><a class="toggle-view" id="owned">Your databases</a></li>
- <li><a class="btn new" id="new"><i class="icon-plus"></i> New database</a></li>
-</ul>
-<hr>
-
-<div>
- <a class="twitter-timeline" data-dnt="true" href="https://twitter.com/CouchDB" data-widget-id="314360971646869505">Tweets by @CouchDB</a>
-<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
-
-</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/templates/documents/all_docs_item.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/all_docs_item.html b/src/fauxton/app/templates/documents/all_docs_item.html
deleted file mode 100644
index c4c0754..0000000
--- a/src/fauxton/app/templates/documents/all_docs_item.html
+++ /dev/null
@@ -1,26 +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.
--->
-
-<td class="select"><input type="checkbox" class="row-select"></td>
-<td>
- <div>
- <pre class="prettyprint"><%= doc.prettyJSON() %></pre>
- <% if (doc.isEditable()) { %>
- <div class="btn-group">
- <a href="#<%= doc.url('app') %>" class="btn btn-small edits">Edit <%= doc.docType() %></a>
- <button href="#" class="btn btn-small btn-danger delete" title="Delete this document."><i class="icon icon-trash"></i></button>
- </div>
- <% } %>
- </div>
-</td>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/templates/documents/all_docs_list.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/all_docs_list.html b/src/fauxton/app/templates/documents/all_docs_list.html
deleted file mode 100644
index c0a0d40..0000000
--- a/src/fauxton/app/templates/documents/all_docs_list.html
+++ /dev/null
@@ -1,59 +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.
--->
-
-<div class="view show">
- <% if (!viewList) { %>
- <div class="row">
- <div class="btn-toolbar span6">
- <button type="button" class="btn all" data-toggle="button">ā All</button>
- <button class="btn btn-small disabled bulk-delete"><i class="icon-trash"></i></button>
- </div>
- <!-- TODO::REENABLE
- <div class="btn-toolbar pull-right">
- <a href="#new-view-index" class="btn btn-small toggle-edit disabled"><i class="icon-wrench"></i> Edit index</a>
- <a href="#params" class="btn btn-small toggle-params"><i class="icon-plus"></i> API preview</a>
- </div>
- -->
- </div>
- <% } %>
-
- <p>
- Showing 1-<%= numModels %> of <%= totalRows %> rows
- <% if (updateSeq) { %>
- -- Update Sequence: <%= updateSeq %>
- <% } %>
- <% if (requestDuration) { %>
- <span class="view-request-duration">
- View request duration: <strong> <%= requestDuration %> </strong>
- </span>
- <% } %>
- </p>
- <table class="all-docs table table-striped table-condensed">
- <tbody></tbody>
- </table>
- <!--
- <div class="pagination pagination-centered">
- <ul>
- <li class="disabled"><a href="#">«</a></li>
- <li class="active"><a href="#">1</a></li>
- <li><a href="#">2</a></li>
- <li><a href="#">3</a></li>
- <li><a href="#">4</a></li>
- <li><a href="#">5</a></li>
- <li><a href="#">»</a></li>
- </ul>
- </div>
- -->
-
-</div>
[11/26] Remove fauxton from 1.4.x branch.
Posted by dj...@apache.org.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/js/plugins/prettify.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/plugins/prettify.js b/src/fauxton/assets/js/plugins/prettify.js
deleted file mode 100644
index eef5ad7..0000000
--- a/src/fauxton/assets/js/plugins/prettify.js
+++ /dev/null
@@ -1,28 +0,0 @@
-var q=null;window.PR_SHOULD_USE_CONTINUATION=!0;
-(function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a=
-[],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c<i;++c){var j=f[c];if(/\\[bdsw]/i.test(j))a.push(j);else{var j=m(j),d;c+2<i&&"-"===f[c+1]?(d=m(f[c+2]),c+=2):d=j;b.push([j,d]);d<65||j>122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;c<b.length;++c)i=b[c],i[0]<=j[1]+1?j[1]=Math.max(j[1],i[1]):f.push(j=i);b=["["];o&&b.push("^");b.push.apply(b,a);for(c=0;c<
-f.length;++c)i=f[c],b.push(e(i[0])),i[1]>i[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c<b;++c){var j=f[c];j==="("?++i:"\\"===j.charAt(0)&&(j=+j.substring(1))&&j<=i&&(d[j]=-1)}for(c=1;c<d.length;++c)-1===d[c]&&(d[c]=++t);for(i=c=0;c<b;++c)j=f[c],j==="("?(++i,d[i]===void 0&&(f[c]="(?:")):"\\"===j.charAt(0)&&
-(j=+j.substring(1))&&j<=i&&(f[c]="\\"+d[i]);for(i=c=0;c<b;++c)"^"===f[c]&&"^"!==f[c+1]&&(f[c]="");if(a.ignoreCase&&s)for(c=0;c<b;++c)j=f[c],a=j.charAt(0),j.length>=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p<d;++p){var g=a[p];if(g.ignoreCase)l=!0;else if(/[a-z]/i.test(g.source.replace(/\\u[\da-f]{4}|\\x[\da-f]{2}|\\[^UXux]/gi,""))){s=!0;l=!1;break}}for(var r=
-{b:8,t:9,n:10,v:11,f:12,r:13},n=[],p=0,d=a.length;p<d;++p){g=a[p];if(g.global||g.multiline)throw Error(""+g);n.push("(?:"+y(g)+")")}return RegExp(n.join("|"),l?"gi":"g")}function M(a){function m(a){switch(a.nodeType){case 1:if(e.test(a.className))break;for(var g=a.firstChild;g;g=g.nextSibling)m(g);g=a.nodeName;if("BR"===g||"LI"===g)h[s]="\n",t[s<<1]=y++,t[s++<<1|1]=a;break;case 3:case 4:g=a.nodeValue,g.length&&(g=p?g.replace(/\r\n?/g,"\n"):g.replace(/[\t\n\r ]+/g," "),h[s]=g,t[s<<1]=y,y+=g.length,
-t[s++<<1|1]=a)}}var e=/(?:^|\s)nocode(?:\s|$)/,h=[],y=0,t=[],s=0,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=document.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);m(a);return{a:h.join("").replace(/\n$/,""),c:t}}function B(a,m,e,h){m&&(a={a:m,d:a},e(a),h.push.apply(h,a.e))}function x(a,m){function e(a){for(var l=a.d,p=[l,"pln"],d=0,g=a.a.match(y)||[],r={},n=0,z=g.length;n<z;++n){var f=g[n],b=r[f],o=void 0,c;if(typeof b===
-"string")c=!1;else{var i=h[f.charAt(0)];if(i)o=f.match(i[1]),b=i[0];else{for(c=0;c<t;++c)if(i=m[c],o=f.match(i[1])){b=i[0];break}o||(b="pln")}if((c=b.length>=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m),
-l=[],p={},d=0,g=e.length;d<g;++d){var r=e[d],n=r[3];if(n)for(var k=n.length;--k>=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/,
-q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/,
-q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g,
-"");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a),
-a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e}
-for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g<d.length;++g)e(d[g]);m===(m|0)&&d[0].setAttribute("value",
-m);var r=s.createElement("OL");r.className="linenums";for(var n=Math.max(0,m-1|0)||0,g=0,z=d.length;g<z;++g)l=d[g],l.className="L"+(g+n)%10,l.firstChild||l.appendChild(s.createTextNode("\xa0")),r.appendChild(l);a.appendChild(r)}function k(a,m){for(var e=m.length;--e>=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*</.test(m)?"default-markup":"default-code";return A[a]}function E(a){var m=
-a.g;try{var e=M(a.h),h=e.a;a.a=h;a.c=e.c;a.d=0;C(m,h)(a);var k=/\bMSIE\b/.test(navigator.userAgent),m=/\n/g,t=a.a,s=t.length,e=0,l=a.c,p=l.length,h=0,d=a.e,g=d.length,a=0;d[g]=s;var r,n;for(n=r=0;n<g;)d[n]!==d[n+2]?(d[r++]=d[n++],d[r++]=d[n++]):n+=2;g=r;for(n=r=0;n<g;){for(var z=d[n],f=d[n+1],b=n+2;b+2<=g&&d[b+1]===f;)b+=2;d[r++]=z;d[r++]=f;n=b}for(d.length=r;h<p;){var o=l[h+2]||s,c=d[a+2]||s,b=Math.min(o,c),i=l[h+1],j;if(i.nodeType!==1&&(j=t.substring(e,b))){k&&(j=j.replace(m,"\r"));i.nodeValue=
-j;var u=i.ownerDocument,v=u.createElement("SPAN");v.className=d[a+1];var x=i.parentNode;x.replaceChild(v,i);v.appendChild(i);e<o&&(l[h+1]=i=u.createTextNode(t.substring(b,o)),x.insertBefore(i,v.nextSibling))}e=b;e>=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],
-"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"],
-H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],
-J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+
-I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^<?]+/],["dec",/^<!\w[^>]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),
-["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css",
-/^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),
-["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes",
-hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p<h.length&&l.now()<e;p++){var n=h[p],k=n.className;if(k.indexOf("prettyprint")>=0){var k=k.match(g),f,b;if(b=
-!k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p<h.length?setTimeout(m,
-250):a&&a()}for(var e=[document.getElementsByTagName("pre"),document.getElementsByTagName("code"),document.getElementsByTagName("xmp")],h=[],k=0;k<e.length;++k)for(var t=0,s=e[k].length;t<s;++t)h.push(e[k][t]);var e=q,l=Date;l.now||(l={now:function(){return+new Date}});var p=0,d,g=/\blang(?:uage)?-([\w.]+)(?!\S)/;m()};window.PR={createSimpleLexer:x,registerLangHandler:k,sourceDecorator:u,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",
-PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ"}})();
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/accordion.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/accordion.less b/src/fauxton/assets/less/bootstrap/accordion.less
deleted file mode 100644
index d63523b..0000000
--- a/src/fauxton/assets/less/bootstrap/accordion.less
+++ /dev/null
@@ -1,34 +0,0 @@
-//
-// Accordion
-// --------------------------------------------------
-
-
-// Parent container
-.accordion {
- margin-bottom: @baseLineHeight;
-}
-
-// Group == heading + body
-.accordion-group {
- margin-bottom: 2px;
- border: 1px solid #e5e5e5;
- .border-radius(@baseBorderRadius);
-}
-.accordion-heading {
- border-bottom: 0;
-}
-.accordion-heading .accordion-toggle {
- display: block;
- padding: 8px 15px;
-}
-
-// General toggle styles
-.accordion-toggle {
- cursor: pointer;
-}
-
-// Inner needs the styles because you can't animate properly with any styles on the element
-.accordion-inner {
- padding: 9px 15px;
- border-top: 1px solid #e5e5e5;
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/alerts.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/alerts.less b/src/fauxton/assets/less/bootstrap/alerts.less
deleted file mode 100644
index 9abb226..0000000
--- a/src/fauxton/assets/less/bootstrap/alerts.less
+++ /dev/null
@@ -1,65 +0,0 @@
-//
-// Alerts
-// --------------------------------------------------
-
-
-// Base styles
-// -------------------------
-
-.alert {
- padding: 8px 35px 8px 14px;
- margin-bottom: @baseLineHeight;
- text-shadow: 0 1px 0 rgba(255,255,255,.5);
- background-color: @warningBackground;
- border: 1px solid @warningBorder;
- .border-radius(@baseBorderRadius);
- color: @warningText;
-}
-.alert h4 {
- margin: 0;
-}
-
-// Adjust close link position
-.alert .close {
- position: relative;
- top: -2px;
- right: -21px;
- line-height: @baseLineHeight;
-}
-
-
-// Alternate styles
-// -------------------------
-
-.alert-success {
- background-color: @successBackground;
- border-color: @successBorder;
- color: @successText;
-}
-.alert-danger,
-.alert-error {
- background-color: @errorBackground;
- border-color: @errorBorder;
- color: @errorText;
-}
-.alert-info {
- background-color: @infoBackground;
- border-color: @infoBorder;
- color: @infoText;
-}
-
-
-// Block alerts
-// -------------------------
-
-.alert-block {
- padding-top: 14px;
- padding-bottom: 14px;
-}
-.alert-block > p,
-.alert-block > ul {
- margin-bottom: 0;
-}
-.alert-block p + p {
- margin-top: 5px;
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/bootstrap.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/bootstrap.less b/src/fauxton/assets/less/bootstrap/bootstrap.less
deleted file mode 100644
index 14bb3f0..0000000
--- a/src/fauxton/assets/less/bootstrap/bootstrap.less
+++ /dev/null
@@ -1,63 +0,0 @@
-/*!
- * Bootstrap v2.2.1
- *
- * Copyright 2012 Twitter, Inc
- * Licensed under the Apache License v2.0
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Designed and built with all the love in the world @twitter by @mdo and @fat.
- */
-
-// CSS Reset
-@import "reset.less";
-
-// Core variables and mixins
-@import "variables.less"; // Modify this for custom colors, font-sizes, etc
-@import "mixins.less";
-
-// Grid system and page structure
-@import "scaffolding.less";
-@import "grid.less";
-@import "layouts.less";
-
-// Base CSS
-@import "type.less";
-@import "code.less";
-@import "forms.less";
-@import "tables.less";
-
-// Components: common
-@import "sprites.less";
-@import "dropdowns.less";
-@import "wells.less";
-@import "component-animations.less";
-@import "close.less";
-
-// Components: Buttons & Alerts
-@import "buttons.less";
-@import "button-groups.less";
-@import "alerts.less"; // Note: alerts share common CSS with buttons and thus have styles in buttons.less
-
-// Components: Nav
-@import "navs.less";
-@import "navbar.less";
-@import "breadcrumbs.less";
-@import "pagination.less";
-@import "pager.less";
-
-// Components: Popovers
-@import "modals.less";
-@import "tooltip.less";
-@import "popovers.less";
-
-// Components: Misc
-@import "thumbnails.less";
-@import "media.less";
-@import "labels-badges.less";
-@import "progress-bars.less";
-@import "accordion.less";
-@import "carousel.less";
-@import "hero-unit.less";
-
-// Utility classes
-@import "utilities.less"; // Has to be last to override when necessary
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/breadcrumbs.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/breadcrumbs.less b/src/fauxton/assets/less/bootstrap/breadcrumbs.less
deleted file mode 100644
index 76fbe30..0000000
--- a/src/fauxton/assets/less/bootstrap/breadcrumbs.less
+++ /dev/null
@@ -1,24 +0,0 @@
-//
-// Breadcrumbs
-// --------------------------------------------------
-
-
-.breadcrumb {
- padding: 8px 15px;
- margin: 0 0 @baseLineHeight;
- list-style: none;
- background-color: #f5f5f5;
- .border-radius(@baseBorderRadius);
- li {
- display: inline-block;
- .ie7-inline-block();
- text-shadow: 0 1px 0 @white;
- }
- .divider {
- padding: 0 5px;
- color: #ccc;
- }
- .active {
- color: @grayLight;
- }
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/button-groups.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/button-groups.less b/src/fauxton/assets/less/bootstrap/button-groups.less
deleted file mode 100644
index 46837e6..0000000
--- a/src/fauxton/assets/less/bootstrap/button-groups.less
+++ /dev/null
@@ -1,242 +0,0 @@
-//
-// Button groups
-// --------------------------------------------------
-
-
-// Make the div behave like a button
-.btn-group {
- position: relative;
- display: inline-block;
- .ie7-inline-block();
- font-size: 0; // remove as part 1 of font-size inline-block hack
- vertical-align: middle; // match .btn alignment given font-size hack above
- white-space: nowrap; // prevent buttons from wrapping when in tight spaces (e.g., the table on the tests page)
- .ie7-restore-left-whitespace();
-}
-
-// Space out series of button groups
-.btn-group + .btn-group {
- margin-left: 5px;
-}
-
-// Optional: Group multiple button groups together for a toolbar
-.btn-toolbar {
- font-size: 0; // Hack to remove whitespace that results from using inline-block
- margin-top: @baseLineHeight / 2;
- margin-bottom: @baseLineHeight / 2;
- .btn + .btn,
- .btn-group + .btn,
- .btn + .btn-group {
- margin-left: 5px;
- }
-}
-
-// Float them, remove border radius, then re-add to first and last elements
-.btn-group > .btn {
- position: relative;
- .border-radius(0);
-}
-.btn-group > .btn + .btn {
- margin-left: -1px;
-}
-.btn-group > .btn,
-.btn-group > .dropdown-menu {
- font-size: @baseFontSize; // redeclare as part 2 of font-size inline-block hack
-}
-
-// Reset fonts for other sizes
-.btn-group > .btn-mini {
- font-size: 11px;
-}
-.btn-group > .btn-small {
- font-size: 12px;
-}
-.btn-group > .btn-large {
- font-size: 16px;
-}
-
-// Set corners individual because sometimes a single button can be in a .btn-group and we need :first-child and :last-child to both match
-.btn-group > .btn:first-child {
- margin-left: 0;
- -webkit-border-top-left-radius: 4px;
- -moz-border-radius-topleft: 4px;
- border-top-left-radius: 4px;
- -webkit-border-bottom-left-radius: 4px;
- -moz-border-radius-bottomleft: 4px;
- border-bottom-left-radius: 4px;
-}
-// Need .dropdown-toggle since :last-child doesn't apply given a .dropdown-menu immediately after it
-.btn-group > .btn:last-child,
-.btn-group > .dropdown-toggle {
- -webkit-border-top-right-radius: 4px;
- -moz-border-radius-topright: 4px;
- border-top-right-radius: 4px;
- -webkit-border-bottom-right-radius: 4px;
- -moz-border-radius-bottomright: 4px;
- border-bottom-right-radius: 4px;
-}
-// Reset corners for large buttons
-.btn-group > .btn.large:first-child {
- margin-left: 0;
- -webkit-border-top-left-radius: 6px;
- -moz-border-radius-topleft: 6px;
- border-top-left-radius: 6px;
- -webkit-border-bottom-left-radius: 6px;
- -moz-border-radius-bottomleft: 6px;
- border-bottom-left-radius: 6px;
-}
-.btn-group > .btn.large:last-child,
-.btn-group > .large.dropdown-toggle {
- -webkit-border-top-right-radius: 6px;
- -moz-border-radius-topright: 6px;
- border-top-right-radius: 6px;
- -webkit-border-bottom-right-radius: 6px;
- -moz-border-radius-bottomright: 6px;
- border-bottom-right-radius: 6px;
-}
-
-// On hover/focus/active, bring the proper btn to front
-.btn-group > .btn:hover,
-.btn-group > .btn:focus,
-.btn-group > .btn:active,
-.btn-group > .btn.active {
- z-index: 2;
-}
-
-// On active and open, don't show outline
-.btn-group .dropdown-toggle:active,
-.btn-group.open .dropdown-toggle {
- outline: 0;
-}
-
-
-
-// Split button dropdowns
-// ----------------------
-
-// Give the line between buttons some depth
-.btn-group > .btn + .dropdown-toggle {
- padding-left: 8px;
- padding-right: 8px;
- .box-shadow(~"inset 1px 0 0 rgba(255,255,255,.125), inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05)");
- *padding-top: 5px;
- *padding-bottom: 5px;
-}
-.btn-group > .btn-mini + .dropdown-toggle {
- padding-left: 5px;
- padding-right: 5px;
- *padding-top: 2px;
- *padding-bottom: 2px;
-}
-.btn-group > .btn-small + .dropdown-toggle {
- *padding-top: 5px;
- *padding-bottom: 4px;
-}
-.btn-group > .btn-large + .dropdown-toggle {
- padding-left: 12px;
- padding-right: 12px;
- *padding-top: 7px;
- *padding-bottom: 7px;
-}
-
-.btn-group.open {
-
- // The clickable button for toggling the menu
- // Remove the gradient and set the same inset shadow as the :active state
- .dropdown-toggle {
- background-image: none;
- .box-shadow(~"inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05)");
- }
-
- // Keep the hover's background when dropdown is open
- .btn.dropdown-toggle {
- background-color: @btnBackgroundHighlight;
- }
- .btn-primary.dropdown-toggle {
- background-color: @btnPrimaryBackgroundHighlight;
- }
- .btn-warning.dropdown-toggle {
- background-color: @btnWarningBackgroundHighlight;
- }
- .btn-danger.dropdown-toggle {
- background-color: @btnDangerBackgroundHighlight;
- }
- .btn-success.dropdown-toggle {
- background-color: @btnSuccessBackgroundHighlight;
- }
- .btn-info.dropdown-toggle {
- background-color: @btnInfoBackgroundHighlight;
- }
- .btn-inverse.dropdown-toggle {
- background-color: @btnInverseBackgroundHighlight;
- }
-}
-
-
-// Reposition the caret
-.btn .caret {
- margin-top: 8px;
- margin-left: 0;
-}
-// Carets in other button sizes
-.btn-mini .caret,
-.btn-small .caret,
-.btn-large .caret {
- margin-top: 6px;
-}
-.btn-large .caret {
- border-left-width: 5px;
- border-right-width: 5px;
- border-top-width: 5px;
-}
-// Upside down carets for .dropup
-.dropup .btn-large .caret {
- border-bottom-width: 5px;
-}
-
-
-
-// Account for other colors
-.btn-primary,
-.btn-warning,
-.btn-danger,
-.btn-info,
-.btn-success,
-.btn-inverse {
- .caret {
- border-top-color: @white;
- border-bottom-color: @white;
- }
-}
-
-
-
-// Vertical button groups
-// ----------------------
-
-.btn-group-vertical {
- display: inline-block; // makes buttons only take up the width they need
- .ie7-inline-block();
-}
-.btn-group-vertical .btn {
- display: block;
- float: none;
- width: 100%;
- .border-radius(0);
-}
-.btn-group-vertical .btn + .btn {
- margin-left: 0;
- margin-top: -1px;
-}
-.btn-group-vertical .btn:first-child {
- .border-radius(4px 4px 0 0);
-}
-.btn-group-vertical .btn:last-child {
- .border-radius(0 0 4px 4px);
-}
-.btn-group-vertical .btn-large:first-child {
- .border-radius(6px 6px 0 0);
-}
-.btn-group-vertical .btn-large:last-child {
- .border-radius(0 0 6px 6px);
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/buttons.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/buttons.less b/src/fauxton/assets/less/bootstrap/buttons.less
deleted file mode 100644
index 63f2d86..0000000
--- a/src/fauxton/assets/less/bootstrap/buttons.less
+++ /dev/null
@@ -1,232 +0,0 @@
-//
-// Buttons
-// --------------------------------------------------
-
-
-// Base styles
-// --------------------------------------------------
-
-// Core
-.btn {
- display: inline-block;
- .ie7-inline-block();
- padding: 4px 12px;
- margin-bottom: 0; // For input.btn
- font-size: @baseFontSize;
- line-height: @baseLineHeight;
- *line-height: @baseLineHeight;
- text-align: center;
- vertical-align: middle;
- cursor: pointer;
- .buttonBackground(@btnBackground, @btnBackgroundHighlight, @grayDark, 0 1px 1px rgba(255,255,255,.75));
- border: 1px solid @btnBorder;
- *border: 0; // Remove the border to prevent IE7's black border on input:focus
- border-bottom-color: darken(@btnBorder, 10%);
- .border-radius(@baseBorderRadius);
- .ie7-restore-left-whitespace(); // Give IE7 some love
- .box-shadow(~"inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05)");
-
- // Hover state
- &:hover {
- color: @grayDark;
- text-decoration: none;
- background-color: darken(@white, 10%);
- *background-color: darken(@white, 15%); /* Buttons in IE7 don't get borders, so darken on hover */
- background-position: 0 -15px;
-
- // transition is only when going to hover, otherwise the background
- // behind the gradient (there for IE<=9 fallback) gets mismatched
- .transition(background-position .1s linear);
- }
-
- // Focus state for keyboard and accessibility
- &:focus {
- .tab-focus();
- }
-
- // Active state
- &.active,
- &:active {
- background-color: darken(@white, 10%);
- background-color: darken(@white, 15%) e("\9");
- background-image: none;
- outline: 0;
- .box-shadow(~"inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05)");
- }
-
- // Disabled state
- &.disabled,
- &[disabled] {
- cursor: default;
- background-color: darken(@white, 10%);
- background-image: none;
- .opacity(65);
- .box-shadow(none);
- }
-
-}
-
-
-
-// Button Sizes
-// --------------------------------------------------
-
-// Large
-.btn-large {
- padding: @paddingLarge;
- font-size: @fontSizeLarge;
- .border-radius(@borderRadiusLarge);
-}
-.btn-large [class^="icon-"],
-.btn-large [class*=" icon-"] {
- margin-top: 2px;
-}
-
-// Small
-.btn-small {
- padding: @paddingSmall;
- font-size: @fontSizeSmall;
- .border-radius(@borderRadiusSmall);
-}
-.btn-small [class^="icon-"],
-.btn-small [class*=" icon-"] {
- margin-top: 0;
-}
-
-// Mini
-.btn-mini {
- padding: @paddingMini;
- font-size: @fontSizeMini;
- .border-radius(@borderRadiusSmall);
-}
-
-
-// Block button
-// -------------------------
-
-.btn-block {
- display: block;
- width: 100%;
- padding-left: 0;
- padding-right: 0;
- .box-sizing(border-box);
-}
-
-// Vertically space out multiple block buttons
-.btn-block + .btn-block {
- margin-top: 5px;
-}
-
-// Specificity overrides
-input[type="submit"],
-input[type="reset"],
-input[type="button"] {
- &.btn-block {
- width: 100%;
- }
-}
-
-
-
-// Alternate buttons
-// --------------------------------------------------
-
-// Provide *some* extra contrast for those who can get it
-.btn-primary.active,
-.btn-warning.active,
-.btn-danger.active,
-.btn-success.active,
-.btn-info.active,
-.btn-inverse.active {
- color: rgba(255,255,255,.75);
-}
-
-// Set the backgrounds
-// -------------------------
-.btn {
- // reset here as of 2.0.3 due to Recess property order
- border-color: #c5c5c5;
- border-color: rgba(0,0,0,.15) rgba(0,0,0,.15) rgba(0,0,0,.25);
-}
-.btn-primary {
- .buttonBackground(@btnPrimaryBackground, @btnPrimaryBackgroundHighlight);
-}
-// Warning appears are orange
-.btn-warning {
- .buttonBackground(@btnWarningBackground, @btnWarningBackgroundHighlight);
-}
-// Danger and error appear as red
-.btn-danger {
- .buttonBackground(@btnDangerBackground, @btnDangerBackgroundHighlight);
-}
-// Success appears as green
-.btn-success {
- .buttonBackground(@btnSuccessBackground, @btnSuccessBackgroundHighlight);
-}
-// Info appears as a neutral blue
-.btn-info {
- .buttonBackground(@btnInfoBackground, @btnInfoBackgroundHighlight);
-}
-// Inverse appears as dark gray
-.btn-inverse {
- .buttonBackground(@btnInverseBackground, @btnInverseBackgroundHighlight);
-}
-
-
-// Cross-browser Jank
-// --------------------------------------------------
-
-button.btn,
-input[type="submit"].btn {
-
- // Firefox 3.6 only I believe
- &::-moz-focus-inner {
- padding: 0;
- border: 0;
- }
-
- // IE7 has some default padding on button controls
- *padding-top: 3px;
- *padding-bottom: 3px;
-
- &.btn-large {
- *padding-top: 7px;
- *padding-bottom: 7px;
- }
- &.btn-small {
- *padding-top: 3px;
- *padding-bottom: 3px;
- }
- &.btn-mini {
- *padding-top: 1px;
- *padding-bottom: 1px;
- }
-}
-
-
-// Link buttons
-// --------------------------------------------------
-
-// Make a button look and behave like a link
-.btn-link,
-.btn-link:active,
-.btn-link[disabled] {
- background-color: transparent;
- background-image: none;
- .box-shadow(none);
-}
-.btn-link {
- border-color: transparent;
- cursor: pointer;
- color: @linkColor;
- .border-radius(0);
-}
-.btn-link:hover {
- color: @linkColorHover;
- text-decoration: underline;
- background-color: transparent;
-}
-.btn-link[disabled]:hover {
- color: @grayDark;
- text-decoration: none;
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/carousel.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/carousel.less b/src/fauxton/assets/less/bootstrap/carousel.less
deleted file mode 100644
index 33f98ac..0000000
--- a/src/fauxton/assets/less/bootstrap/carousel.less
+++ /dev/null
@@ -1,131 +0,0 @@
-//
-// Carousel
-// --------------------------------------------------
-
-
-.carousel {
- position: relative;
- margin-bottom: @baseLineHeight;
- line-height: 1;
-}
-
-.carousel-inner {
- overflow: hidden;
- width: 100%;
- position: relative;
-}
-
-.carousel {
-
- .item {
- display: none;
- position: relative;
- .transition(.6s ease-in-out left);
- }
-
- // Account for jankitude on images
- .item > img {
- display: block;
- line-height: 1;
- }
-
- .active,
- .next,
- .prev { display: block; }
-
- .active {
- left: 0;
- }
-
- .next,
- .prev {
- position: absolute;
- top: 0;
- width: 100%;
- }
-
- .next {
- left: 100%;
- }
- .prev {
- left: -100%;
- }
- .next.left,
- .prev.right {
- left: 0;
- }
-
- .active.left {
- left: -100%;
- }
- .active.right {
- left: 100%;
- }
-
-}
-
-// Left/right controls for nav
-// ---------------------------
-
-.carousel-control {
- position: absolute;
- top: 40%;
- left: 15px;
- width: 40px;
- height: 40px;
- margin-top: -20px;
- font-size: 60px;
- font-weight: 100;
- line-height: 30px;
- color: @white;
- text-align: center;
- background: @grayDarker;
- border: 3px solid @white;
- .border-radius(23px);
- .opacity(50);
-
- // we can't have this transition here
- // because webkit cancels the carousel
- // animation if you trip this while
- // in the middle of another animation
- // ;_;
- // .transition(opacity .2s linear);
-
- // Reposition the right one
- &.right {
- left: auto;
- right: 15px;
- }
-
- // Hover state
- &:hover {
- color: @white;
- text-decoration: none;
- .opacity(90);
- }
-}
-
-
-// Caption for text below images
-// -----------------------------
-
-.carousel-caption {
- position: absolute;
- left: 0;
- right: 0;
- bottom: 0;
- padding: 15px;
- background: @grayDark;
- background: rgba(0,0,0,.75);
-}
-.carousel-caption h4,
-.carousel-caption p {
- color: @white;
- line-height: @baseLineHeight;
-}
-.carousel-caption h4 {
- margin: 0 0 5px;
-}
-.carousel-caption p {
- margin-bottom: 0;
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/close.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/close.less b/src/fauxton/assets/less/bootstrap/close.less
deleted file mode 100644
index c71a508..0000000
--- a/src/fauxton/assets/less/bootstrap/close.less
+++ /dev/null
@@ -1,31 +0,0 @@
-//
-// Close icons
-// --------------------------------------------------
-
-
-.close {
- float: right;
- font-size: 20px;
- font-weight: bold;
- line-height: @baseLineHeight;
- color: @black;
- text-shadow: 0 1px 0 rgba(255,255,255,1);
- .opacity(20);
- &:hover {
- color: @black;
- text-decoration: none;
- cursor: pointer;
- .opacity(40);
- }
-}
-
-// Additional properties for button version
-// iOS requires the button element instead of an anchor tag.
-// If you want the anchor version, it requires `href="#"`.
-button.close {
- padding: 0;
- cursor: pointer;
- background: transparent;
- border: 0;
- -webkit-appearance: none;
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/code.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/code.less b/src/fauxton/assets/less/bootstrap/code.less
deleted file mode 100644
index 5495b15..0000000
--- a/src/fauxton/assets/less/bootstrap/code.less
+++ /dev/null
@@ -1,58 +0,0 @@
-//
-// Code (inline and blocK)
-// --------------------------------------------------
-
-
-// Inline and block code styles
-code,
-pre {
- padding: 0 3px 2px;
- #font > #family > .monospace;
- font-size: @baseFontSize - 2;
- color: @grayDark;
- .border-radius(3px);
-}
-
-// Inline code
-code {
- padding: 2px 4px;
- color: #d14;
- background-color: #f7f7f9;
- border: 1px solid #e1e1e8;
-}
-
-// Blocks of code
-pre {
- display: block;
- padding: (@baseLineHeight - 1) / 2;
- margin: 0 0 @baseLineHeight / 2;
- font-size: @baseFontSize - 1; // 14px to 13px
- line-height: @baseLineHeight;
- word-break: break-all;
- word-wrap: break-word;
- white-space: pre;
- white-space: pre-wrap;
- background-color: #f5f5f5;
- border: 1px solid #ccc; // fallback for IE7-8
- border: 1px solid rgba(0,0,0,.15);
- .border-radius(@baseBorderRadius);
-
- // Make prettyprint styles more spaced out for readability
- &.prettyprint {
- margin-bottom: @baseLineHeight;
- }
-
- // Account for some code outputs that place code tags in pre tags
- code {
- padding: 0;
- color: inherit;
- background-color: transparent;
- border: 0;
- }
-}
-
-// Enable scrollable blocks of code
-.pre-scrollable {
- max-height: 340px;
- overflow-y: scroll;
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/component-animations.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/component-animations.less b/src/fauxton/assets/less/bootstrap/component-animations.less
deleted file mode 100644
index d614263..0000000
--- a/src/fauxton/assets/less/bootstrap/component-animations.less
+++ /dev/null
@@ -1,22 +0,0 @@
-//
-// Component animations
-// --------------------------------------------------
-
-
-.fade {
- opacity: 0;
- .transition(opacity .15s linear);
- &.in {
- opacity: 1;
- }
-}
-
-.collapse {
- position: relative;
- height: 0;
- overflow: hidden;
- .transition(height .35s ease);
- &.in {
- height: auto;
- }
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/dropdowns.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/dropdowns.less b/src/fauxton/assets/less/bootstrap/dropdowns.less
deleted file mode 100644
index 26ca0f9..0000000
--- a/src/fauxton/assets/less/bootstrap/dropdowns.less
+++ /dev/null
@@ -1,237 +0,0 @@
-//
-// Dropdown menus
-// --------------------------------------------------
-
-
-// Use the .menu class on any <li> element within the topbar or ul.tabs and you'll get some superfancy dropdowns
-.dropup,
-.dropdown {
- position: relative;
-}
-.dropdown-toggle {
- // The caret makes the toggle a bit too tall in IE7
- *margin-bottom: -3px;
-}
-.dropdown-toggle:active,
-.open .dropdown-toggle {
- outline: 0;
-}
-
-// Dropdown arrow/caret
-// --------------------
-.caret {
- display: inline-block;
- width: 0;
- height: 0;
- vertical-align: top;
- border-top: 4px solid @black;
- border-right: 4px solid transparent;
- border-left: 4px solid transparent;
- content: "";
-}
-
-// Place the caret
-.dropdown .caret {
- margin-top: 8px;
- margin-left: 2px;
-}
-
-// The dropdown menu (ul)
-// ----------------------
-.dropdown-menu {
- position: absolute;
- top: 100%;
- left: 0;
- z-index: @zindexDropdown;
- display: none; // none by default, but block on "open" of the menu
- float: left;
- min-width: 160px;
- padding: 5px 0;
- margin: 2px 0 0; // override default ul
- list-style: none;
- background-color: @dropdownBackground;
- border: 1px solid #ccc; // Fallback for IE7-8
- border: 1px solid @dropdownBorder;
- *border-right-width: 2px;
- *border-bottom-width: 2px;
- .border-radius(6px);
- .box-shadow(0 5px 10px rgba(0,0,0,.2));
- -webkit-background-clip: padding-box;
- -moz-background-clip: padding;
- background-clip: padding-box;
-
- // Aligns the dropdown menu to right
- &.pull-right {
- right: 0;
- left: auto;
- }
-
- // Dividers (basically an hr) within the dropdown
- .divider {
- .nav-divider(@dropdownDividerTop, @dropdownDividerBottom);
- }
-
- // Links within the dropdown menu
- li > a {
- display: block;
- padding: 3px 20px;
- clear: both;
- font-weight: normal;
- line-height: @baseLineHeight;
- color: @dropdownLinkColor;
- white-space: nowrap;
- }
-}
-
-// Hover state
-// -----------
-.dropdown-menu li > a:hover,
-.dropdown-menu li > a:focus,
-.dropdown-submenu:hover > a {
- text-decoration: none;
- color: @dropdownLinkColorHover;
- #gradient > .vertical(@dropdownLinkBackgroundHover, darken(@dropdownLinkBackgroundHover, 5%));
-}
-
-// Active state
-// ------------
-.dropdown-menu .active > a,
-.dropdown-menu .active > a:hover {
- color: @dropdownLinkColorActive;
- text-decoration: none;
- outline: 0;
- #gradient > .vertical(@dropdownLinkBackgroundActive, darken(@dropdownLinkBackgroundActive, 5%));
-}
-
-// Disabled state
-// --------------
-// Gray out text and ensure the hover state remains gray
-.dropdown-menu .disabled > a,
-.dropdown-menu .disabled > a:hover {
- color: @grayLight;
-}
-// Nuke hover effects
-.dropdown-menu .disabled > a:hover {
- text-decoration: none;
- background-color: transparent;
- background-image: none; // Remove CSS gradient
- cursor: default;
-}
-
-// Open state for the dropdown
-// ---------------------------
-.open {
- // IE7's z-index only goes to the nearest positioned ancestor, which would
- // make the menu appear below buttons that appeared later on the page
- *z-index: @zindexDropdown;
-
- & > .dropdown-menu {
- display: block;
- }
-}
-
-// Right aligned dropdowns
-// ---------------------------
-.pull-right > .dropdown-menu {
- right: 0;
- left: auto;
-}
-
-// Allow for dropdowns to go bottom up (aka, dropup-menu)
-// ------------------------------------------------------
-// Just add .dropup after the standard .dropdown class and you're set, bro.
-// TODO: abstract this so that the navbar fixed styles are not placed here?
-.dropup,
-.navbar-fixed-bottom .dropdown {
- // Reverse the caret
- .caret {
- border-top: 0;
- border-bottom: 4px solid @black;
- content: "";
- }
- // Different positioning for bottom up menu
- .dropdown-menu {
- top: auto;
- bottom: 100%;
- margin-bottom: 1px;
- }
-}
-
-// Sub menus
-// ---------------------------
-.dropdown-submenu {
- position: relative;
-}
-// Default dropdowns
-.dropdown-submenu > .dropdown-menu {
- top: 0;
- left: 100%;
- margin-top: -6px;
- margin-left: -1px;
- -webkit-border-radius: 0 6px 6px 6px;
- -moz-border-radius: 0 6px 6px 6px;
- border-radius: 0 6px 6px 6px;
-}
-.dropdown-submenu:hover > .dropdown-menu {
- display: block;
-}
-
-// Dropups
-.dropup .dropdown-submenu > .dropdown-menu {
- top: auto;
- bottom: 0;
- margin-top: 0;
- margin-bottom: -2px;
- -webkit-border-radius: 5px 5px 5px 0;
- -moz-border-radius: 5px 5px 5px 0;
- border-radius: 5px 5px 5px 0;
-}
-
-// Caret to indicate there is a submenu
-.dropdown-submenu > a:after {
- display: block;
- content: " ";
- float: right;
- width: 0;
- height: 0;
- border-color: transparent;
- border-style: solid;
- border-width: 5px 0 5px 5px;
- border-left-color: darken(@dropdownBackground, 20%);
- margin-top: 5px;
- margin-right: -10px;
-}
-.dropdown-submenu:hover > a:after {
- border-left-color: @dropdownLinkColorHover;
-}
-
-// Left aligned submenus
-.dropdown-submenu.pull-left {
- // Undo the float
- // Yes, this is awkward since .pull-left adds a float, but it sticks to our conventions elsewhere.
- float: none;
-
- // Positioning the submenu
- > .dropdown-menu {
- left: -100%;
- margin-left: 10px;
- -webkit-border-radius: 6px 0 6px 6px;
- -moz-border-radius: 6px 0 6px 6px;
- border-radius: 6px 0 6px 6px;
- }
-}
-
-// Tweak nav headers
-// -----------------
-// Increase padding from 15px to 20px on sides
-.dropdown .dropdown-menu .nav-header {
- padding-left: 20px;
- padding-right: 20px;
-}
-
-// Typeahead
-// ---------
-.typeahead {
- margin-top: 2px; // give it some space to breathe
- .border-radius(@baseBorderRadius);
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/forms.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/forms.less b/src/fauxton/assets/less/bootstrap/forms.less
deleted file mode 100644
index e142f2a..0000000
--- a/src/fauxton/assets/less/bootstrap/forms.less
+++ /dev/null
@@ -1,683 +0,0 @@
-//
-// Forms
-// --------------------------------------------------
-
-
-// GENERAL STYLES
-// --------------
-
-// Make all forms have space below them
-form {
- margin: 0 0 @baseLineHeight;
-}
-
-fieldset {
- padding: 0;
- margin: 0;
- border: 0;
-}
-
-// Groups of fields with labels on top (legends)
-legend {
- display: block;
- width: 100%;
- padding: 0;
- margin-bottom: @baseLineHeight;
- font-size: @baseFontSize * 1.5;
- line-height: @baseLineHeight * 2;
- color: @grayDark;
- border: 0;
- border-bottom: 1px solid #e5e5e5;
-
- // Small
- small {
- font-size: @baseLineHeight * .75;
- color: @grayLight;
- }
-}
-
-// Set font for forms
-label,
-input,
-button,
-select,
-textarea {
- #font > .shorthand(@baseFontSize,normal,@baseLineHeight); // Set size, weight, line-height here
-}
-input,
-button,
-select,
-textarea {
- font-family: @baseFontFamily; // And only set font-family here for those that need it (note the missing label element)
-}
-
-// Identify controls by their labels
-label {
- display: block;
- margin-bottom: 5px;
-}
-
-// Form controls
-// -------------------------
-
-// Shared size and type resets
-select,
-textarea,
-input[type="text"],
-input[type="password"],
-input[type="datetime"],
-input[type="datetime-local"],
-input[type="date"],
-input[type="month"],
-input[type="time"],
-input[type="week"],
-input[type="number"],
-input[type="email"],
-input[type="url"],
-input[type="search"],
-input[type="tel"],
-input[type="color"],
-.uneditable-input {
- display: inline-block;
- height: @baseLineHeight;
- padding: 4px 6px;
- margin-bottom: @baseLineHeight / 2;
- font-size: @baseFontSize;
- line-height: @baseLineHeight;
- color: @gray;
- .border-radius(@inputBorderRadius);
- vertical-align: middle;
-}
-
-// Reset appearance properties for textual inputs and textarea
-// Declare width for legacy (can't be on input[type=*] selectors or it's too specific)
-input,
-textarea,
-.uneditable-input {
- width: 206px; // plus 12px padding and 2px border
-}
-// Reset height since textareas have rows
-textarea {
- height: auto;
-}
-// Everything else
-textarea,
-input[type="text"],
-input[type="password"],
-input[type="datetime"],
-input[type="datetime-local"],
-input[type="date"],
-input[type="month"],
-input[type="time"],
-input[type="week"],
-input[type="number"],
-input[type="email"],
-input[type="url"],
-input[type="search"],
-input[type="tel"],
-input[type="color"],
-.uneditable-input {
- background-color: @inputBackground;
- border: 1px solid @inputBorder;
- .box-shadow(inset 0 1px 1px rgba(0,0,0,.075));
- .transition(~"border linear .2s, box-shadow linear .2s");
-
- // Focus state
- &:focus {
- border-color: rgba(82,168,236,.8);
- outline: 0;
- outline: thin dotted \9; /* IE6-9 */
- .box-shadow(~"inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(82,168,236,.6)");
- }
-}
-
-// Position radios and checkboxes better
-input[type="radio"],
-input[type="checkbox"] {
- margin: 4px 0 0;
- *margin-top: 0; /* IE7 */
- margin-top: 1px \9; /* IE8-9 */
- line-height: normal;
- cursor: pointer;
-}
-
-// Reset width of input images, buttons, radios, checkboxes
-input[type="file"],
-input[type="image"],
-input[type="submit"],
-input[type="reset"],
-input[type="button"],
-input[type="radio"],
-input[type="checkbox"] {
- width: auto; // Override of generic input selector
-}
-
-// Set the height of select and file controls to match text inputs
-select,
-input[type="file"] {
- height: @inputHeight; /* In IE7, the height of the select element cannot be changed by height, only font-size */
- *margin-top: 4px; /* For IE7, add top margin to align select with labels */
- line-height: @inputHeight;
-}
-
-// Make select elements obey height by applying a border
-select {
- width: 220px; // default input width + 10px of padding that doesn't get applied
- border: 1px solid @inputBorder;
- background-color: @inputBackground; // Chrome on Linux and Mobile Safari need background-color
-}
-
-// Make multiple select elements height not fixed
-select[multiple],
-select[size] {
- height: auto;
-}
-
-// Focus for select, file, radio, and checkbox
-select:focus,
-input[type="file"]:focus,
-input[type="radio"]:focus,
-input[type="checkbox"]:focus {
- .tab-focus();
-}
-
-
-// Uneditable inputs
-// -------------------------
-
-// Make uneditable inputs look inactive
-.uneditable-input,
-.uneditable-textarea {
- color: @grayLight;
- background-color: darken(@inputBackground, 1%);
- border-color: @inputBorder;
- .box-shadow(inset 0 1px 2px rgba(0,0,0,.025));
- cursor: not-allowed;
-}
-
-// For text that needs to appear as an input but should not be an input
-.uneditable-input {
- overflow: hidden; // prevent text from wrapping, but still cut it off like an input does
- white-space: nowrap;
-}
-
-// Make uneditable textareas behave like a textarea
-.uneditable-textarea {
- width: auto;
- height: auto;
-}
-
-
-// Placeholder
-// -------------------------
-
-// Placeholder text gets special styles because when browsers invalidate entire lines if it doesn't understand a selector
-input,
-textarea {
- .placeholder();
-}
-
-
-// CHECKBOXES & RADIOS
-// -------------------
-
-// Indent the labels to position radios/checkboxes as hanging
-.radio,
-.checkbox {
- min-height: @baseLineHeight; // clear the floating input if there is no label text
- padding-left: 20px;
-}
-.radio input[type="radio"],
-.checkbox input[type="checkbox"] {
- float: left;
- margin-left: -20px;
-}
-
-// Move the options list down to align with labels
-.controls > .radio:first-child,
-.controls > .checkbox:first-child {
- padding-top: 5px; // has to be padding because margin collaspes
-}
-
-// Radios and checkboxes on same line
-// TODO v3: Convert .inline to .control-inline
-.radio.inline,
-.checkbox.inline {
- display: inline-block;
- padding-top: 5px;
- margin-bottom: 0;
- vertical-align: middle;
-}
-.radio.inline + .radio.inline,
-.checkbox.inline + .checkbox.inline {
- margin-left: 10px; // space out consecutive inline controls
-}
-
-
-
-// INPUT SIZES
-// -----------
-
-// General classes for quick sizes
-.input-mini { width: 60px; }
-.input-small { width: 90px; }
-.input-medium { width: 150px; }
-.input-large { width: 210px; }
-.input-xlarge { width: 270px; }
-.input-xxlarge { width: 530px; }
-
-// Grid style input sizes
-input[class*="span"],
-select[class*="span"],
-textarea[class*="span"],
-.uneditable-input[class*="span"],
-// Redeclare since the fluid row class is more specific
-.row-fluid input[class*="span"],
-.row-fluid select[class*="span"],
-.row-fluid textarea[class*="span"],
-.row-fluid .uneditable-input[class*="span"] {
- float: none;
- margin-left: 0;
-}
-// Ensure input-prepend/append never wraps
-.input-append input[class*="span"],
-.input-append .uneditable-input[class*="span"],
-.input-prepend input[class*="span"],
-.input-prepend .uneditable-input[class*="span"],
-.row-fluid input[class*="span"],
-.row-fluid select[class*="span"],
-.row-fluid textarea[class*="span"],
-.row-fluid .uneditable-input[class*="span"],
-.row-fluid .input-prepend [class*="span"],
-.row-fluid .input-append [class*="span"] {
- display: inline-block;
-}
-
-
-
-// GRID SIZING FOR INPUTS
-// ----------------------
-
-// Grid sizes
-#grid > .input(@gridColumnWidth, @gridGutterWidth);
-
-// Control row for multiple inputs per line
-.controls-row {
- .clearfix(); // Clear the float from controls
-}
-
-// Float to collapse white-space for proper grid alignment
-.controls-row [class*="span"],
-// Redeclare the fluid grid collapse since we undo the float for inputs
-.row-fluid .controls-row [class*="span"] {
- float: left;
-}
-// Explicity set top padding on all checkboxes/radios, not just first-child
-.controls-row .checkbox[class*="span"],
-.controls-row .radio[class*="span"] {
- padding-top: 5px;
-}
-
-
-
-
-// DISABLED STATE
-// --------------
-
-// Disabled and read-only inputs
-input[disabled],
-select[disabled],
-textarea[disabled],
-input[readonly],
-select[readonly],
-textarea[readonly] {
- cursor: not-allowed;
- background-color: @inputDisabledBackground;
-}
-// Explicitly reset the colors here
-input[type="radio"][disabled],
-input[type="checkbox"][disabled],
-input[type="radio"][readonly],
-input[type="checkbox"][readonly] {
- background-color: transparent;
-}
-
-
-
-
-// FORM FIELD FEEDBACK STATES
-// --------------------------
-
-// Warning
-.control-group.warning {
- .formFieldState(@warningText, @warningText, @warningBackground);
-}
-// Error
-.control-group.error {
- .formFieldState(@errorText, @errorText, @errorBackground);
-}
-// Success
-.control-group.success {
- .formFieldState(@successText, @successText, @successBackground);
-}
-// Success
-.control-group.info {
- .formFieldState(@infoText, @infoText, @infoBackground);
-}
-
-// HTML5 invalid states
-// Shares styles with the .control-group.error above
-input:focus:required:invalid,
-textarea:focus:required:invalid,
-select:focus:required:invalid {
- color: #b94a48;
- border-color: #ee5f5b;
- &:focus {
- border-color: darken(#ee5f5b, 10%);
- @shadow: 0 0 6px lighten(#ee5f5b, 20%);
- .box-shadow(@shadow);
- }
-}
-
-
-
-// FORM ACTIONS
-// ------------
-
-.form-actions {
- padding: (@baseLineHeight - 1) 20px @baseLineHeight;
- margin-top: @baseLineHeight;
- margin-bottom: @baseLineHeight;
- background-color: @formActionsBackground;
- border-top: 1px solid #e5e5e5;
- .clearfix(); // Adding clearfix to allow for .pull-right button containers
-}
-
-
-
-// HELP TEXT
-// ---------
-
-.help-block,
-.help-inline {
- color: lighten(@textColor, 15%); // lighten the text some for contrast
-}
-
-.help-block {
- display: block; // account for any element using help-block
- margin-bottom: @baseLineHeight / 2;
-}
-
-.help-inline {
- display: inline-block;
- .ie7-inline-block();
- vertical-align: middle;
- padding-left: 5px;
-}
-
-
-
-// INPUT GROUPS
-// ------------
-
-// Allow us to put symbols and text within the input field for a cleaner look
-.input-append,
-.input-prepend {
- margin-bottom: 5px;
- font-size: 0; // white space collapse hack
- white-space: nowrap; // Prevent span and input from separating
-
- // Reset the white space collapse hack
- input,
- select,
- .uneditable-input,
- .dropdown-menu {
- font-size: @baseFontSize;
- }
-
- input,
- select,
- .uneditable-input {
- position: relative; // placed here by default so that on :focus we can place the input above the .add-on for full border and box-shadow goodness
- margin-bottom: 0; // prevent bottom margin from screwing up alignment in stacked forms
- *margin-left: 0;
- vertical-align: top;
- .border-radius(0 @inputBorderRadius @inputBorderRadius 0);
- // Make input on top when focused so blue border and shadow always show
- &:focus {
- z-index: 2;
- }
- }
- .add-on {
- display: inline-block;
- width: auto;
- height: @baseLineHeight;
- min-width: 16px;
- padding: 4px 5px;
- font-size: @baseFontSize;
- font-weight: normal;
- line-height: @baseLineHeight;
- text-align: center;
- text-shadow: 0 1px 0 @white;
- background-color: @grayLighter;
- border: 1px solid #ccc;
- }
- .add-on,
- .btn {
- vertical-align: top;
- .border-radius(0);
- }
- .active {
- background-color: lighten(@green, 30);
- border-color: @green;
- }
-}
-
-.input-prepend {
- .add-on,
- .btn {
- margin-right: -1px;
- }
- .add-on:first-child,
- .btn:first-child {
- // FYI, `.btn:first-child` accounts for a button group that's prepended
- .border-radius(@inputBorderRadius 0 0 @inputBorderRadius);
- }
-}
-
-.input-append {
- input,
- select,
- .uneditable-input {
- .border-radius(@inputBorderRadius 0 0 @inputBorderRadius);
- + .btn-group .btn {
- .border-radius(0 @inputBorderRadius @inputBorderRadius 0);
- }
- }
- .add-on,
- .btn,
- .btn-group {
- margin-left: -1px;
- }
- .add-on:last-child,
- .btn:last-child {
- .border-radius(0 @inputBorderRadius @inputBorderRadius 0);
- }
-}
-
-// Remove all border-radius for inputs with both prepend and append
-.input-prepend.input-append {
- input,
- select,
- .uneditable-input {
- .border-radius(0);
- + .btn-group .btn {
- .border-radius(0 @inputBorderRadius @inputBorderRadius 0);
- }
- }
- .add-on:first-child,
- .btn:first-child {
- margin-right: -1px;
- .border-radius(@inputBorderRadius 0 0 @inputBorderRadius);
- }
- .add-on:last-child,
- .btn:last-child {
- margin-left: -1px;
- .border-radius(0 @inputBorderRadius @inputBorderRadius 0);
- }
- .btn-group:first-child {
- margin-left: 0;
- }
-}
-
-
-
-
-// SEARCH FORM
-// -----------
-
-input.search-query {
- padding-right: 14px;
- padding-right: 4px \9;
- padding-left: 14px;
- padding-left: 4px \9; /* IE7-8 doesn't have border-radius, so don't indent the padding */
- margin-bottom: 0; // Remove the default margin on all inputs
- .border-radius(15px);
-}
-
-/* Allow for input prepend/append in search forms */
-.form-search .input-append .search-query,
-.form-search .input-prepend .search-query {
- .border-radius(0); // Override due to specificity
-}
-.form-search .input-append .search-query {
- .border-radius(14px 0 0 14px);
-}
-.form-search .input-append .btn {
- .border-radius(0 14px 14px 0);
-}
-.form-search .input-prepend .search-query {
- .border-radius(0 14px 14px 0);
-}
-.form-search .input-prepend .btn {
- .border-radius(14px 0 0 14px);
-}
-
-
-
-
-// HORIZONTAL & VERTICAL FORMS
-// ---------------------------
-
-// Common properties
-// -----------------
-
-.form-search,
-.form-inline,
-.form-horizontal {
- input,
- textarea,
- select,
- .help-inline,
- .uneditable-input,
- .input-prepend,
- .input-append {
- display: inline-block;
- .ie7-inline-block();
- margin-bottom: 0;
- vertical-align: middle;
- }
- // Re-hide hidden elements due to specifity
- .hide {
- display: none;
- }
-}
-.form-search label,
-.form-inline label,
-.form-search .btn-group,
-.form-inline .btn-group {
- display: inline-block;
-}
-// Remove margin for input-prepend/-append
-.form-search .input-append,
-.form-inline .input-append,
-.form-search .input-prepend,
-.form-inline .input-prepend {
- margin-bottom: 0;
-}
-// Inline checkbox/radio labels (remove padding on left)
-.form-search .radio,
-.form-search .checkbox,
-.form-inline .radio,
-.form-inline .checkbox {
- padding-left: 0;
- margin-bottom: 0;
- vertical-align: middle;
-}
-// Remove float and margin, set to inline-block
-.form-search .radio input[type="radio"],
-.form-search .checkbox input[type="checkbox"],
-.form-inline .radio input[type="radio"],
-.form-inline .checkbox input[type="checkbox"] {
- float: left;
- margin-right: 3px;
- margin-left: 0;
-}
-
-
-// Margin to space out fieldsets
-.control-group {
- margin-bottom: @baseLineHeight / 2;
-}
-
-// Legend collapses margin, so next element is responsible for spacing
-legend + .control-group {
- margin-top: @baseLineHeight;
- -webkit-margin-top-collapse: separate;
-}
-
-// Horizontal-specific styles
-// --------------------------
-
-.form-horizontal {
- // Increase spacing between groups
- .control-group {
- margin-bottom: @baseLineHeight;
- .clearfix();
- }
- // Float the labels left
- .control-label {
- float: left;
- width: @horizontalComponentOffset - 20;
- padding-top: 5px;
- text-align: right;
- }
- // Move over all input controls and content
- .controls {
- // Super jank IE7 fix to ensure the inputs in .input-append and input-prepend
- // don't inherit the margin of the parent, in this case .controls
- *display: inline-block;
- *padding-left: 20px;
- margin-left: @horizontalComponentOffset;
- *margin-left: 0;
- &:first-child {
- *padding-left: @horizontalComponentOffset;
- }
- }
- // Remove bottom margin on block level help text since that's accounted for on .control-group
- .help-block {
- margin-bottom: 0;
- }
- // And apply it only to .help-block instances that follow a form control
- input,
- select,
- textarea {
- + .help-block {
- margin-top: @baseLineHeight / 2;
- }
- }
- // Move over buttons in .form-actions to align with .controls
- .form-actions {
- padding-left: @horizontalComponentOffset;
- }
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/grid.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/grid.less b/src/fauxton/assets/less/bootstrap/grid.less
deleted file mode 100644
index 750d203..0000000
--- a/src/fauxton/assets/less/bootstrap/grid.less
+++ /dev/null
@@ -1,21 +0,0 @@
-//
-// Grid system
-// --------------------------------------------------
-
-
-// Fixed (940px)
-#grid > .core(@gridColumnWidth, @gridGutterWidth);
-
-// Fluid (940px)
-#grid > .fluid(@fluidGridColumnWidth, @fluidGridGutterWidth);
-
-// Reset utility classes due to specificity
-[class*="span"].hide,
-.row-fluid [class*="span"].hide {
- display: none;
-}
-
-[class*="span"].pull-right,
-.row-fluid [class*="span"].pull-right {
- float: right;
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/hero-unit.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/hero-unit.less b/src/fauxton/assets/less/bootstrap/hero-unit.less
deleted file mode 100644
index 763d86a..0000000
--- a/src/fauxton/assets/less/bootstrap/hero-unit.less
+++ /dev/null
@@ -1,25 +0,0 @@
-//
-// Hero unit
-// --------------------------------------------------
-
-
-.hero-unit {
- padding: 60px;
- margin-bottom: 30px;
- font-size: 18px;
- font-weight: 200;
- line-height: @baseLineHeight * 1.5;
- color: @heroUnitLeadColor;
- background-color: @heroUnitBackground;
- .border-radius(6px);
- h1 {
- margin-bottom: 0;
- font-size: 60px;
- line-height: 1;
- color: @heroUnitHeadingColor;
- letter-spacing: -1px;
- }
- li {
- line-height: @baseLineHeight * 1.5; // Reset since we specify in type.less
- }
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/labels-badges.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/labels-badges.less b/src/fauxton/assets/less/bootstrap/labels-badges.less
deleted file mode 100644
index d118a01..0000000
--- a/src/fauxton/assets/less/bootstrap/labels-badges.less
+++ /dev/null
@@ -1,74 +0,0 @@
-//
-// Labels and badges
-// --------------------------------------------------
-
-
-// Base classes
-.label,
-.badge {
- display: inline-block;
- padding: 2px 4px;
- font-size: @baseFontSize * .846;
- font-weight: bold;
- line-height: 14px; // ensure proper line-height if floated
- color: @white;
- vertical-align: baseline;
- white-space: nowrap;
- text-shadow: 0 -1px 0 rgba(0,0,0,.25);
- background-color: @grayLight;
-}
-// Set unique padding and border-radii
-.label {
- .border-radius(3px);
-}
-.badge {
- padding-left: 9px;
- padding-right: 9px;
- .border-radius(9px);
-}
-
-// Hover state, but only for links
-a {
- &.label:hover,
- &.badge:hover {
- color: @white;
- text-decoration: none;
- cursor: pointer;
- }
-}
-
-// Colors
-// Only give background-color difference to links (and to simplify, we don't qualifty with `a` but [href] attribute)
-.label,
-.badge {
- // Important (red)
- &-important { background-color: @errorText; }
- &-important[href] { background-color: darken(@errorText, 10%); }
- // Warnings (orange)
- &-warning { background-color: @orange; }
- &-warning[href] { background-color: darken(@orange, 10%); }
- // Success (green)
- &-success { background-color: @successText; }
- &-success[href] { background-color: darken(@successText, 10%); }
- // Info (turquoise)
- &-info { background-color: @infoText; }
- &-info[href] { background-color: darken(@infoText, 10%); }
- // Inverse (black)
- &-inverse { background-color: @grayDark; }
- &-inverse[href] { background-color: darken(@grayDark, 10%); }
-}
-
-// Quick fix for labels/badges in buttons
-.btn {
- .label,
- .badge {
- position: relative;
- top: -1px;
- }
-}
-.btn-mini {
- .label,
- .badge {
- top: 0;
- }
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/layouts.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/layouts.less b/src/fauxton/assets/less/bootstrap/layouts.less
deleted file mode 100644
index 24a2062..0000000
--- a/src/fauxton/assets/less/bootstrap/layouts.less
+++ /dev/null
@@ -1,16 +0,0 @@
-//
-// Layouts
-// --------------------------------------------------
-
-
-// Container (centered, fixed-width layouts)
-.container {
- .container-fixed();
-}
-
-// Fluid layouts (left aligned, with sidebar, min- & max-width content)
-.container-fluid {
- padding-right: @gridGutterWidth;
- padding-left: @gridGutterWidth;
- .clearfix();
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/less/bootstrap/media.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/bootstrap/media.less b/src/fauxton/assets/less/bootstrap/media.less
deleted file mode 100644
index 1decab7..0000000
--- a/src/fauxton/assets/less/bootstrap/media.less
+++ /dev/null
@@ -1,55 +0,0 @@
-// Media objects
-// Source: http://stubbornella.org/content/?p=497
-// --------------------------------------------------
-
-
-// Common styles
-// -------------------------
-
-// Clear the floats
-.media,
-.media-body {
- overflow: hidden;
- *overflow: visible;
- zoom: 1;
-}
-
-// Proper spacing between instances of .media
-.media,
-.media .media {
- margin-top: 15px;
-}
-.media:first-child {
- margin-top: 0;
-}
-
-// For images and videos, set to block
-.media-object {
- display: block;
-}
-
-// Reset margins on headings for tighter default spacing
-.media-heading {
- margin: 0 0 5px;
-}
-
-
-// Media image alignment
-// -------------------------
-
-.media .pull-left {
- margin-right: 10px;
-}
-.media .pull-right {
- margin-left: 10px;
-}
-
-
-// Media list variation
-// -------------------------
-
-// Undo default ul/ol styles
-.media-list {
- margin-left: 0;
- list-style: none;
-}
[18/26] Remove fauxton from 1.4.x branch.
Posted by dj...@apache.org.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/js/libs/d3.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/d3.js b/src/fauxton/assets/js/libs/d3.js
deleted file mode 100644
index 44fc0b0..0000000
--- a/src/fauxton/assets/js/libs/d3.js
+++ /dev/null
@@ -1,7026 +0,0 @@
-(function() {
- function d3_class(ctor, properties) {
- try {
- for (var key in properties) {
- Object.defineProperty(ctor.prototype, key, {
- value: properties[key],
- enumerable: false
- });
- }
- } catch (e) {
- ctor.prototype = properties;
- }
- }
- function d3_arrayCopy(pseudoarray) {
- var i = -1, n = pseudoarray.length, array = [];
- while (++i < n) array.push(pseudoarray[i]);
- return array;
- }
- function d3_arraySlice(pseudoarray) {
- return Array.prototype.slice.call(pseudoarray);
- }
- function d3_Map() {}
- function d3_identity(d) {
- return d;
- }
- function d3_this() {
- return this;
- }
- function d3_true() {
- return true;
- }
- function d3_functor(v) {
- return typeof v === "function" ? v : function() {
- return v;
- };
- }
- function d3_rebind(target, source, method) {
- return function() {
- var value = method.apply(source, arguments);
- return arguments.length ? target : value;
- };
- }
- function d3_number(x) {
- return x != null && !isNaN(x);
- }
- function d3_zipLength(d) {
- return d.length;
- }
- function d3_splitter(d) {
- return d == null;
- }
- function d3_collapse(s) {
- return s.trim().replace(/\s+/g, " ");
- }
- function d3_range_integerScale(x) {
- var k = 1;
- while (x * k % 1) k *= 10;
- return k;
- }
- function d3_dispatch() {}
- function d3_dispatch_event(dispatch) {
- function event() {
- var z = listeners, i = -1, n = z.length, l;
- while (++i < n) if (l = z[i].on) l.apply(this, arguments);
- return dispatch;
- }
- var listeners = [], listenerByName = new d3_Map;
- event.on = function(name, listener) {
- var l = listenerByName.get(name), i;
- if (arguments.length < 2) return l && l.on;
- if (l) {
- l.on = null;
- listeners = listeners.slice(0, i = listeners.indexOf(l)).concat(listeners.slice(i + 1));
- listenerByName.remove(name);
- }
- if (listener) listeners.push(listenerByName.set(name, {
- on: listener
- }));
- return dispatch;
- };
- return event;
- }
- function d3_format_precision(x, p) {
- return p - (x ? 1 + Math.floor(Math.log(x + Math.pow(10, 1 + Math.floor(Math.log(x) / Math.LN10) - p)) / Math.LN10) : 1);
- }
- function d3_format_typeDefault(x) {
- return x + "";
- }
- function d3_format_group(value) {
- var i = value.lastIndexOf("."), f = i >= 0 ? value.substring(i) : (i = value.length, ""), t = [];
- while (i > 0) t.push(value.substring(i -= 3, i + 3));
- return t.reverse().join(",") + f;
- }
- function d3_formatPrefix(d, i) {
- var k = Math.pow(10, Math.abs(8 - i) * 3);
- return {
- scale: i > 8 ? function(d) {
- return d / k;
- } : function(d) {
- return d * k;
- },
- symbol: d
- };
- }
- function d3_ease_clamp(f) {
- return function(t) {
- return t <= 0 ? 0 : t >= 1 ? 1 : f(t);
- };
- }
- function d3_ease_reverse(f) {
- return function(t) {
- return 1 - f(1 - t);
- };
- }
- function d3_ease_reflect(f) {
- return function(t) {
- return .5 * (t < .5 ? f(2 * t) : 2 - f(2 - 2 * t));
- };
- }
- function d3_ease_identity(t) {
- return t;
- }
- function d3_ease_poly(e) {
- return function(t) {
- return Math.pow(t, e);
- };
- }
- function d3_ease_sin(t) {
- return 1 - Math.cos(t * Math.PI / 2);
- }
- function d3_ease_exp(t) {
- return Math.pow(2, 10 * (t - 1));
- }
- function d3_ease_circle(t) {
- return 1 - Math.sqrt(1 - t * t);
- }
- function d3_ease_elastic(a, p) {
- var s;
- if (arguments.length < 2) p = .45;
- if (arguments.length < 1) {
- a = 1;
- s = p / 4;
- } else s = p / (2 * Math.PI) * Math.asin(1 / a);
- return function(t) {
- return 1 + a * Math.pow(2, 10 * -t) * Math.sin((t - s) * 2 * Math.PI / p);
- };
- }
- function d3_ease_back(s) {
- if (!s) s = 1.70158;
- return function(t) {
- return t * t * ((s + 1) * t - s);
- };
- }
- function d3_ease_bounce(t) {
- return t < 1 / 2.75 ? 7.5625 * t * t : t < 2 / 2.75 ? 7.5625 * (t -= 1.5 / 2.75) * t + .75 : t < 2.5 / 2.75 ? 7.5625 * (t -= 2.25 / 2.75) * t + .9375 : 7.5625 * (t -= 2.625 / 2.75) * t + .984375;
- }
- function d3_eventCancel() {
- d3.event.stopPropagation();
- d3.event.preventDefault();
- }
- function d3_eventSource() {
- var e = d3.event, s;
- while (s = e.sourceEvent) e = s;
- return e;
- }
- function d3_eventDispatch(target) {
- var dispatch = new d3_dispatch, i = 0, n = arguments.length;
- while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch);
- dispatch.of = function(thiz, argumentz) {
- return function(e1) {
- try {
- var e0 = e1.sourceEvent = d3.event;
- e1.target = target;
- d3.event = e1;
- dispatch[e1.type].apply(thiz, argumentz);
- } finally {
- d3.event = e0;
- }
- };
- };
- return dispatch;
- }
- function d3_transform(m) {
- var r0 = [ m.a, m.b ], r1 = [ m.c, m.d ], kx = d3_transformNormalize(r0), kz = d3_transformDot(r0, r1), ky = d3_transformNormalize(d3_transformCombine(r1, r0, -kz)) || 0;
- if (r0[0] * r1[1] < r1[0] * r0[1]) {
- r0[0] *= -1;
- r0[1] *= -1;
- kx *= -1;
- kz *= -1;
- }
- this.rotate = (kx ? Math.atan2(r0[1], r0[0]) : Math.atan2(-r1[0], r1[1])) * d3_transformDegrees;
- this.translate = [ m.e, m.f ];
- this.scale = [ kx, ky ];
- this.skew = ky ? Math.atan2(kz, ky) * d3_transformDegrees : 0;
- }
- function d3_transformDot(a, b) {
- return a[0] * b[0] + a[1] * b[1];
- }
- function d3_transformNormalize(a) {
- var k = Math.sqrt(d3_transformDot(a, a));
- if (k) {
- a[0] /= k;
- a[1] /= k;
- }
- return k;
- }
- function d3_transformCombine(a, b, k) {
- a[0] += k * b[0];
- a[1] += k * b[1];
- return a;
- }
- function d3_interpolateByName(name) {
- return name == "transform" ? d3.interpolateTransform : d3.interpolate;
- }
- function d3_uninterpolateNumber(a, b) {
- b = b - (a = +a) ? 1 / (b - a) : 0;
- return function(x) {
- return (x - a) * b;
- };
- }
- function d3_uninterpolateClamp(a, b) {
- b = b - (a = +a) ? 1 / (b - a) : 0;
- return function(x) {
- return Math.max(0, Math.min(1, (x - a) * b));
- };
- }
- function d3_Color() {}
- function d3_rgb(r, g, b) {
- return new d3_Rgb(r, g, b);
- }
- function d3_Rgb(r, g, b) {
- this.r = r;
- this.g = g;
- this.b = b;
- }
- function d3_rgb_hex(v) {
- return v < 16 ? "0" + Math.max(0, v).toString(16) : Math.min(255, v).toString(16);
- }
- function d3_rgb_parse(format, rgb, hsl) {
- var r = 0, g = 0, b = 0, m1, m2, name;
- m1 = /([a-z]+)\((.*)\)/i.exec(format);
- if (m1) {
- m2 = m1[2].split(",");
- switch (m1[1]) {
- case "hsl":
- {
- return hsl(parseFloat(m2[0]), parseFloat(m2[1]) / 100, parseFloat(m2[2]) / 100);
- }
- case "rgb":
- {
- return rgb(d3_rgb_parseNumber(m2[0]), d3_rgb_parseNumber(m2[1]), d3_rgb_parseNumber(m2[2]));
- }
- }
- }
- if (name = d3_rgb_names.get(format)) return rgb(name.r, name.g, name.b);
- if (format != null && format.charAt(0) === "#") {
- if (format.length === 4) {
- r = format.charAt(1);
- r += r;
- g = format.charAt(2);
- g += g;
- b = format.charAt(3);
- b += b;
- } else if (format.length === 7) {
- r = format.substring(1, 3);
- g = format.substring(3, 5);
- b = format.substring(5, 7);
- }
- r = parseInt(r, 16);
- g = parseInt(g, 16);
- b = parseInt(b, 16);
- }
- return rgb(r, g, b);
- }
- function d3_rgb_hsl(r, g, b) {
- var min = Math.min(r /= 255, g /= 255, b /= 255), max = Math.max(r, g, b), d = max - min, h, s, l = (max + min) / 2;
- if (d) {
- s = l < .5 ? d / (max + min) : d / (2 - max - min);
- if (r == max) h = (g - b) / d + (g < b ? 6 : 0); else if (g == max) h = (b - r) / d + 2; else h = (r - g) / d + 4;
- h *= 60;
- } else {
- s = h = 0;
- }
- return d3_hsl(h, s, l);
- }
- function d3_rgb_lab(r, g, b) {
- r = d3_rgb_xyz(r);
- g = d3_rgb_xyz(g);
- b = d3_rgb_xyz(b);
- var x = d3_xyz_lab((.4124564 * r + .3575761 * g + .1804375 * b) / d3_lab_X), y = d3_xyz_lab((.2126729 * r + .7151522 * g + .072175 * b) / d3_lab_Y), z = d3_xyz_lab((.0193339 * r + .119192 * g + .9503041 * b) / d3_lab_Z);
- return d3_lab(116 * y - 16, 500 * (x - y), 200 * (y - z));
- }
- function d3_rgb_xyz(r) {
- return (r /= 255) <= .04045 ? r / 12.92 : Math.pow((r + .055) / 1.055, 2.4);
- }
- function d3_rgb_parseNumber(c) {
- var f = parseFloat(c);
- return c.charAt(c.length - 1) === "%" ? Math.round(f * 2.55) : f;
- }
- function d3_hsl(h, s, l) {
- return new d3_Hsl(h, s, l);
- }
- function d3_Hsl(h, s, l) {
- this.h = h;
- this.s = s;
- this.l = l;
- }
- function d3_hsl_rgb(h, s, l) {
- function v(h) {
- if (h > 360) h -= 360; else if (h < 0) h += 360;
- if (h < 60) return m1 + (m2 - m1) * h / 60;
- if (h < 180) return m2;
- if (h < 240) return m1 + (m2 - m1) * (240 - h) / 60;
- return m1;
- }
- function vv(h) {
- return Math.round(v(h) * 255);
- }
- var m1, m2;
- h = h % 360;
- if (h < 0) h += 360;
- s = s < 0 ? 0 : s > 1 ? 1 : s;
- l = l < 0 ? 0 : l > 1 ? 1 : l;
- m2 = l <= .5 ? l * (1 + s) : l + s - l * s;
- m1 = 2 * l - m2;
- return d3_rgb(vv(h + 120), vv(h), vv(h - 120));
- }
- function d3_hcl(h, c, l) {
- return new d3_Hcl(h, c, l);
- }
- function d3_Hcl(h, c, l) {
- this.h = h;
- this.c = c;
- this.l = l;
- }
- function d3_hcl_lab(h, c, l) {
- return d3_lab(l, Math.cos(h *= Math.PI / 180) * c, Math.sin(h) * c);
- }
- function d3_lab(l, a, b) {
- return new d3_Lab(l, a, b);
- }
- function d3_Lab(l, a, b) {
- this.l = l;
- this.a = a;
- this.b = b;
- }
- function d3_lab_rgb(l, a, b) {
- var y = (l + 16) / 116, x = y + a / 500, z = y - b / 200;
- x = d3_lab_xyz(x) * d3_lab_X;
- y = d3_lab_xyz(y) * d3_lab_Y;
- z = d3_lab_xyz(z) * d3_lab_Z;
- return d3_rgb(d3_xyz_rgb(3.2404542 * x - 1.5371385 * y - .4985314 * z), d3_xyz_rgb(-.969266 * x + 1.8760108 * y + .041556 * z), d3_xyz_rgb(.0556434 * x - .2040259 * y + 1.0572252 * z));
- }
- function d3_lab_hcl(l, a, b) {
- return d3_hcl(Math.atan2(b, a) / Math.PI * 180, Math.sqrt(a * a + b * b), l);
- }
- function d3_lab_xyz(x) {
- return x > .206893034 ? x * x * x : (x - 4 / 29) / 7.787037;
- }
- function d3_xyz_lab(x) {
- return x > .008856 ? Math.pow(x, 1 / 3) : 7.787037 * x + 4 / 29;
- }
- function d3_xyz_rgb(r) {
- return Math.round(255 * (r <= .00304 ? 12.92 * r : 1.055 * Math.pow(r, 1 / 2.4) - .055));
- }
- function d3_selection(groups) {
- d3_arraySubclass(groups, d3_selectionPrototype);
- return groups;
- }
- function d3_selection_selector(selector) {
- return function() {
- return d3_select(selector, this);
- };
- }
- function d3_selection_selectorAll(selector) {
- return function() {
- return d3_selectAll(selector, this);
- };
- }
- function d3_selection_attr(name, value) {
- function attrNull() {
- this.removeAttribute(name);
- }
- function attrNullNS() {
- this.removeAttributeNS(name.space, name.local);
- }
- function attrConstant() {
- this.setAttribute(name, value);
- }
- function attrConstantNS() {
- this.setAttributeNS(name.space, name.local, value);
- }
- function attrFunction() {
- var x = value.apply(this, arguments);
- if (x == null) this.removeAttribute(name); else this.setAttribute(name, x);
- }
- function attrFunctionNS() {
- var x = value.apply(this, arguments);
- if (x == null) this.removeAttributeNS(name.space, name.local); else this.setAttributeNS(name.space, name.local, x);
- }
- name = d3.ns.qualify(name);
- return value == null ? name.local ? attrNullNS : attrNull : typeof value === "function" ? name.local ? attrFunctionNS : attrFunction : name.local ? attrConstantNS : attrConstant;
- }
- function d3_selection_classedRe(name) {
- return new RegExp("(?:^|\\s+)" + d3.requote(name) + "(?:\\s+|$)", "g");
- }
- function d3_selection_classed(name, value) {
- function classedConstant() {
- var i = -1;
- while (++i < n) name[i](this, value);
- }
- function classedFunction() {
- var i = -1, x = value.apply(this, arguments);
- while (++i < n) name[i](this, x);
- }
- name = name.trim().split(/\s+/).map(d3_selection_classedName);
- var n = name.length;
- return typeof value === "function" ? classedFunction : classedConstant;
- }
- function d3_selection_classedName(name) {
- var re = d3_selection_classedRe(name);
- return function(node, value) {
- if (c = node.classList) return value ? c.add(name) : c.remove(name);
- var c = node.className, cb = c.baseVal != null, cv = cb ? c.baseVal : c;
- if (value) {
- re.lastIndex = 0;
- if (!re.test(cv)) {
- cv = d3_collapse(cv + " " + name);
- if (cb) c.baseVal = cv; else node.className = cv;
- }
- } else if (cv) {
- cv = d3_collapse(cv.replace(re, " "));
- if (cb) c.baseVal = cv; else node.className = cv;
- }
- };
- }
- function d3_selection_style(name, value, priority) {
- function styleNull() {
- this.style.removeProperty(name);
- }
- function styleConstant() {
- this.style.setProperty(name, value, priority);
- }
- function styleFunction() {
- var x = value.apply(this, arguments);
- if (x == null) this.style.removeProperty(name); else this.style.setProperty(name, x, priority);
- }
- return value == null ? styleNull : typeof value === "function" ? styleFunction : styleConstant;
- }
- function d3_selection_property(name, value) {
- function propertyNull() {
- delete this[name];
- }
- function propertyConstant() {
- this[name] = value;
- }
- function propertyFunction() {
- var x = value.apply(this, arguments);
- if (x == null) delete this[name]; else this[name] = x;
- }
- return value == null ? propertyNull : typeof value === "function" ? propertyFunction : propertyConstant;
- }
- function d3_selection_dataNode(data) {
- return {
- __data__: data
- };
- }
- function d3_selection_filter(selector) {
- return function() {
- return d3_selectMatches(this, selector);
- };
- }
- function d3_selection_sortComparator(comparator) {
- if (!arguments.length) comparator = d3.ascending;
- return function(a, b) {
- return comparator(a && a.__data__, b && b.__data__);
- };
- }
- function d3_selection_on(type, listener, capture) {
- function onRemove() {
- var wrapper = this[name];
- if (wrapper) {
- this.removeEventListener(type, wrapper, wrapper.$);
- delete this[name];
- }
- }
- function onAdd() {
- function wrapper(e) {
- var o = d3.event;
- d3.event = e;
- args[0] = node.__data__;
- try {
- listener.apply(node, args);
- } finally {
- d3.event = o;
- }
- }
- var node = this, args = arguments;
- onRemove.call(this);
- this.addEventListener(type, this[name] = wrapper, wrapper.$ = capture);
- wrapper._ = listener;
- }
- var name = "__on" + type, i = type.indexOf(".");
- if (i > 0) type = type.substring(0, i);
- return listener ? onAdd : onRemove;
- }
- function d3_selection_each(groups, callback) {
- for (var j = 0, m = groups.length; j < m; j++) {
- for (var group = groups[j], i = 0, n = group.length, node; i < n; i++) {
- if (node = group[i]) callback(node, i, j);
- }
- }
- return groups;
- }
- function d3_selection_enter(selection) {
- d3_arraySubclass(selection, d3_selection_enterPrototype);
- return selection;
- }
- function d3_transition(groups, id, time) {
- d3_arraySubclass(groups, d3_transitionPrototype);
- var tweens = new d3_Map, event = d3.dispatch("start", "end"), ease = d3_transitionEase;
- groups.id = id;
- groups.time = time;
- groups.tween = function(name, tween) {
- if (arguments.length < 2) return tweens.get(name);
- if (tween == null) tweens.remove(name); else tweens.set(name, tween);
- return groups;
- };
- groups.ease = function(value) {
- if (!arguments.length) return ease;
- ease = typeof value === "function" ? value : d3.ease.apply(d3, arguments);
- return groups;
- };
- groups.each = function(type, listener) {
- if (arguments.length < 2) return d3_transition_each.call(groups, type);
- event.on(type, listener);
- return groups;
- };
- d3.timer(function(elapsed) {
- return d3_selection_each(groups, function(node, i, j) {
- function start(elapsed) {
- if (lock.active > id) return stop();
- lock.active = id;
- tweens.forEach(function(key, value) {
- if (value = value.call(node, d, i)) {
- tweened.push(value);
- }
- });
- event.start.call(node, d, i);
- if (!tick(elapsed)) d3.timer(tick, 0, time);
- return 1;
- }
- function tick(elapsed) {
- if (lock.active !== id) return stop();
- var t = (elapsed - delay) / duration, e = ease(t), n = tweened.length;
- while (n > 0) {
- tweened[--n].call(node, e);
- }
- if (t >= 1) {
- stop();
- d3_transitionId = id;
- event.end.call(node, d, i);
- d3_transitionId = 0;
- return 1;
- }
- }
- function stop() {
- if (!--lock.count) delete node.__transition__;
- return 1;
- }
- var tweened = [], delay = node.delay, duration = node.duration, lock = (node = node.node).__transition__ || (node.__transition__ = {
- active: 0,
- count: 0
- }), d = node.__data__;
- ++lock.count;
- delay <= elapsed ? start(elapsed) : d3.timer(start, delay, time);
- });
- }, 0, time);
- return groups;
- }
- function d3_transition_each(callback) {
- var id = d3_transitionId, ease = d3_transitionEase, delay = d3_transitionDelay, duration = d3_transitionDuration;
- d3_transitionId = this.id;
- d3_transitionEase = this.ease();
- d3_selection_each(this, function(node, i, j) {
- d3_transitionDelay = node.delay;
- d3_transitionDuration = node.duration;
- callback.call(node = node.node, node.__data__, i, j);
- });
- d3_transitionId = id;
- d3_transitionEase = ease;
- d3_transitionDelay = delay;
- d3_transitionDuration = duration;
- return this;
- }
- function d3_tweenNull(d, i, a) {
- return a != "" && d3_tweenRemove;
- }
- function d3_tweenByName(b, name) {
- return d3.tween(b, d3_interpolateByName(name));
- }
- function d3_timer_step() {
- var elapsed, now = Date.now(), t1 = d3_timer_queue;
- while (t1) {
- elapsed = now - t1.then;
- if (elapsed >= t1.delay) t1.flush = t1.callback(elapsed);
- t1 = t1.next;
- }
- var delay = d3_timer_flush() - now;
- if (delay > 24) {
- if (isFinite(delay)) {
- clearTimeout(d3_timer_timeout);
- d3_timer_timeout = setTimeout(d3_timer_step, delay);
- }
- d3_timer_interval = 0;
- } else {
- d3_timer_interval = 1;
- d3_timer_frame(d3_timer_step);
- }
- }
- function d3_timer_flush() {
- var t0 = null, t1 = d3_timer_queue, then = Infinity;
- while (t1) {
- if (t1.flush) {
- delete d3_timer_byId[t1.callback.id];
- t1 = t0 ? t0.next = t1.next : d3_timer_queue = t1.next;
- } else {
- then = Math.min(then, t1.then + t1.delay);
- t1 = (t0 = t1).next;
- }
- }
- return then;
- }
- function d3_mousePoint(container, e) {
- var svg = container.ownerSVGElement || container;
- if (svg.createSVGPoint) {
- var point = svg.createSVGPoint();
- if (d3_mouse_bug44083 < 0 && (window.scrollX || window.scrollY)) {
- svg = d3.select(document.body).append("svg").style("position", "absolute").style("top", 0).style("left", 0);
- var ctm = svg[0][0].getScreenCTM();
- d3_mouse_bug44083 = !(ctm.f || ctm.e);
- svg.remove();
- }
- if (d3_mouse_bug44083) {
- point.x = e.pageX;
- point.y = e.pageY;
- } else {
- point.x = e.clientX;
- point.y = e.clientY;
- }
- point = point.matrixTransform(container.getScreenCTM().inverse());
- return [ point.x, point.y ];
- }
- var rect = container.getBoundingClientRect();
- return [ e.clientX - rect.left - container.clientLeft, e.clientY - rect.top - container.clientTop ];
- }
- function d3_noop() {}
- function d3_scaleExtent(domain) {
- var start = domain[0], stop = domain[domain.length - 1];
- return start < stop ? [ start, stop ] : [ stop, start ];
- }
- function d3_scaleRange(scale) {
- return scale.rangeExtent ? scale.rangeExtent() : d3_scaleExtent(scale.range());
- }
- function d3_scale_nice(domain, nice) {
- var i0 = 0, i1 = domain.length - 1, x0 = domain[i0], x1 = domain[i1], dx;
- if (x1 < x0) {
- dx = i0, i0 = i1, i1 = dx;
- dx = x0, x0 = x1, x1 = dx;
- }
- if (nice = nice(x1 - x0)) {
- domain[i0] = nice.floor(x0);
- domain[i1] = nice.ceil(x1);
- }
- return domain;
- }
- function d3_scale_niceDefault() {
- return Math;
- }
- function d3_scale_linear(domain, range, interpolate, clamp) {
- function rescale() {
- var linear = Math.min(domain.length, range.length) > 2 ? d3_scale_polylinear : d3_scale_bilinear, uninterpolate = clamp ? d3_uninterpolateClamp : d3_uninterpolateNumber;
- output = linear(domain, range, uninterpolate, interpolate);
- input = linear(range, domain, uninterpolate, d3.interpolate);
- return scale;
- }
- function scale(x) {
- return output(x);
- }
- var output, input;
- scale.invert = function(y) {
- return input(y);
- };
- scale.domain = function(x) {
- if (!arguments.length) return domain;
- domain = x.map(Number);
- return rescale();
- };
- scale.range = function(x) {
- if (!arguments.length) return range;
- range = x;
- return rescale();
- };
- scale.rangeRound = function(x) {
- return scale.range(x).interpolate(d3.interpolateRound);
- };
- scale.clamp = function(x) {
- if (!arguments.length) return clamp;
- clamp = x;
- return rescale();
- };
- scale.interpolate = function(x) {
- if (!arguments.length) return interpolate;
- interpolate = x;
- return rescale();
- };
- scale.ticks = function(m) {
- return d3_scale_linearTicks(domain, m);
- };
- scale.tickFormat = function(m) {
- return d3_scale_linearTickFormat(domain, m);
- };
- scale.nice = function() {
- d3_scale_nice(domain, d3_scale_linearNice);
- return rescale();
- };
- scale.copy = function() {
- return d3_scale_linear(domain, range, interpolate, clamp);
- };
- return rescale();
- }
- function d3_scale_linearRebind(scale, linear) {
- return d3.rebind(scale, linear, "range", "rangeRound", "interpolate", "clamp");
- }
- function d3_scale_linearNice(dx) {
- dx = Math.pow(10, Math.round(Math.log(dx) / Math.LN10) - 1);
- return dx && {
- floor: function(x) {
- return Math.floor(x / dx) * dx;
- },
- ceil: function(x) {
- return Math.ceil(x / dx) * dx;
- }
- };
- }
- function d3_scale_linearTickRange(domain, m) {
- var extent = d3_scaleExtent(domain), span = extent[1] - extent[0], step = Math.pow(10, Math.floor(Math.log(span / m) / Math.LN10)), err = m / span * step;
- if (err <= .15) step *= 10; else if (err <= .35) step *= 5; else if (err <= .75) step *= 2;
- extent[0] = Math.ceil(extent[0] / step) * step;
- extent[1] = Math.floor(extent[1] / step) * step + step * .5;
- extent[2] = step;
- return extent;
- }
- function d3_scale_linearTicks(domain, m) {
- return d3.range.apply(d3, d3_scale_linearTickRange(domain, m));
- }
- function d3_scale_linearTickFormat(domain, m) {
- return d3.format(",." + Math.max(0, -Math.floor(Math.log(d3_scale_linearTickRange(domain, m)[2]) / Math.LN10 + .01)) + "f");
- }
- function d3_scale_bilinear(domain, range, uninterpolate, interpolate) {
- var u = uninterpolate(domain[0], domain[1]), i = interpolate(range[0], range[1]);
- return function(x) {
- return i(u(x));
- };
- }
- function d3_scale_polylinear(domain, range, uninterpolate, interpolate) {
- var u = [], i = [], j = 0, k = Math.min(domain.length, range.length) - 1;
- if (domain[k] < domain[0]) {
- domain = domain.slice().reverse();
- range = range.slice().reverse();
- }
- while (++j <= k) {
- u.push(uninterpolate(domain[j - 1], domain[j]));
- i.push(interpolate(range[j - 1], range[j]));
- }
- return function(x) {
- var j = d3.bisect(domain, x, 1, k) - 1;
- return i[j](u[j](x));
- };
- }
- function d3_scale_log(linear, log) {
- function scale(x) {
- return linear(log(x));
- }
- var pow = log.pow;
- scale.invert = function(x) {
- return pow(linear.invert(x));
- };
- scale.domain = function(x) {
- if (!arguments.length) return linear.domain().map(pow);
- log = x[0] < 0 ? d3_scale_logn : d3_scale_logp;
- pow = log.pow;
- linear.domain(x.map(log));
- return scale;
- };
- scale.nice = function() {
- linear.domain(d3_scale_nice(linear.domain(), d3_scale_niceDefault));
- return scale;
- };
- scale.ticks = function() {
- var extent = d3_scaleExtent(linear.domain()), ticks = [];
- if (extent.every(isFinite)) {
- var i = Math.floor(extent[0]), j = Math.ceil(extent[1]), u = pow(extent[0]), v = pow(extent[1]);
- if (log === d3_scale_logn) {
- ticks.push(pow(i));
- for (; i++ < j; ) for (var k = 9; k > 0; k--) ticks.push(pow(i) * k);
- } else {
- for (; i < j; i++) for (var k = 1; k < 10; k++) ticks.push(pow(i) * k);
- ticks.push(pow(i));
- }
- for (i = 0; ticks[i] < u; i++) {}
- for (j = ticks.length; ticks[j - 1] > v; j--) {}
- ticks = ticks.slice(i, j);
- }
- return ticks;
- };
- scale.tickFormat = function(n, format) {
- if (arguments.length < 2) format = d3_scale_logFormat;
- if (arguments.length < 1) return format;
- var k = Math.max(.1, n / scale.ticks().length), f = log === d3_scale_logn ? (e = -1e-12, Math.floor) : (e = 1e-12, Math.ceil), e;
- return function(d) {
- return d / pow(f(log(d) + e)) <= k ? format(d) : "";
- };
- };
- scale.copy = function() {
- return d3_scale_log(linear.copy(), log);
- };
- return d3_scale_linearRebind(scale, linear);
- }
- function d3_scale_logp(x) {
- return Math.log(x < 0 ? 0 : x) / Math.LN10;
- }
- function d3_scale_logn(x) {
- return -Math.log(x > 0 ? 0 : -x) / Math.LN10;
- }
- function d3_scale_pow(linear, exponent) {
- function scale(x) {
- return linear(powp(x));
- }
- var powp = d3_scale_powPow(exponent), powb = d3_scale_powPow(1 / exponent);
- scale.invert = function(x) {
- return powb(linear.invert(x));
- };
- scale.domain = function(x) {
- if (!arguments.length) return linear.domain().map(powb);
- linear.domain(x.map(powp));
- return scale;
- };
- scale.ticks = function(m) {
- return d3_scale_linearTicks(scale.domain(), m);
- };
- scale.tickFormat = function(m) {
- return d3_scale_linearTickFormat(scale.domain(), m);
- };
- scale.nice = function() {
- return scale.domain(d3_scale_nice(scale.domain(), d3_scale_linearNice));
- };
- scale.exponent = function(x) {
- if (!arguments.length) return exponent;
- var domain = scale.domain();
- powp = d3_scale_powPow(exponent = x);
- powb = d3_scale_powPow(1 / exponent);
- return scale.domain(domain);
- };
- scale.copy = function() {
- return d3_scale_pow(linear.copy(), exponent);
- };
- return d3_scale_linearRebind(scale, linear);
- }
- function d3_scale_powPow(e) {
- return function(x) {
- return x < 0 ? -Math.pow(-x, e) : Math.pow(x, e);
- };
- }
- function d3_scale_ordinal(domain, ranger) {
- function scale(x) {
- return range[((index.get(x) || index.set(x, domain.push(x))) - 1) % range.length];
- }
- function steps(start, step) {
- return d3.range(domain.length).map(function(i) {
- return start + step * i;
- });
- }
- var index, range, rangeBand;
- scale.domain = function(x) {
- if (!arguments.length) return domain;
- domain = [];
- index = new d3_Map;
- var i = -1, n = x.length, xi;
- while (++i < n) if (!index.has(xi = x[i])) index.set(xi, domain.push(xi));
- return scale[ranger.t].apply(scale, ranger.a);
- };
- scale.range = function(x) {
- if (!arguments.length) return range;
- range = x;
- rangeBand = 0;
- ranger = {
- t: "range",
- a: arguments
- };
- return scale;
- };
- scale.rangePoints = function(x, padding) {
- if (arguments.length < 2) padding = 0;
- var start = x[0], stop = x[1], step = (stop - start) / (Math.max(1, domain.length - 1) + padding);
- range = steps(domain.length < 2 ? (start + stop) / 2 : start + step * padding / 2, step);
- rangeBand = 0;
- ranger = {
- t: "rangePoints",
- a: arguments
- };
- return scale;
- };
- scale.rangeBands = function(x, padding, outerPadding) {
- if (arguments.length < 2) padding = 0;
- if (arguments.length < 3) outerPadding = padding;
- var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = (stop - start) / (domain.length - padding + 2 * outerPadding);
- range = steps(start + step * outerPadding, step);
- if (reverse) range.reverse();
- rangeBand = step * (1 - padding);
- ranger = {
- t: "rangeBands",
- a: arguments
- };
- return scale;
- };
- scale.rangeRoundBands = function(x, padding, outerPadding) {
- if (arguments.length < 2) padding = 0;
- if (arguments.length < 3) outerPadding = padding;
- var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = Math.floor((stop - start) / (domain.length - padding + 2 * outerPadding)), error = stop - start - (domain.length - padding) * step;
- range = steps(start + Math.round(error / 2), step);
- if (reverse) range.reverse();
- rangeBand = Math.round(step * (1 - padding));
- ranger = {
- t: "rangeRoundBands",
- a: arguments
- };
- return scale;
- };
- scale.rangeBand = function() {
- return rangeBand;
- };
- scale.rangeExtent = function() {
- return d3_scaleExtent(ranger.a[0]);
- };
- scale.copy = function() {
- return d3_scale_ordinal(domain, ranger);
- };
- return scale.domain(domain);
- }
- function d3_scale_quantile(domain, range) {
- function rescale() {
- var k = 0, n = domain.length, q = range.length;
- thresholds = [];
- while (++k < q) thresholds[k - 1] = d3.quantile(domain, k / q);
- return scale;
- }
- function scale(x) {
- if (isNaN(x = +x)) return NaN;
- return range[d3.bisect(thresholds, x)];
- }
- var thresholds;
- scale.domain = function(x) {
- if (!arguments.length) return domain;
- domain = x.filter(function(d) {
- return !isNaN(d);
- }).sort(d3.ascending);
- return rescale();
- };
- scale.range = function(x) {
- if (!arguments.length) return range;
- range = x;
- return rescale();
- };
- scale.quantiles = function() {
- return thresholds;
- };
- scale.copy = function() {
- return d3_scale_quantile(domain, range);
- };
- return rescale();
- }
- function d3_scale_quantize(x0, x1, range) {
- function scale(x) {
- return range[Math.max(0, Math.min(i, Math.floor(kx * (x - x0))))];
- }
- function rescale() {
- kx = range.length / (x1 - x0);
- i = range.length - 1;
- return scale;
- }
- var kx, i;
- scale.domain = function(x) {
- if (!arguments.length) return [ x0, x1 ];
- x0 = +x[0];
- x1 = +x[x.length - 1];
- return rescale();
- };
- scale.range = function(x) {
- if (!arguments.length) return range;
- range = x;
- return rescale();
- };
- scale.copy = function() {
- return d3_scale_quantize(x0, x1, range);
- };
- return rescale();
- }
- function d3_scale_threshold(domain, range) {
- function scale(x) {
- return range[d3.bisect(domain, x)];
- }
- scale.domain = function(_) {
- if (!arguments.length) return domain;
- domain = _;
- return scale;
- };
- scale.range = function(_) {
- if (!arguments.length) return range;
- range = _;
- return scale;
- };
- scale.copy = function() {
- return d3_scale_threshold(domain, range);
- };
- return scale;
- }
- function d3_scale_identity(domain) {
- function identity(x) {
- return +x;
- }
- identity.invert = identity;
- identity.domain = identity.range = function(x) {
- if (!arguments.length) return domain;
- domain = x.map(identity);
- return identity;
- };
- identity.ticks = function(m) {
- return d3_scale_linearTicks(domain, m);
- };
- identity.tickFormat = function(m) {
- return d3_scale_linearTickFormat(domain, m);
- };
- identity.copy = function() {
- return d3_scale_identity(domain);
- };
- return identity;
- }
- function d3_svg_arcInnerRadius(d) {
- return d.innerRadius;
- }
- function d3_svg_arcOuterRadius(d) {
- return d.outerRadius;
- }
- function d3_svg_arcStartAngle(d) {
- return d.startAngle;
- }
- function d3_svg_arcEndAngle(d) {
- return d.endAngle;
- }
- function d3_svg_line(projection) {
- function line(data) {
- function segment() {
- segments.push("M", interpolate(projection(points), tension));
- }
- var segments = [], points = [], i = -1, n = data.length, d, fx = d3_functor(x), fy = d3_functor(y);
- while (++i < n) {
- if (defined.call(this, d = data[i], i)) {
- points.push([ +fx.call(this, d, i), +fy.call(this, d, i) ]);
- } else if (points.length) {
- segment();
- points = [];
- }
- }
- if (points.length) segment();
- return segments.length ? segments.join("") : null;
- }
- var x = d3_svg_lineX, y = d3_svg_lineY, defined = d3_true, interpolate = d3_svg_lineLinear, interpolateKey = interpolate.key, tension = .7;
- line.x = function(_) {
- if (!arguments.length) return x;
- x = _;
- return line;
- };
- line.y = function(_) {
- if (!arguments.length) return y;
- y = _;
- return line;
- };
- line.defined = function(_) {
- if (!arguments.length) return defined;
- defined = _;
- return line;
- };
- line.interpolate = function(_) {
- if (!arguments.length) return interpolateKey;
- if (typeof _ === "function") interpolateKey = interpolate = _; else interpolateKey = (interpolate = d3_svg_lineInterpolators.get(_) || d3_svg_lineLinear).key;
- return line;
- };
- line.tension = function(_) {
- if (!arguments.length) return tension;
- tension = _;
- return line;
- };
- return line;
- }
- function d3_svg_lineX(d) {
- return d[0];
- }
- function d3_svg_lineY(d) {
- return d[1];
- }
- function d3_svg_lineLinear(points) {
- return points.join("L");
- }
- function d3_svg_lineLinearClosed(points) {
- return d3_svg_lineLinear(points) + "Z";
- }
- function d3_svg_lineStepBefore(points) {
- var i = 0, n = points.length, p = points[0], path = [ p[0], ",", p[1] ];
- while (++i < n) path.push("V", (p = points[i])[1], "H", p[0]);
- return path.join("");
- }
- function d3_svg_lineStepAfter(points) {
- var i = 0, n = points.length, p = points[0], path = [ p[0], ",", p[1] ];
- while (++i < n) path.push("H", (p = points[i])[0], "V", p[1]);
- return path.join("");
- }
- function d3_svg_lineCardinalOpen(points, tension) {
- return points.length < 4 ? d3_svg_lineLinear(points) : points[1] + d3_svg_lineHermite(points.slice(1, points.length - 1), d3_svg_lineCardinalTangents(points, tension));
- }
- function d3_svg_lineCardinalClosed(points, tension) {
- return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite((points.push(points[0]), points), d3_svg_lineCardinalTangents([ points[points.length - 2] ].concat(points, [ points[1] ]), tension));
- }
- function d3_svg_lineCardinal(points, tension, closed) {
- return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite(points, d3_svg_lineCardinalTangents(points, tension));
- }
- function d3_svg_lineHermite(points, tangents) {
- if (tangents.length < 1 || points.length != tangents.length && points.length != tangents.length + 2) {
- return d3_svg_lineLinear(points);
- }
- var quad = points.length != tangents.length, path = "", p0 = points[0], p = points[1], t0 = tangents[0], t = t0, pi = 1;
- if (quad) {
- path += "Q" + (p[0] - t0[0] * 2 / 3) + "," + (p[1] - t0[1] * 2 / 3) + "," + p[0] + "," + p[1];
- p0 = points[1];
- pi = 2;
- }
- if (tangents.length > 1) {
- t = tangents[1];
- p = points[pi];
- pi++;
- path += "C" + (p0[0] + t0[0]) + "," + (p0[1] + t0[1]) + "," + (p[0] - t[0]) + "," + (p[1] - t[1]) + "," + p[0] + "," + p[1];
- for (var i = 2; i < tangents.length; i++, pi++) {
- p = points[pi];
- t = tangents[i];
- path += "S" + (p[0] - t[0]) + "," + (p[1] - t[1]) + "," + p[0] + "," + p[1];
- }
- }
- if (quad) {
- var lp = points[pi];
- path += "Q" + (p[0] + t[0] * 2 / 3) + "," + (p[1] + t[1] * 2 / 3) + "," + lp[0] + "," + lp[1];
- }
- return path;
- }
- function d3_svg_lineCardinalTangents(points, tension) {
- var tangents = [], a = (1 - tension) / 2, p0, p1 = points[0], p2 = points[1], i = 1, n = points.length;
- while (++i < n) {
- p0 = p1;
- p1 = p2;
- p2 = points[i];
- tangents.push([ a * (p2[0] - p0[0]), a * (p2[1] - p0[1]) ]);
- }
- return tangents;
- }
- function d3_svg_lineBasis(points) {
- if (points.length < 3) return d3_svg_lineLinear(points);
- var i = 1, n = points.length, pi = points[0], x0 = pi[0], y0 = pi[1], px = [ x0, x0, x0, (pi = points[1])[0] ], py = [ y0, y0, y0, pi[1] ], path = [ x0, ",", y0 ];
- d3_svg_lineBasisBezier(path, px, py);
- while (++i < n) {
- pi = points[i];
- px.shift();
- px.push(pi[0]);
- py.shift();
- py.push(pi[1]);
- d3_svg_lineBasisBezier(path, px, py);
- }
- i = -1;
- while (++i < 2) {
- px.shift();
- px.push(pi[0]);
- py.shift();
- py.push(pi[1]);
- d3_svg_lineBasisBezier(path, px, py);
- }
- return path.join("");
- }
- function d3_svg_lineBasisOpen(points) {
- if (points.length < 4) return d3_svg_lineLinear(points);
- var path = [], i = -1, n = points.length, pi, px = [ 0 ], py = [ 0 ];
- while (++i < 3) {
- pi = points[i];
- px.push(pi[0]);
- py.push(pi[1]);
- }
- path.push(d3_svg_lineDot4(d3_svg_lineBasisBezier3, px) + "," + d3_svg_lineDot4(d3_svg_lineBasisBezier3, py));
- --i;
- while (++i < n) {
- pi = points[i];
- px.shift();
- px.push(pi[0]);
- py.shift();
- py.push(pi[1]);
- d3_svg_lineBasisBezier(path, px, py);
- }
- return path.join("");
- }
- function d3_svg_lineBasisClosed(points) {
- var path, i = -1, n = points.length, m = n + 4, pi, px = [], py = [];
- while (++i < 4) {
- pi = points[i % n];
- px.push(pi[0]);
- py.push(pi[1]);
- }
- path = [ d3_svg_lineDot4(d3_svg_lineBasisBezier3, px), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, py) ];
- --i;
- while (++i < m) {
- pi = points[i % n];
- px.shift();
- px.push(pi[0]);
- py.shift();
- py.push(pi[1]);
- d3_svg_lineBasisBezier(path, px, py);
- }
- return path.join("");
- }
- function d3_svg_lineBundle(points, tension) {
- var n = points.length - 1;
- if (n) {
- var x0 = points[0][0], y0 = points[0][1], dx = points[n][0] - x0, dy = points[n][1] - y0, i = -1, p, t;
- while (++i <= n) {
- p = points[i];
- t = i / n;
- p[0] = tension * p[0] + (1 - tension) * (x0 + t * dx);
- p[1] = tension * p[1] + (1 - tension) * (y0 + t * dy);
- }
- }
- return d3_svg_lineBasis(points);
- }
- function d3_svg_lineDot4(a, b) {
- return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];
- }
- function d3_svg_lineBasisBezier(path, x, y) {
- path.push("C", d3_svg_lineDot4(d3_svg_lineBasisBezier1, x), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier1, y), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier2, x), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier2, y), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, x), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, y));
- }
- function d3_svg_lineSlope(p0, p1) {
- return (p1[1] - p0[1]) / (p1[0] - p0[0]);
- }
- function d3_svg_lineFiniteDifferences(points) {
- var i = 0, j = points.length - 1, m = [], p0 = points[0], p1 = points[1], d = m[0] = d3_svg_lineSlope(p0, p1);
- while (++i < j) {
- m[i] = (d + (d = d3_svg_lineSlope(p0 = p1, p1 = points[i + 1]))) / 2;
- }
- m[i] = d;
- return m;
- }
- function d3_svg_lineMonotoneTangents(points) {
- var tangents = [], d, a, b, s, m = d3_svg_lineFiniteDifferences(points), i = -1, j = points.length - 1;
- while (++i < j) {
- d = d3_svg_lineSlope(points[i], points[i + 1]);
- if (Math.abs(d) < 1e-6) {
- m[i] = m[i + 1] = 0;
- } else {
- a = m[i] / d;
- b = m[i + 1] / d;
- s = a * a + b * b;
- if (s > 9) {
- s = d * 3 / Math.sqrt(s);
- m[i] = s * a;
- m[i + 1] = s * b;
- }
- }
- }
- i = -1;
- while (++i <= j) {
- s = (points[Math.min(j, i + 1)][0] - points[Math.max(0, i - 1)][0]) / (6 * (1 + m[i] * m[i]));
- tangents.push([ s || 0, m[i] * s || 0 ]);
- }
- return tangents;
- }
- function d3_svg_lineMonotone(points) {
- return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite(points, d3_svg_lineMonotoneTangents(points));
- }
- function d3_svg_lineRadial(points) {
- var point, i = -1, n = points.length, r, a;
- while (++i < n) {
- point = points[i];
- r = point[0];
- a = point[1] + d3_svg_arcOffset;
- point[0] = r * Math.cos(a);
- point[1] = r * Math.sin(a);
- }
- return points;
- }
- function d3_svg_area(projection) {
- function area(data) {
- function segment() {
- segments.push("M", interpolate(projection(points1), tension), L, interpolateReverse(projection(points0.reverse()), tension), "Z");
- }
- var segments = [], points0 = [], points1 = [], i = -1, n = data.length, d, fx0 = d3_functor(x0), fy0 = d3_functor(y0), fx1 = x0 === x1 ? function() {
- return x;
- } : d3_functor(x1), fy1 = y0 === y1 ? function() {
- return y;
- } : d3_functor(y1), x, y;
- while (++i < n) {
- if (defined.call(this, d = data[i], i)) {
- points0.push([ x = +fx0.call(this, d, i), y = +fy0.call(this, d, i) ]);
- points1.push([ +fx1.call(this, d, i), +fy1.call(this, d, i) ]);
- } else if (points0.length) {
- segment();
- points0 = [];
- points1 = [];
- }
- }
- if (points0.length) segment();
- return segments.length ? segments.join("") : null;
- }
- var x0 = d3_svg_lineX, x1 = d3_svg_lineX, y0 = 0, y1 = d3_svg_lineY, defined = d3_true, interpolate = d3_svg_lineLinear, interpolateKey = interpolate.key, interpolateReverse = interpolate, L = "L", tension = .7;
- area.x = function(_) {
- if (!arguments.length) return x1;
- x0 = x1 = _;
- return area;
- };
- area.x0 = function(_) {
- if (!arguments.length) return x0;
- x0 = _;
- return area;
- };
- area.x1 = function(_) {
- if (!arguments.length) return x1;
- x1 = _;
- return area;
- };
- area.y = function(_) {
- if (!arguments.length) return y1;
- y0 = y1 = _;
- return area;
- };
- area.y0 = function(_) {
- if (!arguments.length) return y0;
- y0 = _;
- return area;
- };
- area.y1 = function(_) {
- if (!arguments.length) return y1;
- y1 = _;
- return area;
- };
- area.defined = function(_) {
- if (!arguments.length) return defined;
- defined = _;
- return area;
- };
- area.interpolate = function(_) {
- if (!arguments.length) return interpolateKey;
- if (typeof _ === "function") interpolateKey = interpolate = _; else interpolateKey = (interpolate = d3_svg_lineInterpolators.get(_) || d3_svg_lineLinear).key;
- interpolateReverse = interpolate.reverse || interpolate;
- L = interpolate.closed ? "M" : "L";
- return area;
- };
- area.tension = function(_) {
- if (!arguments.length) return tension;
- tension = _;
- return area;
- };
- return area;
- }
- function d3_svg_chordSource(d) {
- return d.source;
- }
- function d3_svg_chordTarget(d) {
- return d.target;
- }
- function d3_svg_chordRadius(d) {
- return d.radius;
- }
- function d3_svg_chordStartAngle(d) {
- return d.startAngle;
- }
- function d3_svg_chordEndAngle(d) {
- return d.endAngle;
- }
- function d3_svg_diagonalProjection(d) {
- return [ d.x, d.y ];
- }
- function d3_svg_diagonalRadialProjection(projection) {
- return function() {
- var d = projection.apply(this, arguments), r = d[0], a = d[1] + d3_svg_arcOffset;
- return [ r * Math.cos(a), r * Math.sin(a) ];
- };
- }
- function d3_svg_symbolSize() {
- return 64;
- }
- function d3_svg_symbolType() {
- return "circle";
- }
- function d3_svg_symbolCircle(size) {
- var r = Math.sqrt(size / Math.PI);
- return "M0," + r + "A" + r + "," + r + " 0 1,1 0," + -r + "A" + r + "," + r + " 0 1,1 0," + r + "Z";
- }
- function d3_svg_axisX(selection, x) {
- selection.attr("transform", function(d) {
- return "translate(" + x(d) + ",0)";
- });
- }
- function d3_svg_axisY(selection, y) {
- selection.attr("transform", function(d) {
- return "translate(0," + y(d) + ")";
- });
- }
- function d3_svg_axisSubdivide(scale, ticks, m) {
- subticks = [];
- if (m && ticks.length > 1) {
- var extent = d3_scaleExtent(scale.domain()), subticks, i = -1, n = ticks.length, d = (ticks[1] - ticks[0]) / ++m, j, v;
- while (++i < n) {
- for (j = m; --j > 0; ) {
- if ((v = +ticks[i] - j * d) >= extent[0]) {
- subticks.push(v);
- }
- }
- }
- for (--i, j = 0; ++j < m && (v = +ticks[i] + j * d) < extent[1]; ) {
- subticks.push(v);
- }
- }
- return subticks;
- }
- function d3_behavior_zoomDelta() {
- if (!d3_behavior_zoomDiv) {
- d3_behavior_zoomDiv = d3.select("body").append("div").style("visibility", "hidden").style("top", 0).style("height", 0).style("width", 0).style("overflow-y", "scroll").append("div").style("height", "2000px").node().parentNode;
- }
- var e = d3.event, delta;
- try {
- d3_behavior_zoomDiv.scrollTop = 1e3;
- d3_behavior_zoomDiv.dispatchEvent(e);
- delta = 1e3 - d3_behavior_zoomDiv.scrollTop;
- } catch (error) {
- delta = e.wheelDelta || -e.detail * 5;
- }
- return delta;
- }
- function d3_layout_bundlePath(link) {
- var start = link.source, end = link.target, lca = d3_layout_bundleLeastCommonAncestor(start, end), points = [ start ];
- while (start !== lca) {
- start = start.parent;
- points.push(start);
- }
- var k = points.length;
- while (end !== lca) {
- points.splice(k, 0, end);
- end = end.parent;
- }
- return points;
- }
- function d3_layout_bundleAncestors(node) {
- var ancestors = [], parent = node.parent;
- while (parent != null) {
- ancestors.push(node);
- node = parent;
- parent = parent.parent;
- }
- ancestors.push(node);
- return ancestors;
- }
- function d3_layout_bundleLeastCommonAncestor(a, b) {
- if (a === b) return a;
- var aNodes = d3_layout_bundleAncestors(a), bNodes = d3_layout_bundleAncestors(b), aNode = aNodes.pop(), bNode = bNodes.pop(), sharedNode = null;
- while (aNode === bNode) {
- sharedNode = aNode;
- aNode = aNodes.pop();
- bNode = bNodes.pop();
- }
- return sharedNode;
- }
- function d3_layout_forceDragstart(d) {
- d.fixed |= 2;
- }
- function d3_layout_forceDragend(d) {
- d.fixed &= 1;
- }
- function d3_layout_forceMouseover(d) {
- d.fixed |= 4;
- }
- function d3_layout_forceMouseout(d) {
- d.fixed &= 3;
- }
- function d3_layout_forceAccumulate(quad, alpha, charges) {
- var cx = 0, cy = 0;
- quad.charge = 0;
- if (!quad.leaf) {
- var nodes = quad.nodes, n = nodes.length, i = -1, c;
- while (++i < n) {
- c = nodes[i];
- if (c == null) continue;
- d3_layout_forceAccumulate(c, alpha, charges);
- quad.charge += c.charge;
- cx += c.charge * c.cx;
- cy += c.charge * c.cy;
- }
- }
- if (quad.point) {
- if (!quad.leaf) {
- quad.point.x += Math.random() - .5;
- quad.point.y += Math.random() - .5;
- }
- var k = alpha * charges[quad.point.index];
- quad.charge += quad.pointCharge = k;
- cx += k * quad.point.x;
- cy += k * quad.point.y;
- }
- quad.cx = cx / quad.charge;
- quad.cy = cy / quad.charge;
- }
- function d3_layout_forceLinkDistance(link) {
- return 20;
- }
- function d3_layout_forceLinkStrength(link) {
- return 1;
- }
- function d3_layout_stackX(d) {
- return d.x;
- }
- function d3_layout_stackY(d) {
- return d.y;
- }
- function d3_layout_stackOut(d, y0, y) {
- d.y0 = y0;
- d.y = y;
- }
- function d3_layout_stackOrderDefault(data) {
- return d3.range(data.length);
- }
- function d3_layout_stackOffsetZero(data) {
- var j = -1, m = data[0].length, y0 = [];
- while (++j < m) y0[j] = 0;
- return y0;
- }
- function d3_layout_stackMaxIndex(array) {
- var i = 1, j = 0, v = array[0][1], k, n = array.length;
- for (; i < n; ++i) {
- if ((k = array[i][1]) > v) {
- j = i;
- v = k;
- }
- }
- return j;
- }
- function d3_layout_stackReduceSum(d) {
- return d.reduce(d3_layout_stackSum, 0);
- }
- function d3_layout_stackSum(p, d) {
- return p + d[1];
- }
- function d3_layout_histogramBinSturges(range, values) {
- return d3_layout_histogramBinFixed(range, Math.ceil(Math.log(values.length) / Math.LN2 + 1));
- }
- function d3_layout_histogramBinFixed(range, n) {
- var x = -1, b = +range[0], m = (range[1] - b) / n, f = [];
- while (++x <= n) f[x] = m * x + b;
- return f;
- }
- function d3_layout_histogramRange(values) {
- return [ d3.min(values), d3.max(values) ];
- }
- function d3_layout_hierarchyRebind(object, hierarchy) {
- d3.rebind(object, hierarchy, "sort", "children", "value");
- object.links = d3_layout_hierarchyLinks;
- object.nodes = function(d) {
- d3_layout_hierarchyInline = true;
- return (object.nodes = object)(d);
- };
- return object;
- }
- function d3_layout_hierarchyChildren(d) {
- return d.children;
- }
- function d3_layout_hierarchyValue(d) {
- return d.value;
- }
- function d3_layout_hierarchySort(a, b) {
- return b.value - a.value;
- }
- function d3_layout_hierarchyLinks(nodes) {
- return d3.merge(nodes.map(function(parent) {
- return (parent.children || []).map(function(child) {
- return {
- source: parent,
- target: child
- };
- });
- }));
- }
- function d3_layout_packSort(a, b) {
- return a.value - b.value;
- }
- function d3_layout_packInsert(a, b) {
- var c = a._pack_next;
- a._pack_next = b;
- b._pack_prev = a;
- b._pack_next = c;
- c._pack_prev = b;
- }
- function d3_layout_packSplice(a, b) {
- a._pack_next = b;
- b._pack_prev = a;
- }
- function d3_layout_packIntersects(a, b) {
- var dx = b.x - a.x, dy = b.y - a.y, dr = a.r + b.r;
- return dr * dr - dx * dx - dy * dy > .001;
- }
- function d3_layout_packSiblings(node) {
- function bound(node) {
- xMin = Math.min(node.x - node.r, xMin);
- xMax = Math.max(node.x + node.r, xMax);
- yMin = Math.min(node.y - node.r, yMin);
- yMax = Math.max(node.y + node.r, yMax);
- }
- if (!(nodes = node.children) || !(n = nodes.length)) return;
- var nodes, xMin = Infinity, xMax = -Infinity, yMin = Infinity, yMax = -Infinity, a, b, c, i, j, k, n;
- nodes.forEach(d3_layout_packLink);
- a = nodes[0];
- a.x = -a.r;
- a.y = 0;
- bound(a);
- if (n > 1) {
- b = nodes[1];
- b.x = b.r;
- b.y = 0;
- bound(b);
- if (n > 2) {
- c = nodes[2];
- d3_layout_packPlace(a, b, c);
- bound(c);
- d3_layout_packInsert(a, c);
- a._pack_prev = c;
- d3_layout_packInsert(c, b);
- b = a._pack_next;
- for (i = 3; i < n; i++) {
- d3_layout_packPlace(a, b, c = nodes[i]);
- var isect = 0, s1 = 1, s2 = 1;
- for (j = b._pack_next; j !== b; j = j._pack_next, s1++) {
- if (d3_layout_packIntersects(j, c)) {
- isect = 1;
- break;
- }
- }
- if (isect == 1) {
- for (k = a._pack_prev; k !== j._pack_prev; k = k._pack_prev, s2++) {
- if (d3_layout_packIntersects(k, c)) {
- break;
- }
- }
- }
- if (isect) {
- if (s1 < s2 || s1 == s2 && b.r < a.r) d3_layout_packSplice(a, b = j); else d3_layout_packSplice(a = k, b);
- i--;
- } else {
- d3_layout_packInsert(a, c);
- b = c;
- bound(c);
- }
- }
- }
- }
- var cx = (xMin + xMax) / 2, cy = (yMin + yMax) / 2, cr = 0;
- for (i = 0; i < n; i++) {
- c = nodes[i];
- c.x -= cx;
- c.y -= cy;
- cr = Math.max(cr, c.r + Math.sqrt(c.x * c.x + c.y * c.y));
- }
- node.r = cr;
- nodes.forEach(d3_layout_packUnlink);
- }
- function d3_layout_packLink(node) {
- node._pack_next = node._pack_prev = node;
- }
- function d3_layout_packUnlink(node) {
- delete node._pack_next;
- delete node._pack_prev;
- }
- function d3_layout_packTransform(node, x, y, k) {
- var children = node.children;
- node.x = x += k * node.x;
- node.y = y += k * node.y;
- node.r *= k;
- if (children) {
- var i = -1, n = children.length;
- while (++i < n) d3_layout_packTransform(children[i], x, y, k);
- }
- }
- function d3_layout_packPlace(a, b, c) {
- var db = a.r + c.r, dx = b.x - a.x, dy = b.y - a.y;
- if (db && (dx || dy)) {
- var da = b.r + c.r, dc = dx * dx + dy * dy;
- da *= da;
- db *= db;
- var x = .5 + (db - da) / (2 * dc), y = Math.sqrt(Math.max(0, 2 * da * (db + dc) - (db -= dc) * db - da * da)) / (2 * dc);
- c.x = a.x + x * dx + y * dy;
- c.y = a.y + x * dy - y * dx;
- } else {
- c.x = a.x + db;
- c.y = a.y;
- }
- }
- function d3_layout_clusterY(children) {
- return 1 + d3.max(children, function(child) {
- return child.y;
- });
- }
- function d3_layout_clusterX(children) {
- return children.reduce(function(x, child) {
- return x + child.x;
- }, 0) / children.length;
- }
- function d3_layout_clusterLeft(node) {
- var children = node.children;
- return children && children.length ? d3_layout_clusterLeft(children[0]) : node;
- }
- function d3_layout_clusterRight(node) {
- var children = node.children, n;
- return children && (n = children.length) ? d3_layout_clusterRight(children[n - 1]) : node;
- }
- function d3_layout_treeSeparation(a, b) {
- return a.parent == b.parent ? 1 : 2;
- }
- function d3_layout_treeLeft(node) {
- var children = node.children;
- return children && children.length ? children[0] : node._tree.thread;
- }
- function d3_layout_treeRight(node) {
- var children = node.children, n;
- return children && (n = children.length) ? children[n - 1] : node._tree.thread;
- }
- function d3_layout_treeSearch(node, compare) {
- var children = node.children;
- if (children && (n = children.length)) {
- var child, n, i = -1;
- while (++i < n) {
- if (compare(child = d3_layout_treeSearch(children[i], compare), node) > 0) {
- node = child;
- }
- }
- }
- return node;
- }
- function d3_layout_treeRightmost(a, b) {
- return a.x - b.x;
- }
- function d3_layout_treeLeftmost(a, b) {
- return b.x - a.x;
- }
- function d3_layout_treeDeepest(a, b) {
- return a.depth - b.depth;
- }
- function d3_layout_treeVisitAfter(node, callback) {
- function visit(node, previousSibling) {
- var children = node.children;
- if (children && (n = children.length)) {
- var child, previousChild = null, i = -1, n;
- while (++i < n) {
- child = children[i];
- visit(child, previousChild);
- previousChild = child;
- }
- }
- callback(node, previousSibling);
- }
- visit(node, null);
- }
- function d3_layout_treeShift(node) {
- var shift = 0, change = 0, children = node.children, i = children.length, child;
- while (--i >= 0) {
- child = children[i]._tree;
- child.prelim += shift;
- child.mod += shift;
- shift += child.shift + (change += child.change);
- }
- }
- function d3_layout_treeMove(ancestor, node, shift) {
- ancestor = ancestor._tree;
- node = node._tree;
- var change = shift / (node.number - ancestor.number);
- ancestor.change += change;
- node.change -= change;
- node.shift += shift;
- node.prelim += shift;
- node.mod += shift;
- }
- function d3_layout_treeAncestor(vim, node, ancestor) {
- return vim._tree.ancestor.parent == node.parent ? vim._tree.ancestor : ancestor;
- }
- function d3_layout_treemapPadNull(node) {
- return {
- x: node.x,
- y: node.y,
- dx: node.dx,
- dy: node.dy
- };
- }
- function d3_layout_treemapPad(node, padding) {
- var x = node.x + padding[3], y = node.y + padding[0], dx = node.dx - padding[1] - padding[3], dy = node.dy - padding[0] - padding[2];
- if (dx < 0) {
- x += dx / 2;
- dx = 0;
- }
- if (dy < 0) {
- y += dy / 2;
- dy = 0;
- }
- return {
- x: x,
- y: y,
- dx: dx,
- dy: dy
- };
- }
- function d3_dsv(delimiter, mimeType) {
- function dsv(url, callback) {
- d3.text(url, mimeType, function(text) {
- callback(text && dsv.parse(text));
- });
- }
- function formatRow(row) {
- return row.map(formatValue).join(delimiter);
- }
- function formatValue(text) {
- return reFormat.test(text) ? '"' + text.replace(/\"/g, '""') + '"' : text;
- }
- var reParse = new RegExp("\r\n|[" + delimiter + "\r\n]", "g"), reFormat = new RegExp('["' + delimiter + "\n]"), delimiterCode = delimiter.charCodeAt(0);
- dsv.parse = function(text) {
- var header;
- return dsv.parseRows(text, function(row, i) {
- if (i) {
- var o = {}, j = -1, m = header.length;
- while (++j < m) o[header[j]] = row[j];
- return o;
- } else {
- header = row;
- return null;
- }
- });
- };
- dsv.parseRows = function(text, f) {
- function token() {
- if (reParse.lastIndex >= text.length) return EOF;
- if (eol) {
- eol = false;
- return EOL;
- }
- var j = reParse.lastIndex;
- if (text.charCodeAt(j) === 34) {
- var i = j;
- while (i++ < text.length) {
- if (text.charCodeAt(i) === 34) {
- if (text.charCodeAt(i + 1) !== 34) break;
- i++;
- }
- }
- reParse.lastIndex = i + 2;
- var c = text.charCodeAt(i + 1);
- if (c === 13) {
- eol = true;
- if (text.charCodeAt(i + 2) === 10) reParse.lastIndex++;
- } else if (c === 10) {
- eol = true;
- }
- return text.substring(j + 1, i).replace(/""/g, '"');
- }
- var m = reParse.exec(text);
- if (m) {
- eol = m[0].charCodeAt(0) !== delimiterCode;
- return text.substring(j, m.index);
- }
- reParse.lastIndex = text.length;
- return text.substring(j);
- }
- var EOL = {}, EOF = {}, rows = [], n = 0, t, eol;
- reParse.lastIndex = 0;
- while ((t = token()) !== EOF) {
- var a = [];
- while (t !== EOL && t !== EOF) {
- a.push(t);
- t = token();
- }
- if (f && !(a = f(a, n++))) continue;
- rows.push(a);
- }
- return rows;
- };
- dsv.format = function(rows) {
- return rows.map(formatRow).join("\n");
- };
- return dsv;
- }
- function d3_geo_type(types, defaultValue) {
- return function(object) {
- return object && types.hasOwnProperty(object.type) ? types[object.type](object) : defaultValue;
- };
- }
- function d3_path_circle(radius) {
- return "m0," + radius + "a" + radius + "," + radius + " 0 1,1 0," + -2 * radius + "a" + radius + "," + radius + " 0 1,1 0," + +2 * radius + "z";
- }
- function d3_geo_bounds(o, f) {
- if (d3_geo_boundsTypes.hasOwnProperty(o.type)) d3_geo_boundsTypes[o.type](o, f);
- }
- function d3_geo_boundsFeature(o, f) {
- d3_geo_bounds(o.geometry, f);
- }
- function d3_geo_boundsFeatureCollection(o, f) {
- for (var a = o.features, i = 0, n = a.length; i < n; i++) {
- d3_geo_bounds(a[i].geometry, f);
- }
- }
- function d3_geo_boundsGeometryCollection(o, f) {
- for (var a = o.geometries, i = 0, n = a.length; i < n; i++) {
- d3_geo_bounds(a[i], f);
- }
- }
- function d3_geo_boundsLineString(o, f) {
- for (var a = o.coordinates, i = 0, n = a.length; i < n; i++) {
- f.apply(null, a[i]);
- }
- }
- function d3_geo_boundsMultiLineString(o, f) {
- for (var a = o.coordinates, i = 0, n = a.length; i < n; i++) {
- for (var b = a[i], j = 0, m = b.length; j < m; j++) {
- f.apply(null, b[j]);
- }
- }
- }
- function d3_geo_boundsMultiPolygon(o, f) {
- for (var a = o.coordinates, i = 0, n = a.length; i < n; i++) {
- for (var b = a[i][0], j = 0, m = b.length; j < m; j++) {
- f.apply(null, b[j]);
- }
- }
- }
- function d3_geo_boundsPoint(o, f) {
- f.apply(null, o.coordinates);
- }
- function d3_geo_boundsPolygon(o, f) {
- for (var a = o.coordinates[0], i = 0, n = a.length; i < n; i++) {
- f.apply(null, a[i]);
- }
- }
- function d3_geo_greatArcSource(d) {
- return d.source;
- }
- function d3_geo_greatArcTarget(d) {
- return d.target;
- }
- function d3_geo_greatArcInterpolator() {
- function interpolate(t) {
- var B = Math.sin(t *= d) * k, A = Math.sin(d - t) * k, x = A * kx0 + B * kx1, y = A * ky0 + B * ky1, z = A * sy0 + B * sy1;
- return [ Math.atan2(y, x) / d3_geo_radians, Math.atan2(z, Math.sqrt(x * x + y * y)) / d3_geo_radians ];
- }
- var x0, y0, cy0, sy0, kx0, ky0, x1, y1, cy1, sy1, kx1, ky1, d, k;
- interpolate.distance = function() {
- if (d == null) k = 1 / Math.sin(d = Math.acos(Math.max(-1, Math.min(1, sy0 * sy1 + cy0 * cy1 * Math.cos(x1 - x0)))));
- return d;
- };
- interpolate.source = function(_) {
- var cx0 = Math.cos(x0 = _[0] * d3_geo_radians), sx0 = Math.sin(x0);
- cy0 = Math.cos(y0 = _[1] * d3_geo_radians);
- sy0 = Math.sin(y0);
- kx0 = cy0 * cx0;
- ky0 = cy0 * sx0;
- d = null;
- return interpolate;
- };
- interpolate.target = function(_) {
- var cx1 = Math.cos(x1 = _[0] * d3_geo_radians), sx1 = Math.sin(x1);
- cy1 = Math.cos(y1 = _[1] * d3_geo_radians);
- sy1 = Math.sin(y1);
- kx1 = cy1 * cx1;
- ky1 = cy1 * sx1;
- d = null;
- return interpolate;
- };
- return interpolate;
- }
- function d3_geo_greatArcInterpolate(a, b) {
- var i = d3_geo_greatArcInterpolator().source(a).target(b);
- i.distance();
- return i;
- }
- function d3_geom_contourStart(grid) {
- var x = 0, y = 0;
- while (true) {
- if (grid(x, y)) {
- return [ x, y ];
- }
- if (x === 0) {
- x = y + 1;
- y = 0;
- } else {
- x = x - 1;
- y = y + 1;
- }
- }
- }
- function d3_geom_hullCCW(i1, i2, i3, v) {
- var t, a, b, c, d, e, f;
- t = v[i1];
- a = t[0];
- b = t[1];
- t = v[i2];
- c = t[0];
- d = t[1];
- t = v[i3];
- e = t[0];
- f = t[1];
- return (f - b) * (c - a) - (d - b) * (e - a) > 0;
- }
- function d3_geom_polygonInside(p, a, b) {
- return (b[0] - a[0]) * (p[1] - a[1]) < (b[1] - a[1]) * (p[0] - a[0]);
- }
- function d3_geom_polygonIntersect(c, d, a, b) {
- var x1 = c[0], x2 = d[0], x3 = a[0], x4 = b[0], y1 = c[1], y2 = d[1], y3 = a[1], y4 = b[1], x13 = x1 - x3, x21 = x2 - x1, x43 = x4 - x3, y13 = y1 - y3, y21 = y2 - y1, y43 = y4 - y3, ua = (x43 * y13 - y43 * x13) / (y43 * x21 - x43 * y21);
- return [ x1 + ua * x21, y1 + ua * y21 ];
- }
- function d3_voronoi_tessellate(vertices, callback) {
- var Sites = {
- list: vertices.map(function(v, i) {
- return {
- index: i,
- x: v[0],
- y: v[1]
- };
- }).sort(function(a, b) {
- return a.y < b.y ? -1 : a.y > b.y ? 1 : a.x < b.x ? -1 : a.x > b.x ? 1 : 0;
- }),
- bottomSite: null
- };
- var EdgeList = {
- list: [],
- leftEnd: null,
- rightEnd: null,
- init: function() {
- EdgeList.leftEnd = EdgeList.createHalfEdge(null, "l");
- EdgeList.rightEnd = EdgeList.createHalfEdge(null, "l");
- EdgeList.leftEnd.r = EdgeList.rightEnd;
- EdgeList.rightEnd.l = EdgeList.leftEnd;
- EdgeList.list.unshift(EdgeList.leftEnd, EdgeList.rightEnd);
- },
- createHalfEdge: function(edge, side) {
- return {
- edge: edge,
- side: side,
- vertex: null,
- l: null,
- r: null
- };
- },
- insert: function(lb, he) {
- he.l = lb;
- he.r = lb.r;
- lb.r.l = he;
- lb.r = he;
- },
- leftBound: function(p) {
- var he = EdgeList.leftEnd;
- do {
- he = he.r;
- } while (he != EdgeList.rightEnd && Geom.rightOf(he, p));
- he = he.l;
- return he;
- },
- del: function(he) {
- he.l.r = he.r;
- he.r.l = he.l;
- he.edge = null;
- },
- right: function(he) {
- return he.r;
- },
- left: function(he) {
- return he.l;
- },
- leftRegion: function(he) {
- return he.edge == null ? Sites.bottomSite : he.edge.region[he.side];
- },
- rightRegion: function(he) {
- return he.edge == null ? Sites.bottomSite : he.edge.region[d3_voronoi_opposite[he.side]];
- }
- };
- var Geom = {
- bisect: function(s1, s2) {
- var newEdge = {
- region: {
- l: s1,
- r: s2
- },
- ep: {
- l: null,
- r: null
- }
- };
- var dx = s2.x - s1.x, dy = s2.y - s1.y, adx = dx > 0 ? dx : -dx, ady = dy > 0 ? dy : -dy;
- newEdge.c = s1.x * dx + s1.y * dy + (dx * dx + dy * dy) * .5;
- if (adx > ady) {
- newEdge.a = 1;
- newEdge.b = dy / dx;
- newEdge.c /= dx;
- } else {
- newEdge.b = 1;
- newEdge.a = dx / dy;
- newEdge.c /= dy;
- }
- return newEdge;
- },
- intersect: function(el1, el2) {
- var e1 = el1.edge, e2 = el2.edge;
- if (!e1 || !e2 || e1.region.r == e2.region.r) {
- return null;
- }
- var d = e1.a * e2.b - e1.b * e2.a;
- if (Math.abs(d) < 1e-10) {
- return null;
- }
- var xint = (e1.c * e2.b - e2.c * e1.b) / d, yint = (e2.c * e1.a - e1.c * e2.a) / d, e1r = e1.region.r, e2r = e2.region.r, el, e;
- if (e1r.y < e2r.y || e1r.y == e2r.y && e1r.x < e2r.x) {
- el = el1;
- e = e1;
- } else {
- el = el2;
- e = e2;
- }
- var rightOfSite = xint >= e.region.r.x;
- if (rightOfSite && el.side === "l" || !rightOfSite && el.side === "r") {
- return null;
- }
- return {
- x: xint,
- y: yint
- };
- },
- rightOf: function(he, p) {
- var e = he.edge, topsite = e.region.r, rightOfSite = p.x > topsite.x;
- if (rightOfSite && he.side === "l") {
- return 1;
- }
- if (!rightOfSite && he.side === "r") {
- return 0;
- }
- if (e.a === 1) {
- var dyp = p.y - topsite.y, dxp = p.x - topsite.x, fast = 0, above = 0;
- if (!rightOfSite && e.b < 0 || rightOfSite && e.b >= 0) {
- above = fast = dyp >= e.b * dxp;
- } else {
- above = p.x + p.y * e.b > e.c;
- if (e.b < 0) {
- above = !above;
- }
- if (!above) {
- fast = 1;
- }
- }
- if (!fast) {
- var dxs = topsite.x - e.region.l.x;
- above = e.b * (dxp * dxp - dyp * dyp) < dxs * dyp * (1 + 2 * dxp / dxs + e.b * e.b);
- if (e.b < 0) {
- above = !above;
- }
- }
- } else {
- var yl = e.c - e.a * p.x, t1 = p.y - yl, t2 = p.x - topsite.x, t3 = yl - topsite.y;
- above = t1 * t1 > t2 * t2 + t3 * t3;
- }
- return he.side === "l" ? above : !above;
- },
- endPoint: function(edge, side, site) {
- edge.ep[side] = site;
- if (!edge.ep[d3_voronoi_opposite[side]]) return;
- callback(edge);
- },
- distance: function(s, t) {
- var dx = s.x - t.x, dy = s.y - t.y;
- return Math.sqrt(dx * dx + dy * dy);
- }
- };
- var EventQueue = {
- list: [],
- insert: function(he, site, offset) {
- he.vertex = site;
- he.ystar = site.y + offset;
- for (var i = 0, list = EventQueue.list, l = list.length; i < l; i++) {
- var next = list[i];
- if (he.ystar > next.ystar || he.ystar == next.ystar && site.x > next.vertex.x) {
- continue;
- } else {
- break;
- }
- }
- list.splice(i, 0, he);
- },
- del: function(he) {
- for (var i = 0, ls = EventQueue.list, l = ls.length; i < l && ls[i] != he; ++i) {}
- ls.splice(i, 1);
- },
- empty: function() {
- return EventQueue.list.length === 0;
- },
- nextEvent: function(he) {
- for (var i = 0, ls = EventQueue.list, l = ls.length; i < l; ++i) {
- if (ls[i] == he) return ls[i + 1];
- }
- return null;
- },
- min: function() {
- var elem = EventQueue.list[0];
- return {
- x: elem.vertex.x,
- y: elem.ystar
- };
- },
- extractMin: function() {
- return EventQueue.list.shift();
- }
- };
- EdgeList.init();
- Sites.bottomSite = Sites.list.shift();
- var newSite = Sites.list.shift(), newIntStar;
- var lbnd, rbnd, llbnd, rrbnd, bisector;
- var bot, top, temp, p, v;
- var e, pm;
- while (true) {
- if (!EventQueue.empty()) {
- newIntStar = EventQueue.min();
- }
- if (newSite && (EventQueue.empty() || newSite.y < newIntStar.y || newSite.y == newIntStar.y && newSite.x < newIntStar.x)) {
- lbnd = EdgeList.leftBound(newSite);
- rbnd = EdgeList.right(lbnd);
- bot = EdgeList.rightRegion(lbnd);
- e = Geom.bisect(bot, newSite);
- bisector = EdgeList.createHalfEdge(e, "l");
- EdgeList.insert(lbnd, bisector);
- p = Geom.intersect(lbnd, bisector);
- if (p) {
- EventQueue.del(lbnd);
- EventQueue.insert(lbnd, p, Geom.distance(p, newSite));
- }
- lbnd = bisector;
- bisector = EdgeList.createHalfEdge(e, "r");
- EdgeList.insert(lbnd, bisector);
- p = Geom.intersect(bisector, rbnd);
- if (p) {
- EventQueue.insert(bisector, p, Geom.distance(p, newSite));
- }
- newSite = Sites.list.shift();
- } else if (!EventQueue.empty()) {
- lbnd = EventQueue.extractMin();
- llbnd = EdgeList.left(lbnd);
- rbnd = EdgeList.right(lbnd);
- rrbnd = EdgeList.right(rbnd);
- bot = EdgeList.leftRegion(lbnd);
- top = EdgeList.rightRegion(rbnd);
- v = lbnd.vertex;
- Geom.endPoint(lbnd.edge, lbnd.side, v);
- Geom.endPoint(rbnd.edge, rbnd.side, v);
- EdgeList.del(lbnd);
- EventQueue.del(rbnd);
- EdgeList.del(rbnd);
- pm = "l";
- if (bot.y > top.y) {
- temp = bot;
- bot = top;
- top = temp;
- pm = "r";
- }
- e = Geom.bisect(bot, top);
- bisector = EdgeList.createHalfEdge(e, pm);
- EdgeList.insert(llbnd, bisector);
- Geom.endPoint(e, d3_voronoi_opposite[pm], v);
- p = Geom.intersect(llbnd, bisector);
- if (p) {
- EventQueue.del(llbnd);
- EventQueue.insert(llbnd, p, Geom.distance(p, bot));
- }
- p = Geom.intersect(bisector, rrbnd);
- if (p) {
- EventQueue.insert(bisector, p, Geom.distance(p, bot));
- }
- } else {
- break;
- }
- }
- for (lbnd = EdgeList.right(EdgeList.leftEnd); lbnd != EdgeList.rightEnd; lbnd = EdgeList.right(lbnd)) {
- callback(lbnd.edge);
- }
- }
- function d3_geom_quadtreeNode() {
- return {
- leaf: true,
- nodes: [],
- point: null
- };
- }
- function d3_geom_quadtreeVisit(f, node, x1, y1, x2, y2) {
- if (!f(node, x1, y1, x2, y2)) {
- var sx = (x1 + x2) * .5, sy = (y1 + y2) * .5, children = node.nodes;
- if (children[0]) d3_geom_quadtreeVisit(f, children[0], x1, y1, sx, sy);
- if (children[1]) d3_geom_quadtreeVisit(f, children[1], sx, y1, x2, sy);
- if (children[2]) d3_geom_quadtreeVisit(f, children[2], x1, sy, sx, y2);
- if (children[3]) d3_geom_quadtreeVisit(f, children[3], sx, sy, x2, y2);
- }
- }
- function d3_geom_quadtreePoint(p) {
- return {
- x: p[0],
- y: p[1]
- };
- }
- function d3_time_utc() {
- this._ = new Date(arguments.length > 1 ? Date.UTC.apply(this, arguments) : arguments[0]);
- }
- function d3_time_formatAbbreviate(name) {
- return name.substring(0, 3);
- }
- function d3_time_parse(date, template, string, j) {
- var c, p, i = 0, n = template.length, m = string.length;
- while (i < n) {
- if (j >= m) return -1;
- c = template.charCodeAt(i++);
- if (c == 37) {
- p = d3_time_parsers[template.charAt(i++)];
- if (!p || (j = p(date, string, j)) < 0) return -1;
- } else if (c != string.charCodeAt(j++)) {
- return -1;
- }
- }
- return j;
- }
- function d3_time_formatRe(names) {
- return new RegExp("^(?:" + names.map(d3.requote).join("|") + ")", "i");
- }
- function d3_time_formatLookup(names) {
- var map = new d3_Map, i = -1, n = names.length;
- while (++i < n) map.set(names[i].toLowerCase(), i);
- return map;
- }
- function d3_time_parseWeekdayAbbrev(date, string, i) {
- d3_time_dayAbbrevRe.lastIndex = 0;
- var n = d3_time_dayAbbrevRe.exec(string.substring(i));
- return n ? i += n[0].length : -1;
- }
- function d3_time_parseWeekday(date, string, i) {
- d3_time_dayRe.lastIndex = 0;
- var n = d3_time_dayRe.exec(string.substring(i));
- return n ? i += n[0].length : -1;
- }
- function d3_time_parseMonthAbbrev(date, string, i) {
- d3_time_monthAbbrevRe.lastIndex = 0;
- var n = d3_time_monthAbbrevRe.exec(string.substring(i));
- return n ? (date.m = d3_time_monthAbbrevLookup.get(n[0].toLowerCase()), i += n[0].length) : -1;
- }
- function d3_time_parseMonth(date, string, i) {
- d3_time_monthRe.lastIndex = 0;
- var n = d3_time_monthRe.exec(string.substring(i));
- return n ? (date.m = d3_time_monthLookup.get(n[0].toLowerCase()), i += n[0].length) : -1;
- }
- function d3_time_parseLocaleFull(date, string, i) {
- return d3_time_parse(date, d3_time_formats.c.toString(), string, i);
- }
- function d3_time_parseLocaleDate(date, string, i) {
- return d3_time_parse(date, d3_time_formats.x.toString(), string, i);
- }
- function d3_time_parseLocaleTime(date, string, i) {
- return d3_time_parse(date, d3_time_formats.X.toString(), string, i);
- }
- function d3_time_parseFullYear(date, string, i) {
- d3_time_numberRe.lastIndex = 0;
- var n = d3_time_numberRe.exec(string.substring(i, i + 4));
- return n ? (date.y = +n[0], i += n[0].length) : -1;
- }
- function d3_time_parseYear(date, string, i) {
- d3_time_numberRe.lastIndex = 0;
- var n = d3_time_numberRe.exec(string.substring(i, i + 2));
- return n ? (date.y = d3_time_expandYear(+n[0]), i += n[0].length) : -1;
- }
- function d3_time_expandYear(d) {
- return d + (d > 68 ? 1900 : 2e3);
- }
- function d3_time_parseMonthNumber(date, string, i) {
- d3_time_numberRe.lastIndex = 0;
- var n = d3_time_numberRe.exec(string.substring(i, i + 2));
- return n ? (date.m = n[0] - 1, i += n[0].length) : -1;
- }
- function d3_time_parseDay(date, string, i) {
- d3_time_numberRe.lastIndex = 0;
- var n = d3_time_numberRe.exec(string.substring(i, i + 2));
- return n ? (date.d = +n[0], i += n[0].length) : -1;
- }
- function d3_time_parseHour24(date, string, i) {
- d3_time_numberRe.lastIndex = 0;
- var n = d3_time_numberRe.exec(string.substring(i, i + 2));
- return n ? (date.H = +n[0], i += n[0].length) : -1;
- }
- function d3_time_parseMinutes(date, string, i) {
- d3_time_numberRe.lastIndex = 0;
- var n = d3_time_numberRe.exec(string.substring(i, i + 2));
- return n ? (date.M = +n[0], i += n[0].length) : -1;
- }
- function d3_time_parseSeconds(date, string, i) {
- d3_time_numberRe.lastIndex = 0;
- var n = d3_time_numberRe.exec(string.substring(i, i + 2));
- return n ? (date.S = +n[0], i += n[0].length) : -1;
- }
- function d3_time_parseMilliseconds(date, string, i) {
- d3_time_numberRe.lastIndex = 0;
- var n = d3_time_numberRe.exec(string.substring(i, i + 3));
- return n ? (date.L = +n[0], i += n[0].length) : -1;
- }
- function d3_time_parseAmPm(date, string, i) {
- var n = d3_time_amPmLookup.get(string.substring(i, i += 2).toLowerCase());
- return n == null ? -1 : (date.p = n, i);
- }
- function d3_time_zone(d) {
- var z = d.getTimezoneOffset(), zs = z > 0 ? "-" : "+", zh = ~~(Math.abs(z) / 60), zm = Math.abs(z) % 60;
- return zs + d3_time_zfill2(zh) + d3_time_zfill2(zm);
- }
- function d3_time_formatIsoNative(date) {
- return date.toISOString();
- }
- function d3_time_interval(local, step, number) {
- function round(date) {
- var d0 = local(date), d1 = offset(d0, 1);
- return date - d0 < d1 - date ? d0 : d1;
- }
- function ceil(date) {
- step(date = local(new d3_time(date - 1)), 1);
- return date;
- }
- function offset(date, k) {
- step(date = new d3_time(+date), k);
- return date;
- }
- function range(t0, t1, dt) {
- var time = ceil(t0), times = [];
- if (dt > 1) {
- while (time < t1) {
- if (!(number(time) % dt)) times.push(new Date(+time));
- step(time, 1);
- }
- } else {
- while (time < t1) times.push(new Date(+time)), step(time, 1);
- }
- return times;
- }
- function range_utc(t0, t1, dt) {
- try {
- d3_time = d3_time_utc;
- var utc = new d3_time_utc;
- utc._ = t0;
- return range(utc, t1, dt);
- } finally {
- d3_time = Date;
- }
- }
- local.floor = local;
- local.round = round;
- local.ceil = ceil;
- local.offset = offset;
- local.range = range;
- var utc = local.utc = d3_time_interval_utc(local);
- utc.floor = utc;
- utc.round = d3_time_interval_utc(round);
- utc.ceil = d3_time_interval_utc(ceil);
- utc.offset = d3_time_interval_utc(offset);
- utc.range = range_utc;
- return local;
- }
- function d3_time_interval_utc(method) {
- return function(date, k) {
- try {
- d3_time = d3_time_utc;
- var utc = new d3_time_utc;
- utc._ = date;
- return method(utc, k)._;
- } finally {
- d3_time = Date;
- }
- };
- }
- function d3_time_scale(linear, methods, format) {
- function scale(x) {
- return linear(x);
- }
- scale.invert = function(x) {
- return d3_time_scaleDate(linear.invert(x));
- };
- scale.domain = function(x) {
- if (!arguments.length) return linear.domain().map(d3_time_scaleDate);
- linear.domain(x);
- return scale;
- };
- scale.nice = function(m) {
- return scale.domain(d3_scale_nice(scale.domain(), function() {
- return m;
- }));
- };
- scale.ticks = function(m, k) {
- var extent = d3_time_scaleExtent(scale.domain());
- if (typeof m !== "function") {
- var span = extent[1] - extent[0], target = span / m, i = d3.bisect(d3_time_scaleSteps, target);
- if (i == d3_time_scaleSteps.length) return methods.year(extent, m);
- if (!i) return linear.ticks(m).map(d3_time_scaleDate);
- if (Math.log(target / d3_time_scaleSteps[i - 1]) < Math.log(d3_time_scaleSteps[i] / target)) --i;
- m = methods[i];
- k = m[1];
- m = m[0].range;
- }
- return m(extent[0], new Date(+extent[1] + 1), k);
- };
- scale.tickFormat = function() {
- return format;
- };
- scale.copy = function() {
- return d3_time_scale(linear.copy(), methods, format);
- };
- return d3.rebind(scale, linear, "range", "rangeRound", "interpolate", "clamp");
- }
- function d3_time_scaleExtent(domain) {
- var start = domain[0], stop = domain[domain.length - 1];
- return start < stop ? [ start, stop ] : [ stop, start ];
- }
- function d3_time_scaleDate(t) {
- return new Date(t);
- }
- function d3_time_scaleFormat(formats) {
- return function(date) {
- var i = formats.length - 1, f = formats[i];
- while (!f[1](date)) f = formats[--i];
- return f[0](date);
- };
- }
- function d3_time_scaleSetYear(y) {
- var d = new Date(y, 0, 1);
- d.setFullYear(y);
- return d;
- }
- function d3_time_scaleGetYear(d) {
- var y = d.getFullYear(), d0 = d3_time_scaleSetYear(y), d1 = d3_time_scaleSetYear(y + 1);
- return y + (d - d0) / (d1 - d0);
- }
- function d3_time_scaleUTCSetYear(y) {
- var d = new Date(Date.UTC(y, 0, 1));
- d.setUTCFullYear(y);
- return d;
- }
- function d3_time_scaleUTCGetYear(d) {
- var y = d.getUTCFullYear(), d0 = d3_time_scaleUTCSetYear(y), d1 = d3_time_scaleUTCSetYear(y + 1);
- return y + (d - d0) / (d1 - d0);
- }
- if (!Date.now) Date.now = function() {
- return +(new Date);
- };
- try {
- document.createElement("div").style.setProperty("opacity", 0, "");
- } catch (error) {
- var d3_style_prototype = CSSStyleDeclaration.prototype, d3_style_setProperty = d3_style_prototype.setProperty;
- d3_style_prototype.setProperty = function(name, value, priority) {
- d3_style_setProperty.call(this, name, value + "", priority);
- };
- }
- d3 = {
- version: "2.10.3"
- };
- var d3_array = d3_arraySlice;
- try {
- d3_array(document.documentElement.childNodes)[0].nodeType;
- } catch (e) {
- d3_array = d3_arrayCopy;
- }
- var d3_arraySubclass = [].__proto__ ? function(array, prototype) {
- array.__proto__ = prototype;
- } : function(array, prototype) {
- for (var property in prototype) array[property] = prototype[property];
- };
- d3.map = function(object) {
- var map = new d3_Map;
- for (var key in object) map.set(key, object[key]);
- return map;
- };
- d3_class(d3_Map, {
- has: function(key) {
- return d3_map_prefix + key in this;
- },
- get: function(key) {
- return this[d3_map_prefix + key];
- },
- set: function(key, value) {
- return this[d3_map_prefix + key] = value;
- },
- remove: function(key) {
- key = d3_map_prefix + key;
- return key in this && delete this[key];
- },
- keys: function() {
- var keys = [];
- this.forEach(function(key) {
- keys.push(key);
- });
- return keys;
- },
- values: function() {
- var values = [];
- this.forEach(function(key, value) {
- values.push(value);
- });
- return values;
- },
- entries: function() {
- var entries = [];
- this.forEach(function(key, value) {
- entries.push({
- key: key,
- value: value
- });
- });
- return entries;
- },
- forEach: function(f) {
- for (var key in this) {
- if (key.charCodeAt(0) === d3_map_prefixCode) {
- f.call(this, key.substring(1), this[key]);
- }
- }
- }
- });
- var d3_map_prefix = "\0", d3_map_prefixCode = d3_map_prefix.charCodeAt(0);
- d3.functor = d3_functor;
- d3.rebind = function(target, source) {
- var i = 1, n = arguments.length, method;
- while (++i < n) target[method = arguments[i]] = d3_rebind(target, source, source[method]);
- return target;
- };
- d3.ascending = function(a, b) {
- return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
- };
- d3.descending = function(a, b) {
- return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;
- };
- d3.mean = function(array, f) {
- var n = array.length, a, m = 0, i = -1, j = 0;
- if (arguments.length === 1) {
- while (++i < n) if (d3_number(a = array[i])) m += (a - m) / ++j;
- } else {
- while (++i < n) if (d3_number(a = f.call(array, array[i], i))) m += (a - m) / ++j;
- }
- return j ? m : undefined;
- };
- d3.median = function(array, f) {
- if (arguments.length > 1) array = array.map(f);
- array = array.filter(d3_number);
- return array.length ? d3.quantile(array.sort(d3.ascending), .5) : undefined;
- };
- d3.min = function(array, f) {
- var i = -1, n = array.length, a, b;
- if (arguments.length === 1) {
- while (++i < n && ((a = array[i]) == null || a != a)) a = undefined;
- while (++i < n) if ((b = array[i]) != null && a > b) a = b;
- } else {
- while (++i < n && ((a = f.call(array, array[i], i)) == null || a != a)) a = undefined;
- while (++i < n) if ((b = f.call(array, array[i], i)) != null && a > b) a = b;
- }
- return a;
- };
- d3.max = function(array, f) {
- var i = -1, n = array.length, a, b;
- if (arguments.length === 1) {
- while (++i < n && ((a = array[i]) == null || a != a)) a = undefined;
- while (++i < n) if ((b = array[i]) != null && b > a) a = b;
- } else {
- while (++i < n && ((a = f.call(array, array[i], i)) == null || a != a)) a = undefined;
- while (++i < n) if ((b = f.call(array, array[i], i)) != null && b > a) a = b;
- }
- return a;
- };
- d3.extent = function(array, f) {
- var i = -1, n = array.length, a, b, c;
- if (arguments.length === 1) {
- while (++i < n && ((a = c = array[i]) == null || a != a)) a = c = undefined;
- while (++i < n) if ((b = array[i]) != null) {
- if (a > b) a = b;
- if (c < b) c = b;
- }
- } else {
- while (++i < n && ((a = c = f.call(array, array[i], i)) == null || a != a)) a = undefined;
- while (++i < n) if ((b = f.call(array, array[i], i)) != null) {
- if (a > b) a = b;
- if (c < b) c = b;
- }
- }
- return [ a, c ];
- };
- d3.random = {
- normal: function(Āµ, Ļ) {
- var n = arguments.length;
- if (n < 2) Ļ = 1;
- if (n < 1) Āµ = 0;
- return function() {
- var x, y, r;
- do {
<TRUNCATED>
[07/26] Remove fauxton from 1.4.x branch.
Posted by dj...@apache.org.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/test/mocha/mocha.css
----------------------------------------------------------------------
diff --git a/src/fauxton/test/mocha/mocha.css b/src/fauxton/test/mocha/mocha.css
deleted file mode 100755
index 1d74784..0000000
--- a/src/fauxton/test/mocha/mocha.css
+++ /dev/null
@@ -1,251 +0,0 @@
-@charset "utf-8";
-
-body {
- margin:0;
-}
-
-#mocha {
- font: 20px/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif;
- margin: 60px 50px;
-}
-
-#mocha ul, #mocha li {
- margin: 0;
- padding: 0;
-}
-
-#mocha ul {
- list-style: none;
-}
-
-#mocha h1, #mocha h2 {
- margin: 0;
-}
-
-#mocha h1 {
- margin-top: 15px;
- font-size: 1em;
- font-weight: 200;
-}
-
-#mocha h1 a {
- text-decoration: none;
- color: inherit;
-}
-
-#mocha h1 a:hover {
- text-decoration: underline;
-}
-
-#mocha .suite .suite h1 {
- margin-top: 0;
- font-size: .8em;
-}
-
-#mocha .hidden {
- display: none;
-}
-
-#mocha h2 {
- font-size: 12px;
- font-weight: normal;
- cursor: pointer;
-}
-
-#mocha .suite {
- margin-left: 15px;
-}
-
-#mocha .test {
- margin-left: 15px;
- overflow: hidden;
-}
-
-#mocha .test.pending:hover h2::after {
- content: '(pending)';
- font-family: arial, sans-serif;
-}
-
-#mocha .test.pass.medium .duration {
- background: #C09853;
-}
-
-#mocha .test.pass.slow .duration {
- background: #B94A48;
-}
-
-#mocha .test.pass::before {
- content: 'ā';
- font-size: 12px;
- display: block;
- float: left;
- margin-right: 5px;
- color: #00d6b2;
-}
-
-#mocha .test.pass .duration {
- font-size: 9px;
- margin-left: 5px;
- padding: 2px 5px;
- color: white;
- -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.2);
- -moz-box-shadow: inset 0 1px 1px rgba(0,0,0,.2);
- box-shadow: inset 0 1px 1px rgba(0,0,0,.2);
- -webkit-border-radius: 5px;
- -moz-border-radius: 5px;
- -ms-border-radius: 5px;
- -o-border-radius: 5px;
- border-radius: 5px;
-}
-
-#mocha .test.pass.fast .duration {
- display: none;
-}
-
-#mocha .test.pending {
- color: #0b97c4;
-}
-
-#mocha .test.pending::before {
- content: 'ā¦';
- color: #0b97c4;
-}
-
-#mocha .test.fail {
- color: #c00;
-}
-
-#mocha .test.fail pre {
- color: black;
-}
-
-#mocha .test.fail::before {
- content: 'ā';
- font-size: 12px;
- display: block;
- float: left;
- margin-right: 5px;
- color: #c00;
-}
-
-#mocha .test pre.error {
- color: #c00;
- max-height: 300px;
- overflow: auto;
-}
-
-#mocha .test pre {
- display: block;
- float: left;
- clear: left;
- font: 12px/1.5 monaco, monospace;
- margin: 5px;
- padding: 15px;
- border: 1px solid #eee;
- border-bottom-color: #ddd;
- -webkit-border-radius: 3px;
- -webkit-box-shadow: 0 1px 3px #eee;
- -moz-border-radius: 3px;
- -moz-box-shadow: 0 1px 3px #eee;
-}
-
-#mocha .test h2 {
- position: relative;
-}
-
-#mocha .test a.replay {
- position: absolute;
- top: 3px;
- right: 0;
- text-decoration: none;
- vertical-align: middle;
- display: block;
- width: 15px;
- height: 15px;
- line-height: 15px;
- text-align: center;
- background: #eee;
- font-size: 15px;
- -moz-border-radius: 15px;
- border-radius: 15px;
- -webkit-transition: opacity 200ms;
- -moz-transition: opacity 200ms;
- transition: opacity 200ms;
- opacity: 0.3;
- color: #888;
-}
-
-#mocha .test:hover a.replay {
- opacity: 1;
-}
-
-#mocha-report.pass .test.fail {
- display: none;
-}
-
-#mocha-report.fail .test.pass {
- display: none;
-}
-
-#mocha-error {
- color: #c00;
- font-size: 1.5em;
- font-weight: 100;
- letter-spacing: 1px;
-}
-
-#mocha-stats {
- position: fixed;
- top: 15px;
- right: 10px;
- font-size: 12px;
- margin: 0;
- color: #888;
- z-index: 1;
-}
-
-#mocha-stats .progress {
- float: right;
- padding-top: 0;
-}
-
-#mocha-stats em {
- color: black;
-}
-
-#mocha-stats a {
- text-decoration: none;
- color: inherit;
-}
-
-#mocha-stats a:hover {
- border-bottom: 1px solid #eee;
-}
-
-#mocha-stats li {
- display: inline-block;
- margin: 0 5px;
- list-style: none;
- padding-top: 11px;
-}
-
-#mocha-stats canvas {
- width: 40px;
- height: 40px;
-}
-
-#mocha code .comment { color: #ddd }
-#mocha code .init { color: #2F6FAD }
-#mocha code .string { color: #5890AD }
-#mocha code .keyword { color: #8A6343 }
-#mocha code .number { color: #2F6FAD }
-
-@media screen and (max-device-width: 480px) {
- #mocha {
- margin: 60px 0px;
- }
-
- #mocha #stats {
- position: absolute;
- }
-}
[22/26] Remove fauxton from 1.4.x branch.
Posted by dj...@apache.org.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/templates/documents/changes.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/changes.html b/src/fauxton/app/templates/documents/changes.html
deleted file mode 100644
index e528a1c..0000000
--- a/src/fauxton/app/templates/documents/changes.html
+++ /dev/null
@@ -1,38 +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.
--->
-
-<table class="table">
- <thead>
- <th> seq </th>
- <th> id </th>
- <th> changes </th>
- <th> deleted? </th>
- </thead>
- <tbody>
- <% _.each(changes, function (change) { %>
- <tr>
- <td> <%= change.seq %> </td>
- <% if (change.deleted) { %>
- <td> <%= change.id %> </td>
- <% } else { %>
- <td> <a href="#<%= database.url('app') %>/<%= change.id %>"><%= change.id %></a> </td>
- <% } %>
- <td>
- <pre class="prettyprint"> <%= JSON.stringify({changes: change.changes, doc: change.doc}, null, " ") %> </pre>
- </td>
- <td><%= change.deleted ? "true" : "false" %></td>
- </tr>
- <% }); %>
- </tbody>
-</table>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/templates/documents/ddoc_info.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/ddoc_info.html b/src/fauxton/app/templates/documents/ddoc_info.html
deleted file mode 100644
index 15dfe48..0000000
--- a/src/fauxton/app/templates/documents/ddoc_info.html
+++ /dev/null
@@ -1,21 +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.
--->
-<div class="well" >
- <h2> Design Doc MetaData </h2>
- <ul style="list-style-type: none;">
- <% _.each(view_index, function (val, key) { %>
- <li><strong> <%= key %></strong> : <%= val %> </li>
- <% }); %>
- </ul>
-</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/templates/documents/doc.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/doc.html b/src/fauxton/app/templates/documents/doc.html
deleted file mode 100644
index 6cca488..0000000
--- a/src/fauxton/app/templates/documents/doc.html
+++ /dev/null
@@ -1,41 +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.
--->
-
-<div id="doc">
- <div class="errors-container"></div>
- <% if (attachments) { %>
- <div class="btn-group pull-right" style="margin-bottom: 15px">
- <a class="btn dropdown-toggle btn" data-toggle="dropdown" href="#">
- View Attachments
- <span class="caret"></span>
- </a>
- <ul class="dropdown-menu">
- <%_.each(attachments, function (att) { %>
- <li>
- <a href="<%= att.url %>" target="_blank"> <strong> <%= att.fileName %> </strong> -
- <span> <%= att.contentType %>, <%= formatSize(att.size)%> </span>
- </a>
- </li>
- <% }) %>
- </ul>
- </div>
- <% } %>
-
- <textarea class="doc-code"><%= JSON.stringify(doc.attributes, null, " ") %></textarea>
- <br />
- <p>
- <button class="save-doc btn btn-large btn-primary" type="button">Save</button>
- </p>
-
-</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/templates/documents/doc_field_editor.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/doc_field_editor.html b/src/fauxton/app/templates/documents/doc_field_editor.html
deleted file mode 100644
index c9ce32b..0000000
--- a/src/fauxton/app/templates/documents/doc_field_editor.html
+++ /dev/null
@@ -1,74 +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.
--->
-
-<div id="doc-field-editor">
- <div class="tools">
-
- <div class="btn-toolbar pull-left">
- <button class="btn btn-small all">✓ All</button>
- <button class="btn btn-small disabled delete"><i class="icon-trash"></i> Delete field</button>
- <button class="btn btn-small new" style="margin-left: 64px"><i class="icon-plus"></i> New field</button>
- </div>
- <div class="btn-toolbar pull-right">
- <button class="btn btn-small cancel">Cancel</button>
- <button class="btn btn-small save">Save</button>
- </div>
- </div>
-
- <div class="clearfix"></div>
- <!-- <hr style="margin-top: 0"/> -->
-
- <table class="table table-striped table-condensed">
- <thead>
- <tr>
- <th class="select">
- </th>
- <th>Key</th>
- <th>Value</th>
- </tr>
- </thead>
- <tbody>
- <tr style="display:none">
- <td class="select"><input type="checkbox" /></td>
- <td class="key"><input type="text" class="input-large" value='' /></td>
- <td class="value"><input type="text" class="input-xxlarge" value='' /></td>
- </tr>
- <% _.each(doc, function(value, key) { %>
- <tr>
- <td class="select"><input type="checkbox" /></td>
- <td class="key">
- <input type="text" class="input-large" name="doc[<%= key %>]" value="<%= key %>" />
- </td>
- <td class="value"><input type="text" class="input-xxlarge" value='<%= JSON.stringify(value) %>' /></td>
- </tr>
- <% }); %>
- <tr>
- <th colspan="3">
- Attachments
- </th>
- </tr>
- <%_.each(attachments, function (att) { %>
- <tr>
- <td class="select"><input type="checkbox" /></td>
- <td colspan="2">
- <a href="<%= att.url %>" target="_blank"> <%= att.fileName %> </a>
- <span> <%= att.contentType %>, <%= formatSize(att.size)%> </span>
- </td>
- </tr>
- <% }) %>
- </tbody>
- </table>
- <a class="btn btn-small new" style="margin-left: 64px"><i class="icon-plus"></i> New field</a>
-
-</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/templates/documents/doc_field_editor_tabs.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/doc_field_editor_tabs.html b/src/fauxton/app/templates/documents/doc_field_editor_tabs.html
deleted file mode 100644
index fcc2b53..0000000
--- a/src/fauxton/app/templates/documents/doc_field_editor_tabs.html
+++ /dev/null
@@ -1,30 +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.
--->
-
-<ul class="nav nav-tabs">
- <li id="field_editor" class="<%= isSelectedClass('field_editor') %>"><a href="#<%= doc.url('app') %>/field_editor">Doc fields</a></li>
- <li id="code_editor" class="<%= isSelectedClass('code_editor') %>"><a href="#<%= doc.url('app') %>/code_editor"><i class="icon-pencil"></i> Code editor</a></li>
- <ul class="nav pull-right" style="margin:5px 10px 0px 10px;">
- <li>
- <div class="btn-group">
- <button class="btn btn-small upload"><i class="icon-circle-arrow-up"></i> Upload Attachment</button>
- <button class="btn btn-small duplicate"><i class="icon-repeat"></i> Duplicate document</button>
- <button class="btn btn-small delete"><i class="icon-trash"></i> Delete document</button>
- </div>
- </li>
- </ul>
-</ul>
-
-<div id="upload-modal"> </div>
-<div id="duplicate-modal"> </div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/templates/documents/duplicate_doc_modal.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/duplicate_doc_modal.html b/src/fauxton/app/templates/documents/duplicate_doc_modal.html
deleted file mode 100644
index dba8d44..0000000
--- a/src/fauxton/app/templates/documents/duplicate_doc_modal.html
+++ /dev/null
@@ -1,36 +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.
--->
-
-<div class="modal hide fade">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
- <h3>Duplicate Document</h3>
- </div>
- <div class="modal-body">
- <div id="modal-error" class="hide alert alert-error"/>
- <form id="file-upload" class="form" method="post">
- <p class="help-block">
- Set new documents ID:
- </p>
- <input id="dup-id" type="text" class="input-xlarge">
- </form>
-
- </div>
- <div class="modal-footer">
- <a href="#" data-dismiss="modal" class="btn">Cancel</a>
- <a href="#" id="duplicate-btn" class="btn btn-primary">Duplicate</a>
- </div>
-</div>
-
-
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/templates/documents/index_menu_item.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/index_menu_item.html b/src/fauxton/app/templates/documents/index_menu_item.html
deleted file mode 100644
index cb9aaf0..0000000
--- a/src/fauxton/app/templates/documents/index_menu_item.html
+++ /dev/null
@@ -1,17 +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.
--->
-
-<a id="<%= ddoc %>_<%= index %>" href="#database/<%= database %>/_design/<%= ddoc %>/_view/<%= index %>" class="toggle-view">
- <i class="icon-list"></i> <%= ddoc %><span class="divider">/</span><%= index %>
-</a>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/templates/documents/index_row_docular.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/index_row_docular.html b/src/fauxton/app/templates/documents/index_row_docular.html
deleted file mode 100644
index 26c0280..0000000
--- a/src/fauxton/app/templates/documents/index_row_docular.html
+++ /dev/null
@@ -1,26 +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.
--->
-
-<td class="select"><input type="checkbox"></td>
-<td>
- <div>
- <pre class="prettyprint"><%= doc.prettyJSON() %></pre>
- <% if (doc.isEditable()) { %>
- <div class="btn-group">
- <a href="#<%= doc.url('app') %>" class="btn btn-small edits">Edit <%= doc.docType() %></a>
- <button href="#" class="btn btn-small btn-danger delete" title="Delete this document."><i class="icon icon-trash"></i></button>
- </div>
- <% } %>
- </div>
-</td>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/templates/documents/index_row_tabular.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/index_row_tabular.html b/src/fauxton/app/templates/documents/index_row_tabular.html
deleted file mode 100644
index f52c48c..0000000
--- a/src/fauxton/app/templates/documents/index_row_tabular.html
+++ /dev/null
@@ -1,25 +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.
--->
-
-<td class="select"><input type="checkbox"></td>
-<td>
- <div>
- <pre class="prettyprint"><%= JSON.stringify(doc.get("key")) %></pre>
- </div>
-</td>
-<td>
- <div>
- <pre class="prettyprint"><%= JSON.stringify(doc.get("value")) %></pre>
- </div>
-</td>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/templates/documents/search.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/search.html b/src/fauxton/app/templates/documents/search.html
deleted file mode 100644
index bb84891..0000000
--- a/src/fauxton/app/templates/documents/search.html
+++ /dev/null
@@ -1,15 +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.
--->
-
-<input id="searchbox" type="text" class="span12" placeholder="Search by doc id, view key or search index">
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/templates/documents/sidebar.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/sidebar.html b/src/fauxton/app/templates/documents/sidebar.html
deleted file mode 100644
index df75311..0000000
--- a/src/fauxton/app/templates/documents/sidebar.html
+++ /dev/null
@@ -1,41 +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.
--->
-
-<div id="sidenav">
- <div class="row-fluid">
- <div class="span4">
- <a class="btn btn-small new" id="doc" href="#<%= database.url('app') %>/new"><i class="icon-file"></i> New doc</a>
- <div class="btn-group" id="new-index">
- <a class="btn btn-small" href="#<%= database.url('app') %>/new_view">New view</a>
- </div>
- </div>
- <div class="span6">
- <form id="jump-to-doc" class="form-inline">
- <label> Jump To:
- <input type="text" id="jump-to-doc-id" class="input-small" placeholder="Document Id"></input>
- </label>
- </form>
- </div>
- </div>
-
- <hr>
- <ul class="nav nav-list">
- <li class="active"><a id="all-docs" href="#<%= database.url('index') %>?limit=100" class="toggle-view"><i class="icon-list"></i> All documents</a></li>
- <li><a id="design-docs" href='#<%= database.url("index") %>?limit=100&startkey="_design"&endkey="_e"' class="toggle-view"><i class="icon-list"></i> All design docs</a></li>
- </ul>
- <ul class="nav nav-list views">
- <li class="nav-header">Secondary Indexes</li>
- <li><a id="new-view" href="#<%= database.url('app') %>/new_view" class="new"><i class="icon-plus"></i> New</a></li>
- </ul>
-</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/templates/documents/tabs.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/tabs.html b/src/fauxton/app/templates/documents/tabs.html
deleted file mode 100644
index 57e6cb1..0000000
--- a/src/fauxton/app/templates/documents/tabs.html
+++ /dev/null
@@ -1,39 +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.
--->
-
-<ul class="nav nav-tabs">
- <li class="active"><a href="<%= db_url %>">Docs</a></li>
- <!-- TODO::REENABLE
- <li><a href="#">Permissions</a></li>
- <li><a href="#">Stats</a></li>
- -->
- <li id="changes"><a href="<%= changes_url %>">Changes</a></li>
- <!-- TODO::REENABLE
- <div id="search" class="navbar-search span4 nav pull-right input-prepend" style="height:20px;"></div>
- <!-- TODO: put this styling into less --//>
- <ul class="nav pull-right" style="margin:5px 10px 0px 10px;">
- <li>
- <div class="btn-group">
- <a class="btn btn-small dropdown-toggle" data-toggle="dropdown" href="#">
- <i class="icon icon-cog"></i> Database actions <span class="caret"></span>
- </a>
- <ul class="dropdown-menu">
- <li><a class=""><i class="icon-repeat"></i> Replicate database</a></li>
- <li><a id="delete-database" class=""><i class="icon-trash"></i> Delete database</a></li>
- </ul>
- </div>
- </li>
- </ul>
- -->
-</ul>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/templates/documents/upload_modal.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/upload_modal.html b/src/fauxton/app/templates/documents/upload_modal.html
deleted file mode 100644
index 08a14a6..0000000
--- a/src/fauxton/app/templates/documents/upload_modal.html
+++ /dev/null
@@ -1,42 +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.
--->
-
-<div class="modal hide fade">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
- <h3>Upload an Attachment</h3>
- </div>
- <div class="modal-body">
- <div id="modal-error" class="hide alert alert-error"/>
- <form id="file-upload" class="form" method="post">
- <p class="help-block">
- Please select the file you want to upload as an attachment to this document.
- Please note that this will result in the immediate creation of a new revision of the document,
- so it's not necessary to save the document after the upload.
- </p>
- <input id="_attachments" type="file" name="_attachments">
- <input id="_rev" type="hidden" name="_rev" value="" >
- <br/>
- </form>
-
- <div class="progress progress-info">
- <div class="bar" style="width: 0%"></div>
- </div>
- </div>
- <div class="modal-footer">
- <a href="#" data-dismiss="modal" class="btn">Cancel</a>
- <a href="#" id="upload-btn" class="btn btn-primary">Upload</a>
- </div>
-</div>
-
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/templates/documents/view_editor.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/view_editor.html b/src/fauxton/app/templates/documents/view_editor.html
deleted file mode 100644
index 32f1d14..0000000
--- a/src/fauxton/app/templates/documents/view_editor.html
+++ /dev/null
@@ -1,195 +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.
--->
-<div class="row">
- <div class="all-docs-list errors-container"></div>
- <div id="edit-index-container">
- <div id="ddoc-info"> </div>
-
- <div class="accordion" id="edit-index-accordion">
- <div class="accordion-group">
- <div class="accordion-heading">
- <a class="accordion-toggle" data-bypass="true" data-toggle="collapse" data-parent="#edit-index-accordion" href="#collapse-edit-index">
- <i class="icon-wrench"></i> <% if (newView) { %> Create Index <% } else { %> Edit Index <% } %>
- </a>
- </div>
- <div id="collapse-edit-index" class="accordion-body <% if (!newView) { %> collapse <% } %>">
- <div class="accordion-inner">
- <div id="define-view" class="ddoc-alert well">
- <div class="errors-container"></div>
- <form class="form-horizontal">
- <h3>Define your index</h3>
- <div class="control-group">
- <div class="row" style="margin-left:10px">
- <div class="span3">
- <label class="control-label" for="ddoc">Design document <a target="_couch_docs" href="http://docs.couchdb.org/en/latest/ddocs/#design-docs"><i class="icon-question-sign"></i></a></label>
- <div class="controls">
- <select id="ddoc">
- <optgroup label="Select a document">
- <option id="new-doc">New document</option>
- <% ddocs.each(function(ddoc) { %>
- <% if (ddoc.id === ddocName) { %>
- <option selected="selected"><%= ddoc.id %></option>
- <% } else { %>
- <option><%= ddoc.id %></option>
- <% } %>
- <% }); %>
- </optgroup>
- </select>
- </div>
- </div>
- <div id="new-ddoc-section" class="span5" style="display:none">
- <label class="control-label" for="new-ddoc"> _design/ </label>
- <div class="controls">
- <input type="text" id="new-ddoc" placeholder="newDesignDoc">
- </div>
- </div>
- </div>
- </div>
- <div class="control-group">
- <label class="control-label" for="index-name">Index name <a target="_couch_docs" href="http://docs.couchdb.org/en/latest/ddocs/#view-functions"><i class="icon-question-sign"></i></a></label>
- <div class="controls">
- <input type="text" id="index-name" value="<%= viewName %>" placeholder="Index name" />
- </div>
- </div>
- <div class="control-group">
- <label class="control-label" for="map-function">Map function <a target="_couch_docs" href="http://docs.couchdb.org/en/latest/ddocs/#map-functions"><i class="icon-question-sign"></i></a></label>
- <div class="controls">
- <% if (newView) { %>
- <textarea class="js-editor" id="map-function"><%= langTemplates.map %></textarea>
- <% } else { %>
- <textarea class="js-editor" id="map-function"><%= ddoc.get('views')[viewName].map %></textarea>
- <% } %>
- </div>
- </div>
- <div class="control-group">
- <label class="control-label" for="reduce-function-selector">Reduce function <a target="_couch_docs" href="http://docs.couchdb.org/en/latest/ddocs.html#reduce-and-rereduce-functions"><i class="icon-question-sign"></i></a></label>
- <div class="controls">
- <select id="reduce-function-selector">
- <option value="" <%= !reduceFunStr ? 'selected="selected"' : '' %>>None</option>
- <% _.each(["_sum", "_count", "_stats"], function(reduce) { %>
- <option value="<%= reduce %>" <% if (reduce == reduceFunStr) { %>selected<% } %>><%= reduce %></option>
- <% }) %>
- <option value="CUSTOM" <% if (isCustomReduce) { %>selected<% } %>>Custom reduce</option>
- </select>
- <span class="help-block">Reduce functions are optional.</span>
- </div>
- </div>
- <div class="control-group reduce-function">
- <label class="control-label" for="reduce-function">Custom Reduce</label>
- <div class="controls">
- <% if (newView) { %>
- <textarea class="js-editor" id="reduce-function"><%= langTemplates.reduce %></textarea>
- <% } else { %>
- <textarea class="js-editor" id="reduce-function"><%= ddoc.get('views')[viewName].reduce %></textarea>
- <% } %>
- </div>
- </div>
- <div class="control-group">
- <hr />
- <div class="controls">
- <% if (!this.newView) { %>
- <button class="btn btn-small btn-danger delete">Delete</button>
- <% } %>
- <button class="btn btn-small btn-info preview">Preview</button>
- <button class="btn btn-primary save">Save</button>
- </div>
- </div>
- <div class="clearfix"></div>
- </form>
- </div>
- </div>
- </div>
-
- </div>
- </div>
- <div class="accordion" id="advanced-options-accordion">
- <div class="accordion-group">
- <div class="accordion-heading">
- <a class="accordion-toggle" data-bypass="true" data-toggle="collapse" data-parent="#advanced-options-accordion" href="#collapse-advanced-options">
- <i class="icon-plus"></i> Advanced Options
- </a>
- </div>
- <div id="collapse-advanced-options" class="accordion-body collapse">
- <div class="accordion-inner">
- <form class="view-query-update">
- <div class="controls controls-row">
- <label class="span3 inline">
- Limit:
- <select name="limit" class="input-small">
- <option>5</option>
- <option selected="selected">10</option>
- <option>25</option>
- <option>50</option>
- <option>100</option>
- </select>
- </label>
- <label class="span3 checkbox inline">
- <input name="include_docs" type="checkbox" value="true"> Include Docs
- </label>
- <% if (hasReduce) { %>
- <label class="span2 checkbox inline">
- <input name="reduce" type="checkbox" value="true"> Reduce
- </label>
- <label class="span4 inline">
- Group Level:
- <select disabled name="group_level" class="input-small">
- <option value="0">None</option>
- <option value="1">1</option>
- <option value="2">2</option>
- <option value="3">3</option>
- <option value="4">4</option>
- <option value="5">5</option>
- <option value="6">6</option>
- <option value="7">7</option>
- <option value="8">8</option>
- <option value="9">9</option>
- <option value="999" selected="selected">exact</option>
- </select>
- </label>
- <% } %>
- </div>
-
- <div class="controls controls-row">
- <input name="key" class="span4" type="text" placeholder="Key">
- <input name="keys" class="span8" type="text" placeholder="Keys">
- </div>
- <div class="controls controls-row">
- <input name="startkey" class="span6" type="text" placeholder="Start Key">
- <input name="endkey" class="span6" type="text" placeholder="End Key">
- </div>
- <div class="controls controls-row">
- <label class="span2 checkbox inline">
- <input name="stale" type="checkbox" value="ok"> Stale
- </label>
- <label class="span2 checkbox inline">
- <input name="descending" type="checkbox" value="true"> Descending
- </label>
- <label class="span4 checkbox inline">
- <input name="inclusive_end" type="checkbox" value="false"> Disable Inclusive End
- </label>
- <label class="span4 checkbox inline">
- <input name="update_seq" type="checkbox" value="true"> Include Update Sequence
- </label>
- </div>
- <div class="controls controls-row">
- <button type="submit" class="btn btn-primary">Query</button>
- </div>
- </form>
-
- </div>
- </div>
-
- </div>
- </div>
- </div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/templates/fauxton/api_bar.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/fauxton/api_bar.html b/src/fauxton/app/templates/fauxton/api_bar.html
deleted file mode 100644
index 0ca6c69..0000000
--- a/src/fauxton/app/templates/fauxton/api_bar.html
+++ /dev/null
@@ -1,30 +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.
--->
-
-<div class="navbar navbar-fixed-bottom">
- <div class="navbar-inner">
- <div class="container">
- <div class="input-prepend input-append">
- <span class="add-on">
- API reference
- <a href="http://docs.couchdb.org/en/latest/" target="_blank">
- <i class="icon-question-sign"></i>
- </a>
- </span>
- <input type="text" class="input-xxlarge" value="<%= endpoint %>">
- <a href="<%= endpoint %>" target="_blank" class="btn">Show me</a>
- </div>
- </div>
- </div>
-</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/templates/fauxton/breadcrumbs.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/fauxton/breadcrumbs.html b/src/fauxton/app/templates/fauxton/breadcrumbs.html
deleted file mode 100644
index 489fef3..0000000
--- a/src/fauxton/app/templates/fauxton/breadcrumbs.html
+++ /dev/null
@@ -1,24 +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.
--->
-
-<ul class="breadcrumb">
- <% _.each(_.initial(crumbs), function(crumb) { %>
- <li>
- <a href="#<%= crumb.link %>"><%= crumb.name %></a>
- <span class="divider"> / </span>
- </li>
- <% }); %>
- <% var last = _.last(crumbs) || {name: ''} %>
- <li class="active"><%= last.name %></li>
-</ul>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/templates/fauxton/footer.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/fauxton/footer.html b/src/fauxton/app/templates/fauxton/footer.html
deleted file mode 100644
index a070b52..0000000
--- a/src/fauxton/app/templates/fauxton/footer.html
+++ /dev/null
@@ -1,15 +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.
--->
-
-<p>Fauxton <%=version%> on <a href="http://couchdb.apache.org/">Apache CouchDB</a></p>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/templates/fauxton/nav_bar.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/fauxton/nav_bar.html b/src/fauxton/app/templates/fauxton/nav_bar.html
deleted file mode 100644
index 75731e0..0000000
--- a/src/fauxton/app/templates/fauxton/nav_bar.html
+++ /dev/null
@@ -1,35 +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.
--->
-
-<div class="navbar navbar-inverse navbar-fixed-top">
- <div class="navbar-inner">
- <div class="container">
- <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- </a>
- <a class="brand" href="#">Project Fauxton</a>
- <div class="nav-collapse">
- <ul id="nav-links" class="nav pull-right">
- <% _.each(navLinks, function(link) { %>
- <% if (!link.view) { %>
- <li data-nav-name= "<%= link.title %>" ><a href="<%= link.href %>"><%= link.title %></a></li>
- <% } %>
- <% }); %>
- </ul>
- </div><!--/.nav-collapse -->
- </div>
- </div>
-</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/templates/fauxton/notification.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/fauxton/notification.html b/src/fauxton/app/templates/fauxton/notification.html
deleted file mode 100644
index ca8a903..0000000
--- a/src/fauxton/app/templates/fauxton/notification.html
+++ /dev/null
@@ -1,18 +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.
--->
-
-<div class="alert alert-<%= type %>">
- <button type="button" class="close" data-dismiss="alert">Ć</button>
- <%= msg %>
-</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/templates/fauxton/pagination.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/fauxton/pagination.html b/src/fauxton/app/templates/fauxton/pagination.html
deleted file mode 100644
index 19dfc8c..0000000
--- a/src/fauxton/app/templates/fauxton/pagination.html
+++ /dev/null
@@ -1,31 +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.
--->
-
-<div class="pagination pagination-centered">
- <ul>
- <% if (page > 1) { %>
- <li> <a href="<%= urlFun(page-1) %>">«</a></li>
- <% } else { %>
- <li class="disabled"> <a href="<%= urlFun(page) %>">«</a></li>
- <% } %>
- <% _.each(_.range(1, totalPages+1), function(i) { %>
- <li <% if (page == i) { %>class="active"<% } %>> <a href="<%= urlFun(i) %>"><%= i %></a></li>
- <% }) %>
- <% if (page < totalPages) { %>
- <li><a href="<%= urlFun(page+1) %>">»</a></li>
- <% } else { %>
- <li class="disabled"> <a href="<%= urlFun(page) %>">»</a></li>
- <% } %>
- </ul>
-</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/templates/layouts/one_pane.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/layouts/one_pane.html b/src/fauxton/app/templates/layouts/one_pane.html
deleted file mode 100644
index 71c38fb..0000000
--- a/src/fauxton/app/templates/layouts/one_pane.html
+++ /dev/null
@@ -1,28 +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.
--->
-
-<div id="primary-navbar"></div>
-
-<div id="dashboard" class="container">
- <div class="row">
- <div id="breadcrumbs" class="span12"></div>
- </div>
- <div id="tabs" class="row"></div>
-
- <div class="row">
- <div id="dashboard-content" class="list span12"></div>
- </div>
-</div>
-
-<div id="api-navbar"></div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/templates/layouts/two_pane.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/layouts/two_pane.html b/src/fauxton/app/templates/layouts/two_pane.html
deleted file mode 100644
index e8b8411..0000000
--- a/src/fauxton/app/templates/layouts/two_pane.html
+++ /dev/null
@@ -1,29 +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.
--->
-
-<div id="primary-navbar"></div>
-
-<div id="dashboard" class="container">
- <div class="row">
- <div id="breadcrumbs" class="span12"></div>
- </div>
- <div id="tabs" class="row"></div>
-
- <div class="row">
- <div id="left-content" class="span6"></div>
- <div id="right-content" class="span6"></div>
- </div>
-</div>
-
-<div id="api-navbar"></div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/templates/layouts/with_right_sidebar.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/layouts/with_right_sidebar.html b/src/fauxton/app/templates/layouts/with_right_sidebar.html
deleted file mode 100644
index 06623c4..0000000
--- a/src/fauxton/app/templates/layouts/with_right_sidebar.html
+++ /dev/null
@@ -1,27 +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.
--->
-
-<div id="primary-navbar"></div>
-
-<div id="dashboard" class="container">
- <div class="row">
- <div id="breadcrumbs" class="span12"></div>
- </div>
- <div class="row">
- <div id="dashboard-content" class="list span8"></div>
- <div id="sidebar-content" class="sidebar span4 pull-right"></div>
- </div>
-</div>
-
-<div id="api-navbar"></div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/templates/layouts/with_sidebar.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/layouts/with_sidebar.html b/src/fauxton/app/templates/layouts/with_sidebar.html
deleted file mode 100644
index 5deb4d1..0000000
--- a/src/fauxton/app/templates/layouts/with_sidebar.html
+++ /dev/null
@@ -1,27 +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.
--->
-
-<div id="primary-navbar"></div>
-
-<div id="dashboard" class="container-fluid">
- <div class="row-fluid">
- <div id="breadcrumbs" class="span12"></div>
- </div>
- <div class="row-fluid">
- <div id="sidebar-content" class="sidebar span3"></div>
- <div id="dashboard-content" class="list span9"></div>
- </div>
-</div>
-
-<div id="api-navbar"></div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/templates/layouts/with_tabs.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/layouts/with_tabs.html b/src/fauxton/app/templates/layouts/with_tabs.html
deleted file mode 100644
index 36b39c8..0000000
--- a/src/fauxton/app/templates/layouts/with_tabs.html
+++ /dev/null
@@ -1,27 +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.
--->
-
-<div id="primary-navbar"></div>
-<div id="dashboard" class="container-fluid">
-
-<div class="row-fluid">
- <div id="breadcrumbs" class="row-fluid"></div>
- <div id="tabs" class="row-fluid"></div>
-
- <div class="row-fluid">
- <div id="dashboard-content" class="list span12"></div>
- </div>
-</div>
-
-<div id="api-navbar"></div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/templates/layouts/with_tabs_sidebar.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/layouts/with_tabs_sidebar.html b/src/fauxton/app/templates/layouts/with_tabs_sidebar.html
deleted file mode 100644
index 0b5f2c7..0000000
--- a/src/fauxton/app/templates/layouts/with_tabs_sidebar.html
+++ /dev/null
@@ -1,31 +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.
--->
-
-<div id="primary-navbar"></div>
-<div id="dashboard" class="container-fluid">
-
-<div class="row-fluid">
- <div id="breadcrumbs" class="row-fluid"></div>
- <div id="tabs" class="row-fluid"></div>
-
- <div class="row-fluid">
- <div id="sidebar-content" class="sidebar span4"></div>
- <div id="dashboard-content" class="list span8 pull-right">
- <div id="dashboard-upper-content"></div>
- <div id="dashboard-lower-content"></div>
- </div>
- </div>
-</div>
-
-<div id="api-navbar"></div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/css/codemirror.css
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/css/codemirror.css b/src/fauxton/assets/css/codemirror.css
deleted file mode 100644
index fb5b6d5..0000000
--- a/src/fauxton/assets/css/codemirror.css
+++ /dev/null
@@ -1,169 +0,0 @@
-.CodeMirror {
- line-height: 1em;
- font-family: monospace;
-
- /* Necessary so the scrollbar can be absolutely positioned within the wrapper on Lion. */
- position: relative;
- /* This prevents unwanted scrollbars from showing up on the body and wrapper in IE. */
- overflow: hidden;
-}
-
-.CodeMirror-scroll {
- overflow-x: auto;
- overflow-y: hidden;
- height: 300px;
- /* This is needed to prevent an IE[67] bug where the scrolled content
- is visible outside of the scrolling box. */
- position: relative;
- outline: none;
-}
-
-/* Vertical scrollbar */
-.CodeMirror-scrollbar {
- float: right;
- overflow-x: hidden;
- overflow-y: scroll;
-
- /* This corrects for the 1px gap introduced to the left of the scrollbar
- by the rule for .CodeMirror-scrollbar-inner. */
- margin-left: -1px;
-}
-.CodeMirror-scrollbar-inner {
- /* This needs to have a nonzero width in order for the scrollbar to appear
- in Firefox and IE9. */
- width: 1px;
-}
-.CodeMirror-scrollbar.cm-sb-overlap {
- /* Ensure that the scrollbar appears in Lion, and that it overlaps the content
- rather than sitting to the right of it. */
- position: absolute;
- z-index: 1;
- float: none;
- right: 0;
- min-width: 12px;
-}
-.CodeMirror-scrollbar.cm-sb-nonoverlap {
- min-width: 12px;
-}
-.CodeMirror-scrollbar.cm-sb-ie7 {
- min-width: 18px;
-}
-
-.CodeMirror-gutter {
- position: absolute; left: 0; top: 0;
- z-index: 10;
- background-color: #f7f7f7;
- border-right: 1px solid #eee;
- min-width: 2em;
- height: 100%;
-}
-.CodeMirror-gutter-text {
- color: #aaa;
- text-align: right;
- padding: .4em .2em .4em .4em;
- white-space: pre !important;
- cursor: default;
-}
-.CodeMirror-lines {
- padding: .4em;
- white-space: pre;
- cursor: text;
-}
-.CodeMirror-lines * {
- /* Necessary for throw-scrolling to decelerate properly on Safari. */
- pointer-events: none;
-}
-
-.CodeMirror pre {
- -moz-border-radius: 0;
- -webkit-border-radius: 0;
- -o-border-radius: 0;
- border-radius: 0;
- border-width: 0; margin: 0; padding: 0; background: transparent;
- font-family: inherit;
- font-size: inherit;
- padding: 0; margin: 0;
- white-space: pre;
- word-wrap: normal;
- line-height: inherit;
- color: inherit;
-}
-
-.CodeMirror-wrap pre {
- word-wrap: break-word;
- white-space: pre-wrap;
- word-break: normal;
-}
-.CodeMirror-wrap .CodeMirror-scroll {
- overflow-x: hidden;
-}
-
-.CodeMirror textarea {
- outline: none !important;
-}
-
-.CodeMirror pre.CodeMirror-cursor {
- z-index: 10;
- position: absolute;
- visibility: hidden;
- border-left: 1px solid black;
- border-right: none;
- width: 0;
-}
-.cm-keymap-fat-cursor pre.CodeMirror-cursor {
- width: auto;
- border: 0;
- background: transparent;
- background: rgba(0, 200, 0, .4);
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#6600c800, endColorstr=#4c00c800);
-}
-/* Kludge to turn off filter in ie9+, which also accepts rgba */
-.cm-keymap-fat-cursor pre.CodeMirror-cursor:not(#nonsense_id) {
- filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
-}
-.CodeMirror pre.CodeMirror-cursor.CodeMirror-overwrite {}
-.CodeMirror-focused pre.CodeMirror-cursor {
- visibility: visible;
-}
-
-div.CodeMirror-selected { background: #d9d9d9; }
-.CodeMirror-focused div.CodeMirror-selected { background: #d7d4f0; }
-
-.CodeMirror-searching {
- background: #ffa;
- background: rgba(255, 255, 0, .4);
-}
-
-/* Default theme */
-
-.cm-s-default span.cm-keyword {color: #708;}
-.cm-s-default span.cm-atom {color: #219;}
-.cm-s-default span.cm-number {color: #164;}
-.cm-s-default span.cm-def {color: #00f;}
-.cm-s-default span.cm-variable {color: black;}
-.cm-s-default span.cm-variable-2 {color: #05a;}
-.cm-s-default span.cm-variable-3 {color: #085;}
-.cm-s-default span.cm-property {color: black;}
-.cm-s-default span.cm-operator {color: black;}
-.cm-s-default span.cm-comment {color: #a50;}
-.cm-s-default span.cm-string {color: #a11;}
-.cm-s-default span.cm-string-2 {color: #f50;}
-.cm-s-default span.cm-meta {color: #555;}
-.cm-s-default span.cm-error {color: #f00;}
-.cm-s-default span.cm-qualifier {color: #555;}
-.cm-s-default span.cm-builtin {color: #30a;}
-.cm-s-default span.cm-bracket {color: #cc7;}
-.cm-s-default span.cm-tag {color: #170;}
-.cm-s-default span.cm-attribute {color: #00c;}
-.cm-s-default span.cm-header {color: blue;}
-.cm-s-default span.cm-quote {color: #090;}
-.cm-s-default span.cm-hr {color: #999;}
-.cm-s-default span.cm-link {color: #00c;}
-
-span.cm-header, span.cm-strong {font-weight: bold;}
-span.cm-em {font-style: italic;}
-span.cm-emstrong {font-style: italic; font-weight: bold;}
-span.cm-link {text-decoration: underline;}
-
-div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
-div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/css/nv.d3.css
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/css/nv.d3.css b/src/fauxton/assets/css/nv.d3.css
deleted file mode 100644
index 28ccd05..0000000
--- a/src/fauxton/assets/css/nv.d3.css
+++ /dev/null
@@ -1,656 +0,0 @@
-
-/********************
- * HTML CSS
- */
-
-
-.chartWrap {
- margin: 0;
- padding: 0;
- overflow: hidden;
-}
-
-
-/********************
- * TOOLTIP CSS
- */
-
-.nvtooltip {
- position: absolute;
- background-color: rgba(255,255,255,1);
- padding: 10px;
- border: 1px solid #ddd;
- z-index: 10000;
-
- font-family: Arial;
- font-size: 13px;
-
- transition: opacity 500ms linear;
- -moz-transition: opacity 500ms linear;
- -webkit-transition: opacity 500ms linear;
-
- transition-delay: 500ms;
- -moz-transition-delay: 500ms;
- -webkit-transition-delay: 500ms;
-
- -moz-box-shadow: 4px 4px 8px rgba(0,0,0,.5);
- -webkit-box-shadow: 4px 4px 8px rgba(0,0,0,.5);
- box-shadow: 4px 4px 8px rgba(0,0,0,.5);
-
- -moz-border-radius: 10px;
- border-radius: 10px;
-
- pointer-events: none;
-
- -webkit-touch-callout: none;
- -webkit-user-select: none;
- -khtml-user-select: none;
- -moz-user-select: none;
- -ms-user-select: none;
- user-select: none;
-}
-
-.nvtooltip h3 {
- margin: 0;
- padding: 0;
- text-align: center;
-}
-
-.nvtooltip p {
- margin: 0;
- padding: 0;
- text-align: center;
-}
-
-.nvtooltip span {
- display: inline-block;
- margin: 2px 0;
-}
-
-.nvtooltip-pending-removal {
- position: absolute;
- pointer-events: none;
-}
-
-
-/********************
- * SVG CSS
- */
-
-
-svg {
- -webkit-touch-callout: none;
- -webkit-user-select: none;
- -khtml-user-select: none;
- -moz-user-select: none;
- -ms-user-select: none;
- user-select: none;
- /* Trying to get SVG to act like a greedy block in all browsers */
- display: block;
- width:100%;
- height:100%;
-}
-
-
-svg text {
- font: normal 12px Arial;
-}
-
-svg .title {
- font: bold 14px Arial;
-}
-
-.nvd3 .nv-background {
- fill: white;
- fill-opacity: 0;
- /*
- pointer-events: none;
- */
-}
-
-.nvd3.nv-noData {
- font-size: 18px;
- font-weight: bolf;
-}
-
-
-/**********
-* Brush
-*/
-
-.nv-brush .extent {
- fill-opacity: .125;
- shape-rendering: crispEdges;
-}
-
-
-
-/**********
-* Legend
-*/
-
-.nvd3 .nv-legend .nv-series {
- cursor: pointer;
-}
-
-.nvd3 .nv-legend .disabled circle {
- fill-opacity: 0;
-}
-
-
-
-/**********
-* Axes
-*/
-
-.nvd3 .nv-axis path {
- fill: none;
- stroke: #000;
- stroke-opacity: .75;
- shape-rendering: crispEdges;
-}
-
-.nvd3 .nv-axis path.domain {
- stroke-opacity: .75;
-}
-
-.nvd3 .nv-axis.nv-x path.domain {
- stroke-opacity: 0;
-}
-
-.nvd3 .nv-axis line {
- fill: none;
- stroke: #000;
- stroke-opacity: .25;
- shape-rendering: crispEdges;
-}
-
-.nvd3 .nv-axis line.zero {
- stroke-opacity: .75;
-}
-
-.nvd3 .nv-axis .nv-axisMaxMin text {
- font-weight: bold;
-}
-
-.nvd3 .x .nv-axis .nv-axisMaxMin text,
-.nvd3 .x2 .nv-axis .nv-axisMaxMin text,
-.nvd3 .x3 .nv-axis .nv-axisMaxMin text {
- text-anchor: middle
-}
-
-
-
-/**********
-* Brush
-*/
-
-.nv-brush .resize path {
- fill: #eee;
- stroke: #666;
-}
-
-
-
-/**********
-* Bars
-*/
-
-.nvd3 .nv-bars .negative rect {
- zfill: brown;
-}
-
-.nvd3 .nv-bars rect {
- zfill: steelblue;
- fill-opacity: .75;
-
- transition: fill-opacity 250ms linear;
- -moz-transition: fill-opacity 250ms linear;
- -webkit-transition: fill-opacity 250ms linear;
-}
-
-.nvd3 .nv-bars rect:hover {
- fill-opacity: 1;
-}
-
-.nvd3 .nv-bars .hover rect {
- fill: lightblue;
-}
-
-.nvd3 .nv-bars text {
- fill: rgba(0,0,0,0);
-}
-
-.nvd3 .nv-bars .hover text {
- fill: rgba(0,0,0,1);
-}
-
-
-/**********
-* Bars
-*/
-
-.nvd3 .nv-multibar .nv-groups rect,
-.nvd3 .nv-multibarHorizontal .nv-groups rect,
-.nvd3 .nv-discretebar .nv-groups rect {
- stroke-opacity: 0;
-
- transition: fill-opacity 250ms linear;
- -moz-transition: fill-opacity 250ms linear;
- -webkit-transition: fill-opacity 250ms linear;
-}
-
-.nvd3 .nv-multibar .nv-groups rect:hover,
-.nvd3 .nv-multibarHorizontal .nv-groups rect:hover,
-.nvd3 .nv-discretebar .nv-groups rect:hover {
- fill-opacity: 1;
-}
-
-.nvd3 .nv-discretebar .nv-groups text,
-.nvd3 .nv-multibarHorizontal .nv-groups text {
- font-weight: bold;
- fill: rgba(0,0,0,1);
- stroke: rgba(0,0,0,0);
-}
-
-/***********
-* Pie Chart
-*/
-
-.nvd3.nv-pie path {
- stroke-opacity: 0;
-
- transition: fill-opacity 250ms linear, stroke-width 250ms linear, stroke-opacity 250ms linear;
- -moz-transition: fill-opacity 250ms linear, stroke-width 250ms linear, stroke-opacity 250ms linear;
- -webkit-transition: fill-opacity 250ms linear, stroke-width 250ms linear, stroke-opacity 250ms linear;
-
-}
-
-.nvd3.nv-pie .nv-slice text {
- stroke: #000;
- stroke-width: 0;
-}
-
-.nvd3.nv-pie path {
- stroke: #fff;
- stroke-width: 1px;
- stroke-opacity: 1;
-}
-
-.nvd3.nv-pie .hover path {
- fill-opacity: .7;
-/*
- stroke-width: 6px;
- stroke-opacity: 1;
-*/
-}
-
-.nvd3.nv-pie .nv-label rect {
- fill-opacity: 0;
- stroke-opacity: 0;
-}
-
-/**********
-* Lines
-*/
-
-.nvd3 .nv-groups path.nv-line {
- fill: none;
- stroke-width: 2.5px;
- /*
- stroke-linecap: round;
- shape-rendering: geometricPrecision;
-
- transition: stroke-width 250ms linear;
- -moz-transition: stroke-width 250ms linear;
- -webkit-transition: stroke-width 250ms linear;
-
- transition-delay: 250ms
- -moz-transition-delay: 250ms;
- -webkit-transition-delay: 250ms;
- */
-}
-
-.nvd3 .nv-groups path.nv-area {
- stroke: none;
- /*
- stroke-linecap: round;
- shape-rendering: geometricPrecision;
-
- stroke-width: 2.5px;
- transition: stroke-width 250ms linear;
- -moz-transition: stroke-width 250ms linear;
- -webkit-transition: stroke-width 250ms linear;
-
- transition-delay: 250ms
- -moz-transition-delay: 250ms;
- -webkit-transition-delay: 250ms;
- */
-}
-
-.nvd3 .nv-line.hover path {
- stroke-width: 6px;
-}
-
-/*
-.nvd3.scatter .groups .point {
- fill-opacity: 0.1;
- stroke-opacity: 0.1;
-}
- */
-
-.nvd3.nv-line .nvd3.nv-scatter .nv-groups .nv-point {
- fill-opacity: 0;
- stroke-opacity: 0;
-}
-
-.nvd3.nv-scatter.nv-single-point .nv-groups .nv-point {
- fill-opacity: .5 !important;
- stroke-opacity: .5 !important;
-}
-
-
-.nvd3 .nv-groups .nv-point {
- transition: stroke-width 250ms linear, stroke-opacity 250ms linear;
- -moz-transition: stroke-width 250ms linear, stroke-opacity 250ms linear;
- -webkit-transition: stroke-width 250ms linear, stroke-opacity 250ms linear;
-}
-
-.nvd3.nv-scatter .nv-groups .nv-point.hover,
-.nvd3 .nv-groups .nv-point.hover {
- stroke-width: 20px;
- fill-opacity: .5 !important;
- stroke-opacity: .5 !important;
-}
-
-
-.nvd3 .nv-point-paths path {
- stroke: #aaa;
- stroke-opacity: 0;
- fill: #eee;
- fill-opacity: 0;
-}
-
-
-
-.nvd3 .nv-indexLine {
- cursor: ew-resize;
-}
-
-
-/**********
-* Distribution
-*/
-
-.nvd3 .nv-distribution {
- pointer-events: none;
-}
-
-
-
-/**********
-* Scatter
-*/
-
-/* **Attempting to remove this for useVoronoi(false), need to see if it's required anywhere
-.nvd3 .nv-groups .nv-point {
- pointer-events: none;
-}
-*/
-
-.nvd3 .nv-groups .nv-point.hover {
- stroke-width: 20px;
- stroke-opacity: .5;
-}
-
-.nvd3 .nv-scatter .nv-point.hover {
- fill-opacity: 1;
-}
-
-/*
-.nv-group.hover .nv-point {
- fill-opacity: 1;
-}
-*/
-
-
-/**********
-* Stacked Area
-*/
-
-.nvd3.nv-stackedarea path.nv-area {
- fill-opacity: .7;
- /*
- stroke-opacity: .65;
- fill-opacity: 1;
- */
- stroke-opacity: 0;
-
- transition: fill-opacity 250ms linear, stroke-opacity 250ms linear;
- -moz-transition: fill-opacity 250ms linear, stroke-opacity 250ms linear;
- -webkit-transition: fill-opacity 250ms linear, stroke-opacity 250ms linear;
-
- /*
- transition-delay: 500ms;
- -moz-transition-delay: 500ms;
- -webkit-transition-delay: 500ms;
- */
-
-}
-
-.nvd3.nv-stackedarea path.nv-area.hover {
- fill-opacity: .9;
- /*
- stroke-opacity: .85;
- */
-}
-/*
-.d3stackedarea .groups path {
- stroke-opacity: 0;
-}
- */
-
-
-
-.nvd3.nv-stackedarea .nv-groups .nv-point {
- stroke-opacity: 0;
- fill-opacity: 0;
-}
-
-.nvd3.nv-stackedarea .nv-groups .nv-point.hover {
- stroke-width: 20px;
- stroke-opacity: .75;
- fill-opacity: 1;
-}
-
-
-
-/**********
-* Line Plus Bar
-*/
-
-.nvd3.nv-linePlusBar .nv-bar rect {
- fill-opacity: .75;
-}
-
-.nvd3.nv-linePlusBar .nv-bar rect:hover {
- fill-opacity: 1;
-}
-
-
-/**********
-* Bullet
-*/
-
-.nvd3.nv-bullet { font: 10px sans-serif; }
-.nvd3.nv-bullet .nv-measure { fill-opacity: .8; }
-.nvd3.nv-bullet .nv-measure:hover { fill-opacity: 1; }
-.nvd3.nv-bullet .nv-marker { stroke: #000; stroke-width: 2px; }
-.nvd3.nv-bullet .nv-markerTriangle { stroke: #000; fill: #fff; stroke-width: 1.5px; }
-.nvd3.nv-bullet .nv-tick line { stroke: #666; stroke-width: .5px; }
-.nvd3.nv-bullet .nv-range.nv-s0 { fill: #eee; }
-.nvd3.nv-bullet .nv-range.nv-s1 { fill: #ddd; }
-.nvd3.nv-bullet .nv-range.nv-s2 { fill: #ccc; }
-.nvd3.nv-bullet .nv-title { font-size: 14px; font-weight: bold; }
-.nvd3.nv-bullet .nv-subtitle { fill: #999; }
-
-
-.nvd3.nv-bullet .nv-range {
- fill: #999;
- fill-opacity: .4;
-}
-.nvd3.nv-bullet .nv-range:hover {
- fill-opacity: .7;
-}
-
-
-
-/**********
-* Sparkline
-*/
-
-.nvd3.nv-sparkline path {
- fill: none;
-}
-
-.nvd3.nv-sparklineplus g.nv-hoverValue {
- pointer-events: none;
-}
-
-.nvd3.nv-sparklineplus .nv-hoverValue line {
- stroke: #333;
- stroke-width: 1.5px;
- }
-
-.nvd3.nv-sparklineplus,
-.nvd3.nv-sparklineplus g {
- pointer-events: all;
-}
-
-.nvd3 .nv-hoverArea {
- fill-opacity: 0;
- stroke-opacity: 0;
-}
-
-.nvd3.nv-sparklineplus .nv-xValue,
-.nvd3.nv-sparklineplus .nv-yValue {
- /*
- stroke: #666;
- */
- stroke-width: 0;
- font-size: .9em;
- font-weight: normal;
-}
-
-.nvd3.nv-sparklineplus .nv-yValue {
- stroke: #f66;
-}
-
-.nvd3.nv-sparklineplus .nv-maxValue {
- stroke: #2ca02c;
- fill: #2ca02c;
-}
-
-.nvd3.nv-sparklineplus .nv-minValue {
- stroke: #d62728;
- fill: #d62728;
-}
-
-.nvd3.nv-sparklineplus .nv-currentValue {
- /*
- stroke: #444;
- fill: #000;
- */
- font-weight: bold;
- font-size: 1.1em;
-}
-
-/**********
-* historical stock
-*/
-
-.nvd3.nv-ohlcBar .nv-ticks .nv-tick {
- stroke-width: 2px;
-}
-
-.nvd3.nv-ohlcBar .nv-ticks .nv-tick.hover {
- stroke-width: 4px;
-}
-
-.nvd3.nv-ohlcBar .nv-ticks .nv-tick.positive {
- stroke: #2ca02c;
-}
-
-.nvd3.nv-ohlcBar .nv-ticks .nv-tick.negative {
- stroke: #d62728;
-}
-
-.nvd3.nv-historicalStockChart .nv-axis .nv-axislabel {
- font-weight: bold;
-}
-
-.nvd3.nv-historicalStockChart .nv-dragTarget {
- fill-opacity: 0;
- stroke: none;
- cursor: move;
-}
-
-.nvd3 .nv-brush .extent {
- /*
- cursor: ew-resize !important;
- */
- fill-opacity: 0 !important;
-}
-
-.nvd3 .nv-brushBackground rect {
- stroke: #000;
- stroke-width: .4;
- fill: #fff;
- fill-opacity: .7;
-}
-
-
-
-/**********
-* Indented Tree
-*/
-
-
-/**
- * TODO: the following 3 selectors are based on classes used in the example. I should either make them standard and leave them here, or move to a CSS file not included in the library
- */
-.nvd3.nv-indentedtree .name {
- margin-left: 5px;
-}
-
-.nvd3.nv-indentedtree .clickable {
- color: #08C;
- cursor: pointer;
-}
-
-.nvd3.nv-indentedtree span.clickable:hover {
- color: #005580;
- text-decoration: underline;
-}
-
-
-.nvd3.nv-indentedtree .nv-childrenCount {
- display: inline-block;
- margin-left: 5px;
-}
-
-.nvd3.nv-indentedtree .nv-treeicon {
- cursor: pointer;
- /*
- cursor: n-resize;
- */
-}
-
-.nvd3.nv-indentedtree .nv-treeicon.nv-folded {
- cursor: pointer;
- /*
- cursor: s-resize;
- */
-}
-
-
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/img/couchdblogo.png
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/img/couchdblogo.png b/src/fauxton/assets/img/couchdblogo.png
deleted file mode 100644
index cbe991c..0000000
Binary files a/src/fauxton/assets/img/couchdblogo.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/img/glyphicons-halflings-white.png
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/img/glyphicons-halflings-white.png b/src/fauxton/assets/img/glyphicons-halflings-white.png
deleted file mode 100644
index 3bf6484..0000000
Binary files a/src/fauxton/assets/img/glyphicons-halflings-white.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/img/glyphicons-halflings.png
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/img/glyphicons-halflings.png b/src/fauxton/assets/img/glyphicons-halflings.png
deleted file mode 100644
index 79bc568..0000000
Binary files a/src/fauxton/assets/img/glyphicons-halflings.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/img/loader.gif
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/img/loader.gif b/src/fauxton/assets/img/loader.gif
deleted file mode 100644
index 96ff188..0000000
Binary files a/src/fauxton/assets/img/loader.gif and /dev/null differ
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/index.underscore
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/index.underscore b/src/fauxton/assets/index.underscore
deleted file mode 100644
index 7ccb930..0000000
--- a/src/fauxton/assets/index.underscore
+++ /dev/null
@@ -1,54 +0,0 @@
-<!doctype html>
-
-<!--
-// 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.
--->
-
-<html lang="en">
-<head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <meta name="viewport" content="width=device-width,initial-scale=1">
- <meta http-equiv="Content-Language" content="en" />
-
- <title>Project Fauxton</title>
-
- <!-- Application styles. -->
- <link rel="stylesheet" href="<%= css %>">
- <style type="text/css">
- body {
- padding-top: 60px;
- padding-bottom: 40px;
- }
- </style>
- <% if (base) { %>
- <base href="<%= base %>"></base>
- <% } %>
-</head>
-
-<body id="home">
- <!-- Main container. -->
- <div role="main" id="main">
- <div id="global-notifications" class="container errors-container"></div>
- <div id="app-container"></div>
- <hr>
-
- <footer>
- <div id="footer-content" class="container"></div>
- </footer>
- </div>
-
- <!-- Application source. -->
- <script data-main="/config" src="<%= requirejs %>"></script>
-</body>
-</html>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/js/libs/almond.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/almond.js b/src/fauxton/assets/js/libs/almond.js
deleted file mode 100644
index f530767..0000000
--- a/src/fauxton/assets/js/libs/almond.js
+++ /dev/null
@@ -1,314 +0,0 @@
-/**
- * almond 0.1.1 Copyright (c) 2011, The Dojo Foundation All Rights Reserved.
- * Available via the MIT or new BSD license.
- * see: http://github.com/jrburke/almond for details
- */
-//Going sloppy to avoid 'use strict' string cost, but strict practices should
-//be followed.
-/*jslint sloppy: true */
-/*global setTimeout: false */
-
-var requirejs, require, define;
-(function (undef) {
- var defined = {},
- waiting = {},
- config = {},
- defining = {},
- aps = [].slice,
- main, req;
-
- /**
- * Given a relative module name, like ./something, normalize it to
- * a real name that can be mapped to a path.
- * @param {String} name the relative name
- * @param {String} baseName a real name that the name arg is relative
- * to.
- * @returns {String} normalized name
- */
- function normalize(name, baseName) {
- var baseParts = baseName && baseName.split("/"),
- map = config.map,
- starMap = (map && map['*']) || {},
- nameParts, nameSegment, mapValue, foundMap, i, j, part;
-
- //Adjust any relative paths.
- if (name && name.charAt(0) === ".") {
- //If have a base name, try to normalize against it,
- //otherwise, assume it is a top-level require that will
- //be relative to baseUrl in the end.
- if (baseName) {
- //Convert baseName to array, and lop off the last part,
- //so that . matches that "directory" and not name of the baseName's
- //module. For instance, baseName of "one/two/three", maps to
- //"one/two/three.js", but we want the directory, "one/two" for
- //this normalization.
- baseParts = baseParts.slice(0, baseParts.length - 1);
-
- name = baseParts.concat(name.split("/"));
-
- //start trimDots
- for (i = 0; (part = name[i]); i++) {
- if (part === ".") {
- name.splice(i, 1);
- i -= 1;
- } else if (part === "..") {
- if (i === 1 && (name[2] === '..' || name[0] === '..')) {
- //End of the line. Keep at least one non-dot
- //path segment at the front so it can be mapped
- //correctly to disk. Otherwise, there is likely
- //no path mapping for a path starting with '..'.
- //This can still fail, but catches the most reasonable
- //uses of ..
- return true;
- } else if (i > 0) {
- name.splice(i - 1, 2);
- i -= 2;
- }
- }
- }
- //end trimDots
-
- name = name.join("/");
- }
- }
-
- //Apply map config if available.
- if ((baseParts || starMap) && map) {
- nameParts = name.split('/');
-
- for (i = nameParts.length; i > 0; i -= 1) {
- nameSegment = nameParts.slice(0, i).join("/");
-
- if (baseParts) {
- //Find the longest baseName segment match in the config.
- //So, do joins on the biggest to smallest lengths of baseParts.
- for (j = baseParts.length; j > 0; j -= 1) {
- mapValue = map[baseParts.slice(0, j).join('/')];
-
- //baseName segment has config, find if it has one for
- //this name.
- if (mapValue) {
- mapValue = mapValue[nameSegment];
- if (mapValue) {
- //Match, update name to the new value.
- foundMap = mapValue;
- break;
- }
- }
- }
- }
-
- foundMap = foundMap || starMap[nameSegment];
-
- if (foundMap) {
- nameParts.splice(0, i, foundMap);
- name = nameParts.join('/');
- break;
- }
- }
- }
-
- return name;
- }
-
- function makeRequire(relName, forceSync) {
- return function () {
- //A version of a require function that passes a moduleName
- //value for items that may need to
- //look up paths relative to the moduleName
- return req.apply(undef, aps.call(arguments, 0).concat([relName, forceSync]));
- };
- }
-
- function makeNormalize(relName) {
- return function (name) {
- return normalize(name, relName);
- };
- }
-
- function makeLoad(depName) {
- return function (value) {
- defined[depName] = value;
- };
- }
-
- function callDep(name) {
- if (waiting.hasOwnProperty(name)) {
- var args = waiting[name];
- delete waiting[name];
- defining[name] = true;
- main.apply(undef, args);
- }
-
- if (!defined.hasOwnProperty(name)) {
- throw new Error('No ' + name);
- }
- return defined[name];
- }
-
- /**
- * Makes a name map, normalizing the name, and using a plugin
- * for normalization if necessary. Grabs a ref to plugin
- * too, as an optimization.
- */
- function makeMap(name, relName) {
- var prefix, plugin,
- index = name.indexOf('!');
-
- if (index !== -1) {
- prefix = normalize(name.slice(0, index), relName);
- name = name.slice(index + 1);
- plugin = callDep(prefix);
-
- //Normalize according
- if (plugin && plugin.normalize) {
- name = plugin.normalize(name, makeNormalize(relName));
- } else {
- name = normalize(name, relName);
- }
- } else {
- name = normalize(name, relName);
- }
-
- //Using ridiculous property names for space reasons
- return {
- f: prefix ? prefix + '!' + name : name, //fullName
- n: name,
- p: plugin
- };
- }
-
- function makeConfig(name) {
- return function () {
- return (config && config.config && config.config[name]) || {};
- };
- }
-
- main = function (name, deps, callback, relName) {
- var args = [],
- usingExports,
- cjsModule, depName, ret, map, i;
-
- //Use name if no relName
- relName = relName || name;
-
- //Call the callback to define the module, if necessary.
- if (typeof callback === 'function') {
-
- //Pull out the defined dependencies and pass the ordered
- //values to the callback.
- //Default to [require, exports, module] if no deps
- deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps;
- for (i = 0; i < deps.length; i++) {
- map = makeMap(deps[i], relName);
- depName = map.f;
-
- //Fast path CommonJS standard dependencies.
- if (depName === "require") {
- args[i] = makeRequire(name);
- } else if (depName === "exports") {
- //CommonJS module spec 1.1
- args[i] = defined[name] = {};
- usingExports = true;
- } else if (depName === "module") {
- //CommonJS module spec 1.1
- cjsModule = args[i] = {
- id: name,
- uri: '',
- exports: defined[name],
- config: makeConfig(name)
- };
- } else if (defined.hasOwnProperty(depName) || waiting.hasOwnProperty(depName)) {
- args[i] = callDep(depName);
- } else if (map.p) {
- map.p.load(map.n, makeRequire(relName, true), makeLoad(depName), {});
- args[i] = defined[depName];
- } else if (!defining[depName]) {
- throw new Error(name + ' missing ' + depName);
- }
- }
-
- ret = callback.apply(defined[name], args);
-
- if (name) {
- //If setting exports via "module" is in play,
- //favor that over return value and exports. After that,
- //favor a non-undefined return value over exports use.
- if (cjsModule && cjsModule.exports !== undef &&
- cjsModule.exports !== defined[name]) {
- defined[name] = cjsModule.exports;
- } else if (ret !== undef || !usingExports) {
- //Use the return value from the function.
- defined[name] = ret;
- }
- }
- } else if (name) {
- //May just be an object definition for the module. Only
- //worry about defining if have a module name.
- defined[name] = callback;
- }
- };
-
- requirejs = require = req = function (deps, callback, relName, forceSync) {
- if (typeof deps === "string") {
- //Just return the module wanted. In this scenario, the
- //deps arg is the module name, and second arg (if passed)
- //is just the relName.
- //Normalize module name, if it contains . or ..
- return callDep(makeMap(deps, callback).f);
- } else if (!deps.splice) {
- //deps is a config object, not an array.
- config = deps;
- if (callback.splice) {
- //callback is an array, which means it is a dependency list.
- //Adjust args if there are dependencies
- deps = callback;
- callback = relName;
- relName = null;
- } else {
- deps = undef;
- }
- }
-
- //Support require(['a'])
- callback = callback || function () {};
-
- //Simulate async callback;
- if (forceSync) {
- main(undef, deps, callback, relName);
- } else {
- setTimeout(function () {
- main(undef, deps, callback, relName);
- }, 15);
- }
-
- return req;
- };
-
- /**
- * Just drops the config on the floor, but returns req in case
- * the config return value is used.
- */
- req.config = function (cfg) {
- config = cfg;
- return req;
- };
-
- define = function (name, deps, callback) {
-
- //This module may not have dependencies
- if (!deps.splice) {
- //deps is not an array, so probably means
- //an object literal or factory function for
- //the value. Adjust args.
- callback = deps;
- deps = [];
- }
-
- waiting[name] = [name, deps, callback];
- };
-
- define.amd = {
- jQuery: true
- };
-}());
[24/26] Remove fauxton from 1.4.x branch.
Posted by dj...@apache.org.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/logs/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/logs/resources.js b/src/fauxton/app/addons/logs/resources.js
deleted file mode 100644
index 072290b..0000000
--- a/src/fauxton/app/addons/logs/resources.js
+++ /dev/null
@@ -1,223 +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.
-
-define([
- "app",
- "api",
- "backbone"
-],
-
-function (app, FauxtonAPI, Backbone) {
-
- var Log = FauxtonAPI.addon();
-
- Log.Model = Backbone.Model.extend({
-
- date: function () {
- var date = new Date(this.get('date'));
-
- var formatted_time = date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
- var formatted_date = date.toDateString().slice(4, 10);
-
- return formatted_date + ' ' + formatted_time;
- },
-
- logLevel: function () {
- return this.get('log_level').replace(/ /g,'');
- },
-
- pid: function () {
- return _.escape(this.get('pid'));
- },
-
- args: function () {
- return _.escape(this.get('args'));
- }
-
- });
-
- Log.Collection = Backbone.Collection.extend({
- model: Log.Model,
-
- initialize: function (options) {
- this.params = {bytes: 5000};
- },
-
- url: function () {
- query = "?" + $.param(this.params);
- return app.host + '/_log' + query;
- },
-
- // override fetch because backbone expects json and couchdb sends text/html for logs,
- // I think its more elegant to set the dataType here than where ever fetch is called
- fetch: function (options) {
- options = options ? options : {};
-
- return Backbone.Collection.prototype.fetch.call(this, _.extend(options, {dataType: "html"}));
- },
-
- parse: function (resp) {
- var lines = resp.split(/\n/);
- return _.foldr(lines, function (acc, logLine) {
- var match = logLine.match(/^\[(.*?)\]\s\[(.*?)\]\s\[(.*?)\]\s(.*)/);
-
- if (!match) { return acc;}
-
- acc.push({
- date: match[1],
- log_level: match[2],
- pid: match[3],
- args: match[4]
- });
-
- return acc;
- }, []);
- }
- });
-
- Log.events = {};
- _.extend(Log.events, Backbone.Events);
-
- Log.Views.View = FauxtonAPI.View.extend({
- template: "addons/logs/templates/dashboard",
-
- initialize: function (options) {
- this.refreshTime = options.refreshTime || 5000;
-
- Log.events.on("log:filter", this.filterLogs, this);
- Log.events.on("log:remove", this.removeFilterLogs, this);
-
- this.filters = [];
-
- this.collection.on("add", function () {
- this.render();
- }, this);
- },
-
- establish: function () {
- return [this.collection.fetch()];
- },
-
- serialize: function () {
- return { logs: new Log.Collection(this.createFilteredCollection())};
- },
-
- afterRender: function () {
- this.startRefreshInterval();
- },
-
- cleanup: function () {
- this.stopRefreshInterval();
- },
-
- filterLogs: function (filter) {
- this.filters.push(filter);
- this.render();
- },
-
- createFilteredCollection: function () {
- var that = this;
-
- return _.reduce(this.filters, function (logs, filter) {
-
- return _.filter(logs, function (log) {
- var match = false;
-
- _.each(log, function (value) {
- if (value.toString().match(new RegExp(filter))) {
- match = true;
- }
- });
- return match;
- });
-
-
- }, this.collection.toJSON(), this);
-
- },
-
- removeFilterLogs: function (filter) {
- this.filters.splice(this.filters.indexOf(filter), 1);
- this.render();
- },
-
- startRefreshInterval: function () {
- var collection = this.collection;
-
- // Interval already set
- if (this.intervalId) { return ; }
-
- this.intervalId = setInterval(function () {
- collection.fetch();
- }, this.refreshTime);
-
- },
-
- stopRefreshInterval: function () {
- clearInterval(this.intervalId);
- }
- });
-
- Log.Views.FilterView = FauxtonAPI.View.extend({
- template: "addons/logs/templates/sidebar",
-
- events: {
- "submit #log-filter-form": "filterLogs"
- },
-
- filterLogs: function (event) {
- event.preventDefault();
- var $filter = this.$('input[name="filter"]'),
- filter = $filter.val();
-
- Log.events.trigger("log:filter", filter);
-
- this.insertView("#filter-list", new Log.Views.FilterItemView({
- filter: filter
- })).render();
-
- $filter.val('');
- }
-
- });
-
- Log.Views.FilterItemView = FauxtonAPI.View.extend({
- template: "addons/logs/templates/filterItem",
- tagName: "li",
-
- initialize: function (options) {
- this.filter = options.filter;
- },
-
- events: {
- "click .remove-filter": "removeFilter"
- },
-
- serialize: function () {
- return {
- filter: this.filter
- };
- },
-
- removeFilter: function (event) {
- event.preventDefault();
-
- Log.events.trigger("log:remove", this.filter);
- this.remove();
- }
-
- });
-
-
- return Log;
-
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/logs/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/logs/routes.js b/src/fauxton/app/addons/logs/routes.js
deleted file mode 100644
index 7c498b0..0000000
--- a/src/fauxton/app/addons/logs/routes.js
+++ /dev/null
@@ -1,58 +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.
-
-define([
- "app",
-
- "api",
-
- // Modules
- "addons/logs/resources"
-],
-
-function(app, FauxtonAPI, Log) {
-
- var LogRouteObject = FauxtonAPI.RouteObject.extend({
- layout: "with_sidebar",
-
- crumbs: [
- {"name": "Logs", "link": "_log"}
- ],
-
- routes: {
- "_log": "showLog"
- },
-
- selectedHeader: "Log",
-
- roles: ["_admin"],
-
- apiUrl: function() {
- return this.logs.url();
- },
-
- initialize: function () {
- this.logs = new Log.Collection();
- this.setView("#sidebar-content", new Log.Views.FilterView({}));
- },
-
- showLog: function () {
- this.setView("#dashboard-content", new Log.Views.View({collection: this.logs}));
- }
- });
-
- Log.RouteObjects = [LogRouteObject];
-
- return Log;
-
-});
-
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/logs/templates/dashboard.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/logs/templates/dashboard.html b/src/fauxton/app/addons/logs/templates/dashboard.html
deleted file mode 100644
index 14969c8..0000000
--- a/src/fauxton/app/addons/logs/templates/dashboard.html
+++ /dev/null
@@ -1,46 +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.
--->
-
- <h2> Couchdb Logs </h2>
- <table class="table table-bordered" >
- <thead>
- <tr>
- <th class="Date">Date</th>
- <th class="Log Level">Log Value</th>
- <th class="Pid">Pid</th>
- <th class="Args">Url</th>
- </tr>
- </thead>
-
- <tbody>
- <% logs.each(function (log) { %>
- <tr class="<%= log.logLevel() %>">
- <td>
- <!-- TODO: better format the date -->
- <%= log.date() %>
- </td>
- <td>
- <%= log.logLevel() %>
- </td>
- <td>
- <%= log.pid() %>
- </td>
- <td>
- <!-- TODO: split the line, maybe put method in it's own column -->
- <%= log.args() %>
- </td>
- </tr>
- <% }); %>
- </tbody>
-</table>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/logs/templates/filterItem.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/logs/templates/filterItem.html b/src/fauxton/app/addons/logs/templates/filterItem.html
deleted file mode 100644
index c4e885a..0000000
--- a/src/fauxton/app/addons/logs/templates/filterItem.html
+++ /dev/null
@@ -1,16 +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.
--->
-
-<span class="label label-info"> <%= filter %> </span>
-<a class="label label-info remove-filter" href="#">×</a>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/logs/templates/sidebar.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/logs/templates/sidebar.html b/src/fauxton/app/addons/logs/templates/sidebar.html
deleted file mode 100644
index 91822e0..0000000
--- a/src/fauxton/app/addons/logs/templates/sidebar.html
+++ /dev/null
@@ -1,27 +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.
--->
-
-<div id="log-sidebar">
- <form class="form-inline" id="log-filter-form">
- <fieldset>
- <legend>Log Filter</legend>
- <input type="text" name="filter" placeholder="Type a filter to sort the logs by">
- <!-- TODO: filter by method -->
- <!-- TODO: correct removed filter behaviour -->
- <button type="submit" class="btn">Filter</button>
- <span class="help-block"> <h6> Eg. debug or <1.4.1> or any regex </h6> </span>
- </fieldset>
- </form>
- <ul id="filter-list"></ul>
-</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/logs/tests/logSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/logs/tests/logSpec.js b/src/fauxton/app/addons/logs/tests/logSpec.js
deleted file mode 100644
index 621cc9b..0000000
--- a/src/fauxton/app/addons/logs/tests/logSpec.js
+++ /dev/null
@@ -1,38 +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.
-define([
- 'addons/logs/base',
- 'chai'
-], function (Log, chai) {
- var expect = chai.expect;
-
- describe('Logs Addon', function(){
-
- describe('Log Model', function () {
- var log;
-
- beforeEach(function () {
- log = new Log.Model({
- log_level: 'DEBUG',
- pid: '1234',
- args: 'testing 123',
- date: (new Date()).toString()
- });
- });
-
- it('should have a log level', function () {
- expect(log.logLevel()).to.equal('DEBUG');
- });
-
- });
- });
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/stats/assets/less/stats.less
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/stats/assets/less/stats.less b/src/fauxton/app/addons/stats/assets/less/stats.less
deleted file mode 100644
index 8c81f86..0000000
--- a/src/fauxton/app/addons/stats/assets/less/stats.less
+++ /dev/null
@@ -1,20 +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.
- */
-
-.datatypes {
- border: #d3d3d3 1px solid;
- -webkit-border-radius: 5px;
- -moz-border-radius: 5px;
- border-radius: 5px;
- padding: 15px;
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/stats/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/stats/base.js b/src/fauxton/app/addons/stats/base.js
deleted file mode 100644
index 4721399..0000000
--- a/src/fauxton/app/addons/stats/base.js
+++ /dev/null
@@ -1,26 +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.
-
-define([
- "app",
- "api",
- "addons/stats/routes"
-],
-
-function(app, FauxtonAPI, Stats) {
-
- Stats.initialize = function() {
- FauxtonAPI.addHeaderLink({title: "Statistics", href: "#stats"});
- };
-
- return Stats;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/stats/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/stats/resources.js b/src/fauxton/app/addons/stats/resources.js
deleted file mode 100644
index 94be6bb..0000000
--- a/src/fauxton/app/addons/stats/resources.js
+++ /dev/null
@@ -1,37 +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.
-
-define([
- "app",
- "api",
- "backbone",
- "lodash",
- "modules/fauxton/base"
-],
-
-function (app, FauxtonAPI, backbone, _, Fauxton) {
- var Stats = new FauxtonAPI.addon();
-
- Stats.Collection = Backbone.Collection.extend({
- model: Backbone.Model,
- url: "/_stats",
- parse: function(resp) {
- return _.flatten(_.map(resp, function(doc, key) {
- return _.map(doc, function(v, k){
- return _.extend({id: k, type: key}, v);
- });
- }), true);
- }
- });
-
- return Stats;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/stats/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/stats/routes.js b/src/fauxton/app/addons/stats/routes.js
deleted file mode 100644
index 5f1affe..0000000
--- a/src/fauxton/app/addons/stats/routes.js
+++ /dev/null
@@ -1,56 +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.
-
-define([
- "app",
- "api",
- "addons/stats/views"
-],
-
-function(app, FauxtonAPI, Stats) {
-
- var StatsRouteObject = FauxtonAPI.RouteObject.extend({
- layout: "with_sidebar",
-
- routes: {
- "stats":"showStats",
- "_stats": "showStats"
- },
-
- selectedHeader: "Statistics",
-
- initialize: function () {
- this.stats = new Stats.Collection();
-
- this.setView("#sidebar-content", new Views.StatSelect({
- collection: this.stats
- }));
-
- },
-
- showStats: function () {
- this.setView("#dashboard-content", new Views.Statistics({
- collection: this.stats
- }));
- },
-
- establish: function() {
- return [this.stats.fetch()];
- },
-
- apiUrl: "_stats"
- });
-
- Stats.RouteObjects = [StatsRouteObject];
-
- return Stats;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/stats/templates/by_method.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/stats/templates/by_method.html b/src/fauxton/app/addons/stats/templates/by_method.html
deleted file mode 100644
index 099d737..0000000
--- a/src/fauxton/app/addons/stats/templates/by_method.html
+++ /dev/null
@@ -1,16 +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.
--->
-
-<h2>By Method <small>GET, POST, PUT, DELETE</small></h2>
-<div id="httpd_request_methods"></div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/stats/templates/pie_table.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/stats/templates/pie_table.html b/src/fauxton/app/addons/stats/templates/pie_table.html
deleted file mode 100644
index fba4717..0000000
--- a/src/fauxton/app/addons/stats/templates/pie_table.html
+++ /dev/null
@@ -1,56 +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.
--->
-
-<div class="row-fluid">
- <div class="span8">
- <h2> <%= datatype %> </h2>
- </div>
-</div>
-
-<div class="row-fluid">
- <div class="span8" style="margin-top:70px">
- <table class="table table-condensed table-striped">
- <thead>
- <tr>
- <th> Description </th>
- <th> current </th>
- <th> sum </th>
- <th> mean </th>
- <th> stddev </th>
- <th> min </th>
- <th> max </th>
- </tr>
- </thead>
- <% _.each (statistics, function (stat_line) {
- if (stat_line.get("sum")){
- %>
- <tr>
- <td><%= stat_line.get("description") %></td>
- <td><%= stat_line.get("current") %></td>
- <td><%= stat_line.get("sum") %></td>
- <td><%= stat_line.get("mean") %></td>
- <td><%= stat_line.get("stddev") %></td>
- <td><%= stat_line.get("min") %></td>
- <td><%= stat_line.get("max") %></td>
- </tr>
- <% }}) %>
- </table>
- </div>
-
- <div class="span4" style="height:430px;min-width: 430px">
- <center>
- <svg id="<%= datatype %>_graph"></svg>
- </center>
- </div>
-</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/stats/templates/stats.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/stats/templates/stats.html b/src/fauxton/app/addons/stats/templates/stats.html
deleted file mode 100644
index ae7ce14..0000000
--- a/src/fauxton/app/addons/stats/templates/stats.html
+++ /dev/null
@@ -1,16 +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.
--->
-
-<div class="datatypes">
-</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/stats/templates/statselect.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/stats/templates/statselect.html b/src/fauxton/app/addons/stats/templates/statselect.html
deleted file mode 100644
index ef1133c..0000000
--- a/src/fauxton/app/addons/stats/templates/statselect.html
+++ /dev/null
@@ -1,22 +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.
--->
-
-<% _.each(datatypes, function (datatype) { %>
-<li>
-<a href="#stats" class="datatype-select" data-type-select="<%= datatype %>">
- <%= datatype %>
- <i class="icon-chevron-right" style="float:right"></i>
-</a>
-</li>
-<% }); %>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/addons/stats/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/stats/views.js b/src/fauxton/app/addons/stats/views.js
deleted file mode 100644
index 9dd9cbc..0000000
--- a/src/fauxton/app/addons/stats/views.js
+++ /dev/null
@@ -1,171 +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.
-
-define([
- "app",
-
- "api",
- 'addons/stats/resources',
- "d3",
- "nv.d3"
-
-],
-
-function(app, FauxtonAPI,Stats) {
- Views = {};
-
- datatypeEventer = {};
- _.extend(datatypeEventer, Backbone.Events);
-
- Views.Legend = FauxtonAPI.View.extend({
- tagName: 'ul',
- template: "addons/stats/templates/legend",
-
- serialize: function () {
- return {
- legend_items: this.collection.toJSON()
- };
- }
- });
-
- Views.Pie = FauxtonAPI.View.extend({
- className: "datatype-section",
- template: 'addons/stats/templates/pie_table',
-
- initialize: function(args){
- this.datatype = args.datatype;
- },
-
- serialize: function() {
- return {
- statistics: this.collection.where({type: this.datatype}),
- datatype: this.datatype
- };
- },
-
- afterRender: function(){
- var collection = this.collection,
- chartelem = "#" + this.datatype + '_graph',
- series = _.map(this.collection.where({type: this.datatype}),
- function(d, counter){
- // TODO: x should be a counter
- var point = {
- y: d.get("sum") || 0,
- key: d.id
- };
- return point;
- }
- );
-
- series = _.filter(series, function(d){return d.y > 0;});
- series = _.sortBy(series, function(d){return -d.y;});
-
- nv.addGraph(function() {
- var width = 550,
- height = 400;
-
- var chart = nv.models.pieChart()
- .x(function(d) { return d.key; })
- .y(function(d) { return d.y; })
- .showLabels(true)
- .showLegend(false)
- .values(function(d) { return d; })
- .color(d3.scale.category10().range())
- .width(width)
- .height(height);
-
- d3.select(chartelem)
- .datum([series])
- .transition().duration(300)
- .attr('width', width)
- .attr('height', height)
- .call(chart);
-
- return chart;
- });
-
- this.$el.addClass(this.datatype + '_section');
- }
- });
-
- Views.StatSelect = FauxtonAPI.View.extend({
- className: 'nav nav-tabs nav-stacked',
- tagName: 'ul',
-
- template: "addons/stats/templates/statselect",
-
- initialize: function (options) {
- this.rows = [];
- },
-
- events: {
- 'click .datatype-select': "datatype_selected"
- },
-
- serialize: function () {
- return {
- datatypes: _.uniq(this.collection.pluck("type"))
- };
- },
-
- afterRender: function () {
- this.$('.datatype-select').first().addClass('active');
- },
-
- datatype_selected: function (event) {
- var $target = $(event.currentTarget);
-
- event.preventDefault();
- event.stopPropagation();
- this.$('.datatype-select').removeClass('active');
- $target.addClass('active');
- datatypeEventer.trigger('datatype-select', $target.attr('data-type-select'));
- }
- });
-
- Views.Statistics = FauxtonAPI.View.extend({
- template: "addons/stats/templates/stats",
-
- initialize: function (options) {
- this.rows = [];
- datatypeEventer.on('datatype-select', this.display_datatype, this);
- },
-
- serialize: function () {
- return {
- datatypes: _.uniq(this.collection.pluck("type"))
- };
- },
-
- beforeRender: function () {
- _.each(_.uniq(this.collection.pluck("type")), function(datatype) {
- this.rows[datatype] = this.insertView(".datatypes", new Views.Pie({
- collection: this.collection,
- datatype: datatype
- }));
- }, this);
- },
-
- afterRender: function () {
- this.$('.datatype-section').hide().first().toggle();
- },
-
- display_datatype: function (datatype) {
- this.$('.datatype-section').hide();
- this.$('.' + datatype + '_section').show();
- }
- });
-
- Stats.Views = Views;
-
- return Stats;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/api.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/api.js b/src/fauxton/app/api.js
deleted file mode 100644
index c4aaaf4..0000000
--- a/src/fauxton/app/api.js
+++ /dev/null
@@ -1,390 +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.
-
-define([
- "app",
-
- // Modules
- "modules/fauxton/base"
-],
-
-function(app, Fauxton) {
- var FauxtonAPI = app.module();
-
- FauxtonAPI.moduleExtensions = {
- Routes: {
- }
- };
-
- FauxtonAPI.addonExtensions = {
- initialize: function() {}
- };
-
- // List of JSHINT errors to ignore
- // Gets around problem of anonymous functions not being a valid statement
- FauxtonAPI.excludedViewErrors = [
- "Missing name in function declaration.",
- "['{a}'] is better written in dot notation."
- ];
-
- FauxtonAPI.isIgnorableError = function(msg) {
- return _.contains(FauxtonAPI.excludedViewErrors, msg);
- };
-
- FauxtonAPI.View = Backbone.View.extend({
- // This should return an array of promises, an empty array, or null
- establish: function() {
- return null;
- },
-
- loaderClassname: 'loader',
-
- disableLoader: false,
-
- hasRendered: function () {
- return !!this.__manager__.hasRendered;
- },
-
- forceRender: function () {
- this.__manager__.hasRendered = false;
- }
- });
-
- FauxtonAPI.navigate = function(url, _opts) {
- var options = _.extend({trigger: true}, _opts );
- app.router.navigate(url,options);
- };
-
- FauxtonAPI.addHeaderLink = function(link) {
- app.masterLayout.navBar.addLink(link);
- };
-
- FauxtonAPI.Deferred = function() {
- return $.Deferred();
- };
-
- FauxtonAPI.when = function (deferreds) {
- if (deferreds instanceof Array) {
- return $.when.apply(null, deferreds);
- }
-
- return $.when(deferreds);
- };
-
- FauxtonAPI.addRoute = function(route) {
- app.router.route(route.route, route.name, route.callback);
- };
-
- FauxtonAPI.triggerRouteEvent = function (routeEvent, args) {
- app.router.triggerRouteEvent("route:"+routeEvent, args);
- };
-
- FauxtonAPI.module = function(extra) {
- return app.module(_.extend(FauxtonAPI.moduleExtensions, extra));
- };
-
- FauxtonAPI.addon = function(extra) {
- return FauxtonAPI.module(FauxtonAPI.addonExtensions, extra);
- };
-
- 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();
- };
-
- FauxtonAPI.UUID = Backbone.Model.extend({
- initialize: function(options) {
- options = _.extend({count: 1}, options);
- this.count = options.count;
- },
-
- url: function() {
- return app.host + "/_uuids?count=" + this.count;
- },
-
- next: function() {
- return this.get("uuids").pop();
- }
- });
-
- FauxtonAPI.Session = Backbone.Model.extend({
- url: '/_session',
-
- user: function () {
- var userCtx = this.get('userCtx');
-
- if (!userCtx || !userCtx.name) { return null; }
-
- return {
- name: userCtx.name,
- roles: userCtx.roles
- };
- },
-
- fetchOnce: function (opt) {
- var options = _.extend({}, opt);
-
- if (!this._deferred || this._deferred.state() === "rejected" || options.forceFetch ) {
- this._deferred = this.fetch();
- }
-
- return this._deferred;
- },
-
- fetchUser: function (opt) {
- var that = this,
- currentUser = this.user();
-
- return this.fetchOnce(opt).then(function () {
- var user = that.user();
-
- // Notify anyone listening on these events that either a user has changed
- // or current user is the same
- if (currentUser !== user) {
- that.trigger('session:userChanged');
- } else {
- that.trigger('session:userFetched');
- }
-
- // this will return the user as a value to all function that calls done on this
- // eg. session.fetchUser().done(user) { .. do something with user ..}
- return user;
- });
- }
- });
-
- FauxtonAPI.setSession = function (newSession) {
- app.session = FauxtonAPI.session = newSession;
- return FauxtonAPI.session.fetchUser();
- };
-
- FauxtonAPI.setSession(new FauxtonAPI.Session());
-
- // This is not exposed externally as it should not need to be accessed or overridden
- var Auth = function (options) {
- this._options = options;
- this.initialize.apply(this, arguments);
- };
-
- // Piggy-back on Backbone's self-propagating extend function,
- Auth.extend = Backbone.Model.extend;
-
- _.extend(Auth.prototype, Backbone.Events, {
- authDeniedCb: function() {},
-
- initialize: function() {
- var that = this;
- },
-
- authHandlerCb : function (roles) {
- var deferred = $.Deferred();
- deferred.resolve();
- return deferred;
- },
-
- registerAuth: function (authHandlerCb) {
- this.authHandlerCb = authHandlerCb;
- },
-
- registerAuthDenied: function (authDeniedCb) {
- this.authDeniedCb = authDeniedCb;
- },
-
- checkAccess: function (roles) {
- var requiredRoles = roles || [],
- that = this;
-
- return FauxtonAPI.session.fetchUser().then(function (user) {
- return FauxtonAPI.when(that.authHandlerCb(FauxtonAPI.session, requiredRoles));
- });
- }
- });
-
- FauxtonAPI.auth = new Auth();
-
- FauxtonAPI.RouteObject = function(options) {
- this._options = options;
-
- this._configure(options || {});
- this.initialize.apply(this, arguments);
- this.addEvents();
- };
-
- // Piggy-back on Backbone's self-propagating extend function
- FauxtonAPI.RouteObject.extend = Backbone.Model.extend;
-
- var routeObjectOptions = ["views", "routes", "events", "roles", "crumbs", "layout", "apiUrl", "establish"];
-
- _.extend(FauxtonAPI.RouteObject.prototype, Backbone.Events, {
- // Should these be default vals or empty funcs?
- views: {},
- routes: {},
- events: {},
- crumbs: [],
- layout: "with_sidebar",
- apiUrl: null,
- disableLoader: false,
- loaderClassname: 'loader',
- renderedState: false,
- establish: function() {},
- route: function() {},
- roles: [],
- initialize: function() {}
- }, {
-
- renderWith: function(route, masterLayout, args) {
- var routeObject = this;
-
- // TODO: Can look at replacing this with events eg beforeRender, afterRender function and events
- this.route.call(this, route, args);
-
- // Only want to redo the template if its a full render
- if (!this.renderedState) {
- masterLayout.setTemplate(this.layout);
- $('#nav-links li').removeClass('active');
-
- if (this.selectedHeader) {
- $('#nav-links li[data-nav-name="' + this.selectedHeader + '"]').addClass('active');
- }
- }
-
- //add page loader. "app-container" shouldn't be overwritten. Even if a new index.underscore is provided in settings.json
- if (!this.disableLoader) {
- $('#app-container').addClass(this.loaderClassname);
- }
-
- masterLayout.clearBreadcrumbs();
- var crumbs = this.get('crumbs');
-
- if (crumbs.length) {
- masterLayout.setBreadcrumbs(new Fauxton.Breadcrumbs({
- crumbs: crumbs
- }));
- }
-
- FauxtonAPI.when(this.establish()).done(function(resp) {
- if (!this.disableLoader) {
- $('#app-container').removeClass(this.loaderClassname);
- }
- _.each(routeObject.getViews(), function(view, selector) {
- if(view.hasRendered()) { return; }
- if (!view.disableLoader){ $(selector).addClass(view.loaderClassname);}
- FauxtonAPI.when(view.establish()).then(function(resp) {
- masterLayout.setView(selector, view);
- if (!view.disableLoader) $(selector).removeClass(view.loaderClassname);
- masterLayout.renderView(selector);
- }, function(resp) {
- view.establishError = {
- error: true,
- reason: resp
- };
- masterLayout.renderView(selector);
- });
-
- var hooks = masterLayout.hooks[selector];
- var boundRoute = route;
-
- _.each(hooks, function(hook){
- if (_.any(hook.routes, function(route){return route == boundRoute;})){
- hook.callback(view);
- }
- });
- });
- }.bind(this));
-
- if (this.get('apiUrl')) masterLayout.apiBar.update(this.get('apiUrl'));
-
- // Track that we've done a full initial render
- this.renderedState = true;
- },
-
- get: function(key) {
- return _.isFunction(this[key]) ? this[key]() : this[key];
- },
-
- addEvents: function(events) {
- events = events || this.get('events');
- _.each(events, function(method, event) {
- if (!_.isFunction(method) && !_.isFunction(this[method])) {
- throw new Error("Invalid method: "+method);
- }
- method = _.isFunction(method) ? method : this[method];
-
- this.on(event, method);
- }, this);
- },
-
- _configure: function(options) {
- _.each(_.intersection(_.keys(options), routeObjectOptions), function(key) {
- this[key] = options[key];
- }, this);
- },
-
- getView: function(selector) {
- return this.views[selector];
- },
-
- setView: function(selector, view) {
- this.views[selector] = view;
- return view;
- },
-
- getViews: function() {
- return this.views;
- },
-
- getRouteUrls: function () {
- return _.keys(this.get('routes'));
- },
-
- hasRoute: function (route) {
- if (this.get('routes')[route]) {
- return true;
- }
- return false;
- },
-
- routeCallback: function (route, args) {
- var routes = this.get('routes'),
- routeObj = routes[route],
- routeCallback;
-
- if (typeof routeObj === 'object') {
- routeCallback = this[routeObj.route];
- } else {
- routeCallback = this[routeObj];
- }
-
- routeCallback.apply(this, args);
- },
-
- getRouteRoles: function (routeUrl) {
- var route = this.get('routes')[routeUrl];
-
- if ((typeof route === 'object') && route.roles) {
- return route.roles;
- }
-
- return this.roles;
- }
-
- });
-
- app.fauxtonAPI = FauxtonAPI;
- return app.fauxtonAPI;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/app.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/app.js b/src/fauxton/app/app.js
deleted file mode 100644
index df0894a..0000000
--- a/src/fauxton/app/app.js
+++ /dev/null
@@ -1,75 +0,0 @@
-define([
- // Libraries.
- "jquery",
- "lodash",
- "backbone",
-
- "helpers",
-
- // Plugins.
- "plugins/backbone.layoutmanager",
- "plugins/jquery.form"
-],
-
-function($, _, Backbone, Helpers) {
-
- // Make sure we have a console.log
- if (typeof console == "undefined") {
- console = {
- log: function(){}
- };
- }
-
- // Provide a global location to place configuration settings and module
- // creation.
- var app = {
- // The root path to run the application.
- root: "/",
- version: "0.0.1"
- };
-
- // Localize or create a new JavaScript Template object.
- var JST = window.JST = window.JST || {};
-
- // Configure LayoutManager with Backbone Boilerplate defaults.
- Backbone.Layout.configure({
- // Allow LayoutManager to augment Backbone.View.prototype.
- manage: true,
-
- prefix: "app/",
-
- // Inject app/helper.js for shared functionality across all html templates
- render: function(template, context) {
- return template(_.extend(Helpers, context));
- },
-
- fetch: function(path) {
- // Initialize done for use in async-mode
- var done;
-
- // Concatenate the file extension.
- path = path + ".html";
-
- // If cached, use the compiled template.
- if (JST[path]) {
- return JST[path];
- } else {
- // Put fetch into `async-mode`.
- done = this.async();
- // Seek out the template asynchronously.
- return $.ajax({ url: app.root + path }).then(function(contents) {
- done(JST[path] = _.template(contents));
- });
- }
- }
- });
-
- // Mix Backbone.Events, and modules into the app object.
- return _.extend(app, {
- // Create a custom object with a nested Views object.
- module: function(additionalProps) {
- return _.extend({ Views: {} }, additionalProps);
- }
- }, Backbone.Events);
-
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/config.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/config.js b/src/fauxton/app/config.js
deleted file mode 100644
index d7d3b40..0000000
--- a/src/fauxton/app/config.js
+++ /dev/null
@@ -1,56 +0,0 @@
-// Set the require.js configuration for your application.
-require.config({
-
- // Initialize the application with the main application file.
- deps: ["main"],
-
- paths: {
- // JavaScript folders.
- libs: "../assets/js/libs",
- plugins: "../assets/js/plugins",
-
- // Libraries.
- jquery: "../assets/js/libs/jquery",
- lodash: "../assets/js/libs/lodash",
- backbone: "../assets/js/libs/backbone",
- bootstrap: "../assets/js/libs/bootstrap",
- codemirror: "../assets/js/libs/codemirror",
- jshint: "../assets/js/libs/jshint",
- d3: "../assets/js/libs/d3",
- "nv.d3": "../assets/js/libs/nv.d3"
- },
-
- baseUrl: '/',
-
- shim: {
- // Backbone library depends on lodash and jQuery.
- backbone: {
- deps: ["lodash", "jquery"],
- exports: "Backbone"
- },
-
- bootstrap: {
- deps: ["jquery"],
- exports: "Bootstrap"
- },
-
- codemirror: {
- deps: ["jquery"],
- exports: "CodeMirror"
- },
-
- jshint: {
- deps: ["jquery"],
- exports: "JSHINT"
- },
-
- // Backbone.LayoutManager depends on Backbone.
- "plugins/backbone.layoutmanager": ["backbone"],
-
- "plugins/codemirror-javascript": ["codemirror"],
-
- "plugins/prettify": [],
-
- "plugins/jquery.form": ["jquery"]
- }
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/helpers.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/helpers.js b/src/fauxton/app/helpers.js
deleted file mode 100644
index 6408afc..0000000
--- a/src/fauxton/app/helpers.js
+++ /dev/null
@@ -1,54 +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([
- "d3"
-],
-
-function() {
-
- var Helpers = {};
-
- Helpers.imageUrl = function(path) {
- // TODO: add dynamic path for different deploy targets
- return path;
- };
-
- // File size pretty printing, taken from futon.format.js
- Helpers.formatSize = function(size) {
- var jump = 512;
- if (size < jump) return size + " bytes";
- var units = ["KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
- var i = 0;
- while (size >= jump && i < units.length) {
- i += 1;
- size /= 1024;
- }
- return size.toFixed(1) + ' ' + units[i - 1];
- };
-
- Helpers.formatDate = function(timestamp){
- format = d3.time.format("%b. %e at %H:%M%p");
- return format(new Date(timestamp*1000));
- };
-
- return Helpers;
-});
-
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/initialize.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/initialize.js b/src/fauxton/app/initialize.js
deleted file mode 100644
index 6fed729..0000000
--- a/src/fauxton/app/initialize.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.
-
-define([
- // Application.
- "app",
-
- // Libraries
- "lodash",
- "bootstrap"
-],
-
-function(app, _, Bootstrap) {
-
- // Provide a global location to place configuration settings and module
- // creation.
- _.extend(app, {
- // The root path to run the application through.
- // TODO: pick this up wither at build time or from the browser
- root: "/_utils/fauxton/",
-
- host: window.location.protocol + "//" + window.location.host,
-
- renderView: function(baseView, selector, view, options, callback) {
- baseView.setView(selector, new view(options)).render().then(callback);
- },
-
- // Thanks to: http://stackoverflow.com/a/2880929
- getParams: function(queryString) {
- if (typeof queryString !== "undefined") {
- // 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;
- }
- });
-
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/load_addons.js.underscore
----------------------------------------------------------------------
diff --git a/src/fauxton/app/load_addons.js.underscore b/src/fauxton/app/load_addons.js.underscore
deleted file mode 100644
index 9686ad7..0000000
--- a/src/fauxton/app/load_addons.js.underscore
+++ /dev/null
@@ -1,27 +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.
-
-
-/*
- * ::WARNING::
- * THIS IS A GENERATED FILE. DO NOT EDIT.
- */
-define([
- <%= '"' + deps.join('","') + '"' %>
-],
-function() {
- var LoadAddons = {
- addons: arguments
- };
-
- return LoadAddons;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/main.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/main.js b/src/fauxton/app/main.js
deleted file mode 100644
index fba4f6e..0000000
--- a/src/fauxton/app/main.js
+++ /dev/null
@@ -1,38 +0,0 @@
-require([
- // Application.
- "app",
-
- // Main Router.
- "router"
-],
-
-function(app, Router) {
-
- // Define your master router on the application namespace and trigger all
- // navigation from this instance.
- app.router = new Router();
- // 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`
- // attribute, bypass the delegation completely.
- $(document).on("click", "a:not([data-bypass])", function(evt) {
- // Get the absolute anchor href.
- var href = { prop: $(this).prop("href"), attr: $(this).attr("href") };
- // Get the absolute root.
- var root = location.protocol + "//" + location.host + app.root;
- // Ensure the root is part of the anchor href, meaning it's relative.
- if (href.prop && href.prop.slice(0, root.length) === root) {
- // Stop the default event to ensure the link will not cause a page
- // refresh.
- evt.preventDefault();
-
- // `Backbone.history.navigate` is sufficient for all Routers and will
- // trigger the correct events. The Router's internal `navigate` method
- // calls this anyways. The fragment is sliced from the root.
- Backbone.history.navigate(href.attr, true);
- }
-
- });
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/modules/databases/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/databases/base.js b/src/fauxton/app/modules/databases/base.js
deleted file mode 100644
index a5b4542..0000000
--- a/src/fauxton/app/modules/databases/base.js
+++ /dev/null
@@ -1,36 +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.
-
-define([
- "app",
-
- "api",
-
- // Modules
- "modules/databases/routes",
- // Views
- "modules/databases/views"
-
-],
-
-function(app, FauxtonAPI, Databases, Views) {
- Databases.Views = Views;
-
- // Utility functions
- Databases.databaseUrl = function(database) {
- var name = _.isObject(database) ? database.id : database;
-
- return ["/database/", name, "/_all_docs?limit=10"].join('');
- };
-
- return Databases;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/modules/databases/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/databases/resources.js b/src/fauxton/app/modules/databases/resources.js
deleted file mode 100644
index 04e6c1e..0000000
--- a/src/fauxton/app/modules/databases/resources.js
+++ /dev/null
@@ -1,148 +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.
-
-define([
- "app",
-
- "api",
-
- // Modules
- "modules/documents/resources"
-],
-
-function(app, FauxtonAPI, Documents) {
- var Databases = FauxtonAPI.module();
-
- Databases.Model = Backbone.Model.extend({
- initialize: function(options) {
- this.status = new Databases.Status({
- database: this
- });
- },
-
- buildAllDocs: function(params) {
- this.allDocs = new Documents.AllDocs(null, {
- database: this,
- params: params
- });
-
- return this.allDocs;
- },
-
- isNew: function(){
- // Databases are never new, to make Backbone do a PUT
- return false;
- },
-
- url: function(context) {
- if (context === "index") {
- return "/database/" + this.id + "/_all_docs";
- } else if (context === "changes") {
- return "/database/" + this.id + "/_changes?descending=true&limit=100&include_docs=true";
- } else if (context === "app") {
- return "/database/" + this.id;
- } else {
- return app.host + "/" + this.id;
- }
- },
-
- buildChanges: function (params) {
- this.changes = new Databases.Changes({
- database: this,
- params: params
- });
-
- return this.changes;
- }
- });
-
- Databases.Changes = Backbone.Collection.extend({
-
- initialize: function(options) {
- this.database = options.database;
- this.params = options.params;
- },
-
- url: function () {
- var query = "";
- if (this.params) {
- query = "?" + $.param(this.params);
- }
-
- return app.host + '/' + this.database.id + '/_changes' + query;
- },
-
- parse: function (resp) {
- this.last_seq = resp.last_seq;
- return resp.results;
- }
- });
-
- Databases.Status = Backbone.Model.extend({
- url: function() {
- return app.host + "/" + this.database.id;
- },
-
- initialize: function(options) {
- this.database = options.database;
- },
-
- numDocs: function() {
- return this.get("doc_count");
- },
-
- updateSeq: function(full) {
- var updateSeq = this.get("update_seq");
- if (full || (typeof(updateSeq) === 'number')) {
- return updateSeq;
- } else if (updateSeq) {
- return updateSeq.split('-')[0];
- } else {
- return 0;
- }
- },
-
- humanSize: function() {
- // cribbed from http://stackoverflow.com/questions/10420352/converting-file-size-in-bytes-to-human-readable
- var i = -1;
- var byteUnits = [' kB', ' MB', ' GB', ' TB', 'PB', 'EB', 'ZB', 'YB'];
- var fileSizeInBytes = this.get("disk_size");
- do {
- fileSizeInBytes = fileSizeInBytes / 1024;
- i++;
- } while (fileSizeInBytes > 1024);
-
- return Math.max(fileSizeInBytes, 0.1).toFixed(1) + byteUnits[i];
- }
- });
-
- // TODO: shared databases - read from the user doc
- Databases.List = Backbone.Collection.extend({
- model: Databases.Model,
-
- url: function() {
- return app.host + "/_all_dbs";
- },
-
- parse: function(resp) {
- // TODO: pagination!
- return _.map(resp, function(database) {
- return {
- id: encodeURIComponent(database),
- name: database
- };
- });
- }
- });
-
- return Databases;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/modules/databases/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/databases/routes.js b/src/fauxton/app/modules/databases/routes.js
deleted file mode 100644
index fe1a441..0000000
--- a/src/fauxton/app/modules/databases/routes.js
+++ /dev/null
@@ -1,84 +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.
-
-define([
- "app",
-
- "api",
-
- // Modules
- "modules/databases/resources",
- // TODO:: fix the include flow modules so we don't have to require views here
- "modules/databases/views"
-],
-
-function(app, FauxtonAPI, Databases, Views) {
-
- var AllDbsRouteObject = FauxtonAPI.RouteObject.extend({
- layout: "with_sidebar",
-
- crumbs: [
- {"name": "Databases", "link": "/_all_dbs"}
- ],
-
- routes: {
- "": "allDatabases",
- "index.html": "allDatabases",
- "_all_dbs(:params)": "allDatabases"
- },
-
- apiUrl: function() {
- return this.databases.url();
- },
-
- selectedHeader: "Databases",
-
- initialize: function() {
- this.databases = new Databases.List();
- this.deferred = FauxtonAPI.Deferred();
-
- this.sidebarView = this.setView("#sidebar-content", new Views.Sidebar({
- collection: this.databases
- }));
- },
-
- allDatabases: function() {
- var params = app.getParams(),
- dbPage = params.page;
-
- this.databasesView = this.setView("#dashboard-content", new Views.List({
- collection: this.databases
- }));
-
- this.databasesView.setPage(dbPage);
- },
-
- establish: function() {
- var databases = this.databases;
- var deferred = this.deferred;
-
- databases.fetch().done(function(resp) {
- FauxtonAPI.when(databases.map(function(database) {
- return database.status.fetch();
- })).done(function(resp) {
- deferred.resolve();
- });
- });
-
- return [deferred];
- }
- });
-
- Databases.RouteObjects = [AllDbsRouteObject];
-
- return Databases;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/modules/databases/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/databases/views.js b/src/fauxton/app/modules/databases/views.js
deleted file mode 100644
index c1b9bb7..0000000
--- a/src/fauxton/app/modules/databases/views.js
+++ /dev/null
@@ -1,190 +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.
-
-define([
- "app",
-
- "modules/fauxton/base",
- "api"
-],
-
-function(app, Fauxton, FauxtonAPI) {
- var Views = {};
-
- Views.Item = FauxtonAPI.View.extend({
- template: "templates/databases/item",
- tagName: "tr",
-
- serialize: function() {
- return {
- database: this.model
- };
- }
- });
-
- Views.List = FauxtonAPI.View.extend({
- dbLimit: 10,
- perPage: 10,
- template: "templates/databases/list",
- events: {
- "click button.all": "selectAll",
- "submit form.database-search": "switchDatabase"
- },
-
- initialize: function(options) {
- var params = app.getParams();
- this.page = params.page ? parseInt(params.page, 10) : 1;
- },
-
- serialize: function() {
- return {
- databases: this.collection
- };
- },
-
- switchDatabase: function(event) {
- event.preventDefault();
- var dbname = this.$el.find("input.search-query").val();
-
- if (dbname) {
- // TODO: switch to using a model, or Databases.databaseUrl()
- // Neither of which are in scope right now
- // var db = new Database.Model({id: dbname});
- var url = ["/database/", dbname, "/_all_docs?limit=10"].join('');
- FauxtonAPI.navigate(url);
- }
- },
-
- paginated: function() {
- var start = (this.page - 1) * this.perPage;
- var end = this.page * this.perPage;
- return this.collection.slice(start, end);
- },
-
- beforeRender: function() {
- _.each(this.paginated(), function(database) {
- this.insertView("table.databases tbody", new Views.Item({
- model: database
- }));
- }, this);
-
- this.insertView("#database-pagination", new Fauxton.Pagination({
- page: this.page,
- perPage: this.perPage,
- total: this.collection.length,
- urlFun: function(page) {
- return "#/_all_dbs?page=" + page;
- }
- }));
- },
-
- setPage: function(page) {
- this.page = page || 1;
- },
-
- afterRender: function() {
- var dbLimit = this.dbLimit;
- var ajaxReq;
-
- this.$el.find("input.search-query").typeahead({
- source: function(query, process) {
- var url = [
- app.host,
- "/_all_dbs?startkey=%22",
- query,
- "%22&endkey=%22",
- query,
- "\u9999%22&limit=",
- dbLimit
- ].join('');
- if (ajaxReq) ajaxReq.abort();
- ajaxReq = $.ajax({
- url: url,
- dataType: 'json',
- success: function(data) {
- process(data);
- }
- });
- }
- });
- },
-
- selectAll: function(evt){
- $("input:checkbox").attr('checked', !$(evt.target).hasClass('active'));
- }
- });
-
- Views.Sidebar = FauxtonAPI.View.extend({
- template: "templates/databases/sidebar",
- events: {
- "click a#new": "newDatabase",
- "click a#owned": "showMine",
- "click a#shared": "showShared"
- },
-
- newDatabase: function() {
- var notification;
- var db;
- // TODO: use a modal here instead of the prompt
- var name = prompt('Name of database', 'newdatabase');
- if (name === null) {
- return;
- } else if (name.length === 0) {
- notification = FauxtonAPI.addNotification({
- msg: "Please enter a valid database name",
- type: "error",
- clear: true
- });
- return;
- }
- db = new this.collection.model({
- id: encodeURIComponent(name),
- name: name
- });
- notification = FauxtonAPI.addNotification({msg: "Creating database."});
- db.save().done(function() {
- notification = FauxtonAPI.addNotification({
- msg: "Database created successfully",
- type: "success",
- clear: true
- });
- var route = "#/database/" + name + "/_all_docs?limit=100";
- app.router.navigate(route, { trigger: true });
- }
- ).error(function(xhr) {
- var responseText = JSON.parse(xhr.responseText).reason;
- notification = FauxtonAPI.addNotification({
- msg: "Create database failed: " + responseText,
- type: "error",
- clear: true
- });
- }
- );
- },
-
- showMine: function(){
- $.contribute(
- 'Show unshared databases',
- 'app/addons/databases/views.js'
- );
- },
-
- showShared: function(){
- $.contribute(
- 'Show shared databases (e.g. continuous replications to/from the database)',
- 'app/addons/databases/views.js'
- );
- }
- });
-
- return Views;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/modules/documents/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/documents/base.js b/src/fauxton/app/modules/documents/base.js
deleted file mode 100644
index 96e4ada..0000000
--- a/src/fauxton/app/modules/documents/base.js
+++ /dev/null
@@ -1,24 +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.
-
-define([
- "app",
-
- "api",
-
- // Modules
- "modules/documents/routes"
-],
-
-function(app, FauxtonAPI, Documents) {
- return Documents;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/app/modules/documents/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/documents/resources.js b/src/fauxton/app/modules/documents/resources.js
deleted file mode 100644
index 0ec44ea..0000000
--- a/src/fauxton/app/modules/documents/resources.js
+++ /dev/null
@@ -1,435 +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.
-
-define([
- "app",
-
- "api"
-],
-
-function(app, FauxtonAPI) {
- var Documents = app.module();
-
- Documents.Doc = Backbone.Model.extend({
- idAttribute: "_id",
-
- url: function(context) {
- if (context === "app") {
- return this.getDatabase().url("app") + "/" + this.safeID();
- } else {
- return app.host + "/" + this.getDatabase().id + "/" + this.id;
- }
- },
-
- initialize: function(_attrs, options) {
- if (this.collection && this.collection.database) {
- this.database = this.collection.database;
- } else if (options.database) {
- this.database = options.database;
- }
- },
-
- // HACK: the doc needs to know about the database, but it may be
- // set directly or indirectly in all docs
- getDatabase: function() {
- return this.database ? this.database : this.collection.database;
- },
-
- docType: function() {
- return this.id.match(/^_design/) ? "design doc" : "doc";
- },
-
- isEditable: function() {
- return this.docType() != "reduction";
- },
-
- isDdoc: function() {
- return this.docType() === "design doc";
- },
-
- hasViews: function() {
- if (!this.isDdoc()) return false;
- var doc = this.get('doc');
- if (doc) {
- return doc && doc.views && _.keys(doc.views).length > 0;
- }
-
- var views = this.get('views');
- return views && _.keys(views).length > 0;
- },
-
- hasAttachments: function () {
- return !!this.get('_attachments');
- },
-
- getDdocView: function(view) {
- if (!this.isDdoc() || !this.hasViews()) return false;
-
- var doc = this.get('doc');
- if (doc) {
- return doc.views[view];
- }
-
- return this.get('views')[view];
- },
-
- setDdocView: function (view, map, reduce) {
- if (!this.isDdoc()) return false;
- var views = this.get('views');
-
- if (reduce) {
- views[view] = {
- map: map,
- reduce: reduce
- };
- } else {
- views[view].map = map;
- }
-
- this.set({views: views});
-
- return true;
- },
-
- removeDdocView: function (viewName) {
- if (!this.isDdoc()) return false;
- var views = this.get('views');
-
- delete views[viewName];
- this.set({views: views});
- },
-
- dDocModel: function () {
- if (!this.isDdoc()) return false;
- var doc = this.get('doc');
-
- if (doc) {
- return new Documents.Doc(doc, {database: this.database});
- }
-
- return this;
- },
-
- viewHasReduce: function(viewName) {
- var view = this.getDdocView(viewName);
-
- return view && view.reduce;
- },
-
- // Need this to work around backbone router thinking _design/foo
- // is a separate route. Alternatively, maybe these should be
- // treated separately. For instance, we could default into the
- // json editor for docs, or into a ddoc specific page.
- safeID: function() {
- return this.id.replace('/', '%2F');
- },
-
- destroy: function() {
- var url = this.url() + "?rev=" + this.get('_rev');
- return $.ajax({
- url: url,
- dataType: 'json',
- type: 'DELETE'
- });
- },
-
- parse: function(resp) {
- if (resp.rev) {
- resp._rev = resp.rev;
- delete resp.rev;
- }
- if (resp.id) {
- if (typeof(this.id) === "undefined") {
- resp._id = resp.id;
- }
- delete resp.id;
- }
- if (resp.ok) {
- delete resp.ok;
- }
-
- return resp;
- },
-
- prettyJSON: function() {
- var data = this.get("doc") ? this.get("doc") : this;
-
- return JSON.stringify(data, null, " ");
- },
-
- copy: function (copyId) {
- return $.ajax({
- type: 'COPY',
- url: '/' + this.database.id + '/' + this.id,
- headers: {Destination: copyId}
- });
- },
-
- isNewDoc: function () {
- return this.get('_rev') ? false : true;
- }
- });
-
- Documents.DdocInfo = Backbone.Model.extend({
- idAttribute: "_id",
-
- initialize: function (_attrs, options) {
- this.database = options.database;
- },
-
- url: function(context) {
- if (context === "app") {
- return this.database.url("app") + "/" + this.safeID() + '/_info';
- } else {
- return app.host + "/" + this.database.id + "/" + this.id + '/_info';
- }
- },
-
- // Need this to work around backbone router thinking _design/foo
- // is a separate route. Alternatively, maybe these should be
- // treated separately. For instance, we could default into the
- // json editor for docs, or into a ddoc specific page.
- safeID: function() {
- return this.id.replace('/', '%2F');
- }
-
- });
-
- Documents.ViewRow = Backbone.Model.extend({
- docType: function() {
- if (!this.id) return "reduction";
-
- return this.id.match(/^_design/) ? "design doc" : "doc";
- },
-
- url: function(context) {
- if (!this.isEditable()) return false;
-
- return this.collection.database.url(context) + "/" + this.id;
- },
-
- isEditable: function() {
- return this.docType() != "reduction";
- },
-
- prettyJSON: function() {
- //var data = this.get("doc") ? this.get("doc") : this;
- return JSON.stringify(this, null, " ");
- }
- });
-
- Documents.NewDoc = Documents.Doc.extend({
- fetch: function() {
- var uuid = new FauxtonAPI.UUID();
- var deferred = this.deferred = $.Deferred();
- var that = this;
-
- uuid.fetch().done(function() {
- that.set("_id", uuid.next());
- deferred.resolve();
- });
-
- return deferred.promise();
- },
-
- });
-
- Documents.AllDocs = Backbone.Collection.extend({
- model: Documents.Doc,
-
- initialize: function(_models, options) {
- this.database = options.database;
- this.params = options.params;
- },
-
- url: function() {
- var query = "";
- if (this.params) {
- query = "?" + $.param(this.params);
- }
- return app.host + "/" + this.database.id + "/_all_docs" + query;
- },
-
- totalRows: function() {
- return this.viewMeta.total_rows || "unknown";
- },
-
- updateSeq: function() {
- return this.viewMeta.update_seq || false;
- },
-
- parse: function(resp) {
- that = this;
- this.viewMeta = {
- total_rows: resp.total_rows,
- offest: resp.offest,
- update_seq: resp.update_seq
- };
- return _.map(resp.rows, function(row) {
- return {
- _id: row.id,
- _rev: row.value.rev,
- value: row.value,
- key: row.key,
- doc: row.doc || undefined
- };
- });
- }
- });
-
- Documents.IndexCollection = Backbone.Collection.extend({
- model: Documents.ViewRow,
-
- initialize: function(_models, options) {
- this.database = options.database;
- this.params = _.extend({limit: 10, reduce: false}, options.params);
- this.idxType = "_view";
- this.view = options.view;
- this.design = options.design.replace('_design/','');
- },
-
- url: function() {
- var query = "";
- if (this.params) {
- query = "?" + $.param(this.params);
- }
- var url = [app.host, this.database.id, "_design", this.design, this.idxType, this.view];
- return url.join("/") + query;
- },
-
- totalRows: function() {
- return this.viewMeta.total_rows || "unknown";
- },
-
- updateSeq: function() {
- return this.viewMeta.update_seq || false;
- },
-
- parse: function(resp) {
- this.endTime = new Date().getTime();
- this.requestDuration = (this.endTime - this.startTime);
-
- this.viewMeta = {
- total_rows: resp.total_rows,
- offest: resp.offest,
- update_seq: resp.update_seq
- };
- return _.map(resp.rows, function(row) {
- return {
- value: row.value,
- key: row.key,
- doc: row.doc,
- id: row.id
- };
- });
- },
-
- buildAllDocs: function(){
- this.fetch();
- },
-
- // We implement our own fetch to store the starttime so we that
- // we can get the request duration
- fetch: function () {
- this.startTime = new Date().getTime();
- return Backbone.Collection.prototype.fetch.call(this);
- },
-
- allDocs: function(){
- return this.models;
- },
-
- // This is taken from futon.browse.js $.timeString
- requestDurationInString: function () {
- var ms, sec, min, h, timeString, milliseconds = this.requestDuration;
-
- sec = Math.floor(milliseconds / 1000.0);
- min = Math.floor(sec / 60.0);
- sec = (sec % 60.0).toString();
- if (sec.length < 2) {
- sec = "0" + sec;
- }
-
- h = (Math.floor(min / 60.0)).toString();
- if (h.length < 2) {
- h = "0" + h;
- }
-
- min = (min % 60.0).toString();
- if (min.length < 2) {
- min = "0" + min;
- }
-
- timeString = h + ":" + min + ":" + sec;
-
- ms = (milliseconds % 1000.0).toString();
- while (ms.length < 3) {
- ms = "0" + ms;
- }
- timeString += "." + ms;
-
- return timeString;
- }
- });
-
-
- Documents.PouchIndexCollection = Backbone.Collection.extend({
- model: Documents.ViewRow,
-
- initialize: function(_models, options) {
- this.database = options.database;
- this.rows = options.rows;
- this.view = options.view;
- this.design = options.design.replace('_design/','');
- this.params = _.extend({limit: 10, reduce: false}, options.params);
- this.idxType = "_view";
- },
-
- url: function () {
- return '';
- },
-
- fetch: function() {
- var deferred = FauxtonAPI.Deferred();
- this.reset(this.rows, {silent: true});
-
- this.viewMeta = {
- total_rows: this.rows.length,
- offest: 0,
- update_seq: false
- };
-
- deferred.resolve();
- return deferred;
- },
-
- totalRows: function() {
- return this.viewMeta.total_rows || "unknown";
- },
-
- updateSeq: function() {
- return this.viewMeta.update_seq || false;
- },
-
- buildAllDocs: function(){
- this.fetch();
- },
-
- allDocs: function(){
- return this.models;
- }
- });
-
-
-
- return Documents;
-});
[17/26] Remove fauxton from 1.4.x branch.
Posted by dj...@apache.org.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/js/libs/jquery.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/jquery.js b/src/fauxton/assets/js/libs/jquery.js
deleted file mode 100644
index e2c203f..0000000
--- a/src/fauxton/assets/js/libs/jquery.js
+++ /dev/null
@@ -1,9597 +0,0 @@
-/*!
- * jQuery JavaScript Library v1.9.1
- * http://jquery.com/
- *
- * Includes Sizzle.js
- * http://sizzlejs.com/
- *
- * Copyright 2005, 2012 jQuery Foundation, Inc. and other contributors
- * Released under the MIT license
- * http://jquery.org/license
- *
- * Date: 2013-2-4
- */
-(function( window, undefined ) {
-
-// Can't do this because several apps including ASP.NET trace
-// the stack via arguments.caller.callee and Firefox dies if
-// you try to trace through "use strict" call chains. (#13335)
-// Support: Firefox 18+
-//"use strict";
-var
- // The deferred used on DOM ready
- readyList,
-
- // A central reference to the root jQuery(document)
- rootjQuery,
-
- // Support: IE<9
- // For `typeof node.method` instead of `node.method !== undefined`
- core_strundefined = typeof undefined,
-
- // Use the correct document accordingly with window argument (sandbox)
- document = window.document,
- location = window.location,
-
- // Map over jQuery in case of overwrite
- _jQuery = window.jQuery,
-
- // Map over the $ in case of overwrite
- _$ = window.$,
-
- // [[Class]] -> type pairs
- class2type = {},
-
- // List of deleted data cache ids, so we can reuse them
- core_deletedIds = [],
-
- core_version = "1.9.1",
-
- // Save a reference to some core methods
- core_concat = core_deletedIds.concat,
- core_push = core_deletedIds.push,
- core_slice = core_deletedIds.slice,
- core_indexOf = core_deletedIds.indexOf,
- core_toString = class2type.toString,
- core_hasOwn = class2type.hasOwnProperty,
- core_trim = core_version.trim,
-
- // Define a local copy of jQuery
- jQuery = function( selector, context ) {
- // The jQuery object is actually just the init constructor 'enhanced'
- return new jQuery.fn.init( selector, context, rootjQuery );
- },
-
- // Used for matching numbers
- core_pnum = /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,
-
- // Used for splitting on whitespace
- core_rnotwhite = /\S+/g,
-
- // Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE)
- rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
-
- // A simple way to check for HTML strings
- // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
- // Strict HTML recognition (#11290: must start with <)
- rquickExpr = /^(?:(<[\w\W]+>)[^>]*|#([\w-]*))$/,
-
- // Match a standalone tag
- rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/,
-
- // JSON RegExp
- rvalidchars = /^[\],:{}\s]*$/,
- rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
- rvalidescape = /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,
- rvalidtokens = /"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,
-
- // Matches dashed string for camelizing
- rmsPrefix = /^-ms-/,
- rdashAlpha = /-([\da-z])/gi,
-
- // Used by jQuery.camelCase as callback to replace()
- fcamelCase = function( all, letter ) {
- return letter.toUpperCase();
- },
-
- // The ready event handler
- completed = function( event ) {
-
- // readyState === "complete" is good enough for us to call the dom ready in oldIE
- if ( document.addEventListener || event.type === "load" || document.readyState === "complete" ) {
- detach();
- jQuery.ready();
- }
- },
- // Clean-up method for dom ready events
- detach = function() {
- if ( document.addEventListener ) {
- document.removeEventListener( "DOMContentLoaded", completed, false );
- window.removeEventListener( "load", completed, false );
-
- } else {
- document.detachEvent( "onreadystatechange", completed );
- window.detachEvent( "onload", completed );
- }
- };
-
-jQuery.fn = jQuery.prototype = {
- // The current version of jQuery being used
- jquery: core_version,
-
- constructor: jQuery,
- init: function( selector, context, rootjQuery ) {
- var match, elem;
-
- // HANDLE: $(""), $(null), $(undefined), $(false)
- if ( !selector ) {
- return this;
- }
-
- // Handle HTML strings
- if ( typeof selector === "string" ) {
- if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
- // Assume that strings that start and end with <> are HTML and skip the regex check
- match = [ null, selector, null ];
-
- } else {
- match = rquickExpr.exec( selector );
- }
-
- // Match html or make sure no context is specified for #id
- if ( match && (match[1] || !context) ) {
-
- // HANDLE: $(html) -> $(array)
- if ( match[1] ) {
- context = context instanceof jQuery ? context[0] : context;
-
- // scripts is true for back-compat
- jQuery.merge( this, jQuery.parseHTML(
- match[1],
- context && context.nodeType ? context.ownerDocument || context : document,
- true
- ) );
-
- // HANDLE: $(html, props)
- if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
- for ( match in context ) {
- // Properties of context are called as methods if possible
- if ( jQuery.isFunction( this[ match ] ) ) {
- this[ match ]( context[ match ] );
-
- // ...and otherwise set as attributes
- } else {
- this.attr( match, context[ match ] );
- }
- }
- }
-
- return this;
-
- // HANDLE: $(#id)
- } else {
- elem = document.getElementById( match[2] );
-
- // Check parentNode to catch when Blackberry 4.6 returns
- // nodes that are no longer in the document #6963
- if ( elem && elem.parentNode ) {
- // Handle the case where IE and Opera return items
- // by name instead of ID
- if ( elem.id !== match[2] ) {
- return rootjQuery.find( selector );
- }
-
- // Otherwise, we inject the element directly into the jQuery object
- this.length = 1;
- this[0] = elem;
- }
-
- this.context = document;
- this.selector = selector;
- return this;
- }
-
- // HANDLE: $(expr, $(...))
- } else if ( !context || context.jquery ) {
- return ( context || rootjQuery ).find( selector );
-
- // HANDLE: $(expr, context)
- // (which is just equivalent to: $(context).find(expr)
- } else {
- return this.constructor( context ).find( selector );
- }
-
- // HANDLE: $(DOMElement)
- } else if ( selector.nodeType ) {
- this.context = this[0] = selector;
- this.length = 1;
- return this;
-
- // HANDLE: $(function)
- // Shortcut for document ready
- } else if ( jQuery.isFunction( selector ) ) {
- return rootjQuery.ready( selector );
- }
-
- if ( selector.selector !== undefined ) {
- this.selector = selector.selector;
- this.context = selector.context;
- }
-
- return jQuery.makeArray( selector, this );
- },
-
- // Start with an empty selector
- selector: "",
-
- // The default length of a jQuery object is 0
- length: 0,
-
- // The number of elements contained in the matched element set
- size: function() {
- return this.length;
- },
-
- toArray: function() {
- return core_slice.call( this );
- },
-
- // Get the Nth element in the matched element set OR
- // Get the whole matched element set as a clean array
- get: function( num ) {
- return num == null ?
-
- // Return a 'clean' array
- this.toArray() :
-
- // Return just the object
- ( num < 0 ? this[ this.length + num ] : this[ num ] );
- },
-
- // Take an array of elements and push it onto the stack
- // (returning the new matched element set)
- pushStack: function( elems ) {
-
- // Build a new jQuery matched element set
- var ret = jQuery.merge( this.constructor(), elems );
-
- // Add the old object onto the stack (as a reference)
- ret.prevObject = this;
- ret.context = this.context;
-
- // Return the newly-formed element set
- return ret;
- },
-
- // Execute a callback for every element in the matched set.
- // (You can seed the arguments with an array of args, but this is
- // only used internally.)
- each: function( callback, args ) {
- return jQuery.each( this, callback, args );
- },
-
- ready: function( fn ) {
- // Add the callback
- jQuery.ready.promise().done( fn );
-
- return this;
- },
-
- slice: function() {
- return this.pushStack( core_slice.apply( this, arguments ) );
- },
-
- first: function() {
- return this.eq( 0 );
- },
-
- last: function() {
- return this.eq( -1 );
- },
-
- eq: function( i ) {
- var len = this.length,
- j = +i + ( i < 0 ? len : 0 );
- return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
- },
-
- map: function( callback ) {
- return this.pushStack( jQuery.map(this, function( elem, i ) {
- return callback.call( elem, i, elem );
- }));
- },
-
- end: function() {
- return this.prevObject || this.constructor(null);
- },
-
- // For internal use only.
- // Behaves like an Array's method, not like a jQuery method.
- push: core_push,
- sort: [].sort,
- splice: [].splice
-};
-
-// Give the init function the jQuery prototype for later instantiation
-jQuery.fn.init.prototype = jQuery.fn;
-
-jQuery.extend = jQuery.fn.extend = function() {
- var src, copyIsArray, copy, name, options, clone,
- target = arguments[0] || {},
- i = 1,
- length = arguments.length,
- deep = false;
-
- // Handle a deep copy situation
- if ( typeof target === "boolean" ) {
- deep = target;
- target = arguments[1] || {};
- // skip the boolean and the target
- i = 2;
- }
-
- // Handle case when target is a string or something (possible in deep copy)
- if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
- target = {};
- }
-
- // extend jQuery itself if only one argument is passed
- if ( length === i ) {
- target = this;
- --i;
- }
-
- for ( ; i < length; i++ ) {
- // Only deal with non-null/undefined values
- if ( (options = arguments[ i ]) != null ) {
- // Extend the base object
- for ( name in options ) {
- src = target[ name ];
- copy = options[ name ];
-
- // Prevent never-ending loop
- if ( target === copy ) {
- continue;
- }
-
- // Recurse if we're merging plain objects or arrays
- if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
- if ( copyIsArray ) {
- copyIsArray = false;
- clone = src && jQuery.isArray(src) ? src : [];
-
- } else {
- clone = src && jQuery.isPlainObject(src) ? src : {};
- }
-
- // Never move original objects, clone them
- target[ name ] = jQuery.extend( deep, clone, copy );
-
- // Don't bring in undefined values
- } else if ( copy !== undefined ) {
- target[ name ] = copy;
- }
- }
- }
- }
-
- // Return the modified object
- return target;
-};
-
-jQuery.extend({
- noConflict: function( deep ) {
- if ( window.$ === jQuery ) {
- window.$ = _$;
- }
-
- if ( deep && window.jQuery === jQuery ) {
- window.jQuery = _jQuery;
- }
-
- return jQuery;
- },
-
- // Is the DOM ready to be used? Set to true once it occurs.
- isReady: false,
-
- // A counter to track how many items to wait for before
- // the ready event fires. See #6781
- readyWait: 1,
-
- // Hold (or release) the ready event
- holdReady: function( hold ) {
- if ( hold ) {
- jQuery.readyWait++;
- } else {
- jQuery.ready( true );
- }
- },
-
- // Handle when the DOM is ready
- ready: function( wait ) {
-
- // Abort if there are pending holds or we're already ready
- if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
- return;
- }
-
- // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
- if ( !document.body ) {
- return setTimeout( jQuery.ready );
- }
-
- // Remember that the DOM is ready
- jQuery.isReady = true;
-
- // If a normal DOM Ready event fired, decrement, and wait if need be
- if ( wait !== true && --jQuery.readyWait > 0 ) {
- return;
- }
-
- // If there are functions bound, to execute
- readyList.resolveWith( document, [ jQuery ] );
-
- // Trigger any bound ready events
- if ( jQuery.fn.trigger ) {
- jQuery( document ).trigger("ready").off("ready");
- }
- },
-
- // See test/unit/core.js for details concerning isFunction.
- // Since version 1.3, DOM methods and functions like alert
- // aren't supported. They return false on IE (#2968).
- isFunction: function( obj ) {
- return jQuery.type(obj) === "function";
- },
-
- isArray: Array.isArray || function( obj ) {
- return jQuery.type(obj) === "array";
- },
-
- isWindow: function( obj ) {
- return obj != null && obj == obj.window;
- },
-
- isNumeric: function( obj ) {
- return !isNaN( parseFloat(obj) ) && isFinite( obj );
- },
-
- type: function( obj ) {
- if ( obj == null ) {
- return String( obj );
- }
- return typeof obj === "object" || typeof obj === "function" ?
- class2type[ core_toString.call(obj) ] || "object" :
- typeof obj;
- },
-
- isPlainObject: function( obj ) {
- // Must be an Object.
- // Because of IE, we also have to check the presence of the constructor property.
- // Make sure that DOM nodes and window objects don't pass through, as well
- if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
- return false;
- }
-
- try {
- // Not own constructor property must be Object
- if ( obj.constructor &&
- !core_hasOwn.call(obj, "constructor") &&
- !core_hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
- return false;
- }
- } catch ( e ) {
- // IE8,9 Will throw exceptions on certain host objects #9897
- return false;
- }
-
- // Own properties are enumerated firstly, so to speed up,
- // if last one is own, then all properties are own.
-
- var key;
- for ( key in obj ) {}
-
- return key === undefined || core_hasOwn.call( obj, key );
- },
-
- isEmptyObject: function( obj ) {
- var name;
- for ( name in obj ) {
- return false;
- }
- return true;
- },
-
- error: function( msg ) {
- throw new Error( msg );
- },
-
- // data: string of html
- // context (optional): If specified, the fragment will be created in this context, defaults to document
- // keepScripts (optional): If true, will include scripts passed in the html string
- parseHTML: function( data, context, keepScripts ) {
- if ( !data || typeof data !== "string" ) {
- return null;
- }
- if ( typeof context === "boolean" ) {
- keepScripts = context;
- context = false;
- }
- context = context || document;
-
- var parsed = rsingleTag.exec( data ),
- scripts = !keepScripts && [];
-
- // Single tag
- if ( parsed ) {
- return [ context.createElement( parsed[1] ) ];
- }
-
- parsed = jQuery.buildFragment( [ data ], context, scripts );
- if ( scripts ) {
- jQuery( scripts ).remove();
- }
- return jQuery.merge( [], parsed.childNodes );
- },
-
- parseJSON: function( data ) {
- // Attempt to parse using the native JSON parser first
- if ( window.JSON && window.JSON.parse ) {
- return window.JSON.parse( data );
- }
-
- if ( data === null ) {
- return data;
- }
-
- if ( typeof data === "string" ) {
-
- // Make sure leading/trailing whitespace is removed (IE can't handle it)
- data = jQuery.trim( data );
-
- if ( data ) {
- // Make sure the incoming data is actual JSON
- // Logic borrowed from http://json.org/json2.js
- if ( rvalidchars.test( data.replace( rvalidescape, "@" )
- .replace( rvalidtokens, "]" )
- .replace( rvalidbraces, "")) ) {
-
- return ( new Function( "return " + data ) )();
- }
- }
- }
-
- jQuery.error( "Invalid JSON: " + data );
- },
-
- // Cross-browser xml parsing
- parseXML: function( data ) {
- var xml, tmp;
- if ( !data || typeof data !== "string" ) {
- return null;
- }
- try {
- if ( window.DOMParser ) { // Standard
- tmp = new DOMParser();
- xml = tmp.parseFromString( data , "text/xml" );
- } else { // IE
- xml = new ActiveXObject( "Microsoft.XMLDOM" );
- xml.async = "false";
- xml.loadXML( data );
- }
- } catch( e ) {
- xml = undefined;
- }
- if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
- jQuery.error( "Invalid XML: " + data );
- }
- return xml;
- },
-
- noop: function() {},
-
- // Evaluates a script in a global context
- // Workarounds based on findings by Jim Driscoll
- // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
- globalEval: function( data ) {
- if ( data && jQuery.trim( data ) ) {
- // We use execScript on Internet Explorer
- // We use an anonymous function so that context is window
- // rather than jQuery in Firefox
- ( window.execScript || function( data ) {
- window[ "eval" ].call( window, data );
- } )( data );
- }
- },
-
- // Convert dashed to camelCase; used by the css and data modules
- // Microsoft forgot to hump their vendor prefix (#9572)
- camelCase: function( string ) {
- return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
- },
-
- nodeName: function( elem, name ) {
- return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
- },
-
- // args is for internal usage only
- each: function( obj, callback, args ) {
- var value,
- i = 0,
- length = obj.length,
- isArray = isArraylike( obj );
-
- if ( args ) {
- if ( isArray ) {
- for ( ; i < length; i++ ) {
- value = callback.apply( obj[ i ], args );
-
- if ( value === false ) {
- break;
- }
- }
- } else {
- for ( i in obj ) {
- value = callback.apply( obj[ i ], args );
-
- if ( value === false ) {
- break;
- }
- }
- }
-
- // A special, fast, case for the most common use of each
- } else {
- if ( isArray ) {
- for ( ; i < length; i++ ) {
- value = callback.call( obj[ i ], i, obj[ i ] );
-
- if ( value === false ) {
- break;
- }
- }
- } else {
- for ( i in obj ) {
- value = callback.call( obj[ i ], i, obj[ i ] );
-
- if ( value === false ) {
- break;
- }
- }
- }
- }
-
- return obj;
- },
-
- // Use native String.trim function wherever possible
- trim: core_trim && !core_trim.call("\uFEFF\xA0") ?
- function( text ) {
- return text == null ?
- "" :
- core_trim.call( text );
- } :
-
- // Otherwise use our own trimming functionality
- function( text ) {
- return text == null ?
- "" :
- ( text + "" ).replace( rtrim, "" );
- },
-
- // results is for internal usage only
- makeArray: function( arr, results ) {
- var ret = results || [];
-
- if ( arr != null ) {
- if ( isArraylike( Object(arr) ) ) {
- jQuery.merge( ret,
- typeof arr === "string" ?
- [ arr ] : arr
- );
- } else {
- core_push.call( ret, arr );
- }
- }
-
- return ret;
- },
-
- inArray: function( elem, arr, i ) {
- var len;
-
- if ( arr ) {
- if ( core_indexOf ) {
- return core_indexOf.call( arr, elem, i );
- }
-
- len = arr.length;
- i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
-
- for ( ; i < len; i++ ) {
- // Skip accessing in sparse arrays
- if ( i in arr && arr[ i ] === elem ) {
- return i;
- }
- }
- }
-
- return -1;
- },
-
- merge: function( first, second ) {
- var l = second.length,
- i = first.length,
- j = 0;
-
- if ( typeof l === "number" ) {
- for ( ; j < l; j++ ) {
- first[ i++ ] = second[ j ];
- }
- } else {
- while ( second[j] !== undefined ) {
- first[ i++ ] = second[ j++ ];
- }
- }
-
- first.length = i;
-
- return first;
- },
-
- grep: function( elems, callback, inv ) {
- var retVal,
- ret = [],
- i = 0,
- length = elems.length;
- inv = !!inv;
-
- // Go through the array, only saving the items
- // that pass the validator function
- for ( ; i < length; i++ ) {
- retVal = !!callback( elems[ i ], i );
- if ( inv !== retVal ) {
- ret.push( elems[ i ] );
- }
- }
-
- return ret;
- },
-
- // arg is for internal usage only
- map: function( elems, callback, arg ) {
- var value,
- i = 0,
- length = elems.length,
- isArray = isArraylike( elems ),
- ret = [];
-
- // Go through the array, translating each of the items to their
- if ( isArray ) {
- for ( ; i < length; i++ ) {
- value = callback( elems[ i ], i, arg );
-
- if ( value != null ) {
- ret[ ret.length ] = value;
- }
- }
-
- // Go through every key on the object,
- } else {
- for ( i in elems ) {
- value = callback( elems[ i ], i, arg );
-
- if ( value != null ) {
- ret[ ret.length ] = value;
- }
- }
- }
-
- // Flatten any nested arrays
- return core_concat.apply( [], ret );
- },
-
- // A global GUID counter for objects
- guid: 1,
-
- // Bind a function to a context, optionally partially applying any
- // arguments.
- proxy: function( fn, context ) {
- var args, proxy, tmp;
-
- if ( typeof context === "string" ) {
- tmp = fn[ context ];
- context = fn;
- fn = tmp;
- }
-
- // Quick check to determine if target is callable, in the spec
- // this throws a TypeError, but we will just return undefined.
- if ( !jQuery.isFunction( fn ) ) {
- return undefined;
- }
-
- // Simulated bind
- args = core_slice.call( arguments, 2 );
- proxy = function() {
- return fn.apply( context || this, args.concat( core_slice.call( arguments ) ) );
- };
-
- // Set the guid of unique handler to the same of original handler, so it can be removed
- proxy.guid = fn.guid = fn.guid || jQuery.guid++;
-
- return proxy;
- },
-
- // Multifunctional method to get and set values of a collection
- // The value/s can optionally be executed if it's a function
- access: function( elems, fn, key, value, chainable, emptyGet, raw ) {
- var i = 0,
- length = elems.length,
- bulk = key == null;
-
- // Sets many values
- if ( jQuery.type( key ) === "object" ) {
- chainable = true;
- for ( i in key ) {
- jQuery.access( elems, fn, i, key[i], true, emptyGet, raw );
- }
-
- // Sets one value
- } else if ( value !== undefined ) {
- chainable = true;
-
- if ( !jQuery.isFunction( value ) ) {
- raw = true;
- }
-
- if ( bulk ) {
- // Bulk operations run against the entire set
- if ( raw ) {
- fn.call( elems, value );
- fn = null;
-
- // ...except when executing function values
- } else {
- bulk = fn;
- fn = function( elem, key, value ) {
- return bulk.call( jQuery( elem ), value );
- };
- }
- }
-
- if ( fn ) {
- for ( ; i < length; i++ ) {
- fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) );
- }
- }
- }
-
- return chainable ?
- elems :
-
- // Gets
- bulk ?
- fn.call( elems ) :
- length ? fn( elems[0], key ) : emptyGet;
- },
-
- now: function() {
- return ( new Date() ).getTime();
- }
-});
-
-jQuery.ready.promise = function( obj ) {
- if ( !readyList ) {
-
- readyList = jQuery.Deferred();
-
- // Catch cases where $(document).ready() is called after the browser event has already occurred.
- // we once tried to use readyState "interactive" here, but it caused issues like the one
- // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
- if ( document.readyState === "complete" ) {
- // Handle it asynchronously to allow scripts the opportunity to delay ready
- setTimeout( jQuery.ready );
-
- // Standards-based browsers support DOMContentLoaded
- } else if ( document.addEventListener ) {
- // Use the handy event callback
- document.addEventListener( "DOMContentLoaded", completed, false );
-
- // A fallback to window.onload, that will always work
- window.addEventListener( "load", completed, false );
-
- // If IE event model is used
- } else {
- // Ensure firing before onload, maybe late but safe also for iframes
- document.attachEvent( "onreadystatechange", completed );
-
- // A fallback to window.onload, that will always work
- window.attachEvent( "onload", completed );
-
- // If IE and not a frame
- // continually check to see if the document is ready
- var top = false;
-
- try {
- top = window.frameElement == null && document.documentElement;
- } catch(e) {}
-
- if ( top && top.doScroll ) {
- (function doScrollCheck() {
- if ( !jQuery.isReady ) {
-
- try {
- // Use the trick by Diego Perini
- // http://javascript.nwbox.com/IEContentLoaded/
- top.doScroll("left");
- } catch(e) {
- return setTimeout( doScrollCheck, 50 );
- }
-
- // detach all dom ready events
- detach();
-
- // and execute any waiting functions
- jQuery.ready();
- }
- })();
- }
- }
- }
- return readyList.promise( obj );
-};
-
-// Populate the class2type map
-jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
- class2type[ "[object " + name + "]" ] = name.toLowerCase();
-});
-
-function isArraylike( obj ) {
- var length = obj.length,
- type = jQuery.type( obj );
-
- if ( jQuery.isWindow( obj ) ) {
- return false;
- }
-
- if ( obj.nodeType === 1 && length ) {
- return true;
- }
-
- return type === "array" || type !== "function" &&
- ( length === 0 ||
- typeof length === "number" && length > 0 && ( length - 1 ) in obj );
-}
-
-// All jQuery objects should point back to these
-rootjQuery = jQuery(document);
-// String to Object options format cache
-var optionsCache = {};
-
-// Convert String-formatted options into Object-formatted ones and store in cache
-function createOptions( options ) {
- var object = optionsCache[ options ] = {};
- jQuery.each( options.match( core_rnotwhite ) || [], function( _, flag ) {
- object[ flag ] = true;
- });
- return object;
-}
-
-/*
- * Create a callback list using the following parameters:
- *
- * options: an optional list of space-separated options that will change how
- * the callback list behaves or a more traditional option object
- *
- * By default a callback list will act like an event callback list and can be
- * "fired" multiple times.
- *
- * Possible options:
- *
- * once: will ensure the callback list can only be fired once (like a Deferred)
- *
- * memory: will keep track of previous values and will call any callback added
- * after the list has been fired right away with the latest "memorized"
- * values (like a Deferred)
- *
- * unique: will ensure a callback can only be added once (no duplicate in the list)
- *
- * stopOnFalse: interrupt callings when a callback returns false
- *
- */
-jQuery.Callbacks = function( options ) {
-
- // Convert options from String-formatted to Object-formatted if needed
- // (we check in cache first)
- options = typeof options === "string" ?
- ( optionsCache[ options ] || createOptions( options ) ) :
- jQuery.extend( {}, options );
-
- var // Flag to know if list is currently firing
- firing,
- // Last fire value (for non-forgettable lists)
- memory,
- // Flag to know if list was already fired
- fired,
- // End of the loop when firing
- firingLength,
- // Index of currently firing callback (modified by remove if needed)
- firingIndex,
- // First callback to fire (used internally by add and fireWith)
- firingStart,
- // Actual callback list
- list = [],
- // Stack of fire calls for repeatable lists
- stack = !options.once && [],
- // Fire callbacks
- fire = function( data ) {
- memory = options.memory && data;
- fired = true;
- firingIndex = firingStart || 0;
- firingStart = 0;
- firingLength = list.length;
- firing = true;
- for ( ; list && firingIndex < firingLength; firingIndex++ ) {
- if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
- memory = false; // To prevent further calls using add
- break;
- }
- }
- firing = false;
- if ( list ) {
- if ( stack ) {
- if ( stack.length ) {
- fire( stack.shift() );
- }
- } else if ( memory ) {
- list = [];
- } else {
- self.disable();
- }
- }
- },
- // Actual Callbacks object
- self = {
- // Add a callback or a collection of callbacks to the list
- add: function() {
- if ( list ) {
- // First, we save the current length
- var start = list.length;
- (function add( args ) {
- jQuery.each( args, function( _, arg ) {
- var type = jQuery.type( arg );
- if ( type === "function" ) {
- if ( !options.unique || !self.has( arg ) ) {
- list.push( arg );
- }
- } else if ( arg && arg.length && type !== "string" ) {
- // Inspect recursively
- add( arg );
- }
- });
- })( arguments );
- // Do we need to add the callbacks to the
- // current firing batch?
- if ( firing ) {
- firingLength = list.length;
- // With memory, if we're not firing then
- // we should call right away
- } else if ( memory ) {
- firingStart = start;
- fire( memory );
- }
- }
- return this;
- },
- // Remove a callback from the list
- remove: function() {
- if ( list ) {
- jQuery.each( arguments, function( _, arg ) {
- var index;
- while( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
- list.splice( index, 1 );
- // Handle firing indexes
- if ( firing ) {
- if ( index <= firingLength ) {
- firingLength--;
- }
- if ( index <= firingIndex ) {
- firingIndex--;
- }
- }
- }
- });
- }
- return this;
- },
- // Check if a given callback is in the list.
- // If no argument is given, return whether or not list has callbacks attached.
- has: function( fn ) {
- return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length );
- },
- // Remove all callbacks from the list
- empty: function() {
- list = [];
- return this;
- },
- // Have the list do nothing anymore
- disable: function() {
- list = stack = memory = undefined;
- return this;
- },
- // Is it disabled?
- disabled: function() {
- return !list;
- },
- // Lock the list in its current state
- lock: function() {
- stack = undefined;
- if ( !memory ) {
- self.disable();
- }
- return this;
- },
- // Is it locked?
- locked: function() {
- return !stack;
- },
- // Call all callbacks with the given context and arguments
- fireWith: function( context, args ) {
- args = args || [];
- args = [ context, args.slice ? args.slice() : args ];
- if ( list && ( !fired || stack ) ) {
- if ( firing ) {
- stack.push( args );
- } else {
- fire( args );
- }
- }
- return this;
- },
- // Call all the callbacks with the given arguments
- fire: function() {
- self.fireWith( this, arguments );
- return this;
- },
- // To know if the callbacks have already been called at least once
- fired: function() {
- return !!fired;
- }
- };
-
- return self;
-};
-jQuery.extend({
-
- Deferred: function( func ) {
- var tuples = [
- // action, add listener, listener list, final state
- [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
- [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
- [ "notify", "progress", jQuery.Callbacks("memory") ]
- ],
- state = "pending",
- promise = {
- state: function() {
- return state;
- },
- always: function() {
- deferred.done( arguments ).fail( arguments );
- return this;
- },
- then: function( /* fnDone, fnFail, fnProgress */ ) {
- var fns = arguments;
- return jQuery.Deferred(function( newDefer ) {
- jQuery.each( tuples, function( i, tuple ) {
- var action = tuple[ 0 ],
- fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
- // deferred[ done | fail | progress ] for forwarding actions to newDefer
- deferred[ tuple[1] ](function() {
- var returned = fn && fn.apply( this, arguments );
- if ( returned && jQuery.isFunction( returned.promise ) ) {
- returned.promise()
- .done( newDefer.resolve )
- .fail( newDefer.reject )
- .progress( newDefer.notify );
- } else {
- newDefer[ action + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
- }
- });
- });
- fns = null;
- }).promise();
- },
- // Get a promise for this deferred
- // If obj is provided, the promise aspect is added to the object
- promise: function( obj ) {
- return obj != null ? jQuery.extend( obj, promise ) : promise;
- }
- },
- deferred = {};
-
- // Keep pipe for back-compat
- promise.pipe = promise.then;
-
- // Add list-specific methods
- jQuery.each( tuples, function( i, tuple ) {
- var list = tuple[ 2 ],
- stateString = tuple[ 3 ];
-
- // promise[ done | fail | progress ] = list.add
- promise[ tuple[1] ] = list.add;
-
- // Handle state
- if ( stateString ) {
- list.add(function() {
- // state = [ resolved | rejected ]
- state = stateString;
-
- // [ reject_list | resolve_list ].disable; progress_list.lock
- }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
- }
-
- // deferred[ resolve | reject | notify ]
- deferred[ tuple[0] ] = function() {
- deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments );
- return this;
- };
- deferred[ tuple[0] + "With" ] = list.fireWith;
- });
-
- // Make the deferred a promise
- promise.promise( deferred );
-
- // Call given func if any
- if ( func ) {
- func.call( deferred, deferred );
- }
-
- // All done!
- return deferred;
- },
-
- // Deferred helper
- when: function( subordinate /* , ..., subordinateN */ ) {
- var i = 0,
- resolveValues = core_slice.call( arguments ),
- length = resolveValues.length,
-
- // the count of uncompleted subordinates
- remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
-
- // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
- deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
-
- // Update function for both resolve and progress values
- updateFunc = function( i, contexts, values ) {
- return function( value ) {
- contexts[ i ] = this;
- values[ i ] = arguments.length > 1 ? core_slice.call( arguments ) : value;
- if( values === progressValues ) {
- deferred.notifyWith( contexts, values );
- } else if ( !( --remaining ) ) {
- deferred.resolveWith( contexts, values );
- }
- };
- },
-
- progressValues, progressContexts, resolveContexts;
-
- // add listeners to Deferred subordinates; treat others as resolved
- if ( length > 1 ) {
- progressValues = new Array( length );
- progressContexts = new Array( length );
- resolveContexts = new Array( length );
- for ( ; i < length; i++ ) {
- if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
- resolveValues[ i ].promise()
- .done( updateFunc( i, resolveContexts, resolveValues ) )
- .fail( deferred.reject )
- .progress( updateFunc( i, progressContexts, progressValues ) );
- } else {
- --remaining;
- }
- }
- }
-
- // if we're not waiting on anything, resolve the master
- if ( !remaining ) {
- deferred.resolveWith( resolveContexts, resolveValues );
- }
-
- return deferred.promise();
- }
-});
-jQuery.support = (function() {
-
- var support, all, a,
- input, select, fragment,
- opt, eventName, isSupported, i,
- div = document.createElement("div");
-
- // Setup
- div.setAttribute( "className", "t" );
- div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
-
- // Support tests won't run in some limited or non-browser environments
- all = div.getElementsByTagName("*");
- a = div.getElementsByTagName("a")[ 0 ];
- if ( !all || !a || !all.length ) {
- return {};
- }
-
- // First batch of tests
- select = document.createElement("select");
- opt = select.appendChild( document.createElement("option") );
- input = div.getElementsByTagName("input")[ 0 ];
-
- a.style.cssText = "top:1px;float:left;opacity:.5";
- support = {
- // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
- getSetAttribute: div.className !== "t",
-
- // IE strips leading whitespace when .innerHTML is used
- leadingWhitespace: div.firstChild.nodeType === 3,
-
- // Make sure that tbody elements aren't automatically inserted
- // IE will insert them into empty tables
- tbody: !div.getElementsByTagName("tbody").length,
-
- // Make sure that link elements get serialized correctly by innerHTML
- // This requires a wrapper element in IE
- htmlSerialize: !!div.getElementsByTagName("link").length,
-
- // Get the style information from getAttribute
- // (IE uses .cssText instead)
- style: /top/.test( a.getAttribute("style") ),
-
- // Make sure that URLs aren't manipulated
- // (IE normalizes it by default)
- hrefNormalized: a.getAttribute("href") === "/a",
-
- // Make sure that element opacity exists
- // (IE uses filter instead)
- // Use a regex to work around a WebKit issue. See #5145
- opacity: /^0.5/.test( a.style.opacity ),
-
- // Verify style float existence
- // (IE uses styleFloat instead of cssFloat)
- cssFloat: !!a.style.cssFloat,
-
- // Check the default checkbox/radio value ("" on WebKit; "on" elsewhere)
- checkOn: !!input.value,
-
- // Make sure that a selected-by-default option has a working selected property.
- // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
- optSelected: opt.selected,
-
- // Tests for enctype support on a form (#6743)
- enctype: !!document.createElement("form").enctype,
-
- // Makes sure cloning an html5 element does not cause problems
- // Where outerHTML is undefined, this still works
- html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav></:nav>",
-
- // jQuery.support.boxModel DEPRECATED in 1.8 since we don't support Quirks Mode
- boxModel: document.compatMode === "CSS1Compat",
-
- // Will be defined later
- deleteExpando: true,
- noCloneEvent: true,
- inlineBlockNeedsLayout: false,
- shrinkWrapBlocks: false,
- reliableMarginRight: true,
- boxSizingReliable: true,
- pixelPosition: false
- };
-
- // Make sure checked status is properly cloned
- input.checked = true;
- support.noCloneChecked = input.cloneNode( true ).checked;
-
- // Make sure that the options inside disabled selects aren't marked as disabled
- // (WebKit marks them as disabled)
- select.disabled = true;
- support.optDisabled = !opt.disabled;
-
- // Support: IE<9
- try {
- delete div.test;
- } catch( e ) {
- support.deleteExpando = false;
- }
-
- // Check if we can trust getAttribute("value")
- input = document.createElement("input");
- input.setAttribute( "value", "" );
- support.input = input.getAttribute( "value" ) === "";
-
- // Check if an input maintains its value after becoming a radio
- input.value = "t";
- input.setAttribute( "type", "radio" );
- support.radioValue = input.value === "t";
-
- // #11217 - WebKit loses check when the name is after the checked attribute
- input.setAttribute( "checked", "t" );
- input.setAttribute( "name", "t" );
-
- fragment = document.createDocumentFragment();
- fragment.appendChild( input );
-
- // Check if a disconnected checkbox will retain its checked
- // value of true after appended to the DOM (IE6/7)
- support.appendChecked = input.checked;
-
- // WebKit doesn't clone checked state correctly in fragments
- support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
-
- // Support: IE<9
- // Opera does not clone events (and typeof div.attachEvent === undefined).
- // IE9-10 clones events bound via attachEvent, but they don't trigger with .click()
- if ( div.attachEvent ) {
- div.attachEvent( "onclick", function() {
- support.noCloneEvent = false;
- });
-
- div.cloneNode( true ).click();
- }
-
- // Support: IE<9 (lack submit/change bubble), Firefox 17+ (lack focusin event)
- // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP), test/csp.php
- for ( i in { submit: true, change: true, focusin: true }) {
- div.setAttribute( eventName = "on" + i, "t" );
-
- support[ i + "Bubbles" ] = eventName in window || div.attributes[ eventName ].expando === false;
- }
-
- div.style.backgroundClip = "content-box";
- div.cloneNode( true ).style.backgroundClip = "";
- support.clearCloneStyle = div.style.backgroundClip === "content-box";
-
- // Run tests that need a body at doc ready
- jQuery(function() {
- var container, marginDiv, tds,
- divReset = "padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",
- body = document.getElementsByTagName("body")[0];
-
- if ( !body ) {
- // Return for frameset docs that don't have a body
- return;
- }
-
- container = document.createElement("div");
- container.style.cssText = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px";
-
- body.appendChild( container ).appendChild( div );
-
- // Support: IE8
- // Check if table cells still have offsetWidth/Height when they are set
- // to display:none and there are still other visible table cells in a
- // table row; if so, offsetWidth/Height are not reliable for use when
- // determining if an element has been hidden directly using
- // display:none (it is still safe to use offsets if a parent element is
- // hidden; don safety goggles and see bug #4512 for more information).
- div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
- tds = div.getElementsByTagName("td");
- tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none";
- isSupported = ( tds[ 0 ].offsetHeight === 0 );
-
- tds[ 0 ].style.display = "";
- tds[ 1 ].style.display = "none";
-
- // Support: IE8
- // Check if empty table cells still have offsetWidth/Height
- support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
-
- // Check box-sizing and margin behavior
- div.innerHTML = "";
- div.style.cssText = "box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;";
- support.boxSizing = ( div.offsetWidth === 4 );
- support.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== 1 );
-
- // Use window.getComputedStyle because jsdom on node.js will break without it.
- if ( window.getComputedStyle ) {
- support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%";
- support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px";
-
- // Check if div with explicit width and no margin-right incorrectly
- // gets computed margin-right based on width of container. (#3333)
- // Fails in WebKit before Feb 2011 nightlies
- // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
- marginDiv = div.appendChild( document.createElement("div") );
- marginDiv.style.cssText = div.style.cssText = divReset;
- marginDiv.style.marginRight = marginDiv.style.width = "0";
- div.style.width = "1px";
-
- support.reliableMarginRight =
- !parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight );
- }
-
- if ( typeof div.style.zoom !== core_strundefined ) {
- // Support: IE<8
- // Check if natively block-level elements act like inline-block
- // elements when setting their display to 'inline' and giving
- // them layout
- div.innerHTML = "";
- div.style.cssText = divReset + "width:1px;padding:1px;display:inline;zoom:1";
- support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 );
-
- // Support: IE6
- // Check if elements with layout shrink-wrap their children
- div.style.display = "block";
- div.innerHTML = "<div></div>";
- div.firstChild.style.width = "5px";
- support.shrinkWrapBlocks = ( div.offsetWidth !== 3 );
-
- if ( support.inlineBlockNeedsLayout ) {
- // Prevent IE 6 from affecting layout for positioned elements #11048
- // Prevent IE from shrinking the body in IE 7 mode #12869
- // Support: IE<8
- body.style.zoom = 1;
- }
- }
-
- body.removeChild( container );
-
- // Null elements to avoid leaks in IE
- container = div = tds = marginDiv = null;
- });
-
- // Null elements to avoid leaks in IE
- all = select = fragment = opt = a = input = null;
-
- return support;
-})();
-
-var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/,
- rmultiDash = /([A-Z])/g;
-
-function internalData( elem, name, data, pvt /* Internal Use Only */ ){
- if ( !jQuery.acceptData( elem ) ) {
- return;
- }
-
- var thisCache, ret,
- internalKey = jQuery.expando,
- getByName = typeof name === "string",
-
- // We have to handle DOM nodes and JS objects differently because IE6-7
- // can't GC object references properly across the DOM-JS boundary
- isNode = elem.nodeType,
-
- // Only DOM nodes need the global jQuery cache; JS object data is
- // attached directly to the object so GC can occur automatically
- cache = isNode ? jQuery.cache : elem,
-
- // Only defining an ID for JS objects if its cache already exists allows
- // the code to shortcut on the same path as a DOM node with no cache
- id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey;
-
- // Avoid doing any more work than we need to when trying to get data on an
- // object that has no data at all
- if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && getByName && data === undefined ) {
- return;
- }
-
- if ( !id ) {
- // Only DOM nodes need a new unique ID for each element since their data
- // ends up in the global cache
- if ( isNode ) {
- elem[ internalKey ] = id = core_deletedIds.pop() || jQuery.guid++;
- } else {
- id = internalKey;
- }
- }
-
- if ( !cache[ id ] ) {
- cache[ id ] = {};
-
- // Avoids exposing jQuery metadata on plain JS objects when the object
- // is serialized using JSON.stringify
- if ( !isNode ) {
- cache[ id ].toJSON = jQuery.noop;
- }
- }
-
- // An object can be passed to jQuery.data instead of a key/value pair; this gets
- // shallow copied over onto the existing cache
- if ( typeof name === "object" || typeof name === "function" ) {
- if ( pvt ) {
- cache[ id ] = jQuery.extend( cache[ id ], name );
- } else {
- cache[ id ].data = jQuery.extend( cache[ id ].data, name );
- }
- }
-
- thisCache = cache[ id ];
-
- // jQuery data() is stored in a separate object inside the object's internal data
- // cache in order to avoid key collisions between internal data and user-defined
- // data.
- if ( !pvt ) {
- if ( !thisCache.data ) {
- thisCache.data = {};
- }
-
- thisCache = thisCache.data;
- }
-
- if ( data !== undefined ) {
- thisCache[ jQuery.camelCase( name ) ] = data;
- }
-
- // Check for both converted-to-camel and non-converted data property names
- // If a data property was specified
- if ( getByName ) {
-
- // First Try to find as-is property data
- ret = thisCache[ name ];
-
- // Test for null|undefined property data
- if ( ret == null ) {
-
- // Try to find the camelCased property
- ret = thisCache[ jQuery.camelCase( name ) ];
- }
- } else {
- ret = thisCache;
- }
-
- return ret;
-}
-
-function internalRemoveData( elem, name, pvt ) {
- if ( !jQuery.acceptData( elem ) ) {
- return;
- }
-
- var i, l, thisCache,
- isNode = elem.nodeType,
-
- // See jQuery.data for more information
- cache = isNode ? jQuery.cache : elem,
- id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
-
- // If there is already no cache entry for this object, there is no
- // purpose in continuing
- if ( !cache[ id ] ) {
- return;
- }
-
- if ( name ) {
-
- thisCache = pvt ? cache[ id ] : cache[ id ].data;
-
- if ( thisCache ) {
-
- // Support array or space separated string names for data keys
- if ( !jQuery.isArray( name ) ) {
-
- // try the string as a key before any manipulation
- if ( name in thisCache ) {
- name = [ name ];
- } else {
-
- // split the camel cased version by spaces unless a key with the spaces exists
- name = jQuery.camelCase( name );
- if ( name in thisCache ) {
- name = [ name ];
- } else {
- name = name.split(" ");
- }
- }
- } else {
- // If "name" is an array of keys...
- // When data is initially created, via ("key", "val") signature,
- // keys will be converted to camelCase.
- // Since there is no way to tell _how_ a key was added, remove
- // both plain key and camelCase key. #12786
- // This will only penalize the array argument path.
- name = name.concat( jQuery.map( name, jQuery.camelCase ) );
- }
-
- for ( i = 0, l = name.length; i < l; i++ ) {
- delete thisCache[ name[i] ];
- }
-
- // If there is no data left in the cache, we want to continue
- // and let the cache object itself get destroyed
- if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) {
- return;
- }
- }
- }
-
- // See jQuery.data for more information
- if ( !pvt ) {
- delete cache[ id ].data;
-
- // Don't destroy the parent cache unless the internal data object
- // had been the only thing left in it
- if ( !isEmptyDataObject( cache[ id ] ) ) {
- return;
- }
- }
-
- // Destroy the cache
- if ( isNode ) {
- jQuery.cleanData( [ elem ], true );
-
- // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080)
- } else if ( jQuery.support.deleteExpando || cache != cache.window ) {
- delete cache[ id ];
-
- // When all else fails, null
- } else {
- cache[ id ] = null;
- }
-}
-
-jQuery.extend({
- cache: {},
-
- // Unique for each copy of jQuery on the page
- // Non-digits removed to match rinlinejQuery
- expando: "jQuery" + ( core_version + Math.random() ).replace( /\D/g, "" ),
-
- // The following elements throw uncatchable exceptions if you
- // attempt to add expando properties to them.
- noData: {
- "embed": true,
- // Ban all objects except for Flash (which handle expandos)
- "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
- "applet": true
- },
-
- hasData: function( elem ) {
- elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
- return !!elem && !isEmptyDataObject( elem );
- },
-
- data: function( elem, name, data ) {
- return internalData( elem, name, data );
- },
-
- removeData: function( elem, name ) {
- return internalRemoveData( elem, name );
- },
-
- // For internal use only.
- _data: function( elem, name, data ) {
- return internalData( elem, name, data, true );
- },
-
- _removeData: function( elem, name ) {
- return internalRemoveData( elem, name, true );
- },
-
- // A method for determining if a DOM node can handle the data expando
- acceptData: function( elem ) {
- // Do not set data on non-element because it will not be cleared (#8335).
- if ( elem.nodeType && elem.nodeType !== 1 && elem.nodeType !== 9 ) {
- return false;
- }
-
- var noData = elem.nodeName && jQuery.noData[ elem.nodeName.toLowerCase() ];
-
- // nodes accept data unless otherwise specified; rejection can be conditional
- return !noData || noData !== true && elem.getAttribute("classid") === noData;
- }
-});
-
-jQuery.fn.extend({
- data: function( key, value ) {
- var attrs, name,
- elem = this[0],
- i = 0,
- data = null;
-
- // Gets all values
- if ( key === undefined ) {
- if ( this.length ) {
- data = jQuery.data( elem );
-
- if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
- attrs = elem.attributes;
- for ( ; i < attrs.length; i++ ) {
- name = attrs[i].name;
-
- if ( !name.indexOf( "data-" ) ) {
- name = jQuery.camelCase( name.slice(5) );
-
- dataAttr( elem, name, data[ name ] );
- }
- }
- jQuery._data( elem, "parsedAttrs", true );
- }
- }
-
- return data;
- }
-
- // Sets multiple values
- if ( typeof key === "object" ) {
- return this.each(function() {
- jQuery.data( this, key );
- });
- }
-
- return jQuery.access( this, function( value ) {
-
- if ( value === undefined ) {
- // Try to fetch any internally stored data first
- return elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : null;
- }
-
- this.each(function() {
- jQuery.data( this, key, value );
- });
- }, null, value, arguments.length > 1, null, true );
- },
-
- removeData: function( key ) {
- return this.each(function() {
- jQuery.removeData( this, key );
- });
- }
-});
-
-function dataAttr( elem, key, data ) {
- // If nothing was found internally, try to fetch any
- // data from the HTML5 data-* attribute
- if ( data === undefined && elem.nodeType === 1 ) {
-
- var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
-
- data = elem.getAttribute( name );
-
- if ( typeof data === "string" ) {
- try {
- data = data === "true" ? true :
- data === "false" ? false :
- data === "null" ? null :
- // Only convert to a number if it doesn't change the string
- +data + "" === data ? +data :
- rbrace.test( data ) ? jQuery.parseJSON( data ) :
- data;
- } catch( e ) {}
-
- // Make sure we set the data so it isn't changed later
- jQuery.data( elem, key, data );
-
- } else {
- data = undefined;
- }
- }
-
- return data;
-}
-
-// checks a cache object for emptiness
-function isEmptyDataObject( obj ) {
- var name;
- for ( name in obj ) {
-
- // if the public data object is empty, the private is still empty
- if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
- continue;
- }
- if ( name !== "toJSON" ) {
- return false;
- }
- }
-
- return true;
-}
-jQuery.extend({
- queue: function( elem, type, data ) {
- var queue;
-
- if ( elem ) {
- type = ( type || "fx" ) + "queue";
- queue = jQuery._data( elem, type );
-
- // Speed up dequeue by getting out quickly if this is just a lookup
- if ( data ) {
- if ( !queue || jQuery.isArray(data) ) {
- queue = jQuery._data( elem, type, jQuery.makeArray(data) );
- } else {
- queue.push( data );
- }
- }
- return queue || [];
- }
- },
-
- dequeue: function( elem, type ) {
- type = type || "fx";
-
- var queue = jQuery.queue( elem, type ),
- startLength = queue.length,
- fn = queue.shift(),
- hooks = jQuery._queueHooks( elem, type ),
- next = function() {
- jQuery.dequeue( elem, type );
- };
-
- // If the fx queue is dequeued, always remove the progress sentinel
- if ( fn === "inprogress" ) {
- fn = queue.shift();
- startLength--;
- }
-
- hooks.cur = fn;
- if ( fn ) {
-
- // Add a progress sentinel to prevent the fx queue from being
- // automatically dequeued
- if ( type === "fx" ) {
- queue.unshift( "inprogress" );
- }
-
- // clear up the last queue stop function
- delete hooks.stop;
- fn.call( elem, next, hooks );
- }
-
- if ( !startLength && hooks ) {
- hooks.empty.fire();
- }
- },
-
- // not intended for public consumption - generates a queueHooks object, or returns the current one
- _queueHooks: function( elem, type ) {
- var key = type + "queueHooks";
- return jQuery._data( elem, key ) || jQuery._data( elem, key, {
- empty: jQuery.Callbacks("once memory").add(function() {
- jQuery._removeData( elem, type + "queue" );
- jQuery._removeData( elem, key );
- })
- });
- }
-});
-
-jQuery.fn.extend({
- queue: function( type, data ) {
- var setter = 2;
-
- if ( typeof type !== "string" ) {
- data = type;
- type = "fx";
- setter--;
- }
-
- if ( arguments.length < setter ) {
- return jQuery.queue( this[0], type );
- }
-
- return data === undefined ?
- this :
- this.each(function() {
- var queue = jQuery.queue( this, type, data );
-
- // ensure a hooks for this queue
- jQuery._queueHooks( this, type );
-
- if ( type === "fx" && queue[0] !== "inprogress" ) {
- jQuery.dequeue( this, type );
- }
- });
- },
- dequeue: function( type ) {
- return this.each(function() {
- jQuery.dequeue( this, type );
- });
- },
- // Based off of the plugin by Clint Helfers, with permission.
- // http://blindsignals.com/index.php/2009/07/jquery-delay/
- delay: function( time, type ) {
- time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
- type = type || "fx";
-
- return this.queue( type, function( next, hooks ) {
- var timeout = setTimeout( next, time );
- hooks.stop = function() {
- clearTimeout( timeout );
- };
- });
- },
- clearQueue: function( type ) {
- return this.queue( type || "fx", [] );
- },
- // Get a promise resolved when queues of a certain type
- // are emptied (fx is the type by default)
- promise: function( type, obj ) {
- var tmp,
- count = 1,
- defer = jQuery.Deferred(),
- elements = this,
- i = this.length,
- resolve = function() {
- if ( !( --count ) ) {
- defer.resolveWith( elements, [ elements ] );
- }
- };
-
- if ( typeof type !== "string" ) {
- obj = type;
- type = undefined;
- }
- type = type || "fx";
-
- while( i-- ) {
- tmp = jQuery._data( elements[ i ], type + "queueHooks" );
- if ( tmp && tmp.empty ) {
- count++;
- tmp.empty.add( resolve );
- }
- }
- resolve();
- return defer.promise( obj );
- }
-});
-var nodeHook, boolHook,
- rclass = /[\t\r\n]/g,
- rreturn = /\r/g,
- rfocusable = /^(?:input|select|textarea|button|object)$/i,
- rclickable = /^(?:a|area)$/i,
- rboolean = /^(?:checked|selected|autofocus|autoplay|async|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped)$/i,
- ruseDefault = /^(?:checked|selected)$/i,
- getSetAttribute = jQuery.support.getSetAttribute,
- getSetInput = jQuery.support.input;
-
-jQuery.fn.extend({
- attr: function( name, value ) {
- return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 );
- },
-
- removeAttr: function( name ) {
- return this.each(function() {
- jQuery.removeAttr( this, name );
- });
- },
-
- prop: function( name, value ) {
- return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 );
- },
-
- removeProp: function( name ) {
- name = jQuery.propFix[ name ] || name;
- return this.each(function() {
- // try/catch handles cases where IE balks (such as removing a property on window)
- try {
- this[ name ] = undefined;
- delete this[ name ];
- } catch( e ) {}
- });
- },
-
- addClass: function( value ) {
- var classes, elem, cur, clazz, j,
- i = 0,
- len = this.length,
- proceed = typeof value === "string" && value;
-
- if ( jQuery.isFunction( value ) ) {
- return this.each(function( j ) {
- jQuery( this ).addClass( value.call( this, j, this.className ) );
- });
- }
-
- if ( proceed ) {
- // The disjunction here is for better compressibility (see removeClass)
- classes = ( value || "" ).match( core_rnotwhite ) || [];
-
- for ( ; i < len; i++ ) {
- elem = this[ i ];
- cur = elem.nodeType === 1 && ( elem.className ?
- ( " " + elem.className + " " ).replace( rclass, " " ) :
- " "
- );
-
- if ( cur ) {
- j = 0;
- while ( (clazz = classes[j++]) ) {
- if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
- cur += clazz + " ";
- }
- }
- elem.className = jQuery.trim( cur );
-
- }
- }
- }
-
- return this;
- },
-
- removeClass: function( value ) {
- var classes, elem, cur, clazz, j,
- i = 0,
- len = this.length,
- proceed = arguments.length === 0 || typeof value === "string" && value;
-
- if ( jQuery.isFunction( value ) ) {
- return this.each(function( j ) {
- jQuery( this ).removeClass( value.call( this, j, this.className ) );
- });
- }
- if ( proceed ) {
- classes = ( value || "" ).match( core_rnotwhite ) || [];
-
- for ( ; i < len; i++ ) {
- elem = this[ i ];
- // This expression is here for better compressibility (see addClass)
- cur = elem.nodeType === 1 && ( elem.className ?
- ( " " + elem.className + " " ).replace( rclass, " " ) :
- ""
- );
-
- if ( cur ) {
- j = 0;
- while ( (clazz = classes[j++]) ) {
- // Remove *all* instances
- while ( cur.indexOf( " " + clazz + " " ) >= 0 ) {
- cur = cur.replace( " " + clazz + " ", " " );
- }
- }
- elem.className = value ? jQuery.trim( cur ) : "";
- }
- }
- }
-
- return this;
- },
-
- toggleClass: function( value, stateVal ) {
- var type = typeof value,
- isBool = typeof stateVal === "boolean";
-
- if ( jQuery.isFunction( value ) ) {
- return this.each(function( i ) {
- jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
- });
- }
-
- return this.each(function() {
- if ( type === "string" ) {
- // toggle individual class names
- var className,
- i = 0,
- self = jQuery( this ),
- state = stateVal,
- classNames = value.match( core_rnotwhite ) || [];
-
- while ( (className = classNames[ i++ ]) ) {
- // check each className given, space separated list
- state = isBool ? state : !self.hasClass( className );
- self[ state ? "addClass" : "removeClass" ]( className );
- }
-
- // Toggle whole class name
- } else if ( type === core_strundefined || type === "boolean" ) {
- if ( this.className ) {
- // store className if set
- jQuery._data( this, "__className__", this.className );
- }
-
- // If the element has a class name or if we're passed "false",
- // then remove the whole classname (if there was one, the above saved it).
- // Otherwise bring back whatever was previously saved (if anything),
- // falling back to the empty string if nothing was stored.
- this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
- }
- });
- },
-
- hasClass: function( selector ) {
- var className = " " + selector + " ",
- i = 0,
- l = this.length;
- for ( ; i < l; i++ ) {
- if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
- return true;
- }
- }
-
- return false;
- },
-
- val: function( value ) {
- var ret, hooks, isFunction,
- elem = this[0];
-
- if ( !arguments.length ) {
- if ( elem ) {
- hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
-
- if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
- return ret;
- }
-
- ret = elem.value;
-
- return typeof ret === "string" ?
- // handle most common string cases
- ret.replace(rreturn, "") :
- // handle cases where value is null/undef or number
- ret == null ? "" : ret;
- }
-
- return;
- }
-
- isFunction = jQuery.isFunction( value );
-
- return this.each(function( i ) {
- var val,
- self = jQuery(this);
-
- if ( this.nodeType !== 1 ) {
- return;
- }
-
- if ( isFunction ) {
- val = value.call( this, i, self.val() );
- } else {
- val = value;
- }
-
- // Treat null/undefined as ""; convert numbers to string
- if ( val == null ) {
- val = "";
- } else if ( typeof val === "number" ) {
- val += "";
- } else if ( jQuery.isArray( val ) ) {
- val = jQuery.map(val, function ( value ) {
- return value == null ? "" : value + "";
- });
- }
-
- hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
-
- // If set returns undefined, fall back to normal setting
- if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
- this.value = val;
- }
- });
- }
-});
-
-jQuery.extend({
- valHooks: {
- option: {
- get: function( elem ) {
- // attributes.value is undefined in Blackberry 4.7 but
- // uses .value. See #6932
- var val = elem.attributes.value;
- return !val || val.specified ? elem.value : elem.text;
- }
- },
- select: {
- get: function( elem ) {
- var value, option,
- options = elem.options,
- index = elem.selectedIndex,
- one = elem.type === "select-one" || index < 0,
- values = one ? null : [],
- max = one ? index + 1 : options.length,
- i = index < 0 ?
- max :
- one ? index : 0;
-
- // Loop through all the selected options
- for ( ; i < max; i++ ) {
- option = options[ i ];
-
- // oldIE doesn't update selected after form reset (#2551)
- if ( ( option.selected || i === index ) &&
- // Don't return options that are disabled or in a disabled optgroup
- ( jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) &&
- ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
-
- // Get the specific value for the option
- value = jQuery( option ).val();
-
- // We don't need an array for one selects
- if ( one ) {
- return value;
- }
-
- // Multi-Selects return an array
- values.push( value );
- }
- }
-
- return values;
- },
-
- set: function( elem, value ) {
- var values = jQuery.makeArray( value );
-
- jQuery(elem).find("option").each(function() {
- this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
- });
-
- if ( !values.length ) {
- elem.selectedIndex = -1;
- }
- return values;
- }
- }
- },
-
- attr: function( elem, name, value ) {
- var hooks, notxml, ret,
- nType = elem.nodeType;
-
- // don't get/set attributes on text, comment and attribute nodes
- if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
- return;
- }
-
- // Fallback to prop when attributes are not supported
- if ( typeof elem.getAttribute === core_strundefined ) {
- return jQuery.prop( elem, name, value );
- }
-
- notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
-
- // All attributes are lowercase
- // Grab necessary hook if one is defined
- if ( notxml ) {
- name = name.toLowerCase();
- hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook );
- }
-
- if ( value !== undefined ) {
-
- if ( value === null ) {
- jQuery.removeAttr( elem, name );
-
- } else if ( hooks && notxml && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
- return ret;
-
- } else {
- elem.setAttribute( name, value + "" );
- return value;
- }
-
- } else if ( hooks && notxml && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
- return ret;
-
- } else {
-
- // In IE9+, Flash objects don't have .getAttribute (#12945)
- // Support: IE9+
- if ( typeof elem.getAttribute !== core_strundefined ) {
- ret = elem.getAttribute( name );
- }
-
- // Non-existent attributes return null, we normalize to undefined
- return ret == null ?
- undefined :
- ret;
- }
- },
-
- removeAttr: function( elem, value ) {
- var name, propName,
- i = 0,
- attrNames = value && value.match( core_rnotwhite );
-
- if ( attrNames && elem.nodeType === 1 ) {
- while ( (name = attrNames[i++]) ) {
- propName = jQuery.propFix[ name ] || name;
-
- // Boolean attributes get special treatment (#10870)
- if ( rboolean.test( name ) ) {
- // Set corresponding property to false for boolean attributes
- // Also clear defaultChecked/defaultSelected (if appropriate) for IE<8
- if ( !getSetAttribute && ruseDefault.test( name ) ) {
- elem[ jQuery.camelCase( "default-" + name ) ] =
- elem[ propName ] = false;
- } else {
- elem[ propName ] = false;
- }
-
- // See #9699 for explanation of this approach (setting first, then removal)
- } else {
- jQuery.attr( elem, name, "" );
- }
-
- elem.removeAttribute( getSetAttribute ? name : propName );
- }
- }
- },
-
- attrHooks: {
- type: {
- set: function( elem, value ) {
- if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
- // Setting the type on a radio button after the value resets the value in IE6-9
- // Reset value to default in case type is set after value during creation
- var val = elem.value;
- elem.setAttribute( "type", value );
- if ( val ) {
- elem.value = val;
- }
- return value;
- }
- }
- }
- },
-
- propFix: {
- tabindex: "tabIndex",
- readonly: "readOnly",
- "for": "htmlFor",
- "class": "className",
- maxlength: "maxLength",
- cellspacing: "cellSpacing",
- cellpadding: "cellPadding",
- rowspan: "rowSpan",
- colspan: "colSpan",
- usemap: "useMap",
- frameborder: "frameBorder",
- contenteditable: "contentEditable"
- },
-
- prop: function( elem, name, value ) {
- var ret, hooks, notxml,
- nType = elem.nodeType;
-
- // don't get/set properties on text, comment and attribute nodes
- if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
- return;
- }
-
- notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
-
- if ( notxml ) {
- // Fix name and attach hooks
- name = jQuery.propFix[ name ] || name;
- hooks = jQuery.propHooks[ name ];
- }
-
- if ( value !== undefined ) {
- if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
- return ret;
-
- } else {
- return ( elem[ name ] = value );
- }
-
- } else {
- if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
- return ret;
-
- } else {
- return elem[ name ];
- }
- }
- },
-
- propHooks: {
- tabIndex: {
- get: function( elem ) {
- // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
- // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
- var attributeNode = elem.getAttributeNode("tabindex");
-
- return attributeNode && attributeNode.specified ?
- parseInt( attributeNode.value, 10 ) :
- rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
- 0 :
- undefined;
- }
- }
- }
-});
-
-// Hook for boolean attributes
-boolHook = {
- get: function( elem, name ) {
- var
- // Use .prop to determine if this attribute is understood as boolean
- prop = jQuery.prop( elem, name ),
-
- // Fetch it accordingly
- attr = typeof prop === "boolean" && elem.getAttribute( name ),
- detail = typeof prop === "boolean" ?
-
- getSetInput && getSetAttribute ?
- attr != null :
- // oldIE fabricates an empty string for missing boolean attributes
- // and conflates checked/selected into attroperties
- ruseDefault.test( name ) ?
- elem[ jQuery.camelCase( "default-" + name ) ] :
- !!attr :
-
- // fetch an attribute node for properties not recognized as boolean
- elem.getAttributeNode( name );
-
- return detail && detail.value !== false ?
- name.toLowerCase() :
- undefined;
- },
- set: function( elem, value, name ) {
- if ( value === false ) {
- // Remove boolean attributes when set to false
- jQuery.removeAttr( elem, name );
- } else if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
- // IE<8 needs the *property* name
- elem.setAttribute( !getSetAttribute && jQuery.propFix[ name ] || name, name );
-
- // Use defaultChecked and defaultSelected for oldIE
- } else {
- elem[ jQuery.camelCase( "default-" + name ) ] = elem[ name ] = true;
- }
-
- return name;
- }
-};
-
-// fix oldIE value attroperty
-if ( !getSetInput || !getSetAttribute ) {
- jQuery.attrHooks.value = {
- get: function( elem, name ) {
- var ret = elem.getAttributeNode( name );
- return jQuery.nodeName( elem, "input" ) ?
-
- // Ignore the value *property* by using defaultValue
- elem.defaultValue :
-
- ret && ret.specified ? ret.value : undefined;
- },
- set: function( elem, value, name ) {
- if ( jQuery.nodeName( elem, "input" ) ) {
- // Does not return so that setAttribute is also used
- elem.defaultValue = value;
- } else {
- // Use nodeHook if defined (#1954); otherwise setAttribute is fine
- return nodeHook && nodeHook.set( elem, value, name );
- }
- }
- };
-}
-
-// IE6/7 do not support getting/setting some attributes with get/setAttribute
-if ( !getSetAttribute ) {
-
- // Use this for any attribute in IE6/7
- // This fixes almost every IE6/7 issue
- nodeHook = jQuery.valHooks.button = {
- get: function( elem, name ) {
- var ret = elem.getAttributeNode( name );
- return ret && ( name === "id" || name === "name" || name === "coords" ? ret.value !== "" : ret.specified ) ?
- ret.value :
- undefined;
- },
- set: function( elem, value, name ) {
- // Set the existing or create a new attribute node
- var ret = elem.getAttributeNode( name );
- if ( !ret ) {
- elem.setAttributeNode(
- (ret = elem.ownerDocument.createAttribute( name ))
- );
- }
-
- ret.value = value += "";
-
- // Break association with cloned elements by also using setAttribute (#9646)
- return name === "value" || value === elem.getAttribute( name ) ?
- value :
- undefined;
- }
- };
-
- // Set contenteditable to false on removals(#10429)
- // Setting to empty string throws an error as an invalid value
- jQuery.attrHooks.contenteditable = {
- get: nodeHook.get,
- set: function( elem, value, name ) {
- nodeHook.set( elem, value === "" ? false : value, name );
- }
- };
-
- // Set width and height to auto instead of 0 on empty string( Bug #8150 )
- // This is for removals
- jQuery.each([ "width", "height" ], function( i, name ) {
- jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
- set: function( elem, value ) {
- if ( value === "" ) {
- elem.setAttribute( name, "auto" );
- return value;
- }
- }
- });
- });
-}
-
-
-// Some attributes require a special call on IE
-// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
-if ( !jQuery.support.hrefNormalized ) {
- jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {
- jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
- get: function( elem ) {
- var ret = elem.getAttribute( name, 2 );
- return ret == null ? undefined : ret;
- }
- });
- });
-
- // href/src property should get the full normalized URL (#10299/#12915)
- jQuery.each([ "href", "src" ], function( i, name ) {
- jQuery.propHooks[ name ] = {
- get: function( elem ) {
- return elem.getAttribute( name, 4 );
- }
- };
- });
-}
-
-if ( !jQuery.support.style ) {
- jQuery.attrHooks.style = {
- get: function( elem ) {
- // Return undefined in the case of empty string
- // Note: IE uppercases css property names, but if we were to .toLowerCase()
- // .cssText, that would destroy case senstitivity in URL's, like in "background"
- return elem.style.cssText || undefined;
- },
- set: function( elem, value ) {
- return ( elem.style.cssText = value + "" );
- }
- };
-}
-
-// Safari mis-reports the default selected property of an option
-// Accessing the parent's selectedIndex property fixes it
-if ( !jQuery.support.optSelected ) {
- jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, {
- get: function( elem ) {
- var parent = elem.parentNode;
-
- if ( parent ) {
- parent.selectedIndex;
-
- // Make sure that it also works with optgroups, see #5701
- if ( parent.parentNode ) {
- parent.parentNode.selectedIndex;
- }
- }
- return null;
- }
- });
-}
-
-// IE6/7 call enctype encoding
-if ( !jQuery.support.enctype ) {
- jQuery.propFix.enctype = "encoding";
-}
-
-// Radios and checkboxes getter/setter
-if ( !jQuery.support.checkOn ) {
- jQuery.each([ "radio", "checkbox" ], function() {
- jQuery.valHooks[ this ] = {
- get: function( elem ) {
- // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
- return elem.getAttribute("value") === null ? "on" : elem.value;
- }
- };
- });
-}
-jQuery.each([ "radio", "checkbox" ], function() {
- jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], {
- set: function( elem, value ) {
- if ( jQuery.isArray( value ) ) {
- return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
- }
- }
- });
-});
-var rformElems = /^(?:input|select|textarea)$/i,
- rkeyEvent = /^key/,
- rmouseEvent = /^(?:mouse|contextmenu)|click/,
- rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
- rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
-
-function returnTrue() {
- return true;
-}
-
-function returnFalse() {
- return false;
-}
-
-/*
- * Helper functions for managing events -- not part of the public interface.
- * Props to Dean Edwards' addEvent library for many of the ideas.
- */
-jQuery.event = {
-
- global: {},
-
- add: function( elem, types, handler, data, selector ) {
- var tmp, events, t, handleObjIn,
- special, eventHandle, handleObj,
- handlers, type, namespaces, origType,
- elemData = jQuery._data( elem );
-
- // Don't attach events to noData or text/comment nodes (but allow plain objects)
- if ( !elemData ) {
- return;
- }
-
- // Caller can pass in an object of custom data in lieu of the handler
- if ( handler.handler ) {
- handleObjIn = handler;
- handler = handleObjIn.handler;
- selector = handleObjIn.selector;
- }
-
- // Make sure that the handler has a unique ID, used to find/remove it later
- if ( !handler.guid ) {
- handler.guid = jQuery.guid++;
- }
-
- // Init the element's event structure and main handler, if this is the first
- if ( !(events = elemData.events) ) {
- events = elemData.events = {};
- }
- if ( !(eventHandle = elemData.handle) ) {
- eventHandle = elemData.handle = function( e ) {
- // Discard the second event of a jQuery.event.trigger() and
- // when an event is called after a page has unloaded
- return typeof jQuery !== core_strundefined && (!e || jQuery.event.triggered !== e.type) ?
- jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
- undefined;
- };
- // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
- eventHandle.elem = elem;
- }
-
- // Handle multiple events separated by a space
- // jQuery(...).bind("mouseover mouseout", fn);
- types = ( types || "" ).match( core_rnotwhite ) || [""];
- t = types.length;
- while ( t-- ) {
- tmp = rtypenamespace.exec( types[t] ) || [];
- type = origType = tmp[1];
- namespaces = ( tmp[2] || "" ).split( "." ).sort();
-
- // If event changes its type, use the special event handlers for the changed type
- special = jQuery.event.special[ type ] || {};
-
- // If selector defined, determine special event api type, otherwise given type
- type = ( selector ? special.delegateType : special.bindType ) || type;
-
- // Update special based on newly reset type
- special = jQuery.event.special[ type ] || {};
-
- // handleObj is passed to all event handlers
- handleObj = jQuery.extend({
- type: type,
- origType: origType,
- data: data,
- handler: handler,
- guid: handler.guid,
- selector: selector,
- needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
- namespace: namespaces.join(".")
- }, handleObjIn );
-
- // Init the event handler queue if we're the first
- if ( !(handlers = events[ type ]) ) {
- handlers = events[ type ] = [];
- handlers.delegateCount = 0;
-
- // Only use addEventListener/attachEvent if the special events handler returns false
- if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
- // Bind the global event handler to the element
- if ( elem.addEventListener ) {
- elem.addEventListener( type, eventHandle, false );
-
- } else if ( elem.attachEvent ) {
- elem.attachEvent( "on" + type, eventHandle );
- }
- }
- }
-
- if ( special.add ) {
- special.add.call( elem, handleObj );
-
- if ( !handleObj.handler.guid ) {
- handleObj.handler.guid = handler.guid;
- }
- }
-
- // Add to the element's handler list, delegates in front
- if ( selector ) {
- handlers.splice( handlers.delegateCount++, 0, handleObj );
- } else {
- handlers.push( handleObj );
- }
-
- // Keep track of which events have ever been used, for event optimization
- jQuery.event.global[ type ] = true;
- }
-
- // Nullify elem to prevent memory leaks in IE
- elem = null;
- },
-
- // Detach an event or set of events from an element
- remove: function( elem, types, handler, selector, mappedTypes ) {
- var j, handleObj, tmp,
- origCount, t, events,
- special, handlers, type,
- namespaces, origType,
- elemData = jQuery.hasData( elem ) && jQuery._data( elem );
-
- if ( !elemData || !(events = elemData.events) ) {
- return;
- }
-
- // Once for each type.namespace in types; type may be omitted
- types = ( types || "" ).match( core_rnotwhite ) || [""];
- t = types.length;
- while ( t-- ) {
- tmp = rtypenamespace.exec( types[t] ) || [];
- type = origType = tmp[1];
- namespaces = ( tmp[2] || "" ).split( "." ).sort();
-
- // Unbind all events (on this namespace, if provided) for the element
- if ( !type ) {
- for ( type in events ) {
- jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
- }
- continue;
- }
-
- special = jQuery.event.special[ type ] || {};
- type = ( selector ? special.delegateType : special.bindType ) || type;
- handlers = events[ type ] || [];
- tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" );
-
- // Remove matching events
- origCount = j = handlers.length;
- while ( j-- ) {
- handleObj = handlers[ j ];
-
- if ( ( mappedTypes || origType === handleObj.origType ) &&
- ( !handler || handler.guid === handleObj.guid ) &&
- ( !tmp || tmp.test( handleObj.namespace ) ) &&
- ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
- handlers.splice( j, 1 );
-
- if ( handleObj.selector ) {
- handlers.delegateCount--;
- }
- if ( special.remove ) {
- special.remove.call( elem, handleObj );
- }
- }
- }
-
- // Remove generic event handler if we removed something and no more handlers exist
- // (avoids potential for endless recursion during removal of special event handlers)
- if ( origCount && !handlers.length ) {
- if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
- jQuery.removeEvent( elem, type, elemData.handle );
- }
-
- delete events[ type ];
- }
- }
-
- // Remove the expando if it's no longer used
- if ( jQuery.isEmptyObject( events ) ) {
- delete elemData.handle;
-
- // removeData also checks for emptiness and clears the expando if empty
- // so use it instead of delete
- jQuery._removeData( elem, "events" );
- }
- },
-
- trigger: function( event, data, elem, onlyHandlers ) {
- var handle, ontype, cur,
- bubbleType, special, tmp, i,
- eventPath = [ elem || document ],
- type = core_hasOwn.call( event, "type" ) ? event.type : event,
- namespaces = core_hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : [];
-
- cur = tmp = elem = elem || document;
-
- // Don't do events on text and comment nodes
- if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
- return;
- }
-
- // focus/blur morphs to focusin/out; ensure we're not firing them right now
- if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
- return;
- }
-
- if ( type.indexOf(".") >= 0 ) {
- // Namespaced trigger; create a regexp to match event type in handle()
- namespaces = type.split(".");
- type = namespaces.shift();
- namespaces.sort();
- }
- ontype = type.indexOf(":") < 0 && "on" + type;
-
- // Caller can pass in a jQuery.Event object, Object, or just an event type string
- event = event[ jQuery.expando ] ?
- event :
- new jQuery.Event( type, typeof event === "object" && event );
-
- event.isTrigger = true;
- event.namespace = namespaces.join(".");
- event.namespace_re = event.namespace ?
- new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
- null;
-
- // Clean up the event in case it is being reused
- event.result = undefined;
- if ( !event.target ) {
- event.target = elem;
- }
-
- // Clone any incoming data and prepend the event, creating the handler arg list
- data = data == null ?
- [ event ] :
- jQuery.makeArray( data, [ event ] );
-
- // Allow special events to draw outside the lines
- special = jQuery.event.special[ type ] || {};
- if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
- return;
- }
-
- // Determine event propagation path in advance, per W3C events spec (#9951)
- // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
- if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
-
- bubbleType = special.delegateType || type;
- if ( !rfocusMorph.test( bubbleType + type ) ) {
- cur = cur.parentNode;
- }
- for ( ; cur; cur = cur.parentNode ) {
- eventPath.push( cur );
- tmp = cur;
- }
-
- // Only add window if we got to document (e.g., not plain obj or detached DOM)
- if ( tmp === (elem.ownerDocument || document) ) {
- eventPath.push( tmp.defaultView || tmp.parentWindow || window );
- }
- }
-
- // Fire handlers on the event path
- i = 0;
- while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) {
-
- event.type = i > 1 ?
- bubbleType :
- special.bindType || type;
-
- // jQuery handler
- handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );
- if ( handle ) {
- handle.apply( cur, data );
- }
-
- // Native handler
- handle = ontype && cur[ ontype ];
- if ( handle && jQuery.acceptData( cur ) && handle.apply && handle.apply( cur, data ) === false ) {
- event.preventDefault();
- }
- }
- event.type = type;
-
- // If nobody prevented the default action, do it now
- if ( !onlyHandlers && !event.isDefaultPrevented() ) {
-
- if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) &&
- !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) {
-
- // Call a native DOM method on the target with the same name name as the event.
- // Can't use an .isFunction() check here because IE6/7 fails that test.
- // Don't do default actions on window, that's where global variables be (#6170)
- if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) {
-
- // Don't re-trigger an onFOO event when we call its FOO() method
- tmp = elem[ ontype ];
-
- if ( tmp ) {
- elem[ ontype ] = null;
- }
-
- // Prevent re-triggering of the same event, since we already bubbled it above
- jQuery.event.triggered = type;
- try {
- elem[ type ]();
- } catch ( e ) {
- // IE<9 dies on focus/blur to hidden element (#1486,#12518)
- // only reproducible on winXP IE8 native, not IE9 in IE8 mode
- }
- jQuery.event.triggered = undefined;
-
- if ( tmp ) {
- elem[ ontype ] = tmp;
- }
- }
- }
- }
-
- return event.result;
- },
-
- dispatch: function( event ) {
-
- // Make a writable jQuery.Event from the native event object
- event = jQuery.event.fix( event );
-
- var i, ret, handleObj, matched, j,
- handlerQueue = [],
- args = core_slice.call( arguments ),
- handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [],
- special = jQuery.event.special[ event.type ] || {};
-
- // Use the fix-ed jQuery.Event rather than the (read-only) native event
- args[0] = event;
- event.delegateTarget = this;
-
- // Call the preDispatch hook for the mapped type, and let it bail if desired
- if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
- return;
- }
-
- // Determine handlers
- handlerQueue = jQuery.event.handlers.call( this, event, handlers );
-
- // Run delegates first; they may want to stop propagation beneath us
- i = 0;
- while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) {
- event.currentTarget = matched.elem;
-
- j = 0;
- while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
-
- // Triggered event must either 1) have no namespace, or
- // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
- if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) {
-
- event.handleObj = handleObj;
- event.data = handleObj.data;
-
- ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
- .apply( matched.elem, args );
-
- if ( ret !== undefined ) {
- if ( (event.result = ret) === false ) {
- event.preventDefault();
- event.stopPropagation();
- }
- }
- }
- }
- }
-
- // Call the postDispatch hook for the mapped type
- if ( special.postDispatch ) {
- special.postDispatch.call( this, event );
- }
-
- return event.result;
- },
-
- handlers: function( event, handlers ) {
- var sel, handleObj, matches, i,
- handlerQueue = [],
- delegateCount = handlers.delegateCount,
- cur = event.target;
-
- // Find delegate handlers
- // Black-hole SVG <use> instance trees (#13180)
- // Avoid non-left-click bubbling in Firefox (#3861)
- if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) {
-
- for ( ; cur != this; cur = cur.parentNode || this ) {
-
- // Don't check non-elements (#13208)
- // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
-
<TRUNCATED>
[20/26] Remove fauxton from 1.4.x branch.
Posted by dj...@apache.org.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/js/libs/bootstrap.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/bootstrap.js b/src/fauxton/assets/js/libs/bootstrap.js
deleted file mode 100644
index c753bd6..0000000
--- a/src/fauxton/assets/js/libs/bootstrap.js
+++ /dev/null
@@ -1,2025 +0,0 @@
-/* ===================================================
- * bootstrap-transition.js v2.2.1
- * http://twitter.github.com/bootstrap/javascript.html#transitions
- * ===================================================
- * Copyright 2012 Twitter, Inc.
- *
- * 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.
- * ========================================================== */
-
-
-!function ($) {
-
- "use strict"; // jshint ;_;
-
-
- /* CSS TRANSITION SUPPORT (http://www.modernizr.com/)
- * ======================================================= */
-
- $(function () {
-
- $.support.transition = (function () {
-
- var transitionEnd = (function () {
-
- var el = document.createElement('bootstrap')
- , transEndEventNames = {
- 'WebkitTransition' : 'webkitTransitionEnd'
- , 'MozTransition' : 'transitionend'
- , 'OTransition' : 'oTransitionEnd otransitionend'
- , 'transition' : 'transitionend'
- }
- , name
-
- for (name in transEndEventNames){
- if (el.style[name] !== undefined) {
- return transEndEventNames[name]
- }
- }
-
- }())
-
- return transitionEnd && {
- end: transitionEnd
- }
-
- })()
-
- })
-
-}(window.jQuery);/* ==========================================================
- * bootstrap-alert.js v2.2.1
- * http://twitter.github.com/bootstrap/javascript.html#alerts
- * ==========================================================
- * Copyright 2012 Twitter, Inc.
- *
- * 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.
- * ========================================================== */
-
-
-!function ($) {
-
- "use strict"; // jshint ;_;
-
-
- /* ALERT CLASS DEFINITION
- * ====================== */
-
- var dismiss = '[data-dismiss="alert"]'
- , Alert = function (el) {
- $(el).on('click', dismiss, this.close)
- }
-
- Alert.prototype.close = function (e) {
- var $this = $(this)
- , selector = $this.attr('data-target')
- , $parent
-
- if (!selector) {
- selector = $this.attr('href')
- selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
- }
-
- $parent = $(selector)
-
- e && e.preventDefault()
-
- $parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent())
-
- $parent.trigger(e = $.Event('close'))
-
- if (e.isDefaultPrevented()) return
-
- $parent.removeClass('in')
-
- function removeElement() {
- $parent
- .trigger('closed')
- .remove()
- }
-
- $.support.transition && $parent.hasClass('fade') ?
- $parent.on($.support.transition.end, removeElement) :
- removeElement()
- }
-
-
- /* ALERT PLUGIN DEFINITION
- * ======================= */
-
- $.fn.alert = function (option) {
- return this.each(function () {
- var $this = $(this)
- , data = $this.data('alert')
- if (!data) $this.data('alert', (data = new Alert(this)))
- if (typeof option == 'string') data[option].call($this)
- })
- }
-
- $.fn.alert.Constructor = Alert
-
-
- /* ALERT DATA-API
- * ============== */
-
- $(document).on('click.alert.data-api', dismiss, Alert.prototype.close)
-
-}(window.jQuery);/* ============================================================
- * bootstrap-button.js v2.2.1
- * http://twitter.github.com/bootstrap/javascript.html#buttons
- * ============================================================
- * Copyright 2012 Twitter, Inc.
- *
- * 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.
- * ============================================================ */
-
-
-!function ($) {
-
- "use strict"; // jshint ;_;
-
-
- /* BUTTON PUBLIC CLASS DEFINITION
- * ============================== */
-
- var Button = function (element, options) {
- this.$element = $(element)
- this.options = $.extend({}, $.fn.button.defaults, options)
- }
-
- Button.prototype.setState = function (state) {
- var d = 'disabled'
- , $el = this.$element
- , data = $el.data()
- , val = $el.is('input') ? 'val' : 'html'
-
- state = state + 'Text'
- data.resetText || $el.data('resetText', $el[val]())
-
- $el[val](data[state] || this.options[state])
-
- // push to event loop to allow forms to submit
- setTimeout(function () {
- state == 'loadingText' ?
- $el.addClass(d).attr(d, d) :
- $el.removeClass(d).removeAttr(d)
- }, 0)
- }
-
- Button.prototype.toggle = function () {
- var $parent = this.$element.closest('[data-toggle="buttons-radio"]')
-
- $parent && $parent
- .find('.active')
- .removeClass('active')
-
- this.$element.toggleClass('active')
- }
-
-
- /* BUTTON PLUGIN DEFINITION
- * ======================== */
-
- $.fn.button = function (option) {
- return this.each(function () {
- var $this = $(this)
- , data = $this.data('button')
- , options = typeof option == 'object' && option
- if (!data) $this.data('button', (data = new Button(this, options)))
- if (option == 'toggle') data.toggle()
- else if (option) data.setState(option)
- })
- }
-
- $.fn.button.defaults = {
- loadingText: 'loading...'
- }
-
- $.fn.button.Constructor = Button
-
-
- /* BUTTON DATA-API
- * =============== */
-
- $(document).on('click.button.data-api', '[data-toggle^=button]', function (e) {
- var $btn = $(e.target)
- if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
- $btn.button('toggle')
- })
-
-}(window.jQuery);/* ==========================================================
- * bootstrap-carousel.js v2.2.1
- * http://twitter.github.com/bootstrap/javascript.html#carousel
- * ==========================================================
- * Copyright 2012 Twitter, Inc.
- *
- * 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.
- * ========================================================== */
-
-
-!function ($) {
-
- "use strict"; // jshint ;_;
-
-
- /* CAROUSEL CLASS DEFINITION
- * ========================= */
-
- var Carousel = function (element, options) {
- this.$element = $(element)
- this.options = options
- this.options.slide && this.slide(this.options.slide)
- this.options.pause == 'hover' && this.$element
- .on('mouseenter', $.proxy(this.pause, this))
- .on('mouseleave', $.proxy(this.cycle, this))
- }
-
- Carousel.prototype = {
-
- cycle: function (e) {
- if (!e) this.paused = false
- this.options.interval
- && !this.paused
- && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
- return this
- }
-
- , to: function (pos) {
- var $active = this.$element.find('.item.active')
- , children = $active.parent().children()
- , activePos = children.index($active)
- , that = this
-
- if (pos > (children.length - 1) || pos < 0) return
-
- if (this.sliding) {
- return this.$element.one('slid', function () {
- that.to(pos)
- })
- }
-
- if (activePos == pos) {
- return this.pause().cycle()
- }
-
- return this.slide(pos > activePos ? 'next' : 'prev', $(children[pos]))
- }
-
- , pause: function (e) {
- if (!e) this.paused = true
- if (this.$element.find('.next, .prev').length && $.support.transition.end) {
- this.$element.trigger($.support.transition.end)
- this.cycle()
- }
- clearInterval(this.interval)
- this.interval = null
- return this
- }
-
- , next: function () {
- if (this.sliding) return
- return this.slide('next')
- }
-
- , prev: function () {
- if (this.sliding) return
- return this.slide('prev')
- }
-
- , slide: function (type, next) {
- var $active = this.$element.find('.item.active')
- , $next = next || $active[type]()
- , isCycling = this.interval
- , direction = type == 'next' ? 'left' : 'right'
- , fallback = type == 'next' ? 'first' : 'last'
- , that = this
- , e
-
- this.sliding = true
-
- isCycling && this.pause()
-
- $next = $next.length ? $next : this.$element.find('.item')[fallback]()
-
- e = $.Event('slide', {
- relatedTarget: $next[0]
- })
-
- if ($next.hasClass('active')) return
-
- if ($.support.transition && this.$element.hasClass('slide')) {
- this.$element.trigger(e)
- if (e.isDefaultPrevented()) return
- $next.addClass(type)
- $next[0].offsetWidth // force reflow
- $active.addClass(direction)
- $next.addClass(direction)
- this.$element.one($.support.transition.end, function () {
- $next.removeClass([type, direction].join(' ')).addClass('active')
- $active.removeClass(['active', direction].join(' '))
- that.sliding = false
- setTimeout(function () { that.$element.trigger('slid') }, 0)
- })
- } else {
- this.$element.trigger(e)
- if (e.isDefaultPrevented()) return
- $active.removeClass('active')
- $next.addClass('active')
- this.sliding = false
- this.$element.trigger('slid')
- }
-
- isCycling && this.cycle()
-
- return this
- }
-
- }
-
-
- /* CAROUSEL PLUGIN DEFINITION
- * ========================== */
-
- $.fn.carousel = function (option) {
- return this.each(function () {
- var $this = $(this)
- , data = $this.data('carousel')
- , options = $.extend({}, $.fn.carousel.defaults, typeof option == 'object' && option)
- , action = typeof option == 'string' ? option : options.slide
- if (!data) $this.data('carousel', (data = new Carousel(this, options)))
- if (typeof option == 'number') data.to(option)
- else if (action) data[action]()
- else if (options.interval) data.cycle()
- })
- }
-
- $.fn.carousel.defaults = {
- interval: 5000
- , pause: 'hover'
- }
-
- $.fn.carousel.Constructor = Carousel
-
-
- /* CAROUSEL DATA-API
- * ================= */
-
- $(document).on('click.carousel.data-api', '[data-slide]', function (e) {
- var $this = $(this), href
- , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
- , options = $.extend({}, $target.data(), $this.data())
- $target.carousel(options)
- e.preventDefault()
- })
-
-}(window.jQuery);/* =============================================================
- * bootstrap-collapse.js v2.2.1
- * http://twitter.github.com/bootstrap/javascript.html#collapse
- * =============================================================
- * Copyright 2012 Twitter, Inc.
- *
- * 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.
- * ============================================================ */
-
-
-!function ($) {
-
- "use strict"; // jshint ;_;
-
-
- /* COLLAPSE PUBLIC CLASS DEFINITION
- * ================================ */
-
- var Collapse = function (element, options) {
- this.$element = $(element)
- this.options = $.extend({}, $.fn.collapse.defaults, options)
-
- if (this.options.parent) {
- this.$parent = $(this.options.parent)
- }
-
- this.options.toggle && this.toggle()
- }
-
- Collapse.prototype = {
-
- constructor: Collapse
-
- , dimension: function () {
- var hasWidth = this.$element.hasClass('width')
- return hasWidth ? 'width' : 'height'
- }
-
- , show: function () {
- var dimension
- , scroll
- , actives
- , hasData
-
- if (this.transitioning) return
-
- dimension = this.dimension()
- scroll = $.camelCase(['scroll', dimension].join('-'))
- actives = this.$parent && this.$parent.find('> .accordion-group > .in')
-
- if (actives && actives.length) {
- hasData = actives.data('collapse')
- if (hasData && hasData.transitioning) return
- actives.collapse('hide')
- hasData || actives.data('collapse', null)
- }
-
- this.$element[dimension](0)
- this.transition('addClass', $.Event('show'), 'shown')
- $.support.transition && this.$element[dimension](this.$element[0][scroll])
- }
-
- , hide: function () {
- var dimension
- if (this.transitioning) return
- dimension = this.dimension()
- this.reset(this.$element[dimension]())
- this.transition('removeClass', $.Event('hide'), 'hidden')
- this.$element[dimension](0)
- }
-
- , reset: function (size) {
- var dimension = this.dimension()
-
- this.$element
- .removeClass('collapse')
- [dimension](size || 'auto')
- [0].offsetWidth
-
- this.$element[size !== null ? 'addClass' : 'removeClass']('collapse')
-
- return this
- }
-
- , transition: function (method, startEvent, completeEvent) {
- var that = this
- , complete = function () {
- if (startEvent.type == 'show') that.reset()
- that.transitioning = 0
- that.$element.trigger(completeEvent)
- }
-
- this.$element.trigger(startEvent)
-
- if (startEvent.isDefaultPrevented()) return
-
- this.transitioning = 1
-
- this.$element[method]('in')
-
- $.support.transition && this.$element.hasClass('collapse') ?
- this.$element.one($.support.transition.end, complete) :
- complete()
- }
-
- , toggle: function () {
- this[this.$element.hasClass('in') ? 'hide' : 'show']()
- }
-
- }
-
-
- /* COLLAPSIBLE PLUGIN DEFINITION
- * ============================== */
-
- $.fn.collapse = function (option) {
- return this.each(function () {
- var $this = $(this)
- , data = $this.data('collapse')
- , options = typeof option == 'object' && option
- if (!data) $this.data('collapse', (data = new Collapse(this, options)))
- if (typeof option == 'string') data[option]()
- })
- }
-
- $.fn.collapse.defaults = {
- toggle: true
- }
-
- $.fn.collapse.Constructor = Collapse
-
-
- /* COLLAPSIBLE DATA-API
- * ==================== */
-
- $(document).on('click.collapse.data-api', '[data-toggle=collapse]', function (e) {
- var $this = $(this), href
- , target = $this.attr('data-target')
- || e.preventDefault()
- || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
- , option = $(target).data('collapse') ? 'toggle' : $this.data()
- $this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
- $(target).collapse(option)
- })
-
-}(window.jQuery);/* ============================================================
- * bootstrap-dropdown.js v2.2.1
- * http://twitter.github.com/bootstrap/javascript.html#dropdowns
- * ============================================================
- * Copyright 2012 Twitter, Inc.
- *
- * 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.
- * ============================================================ */
-
-
-!function ($) {
-
- "use strict"; // jshint ;_;
-
-
- /* DROPDOWN CLASS DEFINITION
- * ========================= */
-
- var toggle = '[data-toggle=dropdown]'
- , Dropdown = function (element) {
- var $el = $(element).on('click.dropdown.data-api', this.toggle)
- $('html').on('click.dropdown.data-api', function () {
- $el.parent().removeClass('open')
- })
- }
-
- Dropdown.prototype = {
-
- constructor: Dropdown
-
- , toggle: function (e) {
- var $this = $(this)
- , $parent
- , isActive
-
- if ($this.is('.disabled, :disabled')) return
-
- $parent = getParent($this)
-
- isActive = $parent.hasClass('open')
-
- clearMenus()
-
- if (!isActive) {
- $parent.toggleClass('open')
- $this.focus()
- }
-
- return false
- }
-
- , keydown: function (e) {
- var $this
- , $items
- , $active
- , $parent
- , isActive
- , index
-
- if (!/(38|40|27)/.test(e.keyCode)) return
-
- $this = $(this)
-
- e.preventDefault()
- e.stopPropagation()
-
- if ($this.is('.disabled, :disabled')) return
-
- $parent = getParent($this)
-
- isActive = $parent.hasClass('open')
-
- if (!isActive || (isActive && e.keyCode == 27)) return $this.click()
-
- $items = $('[role=menu] li:not(.divider) a', $parent)
-
- if (!$items.length) return
-
- index = $items.index($items.filter(':focus'))
-
- if (e.keyCode == 38 && index > 0) index-- // up
- if (e.keyCode == 40 && index < $items.length - 1) index++ // down
- if (!~index) index = 0
-
- $items
- .eq(index)
- .focus()
- }
-
- }
-
- function clearMenus() {
- $(toggle).each(function () {
- getParent($(this)).removeClass('open')
- })
- }
-
- function getParent($this) {
- var selector = $this.attr('data-target')
- , $parent
-
- if (!selector) {
- selector = $this.attr('href')
- selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
- }
-
- $parent = $(selector)
- $parent.length || ($parent = $this.parent())
-
- return $parent
- }
-
-
- /* DROPDOWN PLUGIN DEFINITION
- * ========================== */
-
- $.fn.dropdown = function (option) {
- return this.each(function () {
- var $this = $(this)
- , data = $this.data('dropdown')
- if (!data) $this.data('dropdown', (data = new Dropdown(this)))
- if (typeof option == 'string') data[option].call($this)
- })
- }
-
- $.fn.dropdown.Constructor = Dropdown
-
-
- /* APPLY TO STANDARD DROPDOWN ELEMENTS
- * =================================== */
-
- $(document)
- .on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus)
- .on('click.dropdown touchstart.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
- .on('click.dropdown.data-api touchstart.dropdown.data-api' , toggle, Dropdown.prototype.toggle)
- .on('keydown.dropdown.data-api touchstart.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
-
-}(window.jQuery);/* =========================================================
- * bootstrap-modal.js v2.2.1
- * http://twitter.github.com/bootstrap/javascript.html#modals
- * =========================================================
- * Copyright 2012 Twitter, Inc.
- *
- * 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.
- * ========================================================= */
-
-
-!function ($) {
-
- "use strict"; // jshint ;_;
-
-
- /* MODAL CLASS DEFINITION
- * ====================== */
-
- var Modal = function (element, options) {
- this.options = options
- this.$element = $(element)
- .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
- this.options.remote && this.$element.find('.modal-body').load(this.options.remote)
- }
-
- Modal.prototype = {
-
- constructor: Modal
-
- , toggle: function () {
- return this[!this.isShown ? 'show' : 'hide']()
- }
-
- , show: function () {
- var that = this
- , e = $.Event('show')
-
- this.$element.trigger(e)
-
- if (this.isShown || e.isDefaultPrevented()) return
-
- this.isShown = true
-
- this.escape()
-
- this.backdrop(function () {
- var transition = $.support.transition && that.$element.hasClass('fade')
-
- if (!that.$element.parent().length) {
- that.$element.appendTo(document.body) //don't move modals dom position
- }
-
- that.$element
- .show()
-
- if (transition) {
- that.$element[0].offsetWidth // force reflow
- }
-
- that.$element
- .addClass('in')
- .attr('aria-hidden', false)
-
- that.enforceFocus()
-
- transition ?
- that.$element.one($.support.transition.end, function () { that.$element.focus().trigger('shown') }) :
- that.$element.focus().trigger('shown')
-
- })
- }
-
- , hide: function (e) {
- e && e.preventDefault()
-
- var that = this
-
- e = $.Event('hide')
-
- this.$element.trigger(e)
-
- if (!this.isShown || e.isDefaultPrevented()) return
-
- this.isShown = false
-
- this.escape()
-
- $(document).off('focusin.modal')
-
- this.$element
- .removeClass('in')
- .attr('aria-hidden', true)
-
- $.support.transition && this.$element.hasClass('fade') ?
- this.hideWithTransition() :
- this.hideModal()
- }
-
- , enforceFocus: function () {
- var that = this
- $(document).on('focusin.modal', function (e) {
- if (that.$element[0] !== e.target && !that.$element.has(e.target).length) {
- that.$element.focus()
- }
- })
- }
-
- , escape: function () {
- var that = this
- if (this.isShown && this.options.keyboard) {
- this.$element.on('keyup.dismiss.modal', function ( e ) {
- e.which == 27 && that.hide()
- })
- } else if (!this.isShown) {
- this.$element.off('keyup.dismiss.modal')
- }
- }
-
- , hideWithTransition: function () {
- var that = this
- , timeout = setTimeout(function () {
- that.$element.off($.support.transition.end)
- that.hideModal()
- }, 500)
-
- this.$element.one($.support.transition.end, function () {
- clearTimeout(timeout)
- that.hideModal()
- })
- }
-
- , hideModal: function (that) {
- this.$element
- .hide()
- .trigger('hidden')
-
- this.backdrop()
- }
-
- , removeBackdrop: function () {
- this.$backdrop.remove()
- this.$backdrop = null
- }
-
- , backdrop: function (callback) {
- var that = this
- , animate = this.$element.hasClass('fade') ? 'fade' : ''
-
- if (this.isShown && this.options.backdrop) {
- var doAnimate = $.support.transition && animate
-
- this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
- .appendTo(document.body)
-
- this.$backdrop.click(
- this.options.backdrop == 'static' ?
- $.proxy(this.$element[0].focus, this.$element[0])
- : $.proxy(this.hide, this)
- )
-
- if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
-
- this.$backdrop.addClass('in')
-
- doAnimate ?
- this.$backdrop.one($.support.transition.end, callback) :
- callback()
-
- } else if (!this.isShown && this.$backdrop) {
- this.$backdrop.removeClass('in')
-
- $.support.transition && this.$element.hasClass('fade')?
- this.$backdrop.one($.support.transition.end, $.proxy(this.removeBackdrop, this)) :
- this.removeBackdrop()
-
- } else if (callback) {
- callback()
- }
- }
- }
-
-
- /* MODAL PLUGIN DEFINITION
- * ======================= */
-
- $.fn.modal = function (option) {
- return this.each(function () {
- var $this = $(this)
- , data = $this.data('modal')
- , options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option)
- if (!data) $this.data('modal', (data = new Modal(this, options)))
- if (typeof option == 'string') data[option]()
- else if (options.show) data.show()
- })
- }
-
- $.fn.modal.defaults = {
- backdrop: true
- , keyboard: true
- , show: true
- }
-
- $.fn.modal.Constructor = Modal
-
-
- /* MODAL DATA-API
- * ============== */
-
- $(document).on('click.modal.data-api', '[data-toggle="modal"]', function (e) {
- var $this = $(this)
- , href = $this.attr('href')
- , $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
- , option = $target.data('modal') ? 'toggle' : $.extend({ remote:!/#/.test(href) && href }, $target.data(), $this.data())
-
- e.preventDefault()
-
- $target
- .modal(option)
- .one('hide', function () {
- $this.focus()
- })
- })
-
-}(window.jQuery);
-/* ===========================================================
- * bootstrap-tooltip.js v2.2.1
- * http://twitter.github.com/bootstrap/javascript.html#tooltips
- * Inspired by the original jQuery.tipsy by Jason Frame
- * ===========================================================
- * Copyright 2012 Twitter, Inc.
- *
- * 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.
- * ========================================================== */
-
-
-!function ($) {
-
- "use strict"; // jshint ;_;
-
-
- /* TOOLTIP PUBLIC CLASS DEFINITION
- * =============================== */
-
- var Tooltip = function (element, options) {
- this.init('tooltip', element, options)
- }
-
- Tooltip.prototype = {
-
- constructor: Tooltip
-
- , init: function (type, element, options) {
- var eventIn
- , eventOut
-
- this.type = type
- this.$element = $(element)
- this.options = this.getOptions(options)
- this.enabled = true
-
- if (this.options.trigger == 'click') {
- this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
- } else if (this.options.trigger != 'manual') {
- eventIn = this.options.trigger == 'hover' ? 'mouseenter' : 'focus'
- eventOut = this.options.trigger == 'hover' ? 'mouseleave' : 'blur'
- this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
- this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
- }
-
- this.options.selector ?
- (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
- this.fixTitle()
- }
-
- , getOptions: function (options) {
- options = $.extend({}, $.fn[this.type].defaults, options, this.$element.data())
-
- if (options.delay && typeof options.delay == 'number') {
- options.delay = {
- show: options.delay
- , hide: options.delay
- }
- }
-
- return options
- }
-
- , enter: function (e) {
- var self = $(e.currentTarget)[this.type](this._options).data(this.type)
-
- if (!self.options.delay || !self.options.delay.show) return self.show()
-
- clearTimeout(this.timeout)
- self.hoverState = 'in'
- this.timeout = setTimeout(function() {
- if (self.hoverState == 'in') self.show()
- }, self.options.delay.show)
- }
-
- , leave: function (e) {
- var self = $(e.currentTarget)[this.type](this._options).data(this.type)
-
- if (this.timeout) clearTimeout(this.timeout)
- if (!self.options.delay || !self.options.delay.hide) return self.hide()
-
- self.hoverState = 'out'
- this.timeout = setTimeout(function() {
- if (self.hoverState == 'out') self.hide()
- }, self.options.delay.hide)
- }
-
- , show: function () {
- var $tip
- , inside
- , pos
- , actualWidth
- , actualHeight
- , placement
- , tp
-
- if (this.hasContent() && this.enabled) {
- $tip = this.tip()
- this.setContent()
-
- if (this.options.animation) {
- $tip.addClass('fade')
- }
-
- placement = typeof this.options.placement == 'function' ?
- this.options.placement.call(this, $tip[0], this.$element[0]) :
- this.options.placement
-
- inside = /in/.test(placement)
-
- $tip
- .detach()
- .css({ top: 0, left: 0, display: 'block' })
- .insertAfter(this.$element)
-
- pos = this.getPosition(inside)
-
- actualWidth = $tip[0].offsetWidth
- actualHeight = $tip[0].offsetHeight
-
- switch (inside ? placement.split(' ')[1] : placement) {
- case 'bottom':
- tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}
- break
- case 'top':
- tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}
- break
- case 'left':
- tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}
- break
- case 'right':
- tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}
- break
- }
-
- $tip
- .offset(tp)
- .addClass(placement)
- .addClass('in')
- }
- }
-
- , setContent: function () {
- var $tip = this.tip()
- , title = this.getTitle()
-
- $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
- $tip.removeClass('fade in top bottom left right')
- }
-
- , hide: function () {
- var that = this
- , $tip = this.tip()
-
- $tip.removeClass('in')
-
- function removeWithAnimation() {
- var timeout = setTimeout(function () {
- $tip.off($.support.transition.end).detach()
- }, 500)
-
- $tip.one($.support.transition.end, function () {
- clearTimeout(timeout)
- $tip.detach()
- })
- }
-
- $.support.transition && this.$tip.hasClass('fade') ?
- removeWithAnimation() :
- $tip.detach()
-
- return this
- }
-
- , fixTitle: function () {
- var $e = this.$element
- if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
- $e.attr('data-original-title', $e.attr('title') || '').removeAttr('title')
- }
- }
-
- , hasContent: function () {
- return this.getTitle()
- }
-
- , getPosition: function (inside) {
- return $.extend({}, (inside ? {top: 0, left: 0} : this.$element.offset()), {
- width: this.$element[0].offsetWidth
- , height: this.$element[0].offsetHeight
- })
- }
-
- , getTitle: function () {
- var title
- , $e = this.$element
- , o = this.options
-
- title = $e.attr('data-original-title')
- || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
-
- return title
- }
-
- , tip: function () {
- return this.$tip = this.$tip || $(this.options.template)
- }
-
- , validate: function () {
- if (!this.$element[0].parentNode) {
- this.hide()
- this.$element = null
- this.options = null
- }
- }
-
- , enable: function () {
- this.enabled = true
- }
-
- , disable: function () {
- this.enabled = false
- }
-
- , toggleEnabled: function () {
- this.enabled = !this.enabled
- }
-
- , toggle: function (e) {
- var self = $(e.currentTarget)[this.type](this._options).data(this.type)
- self[self.tip().hasClass('in') ? 'hide' : 'show']()
- }
-
- , destroy: function () {
- this.hide().$element.off('.' + this.type).removeData(this.type)
- }
-
- }
-
-
- /* TOOLTIP PLUGIN DEFINITION
- * ========================= */
-
- $.fn.tooltip = function ( option ) {
- return this.each(function () {
- var $this = $(this)
- , data = $this.data('tooltip')
- , options = typeof option == 'object' && option
- if (!data) $this.data('tooltip', (data = new Tooltip(this, options)))
- if (typeof option == 'string') data[option]()
- })
- }
-
- $.fn.tooltip.Constructor = Tooltip
-
- $.fn.tooltip.defaults = {
- animation: true
- , placement: 'top'
- , selector: false
- , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
- , trigger: 'hover'
- , title: ''
- , delay: 0
- , html: false
- }
-
-}(window.jQuery);/* ===========================================================
- * bootstrap-popover.js v2.2.1
- * http://twitter.github.com/bootstrap/javascript.html#popovers
- * ===========================================================
- * Copyright 2012 Twitter, Inc.
- *
- * 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.
- * =========================================================== */
-
-
-!function ($) {
-
- "use strict"; // jshint ;_;
-
-
- /* POPOVER PUBLIC CLASS DEFINITION
- * =============================== */
-
- var Popover = function (element, options) {
- this.init('popover', element, options)
- }
-
-
- /* NOTE: POPOVER EXTENDS BOOTSTRAP-TOOLTIP.js
- ========================================== */
-
- Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype, {
-
- constructor: Popover
-
- , setContent: function () {
- var $tip = this.tip()
- , title = this.getTitle()
- , content = this.getContent()
-
- $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
- $tip.find('.popover-content > *')[this.options.html ? 'html' : 'text'](content)
-
- $tip.removeClass('fade top bottom left right in')
- }
-
- , hasContent: function () {
- return this.getTitle() || this.getContent()
- }
-
- , getContent: function () {
- var content
- , $e = this.$element
- , o = this.options
-
- content = $e.attr('data-content')
- || (typeof o.content == 'function' ? o.content.call($e[0]) : o.content)
-
- return content
- }
-
- , tip: function () {
- if (!this.$tip) {
- this.$tip = $(this.options.template)
- }
- return this.$tip
- }
-
- , destroy: function () {
- this.hide().$element.off('.' + this.type).removeData(this.type)
- }
-
- })
-
-
- /* POPOVER PLUGIN DEFINITION
- * ======================= */
-
- $.fn.popover = function (option) {
- return this.each(function () {
- var $this = $(this)
- , data = $this.data('popover')
- , options = typeof option == 'object' && option
- if (!data) $this.data('popover', (data = new Popover(this, options)))
- if (typeof option == 'string') data[option]()
- })
- }
-
- $.fn.popover.Constructor = Popover
-
- $.fn.popover.defaults = $.extend({} , $.fn.tooltip.defaults, {
- placement: 'right'
- , trigger: 'click'
- , content: ''
- , template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>'
- })
-
-}(window.jQuery);/* =============================================================
- * bootstrap-scrollspy.js v2.2.1
- * http://twitter.github.com/bootstrap/javascript.html#scrollspy
- * =============================================================
- * Copyright 2012 Twitter, Inc.
- *
- * 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.
- * ============================================================== */
-
-
-!function ($) {
-
- "use strict"; // jshint ;_;
-
-
- /* SCROLLSPY CLASS DEFINITION
- * ========================== */
-
- function ScrollSpy(element, options) {
- var process = $.proxy(this.process, this)
- , $element = $(element).is('body') ? $(window) : $(element)
- , href
- this.options = $.extend({}, $.fn.scrollspy.defaults, options)
- this.$scrollElement = $element.on('scroll.scroll-spy.data-api', process)
- this.selector = (this.options.target
- || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
- || '') + ' .nav li > a'
- this.$body = $('body')
- this.refresh()
- this.process()
- }
-
- ScrollSpy.prototype = {
-
- constructor: ScrollSpy
-
- , refresh: function () {
- var self = this
- , $targets
-
- this.offsets = $([])
- this.targets = $([])
-
- $targets = this.$body
- .find(this.selector)
- .map(function () {
- var $el = $(this)
- , href = $el.data('target') || $el.attr('href')
- , $href = /^#\w/.test(href) && $(href)
- return ( $href
- && $href.length
- && [[ $href.position().top, href ]] ) || null
- })
- .sort(function (a, b) { return a[0] - b[0] })
- .each(function () {
- self.offsets.push(this[0])
- self.targets.push(this[1])
- })
- }
-
- , process: function () {
- var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
- , scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight
- , maxScroll = scrollHeight - this.$scrollElement.height()
- , offsets = this.offsets
- , targets = this.targets
- , activeTarget = this.activeTarget
- , i
-
- if (scrollTop >= maxScroll) {
- return activeTarget != (i = targets.last()[0])
- && this.activate ( i )
- }
-
- for (i = offsets.length; i--;) {
- activeTarget != targets[i]
- && scrollTop >= offsets[i]
- && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
- && this.activate( targets[i] )
- }
- }
-
- , activate: function (target) {
- var active
- , selector
-
- this.activeTarget = target
-
- $(this.selector)
- .parent('.active')
- .removeClass('active')
-
- selector = this.selector
- + '[data-target="' + target + '"],'
- + this.selector + '[href="' + target + '"]'
-
- active = $(selector)
- .parent('li')
- .addClass('active')
-
- if (active.parent('.dropdown-menu').length) {
- active = active.closest('li.dropdown').addClass('active')
- }
-
- active.trigger('activate')
- }
-
- }
-
-
- /* SCROLLSPY PLUGIN DEFINITION
- * =========================== */
-
- $.fn.scrollspy = function (option) {
- return this.each(function () {
- var $this = $(this)
- , data = $this.data('scrollspy')
- , options = typeof option == 'object' && option
- if (!data) $this.data('scrollspy', (data = new ScrollSpy(this, options)))
- if (typeof option == 'string') data[option]()
- })
- }
-
- $.fn.scrollspy.Constructor = ScrollSpy
-
- $.fn.scrollspy.defaults = {
- offset: 10
- }
-
-
- /* SCROLLSPY DATA-API
- * ================== */
-
- $(window).on('load', function () {
- $('[data-spy="scroll"]').each(function () {
- var $spy = $(this)
- $spy.scrollspy($spy.data())
- })
- })
-
-}(window.jQuery);/* ========================================================
- * bootstrap-tab.js v2.2.1
- * http://twitter.github.com/bootstrap/javascript.html#tabs
- * ========================================================
- * Copyright 2012 Twitter, Inc.
- *
- * 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.
- * ======================================================== */
-
-
-!function ($) {
-
- "use strict"; // jshint ;_;
-
-
- /* TAB CLASS DEFINITION
- * ==================== */
-
- var Tab = function (element) {
- this.element = $(element)
- }
-
- Tab.prototype = {
-
- constructor: Tab
-
- , show: function () {
- var $this = this.element
- , $ul = $this.closest('ul:not(.dropdown-menu)')
- , selector = $this.attr('data-target')
- , previous
- , $target
- , e
-
- if (!selector) {
- selector = $this.attr('href')
- selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
- }
-
- if ( $this.parent('li').hasClass('active') ) return
-
- previous = $ul.find('.active:last a')[0]
-
- e = $.Event('show', {
- relatedTarget: previous
- })
-
- $this.trigger(e)
-
- if (e.isDefaultPrevented()) return
-
- $target = $(selector)
-
- this.activate($this.parent('li'), $ul)
- this.activate($target, $target.parent(), function () {
- $this.trigger({
- type: 'shown'
- , relatedTarget: previous
- })
- })
- }
-
- , activate: function ( element, container, callback) {
- var $active = container.find('> .active')
- , transition = callback
- && $.support.transition
- && $active.hasClass('fade')
-
- function next() {
- $active
- .removeClass('active')
- .find('> .dropdown-menu > .active')
- .removeClass('active')
-
- element.addClass('active')
-
- if (transition) {
- element[0].offsetWidth // reflow for transition
- element.addClass('in')
- } else {
- element.removeClass('fade')
- }
-
- if ( element.parent('.dropdown-menu') ) {
- element.closest('li.dropdown').addClass('active')
- }
-
- callback && callback()
- }
-
- transition ?
- $active.one($.support.transition.end, next) :
- next()
-
- $active.removeClass('in')
- }
- }
-
-
- /* TAB PLUGIN DEFINITION
- * ===================== */
-
- $.fn.tab = function ( option ) {
- return this.each(function () {
- var $this = $(this)
- , data = $this.data('tab')
- if (!data) $this.data('tab', (data = new Tab(this)))
- if (typeof option == 'string') data[option]()
- })
- }
-
- $.fn.tab.Constructor = Tab
-
-
- /* TAB DATA-API
- * ============ */
-
- $(document).on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
- e.preventDefault()
- $(this).tab('show')
- })
-
-}(window.jQuery);/* =============================================================
- * bootstrap-typeahead.js v2.2.1
- * http://twitter.github.com/bootstrap/javascript.html#typeahead
- * =============================================================
- * Copyright 2012 Twitter, Inc.
- *
- * 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.
- * ============================================================ */
-
-
-!function($){
-
- "use strict"; // jshint ;_;
-
-
- /* TYPEAHEAD PUBLIC CLASS DEFINITION
- * ================================= */
-
- var Typeahead = function (element, options) {
- this.$element = $(element)
- this.options = $.extend({}, $.fn.typeahead.defaults, options)
- this.matcher = this.options.matcher || this.matcher
- this.sorter = this.options.sorter || this.sorter
- this.highlighter = this.options.highlighter || this.highlighter
- this.updater = this.options.updater || this.updater
- this.$menu = $(this.options.menu).appendTo('body')
- this.source = this.options.source
- this.shown = false
- this.listen()
- }
-
- Typeahead.prototype = {
-
- constructor: Typeahead
-
- , select: function () {
- var val = this.$menu.find('.active').attr('data-value')
- this.$element
- .val(this.updater(val))
- .change()
- return this.hide()
- }
-
- , updater: function (item) {
- return item
- }
-
- , show: function () {
- var pos = $.extend({}, this.$element.offset(), {
- height: this.$element[0].offsetHeight
- })
-
- this.$menu.css({
- top: pos.top + pos.height
- , left: pos.left
- })
-
- this.$menu.show()
- this.shown = true
- return this
- }
-
- , hide: function () {
- this.$menu.hide()
- this.shown = false
- return this
- }
-
- , lookup: function (event) {
- var items
-
- this.query = this.$element.val()
-
- if (!this.query || this.query.length < this.options.minLength) {
- return this.shown ? this.hide() : this
- }
-
- items = $.isFunction(this.source) ? this.source(this.query, $.proxy(this.process, this)) : this.source
-
- return items ? this.process(items) : this
- }
-
- , process: function (items) {
- var that = this
-
- items = $.grep(items, function (item) {
- return that.matcher(item)
- })
-
- items = this.sorter(items)
-
- if (!items.length) {
- return this.shown ? this.hide() : this
- }
-
- return this.render(items.slice(0, this.options.items)).show()
- }
-
- , matcher: function (item) {
- return ~item.toLowerCase().indexOf(this.query.toLowerCase())
- }
-
- , sorter: function (items) {
- var beginswith = []
- , caseSensitive = []
- , caseInsensitive = []
- , item
-
- while (item = items.shift()) {
- if (!item.toLowerCase().indexOf(this.query.toLowerCase())) beginswith.push(item)
- else if (~item.indexOf(this.query)) caseSensitive.push(item)
- else caseInsensitive.push(item)
- }
-
- return beginswith.concat(caseSensitive, caseInsensitive)
- }
-
- , highlighter: function (item) {
- var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&')
- return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
- return '<strong>' + match + '</strong>'
- })
- }
-
- , render: function (items) {
- var that = this
-
- items = $(items).map(function (i, item) {
- i = $(that.options.item).attr('data-value', item)
- i.find('a').html(that.highlighter(item))
- return i[0]
- })
-
- items.first().addClass('active')
- this.$menu.html(items)
- return this
- }
-
- , next: function (event) {
- var active = this.$menu.find('.active').removeClass('active')
- , next = active.next()
-
- if (!next.length) {
- next = $(this.$menu.find('li')[0])
- }
-
- next.addClass('active')
- }
-
- , prev: function (event) {
- var active = this.$menu.find('.active').removeClass('active')
- , prev = active.prev()
-
- if (!prev.length) {
- prev = this.$menu.find('li').last()
- }
-
- prev.addClass('active')
- }
-
- , listen: function () {
- this.$element
- .on('blur', $.proxy(this.blur, this))
- .on('keypress', $.proxy(this.keypress, this))
- .on('keyup', $.proxy(this.keyup, this))
-
- if (this.eventSupported('keydown')) {
- this.$element.on('keydown', $.proxy(this.keydown, this))
- }
-
- this.$menu
- .on('click', $.proxy(this.click, this))
- .on('mouseenter', 'li', $.proxy(this.mouseenter, this))
- }
-
- , eventSupported: function(eventName) {
- var isSupported = eventName in this.$element
- if (!isSupported) {
- this.$element.setAttribute(eventName, 'return;')
- isSupported = typeof this.$element[eventName] === 'function'
- }
- return isSupported
- }
-
- , move: function (e) {
- if (!this.shown) return
-
- switch(e.keyCode) {
- case 9: // tab
- case 13: // enter
- case 27: // escape
- e.preventDefault()
- break
-
- case 38: // up arrow
- e.preventDefault()
- this.prev()
- break
-
- case 40: // down arrow
- e.preventDefault()
- this.next()
- break
- }
-
- e.stopPropagation()
- }
-
- , keydown: function (e) {
- this.suppressKeyPressRepeat = !~$.inArray(e.keyCode, [40,38,9,13,27])
- this.move(e)
- }
-
- , keypress: function (e) {
- if (this.suppressKeyPressRepeat) return
- this.move(e)
- }
-
- , keyup: function (e) {
- switch(e.keyCode) {
- case 40: // down arrow
- case 38: // up arrow
- case 16: // shift
- case 17: // ctrl
- case 18: // alt
- break
-
- case 9: // tab
- case 13: // enter
- if (!this.shown) return
- this.select()
- break
-
- case 27: // escape
- if (!this.shown) return
- this.hide()
- break
-
- default:
- this.lookup()
- }
-
- e.stopPropagation()
- e.preventDefault()
- }
-
- , blur: function (e) {
- var that = this
- setTimeout(function () { that.hide() }, 150)
- }
-
- , click: function (e) {
- e.stopPropagation()
- e.preventDefault()
- this.select()
- }
-
- , mouseenter: function (e) {
- this.$menu.find('.active').removeClass('active')
- $(e.currentTarget).addClass('active')
- }
-
- }
-
-
- /* TYPEAHEAD PLUGIN DEFINITION
- * =========================== */
-
- $.fn.typeahead = function (option) {
- return this.each(function () {
- var $this = $(this)
- , data = $this.data('typeahead')
- , options = typeof option == 'object' && option
- if (!data) $this.data('typeahead', (data = new Typeahead(this, options)))
- if (typeof option == 'string') data[option]()
- })
- }
-
- $.fn.typeahead.defaults = {
- source: []
- , items: 8
- , menu: '<ul class="typeahead dropdown-menu"></ul>'
- , item: '<li><a href="#"></a></li>'
- , minLength: 1
- }
-
- $.fn.typeahead.Constructor = Typeahead
-
-
- /* TYPEAHEAD DATA-API
- * ================== */
-
- $(document).on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) {
- var $this = $(this)
- if ($this.data('typeahead')) return
- e.preventDefault()
- $this.typeahead($this.data())
- })
-
-}(window.jQuery);
-/* ==========================================================
- * bootstrap-affix.js v2.2.1
- * http://twitter.github.com/bootstrap/javascript.html#affix
- * ==========================================================
- * Copyright 2012 Twitter, Inc.
- *
- * 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.
- * ========================================================== */
-
-
-!function ($) {
-
- "use strict"; // jshint ;_;
-
-
- /* AFFIX CLASS DEFINITION
- * ====================== */
-
- var Affix = function (element, options) {
- this.options = $.extend({}, $.fn.affix.defaults, options)
- this.$window = $(window)
- .on('scroll.affix.data-api', $.proxy(this.checkPosition, this))
- .on('click.affix.data-api', $.proxy(function () { setTimeout($.proxy(this.checkPosition, this), 1) }, this))
- this.$element = $(element)
- this.checkPosition()
- }
-
- Affix.prototype.checkPosition = function () {
- if (!this.$element.is(':visible')) return
-
- var scrollHeight = $(document).height()
- , scrollTop = this.$window.scrollTop()
- , position = this.$element.offset()
- , offset = this.options.offset
- , offsetBottom = offset.bottom
- , offsetTop = offset.top
- , reset = 'affix affix-top affix-bottom'
- , affix
-
- if (typeof offset != 'object') offsetBottom = offsetTop = offset
- if (typeof offsetTop == 'function') offsetTop = offset.top()
- if (typeof offsetBottom == 'function') offsetBottom = offset.bottom()
-
- affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ?
- false : offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ?
- 'bottom' : offsetTop != null && scrollTop <= offsetTop ?
- 'top' : false
-
- if (this.affixed === affix) return
-
- this.affixed = affix
- this.unpin = affix == 'bottom' ? position.top - scrollTop : null
-
- this.$element.removeClass(reset).addClass('affix' + (affix ? '-' + affix : ''))
- }
-
-
- /* AFFIX PLUGIN DEFINITION
- * ======================= */
-
- $.fn.affix = function (option) {
- return this.each(function () {
- var $this = $(this)
- , data = $this.data('affix')
- , options = typeof option == 'object' && option
- if (!data) $this.data('affix', (data = new Affix(this, options)))
- if (typeof option == 'string') data[option]()
- })
- }
-
- $.fn.affix.Constructor = Affix
-
- $.fn.affix.defaults = {
- offset: 0
- }
-
-
- /* AFFIX DATA-API
- * ============== */
-
- $(window).on('load', function () {
- $('[data-spy="affix"]').each(function () {
- var $spy = $(this)
- , data = $spy.data()
-
- data.offset = data.offset || {}
-
- data.offsetBottom && (data.offset.bottom = data.offsetBottom)
- data.offsetTop && (data.offset.top = data.offsetTop)
-
- $spy.affix(data)
- })
- })
-
-
-}(window.jQuery);
\ No newline at end of file
[03/26] Remove fauxton from 1.4.x branch.
Posted by dj...@apache.org.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/test/mocha/testUtils.js
----------------------------------------------------------------------
diff --git a/src/fauxton/test/mocha/testUtils.js b/src/fauxton/test/mocha/testUtils.js
deleted file mode 100644
index 08b46de..0000000
--- a/src/fauxton/test/mocha/testUtils.js
+++ /dev/null
@@ -1,25 +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.
-
-define([
- "chai",
- "sinon-chai",
-],
-function(chai, sinonChai) {
- chai.use(sinonChai);
-
- return {
- chai: chai,
- assert: chai.assert
- };
-});
-
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/test/runner.html
----------------------------------------------------------------------
diff --git a/src/fauxton/test/runner.html b/src/fauxton/test/runner.html
deleted file mode 100644
index b86855e..0000000
--- a/src/fauxton/test/runner.html
+++ /dev/null
@@ -1,17 +0,0 @@
-<html>
- <head>
- <meta charset="utf-8">
- <title>testrunnner Fauxton</title>
- <link rel="stylesheet" href="mocha/mocha.css" />
- </head>
- <body>
- <div id="mocha"></div>
- <script type="text/javascript" src="mocha/mocha.js"></script>
- <script type="text/javascript" src="mocha/sinon.js"></script>
- <script type="text/javascript">
- // MOCHA SETUP
- mocha.setup('bdd');
- </script>
- <script data-main="./test.config.js" src="../assets/js/libs/require.js"></script>
- </body>
-</html>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/test/test.config.js
----------------------------------------------------------------------
diff --git a/src/fauxton/test/test.config.js b/src/fauxton/test/test.config.js
deleted file mode 100644
index f876bb3..0000000
--- a/src/fauxton/test/test.config.js
+++ /dev/null
@@ -1,71 +0,0 @@
-// vim: set ft=javascript:
-// Set the require.js configuration for your test setup.
-require.config(
-{
- "paths": {
- "libs": "../assets/js/libs",
- "plugins": "../assets/js/plugins",
- "jquery": "../assets/js/libs/jquery",
- "lodash": "../assets/js/libs/lodash",
- "backbone": "../assets/js/libs/backbone",
- "bootstrap": "../assets/js/libs/bootstrap",
- "codemirror": "../assets/js/libs/codemirror",
- "jshint": "../assets/js/libs/jshint",
- "d3": "../assets/js/libs/d3",
- "nv.d3": "../assets/js/libs/nv.d3",
- "chai": "../test/mocha/chai",
- "sinon-chai": "../test/mocha/sinon-chai",
- "testUtils": "../test/mocha/testUtils"
- },
- "baseUrl": "../app",
- "shim": {
- "backbone": {
- "deps": [
- "lodash",
- "jquery"
- ],
- "exports": "Backbone"
- },
- "bootstrap": {
- "deps": [
- "jquery"
- ],
- "exports": "Bootstrap"
- },
- "codemirror": {
- "deps": [
- "jquery"
- ],
- "exports": "CodeMirror"
- },
- "jshint": {
- "deps": [
- "jquery"
- ],
- "exports": "JSHINT"
- },
- "plugins/backbone.layoutmanager": [
- "backbone"
- ],
- "plugins/codemirror-javascript": [
- "codemirror"
- ],
- "plugins/prettify": [],
- "plugins/jquery.form": [
- "jquery"
- ]
- }
-}
-);
-
-require([
-
- '.././test/core/routeObjectSpec.js',
-
- '.././app/addons/logs/tests/logSpec.js',
-
-], function() {
- if (window.mochaPhantomJS) { mochaPhantomJS.run(); }
- else { mocha.run(); }
-});
-
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/test/test.config.underscore
----------------------------------------------------------------------
diff --git a/src/fauxton/test/test.config.underscore b/src/fauxton/test/test.config.underscore
deleted file mode 100644
index dda16f2..0000000
--- a/src/fauxton/test/test.config.underscore
+++ /dev/null
@@ -1,15 +0,0 @@
-// vim: set ft=javascript:
-// Set the require.js configuration for your test setup.
-require.config(
-<%= JSON.stringify(configInfo, null, '\t') %>
-);
-
-require([
- <% _.each(testFiles, function (test) {%>
- '../<%= test %>',
- <% }) %>
-], function() {
- if (window.mochaPhantomJS) { mochaPhantomJS.run(); }
- else { mocha.run(); }
-});
-
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/writing_addons.md
----------------------------------------------------------------------
diff --git a/src/fauxton/writing_addons.md b/src/fauxton/writing_addons.md
deleted file mode 100644
index e0a85fa..0000000
--- a/src/fauxton/writing_addons.md
+++ /dev/null
@@ -1,163 +0,0 @@
-# Addons
-Addons allow you to extend Fauxton for a specific use case. Addons will usually
-have the following structure:
-
- * templates/
- * my_addon.html - _underscore template fragments_
- * base.js - _entry point to the addon_
- * resources.js - _models and collections of the addon_
- * routes.js - _URL routing for the addon_
- * views.js - _views that the model provides_
-
- [optional]
- * assets/less
- * my_addon.less
-
-## Generating an addon
-We have a `grunt-init` template that lets you create a skeleton addon,
-including all the boiler plate code. Run `grunt-init tasks/addon` and answer
-the questions it asks to create an addon:
-
- Ā± grunt-init tasks/addon
- path.existsSync is now called `fs.existsSync`.
- Running "addon" task
-
- Please answer the following:
- [?] Add on Name (WickedCool) SuperAddon
- [?] Location of add ons (app/addons)
- [?] Do you need an assets folder?(for .less) (y/N)
- [?] Do you need to make any changes to the above before continuing? (y/N)
-
- Created addon SuperAddon in app/addons
-
- Done, without errors.
-
-Once the addon is created add the name to the settings.json file to get it
-compiled and added on the next install.
-
-## Routes and hooks
-An addon can insert itself into fauxton in two ways; via a route or via a hook.
-
-### Routes
-An addon will override an existing route should one exist, but in all other
-ways is just a normal backbone route/view. This is how you would add a whole
-new feature.
-
-### Hooks
-Hooks let you modify/extend an existing feature. They modify a DOM element by
-selector for a named set of routes, for example:
-
- var Search = new FauxtonAPI.addon();
- Search.hooks = {
- // Render additional content into the sidebar
- "#sidebar-content": {
- routes:[
- "database/:database/_design/:ddoc/_search/:search",
- "database/:database/_design/:ddoc/_view/:view",
- "database/:database/_:handler"],
- callback: searchSidebar
- }
- };
- return Search;
-
-adds the `searchSidebar` callback to `#sidebar-content` for three routes.
-
-## Hello world addon
-First create the addon skeleton:
-
- Ā± bbb addon
- path.existsSync is now called `fs.existsSync`.
- Running "addon" task
-
- Please answer the following:
- [?] Add on Name (WickedCool) Hello
- [?] Location of add ons (app/addons)
- [?] Do you need to make any changes to the above before continuing? (y/N)
-
- Created addon Hello in app/addons
-
- Done, without errors.
-
-In `app/addons/hello/templates/hello.html` place:
-
- <h1>Hello!</h1>
-
-Next, we'll defined a simple view in `resources.js` (for more complex addons
-you may want to have a views.js) that renders that template:
-
- define([
- "app",
- "api"
- ],
-
- function (app, FauxtonAPI) {
- var Resources = {};
-
- Resources.Hello = FauxtonAPI.View.extend({
- template: "addons/hello/templates/hello"
- });
-
- return Resources;
- });
-
-
-Then define a route in `routes.js` that the addon is accessible at:
-
- define([
- "app",
- "api",
- "addons/hello/resources"
- ],
-
- function(app, FauxtonAPI, Resources) {
- var helloRoute = function () {
- console.log('helloRoute callback yo');
- return {
- layout: "one_pane",
- crumbs: [
- {"name": "Hello","link": "_hello"}
- ],
- views: {
- "#dashboard-content": new Resources.Hello({})
- },
- apiUrl: 'hello'
- };
- };
-
- Routes = {
- "_hello": helloRoute
- };
-
- return Routes;
- });
-
-
-Then wire it all together in base.js:
-
- define([
- "app",
- "api",
- "addons/hello/routes"
- ],
-
- function(app, FauxtonAPI, HelloRoutes) {
- var Hello = new FauxtonAPI.addon();
- console.log('hello from hello');
-
- Hello.initialize = function() {
- FauxtonAPI.addHeaderLink({title: "Hello", href: "#_hello"});
- };
-
- Hello.Routes = HelloRoutes;
- console.log(Hello);
- return Hello;
- });
-
-Once the code is in place include the add on in your `settings.json` so that it
-gets included by the `require` task. Your addon is included in one of three
-ways; a local path, a git URL or a name. Named plugins assume the plugin is in
-the fauxton base directory, addons with a git URL will be cloned into the
-application, local paths will be copied. Addons included from a local path will
-be cleaned out by the clean task, others are left alone.
-
-**TODO:** addons via npm module
[15/26] Remove fauxton from 1.4.x branch.
Posted by dj...@apache.org.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/js/libs/lodash.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/lodash.js b/src/fauxton/assets/js/libs/lodash.js
deleted file mode 100644
index ccf632d..0000000
--- a/src/fauxton/assets/js/libs/lodash.js
+++ /dev/null
@@ -1,4355 +0,0 @@
-/**
- * @license
- * Lo-Dash 1.1.1 (Custom Build) <http://lodash.com/>
- * Build: `lodash underscore exports="amd,commonjs,global,node" -o ./dist/lodash.underscore.js`
- * Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
- * Based on Underscore.js 1.4.4 <http://underscorejs.org/>
- * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud Inc.
- * Available under MIT license <http://lodash.com/license>
- */
-;(function(window) {
-
- /** Used as a safe reference for `undefined` in pre ES5 environments */
- var undefined;
-
- /** Detect free variable `exports` */
- var freeExports = typeof exports == 'object' && exports;
-
- /** Detect free variable `module` */
- var freeModule = typeof module == 'object' && module && module.exports == freeExports && module;
-
- /** Detect free variable `global` and use it as `window` */
- var freeGlobal = typeof global == 'object' && global;
- if (freeGlobal.global === freeGlobal) {
- window = freeGlobal;
- }
-
- /** Used to generate unique IDs */
- var idCounter = 0;
-
- /** Used internally to indicate various things */
- var indicatorObject = {};
-
- /** Used to match empty string literals in compiled template source */
- var reEmptyStringLeading = /\b__p \+= '';/g,
- reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
- reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
-
- /** Used to match HTML entities */
- var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g;
-
- /**
- * Used to match ES6 template delimiters
- * http://people.mozilla.org/~jorendorff/es6-draft.html#sec-7.8.6
- */
- var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
-
- /** Used to match regexp flags from their coerced string values */
- var reFlags = /\w*$/;
-
- /** Used to match "interpolate" template delimiters */
- var reInterpolate = /<%=([\s\S]+?)%>/g;
-
- /** Used to ensure capturing order of template delimiters */
- var reNoMatch = /($^)/;
-
- /** Used to match HTML characters */
- var reUnescapedHtml = /[&<>"']/g;
-
- /** Used to match unescaped characters in compiled string literals */
- var reUnescapedString = /['\n\r\t\u2028\u2029\\]/g;
-
- /** Used to make template sourceURLs easier to identify */
- var templateCounter = 0;
-
- /** `Object#toString` result shortcuts */
- var argsClass = '[object Arguments]',
- arrayClass = '[object Array]',
- boolClass = '[object Boolean]',
- dateClass = '[object Date]',
- funcClass = '[object Function]',
- numberClass = '[object Number]',
- objectClass = '[object Object]',
- regexpClass = '[object RegExp]',
- stringClass = '[object String]';
-
- /** Used to determine if values are of the language type Object */
- var objectTypes = {
- 'boolean': false,
- 'function': true,
- 'object': true,
- 'number': false,
- 'string': false,
- 'undefined': false
- };
-
- /** Used to escape characters for inclusion in compiled string literals */
- var stringEscapes = {
- '\\': '\\',
- "'": "'",
- '\n': 'n',
- '\r': 'r',
- '\t': 't',
- '\u2028': 'u2028',
- '\u2029': 'u2029'
- };
-
- /*--------------------------------------------------------------------------*/
-
- /** Used for `Array` and `Object` method references */
- var arrayRef = Array(),
- objectRef = Object();
-
- /** Used to restore the original `_` reference in `noConflict` */
- var oldDash = window._;
-
- /** Used to detect if a method is native */
- var reNative = RegExp('^' +
- String(objectRef.valueOf)
- .replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
- .replace(/valueOf|for [^\]]+/g, '.+?') + '$'
- );
-
- /** Native method shortcuts */
- var ceil = Math.ceil,
- clearTimeout = window.clearTimeout,
- concat = arrayRef.concat,
- floor = Math.floor,
- hasOwnProperty = objectRef.hasOwnProperty,
- push = arrayRef.push,
- setTimeout = window.setTimeout,
- slice = arrayRef.slice,
- toString = objectRef.toString;
-
- /* Native method shortcuts for methods with the same name as other `lodash` methods */
- var nativeBind = reNative.test(nativeBind = slice.bind) && nativeBind,
- nativeIsArray = reNative.test(nativeIsArray = Array.isArray) && nativeIsArray,
- nativeIsFinite = window.isFinite,
- nativeIsNaN = window.isNaN,
- nativeKeys = reNative.test(nativeKeys = Object.keys) && nativeKeys,
- nativeMax = Math.max,
- nativeMin = Math.min,
- nativeRandom = Math.random;
-
- /** Detect various environments */
- var isIeOpera = reNative.test(window.attachEvent),
- isV8 = nativeBind && !/\n|true/.test(nativeBind + isIeOpera);
-
- /*--------------------------------------------------------------------------*/
-
- /**
- * Creates a `lodash` object, that wraps the given `value`, to enable method
- * chaining.
- *
- * In addition to Lo-Dash methods, wrappers also have the following `Array` methods:
- * `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`, `splice`,
- * and `unshift`
- *
- * Chaining is supported in custom builds as long as the `value` method is
- * implicitly or explicitly included in the build.
- *
- * The chainable wrapper functions are:
- * `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`,
- * `compose`, `concat`, `countBy`, `createCallback`, `debounce`, `defaults`,
- * `defer`, `delay`, `difference`, `filter`, `flatten`, `forEach`, `forIn`,
- * `forOwn`, `functions`, `groupBy`, `initial`, `intersection`, `invert`,
- * `invoke`, `keys`, `map`, `max`, `memoize`, `merge`, `min`, `object`, `omit`,
- * `once`, `pairs`, `partial`, `partialRight`, `pick`, `pluck`, `push`, `range`,
- * `reject`, `rest`, `reverse`, `shuffle`, `slice`, `sort`, `sortBy`, `splice`,
- * `tap`, `throttle`, `times`, `toArray`, `union`, `uniq`, `unshift`, `values`,
- * `where`, `without`, `wrap`, and `zip`
- *
- * The non-chainable wrapper functions are:
- * `clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `has`,
- * `identity`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`,
- * `isElement`, `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`,
- * `isNull`, `isNumber`, `isObject`, `isPlainObject`, `isRegExp`, `isString`,
- * `isUndefined`, `join`, `lastIndexOf`, `mixin`, `noConflict`, `parseInt`,
- * `pop`, `random`, `reduce`, `reduceRight`, `result`, `shift`, `size`, `some`,
- * `sortedIndex`, `runInContext`, `template`, `unescape`, `uniqueId`, and `value`
- *
- * The wrapper functions `first` and `last` return wrapped values when `n` is
- * passed, otherwise they return unwrapped values.
- *
- * @name _
- * @constructor
- * @category Chaining
- * @param {Mixed} value The value to wrap in a `lodash` instance.
- * @returns {Object} Returns a `lodash` instance.
- */
- function lodash(value) {
- return (value instanceof lodash)
- ? value
- : new lodashWrapper(value);
- }
-
- /**
- * An object used to flag environments features.
- *
- * @static
- * @memberOf _
- * @type Object
- */
- var support = {};
-
- (function() {
- var object = { '0': 1, 'length': 1 };
-
- /**
- * Detect if `arguments` objects are `Object` objects (all but Opera < 10.5).
- *
- * @memberOf _.support
- * @type Boolean
- */
- support.argsObject = arguments.constructor == Object;
-
- /**
- * Detect if `Function#bind` exists and is inferred to be fast (all but V8).
- *
- * @memberOf _.support
- * @type Boolean
- */
- support.fastBind = nativeBind && !isV8;
-
- /**
- * Detect if `Array#shift` and `Array#splice` augment array-like objects correctly.
- *
- * Firefox < 10, IE compatibility mode, and IE < 9 have buggy Array `shift()`
- * and `splice()` functions that fail to remove the last element, `value[0]`,
- * of array-like objects even though the `length` property is set to `0`.
- * The `shift()` method is buggy in IE 8 compatibility mode, while `splice()`
- * is buggy regardless of mode in IE < 9 and buggy in compatibility mode in IE 9.
- *
- * @memberOf _.support
- * @type Boolean
- */
- support.spliceObjects = (arrayRef.splice.call(object, 0, 1), !object[0]);
- }(1));
-
- /**
- * By default, the template delimiters used by Lo-Dash are similar to those in
- * embedded Ruby (ERB). Change the following template settings to use alternative
- * delimiters.
- *
- * @static
- * @memberOf _
- * @type Object
- */
- lodash.templateSettings = {
-
- /**
- * Used to detect `data` property values to be HTML-escaped.
- *
- * @memberOf _.templateSettings
- * @type RegExp
- */
- 'escape': /<%-([\s\S]+?)%>/g,
-
- /**
- * Used to detect code to be evaluated.
- *
- * @memberOf _.templateSettings
- * @type RegExp
- */
- 'evaluate': /<%([\s\S]+?)%>/g,
-
- /**
- * Used to detect `data` property values to inject.
- *
- * @memberOf _.templateSettings
- * @type RegExp
- */
- 'interpolate': reInterpolate,
-
- /**
- * Used to reference the data object in the template text.
- *
- * @memberOf _.templateSettings
- * @type String
- */
- 'variable': ''
- };
-
- /*--------------------------------------------------------------------------*/
-
- /**
- * Used by `_.max` and `_.min` as the default `callback` when a given
- * `collection` is a string value.
- *
- * @private
- * @param {String} value The character to inspect.
- * @returns {Number} Returns the code unit of given character.
- */
- function charAtCallback(value) {
- return value.charCodeAt(0);
- }
-
- /**
- * Used by `sortBy` to compare transformed `collection` values, stable sorting
- * them in ascending order.
- *
- * @private
- * @param {Object} a The object to compare to `b`.
- * @param {Object} b The object to compare to `a`.
- * @returns {Number} Returns the sort order indicator of `1` or `-1`.
- */
- function compareAscending(a, b) {
- var ai = a.index,
- bi = b.index;
-
- a = a.criteria;
- b = b.criteria;
-
- // ensure a stable sort in V8 and other engines
- // http://code.google.com/p/v8/issues/detail?id=90
- if (a !== b) {
- if (a > b || typeof a == 'undefined') {
- return 1;
- }
- if (a < b || typeof b == 'undefined') {
- return -1;
- }
- }
- return ai < bi ? -1 : 1;
- }
-
- /**
- * Creates a function that, when called, invokes `func` with the `this` binding
- * of `thisArg` and prepends any `partialArgs` to the arguments passed to the
- * bound function.
- *
- * @private
- * @param {Function|String} func The function to bind or the method name.
- * @param {Mixed} [thisArg] The `this` binding of `func`.
- * @param {Array} partialArgs An array of arguments to be partially applied.
- * @param {Object} [idicator] Used to indicate binding by key or partially
- * applying arguments from the right.
- * @returns {Function} Returns the new bound function.
- */
- function createBound(func, thisArg, partialArgs, indicator) {
- var isFunc = isFunction(func),
- isPartial = !partialArgs,
- key = thisArg;
-
- // juggle arguments
- if (isPartial) {
- var rightIndicator = indicator;
- partialArgs = thisArg;
- }
- else if (!isFunc) {
- if (!indicator) {
- throw new TypeError;
- }
- thisArg = func;
- }
-
- function bound() {
- // `Function#bind` spec
- // http://es5.github.com/#x15.3.4.5
- var args = arguments,
- thisBinding = isPartial ? this : thisArg;
-
- if (!isFunc) {
- func = thisArg[key];
- }
- if (partialArgs.length) {
- args = args.length
- ? (args = slice.call(args), rightIndicator ? args.concat(partialArgs) : partialArgs.concat(args))
- : partialArgs;
- }
- if (this instanceof bound) {
- // ensure `new bound` is an instance of `func`
- noop.prototype = func.prototype;
- thisBinding = new noop;
- noop.prototype = null;
-
- // mimic the constructor's `return` behavior
- // http://es5.github.com/#x13.2.2
- var result = func.apply(thisBinding, args);
- return isObject(result) ? result : thisBinding;
- }
- return func.apply(thisBinding, args);
- }
- return bound;
- }
-
- /**
- * Used by `template` to escape characters for inclusion in compiled
- * string literals.
- *
- * @private
- * @param {String} match The matched character to escape.
- * @returns {String} Returns the escaped character.
- */
- function escapeStringChar(match) {
- return '\\' + stringEscapes[match];
- }
-
- /**
- * Used by `escape` to convert characters to HTML entities.
- *
- * @private
- * @param {String} match The matched character to escape.
- * @returns {String} Returns the escaped character.
- */
- function escapeHtmlChar(match) {
- return htmlEscapes[match];
- }
-
- /**
- * A fast path for creating `lodash` wrapper objects.
- *
- * @private
- * @param {Mixed} value The value to wrap in a `lodash` instance.
- * @returns {Object} Returns a `lodash` instance.
- */
- function lodashWrapper(value) {
- this.__wrapped__ = value;
- }
- // ensure `new lodashWrapper` is an instance of `lodash`
- lodashWrapper.prototype = lodash.prototype;
-
- /**
- * A no-operation function.
- *
- * @private
- */
- function noop() {
- // no operation performed
- }
-
- /**
- * Used by `unescape` to convert HTML entities to characters.
- *
- * @private
- * @param {String} match The matched character to unescape.
- * @returns {String} Returns the unescaped character.
- */
- function unescapeHtmlChar(match) {
- return htmlUnescapes[match];
- }
-
- /*--------------------------------------------------------------------------*/
-
- /**
- * Checks if `value` is an `arguments` object.
- *
- * @static
- * @memberOf _
- * @category Objects
- * @param {Mixed} value The value to check.
- * @returns {Boolean} Returns `true`, if the `value` is an `arguments` object, else `false`.
- * @example
- *
- * (function() { return _.isArguments(arguments); })(1, 2, 3);
- * // => true
- *
- * _.isArguments([1, 2, 3]);
- * // => false
- */
- function isArguments(value) {
- return toString.call(value) == argsClass;
- }
- // fallback for browsers that can't detect `arguments` objects by [[Class]]
- if (!isArguments(arguments)) {
- isArguments = function(value) {
- return value ? hasOwnProperty.call(value, 'callee') : false;
- };
- }
-
- /**
- * Checks if `value` is an array.
- *
- * @static
- * @memberOf _
- * @category Objects
- * @param {Mixed} value The value to check.
- * @returns {Boolean} Returns `true`, if the `value` is an array, else `false`.
- * @example
- *
- * (function() { return _.isArray(arguments); })();
- * // => false
- *
- * _.isArray([1, 2, 3]);
- * // => true
- */
- var isArray = nativeIsArray || function(value) {
- // `instanceof` may cause a memory leak in IE 7 if `value` is a host object
- // http://ajaxian.com/archives/working-aroung-the-instanceof-memory-leak
- return (support.argsObject && value instanceof Array) || toString.call(value) == arrayClass;
- };
-
- /**
- * A fallback implementation of `Object.keys` that produces an array of the
- * given object's own enumerable property names.
- *
- * @private
- * @type Function
- * @param {Object} object The object to inspect.
- * @returns {Array} Returns a new array of property names.
- */
- var shimKeys = function (object) {
- var index, iterable = object, result = [];
- if (!iterable) return result;
- if (!(objectTypes[typeof object])) return result;
-
- for (index in iterable) {
- if (hasOwnProperty.call(iterable, index)) {
- result.push(index);
- }
- }
- return result
- };
-
- /**
- * Creates an array composed of the own enumerable property names of `object`.
- *
- * @static
- * @memberOf _
- * @category Objects
- * @param {Object} object The object to inspect.
- * @returns {Array} Returns a new array of property names.
- * @example
- *
- * _.keys({ 'one': 1, 'two': 2, 'three': 3 });
- * // => ['one', 'two', 'three'] (order is not guaranteed)
- */
- var keys = !nativeKeys ? shimKeys : function(object) {
- if (!isObject(object)) {
- return [];
- }
- return nativeKeys(object);
- };
-
- /**
- * Used to convert characters to HTML entities:
- *
- * Though the `>` character is escaped for symmetry, characters like `>` and `/`
- * don't require escaping in HTML and have no special meaning unless they're part
- * of a tag or an unquoted attribute value.
- * http://mathiasbynens.be/notes/ambiguous-ampersands (under "semi-related fun fact")
- */
- var htmlEscapes = {
- '&': '&',
- '<': '<',
- '>': '>',
- '"': '"',
- "'": '''
- };
-
- /** Used to convert HTML entities to characters */
- var htmlUnescapes = invert(htmlEscapes);
-
- /*--------------------------------------------------------------------------*/
-
- /**
- * Assigns own enumerable properties of source object(s) to the destination
- * object. Subsequent sources will overwrite property assignments of previous
- * sources. If a `callback` function is passed, it will be executed to produce
- * the assigned values. The `callback` is bound to `thisArg` and invoked with
- * two arguments; (objectValue, sourceValue).
- *
- * @static
- * @memberOf _
- * @type Function
- * @alias extend
- * @category Objects
- * @param {Object} object The destination object.
- * @param {Object} [source1, source2, ...] The source objects.
- * @param {Function} [callback] The function to customize assigning values.
- * @param {Mixed} [thisArg] The `this` binding of `callback`.
- * @returns {Object} Returns the destination object.
- * @example
- *
- * _.assign({ 'name': 'moe' }, { 'age': 40 });
- * // => { 'name': 'moe', 'age': 40 }
- *
- * var defaults = _.partialRight(_.assign, function(a, b) {
- * return typeof a == 'undefined' ? b : a;
- * });
- *
- * var food = { 'name': 'apple' };
- * defaults(food, { 'name': 'banana', 'type': 'fruit' });
- * // => { 'name': 'apple', 'type': 'fruit' }
- */
- function assign(object) {
- if (!object) {
- return object;
- }
- for (var argsIndex = 1, argsLength = arguments.length; argsIndex < argsLength; argsIndex++) {
- var iterable = arguments[argsIndex];
- if (iterable) {
- for (var key in iterable) {
- object[key] = iterable[key];
- }
- }
- }
- return object;
- }
-
- /**
- * Creates a clone of `value`. If `deep` is `true`, nested objects will also
- * be cloned, otherwise they will be assigned by reference. If a `callback`
- * function is passed, it will be executed to produce the cloned values. If
- * `callback` returns `undefined`, cloning will be handled by the method instead.
- * The `callback` is bound to `thisArg` and invoked with one argument; (value).
- *
- * @static
- * @memberOf _
- * @category Objects
- * @param {Mixed} value The value to clone.
- * @param {Boolean} [deep=false] A flag to indicate a deep clone.
- * @param {Function} [callback] The function to customize cloning values.
- * @param {Mixed} [thisArg] The `this` binding of `callback`.
- * @param- {Array} [stackA=[]] Tracks traversed source objects.
- * @param- {Array} [stackB=[]] Associates clones with source counterparts.
- * @returns {Mixed} Returns the cloned `value`.
- * @example
- *
- * var stooges = [
- * { 'name': 'moe', 'age': 40 },
- * { 'name': 'larry', 'age': 50 }
- * ];
- *
- * var shallow = _.clone(stooges);
- * shallow[0] === stooges[0];
- * // => true
- *
- * var deep = _.clone(stooges, true);
- * deep[0] === stooges[0];
- * // => false
- *
- * _.mixin({
- * 'clone': _.partialRight(_.clone, function(value) {
- * return _.isElement(value) ? value.cloneNode(false) : undefined;
- * })
- * });
- *
- * var clone = _.clone(document.body);
- * clone.childNodes.length;
- * // => 0
- */
- function clone(value) {
- return isObject(value)
- ? (isArray(value) ? slice.call(value) : assign({}, value))
- : value;
- }
-
- /**
- * Assigns own enumerable properties of source object(s) to the destination
- * object for all destination properties that resolve to `undefined`. Once a
- * property is set, additional defaults of the same property will be ignored.
- *
- * @static
- * @memberOf _
- * @type Function
- * @category Objects
- * @param {Object} object The destination object.
- * @param {Object} [source1, source2, ...] The source objects.
- * @param- {Object} [guard] Allows working with `_.reduce` without using its
- * callback's `key` and `object` arguments as sources.
- * @returns {Object} Returns the destination object.
- * @example
- *
- * var food = { 'name': 'apple' };
- * _.defaults(food, { 'name': 'banana', 'type': 'fruit' });
- * // => { 'name': 'apple', 'type': 'fruit' }
- */
- function defaults(object) {
- if (!object) {
- return object;
- }
- for (var argsIndex = 1, argsLength = arguments.length; argsIndex < argsLength; argsIndex++) {
- var iterable = arguments[argsIndex];
- if (iterable) {
- for (var key in iterable) {
- if (object[key] == null) {
- object[key] = iterable[key];
- }
- }
- }
- }
- return object;
- }
-
- /**
- * Iterates over `object`'s own and inherited enumerable properties, executing
- * the `callback` for each property. The `callback` is bound to `thisArg` and
- * invoked with three arguments; (value, key, object). Callbacks may exit iteration
- * early by explicitly returning `false`.
- *
- * @static
- * @memberOf _
- * @type Function
- * @category Objects
- * @param {Object} object The object to iterate over.
- * @param {Function} [callback=identity] The function called per iteration.
- * @param {Mixed} [thisArg] The `this` binding of `callback`.
- * @returns {Object} Returns `object`.
- * @example
- *
- * function Dog(name) {
- * this.name = name;
- * }
- *
- * Dog.prototype.bark = function() {
- * alert('Woof, woof!');
- * };
- *
- * _.forIn(new Dog('Dagny'), function(value, key) {
- * alert(key);
- * });
- * // => alerts 'name' and 'bark' (order is not guaranteed)
- */
- var forIn = function (collection, callback) {
- var index, iterable = collection, result = iterable;
- if (!iterable) return result;
- if (!objectTypes[typeof iterable]) return result;
-
- for (index in iterable) {
- if (callback(iterable[index], index, collection) === indicatorObject) return result;
- }
- return result
- };
-
- /**
- * Iterates over an object's own enumerable properties, executing the `callback`
- * for each property. The `callback` is bound to `thisArg` and invoked with three
- * arguments; (value, key, object). Callbacks may exit iteration early by explicitly
- * returning `false`.
- *
- * @static
- * @memberOf _
- * @type Function
- * @category Objects
- * @param {Object} object The object to iterate over.
- * @param {Function} [callback=identity] The function called per iteration.
- * @param {Mixed} [thisArg] The `this` binding of `callback`.
- * @returns {Object} Returns `object`.
- * @example
- *
- * _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) {
- * alert(key);
- * });
- * // => alerts '0', '1', and 'length' (order is not guaranteed)
- */
- var forOwn = function (collection, callback) {
- var index, iterable = collection, result = iterable;
- if (!iterable) return result;
- if (!objectTypes[typeof iterable]) return result;
-
- for (index in iterable) {
- if (hasOwnProperty.call(iterable, index)) {
- if (callback(iterable[index], index, collection) === indicatorObject) return result;
- }
- }
- return result
- };
-
- /**
- * Creates a sorted array of all enumerable properties, own and inherited,
- * of `object` that have function values.
- *
- * @static
- * @memberOf _
- * @alias methods
- * @category Objects
- * @param {Object} object The object to inspect.
- * @returns {Array} Returns a new array of property names that have function values.
- * @example
- *
- * _.functions(_);
- * // => ['all', 'any', 'bind', 'bindAll', 'clone', 'compact', 'compose', ...]
- */
- function functions(object) {
- var result = [];
- forIn(object, function(value, key) {
- if (isFunction(value)) {
- result.push(key);
- }
- });
- return result.sort();
- }
-
- /**
- * Checks if the specified object `property` exists and is a direct property,
- * instead of an inherited property.
- *
- * @static
- * @memberOf _
- * @category Objects
- * @param {Object} object The object to check.
- * @param {String} property The property to check for.
- * @returns {Boolean} Returns `true` if key is a direct property, else `false`.
- * @example
- *
- * _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b');
- * // => true
- */
- function has(object, property) {
- return object ? hasOwnProperty.call(object, property) : false;
- }
-
- /**
- * Creates an object composed of the inverted keys and values of the given `object`.
- *
- * @static
- * @memberOf _
- * @category Objects
- * @param {Object} object The object to invert.
- * @returns {Object} Returns the created inverted object.
- * @example
- *
- * _.invert({ 'first': 'moe', 'second': 'larry' });
- * // => { 'moe': 'first', 'larry': 'second' }
- */
- function invert(object) {
- var index = -1,
- props = keys(object),
- length = props.length,
- result = {};
-
- while (++index < length) {
- var key = props[index];
- result[object[key]] = key;
- }
- return result;
- }
-
- /**
- * Checks if `value` is a boolean value.
- *
- * @static
- * @memberOf _
- * @category Objects
- * @param {Mixed} value The value to check.
- * @returns {Boolean} Returns `true`, if the `value` is a boolean value, else `false`.
- * @example
- *
- * _.isBoolean(null);
- * // => false
- */
- function isBoolean(value) {
- return value === true || value === false || toString.call(value) == boolClass;
- }
-
- /**
- * Checks if `value` is a date.
- *
- * @static
- * @memberOf _
- * @category Objects
- * @param {Mixed} value The value to check.
- * @returns {Boolean} Returns `true`, if the `value` is a date, else `false`.
- * @example
- *
- * _.isDate(new Date);
- * // => true
- */
- function isDate(value) {
- return value instanceof Date || toString.call(value) == dateClass;
- }
-
- /**
- * Checks if `value` is a DOM element.
- *
- * @static
- * @memberOf _
- * @category Objects
- * @param {Mixed} value The value to check.
- * @returns {Boolean} Returns `true`, if the `value` is a DOM element, else `false`.
- * @example
- *
- * _.isElement(document.body);
- * // => true
- */
- function isElement(value) {
- return value ? value.nodeType === 1 : false;
- }
-
- /**
- * Checks if `value` is empty. Arrays, strings, or `arguments` objects with a
- * length of `0` and objects with no own enumerable properties are considered
- * "empty".
- *
- * @static
- * @memberOf _
- * @category Objects
- * @param {Array|Object|String} value The value to inspect.
- * @returns {Boolean} Returns `true`, if the `value` is empty, else `false`.
- * @example
- *
- * _.isEmpty([1, 2, 3]);
- * // => false
- *
- * _.isEmpty({});
- * // => true
- *
- * _.isEmpty('');
- * // => true
- */
- function isEmpty(value) {
- if (!value) {
- return true;
- }
- if (isArray(value) || isString(value)) {
- return !value.length;
- }
- for (var key in value) {
- if (hasOwnProperty.call(value, key)) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Performs a deep comparison between two values to determine if they are
- * equivalent to each other. If `callback` is passed, it will be executed to
- * compare values. If `callback` returns `undefined`, comparisons will be handled
- * by the method instead. The `callback` is bound to `thisArg` and invoked with
- * two arguments; (a, b).
- *
- * @static
- * @memberOf _
- * @category Objects
- * @param {Mixed} a The value to compare.
- * @param {Mixed} b The other value to compare.
- * @param {Function} [callback] The function to customize comparing values.
- * @param {Mixed} [thisArg] The `this` binding of `callback`.
- * @param- {Array} [stackA=[]] Tracks traversed `a` objects.
- * @param- {Array} [stackB=[]] Tracks traversed `b` objects.
- * @returns {Boolean} Returns `true`, if the values are equivalent, else `false`.
- * @example
- *
- * var moe = { 'name': 'moe', 'age': 40 };
- * var copy = { 'name': 'moe', 'age': 40 };
- *
- * moe == copy;
- * // => false
- *
- * _.isEqual(moe, copy);
- * // => true
- *
- * var words = ['hello', 'goodbye'];
- * var otherWords = ['hi', 'goodbye'];
- *
- * _.isEqual(words, otherWords, function(a, b) {
- * var reGreet = /^(?:hello|hi)$/i,
- * aGreet = _.isString(a) && reGreet.test(a),
- * bGreet = _.isString(b) && reGreet.test(b);
- *
- * return (aGreet || bGreet) ? (aGreet == bGreet) : undefined;
- * });
- * // => true
- */
- function isEqual(a, b, stackA, stackB) {
- if (a === b) {
- return a !== 0 || (1 / a == 1 / b);
- }
- var type = typeof a,
- otherType = typeof b;
-
- if (a === a &&
- (!a || (type != 'function' && type != 'object')) &&
- (!b || (otherType != 'function' && otherType != 'object'))) {
- return false;
- }
- if (a == null || b == null) {
- return a === b;
- }
- var className = toString.call(a),
- otherClass = toString.call(b);
-
- if (className != otherClass) {
- return false;
- }
- switch (className) {
- case boolClass:
- case dateClass:
- return +a == +b;
-
- case numberClass:
- return a != +a
- ? b != +b
- : (a == 0 ? (1 / a == 1 / b) : a == +b);
-
- case regexpClass:
- case stringClass:
- return a == String(b);
- }
- var isArr = className == arrayClass;
- if (!isArr) {
- if (a instanceof lodash || b instanceof lodash) {
- return isEqual(a.__wrapped__ || a, b.__wrapped__ || b, stackA, stackB);
- }
- if (className != objectClass) {
- return false;
- }
- var ctorA = a.constructor,
- ctorB = b.constructor;
-
- if (ctorA != ctorB && !(
- isFunction(ctorA) && ctorA instanceof ctorA &&
- isFunction(ctorB) && ctorB instanceof ctorB
- )) {
- return false;
- }
- }
- stackA || (stackA = []);
- stackB || (stackB = []);
-
- var length = stackA.length;
- while (length--) {
- if (stackA[length] == a) {
- return stackB[length] == b;
- }
- }
- var result = true,
- size = 0;
-
- stackA.push(a);
- stackB.push(b);
-
- if (isArr) {
- size = b.length;
- result = size == a.length;
-
- if (result) {
- while (size--) {
- if (!(result = isEqual(a[size], b[size], stackA, stackB))) {
- break;
- }
- }
- }
- return result;
- }
- forIn(b, function(value, key, b) {
- if (hasOwnProperty.call(b, key)) {
- size++;
- return !(result = hasOwnProperty.call(a, key) && isEqual(a[key], value, stackA, stackB)) && indicatorObject;
- }
- });
-
- if (result) {
- forIn(a, function(value, key, a) {
- if (hasOwnProperty.call(a, key)) {
- return !(result = --size > -1) && indicatorObject;
- }
- });
- }
- return result;
- }
-
- /**
- * Checks if `value` is, or can be coerced to, a finite number.
- *
- * Note: This is not the same as native `isFinite`, which will return true for
- * booleans and empty strings. See http://es5.github.com/#x15.1.2.5.
- *
- * @static
- * @memberOf _
- * @category Objects
- * @param {Mixed} value The value to check.
- * @returns {Boolean} Returns `true`, if the `value` is finite, else `false`.
- * @example
- *
- * _.isFinite(-101);
- * // => true
- *
- * _.isFinite('10');
- * // => true
- *
- * _.isFinite(true);
- * // => false
- *
- * _.isFinite('');
- * // => false
- *
- * _.isFinite(Infinity);
- * // => false
- */
- function isFinite(value) {
- return nativeIsFinite(value) && !nativeIsNaN(parseFloat(value));
- }
-
- /**
- * Checks if `value` is a function.
- *
- * @static
- * @memberOf _
- * @category Objects
- * @param {Mixed} value The value to check.
- * @returns {Boolean} Returns `true`, if the `value` is a function, else `false`.
- * @example
- *
- * _.isFunction(_);
- * // => true
- */
- function isFunction(value) {
- return typeof value == 'function';
- }
- // fallback for older versions of Chrome and Safari
- if (isFunction(/x/)) {
- isFunction = function(value) {
- return value instanceof Function || toString.call(value) == funcClass;
- };
- }
-
- /**
- * Checks if `value` is the language type of Object.
- * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
- *
- * @static
- * @memberOf _
- * @category Objects
- * @param {Mixed} value The value to check.
- * @returns {Boolean} Returns `true`, if the `value` is an object, else `false`.
- * @example
- *
- * _.isObject({});
- * // => true
- *
- * _.isObject([1, 2, 3]);
- * // => true
- *
- * _.isObject(1);
- * // => false
- */
- function isObject(value) {
- // check if the value is the ECMAScript language type of Object
- // http://es5.github.com/#x8
- // and avoid a V8 bug
- // http://code.google.com/p/v8/issues/detail?id=2291
- return value ? objectTypes[typeof value] : false;
- }
-
- /**
- * Checks if `value` is `NaN`.
- *
- * Note: This is not the same as native `isNaN`, which will return `true` for
- * `undefined` and other values. See http://es5.github.com/#x15.1.2.4.
- *
- * @static
- * @memberOf _
- * @category Objects
- * @param {Mixed} value The value to check.
- * @returns {Boolean} Returns `true`, if the `value` is `NaN`, else `false`.
- * @example
- *
- * _.isNaN(NaN);
- * // => true
- *
- * _.isNaN(new Number(NaN));
- * // => true
- *
- * isNaN(undefined);
- * // => true
- *
- * _.isNaN(undefined);
- * // => false
- */
- function isNaN(value) {
- // `NaN` as a primitive is the only value that is not equal to itself
- // (perform the [[Class]] check first to avoid errors with some host objects in IE)
- return isNumber(value) && value != +value
- }
-
- /**
- * Checks if `value` is `null`.
- *
- * @static
- * @memberOf _
- * @category Objects
- * @param {Mixed} value The value to check.
- * @returns {Boolean} Returns `true`, if the `value` is `null`, else `false`.
- * @example
- *
- * _.isNull(null);
- * // => true
- *
- * _.isNull(undefined);
- * // => false
- */
- function isNull(value) {
- return value === null;
- }
-
- /**
- * Checks if `value` is a number.
- *
- * @static
- * @memberOf _
- * @category Objects
- * @param {Mixed} value The value to check.
- * @returns {Boolean} Returns `true`, if the `value` is a number, else `false`.
- * @example
- *
- * _.isNumber(8.4 * 5);
- * // => true
- */
- function isNumber(value) {
- return typeof value == 'number' || toString.call(value) == numberClass;
- }
-
- /**
- * Checks if `value` is a regular expression.
- *
- * @static
- * @memberOf _
- * @category Objects
- * @param {Mixed} value The value to check.
- * @returns {Boolean} Returns `true`, if the `value` is a regular expression, else `false`.
- * @example
- *
- * _.isRegExp(/moe/);
- * // => true
- */
- function isRegExp(value) {
- return value instanceof RegExp || toString.call(value) == regexpClass;
- }
-
- /**
- * Checks if `value` is a string.
- *
- * @static
- * @memberOf _
- * @category Objects
- * @param {Mixed} value The value to check.
- * @returns {Boolean} Returns `true`, if the `value` is a string, else `false`.
- * @example
- *
- * _.isString('moe');
- * // => true
- */
- function isString(value) {
- return typeof value == 'string' || toString.call(value) == stringClass;
- }
-
- /**
- * Checks if `value` is `undefined`.
- *
- * @static
- * @memberOf _
- * @category Objects
- * @param {Mixed} value The value to check.
- * @returns {Boolean} Returns `true`, if the `value` is `undefined`, else `false`.
- * @example
- *
- * _.isUndefined(void 0);
- * // => true
- */
- function isUndefined(value) {
- return typeof value == 'undefined';
- }
-
- /**
- * Creates a shallow clone of `object` excluding the specified properties.
- * Property names may be specified as individual arguments or as arrays of
- * property names. If a `callback` function is passed, it will be executed
- * for each property in the `object`, omitting the properties `callback`
- * returns truthy for. The `callback` is bound to `thisArg` and invoked
- * with three arguments; (value, key, object).
- *
- * @static
- * @memberOf _
- * @category Objects
- * @param {Object} object The source object.
- * @param {Function|String} callback|[prop1, prop2, ...] The properties to omit
- * or the function called per iteration.
- * @param {Mixed} [thisArg] The `this` binding of `callback`.
- * @returns {Object} Returns an object without the omitted properties.
- * @example
- *
- * _.omit({ 'name': 'moe', 'age': 40 }, 'age');
- * // => { 'name': 'moe' }
- *
- * _.omit({ 'name': 'moe', 'age': 40 }, function(value) {
- * return typeof value == 'number';
- * });
- * // => { 'name': 'moe' }
- */
- function omit(object) {
- var props = concat.apply(arrayRef, arguments),
- result = {};
-
- forIn(object, function(value, key) {
- if (indexOf(props, key, 1) < 0) {
- result[key] = value;
- }
- });
- return result;
- }
-
- /**
- * Creates a two dimensional array of the given object's key-value pairs,
- * i.e. `[[key1, value1], [key2, value2]]`.
- *
- * @static
- * @memberOf _
- * @category Objects
- * @param {Object} object The object to inspect.
- * @returns {Array} Returns new array of key-value pairs.
- * @example
- *
- * _.pairs({ 'moe': 30, 'larry': 40 });
- * // => [['moe', 30], ['larry', 40]] (order is not guaranteed)
- */
- function pairs(object) {
- var index = -1,
- props = keys(object),
- length = props.length,
- result = Array(length);
-
- while (++index < length) {
- var key = props[index];
- result[index] = [key, object[key]];
- }
- return result;
- }
-
- /**
- * Creates a shallow clone of `object` composed of the specified properties.
- * Property names may be specified as individual arguments or as arrays of property
- * names. If `callback` is passed, it will be executed for each property in the
- * `object`, picking the properties `callback` returns truthy for. The `callback`
- * is bound to `thisArg` and invoked with three arguments; (value, key, object).
- *
- * @static
- * @memberOf _
- * @category Objects
- * @param {Object} object The source object.
- * @param {Array|Function|String} callback|[prop1, prop2, ...] The function called
- * per iteration or properties to pick, either as individual arguments or arrays.
- * @param {Mixed} [thisArg] The `this` binding of `callback`.
- * @returns {Object} Returns an object composed of the picked properties.
- * @example
- *
- * _.pick({ 'name': 'moe', '_userid': 'moe1' }, 'name');
- * // => { 'name': 'moe' }
- *
- * _.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) {
- * return key.charAt(0) != '_';
- * });
- * // => { 'name': 'moe' }
- */
- function pick(object) {
- var index = 0,
- props = concat.apply(arrayRef, arguments),
- length = props.length,
- result = {};
-
- while (++index < length) {
- var prop = props[index];
- if (prop in object) {
- result[prop] = object[prop];
- }
- }
- return result;
- }
-
- /**
- * Creates an array composed of the own enumerable property values of `object`.
- *
- * @static
- * @memberOf _
- * @category Objects
- * @param {Object} object The object to inspect.
- * @returns {Array} Returns a new array of property values.
- * @example
- *
- * _.values({ 'one': 1, 'two': 2, 'three': 3 });
- * // => [1, 2, 3] (order is not guaranteed)
- */
- function values(object) {
- var index = -1,
- props = keys(object),
- length = props.length,
- result = Array(length);
-
- while (++index < length) {
- result[index] = object[props[index]];
- }
- return result;
- }
-
- /*--------------------------------------------------------------------------*/
-
- /**
- * Checks if a given `target` element is present in a `collection` using strict
- * equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used
- * as the offset from the end of the collection.
- *
- * @static
- * @memberOf _
- * @alias include
- * @category Collections
- * @param {Array|Object|String} collection The collection to iterate over.
- * @param {Mixed} target The value to check for.
- * @param {Number} [fromIndex=0] The index to search from.
- * @returns {Boolean} Returns `true` if the `target` element is found, else `false`.
- * @example
- *
- * _.contains([1, 2, 3], 1);
- * // => true
- *
- * _.contains([1, 2, 3], 1, 2);
- * // => false
- *
- * _.contains({ 'name': 'moe', 'age': 40 }, 'moe');
- * // => true
- *
- * _.contains('curly', 'ur');
- * // => true
- */
- function contains(collection, target) {
- var length = collection ? collection.length : 0,
- result = false;
- if (typeof length == 'number') {
- result = indexOf(collection, target) > -1;
- } else {
- forOwn(collection, function(value) {
- return (result = value === target) && indicatorObject;
- });
- }
- return result;
- }
-
- /**
- * Creates an object composed of keys returned from running each element of the
- * `collection` through the given `callback`. The corresponding value of each key
- * is the number of times the key was returned by the `callback`. The `callback`
- * is bound to `thisArg` and invoked with three arguments; (value, index|key, collection).
- *
- * If a property name is passed for `callback`, the created "_.pluck" style
- * callback will return the property value of the given element.
- *
- * If an object is passed for `callback`, the created "_.where" style callback
- * will return `true` for elements that have the properties of the given object,
- * else `false`.
- *
- * @static
- * @memberOf _
- * @category Collections
- * @param {Array|Object|String} collection The collection to iterate over.
- * @param {Function|Object|String} [callback=identity] The function called per
- * iteration. If a property name or object is passed, it will be used to create
- * a "_.pluck" or "_.where" style callback, respectively.
- * @param {Mixed} [thisArg] The `this` binding of `callback`.
- * @returns {Object} Returns the composed aggregate object.
- * @example
- *
- * _.countBy([4.3, 6.1, 6.4], function(num) { return Math.floor(num); });
- * // => { '4': 1, '6': 2 }
- *
- * _.countBy([4.3, 6.1, 6.4], function(num) { return this.floor(num); }, Math);
- * // => { '4': 1, '6': 2 }
- *
- * _.countBy(['one', 'two', 'three'], 'length');
- * // => { '3': 2, '5': 1 }
- */
- function countBy(collection, callback, thisArg) {
- var result = {};
- callback = createCallback(callback, thisArg);
-
- forEach(collection, function(value, key, collection) {
- key = String(callback(value, key, collection));
- (hasOwnProperty.call(result, key) ? result[key]++ : result[key] = 1);
- });
- return result;
- }
-
- /**
- * Checks if the `callback` returns a truthy value for **all** elements of a
- * `collection`. The `callback` is bound to `thisArg` and invoked with three
- * arguments; (value, index|key, collection).
- *
- * If a property name is passed for `callback`, the created "_.pluck" style
- * callback will return the property value of the given element.
- *
- * If an object is passed for `callback`, the created "_.where" style callback
- * will return `true` for elements that have the properties of the given object,
- * else `false`.
- *
- * @static
- * @memberOf _
- * @alias all
- * @category Collections
- * @param {Array|Object|String} collection The collection to iterate over.
- * @param {Function|Object|String} [callback=identity] The function called per
- * iteration. If a property name or object is passed, it will be used to create
- * a "_.pluck" or "_.where" style callback, respectively.
- * @param {Mixed} [thisArg] The `this` binding of `callback`.
- * @returns {Boolean} Returns `true` if all elements pass the callback check,
- * else `false`.
- * @example
- *
- * _.every([true, 1, null, 'yes'], Boolean);
- * // => false
- *
- * var stooges = [
- * { 'name': 'moe', 'age': 40 },
- * { 'name': 'larry', 'age': 50 }
- * ];
- *
- * // using "_.pluck" callback shorthand
- * _.every(stooges, 'age');
- * // => true
- *
- * // using "_.where" callback shorthand
- * _.every(stooges, { 'age': 50 });
- * // => false
- */
- function every(collection, callback, thisArg) {
- var result = true;
- callback = createCallback(callback, thisArg);
-
- var index = -1,
- length = collection ? collection.length : 0;
-
- if (typeof length == 'number') {
- while (++index < length) {
- if (!(result = !!callback(collection[index], index, collection))) {
- break;
- }
- }
- } else {
- forOwn(collection, function(value, index, collection) {
- return !(result = !!callback(value, index, collection)) && indicatorObject;
- });
- }
- return result;
- }
-
- /**
- * Examines each element in a `collection`, returning an array of all elements
- * the `callback` returns truthy for. The `callback` is bound to `thisArg` and
- * invoked with three arguments; (value, index|key, collection).
- *
- * If a property name is passed for `callback`, the created "_.pluck" style
- * callback will return the property value of the given element.
- *
- * If an object is passed for `callback`, the created "_.where" style callback
- * will return `true` for elements that have the properties of the given object,
- * else `false`.
- *
- * @static
- * @memberOf _
- * @alias select
- * @category Collections
- * @param {Array|Object|String} collection The collection to iterate over.
- * @param {Function|Object|String} [callback=identity] The function called per
- * iteration. If a property name or object is passed, it will be used to create
- * a "_.pluck" or "_.where" style callback, respectively.
- * @param {Mixed} [thisArg] The `this` binding of `callback`.
- * @returns {Array} Returns a new array of elements that passed the callback check.
- * @example
- *
- * var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });
- * // => [2, 4, 6]
- *
- * var food = [
- * { 'name': 'apple', 'organic': false, 'type': 'fruit' },
- * { 'name': 'carrot', 'organic': true, 'type': 'vegetable' }
- * ];
- *
- * // using "_.pluck" callback shorthand
- * _.filter(food, 'organic');
- * // => [{ 'name': 'carrot', 'organic': true, 'type': 'vegetable' }]
- *
- * // using "_.where" callback shorthand
- * _.filter(food, { 'type': 'fruit' });
- * // => [{ 'name': 'apple', 'organic': false, 'type': 'fruit' }]
- */
- function filter(collection, callback, thisArg) {
- var result = [];
- callback = createCallback(callback, thisArg);
-
- var index = -1,
- length = collection ? collection.length : 0;
-
- if (typeof length == 'number') {
- while (++index < length) {
- var value = collection[index];
- if (callback(value, index, collection)) {
- result.push(value);
- }
- }
- } else {
- forOwn(collection, function(value, index, collection) {
- if (callback(value, index, collection)) {
- result.push(value);
- }
- });
- }
- return result;
- }
-
- /**
- * Examines each element in a `collection`, returning the first that the `callback`
- * returns truthy for. The `callback` is bound to `thisArg` and invoked with three
- * arguments; (value, index|key, collection).
- *
- * If a property name is passed for `callback`, the created "_.pluck" style
- * callback will return the property value of the given element.
- *
- * If an object is passed for `callback`, the created "_.where" style callback
- * will return `true` for elements that have the properties of the given object,
- * else `false`.
- *
- * @static
- * @memberOf _
- * @alias detect
- * @category Collections
- * @param {Array|Object|String} collection The collection to iterate over.
- * @param {Function|Object|String} [callback=identity] The function called per
- * iteration. If a property name or object is passed, it will be used to create
- * a "_.pluck" or "_.where" style callback, respectively.
- * @param {Mixed} [thisArg] The `this` binding of `callback`.
- * @returns {Mixed} Returns the found element, else `undefined`.
- * @example
- *
- * _.find([1, 2, 3, 4], function(num) { return num % 2 == 0; });
- * // => 2
- *
- * var food = [
- * { 'name': 'apple', 'organic': false, 'type': 'fruit' },
- * { 'name': 'banana', 'organic': true, 'type': 'fruit' },
- * { 'name': 'beet', 'organic': false, 'type': 'vegetable' }
- * ];
- *
- * // using "_.where" callback shorthand
- * _.find(food, { 'type': 'vegetable' });
- * // => { 'name': 'beet', 'organic': false, 'type': 'vegetable' }
- *
- * // using "_.pluck" callback shorthand
- * _.find(food, 'organic');
- * // => { 'name': 'banana', 'organic': true, 'type': 'fruit' }
- */
- function find(collection, callback, thisArg) {
- callback = createCallback(callback, thisArg);
-
- var index = -1,
- length = collection ? collection.length : 0;
-
- if (typeof length == 'number') {
- while (++index < length) {
- var value = collection[index];
- if (callback(value, index, collection)) {
- return value;
- }
- }
- } else {
- var result;
- forOwn(collection, function(value, index, collection) {
- if (callback(value, index, collection)) {
- result = value;
- return indicatorObject;
- }
- });
- return result;
- }
- }
-
- function findWhere(object, properties) {
- return where(object, properties, true);
- }
-
- /**
- * Iterates over a `collection`, executing the `callback` for each element in
- * the `collection`. The `callback` is bound to `thisArg` and invoked with three
- * arguments; (value, index|key, collection). Callbacks may exit iteration early
- * by explicitly returning `false`.
- *
- * @static
- * @memberOf _
- * @alias each
- * @category Collections
- * @param {Array|Object|String} collection The collection to iterate over.
- * @param {Function} [callback=identity] The function called per iteration.
- * @param {Mixed} [thisArg] The `this` binding of `callback`.
- * @returns {Array|Object|String} Returns `collection`.
- * @example
- *
- * _([1, 2, 3]).forEach(alert).join(',');
- * // => alerts each number and returns '1,2,3'
- *
- * _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert);
- * // => alerts each number value (order is not guaranteed)
- */
- function forEach(collection, callback, thisArg) {
- var index = -1,
- length = collection ? collection.length : 0;
-
- callback = callback && typeof thisArg == 'undefined' ? callback : createCallback(callback, thisArg);
- if (typeof length == 'number') {
- while (++index < length) {
- if (callback(collection[index], index, collection) === indicatorObject) {
- break;
- }
- }
- } else {
- forOwn(collection, callback);
- };
- }
-
- /**
- * Creates an object composed of keys returned from running each element of the
- * `collection` through the `callback`. The corresponding value of each key is
- * an array of elements passed to `callback` that returned the key. The `callback`
- * is bound to `thisArg` and invoked with three arguments; (value, index|key, collection).
- *
- * If a property name is passed for `callback`, the created "_.pluck" style
- * callback will return the property value of the given element.
- *
- * If an object is passed for `callback`, the created "_.where" style callback
- * will return `true` for elements that have the properties of the given object,
- * else `false`
- *
- * @static
- * @memberOf _
- * @category Collections
- * @param {Array|Object|String} collection The collection to iterate over.
- * @param {Function|Object|String} [callback=identity] The function called per
- * iteration. If a property name or object is passed, it will be used to create
- * a "_.pluck" or "_.where" style callback, respectively.
- * @param {Mixed} [thisArg] The `this` binding of `callback`.
- * @returns {Object} Returns the composed aggregate object.
- * @example
- *
- * _.groupBy([4.2, 6.1, 6.4], function(num) { return Math.floor(num); });
- * // => { '4': [4.2], '6': [6.1, 6.4] }
- *
- * _.groupBy([4.2, 6.1, 6.4], function(num) { return this.floor(num); }, Math);
- * // => { '4': [4.2], '6': [6.1, 6.4] }
- *
- * // using "_.pluck" callback shorthand
- * _.groupBy(['one', 'two', 'three'], 'length');
- * // => { '3': ['one', 'two'], '5': ['three'] }
- */
- function groupBy(collection, callback, thisArg) {
- var result = {};
- callback = createCallback(callback, thisArg);
-
- forEach(collection, function(value, key, collection) {
- key = String(callback(value, key, collection));
- (hasOwnProperty.call(result, key) ? result[key] : result[key] = []).push(value);
- });
- return result;
- }
-
- /**
- * Invokes the method named by `methodName` on each element in the `collection`,
- * returning an array of the results of each invoked method. Additional arguments
- * will be passed to each invoked method. If `methodName` is a function, it will
- * be invoked for, and `this` bound to, each element in the `collection`.
- *
- * @static
- * @memberOf _
- * @category Collections
- * @param {Array|Object|String} collection The collection to iterate over.
- * @param {Function|String} methodName The name of the method to invoke or
- * the function invoked per iteration.
- * @param {Mixed} [arg1, arg2, ...] Arguments to invoke the method with.
- * @returns {Array} Returns a new array of the results of each invoked method.
- * @example
- *
- * _.invoke([[5, 1, 7], [3, 2, 1]], 'sort');
- * // => [[1, 5, 7], [1, 2, 3]]
- *
- * _.invoke([123, 456], String.prototype.split, '');
- * // => [['1', '2', '3'], ['4', '5', '6']]
- */
- function invoke(collection, methodName) {
- var args = slice.call(arguments, 2),
- index = -1,
- isFunc = typeof methodName == 'function',
- length = collection ? collection.length : 0,
- result = Array(typeof length == 'number' ? length : 0);
-
- forEach(collection, function(value) {
- result[++index] = (isFunc ? methodName : value[methodName]).apply(value, args);
- });
- return result;
- }
-
- /**
- * Creates an array of values by running each element in the `collection`
- * through the `callback`. The `callback` is bound to `thisArg` and invoked with
- * three arguments; (value, index|key, collection).
- *
- * If a property name is passed for `callback`, the created "_.pluck" style
- * callback will return the property value of the given element.
- *
- * If an object is passed for `callback`, the created "_.where" style callback
- * will return `true` for elements that have the properties of the given object,
- * else `false`.
- *
- * @static
- * @memberOf _
- * @alias collect
- * @category Collections
- * @param {Array|Object|String} collection The collection to iterate over.
- * @param {Function|Object|String} [callback=identity] The function called per
- * iteration. If a property name or object is passed, it will be used to create
- * a "_.pluck" or "_.where" style callback, respectively.
- * @param {Mixed} [thisArg] The `this` binding of `callback`.
- * @returns {Array} Returns a new array of the results of each `callback` execution.
- * @example
- *
- * _.map([1, 2, 3], function(num) { return num * 3; });
- * // => [3, 6, 9]
- *
- * _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; });
- * // => [3, 6, 9] (order is not guaranteed)
- *
- * var stooges = [
- * { 'name': 'moe', 'age': 40 },
- * { 'name': 'larry', 'age': 50 }
- * ];
- *
- * // using "_.pluck" callback shorthand
- * _.map(stooges, 'name');
- * // => ['moe', 'larry']
- */
- function map(collection, callback, thisArg) {
- var index = -1,
- length = collection ? collection.length : 0;
-
- callback = createCallback(callback, thisArg);
- if (typeof length == 'number') {
- var result = Array(length);
- while (++index < length) {
- result[index] = callback(collection[index], index, collection);
- }
- } else {
- result = [];
- forOwn(collection, function(value, key, collection) {
- result[++index] = callback(value, key, collection);
- });
- }
- return result;
- }
-
- /**
- * Retrieves the maximum value of an `array`. If `callback` is passed,
- * it will be executed for each value in the `array` to generate the
- * criterion by which the value is ranked. The `callback` is bound to
- * `thisArg` and invoked with three arguments; (value, index, collection).
- *
- * If a property name is passed for `callback`, the created "_.pluck" style
- * callback will return the property value of the given element.
- *
- * If an object is passed for `callback`, the created "_.where" style callback
- * will return `true` for elements that have the properties of the given object,
- * else `false`.
- *
- * @static
- * @memberOf _
- * @category Collections
- * @param {Array|Object|String} collection The collection to iterate over.
- * @param {Function|Object|String} [callback=identity] The function called per
- * iteration. If a property name or object is passed, it will be used to create
- * a "_.pluck" or "_.where" style callback, respectively.
- * @param {Mixed} [thisArg] The `this` binding of `callback`.
- * @returns {Mixed} Returns the maximum value.
- * @example
- *
- * _.max([4, 2, 8, 6]);
- * // => 8
- *
- * var stooges = [
- * { 'name': 'moe', 'age': 40 },
- * { 'name': 'larry', 'age': 50 }
- * ];
- *
- * _.max(stooges, function(stooge) { return stooge.age; });
- * // => { 'name': 'larry', 'age': 50 };
- *
- * // using "_.pluck" callback shorthand
- * _.max(stooges, 'age');
- * // => { 'name': 'larry', 'age': 50 };
- */
- function max(collection, callback, thisArg) {
- var computed = -Infinity,
- result = computed;
-
- var index = -1,
- length = collection ? collection.length : 0;
-
- if (!callback && typeof length == 'number') {
- while (++index < length) {
- var value = collection[index];
- if (value > result) {
- result = value;
- }
- }
- } else {
- callback = createCallback(callback, thisArg);
-
- forEach(collection, function(value, index, collection) {
- var current = callback(value, index, collection);
- if (current > computed) {
- computed = current;
- result = value;
- }
- });
- }
- return result;
- }
-
- /**
- * Retrieves the minimum value of an `array`. If `callback` is passed,
- * it will be executed for each value in the `array` to generate the
- * criterion by which the value is ranked. The `callback` is bound to `thisArg`
- * and invoked with three arguments; (value, index, collection).
- *
- * If a property name is passed for `callback`, the created "_.pluck" style
- * callback will return the property value of the given element.
- *
- * If an object is passed for `callback`, the created "_.where" style callback
- * will return `true` for elements that have the properties of the given object,
- * else `false`.
- *
- * @static
- * @memberOf _
- * @category Collections
- * @param {Array|Object|String} collection The collection to iterate over.
- * @param {Function|Object|String} [callback=identity] The function called per
- * iteration. If a property name or object is passed, it will be used to create
- * a "_.pluck" or "_.where" style callback, respectively.
- * @param {Mixed} [thisArg] The `this` binding of `callback`.
- * @returns {Mixed} Returns the minimum value.
- * @example
- *
- * _.min([4, 2, 8, 6]);
- * // => 2
- *
- * var stooges = [
- * { 'name': 'moe', 'age': 40 },
- * { 'name': 'larry', 'age': 50 }
- * ];
- *
- * _.min(stooges, function(stooge) { return stooge.age; });
- * // => { 'name': 'moe', 'age': 40 };
- *
- * // using "_.pluck" callback shorthand
- * _.min(stooges, 'age');
- * // => { 'name': 'moe', 'age': 40 };
- */
- function min(collection, callback, thisArg) {
- var computed = Infinity,
- result = computed;
-
- var index = -1,
- length = collection ? collection.length : 0;
-
- if (!callback && typeof length == 'number') {
- while (++index < length) {
- var value = collection[index];
- if (value < result) {
- result = value;
- }
- }
- } else {
- callback = createCallback(callback, thisArg);
-
- forEach(collection, function(value, index, collection) {
- var current = callback(value, index, collection);
- if (current < computed) {
- computed = current;
- result = value;
- }
- });
- }
- return result;
- }
-
- /**
- * Retrieves the value of a specified property from all elements in the `collection`.
- *
- * @static
- * @memberOf _
- * @type Function
- * @category Collections
- * @param {Array|Object|String} collection The collection to iterate over.
- * @param {String} property The property to pluck.
- * @returns {Array} Returns a new array of property values.
- * @example
- *
- * var stooges = [
- * { 'name': 'moe', 'age': 40 },
- * { 'name': 'larry', 'age': 50 }
- * ];
- *
- * _.pluck(stooges, 'name');
- * // => ['moe', 'larry']
- */
- function pluck(collection, property) {
- var index = -1,
- length = collection ? collection.length : 0;
-
- if (typeof length == 'number') {
- var result = Array(length);
- while (++index < length) {
- result[index] = collection[index][property];
- }
- }
- return result || map(collection, property);
- }
-
- /**
- * Reduces a `collection` to a value that is the accumulated result of running
- * each element in the `collection` through the `callback`, where each successive
- * `callback` execution consumes the return value of the previous execution.
- * If `accumulator` is not passed, the first element of the `collection` will be
- * used as the initial `accumulator` value. The `callback` is bound to `thisArg`
- * and invoked with four arguments; (accumulator, value, index|key, collection).
- *
- * @static
- * @memberOf _
- * @alias foldl, inject
- * @category Collections
- * @param {Array|Object|String} collection The collection to iterate over.
- * @param {Function} [callback=identity] The function called per iteration.
- * @param {Mixed} [accumulator] Initial value of the accumulator.
- * @param {Mixed} [thisArg] The `this` binding of `callback`.
- * @returns {Mixed} Returns the accumulated value.
- * @example
- *
- * var sum = _.reduce([1, 2, 3], function(sum, num) {
- * return sum + num;
- * });
- * // => 6
- *
- * var mapped = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) {
- * result[key] = num * 3;
- * return result;
- * }, {});
- * // => { 'a': 3, 'b': 6, 'c': 9 }
- */
- function reduce(collection, callback, accumulator, thisArg) {
- if (!collection) return accumulator;
- var noaccum = arguments.length < 3;
- callback = createCallback(callback, thisArg, 4);
-
- var index = -1,
- length = collection.length;
-
- if (typeof length == 'number') {
- if (noaccum) {
- accumulator = collection[++index];
- }
- while (++index < length) {
- accumulator = callback(accumulator, collection[index], index, collection);
- }
- } else {
- forOwn(collection, function(value, index, collection) {
- accumulator = noaccum
- ? (noaccum = false, value)
- : callback(accumulator, value, index, collection)
- });
- }
- return accumulator;
- }
-
- /**
- * This method is similar to `_.reduce`, except that it iterates over a
- * `collection` from right to left.
- *
- * @static
- * @memberOf _
- * @alias foldr
- * @category Collections
- * @param {Array|Object|String} collection The collection to iterate over.
- * @param {Function} [callback=identity] The function called per iteration.
- * @param {Mixed} [accumulator] Initial value of the accumulator.
- * @param {Mixed} [thisArg] The `this` binding of `callback`.
- * @returns {Mixed} Returns the accumulated value.
- * @example
- *
- * var list = [[0, 1], [2, 3], [4, 5]];
- * var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []);
- * // => [4, 5, 2, 3, 0, 1]
- */
- function reduceRight(collection, callback, accumulator, thisArg) {
- var iterable = collection,
- length = collection ? collection.length : 0,
- noaccum = arguments.length < 3;
-
- if (typeof length != 'number') {
- var props = keys(collection);
- length = props.length;
- }
- callback = createCallback(callback, thisArg, 4);
- forEach(collection, function(value, index, collection) {
- index = props ? props[--length] : --length;
- accumulator = noaccum
- ? (noaccum = false, iterable[index])
- : callback(accumulator, iterable[index], index, collection);
- });
- return accumulator;
- }
-
- /**
- * The opposite of `_.filter`, this method returns the elements of a
- * `collection` that `callback` does **not** return truthy for.
- *
- * If a property name is passed for `callback`, the created "_.pluck" style
- * callback will return the property value of the given element.
- *
- * If an object is passed for `callback`, the created "_.where" style callback
- * will return `true` for elements that have the properties of the given object,
- * else `false`.
- *
- * @static
- * @memberOf _
- * @category Collections
- * @param {Array|Object|String} collection The collection to iterate over.
- * @param {Function|Object|String} [callback=identity] The function called per
- * iteration. If a property name or object is passed, it will be used to create
- * a "_.pluck" or "_.where" style callback, respectively.
- * @param {Mixed} [thisArg] The `this` binding of `callback`.
- * @returns {Array} Returns a new array of elements that did **not** pass the
- * callback check.
- * @example
- *
- * var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });
- * // => [1, 3, 5]
- *
- * var food = [
- * { 'name': 'apple', 'organic': false, 'type': 'fruit' },
- * { 'name': 'carrot', 'organic': true, 'type': 'vegetable' }
- * ];
- *
- * // using "_.pluck" callback shorthand
- * _.reject(food, 'organic');
- * // => [{ 'name': 'apple', 'organic': false, 'type': 'fruit' }]
- *
- * // using "_.where" callback shorthand
- * _.reject(food, { 'type': 'fruit' });
- * // => [{ 'name': 'carrot', 'organic': true, 'type': 'vegetable' }]
- */
- function reject(collection, callback, thisArg) {
- callback = createCallback(callback, thisArg);
- return filter(collection, function(value, index, collection) {
- return !callback(value, index, collection);
- });
- }
-
- /**
- * Creates an array of shuffled `array` values, using a version of the
- * Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle.
- *
- * @static
- * @memberOf _
- * @category Collections
- * @param {Array|Object|String} collection The collection to shuffle.
- * @returns {Array} Returns a new shuffled collection.
- * @example
- *
- * _.shuffle([1, 2, 3, 4, 5, 6]);
- * // => [4, 1, 6, 3, 5, 2]
- */
- function shuffle(collection) {
- var index = -1,
- length = collection ? collection.length : 0,
- result = Array(typeof length == 'number' ? length : 0);
-
- forEach(collection, function(value) {
- var rand = floor(nativeRandom() * (++index + 1));
- result[index] = result[rand];
- result[rand] = value;
- });
- return result;
- }
-
- /**
- * Gets the size of the `collection` by returning `collection.length` for arrays
- * and array-like objects or the number of own enumerable properties for objects.
- *
- * @static
- * @memberOf _
- * @category Collections
- * @param {Array|Object|String} collection The collection to inspect.
- * @returns {Number} Returns `collection.length` or number of own enumerable properties.
- * @example
- *
- * _.size([1, 2]);
- * // => 2
- *
- * _.size({ 'one': 1, 'two': 2, 'three': 3 });
- * // => 3
- *
- * _.size('curly');
- * // => 5
- */
- function size(collection) {
- var length = collection ? collection.length : 0;
- return typeof length == 'number' ? length : keys(collection).length;
- }
-
- /**
- * Checks if the `callback` returns a truthy value for **any** element of a
- * `collection`. The function returns as soon as it finds passing value, and
- * does not iterate over the entire `collection`. The `callback` is bound to
- * `thisArg` and invoked with three arguments; (value, index|key, collection).
- *
- * If a property name is passed for `callback`, the created "_.pluck" style
- * callback will return the property value of the given element.
- *
- * If an object is passed for `callback`, the created "_.where" style callback
- * will return `true` for elements that have the properties of the given object,
- * else `false`.
- *
- * @static
- * @memberOf _
- * @alias any
- * @category Collections
- * @param {Array|Object|String} collection The collection to iterate over.
- * @param {Function|Object|String} [callback=identity] The function called per
- * iteration. If a property name or object is passed, it will be used to create
- * a "_.pluck" or "_.where" style callback, respectively.
- * @param {Mixed} [thisArg] The `this` binding of `callback`.
- * @returns {Boolean} Returns `true` if any element passes the callback check,
- * else `false`.
- * @example
- *
- * _.some([null, 0, 'yes', false], Boolean);
- * // => true
- *
- * var food = [
- * { 'name': 'apple', 'organic': false, 'type': 'fruit' },
- * { 'name': 'carrot', 'organic': true, 'type': 'vegetable' }
- * ];
- *
- * // using "_.pluck" callback shorthand
- * _.some(food, 'organic');
- * // => true
- *
- * // using "_.where" callback shorthand
- * _.some(food, { 'type': 'meat' });
- * // => false
- */
- function some(collection, callback, thisArg) {
- var result;
- callback = createCallback(callback, thisArg);
-
- var index = -1,
- length = collection ? collection.length : 0;
-
- if (typeof length == 'number') {
- while (++index < length) {
- if ((result = callback(collection[index], index, collection))) {
- break;
- }
- }
- } else {
- forOwn(collection, function(value, index, collection) {
- return (result = callback(value, index, collection)) && indicatorObject;
- });
- }
- return !!result;
- }
-
- /**
- * Creates an array of elements, sorted in ascending order by the results of
- * running each element in the `collection` through the `callback`. This method
- * performs a stable sort, that is, it will preserve the original sort order of
- * equal elements. The `callback` is bound to `thisArg` and invoked with three
- * arguments; (value, index|key, collection).
- *
- * If a property name is passed for `callback`, the created "_.pluck" style
- * callback will return the property value of the given element.
- *
- * If an object is passed for `callback`, the created "_.where" style callback
- * will return `true` for elements that have the properties of the given object,
- * else `false`.
- *
- * @static
- * @memberOf _
- * @category Collections
- * @param {Array|Object|String} collection The collection to iterate over.
- * @param {Function|Object|String} [callback=identity] The function called per
- * iteration. If a property name or object is passed, it will be used to create
- * a "_.pluck" or "_.where" style callback, respectively.
- * @param {Mixed} [thisArg] The `this` binding of `callback`.
- * @returns {Array} Returns a new array of sorted elements.
- * @example
- *
- * _.sortBy([1, 2, 3], function(num) { return Math.sin(num); });
- * // => [3, 1, 2]
- *
- * _.sortBy([1, 2, 3], function(num) { return this.sin(num); }, Math);
- * // => [3, 1, 2]
- *
- * // using "_.pluck" callback shorthand
- * _.sortBy(['banana', 'strawberry', 'apple'], 'length');
- * // => ['apple', 'banana', 'strawberry']
- */
- function sortBy(collection, callback, thisArg) {
- var index = -1,
- length = collection ? collection.length : 0,
- result = Array(typeof length == 'number' ? length : 0);
-
- callback = createCallback(callback, thisArg);
- forEach(collection, function(value, key, collection) {
- result[++index] = {
- 'criteria': callback(value, key, collection),
- 'index': index,
- 'value': value
- };
- });
-
- length = result.length;
- result.sort(compareAscending);
- while (length--) {
- result[length] = result[length].value;
- }
- return result;
- }
-
- /**
- * Converts the `collection` to an array.
- *
- * @static
- * @memberOf _
- * @category Collections
- * @param {Array|Object|String} collection The collection to convert.
- * @returns {Array} Returns the new converted array.
- * @example
- *
- * (function() { return _.toArray(arguments).slice(1); })(1, 2, 3, 4);
- * // => [2, 3, 4]
- */
- function toArray(collection) {
- if (isArray(collection)) {
- return slice.call(collection);
- }
- if (collection && typeof collection.length == 'number') {
- return map(collection);
- }
- return values(collection);
- }
-
- /**
- * Examines each element in a `collection`, returning an array of all elements
- * that have the given `properties`. When checking `properties`, this method
- * performs a deep comparison between values to determine if they are equivalent
- * to each other.
- *
- * @static
- * @memberOf _
- * @type Function
- * @category Collections
- * @param {Array|Object|String} collection The collection to iterate over.
- * @param {Object} properties The object of property values to filter by.
- * @returns {Array} Returns a new array of elements that have the given `properties`.
- * @example
- *
- * var stooges = [
- * { 'name': 'moe', 'age': 40 },
- * { 'name': 'larry', 'age': 50 }
- * ];
- *
- * _.where(stooges, { 'age': 40 });
- * // => [{ 'name': 'moe', 'age': 40 }]
- */
- function where(collection, properties, first) {
- return (first && isEmpty(properties))
- ? null
- : (first ? find : filter)(collection, properties);
- }
-
- /*--------------------------------------------------------------------------*/
-
- /**
- * Creates an array with all falsey values of `array` removed. The values
- * `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey.
- *
- * @static
- * @memberOf _
- * @category Arrays
- * @param {Array} array The array to compact.
- * @returns {Array} Returns a new filtered array.
- * @example
- *
- * _.compact([0, 1, false, 2, '', 3]);
- * // => [1, 2, 3]
- */
- function compact(array) {
- var index = -1,
- length = array ? array.length : 0,
- result = [];
-
- while (++index < length) {
- var value = array[index];
- if (value) {
- result.push(value);
- }
- }
- return result;
- }
-
- /**
- * Creates an array of `array` elements not present in the other arrays
- * using strict equality for comparisons, i.e. `===`.
- *
- * @static
- * @memberOf _
- * @category Arrays
- * @param {Array} array The array to process.
- * @param {Array} [array1, array2, ...] Arrays to check.
- * @returns {Array} Returns a new array of `array` elements not present in the
- * other arrays.
- * @example
- *
- * _.difference([1, 2, 3, 4, 5], [5, 2, 10]);
- * // => [1, 3, 4]
- */
- function difference(array) {
- var index = -1,
- length = array.length,
- flattened = concat.apply(arrayRef, arguments),
- result = [];
-
- while (++index < length) {
- var value = array[index];
- if (indexOf(flattened, value, length) < 0) {
- result.push(value);
- }
- }
- return result;
- }
-
- /**
- * Gets the first element of the `array`. If a number `n` is passed, the first
- * `n` elements of the `array` are returned. If a `callback` function is passed,
- * elements at the beginning of the array are returned as long as the `callback`
- * returns truthy. The `callback` is bound to `thisArg` and invoked with three
- * arguments; (value, index, array).
- *
- * If a property name is passed for `callback`, the created "_.pluck" style
- * callback will return the property value of the given element.
- *
- * If an object is passed for `callback`, the created "_.where" style callback
- * will return `true` for elements that have the properties of the given object,
- * else `false`.
- *
- * @static
- * @memberOf _
- * @alias head, take
- * @category Arrays
- * @param {Array} array The array to query.
- * @param {Function|Object|Number|String} [callback|n] The function called
- * per element or the number of elements to return. If a property name or
- * object is passed, it will be used to create a "_.pluck" or "_.where"
- * style callback, respectively.
- * @param {Mixed} [thisArg] The `this` binding of `callback`.
- * @returns {Mixed} Returns the first element(s) of `array`.
- * @example
- *
- * _.first([1, 2, 3]);
- * // => 1
- *
- * _.first([1, 2, 3], 2);
- * // => [1, 2]
- *
- * _.first([1, 2, 3], function(num) {
- * return num < 3;
- * });
- * // => [1, 2]
- *
- * var food = [
- * { 'name': 'banana', 'organic': true },
- * { 'name': 'beet', 'organic': false },
- * ];
- *
- * // using "_.pluck" callback shorthand
- * _.first(food, 'organic');
- * // => [{ 'name': 'banana', 'organic': true }]
- *
- * var food = [
- * { 'name': 'apple', 'type': 'fruit' },
- * { 'name': 'banana', 'type': 'fruit' },
- * { 'name': 'beet', 'type': 'vegetable' }
- * ];
- *
- * // using "_.where" callback shorthand
- * _.first(food, { 'type': 'fruit' });
- * // => [{ 'name': 'apple', 'type': 'fruit' }, { 'name': 'banana', 'type': 'fruit' }]
- */
- function first(array, callback, thisArg) {
- if (array) {
- var n = 0,
- length = array.length;
-
- if (typeof callback != 'number' && callback != null) {
- var index = -1;
- callback = createCallback(callback, thisArg);
- while (++index < length && callback(array[index], index, array)) {
- n++;
- }
- } else {
- n = callback;
- if (n == null || thisArg) {
- return array[0];
- }
- }
- return slice.call(array, 0, nativeMin(nativeMax(0, n), length));
- }
- }
-
- /**
- * Flattens a nested array (the nesting can be to any depth). If `isShallow`
- * is truthy, `array` will only be flattened a single level. If `callback`
- * is passed, each element of `array` is passed through a callback` before
- * flattening. The `callback` is bound to `thisArg` and invoked with three
- * arguments; (value, index, array).
- *
- * If a property name is passed for `callback`, the created "_.pluck" style
- * callback will return the property value of the given element.
- *
- * If an object is passed for `callback`, the created "_.where" style callback
- * will return `true` for elements that have the properties of the given object,
- * else `false`.
- *
- * @static
- * @memberOf _
- * @category Arrays
- * @param {Array} array The array to compact.
- * @param {Boolean} [isShallow=false] A flag to indicate only flattening a single level.
- * @param {Function|Object|String} [callback=identity] The function called per
- * iteration. If a property name or object is passed, it will be used to create
- * a "_.pluck" or "_.where" style callback, respectively.
- * @param {Mixed} [thisArg] The `this` binding of `callback`.
- * @returns {Array} Returns a new flattened array.
- * @example
- *
- * _.flatten([1, [2], [3, [[4]]]]);
- * // => [1, 2, 3, 4];
- *
- * _.flatten([1, [2], [3, [[4]]]], true);
- * // => [1, 2, 3, [[4]]];
- *
- * var stooges = [
- * { 'name': 'curly', 'quotes': ['Oh, a wise guy, eh?', 'Poifect!'] },
- * { 'name': 'moe', 'quotes': ['Spread out!', 'You knucklehead!'] }
- * ];
- *
- * // using "_.pluck" callback shorthand
- * _.flatten(stooges, 'quotes');
- * // => ['Oh, a wise guy, eh?', 'Poifect!', 'Spread out!', 'You knucklehead!']
- */
- function flatten(array, isShallow) {
- var index = -1,
- length = array ? array.length : 0,
- result = [];
-
- while (++index < length) {
- var value = array[index];
- if (isArray(value)) {
- push.apply(result, isShallow ? value : flatten(value));
- } else {
- result.push(value);
- }
- }
- return result;
- }
-
- /**
- * Gets the index at which the first occurrence of `value` is found using
- * strict equality for comparisons, i.e. `===`. If the `array` is already
- * sorted, passing `true` for `fromIndex` will run a faster binary search.
- *
- * @static
- * @memberOf _
- * @category Arrays
- * @param {Array} array The array to search.
- * @param {Mixed} value The value to search for.
- * @param {Boolean|Number} [fromIndex=0] The index to search from or `true` to
- * perform a binary search on a sorted `array`.
- * @returns {Number} Returns the index of the matched value or `-1`.
- * @example
- *
- * _.indexOf([1, 2, 3, 1, 2, 3], 2);
- * // => 1
- *
- * _.indexOf([1, 2, 3, 1, 2, 3], 2, 3);
- * // => 4
- *
- * _.indexOf([1, 1, 2, 2, 3, 3], 2, true);
- * // => 2
- */
- function indexOf(array, value, fromIndex) {
- var index = -1,
- length = array ? array.length : 0;
-
- if (typeof fromIndex == 'number') {
- index = (fromIndex < 0 ? nativeMax(0, length + fromIndex) : fromIndex || 0) - 1;
- } else if (fromIndex) {
- index = sortedIndex(array, value);
- return array[index] === value ? index : -1;
- }
- while (++index < length) {
- if (array[index] === value) {
- return index;
- }
- }
- return -1;
- }
-
- /**
- * Gets all but the last element of `array`. If a number `n` is passed, the
- * last `n` elements are excluded from the result. If a `callback` function
- * is passed, elements at the end of the array are excluded from the result
- * as long as the `callback` returns truthy. The `callback` is bound to
- * `thisArg` and invoked with three arguments; (value, index, array).
- *
- * If a property name is passed for `callback`, the created "_.pluck" style
- * callback will return the property value of the given element.
- *
- * If an object is passed for `callback`, the created "_.where" style callback
- * will return `true` for elements that have the properties of the given object,
- * else `false`.
- *
- * @static
- * @memberOf _
- * @category Arrays
- * @param {Array} array The array to query.
- * @param {Function|Object|Number|String} [callback|n=1] The function called
- * per element or the number of elements to exclude. If a property name or
- * object is passed, it will be used to create a "_.pluck" or "_.where"
- * style callback, respectively.
- * @param {Mixed} [thisArg] The `this` binding of `callback`.
- * @returns {Array} Returns a slice of `array`.
- * @example
- *
- * _.initial([1, 2, 3]);
- * // => [1, 2]
- *
- * _.initial([1, 2, 3], 2);
- * // => [1]
- *
- * _.initial([1, 2, 3], function(num) {
- * return num > 1;
- * });
- * // => [1]
- *
- * var food = [
- * { 'name': 'beet', 'organic': false },
- * { 'name': 'carrot', 'organic': true }
- * ];
- *
- * // using "_.pluck" callback shorthand
- * _.initial(food, 'organic');
- * // => [{ 'name': 'beet', 'organic': false }]
- *
- * var food = [
- * { 'name': 'banana', 'type': 'fruit' },
- * { 'name': 'beet', 'type': 'vegetable' },
- * { 'name': 'carrot', 'type': 'vegetable' }
- * ];
- *
- * // using "_.where" callback shorthand
- * _.initial(food, { 'type': 'vegetable' });
- * // => [{ 'name': 'banana', 'type': 'fruit' }]
- */
- function initial(array, callback, thisArg) {
- if (!array) {
- return [];
- }
- var n = 0,
- length = array.length;
-
- if (typeof callback != 'number' && callback != null) {
- var index = length;
- callback = createCallback(callback, thisArg);
- while (index-- && callback(array[index], index, array)) {
- n++;
- }
- } else {
- n = (callback == null || thisArg) ? 1 : callback || n;
- }
- return slice.call(array, 0, nativeMin(nativeMax(0, length - n), length));
- }
-
- /**
- * Computes the intersection of all the passed-in arrays using strict equality
- * for comparisons, i.e. `===`.
- *
- * @static
- * @memberOf _
- * @category Arrays
- * @param {Array} [array1, array2, ...] Arrays to process.
- * @returns {Array} Returns a new array of unique elements that are present
- * in **all** of the arrays.
- * @example
- *
- * _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]);
- * // => [1, 2]
- */
- function intersection(array) {
- var args = arguments,
- argsLength = args.length,
- index = -1,
- length = array ? array.length : 0,
- result = [];
-
- outer:
- while (++index < length) {
- var value = array[index];
- if (indexOf(result, value) < 0) {
- var argsIndex = argsLength;
- while (--argsIndex) {
- if (indexOf(args[argsIndex], value) < 0) {
- continue outer;
- }
- }
- result.push(value);
- }
- }
- return result;
- }
-
- /**
- * Gets the last element of the `array`. If a number `n` is passed, the
- * last `n` elements of the `array` are returned. If a `callback` function
- * is passed, elements at the end of the array are returned
<TRUNCATED>
[21/26] Remove fauxton from 1.4.x branch.
Posted by dj...@apache.org.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/js/libs/backbone.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/backbone.js b/src/fauxton/assets/js/libs/backbone.js
deleted file mode 100644
index 3512d42..0000000
--- a/src/fauxton/assets/js/libs/backbone.js
+++ /dev/null
@@ -1,1571 +0,0 @@
-// Backbone.js 1.0.0
-
-// (c) 2010-2013 Jeremy Ashkenas, DocumentCloud Inc.
-// Backbone may be freely distributed under the MIT license.
-// For all details and documentation:
-// http://backbonejs.org
-
-(function(){
-
- // Initial Setup
- // -------------
-
- // Save a reference to the global object (`window` in the browser, `exports`
- // on the server).
- var root = this;
-
- // Save the previous value of the `Backbone` variable, so that it can be
- // restored later on, if `noConflict` is used.
- var previousBackbone = root.Backbone;
-
- // Create local references to array methods we'll want to use later.
- var array = [];
- var push = array.push;
- var slice = array.slice;
- var splice = array.splice;
-
- // The top-level namespace. All public Backbone classes and modules will
- // be attached to this. Exported for both the browser and the server.
- var Backbone;
- if (typeof exports !== 'undefined') {
- Backbone = exports;
- } else {
- Backbone = root.Backbone = {};
- }
-
- // Current version of the library. Keep in sync with `package.json`.
- Backbone.VERSION = '1.0.0';
-
- // Require Underscore, if we're on the server, and it's not already present.
- var _ = root._;
- if (!_ && (typeof require !== 'undefined')) _ = require('underscore');
-
- // For Backbone's purposes, jQuery, Zepto, Ender, or My Library (kidding) owns
- // the `$` variable.
- Backbone.$ = root.jQuery || root.Zepto || root.ender || root.$;
-
- // Runs Backbone.js in *noConflict* mode, returning the `Backbone` variable
- // to its previous owner. Returns a reference to this Backbone object.
- Backbone.noConflict = function() {
- root.Backbone = previousBackbone;
- return this;
- };
-
- // Turn on `emulateHTTP` to support legacy HTTP servers. Setting this option
- // will fake `"PUT"` and `"DELETE"` requests via the `_method` parameter and
- // set a `X-Http-Method-Override` header.
- Backbone.emulateHTTP = false;
-
- // Turn on `emulateJSON` to support legacy servers that can't deal with direct
- // `application/json` requests ... will encode the body as
- // `application/x-www-form-urlencoded` instead and will send the model in a
- // form param named `model`.
- Backbone.emulateJSON = false;
-
- // Backbone.Events
- // ---------------
-
- // A module that can be mixed in to *any object* in order to provide it with
- // custom events. You may bind with `on` or remove with `off` callback
- // functions to an event; `trigger`-ing an event fires all callbacks in
- // succession.
- //
- // var object = {};
- // _.extend(object, Backbone.Events);
- // object.on('expand', function(){ alert('expanded'); });
- // object.trigger('expand');
- //
- var Events = Backbone.Events = {
-
- // Bind an event to a `callback` function. Passing `"all"` will bind
- // the callback to all events fired.
- on: function(name, callback, context) {
- if (!eventsApi(this, 'on', name, [callback, context]) || !callback) return this;
- this._events || (this._events = {});
- var events = this._events[name] || (this._events[name] = []);
- events.push({callback: callback, context: context, ctx: context || this});
- return this;
- },
-
- // Bind an event to only be triggered a single time. After the first time
- // the callback is invoked, it will be removed.
- once: function(name, callback, context) {
- if (!eventsApi(this, 'once', name, [callback, context]) || !callback) return this;
- var self = this;
- var once = _.once(function() {
- self.off(name, once);
- callback.apply(this, arguments);
- });
- once._callback = callback;
- return this.on(name, once, context);
- },
-
- // Remove one or many callbacks. If `context` is null, removes all
- // callbacks with that function. If `callback` is null, removes all
- // callbacks for the event. If `name` is null, removes all bound
- // callbacks for all events.
- off: function(name, callback, context) {
- var retain, ev, events, names, i, l, j, k;
- if (!this._events || !eventsApi(this, 'off', name, [callback, context])) return this;
- if (!name && !callback && !context) {
- this._events = {};
- return this;
- }
-
- names = name ? [name] : _.keys(this._events);
- for (i = 0, l = names.length; i < l; i++) {
- name = names[i];
- if (events = this._events[name]) {
- this._events[name] = retain = [];
- if (callback || context) {
- for (j = 0, k = events.length; j < k; j++) {
- ev = events[j];
- if ((callback && callback !== ev.callback && callback !== ev.callback._callback) ||
- (context && context !== ev.context)) {
- retain.push(ev);
- }
- }
- }
- if (!retain.length) delete this._events[name];
- }
- }
-
- return this;
- },
-
- // Trigger one or many events, firing all bound callbacks. Callbacks are
- // passed the same arguments as `trigger` is, apart from the event name
- // (unless you're listening on `"all"`, which will cause your callback to
- // receive the true name of the event as the first argument).
- trigger: function(name) {
- if (!this._events) return this;
- var args = slice.call(arguments, 1);
- if (!eventsApi(this, 'trigger', name, args)) return this;
- var events = this._events[name];
- var allEvents = this._events.all;
- if (events) triggerEvents(events, args);
- if (allEvents) triggerEvents(allEvents, arguments);
- return this;
- },
-
- // Tell this object to stop listening to either specific events ... or
- // to every object it's currently listening to.
- stopListening: function(obj, name, callback) {
- var listeners = this._listeners;
- if (!listeners) return this;
- var deleteListener = !name && !callback;
- if (typeof name === 'object') callback = this;
- if (obj) (listeners = {})[obj._listenerId] = obj;
- for (var id in listeners) {
- listeners[id].off(name, callback, this);
- if (deleteListener) delete this._listeners[id];
- }
- return this;
- }
-
- };
-
- // Regular expression used to split event strings.
- var eventSplitter = /\s+/;
-
- // Implement fancy features of the Events API such as multiple event
- // names `"change blur"` and jQuery-style event maps `{change: action}`
- // in terms of the existing API.
- var eventsApi = function(obj, action, name, rest) {
- if (!name) return true;
-
- // Handle event maps.
- if (typeof name === 'object') {
- for (var key in name) {
- obj[action].apply(obj, [key, name[key]].concat(rest));
- }
- return false;
- }
-
- // Handle space separated event names.
- if (eventSplitter.test(name)) {
- var names = name.split(eventSplitter);
- for (var i = 0, l = names.length; i < l; i++) {
- obj[action].apply(obj, [names[i]].concat(rest));
- }
- return false;
- }
-
- return true;
- };
-
- // A difficult-to-believe, but optimized internal dispatch function for
- // triggering events. Tries to keep the usual cases speedy (most internal
- // Backbone events have 3 arguments).
- var triggerEvents = function(events, args) {
- var ev, i = -1, l = events.length, a1 = args[0], a2 = args[1], a3 = args[2];
- switch (args.length) {
- case 0: while (++i < l) (ev = events[i]).callback.call(ev.ctx); return;
- case 1: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1); return;
- case 2: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2); return;
- case 3: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2, a3); return;
- default: while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args);
- }
- };
-
- var listenMethods = {listenTo: 'on', listenToOnce: 'once'};
-
- // Inversion-of-control versions of `on` and `once`. Tell *this* object to
- // listen to an event in another object ... keeping track of what it's
- // listening to.
- _.each(listenMethods, function(implementation, method) {
- Events[method] = function(obj, name, callback) {
- var listeners = this._listeners || (this._listeners = {});
- var id = obj._listenerId || (obj._listenerId = _.uniqueId('l'));
- listeners[id] = obj;
- if (typeof name === 'object') callback = this;
- obj[implementation](name, callback, this);
- return this;
- };
- });
-
- // Aliases for backwards compatibility.
- Events.bind = Events.on;
- Events.unbind = Events.off;
-
- // Allow the `Backbone` object to serve as a global event bus, for folks who
- // want global "pubsub" in a convenient place.
- _.extend(Backbone, Events);
-
- // Backbone.Model
- // --------------
-
- // Backbone **Models** are the basic data object in the framework --
- // frequently representing a row in a table in a database on your server.
- // A discrete chunk of data and a bunch of useful, related methods for
- // performing computations and transformations on that data.
-
- // Create a new model with the specified attributes. A client id (`cid`)
- // is automatically generated and assigned for you.
- var Model = Backbone.Model = function(attributes, options) {
- var defaults;
- var attrs = attributes || {};
- options || (options = {});
- this.cid = _.uniqueId('c');
- this.attributes = {};
- _.extend(this, _.pick(options, modelOptions));
- if (options.parse) attrs = this.parse(attrs, options) || {};
- if (defaults = _.result(this, 'defaults')) {
- attrs = _.defaults({}, attrs, defaults);
- }
- this.set(attrs, options);
- this.changed = {};
- this.initialize.apply(this, arguments);
- };
-
- // A list of options to be attached directly to the model, if provided.
- var modelOptions = ['url', 'urlRoot', 'collection'];
-
- // Attach all inheritable methods to the Model prototype.
- _.extend(Model.prototype, Events, {
-
- // A hash of attributes whose current and previous value differ.
- changed: null,
-
- // The value returned during the last failed validation.
- validationError: null,
-
- // The default name for the JSON `id` attribute is `"id"`. MongoDB and
- // CouchDB users may want to set this to `"_id"`.
- idAttribute: 'id',
-
- // Initialize is an empty function by default. Override it with your own
- // initialization logic.
- initialize: function(){},
-
- // Return a copy of the model's `attributes` object.
- toJSON: function(options) {
- return _.clone(this.attributes);
- },
-
- // Proxy `Backbone.sync` by default -- but override this if you need
- // custom syncing semantics for *this* particular model.
- sync: function() {
- return Backbone.sync.apply(this, arguments);
- },
-
- // Get the value of an attribute.
- get: function(attr) {
- return this.attributes[attr];
- },
-
- // Get the HTML-escaped value of an attribute.
- escape: function(attr) {
- return _.escape(this.get(attr));
- },
-
- // Returns `true` if the attribute contains a value that is not null
- // or undefined.
- has: function(attr) {
- return this.get(attr) != null;
- },
-
- // Set a hash of model attributes on the object, firing `"change"`. This is
- // the core primitive operation of a model, updating the data and notifying
- // anyone who needs to know about the change in state. The heart of the beast.
- set: function(key, val, options) {
- var attr, attrs, unset, changes, silent, changing, prev, current;
- if (key == null) return this;
-
- // Handle both `"key", value` and `{key: value}` -style arguments.
- if (typeof key === 'object') {
- attrs = key;
- options = val;
- } else {
- (attrs = {})[key] = val;
- }
-
- options || (options = {});
-
- // Run validation.
- if (!this._validate(attrs, options)) return false;
-
- // Extract attributes and options.
- unset = options.unset;
- silent = options.silent;
- changes = [];
- changing = this._changing;
- this._changing = true;
-
- if (!changing) {
- this._previousAttributes = _.clone(this.attributes);
- this.changed = {};
- }
- current = this.attributes, prev = this._previousAttributes;
-
- // Check for changes of `id`.
- if (this.idAttribute in attrs) this.id = attrs[this.idAttribute];
-
- // For each `set` attribute, update or delete the current value.
- for (attr in attrs) {
- val = attrs[attr];
- if (!_.isEqual(current[attr], val)) changes.push(attr);
- if (!_.isEqual(prev[attr], val)) {
- this.changed[attr] = val;
- } else {
- delete this.changed[attr];
- }
- unset ? delete current[attr] : current[attr] = val;
- }
-
- // Trigger all relevant attribute changes.
- if (!silent) {
- if (changes.length) this._pending = true;
- for (var i = 0, l = changes.length; i < l; i++) {
- this.trigger('change:' + changes[i], this, current[changes[i]], options);
- }
- }
-
- // You might be wondering why there's a `while` loop here. Changes can
- // be recursively nested within `"change"` events.
- if (changing) return this;
- if (!silent) {
- while (this._pending) {
- this._pending = false;
- this.trigger('change', this, options);
- }
- }
- this._pending = false;
- this._changing = false;
- return this;
- },
-
- // Remove an attribute from the model, firing `"change"`. `unset` is a noop
- // if the attribute doesn't exist.
- unset: function(attr, options) {
- return this.set(attr, void 0, _.extend({}, options, {unset: true}));
- },
-
- // Clear all attributes on the model, firing `"change"`.
- clear: function(options) {
- var attrs = {};
- for (var key in this.attributes) attrs[key] = void 0;
- return this.set(attrs, _.extend({}, options, {unset: true}));
- },
-
- // Determine if the model has changed since the last `"change"` event.
- // If you specify an attribute name, determine if that attribute has changed.
- hasChanged: function(attr) {
- if (attr == null) return !_.isEmpty(this.changed);
- return _.has(this.changed, attr);
- },
-
- // Return an object containing all the attributes that have changed, or
- // false if there are no changed attributes. Useful for determining what
- // parts of a view need to be updated and/or what attributes need to be
- // persisted to the server. Unset attributes will be set to undefined.
- // You can also pass an attributes object to diff against the model,
- // determining if there *would be* a change.
- changedAttributes: function(diff) {
- if (!diff) return this.hasChanged() ? _.clone(this.changed) : false;
- var val, changed = false;
- var old = this._changing ? this._previousAttributes : this.attributes;
- for (var attr in diff) {
- if (_.isEqual(old[attr], (val = diff[attr]))) continue;
- (changed || (changed = {}))[attr] = val;
- }
- return changed;
- },
-
- // Get the previous value of an attribute, recorded at the time the last
- // `"change"` event was fired.
- previous: function(attr) {
- if (attr == null || !this._previousAttributes) return null;
- return this._previousAttributes[attr];
- },
-
- // Get all of the attributes of the model at the time of the previous
- // `"change"` event.
- previousAttributes: function() {
- return _.clone(this._previousAttributes);
- },
-
- // Fetch the model from the server. If the server's representation of the
- // model differs from its current attributes, they will be overridden,
- // triggering a `"change"` event.
- fetch: function(options) {
- options = options ? _.clone(options) : {};
- if (options.parse === void 0) options.parse = true;
- var model = this;
- var success = options.success;
- options.success = function(resp) {
- if (!model.set(model.parse(resp, options), options)) return false;
- if (success) success(model, resp, options);
- model.trigger('sync', model, resp, options);
- };
- wrapError(this, options);
- return this.sync('read', this, options);
- },
-
- // Set a hash of model attributes, and sync the model to the server.
- // If the server returns an attributes hash that differs, the model's
- // state will be `set` again.
- save: function(key, val, options) {
- var attrs, method, xhr, attributes = this.attributes;
-
- // Handle both `"key", value` and `{key: value}` -style arguments.
- if (key == null || typeof key === 'object') {
- attrs = key;
- options = val;
- } else {
- (attrs = {})[key] = val;
- }
-
- // If we're not waiting and attributes exist, save acts as `set(attr).save(null, opts)`.
- if (attrs && (!options || !options.wait) && !this.set(attrs, options)) return false;
-
- options = _.extend({validate: true}, options);
-
- // Do not persist invalid models.
- if (!this._validate(attrs, options)) return false;
-
- // Set temporary attributes if `{wait: true}`.
- if (attrs && options.wait) {
- this.attributes = _.extend({}, attributes, attrs);
- }
-
- // After a successful server-side save, the client is (optionally)
- // updated with the server-side state.
- if (options.parse === void 0) options.parse = true;
- var model = this;
- var success = options.success;
- options.success = function(resp) {
- // Ensure attributes are restored during synchronous saves.
- model.attributes = attributes;
- var serverAttrs = model.parse(resp, options);
- if (options.wait) serverAttrs = _.extend(attrs || {}, serverAttrs);
- if (_.isObject(serverAttrs) && !model.set(serverAttrs, options)) {
- return false;
- }
- if (success) success(model, resp, options);
- model.trigger('sync', model, resp, options);
- };
- wrapError(this, options);
-
- method = this.isNew() ? 'create' : (options.patch ? 'patch' : 'update');
- if (method === 'patch') options.attrs = attrs;
- xhr = this.sync(method, this, options);
-
- // Restore attributes.
- if (attrs && options.wait) this.attributes = attributes;
-
- return xhr;
- },
-
- // Destroy this model on the server if it was already persisted.
- // Optimistically removes the model from its collection, if it has one.
- // If `wait: true` is passed, waits for the server to respond before removal.
- destroy: function(options) {
- options = options ? _.clone(options) : {};
- var model = this;
- var success = options.success;
-
- var destroy = function() {
- model.trigger('destroy', model, model.collection, options);
- };
-
- options.success = function(resp) {
- if (options.wait || model.isNew()) destroy();
- if (success) success(model, resp, options);
- if (!model.isNew()) model.trigger('sync', model, resp, options);
- };
-
- if (this.isNew()) {
- options.success();
- return false;
- }
- wrapError(this, options);
-
- var xhr = this.sync('delete', this, options);
- if (!options.wait) destroy();
- return xhr;
- },
-
- // Default URL for the model's representation on the server -- if you're
- // using Backbone's restful methods, override this to change the endpoint
- // that will be called.
- url: function() {
- var base = _.result(this, 'urlRoot') || _.result(this.collection, 'url') || urlError();
- if (this.isNew()) return base;
- return base + (base.charAt(base.length - 1) === '/' ? '' : '/') + encodeURIComponent(this.id);
- },
-
- // **parse** converts a response into the hash of attributes to be `set` on
- // the model. The default implementation is just to pass the response along.
- parse: function(resp, options) {
- return resp;
- },
-
- // Create a new model with identical attributes to this one.
- clone: function() {
- return new this.constructor(this.attributes);
- },
-
- // A model is new if it has never been saved to the server, and lacks an id.
- isNew: function() {
- return this.id == null;
- },
-
- // Check if the model is currently in a valid state.
- isValid: function(options) {
- return this._validate({}, _.extend(options || {}, { validate: true }));
- },
-
- // Run validation against the next complete set of model attributes,
- // returning `true` if all is well. Otherwise, fire an `"invalid"` event.
- _validate: function(attrs, options) {
- if (!options.validate || !this.validate) return true;
- attrs = _.extend({}, this.attributes, attrs);
- var error = this.validationError = this.validate(attrs, options) || null;
- if (!error) return true;
- this.trigger('invalid', this, error, _.extend(options || {}, {validationError: error}));
- return false;
- }
-
- });
-
- // Underscore methods that we want to implement on the Model.
- var modelMethods = ['keys', 'values', 'pairs', 'invert', 'pick', 'omit'];
-
- // Mix in each Underscore method as a proxy to `Model#attributes`.
- _.each(modelMethods, function(method) {
- Model.prototype[method] = function() {
- var args = slice.call(arguments);
- args.unshift(this.attributes);
- return _[method].apply(_, args);
- };
- });
-
- // Backbone.Collection
- // -------------------
-
- // If models tend to represent a single row of data, a Backbone Collection is
- // more analagous to a table full of data ... or a small slice or page of that
- // table, or a collection of rows that belong together for a particular reason
- // -- all of the messages in this particular folder, all of the documents
- // belonging to this particular author, and so on. Collections maintain
- // indexes of their models, both in order, and for lookup by `id`.
-
- // Create a new **Collection**, perhaps to contain a specific type of `model`.
- // If a `comparator` is specified, the Collection will maintain
- // its models in sort order, as they're added and removed.
- var Collection = Backbone.Collection = function(models, options) {
- options || (options = {});
- if (options.url) this.url = options.url;
- if (options.model) this.model = options.model;
- if (options.comparator !== void 0) this.comparator = options.comparator;
- this._reset();
- this.initialize.apply(this, arguments);
- if (models) this.reset(models, _.extend({silent: true}, options));
- };
-
- // Default options for `Collection#set`.
- var setOptions = {add: true, remove: true, merge: true};
- var addOptions = {add: true, merge: false, remove: false};
-
- // Define the Collection's inheritable methods.
- _.extend(Collection.prototype, Events, {
-
- // The default model for a collection is just a **Backbone.Model**.
- // This should be overridden in most cases.
- model: Model,
-
- // Initialize is an empty function by default. Override it with your own
- // initialization logic.
- initialize: function(){},
-
- // The JSON representation of a Collection is an array of the
- // models' attributes.
- toJSON: function(options) {
- return this.map(function(model){ return model.toJSON(options); });
- },
-
- // Proxy `Backbone.sync` by default.
- sync: function() {
- return Backbone.sync.apply(this, arguments);
- },
-
- // Add a model, or list of models to the set.
- add: function(models, options) {
- return this.set(models, _.defaults(options || {}, addOptions));
- },
-
- // Remove a model, or a list of models from the set.
- remove: function(models, options) {
- models = _.isArray(models) ? models.slice() : [models];
- options || (options = {});
- var i, l, index, model;
- for (i = 0, l = models.length; i < l; i++) {
- model = this.get(models[i]);
- if (!model) continue;
- delete this._byId[model.id];
- delete this._byId[model.cid];
- index = this.indexOf(model);
- this.models.splice(index, 1);
- this.length--;
- if (!options.silent) {
- options.index = index;
- model.trigger('remove', model, this, options);
- }
- this._removeReference(model);
- }
- return this;
- },
-
- // Update a collection by `set`-ing a new list of models, adding new ones,
- // removing models that are no longer present, and merging models that
- // already exist in the collection, as necessary. Similar to **Model#set**,
- // the core operation for updating the data contained by the collection.
- set: function(models, options) {
- options = _.defaults(options || {}, setOptions);
- if (options.parse) models = this.parse(models, options);
- if (!_.isArray(models)) models = models ? [models] : [];
- var i, l, model, attrs, existing, sort;
- var at = options.at;
- var sortable = this.comparator && (at == null) && options.sort !== false;
- var sortAttr = _.isString(this.comparator) ? this.comparator : null;
- var toAdd = [], toRemove = [], modelMap = {};
-
- // Turn bare objects into model references, and prevent invalid models
- // from being added.
- for (i = 0, l = models.length; i < l; i++) {
- if (!(model = this._prepareModel(models[i], options))) continue;
-
- // If a duplicate is found, prevent it from being added and
- // optionally merge it into the existing model.
- if (existing = this.get(model)) {
- if (options.remove) modelMap[existing.cid] = true;
- if (options.merge) {
- existing.set(model.attributes, options);
- if (sortable && !sort && existing.hasChanged(sortAttr)) sort = true;
- }
-
- // This is a new model, push it to the `toAdd` list.
- } else if (options.add) {
- toAdd.push(model);
-
- // Listen to added models' events, and index models for lookup by
- // `id` and by `cid`.
- model.on('all', this._onModelEvent, this);
- this._byId[model.cid] = model;
- if (model.id != null) this._byId[model.id] = model;
- }
- }
-
- // Remove nonexistent models if appropriate.
- if (options.remove) {
- for (i = 0, l = this.length; i < l; ++i) {
- if (!modelMap[(model = this.models[i]).cid]) toRemove.push(model);
- }
- if (toRemove.length) this.remove(toRemove, options);
- }
-
- // See if sorting is needed, update `length` and splice in new models.
- if (toAdd.length) {
- if (sortable) sort = true;
- this.length += toAdd.length;
- if (at != null) {
- splice.apply(this.models, [at, 0].concat(toAdd));
- } else {
- push.apply(this.models, toAdd);
- }
- }
-
- // Silently sort the collection if appropriate.
- if (sort) this.sort({silent: true});
-
- if (options.silent) return this;
-
- // Trigger `add` events.
- for (i = 0, l = toAdd.length; i < l; i++) {
- (model = toAdd[i]).trigger('add', model, this, options);
- }
-
- // Trigger `sort` if the collection was sorted.
- if (sort) this.trigger('sort', this, options);
- return this;
- },
-
- // When you have more items than you want to add or remove individually,
- // you can reset the entire set with a new list of models, without firing
- // any granular `add` or `remove` events. Fires `reset` when finished.
- // Useful for bulk operations and optimizations.
- reset: function(models, options) {
- options || (options = {});
- for (var i = 0, l = this.models.length; i < l; i++) {
- this._removeReference(this.models[i]);
- }
- options.previousModels = this.models;
- this._reset();
- this.add(models, _.extend({silent: true}, options));
- if (!options.silent) this.trigger('reset', this, options);
- return this;
- },
-
- // Add a model to the end of the collection.
- push: function(model, options) {
- model = this._prepareModel(model, options);
- this.add(model, _.extend({at: this.length}, options));
- return model;
- },
-
- // Remove a model from the end of the collection.
- pop: function(options) {
- var model = this.at(this.length - 1);
- this.remove(model, options);
- return model;
- },
-
- // Add a model to the beginning of the collection.
- unshift: function(model, options) {
- model = this._prepareModel(model, options);
- this.add(model, _.extend({at: 0}, options));
- return model;
- },
-
- // Remove a model from the beginning of the collection.
- shift: function(options) {
- var model = this.at(0);
- this.remove(model, options);
- return model;
- },
-
- // Slice out a sub-array of models from the collection.
- slice: function(begin, end) {
- return this.models.slice(begin, end);
- },
-
- // Get a model from the set by id.
- get: function(obj) {
- if (obj == null) return void 0;
- return this._byId[obj.id != null ? obj.id : obj.cid || obj];
- },
-
- // Get the model at the given index.
- at: function(index) {
- return this.models[index];
- },
-
- // Return models with matching attributes. Useful for simple cases of
- // `filter`.
- where: function(attrs, first) {
- if (_.isEmpty(attrs)) return first ? void 0 : [];
- return this[first ? 'find' : 'filter'](function(model) {
- for (var key in attrs) {
- if (attrs[key] !== model.get(key)) return false;
- }
- return true;
- });
- },
-
- // Return the first model with matching attributes. Useful for simple cases
- // of `find`.
- findWhere: function(attrs) {
- return this.where(attrs, true);
- },
-
- // Force the collection to re-sort itself. You don't need to call this under
- // normal circumstances, as the set will maintain sort order as each item
- // is added.
- sort: function(options) {
- if (!this.comparator) throw new Error('Cannot sort a set without a comparator');
- options || (options = {});
-
- // Run sort based on type of `comparator`.
- if (_.isString(this.comparator) || this.comparator.length === 1) {
- this.models = this.sortBy(this.comparator, this);
- } else {
- this.models.sort(_.bind(this.comparator, this));
- }
-
- if (!options.silent) this.trigger('sort', this, options);
- return this;
- },
-
- // Figure out the smallest index at which a model should be inserted so as
- // to maintain order.
- sortedIndex: function(model, value, context) {
- value || (value = this.comparator);
- var iterator = _.isFunction(value) ? value : function(model) {
- return model.get(value);
- };
- return _.sortedIndex(this.models, model, iterator, context);
- },
-
- // Pluck an attribute from each model in the collection.
- pluck: function(attr) {
- return _.invoke(this.models, 'get', attr);
- },
-
- // Fetch the default set of models for this collection, resetting the
- // collection when they arrive. If `reset: true` is passed, the response
- // data will be passed through the `reset` method instead of `set`.
- fetch: function(options) {
- options = options ? _.clone(options) : {};
- if (options.parse === void 0) options.parse = true;
- var success = options.success;
- var collection = this;
- options.success = function(resp) {
- var method = options.reset ? 'reset' : 'set';
- collection[method](resp, options);
- if (success) success(collection, resp, options);
- collection.trigger('sync', collection, resp, options);
- };
- wrapError(this, options);
- return this.sync('read', this, options);
- },
-
- // Create a new instance of a model in this collection. Add the model to the
- // collection immediately, unless `wait: true` is passed, in which case we
- // wait for the server to agree.
- create: function(model, options) {
- options = options ? _.clone(options) : {};
- if (!(model = this._prepareModel(model, options))) return false;
- if (!options.wait) this.add(model, options);
- var collection = this;
- var success = options.success;
- options.success = function(resp) {
- if (options.wait) collection.add(model, options);
- if (success) success(model, resp, options);
- };
- model.save(null, options);
- return model;
- },
-
- // **parse** converts a response into a list of models to be added to the
- // collection. The default implementation is just to pass it through.
- parse: function(resp, options) {
- return resp;
- },
-
- // Create a new collection with an identical list of models as this one.
- clone: function() {
- return new this.constructor(this.models);
- },
-
- // Private method to reset all internal state. Called when the collection
- // is first initialized or reset.
- _reset: function() {
- this.length = 0;
- this.models = [];
- this._byId = {};
- },
-
- // Prepare a hash of attributes (or other model) to be added to this
- // collection.
- _prepareModel: function(attrs, options) {
- if (attrs instanceof Model) {
- if (!attrs.collection) attrs.collection = this;
- return attrs;
- }
- options || (options = {});
- options.collection = this;
- var model = new this.model(attrs, options);
- if (!model._validate(attrs, options)) {
- this.trigger('invalid', this, attrs, options);
- return false;
- }
- return model;
- },
-
- // Internal method to sever a model's ties to a collection.
- _removeReference: function(model) {
- if (this === model.collection) delete model.collection;
- model.off('all', this._onModelEvent, this);
- },
-
- // Internal method called every time a model in the set fires an event.
- // Sets need to update their indexes when models change ids. All other
- // events simply proxy through. "add" and "remove" events that originate
- // in other collections are ignored.
- _onModelEvent: function(event, model, collection, options) {
- if ((event === 'add' || event === 'remove') && collection !== this) return;
- if (event === 'destroy') this.remove(model, options);
- if (model && event === 'change:' + model.idAttribute) {
- delete this._byId[model.previous(model.idAttribute)];
- if (model.id != null) this._byId[model.id] = model;
- }
- this.trigger.apply(this, arguments);
- }
-
- });
-
- // Underscore methods that we want to implement on the Collection.
- // 90% of the core usefulness of Backbone Collections is actually implemented
- // right here:
- var methods = ['forEach', 'each', 'map', 'collect', 'reduce', 'foldl',
- 'inject', 'reduceRight', 'foldr', 'find', 'detect', 'filter', 'select',
- 'reject', 'every', 'all', 'some', 'any', 'include', 'contains', 'invoke',
- 'max', 'min', 'toArray', 'size', 'first', 'head', 'take', 'initial', 'rest',
- 'tail', 'drop', 'last', 'without', 'indexOf', 'shuffle', 'lastIndexOf',
- 'isEmpty', 'chain'];
-
- // Mix in each Underscore method as a proxy to `Collection#models`.
- _.each(methods, function(method) {
- Collection.prototype[method] = function() {
- var args = slice.call(arguments);
- args.unshift(this.models);
- return _[method].apply(_, args);
- };
- });
-
- // Underscore methods that take a property name as an argument.
- var attributeMethods = ['groupBy', 'countBy', 'sortBy'];
-
- // Use attributes instead of properties.
- _.each(attributeMethods, function(method) {
- Collection.prototype[method] = function(value, context) {
- var iterator = _.isFunction(value) ? value : function(model) {
- return model.get(value);
- };
- return _[method](this.models, iterator, context);
- };
- });
-
- // Backbone.View
- // -------------
-
- // Backbone Views are almost more convention than they are actual code. A View
- // is simply a JavaScript object that represents a logical chunk of UI in the
- // DOM. This might be a single item, an entire list, a sidebar or panel, or
- // even the surrounding frame which wraps your whole app. Defining a chunk of
- // UI as a **View** allows you to define your DOM events declaratively, without
- // having to worry about render order ... and makes it easy for the view to
- // react to specific changes in the state of your models.
-
- // Creating a Backbone.View creates its initial element outside of the DOM,
- // if an existing element is not provided...
- var View = Backbone.View = function(options) {
- this.cid = _.uniqueId('view');
- this._configure(options || {});
- this._ensureElement();
- this.initialize.apply(this, arguments);
- this.delegateEvents();
- };
-
- // Cached regex to split keys for `delegate`.
- var delegateEventSplitter = /^(\S+)\s*(.*)$/;
-
- // List of view options to be merged as properties.
- var viewOptions = ['model', 'collection', 'el', 'id', 'attributes', 'className', 'tagName', 'events'];
-
- // Set up all inheritable **Backbone.View** properties and methods.
- _.extend(View.prototype, Events, {
-
- // The default `tagName` of a View's element is `"div"`.
- tagName: 'div',
-
- // jQuery delegate for element lookup, scoped to DOM elements within the
- // current view. This should be prefered to global lookups where possible.
- $: function(selector) {
- return this.$el.find(selector);
- },
-
- // Initialize is an empty function by default. Override it with your own
- // initialization logic.
- initialize: function(){},
-
- // **render** is the core function that your view should override, in order
- // to populate its element (`this.el`), with the appropriate HTML. The
- // convention is for **render** to always return `this`.
- render: function() {
- return this;
- },
-
- // Remove this view by taking the element out of the DOM, and removing any
- // applicable Backbone.Events listeners.
- remove: function() {
- this.$el.remove();
- this.stopListening();
- return this;
- },
-
- // Change the view's element (`this.el` property), including event
- // re-delegation.
- setElement: function(element, delegate) {
- if (this.$el) this.undelegateEvents();
- this.$el = element instanceof Backbone.$ ? element : Backbone.$(element);
- this.el = this.$el[0];
- if (delegate !== false) this.delegateEvents();
- return this;
- },
-
- // Set callbacks, where `this.events` is a hash of
- //
- // *{"event selector": "callback"}*
- //
- // {
- // 'mousedown .title': 'edit',
- // 'click .button': 'save'
- // 'click .open': function(e) { ... }
- // }
- //
- // pairs. Callbacks will be bound to the view, with `this` set properly.
- // Uses event delegation for efficiency.
- // Omitting the selector binds the event to `this.el`.
- // This only works for delegate-able events: not `focus`, `blur`, and
- // not `change`, `submit`, and `reset` in Internet Explorer.
- delegateEvents: function(events) {
- if (!(events || (events = _.result(this, 'events')))) return this;
- this.undelegateEvents();
- for (var key in events) {
- var method = events[key];
- if (!_.isFunction(method)) method = this[events[key]];
- if (!method) continue;
-
- var match = key.match(delegateEventSplitter);
- var eventName = match[1], selector = match[2];
- method = _.bind(method, this);
- eventName += '.delegateEvents' + this.cid;
- if (selector === '') {
- this.$el.on(eventName, method);
- } else {
- this.$el.on(eventName, selector, method);
- }
- }
- return this;
- },
-
- // Clears all callbacks previously bound to the view with `delegateEvents`.
- // You usually don't need to use this, but may wish to if you have multiple
- // Backbone views attached to the same DOM element.
- undelegateEvents: function() {
- this.$el.off('.delegateEvents' + this.cid);
- return this;
- },
-
- // Performs the initial configuration of a View with a set of options.
- // Keys with special meaning *(e.g. model, collection, id, className)* are
- // attached directly to the view. See `viewOptions` for an exhaustive
- // list.
- _configure: function(options) {
- if (this.options) options = _.extend({}, _.result(this, 'options'), options);
- _.extend(this, _.pick(options, viewOptions));
- this.options = options;
- },
-
- // Ensure that the View has a DOM element to render into.
- // If `this.el` is a string, pass it through `$()`, take the first
- // matching element, and re-assign it to `el`. Otherwise, create
- // an element from the `id`, `className` and `tagName` properties.
- _ensureElement: function() {
- if (!this.el) {
- var attrs = _.extend({}, _.result(this, 'attributes'));
- if (this.id) attrs.id = _.result(this, 'id');
- if (this.className) attrs['class'] = _.result(this, 'className');
- var $el = Backbone.$('<' + _.result(this, 'tagName') + '>').attr(attrs);
- this.setElement($el, false);
- } else {
- this.setElement(_.result(this, 'el'), false);
- }
- }
-
- });
-
- // Backbone.sync
- // -------------
-
- // Override this function to change the manner in which Backbone persists
- // models to the server. You will be passed the type of request, and the
- // model in question. By default, makes a RESTful Ajax request
- // to the model's `url()`. Some possible customizations could be:
- //
- // * Use `setTimeout` to batch rapid-fire updates into a single request.
- // * Send up the models as XML instead of JSON.
- // * Persist models via WebSockets instead of Ajax.
- //
- // Turn on `Backbone.emulateHTTP` in order to send `PUT` and `DELETE` requests
- // as `POST`, with a `_method` parameter containing the true HTTP method,
- // as well as all requests with the body as `application/x-www-form-urlencoded`
- // instead of `application/json` with the model in a param named `model`.
- // Useful when interfacing with server-side languages like **PHP** that make
- // it difficult to read the body of `PUT` requests.
- Backbone.sync = function(method, model, options) {
- var type = methodMap[method];
-
- // Default options, unless specified.
- _.defaults(options || (options = {}), {
- emulateHTTP: Backbone.emulateHTTP,
- emulateJSON: Backbone.emulateJSON
- });
-
- // Default JSON-request options.
- var params = {type: type, dataType: 'json'};
-
- // Ensure that we have a URL.
- if (!options.url) {
- params.url = _.result(model, 'url') || urlError();
- }
-
- // Ensure that we have the appropriate request data.
- if (options.data == null && model && (method === 'create' || method === 'update' || method === 'patch')) {
- params.contentType = 'application/json';
- params.data = JSON.stringify(options.attrs || model.toJSON(options));
- }
-
- // For older servers, emulate JSON by encoding the request into an HTML-form.
- if (options.emulateJSON) {
- params.contentType = 'application/x-www-form-urlencoded';
- params.data = params.data ? {model: params.data} : {};
- }
-
- // For older servers, emulate HTTP by mimicking the HTTP method with `_method`
- // And an `X-HTTP-Method-Override` header.
- if (options.emulateHTTP && (type === 'PUT' || type === 'DELETE' || type === 'PATCH')) {
- params.type = 'POST';
- if (options.emulateJSON) params.data._method = type;
- var beforeSend = options.beforeSend;
- options.beforeSend = function(xhr) {
- xhr.setRequestHeader('X-HTTP-Method-Override', type);
- if (beforeSend) return beforeSend.apply(this, arguments);
- };
- }
-
- // Don't process data on a non-GET request.
- if (params.type !== 'GET' && !options.emulateJSON) {
- params.processData = false;
- }
-
- // If we're sending a `PATCH` request, and we're in an old Internet Explorer
- // that still has ActiveX enabled by default, override jQuery to use that
- // for XHR instead. Remove this line when jQuery supports `PATCH` on IE8.
- if (params.type === 'PATCH' && window.ActiveXObject &&
- !(window.external && window.external.msActiveXFilteringEnabled)) {
- params.xhr = function() {
- return new ActiveXObject("Microsoft.XMLHTTP");
- };
- }
-
- // Make the request, allowing the user to override any Ajax options.
- var xhr = options.xhr = Backbone.ajax(_.extend(params, options));
- model.trigger('request', model, xhr, options);
- return xhr;
- };
-
- // Map from CRUD to HTTP for our default `Backbone.sync` implementation.
- var methodMap = {
- 'create': 'POST',
- 'update': 'PUT',
- 'patch': 'PATCH',
- 'delete': 'DELETE',
- 'read': 'GET'
- };
-
- // Set the default implementation of `Backbone.ajax` to proxy through to `$`.
- // Override this if you'd like to use a different library.
- Backbone.ajax = function() {
- return Backbone.$.ajax.apply(Backbone.$, arguments);
- };
-
- // Backbone.Router
- // ---------------
-
- // Routers map faux-URLs to actions, and fire events when routes are
- // matched. Creating a new one sets its `routes` hash, if not set statically.
- var Router = Backbone.Router = function(options) {
- options || (options = {});
- if (options.routes) this.routes = options.routes;
- this._bindRoutes();
- this.initialize.apply(this, arguments);
- };
-
- // Cached regular expressions for matching named param parts and splatted
- // parts of route strings.
- var optionalParam = /\((.*?)\)/g;
- var namedParam = /(\(\?)?:\w+/g;
- var splatParam = /\*\w+/g;
- var escapeRegExp = /[\-{}\[\]+?.,\\\^$|#\s]/g;
-
- // Set up all inheritable **Backbone.Router** properties and methods.
- _.extend(Router.prototype, Events, {
-
- // Initialize is an empty function by default. Override it with your own
- // initialization logic.
- initialize: function(){},
-
- // Manually bind a single named route to a callback. For example:
- //
- // this.route('search/:query/p:num', 'search', function(query, num) {
- // ...
- // });
- //
- route: function(route, name, callback) {
- if (!_.isRegExp(route)) route = this._routeToRegExp(route);
- if (_.isFunction(name)) {
- callback = name;
- name = '';
- }
- if (!callback) callback = this[name];
- var router = this;
- Backbone.history.route(route, function(fragment) {
- var args = router._extractParameters(route, fragment);
- callback && callback.apply(router, args);
- router.trigger.apply(router, ['route:' + name].concat(args));
- router.trigger('route', name, args);
- Backbone.history.trigger('route', router, name, args);
- });
- return this;
- },
-
- // Simple proxy to `Backbone.history` to save a fragment into the history.
- navigate: function(fragment, options) {
- Backbone.history.navigate(fragment, options);
- return this;
- },
-
- // Bind all defined routes to `Backbone.history`. We have to reverse the
- // order of the routes here to support behavior where the most general
- // routes can be defined at the bottom of the route map.
- _bindRoutes: function() {
- if (!this.routes) return;
- this.routes = _.result(this, 'routes');
- var route, routes = _.keys(this.routes);
- while ((route = routes.pop()) != null) {
- this.route(route, this.routes[route]);
- }
- },
-
- // Convert a route string into a regular expression, suitable for matching
- // against the current location hash.
- _routeToRegExp: function(route) {
- route = route.replace(escapeRegExp, '\\$&')
- .replace(optionalParam, '(?:$1)?')
- .replace(namedParam, function(match, optional){
- return optional ? match : '([^\/]+)';
- })
- .replace(splatParam, '(.*?)');
- return new RegExp('^' + route + '$');
- },
-
- // Given a route, and a URL fragment that it matches, return the array of
- // extracted decoded parameters. Empty or unmatched parameters will be
- // treated as `null` to normalize cross-browser behavior.
- _extractParameters: function(route, fragment) {
- var params = route.exec(fragment).slice(1);
- return _.map(params, function(param) {
- return param ? decodeURIComponent(param) : null;
- });
- }
-
- });
-
- // Backbone.History
- // ----------------
-
- // Handles cross-browser history management, based on either
- // [pushState](http://diveintohtml5.info/history.html) and real URLs, or
- // [onhashchange](https://developer.mozilla.org/en-US/docs/DOM/window.onhashchange)
- // and URL fragments. If the browser supports neither (old IE, natch),
- // falls back to polling.
- var History = Backbone.History = function() {
- this.handlers = [];
- _.bindAll(this, 'checkUrl');
-
- // Ensure that `History` can be used outside of the browser.
- if (typeof window !== 'undefined') {
- this.location = window.location;
- this.history = window.history;
- }
- };
-
- // Cached regex for stripping a leading hash/slash and trailing space.
- var routeStripper = /^[#\/]|\s+$/g;
-
- // Cached regex for stripping leading and trailing slashes.
- var rootStripper = /^\/+|\/+$/g;
-
- // Cached regex for detecting MSIE.
- var isExplorer = /msie [\w.]+/;
-
- // Cached regex for removing a trailing slash.
- var trailingSlash = /\/$/;
-
- // Has the history handling already been started?
- History.started = false;
-
- // Set up all inheritable **Backbone.History** properties and methods.
- _.extend(History.prototype, Events, {
-
- // The default interval to poll for hash changes, if necessary, is
- // twenty times a second.
- interval: 50,
-
- // Gets the true hash value. Cannot use location.hash directly due to bug
- // in Firefox where location.hash will always be decoded.
- getHash: function(window) {
- var match = (window || this).location.href.match(/#(.*)$/);
- return match ? match[1] : '';
- },
-
- // Get the cross-browser normalized URL fragment, either from the URL,
- // the hash, or the override.
- getFragment: function(fragment, forcePushState) {
- if (fragment == null) {
- if (this._hasPushState || !this._wantsHashChange || forcePushState) {
- fragment = this.location.pathname;
- var root = this.root.replace(trailingSlash, '');
- if (!fragment.indexOf(root)) fragment = fragment.substr(root.length);
- } else {
- fragment = this.getHash();
- }
- }
- return fragment.replace(routeStripper, '');
- },
-
- // Start the hash change handling, returning `true` if the current URL matches
- // an existing route, and `false` otherwise.
- start: function(options) {
- if (History.started) throw new Error("Backbone.history has already been started");
- History.started = true;
-
- // Figure out the initial configuration. Do we need an iframe?
- // Is pushState desired ... is it available?
- this.options = _.extend({}, {root: '/'}, this.options, options);
- this.root = this.options.root;
- this._wantsHashChange = this.options.hashChange !== false;
- this._wantsPushState = !!this.options.pushState;
- this._hasPushState = !!(this.options.pushState && this.history && this.history.pushState);
- var fragment = this.getFragment();
- var docMode = document.documentMode;
- var oldIE = (isExplorer.exec(navigator.userAgent.toLowerCase()) && (!docMode || docMode <= 7));
-
- // Normalize root to always include a leading and trailing slash.
- this.root = ('/' + this.root + '/').replace(rootStripper, '/');
-
- if (oldIE && this._wantsHashChange) {
- this.iframe = Backbone.$('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo('body')[0].contentWindow;
- this.navigate(fragment);
- }
-
- // Depending on whether we're using pushState or hashes, and whether
- // 'onhashchange' is supported, determine how we check the URL state.
- if (this._hasPushState) {
- Backbone.$(window).on('popstate', this.checkUrl);
- } else if (this._wantsHashChange && ('onhashchange' in window) && !oldIE) {
- Backbone.$(window).on('hashchange', this.checkUrl);
- } else if (this._wantsHashChange) {
- this._checkUrlInterval = setInterval(this.checkUrl, this.interval);
- }
-
- // Determine if we need to change the base url, for a pushState link
- // opened by a non-pushState browser.
- this.fragment = fragment;
- var loc = this.location;
- var atRoot = loc.pathname.replace(/[^\/]$/, '$&/') === this.root;
-
- // If we've started off with a route from a `pushState`-enabled browser,
- // but we're currently in a browser that doesn't support it...
- if (this._wantsHashChange && this._wantsPushState && !this._hasPushState && !atRoot) {
- this.fragment = this.getFragment(null, true);
- this.location.replace(this.root + this.location.search + '#' + this.fragment);
- // Return immediately as browser will do redirect to new url
- return true;
-
- // Or if we've started out with a hash-based route, but we're currently
- // in a browser where it could be `pushState`-based instead...
- } else if (this._wantsPushState && this._hasPushState && atRoot && loc.hash) {
- this.fragment = this.getHash().replace(routeStripper, '');
- this.history.replaceState({}, document.title, this.root + this.fragment + loc.search);
- }
-
- if (!this.options.silent) return this.loadUrl();
- },
-
- // Disable Backbone.history, perhaps temporarily. Not useful in a real app,
- // but possibly useful for unit testing Routers.
- stop: function() {
- Backbone.$(window).off('popstate', this.checkUrl).off('hashchange', this.checkUrl);
- clearInterval(this._checkUrlInterval);
- History.started = false;
- },
-
- // Add a route to be tested when the fragment changes. Routes added later
- // may override previous routes.
- route: function(route, callback) {
- this.handlers.unshift({route: route, callback: callback});
- },
-
- // Checks the current URL to see if it has changed, and if it has,
- // calls `loadUrl`, normalizing across the hidden iframe.
- checkUrl: function(e) {
- var current = this.getFragment();
- if (current === this.fragment && this.iframe) {
- current = this.getFragment(this.getHash(this.iframe));
- }
- if (current === this.fragment) return false;
- if (this.iframe) this.navigate(current);
- this.loadUrl() || this.loadUrl(this.getHash());
- },
-
- // Attempt to load the current URL fragment. If a route succeeds with a
- // match, returns `true`. If no defined routes matches the fragment,
- // returns `false`.
- loadUrl: function(fragmentOverride) {
- var fragment = this.fragment = this.getFragment(fragmentOverride);
- var matched = _.any(this.handlers, function(handler) {
- if (handler.route.test(fragment)) {
- handler.callback(fragment);
- return true;
- }
- });
- return matched;
- },
-
- // Save a fragment into the hash history, or replace the URL state if the
- // 'replace' option is passed. You are responsible for properly URL-encoding
- // the fragment in advance.
- //
- // The options object can contain `trigger: true` if you wish to have the
- // route callback be fired (not usually desirable), or `replace: true`, if
- // you wish to modify the current URL without adding an entry to the history.
- navigate: function(fragment, options) {
- if (!History.started) return false;
- if (!options || options === true) options = {trigger: options};
- fragment = this.getFragment(fragment || '');
- if (this.fragment === fragment) return;
- this.fragment = fragment;
- var url = this.root + fragment;
-
- // If pushState is available, we use it to set the fragment as a real URL.
- if (this._hasPushState) {
- this.history[options.replace ? 'replaceState' : 'pushState']({}, document.title, url);
-
- // If hash changes haven't been explicitly disabled, update the hash
- // fragment to store history.
- } else if (this._wantsHashChange) {
- this._updateHash(this.location, fragment, options.replace);
- if (this.iframe && (fragment !== this.getFragment(this.getHash(this.iframe)))) {
- // Opening and closing the iframe tricks IE7 and earlier to push a
- // history entry on hash-tag change. When replace is true, we don't
- // want this.
- if(!options.replace) this.iframe.document.open().close();
- this._updateHash(this.iframe.location, fragment, options.replace);
- }
-
- // If you've told us that you explicitly don't want fallback hashchange-
- // based history, then `navigate` becomes a page refresh.
- } else {
- return this.location.assign(url);
- }
- if (options.trigger) this.loadUrl(fragment);
- },
-
- // Update the hash location, either replacing the current entry, or adding
- // a new one to the browser history.
- _updateHash: function(location, fragment, replace) {
- if (replace) {
- var href = location.href.replace(/(javascript:|#).*$/, '');
- location.replace(href + '#' + fragment);
- } else {
- // Some browsers require that `hash` contains a leading #.
- location.hash = '#' + fragment;
- }
- }
-
- });
-
- // Create the default Backbone.history.
- Backbone.history = new History;
-
- // Helpers
- // -------
-
- // Helper function to correctly set up the prototype chain, for subclasses.
- // Similar to `goog.inherits`, but uses a hash of prototype properties and
- // class properties to be extended.
- var extend = function(protoProps, staticProps) {
- var parent = this;
- var child;
-
- // The constructor function for the new subclass is either defined by you
- // (the "constructor" property in your `extend` definition), or defaulted
- // by us to simply call the parent's constructor.
- if (protoProps && _.has(protoProps, 'constructor')) {
- child = protoProps.constructor;
- } else {
- child = function(){ return parent.apply(this, arguments); };
- }
-
- // Add static properties to the constructor function, if supplied.
- _.extend(child, parent, staticProps);
-
- // Set the prototype chain to inherit from `parent`, without calling
- // `parent`'s constructor function.
- var Surrogate = function(){ this.constructor = child; };
- Surrogate.prototype = parent.prototype;
- child.prototype = new Surrogate;
-
- // Add prototype properties (instance properties) to the subclass,
- // if supplied.
- if (protoProps) _.extend(child.prototype, protoProps);
-
- // Set a convenience property in case the parent's prototype is needed
- // later.
- child.__super__ = parent.prototype;
-
- return child;
- };
-
- // Set up inheritance for the model, collection, router, view and history.
- Model.extend = Collection.extend = Router.extend = View.extend = History.extend = extend;
-
- // Throw an error when a URL is needed, and none is supplied.
- var urlError = function() {
- throw new Error('A "url" property or function must be specified');
- };
-
- // Wrap an optional error callback with a fallback error event.
- var wrapError = function (model, options) {
- var error = options.error;
- options.error = function(resp) {
- if (error) error(model, resp, options);
- model.trigger('error', model, resp, options);
- };
- };
-
-}).call(this);
[14/26] Remove fauxton from 1.4.x branch.
Posted by dj...@apache.org.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/js/libs/nv.d3.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/nv.d3.js b/src/fauxton/assets/js/libs/nv.d3.js
deleted file mode 100755
index 62ca71e..0000000
--- a/src/fauxton/assets/js/libs/nv.d3.js
+++ /dev/null
@@ -1,13048 +0,0 @@
-(function(){
-
-var nv = window.nv || {};
-
-nv.version = '0.0.1a';
-nv.dev = true //set false when in production
-
-window.nv = nv;
-
-nv.tooltip = {}; // For the tooltip system
-nv.utils = {}; // Utility subsystem
-nv.models = {}; //stores all the possible models/components
-nv.charts = {}; //stores all the ready to use charts
-nv.graphs = []; //stores all the graphs currently on the page
-nv.logs = {}; //stores some statistics and potential error messages
-
-nv.dispatch = d3.dispatch('render_start', 'render_end');
-
-// *************************************************************************
-// Development render timers - disabled if dev = false
-
-if (nv.dev) {
- nv.dispatch.on('render_start', function(e) {
- nv.logs.startTime = +new Date();
- });
-
- nv.dispatch.on('render_end', function(e) {
- nv.logs.endTime = +new Date();
- nv.logs.totalTime = nv.logs.endTime - nv.logs.startTime;
- nv.log('total', nv.logs.totalTime); // used for development, to keep track of graph generation times
- });
-}
-
-// ********************************************
-// Public Core NV functions
-
-// Logs all arguments, and returns the last so you can test things in place
-nv.log = function() {
- if (nv.dev && console.log && console.log.apply)
- console.log.apply(console, arguments)
- else if (nv.dev && console.log && Function.prototype.bind) {
- var log = Function.prototype.bind.call(console.log, console);
- log.apply(console, arguments);
- }
- return arguments[arguments.length - 1];
-};
-
-
-nv.render = function render(step) {
- step = step || 1; // number of graphs to generate in each timeout loop
-
- nv.render.active = true;
- nv.dispatch.render_start();
-
- setTimeout(function() {
- var chart, graph;
-
- for (var i = 0; i < step && (graph = nv.render.queue[i]); i++) {
- chart = graph.generate();
- if (typeof graph.callback == typeof(Function)) graph.callback(chart);
- nv.graphs.push(chart);
- }
-
- nv.render.queue.splice(0, i);
-
- if (nv.render.queue.length) setTimeout(arguments.callee, 0);
- else { nv.render.active = false; nv.dispatch.render_end(); }
- }, 0);
-};
-
-nv.render.active = false;
-nv.render.queue = [];
-
-nv.addGraph = function(obj) {
- if (typeof arguments[0] === typeof(Function))
- obj = {generate: arguments[0], callback: arguments[1]};
-
- nv.render.queue.push(obj);
-
- if (!nv.render.active) nv.render();
-};
-
-nv.identity = function(d) { return d; };
-
-nv.strip = function(s) { return s.replace(/(\s|&)/g,''); };
-
-function daysInMonth(month,year) {
- return (new Date(year, month+1, 0)).getDate();
-}
-
-function d3_time_range(floor, step, number) {
- return function(t0, t1, dt) {
- var time = floor(t0), times = [];
- if (time < t0) step(time);
- if (dt > 1) {
- while (time < t1) {
- var date = new Date(+time);
- if ((number(date) % dt === 0)) times.push(date);
- step(time);
- }
- } else {
- while (time < t1) { times.push(new Date(+time)); step(time); }
- }
- return times;
- };
-}
-
-d3.time.monthEnd = function(date) {
- return new Date(date.getFullYear(), date.getMonth(), 0);
-};
-
-d3.time.monthEnds = d3_time_range(d3.time.monthEnd, function(date) {
- date.setUTCDate(date.getUTCDate() + 1);
- date.setDate(daysInMonth(date.getMonth() + 1, date.getFullYear()));
- }, function(date) {
- return date.getMonth();
- }
-);
-
-
-/*****
- * A no-frills tooltip implementation.
- *****/
-
-
-(function() {
-
- var nvtooltip = window.nv.tooltip = {};
-
- nvtooltip.show = function(pos, content, gravity, dist, parentContainer, classes) {
-
- var container = document.createElement('div');
- container.className = 'nvtooltip ' + (classes ? classes : 'xy-tooltip');
-
- gravity = gravity || 's';
- dist = dist || 20;
-
- var body = parentContainer;
- if ( !parentContainer || parentContainer.tagName.match(/g|svg/i)) {
- //If the parent element is an SVG element, place tooltip in the <body> element.
- body = document.getElementsByTagName('body')[0];
- }
-
- container.innerHTML = content;
- container.style.left = 0;
- container.style.top = 0;
- container.style.opacity = 0;
-
- body.appendChild(container);
-
- var height = parseInt(container.offsetHeight),
- width = parseInt(container.offsetWidth),
- windowWidth = nv.utils.windowSize().width,
- windowHeight = nv.utils.windowSize().height,
- scrollTop = window.scrollY,
- scrollLeft = window.scrollX,
- left, top;
-
- windowHeight = window.innerWidth >= document.body.scrollWidth ? windowHeight : windowHeight - 16;
- windowWidth = window.innerHeight >= document.body.scrollHeight ? windowWidth : windowWidth - 16;
-
- var tooltipTop = function ( Elem ) {
- var offsetTop = top;
- do {
- if( !isNaN( Elem.offsetTop ) ) {
- offsetTop += (Elem.offsetTop);
- }
- } while( Elem = Elem.offsetParent );
- return offsetTop;
- }
-
- var tooltipLeft = function ( Elem ) {
- var offsetLeft = left;
- do {
- if( !isNaN( Elem.offsetLeft ) ) {
- offsetLeft += (Elem.offsetLeft);
- }
- } while( Elem = Elem.offsetParent );
- return offsetLeft;
- }
-
- switch (gravity) {
- case 'e':
- left = pos[0] - width - dist;
- top = pos[1] - (height / 2);
- var tLeft = tooltipLeft(container);
- var tTop = tooltipTop(container);
- if (tLeft < scrollLeft) left = pos[0] + dist > scrollLeft ? pos[0] + dist : scrollLeft - tLeft + left;
- if (tTop < scrollTop) top = scrollTop - tTop + top;
- if (tTop + height > scrollTop + windowHeight) top = scrollTop + windowHeight - tTop + top - height;
- break;
- case 'w':
- left = pos[0] + dist;
- top = pos[1] - (height / 2);
- if (tLeft + width > windowWidth) left = pos[0] - width - dist;
- if (tTop < scrollTop) top = scrollTop + 5;
- if (tTop + height > scrollTop + windowHeight) top = scrollTop - height - 5;
- break;
- case 'n':
- left = pos[0] - (width / 2) - 5;
- top = pos[1] + dist;
- var tLeft = tooltipLeft(container);
- var tTop = tooltipTop(container);
- if (tLeft < scrollLeft) left = scrollLeft + 5;
- if (tLeft + width > windowWidth) left = left - width/2 + 5;
- if (tTop + height > scrollTop + windowHeight) top = scrollTop + windowHeight - tTop + top - height;
- break;
- case 's':
- left = pos[0] - (width / 2);
- top = pos[1] - height - dist;
- var tLeft = tooltipLeft(container);
- var tTop = tooltipTop(container);
- if (tLeft < scrollLeft) left = scrollLeft + 5;
- if (tLeft + width > windowWidth) left = left - width/2 + 5;
- if (scrollTop > tTop) top = scrollTop;
- break;
- }
-
-
- container.style.left = left+'px';
- container.style.top = top+'px';
- container.style.opacity = 1;
- container.style.position = 'absolute'; //fix scroll bar issue
- container.style.pointerEvents = 'none'; //fix scroll bar issue
-
- return container;
- };
-
- nvtooltip.cleanup = function() {
-
- // Find the tooltips, mark them for removal by this class (so others cleanups won't find it)
- var tooltips = document.getElementsByClassName('nvtooltip');
- var purging = [];
- while(tooltips.length) {
- purging.push(tooltips[0]);
- tooltips[0].style.transitionDelay = '0 !important';
- tooltips[0].style.opacity = 0;
- tooltips[0].className = 'nvtooltip-pending-removal';
- }
-
-
- setTimeout(function() {
-
- while (purging.length) {
- var removeMe = purging.pop();
- removeMe.parentNode.removeChild(removeMe);
- }
- }, 500);
- };
-
-
-})();
-
-nv.utils.windowSize = function() {
- // Sane defaults
- var size = {width: 640, height: 480};
-
- // Earlier IE uses Doc.body
- if (document.body && document.body.offsetWidth) {
- size.width = document.body.offsetWidth;
- size.height = document.body.offsetHeight;
- }
-
- // IE can use depending on mode it is in
- if (document.compatMode=='CSS1Compat' &&
- document.documentElement &&
- document.documentElement.offsetWidth ) {
- size.width = document.documentElement.offsetWidth;
- size.height = document.documentElement.offsetHeight;
- }
-
- // Most recent browsers use
- if (window.innerWidth && window.innerHeight) {
- size.width = window.innerWidth;
- size.height = window.innerHeight;
- }
- return (size);
-};
-
-
-
-// Easy way to bind multiple functions to window.onresize
-// TODO: give a way to remove a function after its bound, other than removing all of them
-nv.utils.windowResize = function(fun){
- var oldresize = window.onresize;
-
- window.onresize = function(e) {
- if (typeof oldresize == 'function') oldresize(e);
- fun(e);
- }
-}
-
-// Backwards compatible way to implement more d3-like coloring of graphs.
-// If passed an array, wrap it in a function which implements the old default
-// behavior
-nv.utils.getColor = function(color) {
- if (!arguments.length) return nv.utils.defaultColor(); //if you pass in nothing, get default colors back
-
- if( Object.prototype.toString.call( color ) === '[object Array]' )
- return function(d, i) { return d.color || color[i % color.length]; };
- else
- return color;
- //can't really help it if someone passes rubbish as color
-}
-
-// Default color chooser uses the index of an object as before.
-nv.utils.defaultColor = function() {
- var colors = d3.scale.category20().range();
- return function(d, i) { return d.color || colors[i % colors.length] };
-}
-
-
-// Returns a color function that takes the result of 'getKey' for each series and
-// looks for a corresponding color from the dictionary,
-nv.utils.customTheme = function(dictionary, getKey, defaultColors) {
- getKey = getKey || function(series) { return series.key }; // use default series.key if getKey is undefined
- defaultColors = defaultColors || d3.scale.category20().range(); //default color function
-
- var defIndex = defaultColors.length; //current default color (going in reverse)
-
- return function(series, index) {
- var key = getKey(series);
-
- if (!defIndex) defIndex = defaultColors.length; //used all the default colors, start over
-
- if (typeof dictionary[key] !== "undefined")
- return (typeof dictionary[key] === "function") ? dictionary[key]() : dictionary[key];
- else
- return defaultColors[--defIndex]; // no match in dictionary, use default color
- }
-}
-
-
-
-// From the PJAX example on d3js.org, while this is not really directly needed
-// it's a very cool method for doing pjax, I may expand upon it a little bit,
-// open to suggestions on anything that may be useful
-nv.utils.pjax = function(links, content) {
- d3.selectAll(links).on("click", function() {
- history.pushState(this.href, this.textContent, this.href);
- load(this.href);
- d3.event.preventDefault();
- });
-
- function load(href) {
- d3.html(href, function(fragment) {
- var target = d3.select(content).node();
- target.parentNode.replaceChild(d3.select(fragment).select(content).node(), target);
- nv.utils.pjax(links, content);
- });
- }
-
- d3.select(window).on("popstate", function() {
- if (d3.event.state) load(d3.event.state);
- });
-}
-
-/* For situations where we want to approximate the width in pixels for an SVG:text element.
-Most common instance is when the element is in a display:none; container.
-Forumla is : text.length * font-size * constant_factor
-*/
-nv.utils.calcApproxTextWidth = function (svgTextElem) {
- if (svgTextElem instanceof d3.selection) {
- var fontSize = parseInt(svgTextElem.style("font-size").replace("px",""));
- var textLength = svgTextElem.text().length;
-
- return textLength * fontSize * 0.5;
- }
- return 0;
-};
-nv.models.axis = function() {
-
- //============================================================
- // Public Variables with Default Settings
- //------------------------------------------------------------
-
- var axis = d3.svg.axis()
- ;
-
- var margin = {top: 0, right: 0, bottom: 0, left: 0}
- , width = 75 //only used for tickLabel currently
- , height = 60 //only used for tickLabel currently
- , scale = d3.scale.linear()
- , axisLabelText = null
- , showMaxMin = true //TODO: showMaxMin should be disabled on all ordinal scaled axes
- , highlightZero = true
- , rotateLabels = 0
- , rotateYLabel = true
- , staggerLabels = false
- , isOrdinal = false
- , ticks = null
- ;
-
- axis
- .scale(scale)
- .orient('bottom')
- .tickFormat(function(d) { return d })
- ;
-
- //============================================================
-
-
- //============================================================
- // Private Variables
- //------------------------------------------------------------
-
- var scale0;
-
- //============================================================
-
-
- function chart(selection) {
- selection.each(function(data) {
- var container = d3.select(this);
-
-
- //------------------------------------------------------------
- // Setup containers and skeleton of chart
-
- var wrap = container.selectAll('g.nv-wrap.nv-axis').data([data]);
- var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-axis');
- var gEnter = wrapEnter.append('g');
- var g = wrap.select('g')
-
- //------------------------------------------------------------
-
-
- if (ticks !== null)
- axis.ticks(ticks);
- else if (axis.orient() == 'top' || axis.orient() == 'bottom')
- axis.ticks(Math.abs(scale.range()[1] - scale.range()[0]) / 100);
-
-
- //TODO: consider calculating width/height based on whether or not label is added, for reference in charts using this component
-
-
- d3.transition(g)
- .call(axis);
-
- scale0 = scale0 || axis.scale();
-
- var fmt = axis.tickFormat();
- if (fmt == null) {
- fmt = scale0.tickFormat();
- }
-
- var axisLabel = g.selectAll('text.nv-axislabel')
- .data([axisLabelText || null]);
- axisLabel.exit().remove();
- switch (axis.orient()) {
- case 'top':
- axisLabel.enter().append('text').attr('class', 'nv-axislabel');
- var w = (scale.range().length==2) ? scale.range()[1] : (scale.range()[scale.range().length-1]+(scale.range()[1]-scale.range()[0]));
- axisLabel
- .attr('text-anchor', 'middle')
- .attr('y', 0)
- .attr('x', w/2);
- if (showMaxMin) {
- var axisMaxMin = wrap.selectAll('g.nv-axisMaxMin')
- .data(scale.domain());
- axisMaxMin.enter().append('g').attr('class', 'nv-axisMaxMin').append('text');
- axisMaxMin.exit().remove();
- axisMaxMin
- .attr('transform', function(d,i) {
- return 'translate(' + scale(d) + ',0)'
- })
- .select('text')
- .attr('dy', '0em')
- .attr('y', -axis.tickPadding())
- .attr('text-anchor', 'middle')
- .text(function(d,i) {
- var v = fmt(d);
- return ('' + v).match('NaN') ? '' : v;
- });
- d3.transition(axisMaxMin)
- .attr('transform', function(d,i) {
- return 'translate(' + scale.range()[i] + ',0)'
- });
- }
- break;
- case 'bottom':
- var xLabelMargin = 36;
- var maxTextWidth = 30;
- var xTicks = g.selectAll('g').select("text");
- if (rotateLabels%360) {
- //Calculate the longest xTick width
- xTicks.each(function(d,i){
- var width = this.getBBox().width;
- if(width > maxTextWidth) maxTextWidth = width;
- });
- //Convert to radians before calculating sin. Add 30 to margin for healthy padding.
- var sin = Math.abs(Math.sin(rotateLabels*Math.PI/180));
- var xLabelMargin = (sin ? sin*maxTextWidth : maxTextWidth)+30;
- //Rotate all xTicks
- xTicks
- .attr('transform', function(d,i,j) { return 'rotate(' + rotateLabels + ' 0,0)' })
- .attr('text-anchor', rotateLabels%360 > 0 ? 'start' : 'end');
- }
- axisLabel.enter().append('text').attr('class', 'nv-axislabel');
- var w = (scale.range().length==2) ? scale.range()[1] : (scale.range()[scale.range().length-1]+(scale.range()[1]-scale.range()[0]));
- axisLabel
- .attr('text-anchor', 'middle')
- .attr('y', xLabelMargin)
- .attr('x', w/2);
- if (showMaxMin) {
- //if (showMaxMin && !isOrdinal) {
- var axisMaxMin = wrap.selectAll('g.nv-axisMaxMin')
- //.data(scale.domain())
- .data([scale.domain()[0], scale.domain()[scale.domain().length - 1]]);
- axisMaxMin.enter().append('g').attr('class', 'nv-axisMaxMin').append('text');
- axisMaxMin.exit().remove();
- axisMaxMin
- .attr('transform', function(d,i) {
- return 'translate(' + (scale(d) + (isOrdinal ? scale.rangeBand() / 2 : 0)) + ',0)'
- })
- .select('text')
- .attr('dy', '.71em')
- .attr('y', axis.tickPadding())
- .attr('transform', function(d,i,j) { return 'rotate(' + rotateLabels + ' 0,0)' })
- .attr('text-anchor', rotateLabels ? (rotateLabels%360 > 0 ? 'start' : 'end') : 'middle')
- .text(function(d,i) {
- var v = fmt(d);
- return ('' + v).match('NaN') ? '' : v;
- });
- d3.transition(axisMaxMin)
- .attr('transform', function(d,i) {
- //return 'translate(' + scale.range()[i] + ',0)'
- //return 'translate(' + scale(d) + ',0)'
- return 'translate(' + (scale(d) + (isOrdinal ? scale.rangeBand() / 2 : 0)) + ',0)'
- });
- }
- if (staggerLabels)
- xTicks
- .attr('transform', function(d,i) { return 'translate(0,' + (i % 2 == 0 ? '0' : '12') + ')' });
-
- break;
- case 'right':
- axisLabel.enter().append('text').attr('class', 'nv-axislabel');
- axisLabel
- .attr('text-anchor', rotateYLabel ? 'middle' : 'begin')
- .attr('transform', rotateYLabel ? 'rotate(90)' : '')
- .attr('y', rotateYLabel ? (-Math.max(margin.right,width) + 12) : -10) //TODO: consider calculating this based on largest tick width... OR at least expose this on chart
- .attr('x', rotateYLabel ? (scale.range()[0] / 2) : axis.tickPadding());
- if (showMaxMin) {
- var axisMaxMin = wrap.selectAll('g.nv-axisMaxMin')
- .data(scale.domain());
- axisMaxMin.enter().append('g').attr('class', 'nv-axisMaxMin').append('text')
- .style('opacity', 0);
- axisMaxMin.exit().remove();
- axisMaxMin
- .attr('transform', function(d,i) {
- return 'translate(0,' + scale(d) + ')'
- })
- .select('text')
- .attr('dy', '.32em')
- .attr('y', 0)
- .attr('x', axis.tickPadding())
- .attr('text-anchor', 'start')
- .text(function(d,i) {
- var v = fmt(d);
- return ('' + v).match('NaN') ? '' : v;
- });
- d3.transition(axisMaxMin)
- .attr('transform', function(d,i) {
- return 'translate(0,' + scale.range()[i] + ')'
- })
- .select('text')
- .style('opacity', 1);
- }
- break;
- case 'left':
- /*
- //For dynamically placing the label. Can be used with dynamically-sized chart axis margins
- var yTicks = g.selectAll('g').select("text");
- yTicks.each(function(d,i){
- var labelPadding = this.getBBox().width + axis.tickPadding() + 16;
- if(labelPadding > width) width = labelPadding;
- });
- */
- axisLabel.enter().append('text').attr('class', 'nv-axislabel');
- axisLabel
- .attr('text-anchor', rotateYLabel ? 'middle' : 'end')
- .attr('transform', rotateYLabel ? 'rotate(-90)' : '')
- .attr('y', rotateYLabel ? (-Math.max(margin.left,width) + 12) : -10) //TODO: consider calculating this based on largest tick width... OR at least expose this on chart
- .attr('x', rotateYLabel ? (-scale.range()[0] / 2) : -axis.tickPadding());
- if (showMaxMin) {
- var axisMaxMin = wrap.selectAll('g.nv-axisMaxMin')
- .data(scale.domain());
- axisMaxMin.enter().append('g').attr('class', 'nv-axisMaxMin').append('text')
- .style('opacity', 0);
- axisMaxMin.exit().remove();
- axisMaxMin
- .attr('transform', function(d,i) {
- return 'translate(0,' + scale0(d) + ')'
- })
- .select('text')
- .attr('dy', '.32em')
- .attr('y', 0)
- .attr('x', -axis.tickPadding())
- .attr('text-anchor', 'end')
- .text(function(d,i) {
- var v = fmt(d);
- return ('' + v).match('NaN') ? '' : v;
- });
- d3.transition(axisMaxMin)
- .attr('transform', function(d,i) {
- return 'translate(0,' + scale.range()[i] + ')'
- })
- .select('text')
- .style('opacity', 1);
- }
- break;
- }
- axisLabel
- .text(function(d) { return d });
-
-
- if (showMaxMin && (axis.orient() === 'left' || axis.orient() === 'right')) {
- //check if max and min overlap other values, if so, hide the values that overlap
- g.selectAll('g') // the g's wrapping each tick
- .each(function(d,i) {
- d3.select(this).select('text').attr('opacity', 1);
- if (scale(d) < scale.range()[1] + 10 || scale(d) > scale.range()[0] - 10) { // 10 is assuming text height is 16... if d is 0, leave it!
- if (d > 1e-10 || d < -1e-10) // accounts for minor floating point errors... though could be problematic if the scale is EXTREMELY SMALL
- d3.select(this).attr('opacity', 0);
-
- d3.select(this).select('text').attr('opacity', 0); // Don't remove the ZERO line!!
- }
- });
-
- //if Max and Min = 0 only show min, Issue #281
- if (scale.domain()[0] == scale.domain()[1] && scale.domain()[0] == 0)
- wrap.selectAll('g.nv-axisMaxMin')
- .style('opacity', function(d,i) { return !i ? 1 : 0 });
-
- }
-
- if (showMaxMin && (axis.orient() === 'top' || axis.orient() === 'bottom')) {
- var maxMinRange = [];
- wrap.selectAll('g.nv-axisMaxMin')
- .each(function(d,i) {
- try {
- if (i) // i== 1, max position
- maxMinRange.push(scale(d) - this.getBBox().width - 4) //assuming the max and min labels are as wide as the next tick (with an extra 4 pixels just in case)
- else // i==0, min position
- maxMinRange.push(scale(d) + this.getBBox().width + 4)
- }catch (err) {
- if (i) // i== 1, max position
- maxMinRange.push(scale(d) - 4) //assuming the max and min labels are as wide as the next tick (with an extra 4 pixels just in case)
- else // i==0, min position
- maxMinRange.push(scale(d) + 4)
- }
- });
- g.selectAll('g') // the g's wrapping each tick
- .each(function(d,i) {
- if (scale(d) < maxMinRange[0] || scale(d) > maxMinRange[1]) {
- if (d > 1e-10 || d < -1e-10) // accounts for minor floating point errors... though could be problematic if the scale is EXTREMELY SMALL
- d3.select(this).remove();
- else
- d3.select(this).select('text').remove(); // Don't remove the ZERO line!!
- }
- });
- }
-
-
- //highlight zero line ... Maybe should not be an option and should just be in CSS?
- if (highlightZero)
- g.selectAll('.tick')
- .filter(function(d) { return !parseFloat(Math.round(d.__data__*100000)/1000000) && (d.__data__ !== undefined) }) //this is because sometimes the 0 tick is a very small fraction, TODO: think of cleaner technique
- .classed('zero', true);
-
- //store old scales for use in transitions on update
- scale0 = scale.copy();
-
- });
-
- return chart;
- }
-
-
- //============================================================
- // Expose Public Variables
- //------------------------------------------------------------
-
- // expose chart's sub-components
- chart.axis = axis;
-
- d3.rebind(chart, axis, 'orient', 'tickValues', 'tickSubdivide', 'tickSize', 'tickPadding', 'tickFormat');
- d3.rebind(chart, scale, 'domain', 'range', 'rangeBand', 'rangeBands'); //these are also accessible by chart.scale(), but added common ones directly for ease of use
-
- chart.margin = function(_) {
- if(!arguments.length) return margin;
- margin.top = typeof _.top != 'undefined' ? _.top : margin.top;
- margin.right = typeof _.right != 'undefined' ? _.right : margin.right;
- margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom;
- margin.left = typeof _.left != 'undefined' ? _.left : margin.left;
- return chart;
- }
-
- chart.width = function(_) {
- if (!arguments.length) return width;
- width = _;
- return chart;
- };
-
- chart.ticks = function(_) {
- if (!arguments.length) return ticks;
- ticks = _;
- return chart;
- };
-
- chart.height = function(_) {
- if (!arguments.length) return height;
- height = _;
- return chart;
- };
-
- chart.axisLabel = function(_) {
- if (!arguments.length) return axisLabelText;
- axisLabelText = _;
- return chart;
- }
-
- chart.showMaxMin = function(_) {
- if (!arguments.length) return showMaxMin;
- showMaxMin = _;
- return chart;
- }
-
- chart.highlightZero = function(_) {
- if (!arguments.length) return highlightZero;
- highlightZero = _;
- return chart;
- }
-
- chart.scale = function(_) {
- if (!arguments.length) return scale;
- scale = _;
- axis.scale(scale);
- isOrdinal = typeof scale.rangeBands === 'function';
- d3.rebind(chart, scale, 'domain', 'range', 'rangeBand', 'rangeBands');
- return chart;
- }
-
- chart.rotateYLabel = function(_) {
- if(!arguments.length) return rotateYLabel;
- rotateYLabel = _;
- return chart;
- }
-
- chart.rotateLabels = function(_) {
- if(!arguments.length) return rotateLabels;
- rotateLabels = _;
- return chart;
- }
-
- chart.staggerLabels = function(_) {
- if (!arguments.length) return staggerLabels;
- staggerLabels = _;
- return chart;
- };
-
-
- //============================================================
-
-
- return chart;
-}
-
-// Chart design based on the recommendations of Stephen Few. Implementation
-// based on the work of Clint Ivy, Jamie Love, and Jason Davies.
-// http://projects.instantcognition.com/protovis/bulletchart/
-
-nv.models.bullet = function() {
-
- //============================================================
- // Public Variables with Default Settings
- //------------------------------------------------------------
-
- var margin = {top: 0, right: 0, bottom: 0, left: 0}
- , orient = 'left' // TODO top & bottom
- , reverse = false
- , ranges = function(d) { return d.ranges }
- , markers = function(d) { return d.markers }
- , measures = function(d) { return d.measures }
- , forceX = [0] // List of numbers to Force into the X scale (ie. 0, or a max / min, etc.)
- , width = 380
- , height = 30
- , tickFormat = null
- , color = nv.utils.getColor(['#1f77b4'])
- , dispatch = d3.dispatch('elementMouseover', 'elementMouseout')
- ;
-
- //============================================================
-
-
- function chart(selection) {
- selection.each(function(d, i) {
- var availableWidth = width - margin.left - margin.right,
- availableHeight = height - margin.top - margin.bottom,
- container = d3.select(this);
-
- var rangez = ranges.call(this, d, i).slice().sort(d3.descending),
- markerz = markers.call(this, d, i).slice().sort(d3.descending),
- measurez = measures.call(this, d, i).slice().sort(d3.descending);
-
-
- //------------------------------------------------------------
- // Setup Scales
-
- // Compute the new x-scale.
- var x1 = d3.scale.linear()
- .domain( d3.extent(d3.merge([forceX, rangez])) )
- .range(reverse ? [availableWidth, 0] : [0, availableWidth]);
-
- // Retrieve the old x-scale, if this is an update.
- var x0 = this.__chart__ || d3.scale.linear()
- .domain([0, Infinity])
- .range(x1.range());
-
- // Stash the new scale.
- this.__chart__ = x1;
-
-
- var rangeMin = d3.min(rangez), //rangez[2]
- rangeMax = d3.max(rangez), //rangez[0]
- rangeAvg = rangez[1];
-
- //------------------------------------------------------------
-
-
- //------------------------------------------------------------
- // Setup containers and skeleton of chart
-
- var wrap = container.selectAll('g.nv-wrap.nv-bullet').data([d]);
- var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-bullet');
- var gEnter = wrapEnter.append('g');
- var g = wrap.select('g');
-
- gEnter.append('rect').attr('class', 'nv-range nv-rangeMax');
- gEnter.append('rect').attr('class', 'nv-range nv-rangeAvg');
- gEnter.append('rect').attr('class', 'nv-range nv-rangeMin');
- gEnter.append('rect').attr('class', 'nv-measure');
- gEnter.append('path').attr('class', 'nv-markerTriangle');
-
- wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
-
- //------------------------------------------------------------
-
-
-
- var w0 = function(d) { return Math.abs(x0(d) - x0(0)) }, // TODO: could optimize by precalculating x0(0) and x1(0)
- w1 = function(d) { return Math.abs(x1(d) - x1(0)) };
- var xp0 = function(d) { return d < 0 ? x0(d) : x0(0) },
- xp1 = function(d) { return d < 0 ? x1(d) : x1(0) };
-
-
- g.select('rect.nv-rangeMax')
- .attr('height', availableHeight)
- .attr('width', w1(rangeMax > 0 ? rangeMax : rangeMin))
- .attr('x', xp1(rangeMax > 0 ? rangeMax : rangeMin))
- .datum(rangeMax > 0 ? rangeMax : rangeMin)
- /*
- .attr('x', rangeMin < 0 ?
- rangeMax > 0 ?
- x1(rangeMin)
- : x1(rangeMax)
- : x1(0))
- */
-
- g.select('rect.nv-rangeAvg')
- .attr('height', availableHeight)
- .attr('width', w1(rangeAvg))
- .attr('x', xp1(rangeAvg))
- .datum(rangeAvg)
- /*
- .attr('width', rangeMax <= 0 ?
- x1(rangeMax) - x1(rangeAvg)
- : x1(rangeAvg) - x1(rangeMin))
- .attr('x', rangeMax <= 0 ?
- x1(rangeAvg)
- : x1(rangeMin))
- */
-
- g.select('rect.nv-rangeMin')
- .attr('height', availableHeight)
- .attr('width', w1(rangeMax))
- .attr('x', xp1(rangeMax))
- .attr('width', w1(rangeMax > 0 ? rangeMin : rangeMax))
- .attr('x', xp1(rangeMax > 0 ? rangeMin : rangeMax))
- .datum(rangeMax > 0 ? rangeMin : rangeMax)
- /*
- .attr('width', rangeMax <= 0 ?
- x1(rangeAvg) - x1(rangeMin)
- : x1(rangeMax) - x1(rangeAvg))
- .attr('x', rangeMax <= 0 ?
- x1(rangeMin)
- : x1(rangeAvg))
- */
-
- g.select('rect.nv-measure')
- .style('fill', color)
- .attr('height', availableHeight / 3)
- .attr('y', availableHeight / 3)
- .attr('width', measurez < 0 ?
- x1(0) - x1(measurez[0])
- : x1(measurez[0]) - x1(0))
- .attr('x', xp1(measurez))
- .on('mouseover', function() {
- dispatch.elementMouseover({
- value: measurez[0],
- label: 'Current',
- pos: [x1(measurez[0]), availableHeight/2]
- })
- })
- .on('mouseout', function() {
- dispatch.elementMouseout({
- value: measurez[0],
- label: 'Current'
- })
- })
-
- var h3 = availableHeight / 6;
- if (markerz[0]) {
- g.selectAll('path.nv-markerTriangle')
- .attr('transform', function(d) { return 'translate(' + x1(markerz[0]) + ',' + (availableHeight / 2) + ')' })
- .attr('d', 'M0,' + h3 + 'L' + h3 + ',' + (-h3) + ' ' + (-h3) + ',' + (-h3) + 'Z')
- .on('mouseover', function() {
- dispatch.elementMouseover({
- value: markerz[0],
- label: 'Previous',
- pos: [x1(markerz[0]), availableHeight/2]
- })
- })
- .on('mouseout', function() {
- dispatch.elementMouseout({
- value: markerz[0],
- label: 'Previous'
- })
- });
- } else {
- g.selectAll('path.nv-markerTriangle').remove();
- }
-
-
- wrap.selectAll('.nv-range')
- .on('mouseover', function(d,i) {
- var label = !i ? "Maximum" : i == 1 ? "Mean" : "Minimum";
-
- dispatch.elementMouseover({
- value: d,
- label: label,
- pos: [x1(d), availableHeight/2]
- })
- })
- .on('mouseout', function(d,i) {
- var label = !i ? "Maximum" : i == 1 ? "Mean" : "Minimum";
-
- dispatch.elementMouseout({
- value: d,
- label: label
- })
- })
-
-/* // THIS IS THE PREVIOUS BULLET IMPLEMENTATION, WILL REMOVE SHORTLY
- // Update the range rects.
- var range = g.selectAll('rect.nv-range')
- .data(rangez);
-
- range.enter().append('rect')
- .attr('class', function(d, i) { return 'nv-range nv-s' + i; })
- .attr('width', w0)
- .attr('height', availableHeight)
- .attr('x', reverse ? x0 : 0)
- .on('mouseover', function(d,i) {
- dispatch.elementMouseover({
- value: d,
- label: (i <= 0) ? 'Maximum' : (i > 1) ? 'Minimum' : 'Mean', //TODO: make these labels a variable
- pos: [x1(d), availableHeight/2]
- })
- })
- .on('mouseout', function(d,i) {
- dispatch.elementMouseout({
- value: d,
- label: (i <= 0) ? 'Minimum' : (i >=1) ? 'Maximum' : 'Mean' //TODO: make these labels a variable
- })
- })
-
- d3.transition(range)
- .attr('x', reverse ? x1 : 0)
- .attr('width', w1)
- .attr('height', availableHeight);
-
-
- // Update the measure rects.
- var measure = g.selectAll('rect.nv-measure')
- .data(measurez);
-
- measure.enter().append('rect')
- .attr('class', function(d, i) { return 'nv-measure nv-s' + i; })
- .style('fill', function(d,i) { return color(d,i ) })
- .attr('width', w0)
- .attr('height', availableHeight / 3)
- .attr('x', reverse ? x0 : 0)
- .attr('y', availableHeight / 3)
- .on('mouseover', function(d) {
- dispatch.elementMouseover({
- value: d,
- label: 'Current', //TODO: make these labels a variable
- pos: [x1(d), availableHeight/2]
- })
- })
- .on('mouseout', function(d) {
- dispatch.elementMouseout({
- value: d,
- label: 'Current' //TODO: make these labels a variable
- })
- })
-
- d3.transition(measure)
- .attr('width', w1)
- .attr('height', availableHeight / 3)
- .attr('x', reverse ? x1 : 0)
- .attr('y', availableHeight / 3);
-
-
-
- // Update the marker lines.
- var marker = g.selectAll('path.nv-markerTriangle')
- .data(markerz);
-
- var h3 = availableHeight / 6;
- marker.enter().append('path')
- .attr('class', 'nv-markerTriangle')
- .attr('transform', function(d) { return 'translate(' + x0(d) + ',' + (availableHeight / 2) + ')' })
- .attr('d', 'M0,' + h3 + 'L' + h3 + ',' + (-h3) + ' ' + (-h3) + ',' + (-h3) + 'Z')
- .on('mouseover', function(d,i) {
- dispatch.elementMouseover({
- value: d,
- label: 'Previous',
- pos: [x1(d), availableHeight/2]
- })
- })
- .on('mouseout', function(d,i) {
- dispatch.elementMouseout({
- value: d,
- label: 'Previous'
- })
- });
-
- d3.transition(marker)
- .attr('transform', function(d) { return 'translate(' + (x1(d) - x1(0)) + ',' + (availableHeight / 2) + ')' });
-
- marker.exit().remove();
-*/
-
- });
-
- // d3.timer.flush(); // Not needed?
-
- return chart;
- }
-
-
- //============================================================
- // Expose Public Variables
- //------------------------------------------------------------
-
- chart.dispatch = dispatch;
-
- // left, right, top, bottom
- chart.orient = function(_) {
- if (!arguments.length) return orient;
- orient = _;
- reverse = orient == 'right' || orient == 'bottom';
- return chart;
- };
-
- // ranges (bad, satisfactory, good)
- chart.ranges = function(_) {
- if (!arguments.length) return ranges;
- ranges = _;
- return chart;
- };
-
- // markers (previous, goal)
- chart.markers = function(_) {
- if (!arguments.length) return markers;
- markers = _;
- return chart;
- };
-
- // measures (actual, forecast)
- chart.measures = function(_) {
- if (!arguments.length) return measures;
- measures = _;
- return chart;
- };
-
- chart.forceX = function(_) {
- if (!arguments.length) return forceX;
- forceX = _;
- return chart;
- };
-
- chart.width = function(_) {
- if (!arguments.length) return width;
- width = _;
- return chart;
- };
-
- chart.height = function(_) {
- if (!arguments.length) return height;
- height = _;
- return chart;
- };
-
- chart.margin = function(_) {
- if (!arguments.length) return margin;
- margin.top = typeof _.top != 'undefined' ? _.top : margin.top;
- margin.right = typeof _.right != 'undefined' ? _.right : margin.right;
- margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom;
- margin.left = typeof _.left != 'undefined' ? _.left : margin.left;
- return chart;
- };
-
- chart.tickFormat = function(_) {
- if (!arguments.length) return tickFormat;
- tickFormat = _;
- return chart;
- };
-
- chart.color = function(_) {
- if (!arguments.length) return color;
- color = nv.utils.getColor(_);
- return chart;
- };
-
- //============================================================
-
-
- return chart;
-};
-
-
-
-// Chart design based on the recommendations of Stephen Few. Implementation
-// based on the work of Clint Ivy, Jamie Love, and Jason Davies.
-// http://projects.instantcognition.com/protovis/bulletchart/
-nv.models.bulletChart = function() {
-
- //============================================================
- // Public Variables with Default Settings
- //------------------------------------------------------------
-
- var bullet = nv.models.bullet()
- ;
-
- var orient = 'left' // TODO top & bottom
- , reverse = false
- , margin = {top: 5, right: 40, bottom: 20, left: 120}
- , ranges = function(d) { return d.ranges }
- , markers = function(d) { return d.markers }
- , measures = function(d) { return d.measures }
- , width = null
- , height = 55
- , tickFormat = null
- , tooltips = true
- , tooltip = function(key, x, y, e, graph) {
- return '<h3>' + x + '</h3>' +
- '<p>' + y + '</p>'
- }
- , noData = 'No Data Available.'
- , dispatch = d3.dispatch('tooltipShow', 'tooltipHide')
- ;
-
- //============================================================
-
-
- //============================================================
- // Private Variables
- //------------------------------------------------------------
-
- var showTooltip = function(e, offsetElement) {
- var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ) + margin.left,
- top = e.pos[1] + ( offsetElement.offsetTop || 0) + margin.top,
- content = tooltip(e.key, e.label, e.value, e, chart);
-
- nv.tooltip.show([left, top], content, e.value < 0 ? 'e' : 'w', null, offsetElement);
- };
-
- //============================================================
-
-
- function chart(selection) {
- selection.each(function(d, i) {
- var container = d3.select(this);
-
- var availableWidth = (width || parseInt(container.style('width')) || 960)
- - margin.left - margin.right,
- availableHeight = height - margin.top - margin.bottom,
- that = this;
-
-
- chart.update = function() { chart(selection) };
- chart.container = this;
-
- //------------------------------------------------------------
- // Display No Data message if there's nothing to show.
-
- if (!d || !ranges.call(this, d, i)) {
- var noDataText = container.selectAll('.nv-noData').data([noData]);
-
- noDataText.enter().append('text')
- .attr('class', 'nvd3 nv-noData')
- .attr('dy', '-.7em')
- .style('text-anchor', 'middle');
-
- noDataText
- .attr('x', margin.left + availableWidth / 2)
- .attr('y', 18 + margin.top + availableHeight / 2)
- .text(function(d) { return d });
-
- return chart;
- } else {
- container.selectAll('.nv-noData').remove();
- }
-
- //------------------------------------------------------------
-
-
-
- var rangez = ranges.call(this, d, i).slice().sort(d3.descending),
- markerz = markers.call(this, d, i).slice().sort(d3.descending),
- measurez = measures.call(this, d, i).slice().sort(d3.descending);
-
-
- //------------------------------------------------------------
- // Setup containers and skeleton of chart
-
- var wrap = container.selectAll('g.nv-wrap.nv-bulletChart').data([d]);
- var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-bulletChart');
- var gEnter = wrapEnter.append('g');
- var g = wrap.select('g');
-
- gEnter.append('g').attr('class', 'nv-bulletWrap');
- gEnter.append('g').attr('class', 'nv-titles');
-
- wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
-
- //------------------------------------------------------------
-
-
- // Compute the new x-scale.
- var x1 = d3.scale.linear()
- .domain([0, Math.max(rangez[0], markerz[0], measurez[0])]) // TODO: need to allow forceX and forceY, and xDomain, yDomain
- .range(reverse ? [availableWidth, 0] : [0, availableWidth]);
-
- // Retrieve the old x-scale, if this is an update.
- var x0 = this.__chart__ || d3.scale.linear()
- .domain([0, Infinity])
- .range(x1.range());
-
- // Stash the new scale.
- this.__chart__ = x1;
-
- /*
- // Derive width-scales from the x-scales.
- var w0 = bulletWidth(x0),
- w1 = bulletWidth(x1);
-
- function bulletWidth(x) {
- var x0 = x(0);
- return function(d) {
- return Math.abs(x(d) - x(0));
- };
- }
-
- function bulletTranslate(x) {
- return function(d) {
- return 'translate(' + x(d) + ',0)';
- };
- }
- */
-
- var w0 = function(d) { return Math.abs(x0(d) - x0(0)) }, // TODO: could optimize by precalculating x0(0) and x1(0)
- w1 = function(d) { return Math.abs(x1(d) - x1(0)) };
-
-
- var title = gEnter.select('.nv-titles').append('g')
- .attr('text-anchor', 'end')
- .attr('transform', 'translate(-6,' + (height - margin.top - margin.bottom) / 2 + ')');
- title.append('text')
- .attr('class', 'nv-title')
- .text(function(d) { return d.title; });
-
- title.append('text')
- .attr('class', 'nv-subtitle')
- .attr('dy', '1em')
- .text(function(d) { return d.subtitle; });
-
-
-
- bullet
- .width(availableWidth)
- .height(availableHeight)
-
- var bulletWrap = g.select('.nv-bulletWrap');
-
- d3.transition(bulletWrap).call(bullet);
-
-
-
- // Compute the tick format.
- var format = tickFormat || x1.tickFormat( availableWidth / 100 );
-
- // Update the tick groups.
- var tick = g.selectAll('g.nv-tick')
- .data(x1.ticks( availableWidth / 50 ), function(d) {
- return this.textContent || format(d);
- });
-
- // Initialize the ticks with the old scale, x0.
- var tickEnter = tick.enter().append('g')
- .attr('class', 'nv-tick')
- .attr('transform', function(d) { return 'translate(' + x0(d) + ',0)' })
- .style('opacity', 1e-6);
-
- tickEnter.append('line')
- .attr('y1', availableHeight)
- .attr('y2', availableHeight * 7 / 6);
-
- tickEnter.append('text')
- .attr('text-anchor', 'middle')
- .attr('dy', '1em')
- .attr('y', availableHeight * 7 / 6)
- .text(format);
-
-
- // Transition the updating ticks to the new scale, x1.
- var tickUpdate = d3.transition(tick)
- .attr('transform', function(d) { return 'translate(' + x1(d) + ',0)' })
- .style('opacity', 1);
-
- tickUpdate.select('line')
- .attr('y1', availableHeight)
- .attr('y2', availableHeight * 7 / 6);
-
- tickUpdate.select('text')
- .attr('y', availableHeight * 7 / 6);
-
- // Transition the exiting ticks to the new scale, x1.
- d3.transition(tick.exit())
- .attr('transform', function(d) { return 'translate(' + x1(d) + ',0)' })
- .style('opacity', 1e-6)
- .remove();
-
-
- //============================================================
- // Event Handling/Dispatching (in chart's scope)
- //------------------------------------------------------------
-
- dispatch.on('tooltipShow', function(e) {
- e.key = d.title;
- if (tooltips) showTooltip(e, that.parentNode);
- });
-
- //============================================================
-
- });
-
- d3.timer.flush();
-
- return chart;
- }
-
-
- //============================================================
- // Event Handling/Dispatching (out of chart's scope)
- //------------------------------------------------------------
-
- bullet.dispatch.on('elementMouseover.tooltip', function(e) {
- dispatch.tooltipShow(e);
- });
-
- bullet.dispatch.on('elementMouseout.tooltip', function(e) {
- dispatch.tooltipHide(e);
- });
-
- dispatch.on('tooltipHide', function() {
- if (tooltips) nv.tooltip.cleanup();
- });
-
- //============================================================
-
-
- //============================================================
- // Expose Public Variables
- //------------------------------------------------------------
-
- chart.dispatch = dispatch;
- chart.bullet = bullet;
-
- d3.rebind(chart, bullet, 'color');
-
- // left, right, top, bottom
- chart.orient = function(x) {
- if (!arguments.length) return orient;
- orient = x;
- reverse = orient == 'right' || orient == 'bottom';
- return chart;
- };
-
- // ranges (bad, satisfactory, good)
- chart.ranges = function(x) {
- if (!arguments.length) return ranges;
- ranges = x;
- return chart;
- };
-
- // markers (previous, goal)
- chart.markers = function(x) {
- if (!arguments.length) return markers;
- markers = x;
- return chart;
- };
-
- // measures (actual, forecast)
- chart.measures = function(x) {
- if (!arguments.length) return measures;
- measures = x;
- return chart;
- };
-
- chart.width = function(x) {
- if (!arguments.length) return width;
- width = x;
- return chart;
- };
-
- chart.height = function(x) {
- if (!arguments.length) return height;
- height = x;
- return chart;
- };
-
- chart.margin = function(_) {
- if (!arguments.length) return margin;
- margin.top = typeof _.top != 'undefined' ? _.top : margin.top;
- margin.right = typeof _.right != 'undefined' ? _.right : margin.right;
- margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom;
- margin.left = typeof _.left != 'undefined' ? _.left : margin.left;
- return chart;
- };
-
- chart.tickFormat = function(x) {
- if (!arguments.length) return tickFormat;
- tickFormat = x;
- return chart;
- };
-
- chart.tooltips = function(_) {
- if (!arguments.length) return tooltips;
- tooltips = _;
- return chart;
- };
-
- chart.tooltipContent = function(_) {
- if (!arguments.length) return tooltip;
- tooltip = _;
- return chart;
- };
-
- chart.noData = function(_) {
- if (!arguments.length) return noData;
- noData = _;
- return chart;
- };
-
- //============================================================
-
-
- return chart;
-};
-
-
-
-nv.models.cumulativeLineChart = function() {
-
- //============================================================
- // Public Variables with Default Settings
- //------------------------------------------------------------
-
- var lines = nv.models.line()
- , xAxis = nv.models.axis()
- , yAxis = nv.models.axis()
- , legend = nv.models.legend()
- , controls = nv.models.legend()
- ;
-
- var margin = {top: 30, right: 30, bottom: 50, left: 60}
- , color = nv.utils.defaultColor()
- , width = null
- , height = null
- , showLegend = true
- , tooltips = true
- , showControls = true
- , rescaleY = true
- , tooltip = function(key, x, y, e, graph) {
- return '<h3>' + key + '</h3>' +
- '<p>' + y + ' at ' + x + '</p>'
- }
- , x //can be accessed via chart.xScale()
- , y //can be accessed via chart.yScale()
- , id = lines.id()
- , state = { index: 0, rescaleY: rescaleY }
- , defaultState = null
- , noData = 'No Data Available.'
- , average = function(d) { return d.average }
- , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState')
- ;
-
- xAxis
- .orient('bottom')
- .tickPadding(7)
- ;
- yAxis
- .orient('left')
- ;
-
- //============================================================
-
-
- //============================================================
- // Private Variables
- //------------------------------------------------------------
-
- var dx = d3.scale.linear()
- , index = {i: 0, x: 0}
- ;
-
- var showTooltip = function(e, offsetElement) {
- var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ),
- top = e.pos[1] + ( offsetElement.offsetTop || 0),
- x = xAxis.tickFormat()(lines.x()(e.point, e.pointIndex)),
- y = yAxis.tickFormat()(lines.y()(e.point, e.pointIndex)),
- content = tooltip(e.series.key, x, y, e, chart);
-
- nv.tooltip.show([left, top], content, null, null, offsetElement);
- };
-
-/*
- //Moved to see if we can get better behavior to fix issue #315
- var indexDrag = d3.behavior.drag()
- .on('dragstart', dragStart)
- .on('drag', dragMove)
- .on('dragend', dragEnd);
-
- function dragStart(d,i) {
- d3.select(chart.container)
- .style('cursor', 'ew-resize');
- }
-
- function dragMove(d,i) {
- d.x += d3.event.dx;
- d.i = Math.round(dx.invert(d.x));
-
- d3.select(this).attr('transform', 'translate(' + dx(d.i) + ',0)');
- chart.update();
- }
-
- function dragEnd(d,i) {
- d3.select(chart.container)
- .style('cursor', 'auto');
- chart.update();
- }
-*/
-
- //============================================================
-
-
- function chart(selection) {
- selection.each(function(data) {
- var container = d3.select(this).classed('nv-chart-' + id, true),
- that = this;
-
- var availableWidth = (width || parseInt(container.style('width')) || 960)
- - margin.left - margin.right,
- availableHeight = (height || parseInt(container.style('height')) || 400)
- - margin.top - margin.bottom;
-
-
- chart.update = function() { container.transition().call(chart) };
- chart.container = this;
-
- //set state.disabled
- state.disabled = data.map(function(d) { return !!d.disabled });
-
- if (!defaultState) {
- var key;
- defaultState = {};
- for (key in state) {
- if (state[key] instanceof Array)
- defaultState[key] = state[key].slice(0);
- else
- defaultState[key] = state[key];
- }
- }
-
- var indexDrag = d3.behavior.drag()
- .on('dragstart', dragStart)
- .on('drag', dragMove)
- .on('dragend', dragEnd);
-
-
- function dragStart(d,i) {
- d3.select(chart.container)
- .style('cursor', 'ew-resize');
- }
-
- function dragMove(d,i) {
- index.x = d3.event.x;
- index.i = Math.round(dx.invert(index.x));
- updateZero();
- }
-
- function dragEnd(d,i) {
- d3.select(chart.container)
- .style('cursor', 'auto');
-
- // update state and send stateChange with new index
- state.index = index.i;
- dispatch.stateChange(state);
- }
-
-
-
-
- //------------------------------------------------------------
- // Display No Data message if there's nothing to show.
-
- if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {
- var noDataText = container.selectAll('.nv-noData').data([noData]);
-
- noDataText.enter().append('text')
- .attr('class', 'nvd3 nv-noData')
- .attr('dy', '-.7em')
- .style('text-anchor', 'middle');
-
- noDataText
- .attr('x', margin.left + availableWidth / 2)
- .attr('y', margin.top + availableHeight / 2)
- .text(function(d) { return d });
-
- return chart;
- } else {
- container.selectAll('.nv-noData').remove();
- }
-
- //------------------------------------------------------------
-
-
- //------------------------------------------------------------
- // Setup Scales
-
- x = lines.xScale();
- y = lines.yScale();
-
-
- if (!rescaleY) {
- var seriesDomains = data
- .filter(function(series) { return !series.disabled })
- .map(function(series,i) {
- var initialDomain = d3.extent(series.values, lines.y());
-
- //account for series being disabled when losing 95% or more
- if (initialDomain[0] < -.95) initialDomain[0] = -.95;
-
- return [
- (initialDomain[0] - initialDomain[1]) / (1 + initialDomain[1]),
- (initialDomain[1] - initialDomain[0]) / (1 + initialDomain[0])
- ];
- });
-
- var completeDomain = [
- d3.min(seriesDomains, function(d) { return d[0] }),
- d3.max(seriesDomains, function(d) { return d[1] })
- ]
-
- lines.yDomain(completeDomain);
- } else {
- lines.yDomain(null);
- }
-
-
- dx .domain([0, data[0].values.length - 1]) //Assumes all series have same length
- .range([0, availableWidth])
- .clamp(true);
-
- //------------------------------------------------------------
-
-
- var data = indexify(index.i, data);
-
-
- //------------------------------------------------------------
- // Setup containers and skeleton of chart
-
- var wrap = container.selectAll('g.nv-wrap.nv-cumulativeLine').data([data]);
- var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-cumulativeLine').append('g');
- var g = wrap.select('g');
-
- gEnter.append('g').attr('class', 'nv-x nv-axis');
- gEnter.append('g').attr('class', 'nv-y nv-axis');
- gEnter.append('g').attr('class', 'nv-background');
- gEnter.append('g').attr('class', 'nv-linesWrap');
- gEnter.append('g').attr('class', 'nv-avgLinesWrap');
- gEnter.append('g').attr('class', 'nv-legendWrap');
- gEnter.append('g').attr('class', 'nv-controlsWrap');
-
- //------------------------------------------------------------
-
-
- //------------------------------------------------------------
- // Legend
-
- if (showLegend) {
- legend.width(availableWidth);
-
- g.select('.nv-legendWrap')
- .datum(data)
- .call(legend);
-
- if ( margin.top != legend.height()) {
- margin.top = legend.height();
- availableHeight = (height || parseInt(container.style('height')) || 400)
- - margin.top - margin.bottom;
- }
-
- g.select('.nv-legendWrap')
- .attr('transform', 'translate(0,' + (-margin.top) +')')
- }
-
- //------------------------------------------------------------
-
-
- //------------------------------------------------------------
- // Controls
-
- if (showControls) {
- var controlsData = [
- { key: 'Re-scale y-axis', disabled: !rescaleY }
- ];
-
- controls.width(140).color(['#444', '#444', '#444']);
- g.select('.nv-controlsWrap')
- .datum(controlsData)
- .attr('transform', 'translate(0,' + (-margin.top) +')')
- .call(controls);
- }
-
- //------------------------------------------------------------
-
-
- wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
-
-
- // Show error if series goes below 100%
- var tempDisabled = data.filter(function(d) { return d.tempDisabled });
-
- wrap.select('.tempDisabled').remove(); //clean-up and prevent duplicates
- if (tempDisabled.length) {
- wrap.append('text').attr('class', 'tempDisabled')
- .attr('x', availableWidth / 2)
- .attr('y', '-.71em')
- .style('text-anchor', 'end')
- .text(tempDisabled.map(function(d) { return d.key }).join(', ') + ' values cannot be calculated for this time period.');
- }
-
- //------------------------------------------------------------
- // Main Chart Component(s)
-
- gEnter.select('.nv-background')
- .append('rect');
-
- g.select('.nv-background rect')
- .attr('width', availableWidth)
- .attr('height', availableHeight);
-
- lines
- //.x(function(d) { return d.x })
- .y(function(d) { return d.display.y })
- .width(availableWidth)
- .height(availableHeight)
- .color(data.map(function(d,i) {
- return d.color || color(d, i);
- }).filter(function(d,i) { return !data[i].disabled && !data[i].tempDisabled; }));
-
-
-
- var linesWrap = g.select('.nv-linesWrap')
- .datum(data.filter(function(d) { return !d.disabled && !d.tempDisabled }));
-
- //d3.transition(linesWrap).call(lines);
- linesWrap.call(lines);
-
- /*Handle average lines [AN-612] ----------------------------*/
-
- //Store a series index number in the data array.
- data.forEach(function(d,i) {
- d.seriesIndex = i;
- });
-
- var avgLineData = data.filter(function(d) {
- return !d.disabled && !!average(d);
- });
-
- var avgLines = g.select(".nv-avgLinesWrap").selectAll("line")
- .data(avgLineData, function(d) { return d.key; });
-
- avgLines.enter()
- .append('line')
- .style('stroke-width',2)
- .style('stroke-dasharray','10,10')
- .style('stroke',function (d,i) {
- return lines.color()(d,d.seriesIndex);
- })
- .attr('x1',0)
- .attr('x2',availableWidth)
- .attr('y1', function(d) { return y(average(d)); })
- .attr('y2', function(d) { return y(average(d)); });
-
- avgLines
- .attr('x1',0)
- .attr('x2',availableWidth)
- .attr('y1', function(d) { return y(average(d)); })
- .attr('y2', function(d) { return y(average(d)); });
-
- avgLines.exit().remove();
-
- //Create index line -----------------------------------------
-
- var indexLine = linesWrap.selectAll('.nv-indexLine')
- .data([index]);
- indexLine.enter().append('rect').attr('class', 'nv-indexLine')
- .attr('width', 3)
- .attr('x', -2)
- .attr('fill', 'red')
- .attr('fill-opacity', .5)
- .call(indexDrag)
-
- indexLine
- .attr('transform', function(d) { return 'translate(' + dx(d.i) + ',0)' })
- .attr('height', availableHeight)
-
- //------------------------------------------------------------
-
-
- //------------------------------------------------------------
- // Setup Axes
-
- xAxis
- .scale(x)
- //Suggest how many ticks based on the chart width and D3 should listen (70 is the optimal number for MM/DD/YY dates)
- .ticks( Math.min(data[0].values.length,availableWidth/70) )
- .tickSize(-availableHeight, 0);
-
- g.select('.nv-x.nv-axis')
- .attr('transform', 'translate(0,' + y.range()[0] + ')');
- d3.transition(g.select('.nv-x.nv-axis'))
- .call(xAxis);
-
-
- yAxis
- .scale(y)
- .ticks( availableHeight / 36 )
- .tickSize( -availableWidth, 0);
-
- d3.transition(g.select('.nv-y.nv-axis'))
- .call(yAxis);
-
- //------------------------------------------------------------
-
-
- //============================================================
- // Event Handling/Dispatching (in chart's scope)
- //------------------------------------------------------------
-
-
- function updateZero() {
- indexLine
- .data([index]);
-
- container.call(chart);
- }
-
- g.select('.nv-background rect')
- .on('click', function() {
- index.x = d3.mouse(this)[0];
- index.i = Math.round(dx.invert(index.x));
-
- // update state and send stateChange with new index
- state.index = index.i;
- dispatch.stateChange(state);
-
- updateZero();
- });
-
- lines.dispatch.on('elementClick', function(e) {
- index.i = e.pointIndex;
- index.x = dx(index.i);
-
- // update state and send stateChange with new index
- state.index = index.i;
- dispatch.stateChange(state);
-
- updateZero();
- });
-
- controls.dispatch.on('legendClick', function(d,i) {
- d.disabled = !d.disabled;
- rescaleY = !d.disabled;
-
- state.rescaleY = rescaleY;
- dispatch.stateChange(state);
-
- //selection.transition().call(chart);
- chart.update();
- });
-
-
- legend.dispatch.on('legendClick', function(d,i) {
- d.disabled = !d.disabled;
-
- if (!data.filter(function(d) { return !d.disabled }).length) {
- data.map(function(d) {
- d.disabled = false;
- wrap.selectAll('.nv-series').classed('disabled', false);
- return d;
- });
- }
-
- state.disabled = data.map(function(d) { return !!d.disabled });
- dispatch.stateChange(state);
-
- //selection.transition().call(chart);
- chart.update();
- });
-
- legend.dispatch.on('legendDblclick', function(d) {
- //Double clicking should always enable current series, and disabled all others.
- data.forEach(function(d) {
- d.disabled = true;
- });
- d.disabled = false;
-
- state.disabled = data.map(function(d) { return !!d.disabled });
- dispatch.stateChange(state);
- chart.update();
- });
-
-
-/*
- //
- legend.dispatch.on('legendMouseover', function(d, i) {
- d.hover = true;
- selection.transition().call(chart)
- });
-
- legend.dispatch.on('legendMouseout', function(d, i) {
- d.hover = false;
- selection.transition().call(chart)
- });
-*/
-
- dispatch.on('tooltipShow', function(e) {
- if (tooltips) showTooltip(e, that.parentNode);
- });
-
-
- // Update chart from a state object passed to event handler
- dispatch.on('changeState', function(e) {
-
- if (typeof e.disabled !== 'undefined') {
- data.forEach(function(series,i) {
- series.disabled = e.disabled[i];
- });
-
- state.disabled = e.disabled;
- }
-
-
- if (typeof e.index !== 'undefined') {
- index.i = e.index;
- index.x = dx(index.i);
-
- state.index = e.index;
-
- indexLine
- .data([index]);
- }
-
-
- if (typeof e.rescaleY !== 'undefined') {
- rescaleY = e.rescaleY;
- }
-
- chart.update();
- });
-
- //============================================================
-
- });
-
- return chart;
- }
-
-
- //============================================================
- // Event Handling/Dispatching (out of chart's scope)
- //------------------------------------------------------------
-
- lines.dispatch.on('elementMouseover.tooltip', function(e) {
- e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top];
- dispatch.tooltipShow(e);
- });
-
- lines.dispatch.on('elementMouseout.tooltip', function(e) {
- dispatch.tooltipHide(e);
- });
-
- dispatch.on('tooltipHide', function() {
- if (tooltips) nv.tooltip.cleanup();
- });
-
- //============================================================
-
-
- //============================================================
- // Expose Public Variables
- //------------------------------------------------------------
-
- // expose chart's sub-components
- chart.dispatch = dispatch;
- chart.lines = lines;
- chart.legend = legend;
- chart.xAxis = xAxis;
- chart.yAxis = yAxis;
-
- d3.rebind(chart, lines, 'defined', 'isArea', 'x', 'y', 'size', 'xDomain', 'yDomain', 'forceX', 'forceY', 'interactive', 'clipEdge', 'clipVoronoi', 'id');
-
- chart.margin = function(_) {
- if (!arguments.length) return margin;
- margin.top = typeof _.top != 'undefined' ? _.top : margin.top;
- margin.right = typeof _.right != 'undefined' ? _.right : margin.right;
- margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom;
- margin.left = typeof _.left != 'undefined' ? _.left : margin.left;
- return chart;
- };
-
- chart.width = function(_) {
- if (!arguments.length) return width;
- width = _;
- return chart;
- };
-
- chart.height = function(_) {
- if (!arguments.length) return height;
- height = _;
- return chart;
- };
-
- chart.color = function(_) {
- if (!arguments.length) return color;
- color = nv.utils.getColor(_);
- legend.color(color);
- return chart;
- };
-
- chart.rescaleY = function(_) {
- if (!arguments.length) return rescaleY;
- rescaleY = _
- return rescaleY;
- };
-
- chart.showControls = function(_) {
- if (!arguments.length) return showControls;
- showControls = _;
- return chart;
- };
-
- chart.showLegend = function(_) {
- if (!arguments.length) return showLegend;
- showLegend = _;
- return chart;
- };
-
- chart.tooltips = function(_) {
- if (!arguments.length) return tooltips;
- tooltips = _;
- return chart;
- };
-
- chart.tooltipContent = function(_) {
- if (!arguments.length) return tooltip;
- tooltip = _;
- return chart;
- };
-
- chart.state = function(_) {
- if (!arguments.length) return state;
- state = _;
- return chart;
- };
-
- chart.defaultState = function(_) {
- if (!arguments.length) return defaultState;
- defaultState = _;
- return chart;
- };
-
- chart.noData = function(_) {
- if (!arguments.length) return noData;
- noData = _;
- return chart;
- };
-
- chart.average = function(_) {
- if(!arguments.length) return average;
- average = _;
- return chart;
- };
-
- //============================================================
-
-
- //============================================================
- // Functions
- //------------------------------------------------------------
-
- /* Normalize the data according to an index point. */
- function indexify(idx, data) {
- return data.map(function(line, i) {
- if (!line.values) {
- return line;
- }
- var v = lines.y()(line.values[idx], idx);
-
- //TODO: implement check below, and disable series if series loses 100% or more cause divide by 0 issue
- if (v < -.95) {
- //if a series loses more than 100%, calculations fail.. anything close can cause major distortion (but is mathematically correct till it hits 100)
- line.tempDisabled = true;
- return line;
- }
-
- line.tempDisabled = false;
-
- line.values = line.values.map(function(point, pointIndex) {
- point.display = {'y': (lines.y()(point, pointIndex) - v) / (1 + v) };
- return point;
- })
-
- return line;
- })
- }
-
- //============================================================
-
-
- return chart;
-}
-//TODO: consider deprecating by adding necessary features to multiBar model
-nv.models.discreteBar = function() {
-
- //============================================================
- // Public Variables with Default Settings
- //------------------------------------------------------------
-
- var margin = {top: 0, right: 0, bottom: 0, left: 0}
- , width = 960
- , height = 500
- , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one
- , x = d3.scale.ordinal()
- , y = d3.scale.linear()
- , getX = function(d) { return d.x }
- , getY = function(d) { return d.y }
- , forceY = [0] // 0 is forced by default.. this makes sense for the majority of bar graphs... user can always do chart.forceY([]) to remove
- , color = nv.utils.defaultColor()
- , showValues = false
- , valueFormat = d3.format(',.2f')
- , xDomain
- , yDomain
- , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout')
- , rectClass = 'discreteBar'
- ;
-
- //============================================================
-
-
- //============================================================
- // Private Variables
- //------------------------------------------------------------
-
- var x0, y0;
-
- //============================================================
-
-
- function chart(selection) {
- selection.each(function(data) {
- var availableWidth = width - margin.left - margin.right,
- availableHeight = height - margin.top - margin.bottom,
- container = d3.select(this);
-
-
- //add series index to each data point for reference
- data = data.map(function(series, i) {
- series.values = series.values.map(function(point) {
- point.series = i;
- return point;
- });
- return series;
- });
-
-
- //------------------------------------------------------------
- // Setup Scales
-
- // remap and flatten the data for use in calculating the scales' domains
- var seriesData = (xDomain && yDomain) ? [] : // if we know xDomain and yDomain, no need to calculate
- data.map(function(d) {
- return d.values.map(function(d,i) {
- return { x: getX(d,i), y: getY(d,i), y0: d.y0 }
- })
- });
-
- x .domain(xDomain || d3.merge(seriesData).map(function(d) { return d.x }))
- .rangeBands([0, availableWidth], .1);
-
- y .domain(yDomain || d3.extent(d3.merge(seriesData).map(function(d) { return d.y }).concat(forceY)));
-
-
- // If showValues, pad the Y axis range to account for label height
- if (showValues) y.range([availableHeight - (y.domain()[0] < 0 ? 12 : 0), y.domain()[1] > 0 ? 12 : 0]);
- else y.range([availableHeight, 0]);
-
- //store old scales if they exist
- x0 = x0 || x;
- y0 = y0 || y.copy().range([y(0),y(0)]);
-
- //------------------------------------------------------------
-
-
- //------------------------------------------------------------
- // Setup containers and skeleton of chart
-
- var wrap = container.selectAll('g.nv-wrap.nv-discretebar').data([data]);
- var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-discretebar');
- var gEnter = wrapEnter.append('g');
- var g = wrap.select('g');
-
- gEnter.append('g').attr('class', 'nv-groups');
-
- wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
-
- //------------------------------------------------------------
-
-
-
- //TODO: by definition, the discrete bar should not have multiple groups, will modify/remove later
- var groups = wrap.select('.nv-groups').selectAll('.nv-group')
- .data(function(d) { return d }, function(d) { return d.key });
- groups.enter().append('g')
- .style('stroke-opacity', 1e-6)
- .style('fill-opacity', 1e-6);
- d3.transition(groups.exit())
- .style('stroke-opacity', 1e-6)
- .style('fill-opacity', 1e-6)
- .remove();
- groups
- .attr('class', function(d,i) { return 'nv-group nv-series-' + i })
- .classed('hover', function(d) { return d.hover });
- d3.transition(groups)
- .style('stroke-opacity', 1)
- .style('fill-opacity', .75);
-
-
- var bars = groups.selectAll('g.nv-bar')
- .data(function(d) { return d.values });
-
- bars.exit().remove();
-
-
- var barsEnter = bars.enter().append('g')
- .attr('transform', function(d,i,j) {
- return 'translate(' + (x(getX(d,i)) + x.rangeBand() * .05 ) + ', ' + y(0) + ')'
- })
- .on('mouseover', function(d,i) { //TODO: figure out why j works above, but not here
- d3.select(this).classed('hover', true);
- dispatch.elementMouseover({
- value: getY(d,i),
- point: d,
- series: data[d.series],
- pos: [x(getX(d,i)) + (x.rangeBand() * (d.series + .5) / data.length), y(getY(d,i))], // TODO: Figure out why the value appears to be shifted
- pointIndex: i,
- seriesIndex: d.series,
- e: d3.event
- });
- })
- .on('mouseout', function(d,i) {
- d3.select(this).classed('hover', false);
- dispatch.elementMouseout({
- value: getY(d,i),
- point: d,
- series: data[d.series],
- pointIndex: i,
- seriesIndex: d.series,
- e: d3.event
- });
- })
- .on('click', function(d,i) {
- dispatch.elementClick({
- value: getY(d,i),
- point: d,
- series: data[d.series],
- pos: [x(getX(d,i)) + (x.rangeBand() * (d.series + .5) / data.length), y(getY(d,i))], // TODO: Figure out why the value appears to be shifted
- pointIndex: i,
- seriesIndex: d.series,
- e: d3.event
- });
- d3.event.stopPropagation();
- })
- .on('dblclick', function(d,i) {
- dispatch.elementDblClick({
- value: getY(d,i),
- point: d,
- series: data[d.series],
- pos: [x(getX(d,i)) + (x.rangeBand() * (d.series + .5) / data.length), y(getY(d,i))], // TODO: Figure out why the value appears to be shifted
- pointIndex: i,
- seriesIndex: d.series,
- e: d3.event
- });
- d3.event.stopPropagation();
- });
-
- barsEnter.append('rect')
- .attr('height', 0)
- .attr('width', x.rangeBand() * .9 / data.length )
-
- if (showValues) {
- barsEnter.append('text')
- .attr('text-anchor', 'middle')
- bars.select('text')
- .attr('x', x.rangeBand() * .9 / 2)
- .attr('y', function(d,i) { return getY(d,i) < 0 ? y(getY(d,i)) - y(0) + 12 : -4 })
- .text(function(d,i) { return valueFormat(getY(d,i)) });
- } else {
- bars.selectAll('text').remove();
- }
-
- bars
- .attr('class', function(d,i) { return getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive' })
- .style('fill', function(d,i) { return d.color || color(d,i) })
- .style('stroke', function(d,i) { return d.color || color(d,i) })
- .select('rect')
- .attr('class', rectClass)
- .attr('width', x.rangeBand() * .9 / data.length);
- d3.transition(bars)
- //.delay(function(d,i) { return i * 1200 / data[0].values.length })
- .attr('transform', function(d,i) {
- var left = x(getX(d,i)) + x.rangeBand() * .05,
- top = getY(d,i) < 0 ?
- y(0) :
- y(0) - y(getY(d,i)) < 1 ?
- y(0) - 1 : //make 1 px positive bars show up above y=0
- y(getY(d,i));
-
- return 'translate(' + left + ', ' + top + ')'
- })
- .select('rect')
- .attr('height', function(d,i) {
- return Math.max(Math.abs(y(getY(d,i)) - y(0)) || 1)
- });
-
-
- //store old scales for use in transitions on update
- x0 = x.copy();
- y0 = y.copy();
-
- });
-
- return chart;
- }
-
-
- //============================================================
- // Expose Public Variables
- //------------------------------------------------------------
-
- chart.dispatch = dispatch;
-
- chart.x = function(_) {
- if (!arguments.length) return getX;
- getX = _;
- return chart;
- };
-
- chart.y = function(_) {
- if (!arguments.length) return getY;
- getY = _;
- return chart;
- };
-
- chart.margin = function(_) {
- if (!arguments.length) return margin;
- margin.top = typeof _.top != 'undefined' ? _.top : margin.top;
- margin.right = typeof _.right != 'undefined' ? _.right : margin.right;
- margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom;
- margin.left = typeof _.left != 'undefined' ? _.left : margin.left;
- return chart;
- };
-
- chart.width = function(_) {
- if (!arguments.length) return width;
- width = _;
- return chart;
- };
-
- chart.height = function(_) {
- if (!arguments.length) return height;
- height = _;
- return chart;
- };
-
- chart.xScale = function(_) {
- if (!arguments.length) return x;
- x = _;
- return chart;
- };
-
- chart.yScale = function(_) {
- if (!arguments.length) return y;
- y = _;
- return chart;
- };
-
- chart.xDomain = function(_) {
- if (!arguments.length) return xDomain;
- xDomain = _;
- return chart;
- };
-
- chart.yDomain = function(_) {
- if (!arguments.length) return yDomain;
- yDomain = _;
- return chart;
- };
-
- chart.forceY = function(_) {
- if (!arguments.length) return forceY;
- forceY = _;
- return chart;
- };
-
- chart.color = function(_) {
- if (!arguments.length) return color;
- color = nv.utils.getColor(_);
- return chart;
- };
-
- chart.id = function(_) {
- if (!arguments.length) return id;
- id = _;
- return chart;
- };
-
- chart.showValues = function(_) {
- if (!arguments.length) return showValues;
- showValues = _;
- return chart;
- };
-
- chart.valueFormat= function(_) {
- if (!arguments.length) return valueFormat;
- valueFormat = _;
- return chart;
- };
-
- chart.rectClass= function(_) {
- if (!arguments.length) return rectClass;
- rectClass = _;
- return chart;
- }
- //============================================================
-
-
- return chart;
-}
-
-nv.models.discreteBarChart = function() {
-
- //============================================================
- // Public Variables with Default Settings
- //------------------------------------------------------------
-
- var discretebar = nv.models.discreteBar()
- , xAxis = nv.models.axis()
- , yAxis = nv.models.axis()
- ;
-
- var margin = {top: 15, right: 10, bottom: 50, left: 60}
- , width = null
- , height = null
- , color = nv.utils.getColor()
- , staggerLabels = false
- , tooltips = true
- , tooltip = function(key, x, y, e, graph) {
- return '<h3>' + x + '</h3>' +
- '<p>' + y + '</p>'
- }
- , x
- , y
- , noData = "No Data Available."
- , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'beforeUpdate')
- ;
-
- xAxis
- .orient('bottom')
- .highlightZero(false)
- .showMaxMin(false)
- .tickFormat(function(d) { return d })
- ;
- yAxis
- .orient('left')
- .tickFormat(d3.format(',.1f'))
- ;
-
- //============================================================
-
-
- //============================================================
- // Private Variables
- //------------------------------------------------------------
-
- var showTooltip = function(e, offsetElement) {
- var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ),
- top = e.pos[1] + ( offsetElement.offsetTop || 0),
- x = xAxis.tickFormat()(discretebar.x()(e.point, e.pointIndex)),
- y = yAxis.tickFormat()(discretebar.y()(e.point, e.pointIndex)),
- content = tooltip(e.series.key, x, y, e, chart);
-
- nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's', null, offsetElement);
- };
-
- //============================================================
-
-
- function chart(selection) {
- selection.each(function(data) {
- var container = d3.select(this),
- that = this;
-
- var availableWidth = (width || parseInt(container.style('width')) || 960)
- - margin.left - margin.right,
- availableHeight = (height || parseInt(container.style('height')) || 400)
- - margin.top - margin.bottom;
-
-
- chart.update = function() { dispatch.beforeUpdate(); container.transition().call(chart); };
- chart.container = this;
-
-
- //------------------------------------------------------------
- // Display No Data message if there's nothing to show.
-
- if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {
- var noDataText = container.selectAll('.nv-noData').data([noData]);
-
- noDataText.enter().append('text')
- .attr('class', 'nvd3 nv-noData')
- .attr('dy', '-.7em')
- .style('text-anchor', 'middle');
-
- noDataText
- .attr('x', margin.left + availableWidth / 2)
- .attr('y', margin.top + availableHeight / 2)
- .text(function(d) { return d });
-
- return chart;
- } else {
- container.selectAll('.nv-noData').remove();
- }
-
- //------------------------------------------------------------
-
-
- //------------------------------------------------------------
- // Setup Scales
-
- x = discretebar.xScale();
- y = discretebar.yScale();
-
- //------------------------------------------------------------
-
-
- //------------------------------------------------------------
- // Setup containers and skeleton of chart
-
- var wrap = container.selectAll('g.nv-wrap.nv-discreteBarWithAxes').data([data]);
- var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-discreteBarWithAxes').append('g');
- var defsEnter = gEnter.append('defs');
- var g = wrap.select('g');
-
- gEnter.append('g').attr('class', 'nv-x nv-axis');
- gEnter.append('g').attr('class', 'nv-y nv-axis');
- gEnter.append('g').attr('class', 'nv-barsWrap');
-
- g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
-
- //------------------------------------------------------------
-
-
- //------------------------------------------------------------
- // Main Chart Component(s)
-
- discretebar
- .width(availableWidth)
- .height(availableHeight);
-
-
- var barsWrap = g.select('.nv-barsWrap')
- .datum(data.filter(function(d) { return !d.disabled }))
-
- d3.transition(barsWrap).call(discretebar);
-
- //------------------------------------------------------------
-
-
-
- defsEnter.append('clipPath')
- .attr('id', 'nv-x-label-clip-' + discretebar.id())
- .append('rect');
-
- g.select('#nv-x-label-clip-' + discretebar.id() + ' rect')
- .attr('width', x.rangeBand() * (staggerLabels ? 2 : 1))
- .attr('height', 16)
- .attr('x', -x.rangeBand() / (staggerLabels ? 1 : 2 ));
-
-
- //------------------------------------------------------------
- // Setup Axes
-
- xAxis
- .scale(x)
- .ticks( availableWidth / 100 )
- .tickSize(-availableHeight, 0);
-
- g.select('.nv-x.nv-axis')
- .attr('transform', 'translate(0,' + (y.range()[0] + ((discretebar.showValues() && y.domain()[0] < 0) ? 16 : 0)) + ')');
- //d3.transition(g.select('.nv-x.nv-axis'))
- g.select('.nv-x.nv-axis').transition().duration(0)
- .call(xAxis);
-
-
- var xTicks = g.select('.nv-x.nv-axis').selectAll('g');
-
- if (staggerLabels) {
- xTicks
- .selectAll('text')
- .attr('transform', function(d,i,j) { return 'translate(0,' + (j % 2 == 0 ? '5' : '17') + ')' })
- }
-
- yAxis
- .scale(y)
- .ticks( availableHeight / 36 )
- .tickSize( -availableWidth, 0);
-
- d3.transition(g.select('.nv-y.nv-axis'))
- .call(yAxis);
-
- //------------------------------------------------------------
-
-
- //============================================================
- // Event Handling/Dispatching (in chart's scope)
- //------------------------------------------------------------
-
- dispatch.on('tooltipShow', function(e) {
- if (tooltips) showTooltip(e, that.parentNode);
- });
-
- //============================================================
-
-
- });
-
- return chart;
- }
-
- //============================================================
- // Event Handling/Dispatching (out of chart's scope)
- //------------------------------------------------------------
-
- discretebar.dispatch.on('elementMouseover.tooltip', function(e) {
- e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top];
- dispatch.tooltipShow(e);
- });
-
- discretebar.dispatch.on('elementMouseout.tooltip', function(e) {
- dispatch.toolt
<TRUNCATED>
[04/26] Remove fauxton from 1.4.x branch.
Posted by dj...@apache.org.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/test/mocha/sinon.js
----------------------------------------------------------------------
diff --git a/src/fauxton/test/mocha/sinon.js b/src/fauxton/test/mocha/sinon.js
deleted file mode 100644
index 26c4bd9..0000000
--- a/src/fauxton/test/mocha/sinon.js
+++ /dev/null
@@ -1,4290 +0,0 @@
-/**
- * Sinon.JS 1.7.3, 2013/06/20
- *
- * @author Christian Johansen (christian@cjohansen.no)
- * @author Contributors: https://github.com/cjohansen/Sinon.JS/blob/master/AUTHORS
- *
- * (The BSD License)
- *
- * Copyright (c) 2010-2013, Christian Johansen, christian@cjohansen.no
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of Christian Johansen nor the names of his contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-this.sinon = (function () {
-var buster = (function (setTimeout, B) {
- var isNode = typeof require == "function" && typeof module == "object";
- var div = typeof document != "undefined" && document.createElement("div");
- var F = function () {};
-
- var buster = {
- bind: function bind(obj, methOrProp) {
- var method = typeof methOrProp == "string" ? obj[methOrProp] : methOrProp;
- var args = Array.prototype.slice.call(arguments, 2);
- return function () {
- var allArgs = args.concat(Array.prototype.slice.call(arguments));
- return method.apply(obj, allArgs);
- };
- },
-
- partial: function partial(fn) {
- var args = [].slice.call(arguments, 1);
- return function () {
- return fn.apply(this, args.concat([].slice.call(arguments)));
- };
- },
-
- create: function create(object) {
- F.prototype = object;
- return new F();
- },
-
- extend: function extend(target) {
- if (!target) { return; }
- for (var i = 1, l = arguments.length, prop; i < l; ++i) {
- for (prop in arguments[i]) {
- target[prop] = arguments[i][prop];
- }
- }
- return target;
- },
-
- nextTick: function nextTick(callback) {
- if (typeof process != "undefined" && process.nextTick) {
- return process.nextTick(callback);
- }
- setTimeout(callback, 0);
- },
-
- functionName: function functionName(func) {
- if (!func) return "";
- if (func.displayName) return func.displayName;
- if (func.name) return func.name;
- var matches = func.toString().match(/function\s+([^\(]+)/m);
- return matches && matches[1] || "";
- },
-
- isNode: function isNode(obj) {
- if (!div) return false;
- try {
- obj.appendChild(div);
- obj.removeChild(div);
- } catch (e) {
- return false;
- }
- return true;
- },
-
- isElement: function isElement(obj) {
- return obj && obj.nodeType === 1 && buster.isNode(obj);
- },
-
- isArray: function isArray(arr) {
- return Object.prototype.toString.call(arr) == "[object Array]";
- },
-
- flatten: function flatten(arr) {
- var result = [], arr = arr || [];
- for (var i = 0, l = arr.length; i < l; ++i) {
- result = result.concat(buster.isArray(arr[i]) ? flatten(arr[i]) : arr[i]);
- }
- return result;
- },
-
- each: function each(arr, callback) {
- for (var i = 0, l = arr.length; i < l; ++i) {
- callback(arr[i]);
- }
- },
-
- map: function map(arr, callback) {
- var results = [];
- for (var i = 0, l = arr.length; i < l; ++i) {
- results.push(callback(arr[i]));
- }
- return results;
- },
-
- parallel: function parallel(fns, callback) {
- function cb(err, res) {
- if (typeof callback == "function") {
- callback(err, res);
- callback = null;
- }
- }
- if (fns.length == 0) { return cb(null, []); }
- var remaining = fns.length, results = [];
- function makeDone(num) {
- return function done(err, result) {
- if (err) { return cb(err); }
- results[num] = result;
- if (--remaining == 0) { cb(null, results); }
- };
- }
- for (var i = 0, l = fns.length; i < l; ++i) {
- fns[i](makeDone(i));
- }
- },
-
- series: function series(fns, callback) {
- function cb(err, res) {
- if (typeof callback == "function") {
- callback(err, res);
- }
- }
- var remaining = fns.slice();
- var results = [];
- function callNext() {
- if (remaining.length == 0) return cb(null, results);
- var promise = remaining.shift()(next);
- if (promise && typeof promise.then == "function") {
- promise.then(buster.partial(next, null), next);
- }
- }
- function next(err, result) {
- if (err) return cb(err);
- results.push(result);
- callNext();
- }
- callNext();
- },
-
- countdown: function countdown(num, done) {
- return function () {
- if (--num == 0) done();
- };
- }
- };
-
- if (typeof process === "object" &&
- typeof require === "function" && typeof module === "object") {
- var crypto = require("crypto");
- var path = require("path");
-
- buster.tmpFile = function (fileName) {
- var hashed = crypto.createHash("sha1");
- hashed.update(fileName);
- var tmpfileName = hashed.digest("hex");
-
- if (process.platform == "win32") {
- return path.join(process.env["TEMP"], tmpfileName);
- } else {
- return path.join("/tmp", tmpfileName);
- }
- };
- }
-
- if (Array.prototype.some) {
- buster.some = function (arr, fn, thisp) {
- return arr.some(fn, thisp);
- };
- } else {
- // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some
- buster.some = function (arr, fun, thisp) {
- if (arr == null) { throw new TypeError(); }
- arr = Object(arr);
- var len = arr.length >>> 0;
- if (typeof fun !== "function") { throw new TypeError(); }
-
- for (var i = 0; i < len; i++) {
- if (arr.hasOwnProperty(i) && fun.call(thisp, arr[i], i, arr)) {
- return true;
- }
- }
-
- return false;
- };
- }
-
- if (Array.prototype.filter) {
- buster.filter = function (arr, fn, thisp) {
- return arr.filter(fn, thisp);
- };
- } else {
- // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/filter
- buster.filter = function (fn, thisp) {
- if (this == null) { throw new TypeError(); }
-
- var t = Object(this);
- var len = t.length >>> 0;
- if (typeof fn != "function") { throw new TypeError(); }
-
- var res = [];
- for (var i = 0; i < len; i++) {
- if (i in t) {
- var val = t[i]; // in case fun mutates this
- if (fn.call(thisp, val, i, t)) { res.push(val); }
- }
- }
-
- return res;
- };
- }
-
- if (isNode) {
- module.exports = buster;
- buster.eventEmitter = require("./buster-event-emitter");
- Object.defineProperty(buster, "defineVersionGetter", {
- get: function () {
- return require("./define-version-getter");
- }
- });
- }
-
- return buster.extend(B || {}, buster);
-}(setTimeout, buster));
-if (typeof buster === "undefined") {
- var buster = {};
-}
-
-if (typeof module === "object" && typeof require === "function") {
- buster = require("buster-core");
-}
-
-buster.format = buster.format || {};
-buster.format.excludeConstructors = ["Object", /^.$/];
-buster.format.quoteStrings = true;
-
-buster.format.ascii = (function () {
-
- var hasOwn = Object.prototype.hasOwnProperty;
-
- var specialObjects = [];
- if (typeof global != "undefined") {
- specialObjects.push({ obj: global, value: "[object global]" });
- }
- if (typeof document != "undefined") {
- specialObjects.push({ obj: document, value: "[object HTMLDocument]" });
- }
- if (typeof window != "undefined") {
- specialObjects.push({ obj: window, value: "[object Window]" });
- }
-
- function keys(object) {
- var k = Object.keys && Object.keys(object) || [];
-
- if (k.length == 0) {
- for (var prop in object) {
- if (hasOwn.call(object, prop)) {
- k.push(prop);
- }
- }
- }
-
- return k.sort();
- }
-
- function isCircular(object, objects) {
- if (typeof object != "object") {
- return false;
- }
-
- for (var i = 0, l = objects.length; i < l; ++i) {
- if (objects[i] === object) {
- return true;
- }
- }
-
- return false;
- }
-
- function ascii(object, processed, indent) {
- if (typeof object == "string") {
- var quote = typeof this.quoteStrings != "boolean" || this.quoteStrings;
- return processed || quote ? '"' + object + '"' : object;
- }
-
- if (typeof object == "function" && !(object instanceof RegExp)) {
- return ascii.func(object);
- }
-
- processed = processed || [];
-
- if (isCircular(object, processed)) {
- return "[Circular]";
- }
-
- if (Object.prototype.toString.call(object) == "[object Array]") {
- return ascii.array.call(this, object, processed);
- }
-
- if (!object) {
- return "" + object;
- }
-
- if (buster.isElement(object)) {
- return ascii.element(object);
- }
-
- if (typeof object.toString == "function" &&
- object.toString !== Object.prototype.toString) {
- return object.toString();
- }
-
- for (var i = 0, l = specialObjects.length; i < l; i++) {
- if (object === specialObjects[i].obj) {
- return specialObjects[i].value;
- }
- }
-
- return ascii.object.call(this, object, processed, indent);
- }
-
- ascii.func = function (func) {
- return "function " + buster.functionName(func) + "() {}";
- };
-
- ascii.array = function (array, processed) {
- processed = processed || [];
- processed.push(array);
- var pieces = [];
-
- for (var i = 0, l = array.length; i < l; ++i) {
- pieces.push(ascii.call(this, array[i], processed));
- }
-
- return "[" + pieces.join(", ") + "]";
- };
-
- ascii.object = function (object, processed, indent) {
- processed = processed || [];
- processed.push(object);
- indent = indent || 0;
- var pieces = [], properties = keys(object), prop, str, obj;
- var is = "";
- var length = 3;
-
- for (var i = 0, l = indent; i < l; ++i) {
- is += " ";
- }
-
- for (i = 0, l = properties.length; i < l; ++i) {
- prop = properties[i];
- obj = object[prop];
-
- if (isCircular(obj, processed)) {
- str = "[Circular]";
- } else {
- str = ascii.call(this, obj, processed, indent + 2);
- }
-
- str = (/\s/.test(prop) ? '"' + prop + '"' : prop) + ": " + str;
- length += str.length;
- pieces.push(str);
- }
-
- var cons = ascii.constructorName.call(this, object);
- var prefix = cons ? "[" + cons + "] " : ""
-
- return (length + indent) > 80 ?
- prefix + "{\n " + is + pieces.join(",\n " + is) + "\n" + is + "}" :
- prefix + "{ " + pieces.join(", ") + " }";
- };
-
- ascii.element = function (element) {
- var tagName = element.tagName.toLowerCase();
- var attrs = element.attributes, attribute, pairs = [], attrName;
-
- for (var i = 0, l = attrs.length; i < l; ++i) {
- attribute = attrs.item(i);
- attrName = attribute.nodeName.toLowerCase().replace("html:", "");
-
- if (attrName == "contenteditable" && attribute.nodeValue == "inherit") {
- continue;
- }
-
- if (!!attribute.nodeValue) {
- pairs.push(attrName + "=\"" + attribute.nodeValue + "\"");
- }
- }
-
- var formatted = "<" + tagName + (pairs.length > 0 ? " " : "");
- var content = element.innerHTML;
-
- if (content.length > 20) {
- content = content.substr(0, 20) + "[...]";
- }
-
- var res = formatted + pairs.join(" ") + ">" + content + "</" + tagName + ">";
-
- return res.replace(/ contentEditable="inherit"/, "");
- };
-
- ascii.constructorName = function (object) {
- var name = buster.functionName(object && object.constructor);
- var excludes = this.excludeConstructors || buster.format.excludeConstructors || [];
-
- for (var i = 0, l = excludes.length; i < l; ++i) {
- if (typeof excludes[i] == "string" && excludes[i] == name) {
- return "";
- } else if (excludes[i].test && excludes[i].test(name)) {
- return "";
- }
- }
-
- return name;
- };
-
- return ascii;
-}());
-
-if (typeof module != "undefined") {
- module.exports = buster.format;
-}
-/*jslint eqeqeq: false, onevar: false, forin: true, nomen: false, regexp: false, plusplus: false*/
-/*global module, require, __dirname, document*/
-/**
- * Sinon core utilities. For internal use only.
- *
- * @author Christian Johansen (christian@cjohansen.no)
- * @license BSD
- *
- * Copyright (c) 2010-2013 Christian Johansen
- */
-
-var sinon = (function (buster) {
- var div = typeof document != "undefined" && document.createElement("div");
- var hasOwn = Object.prototype.hasOwnProperty;
-
- function isDOMNode(obj) {
- var success = false;
-
- try {
- obj.appendChild(div);
- success = div.parentNode == obj;
- } catch (e) {
- return false;
- } finally {
- try {
- obj.removeChild(div);
- } catch (e) {
- // Remove failed, not much we can do about that
- }
- }
-
- return success;
- }
-
- function isElement(obj) {
- return div && obj && obj.nodeType === 1 && isDOMNode(obj);
- }
-
- function isFunction(obj) {
- return typeof obj === "function" || !!(obj && obj.constructor && obj.call && obj.apply);
- }
-
- function mirrorProperties(target, source) {
- for (var prop in source) {
- if (!hasOwn.call(target, prop)) {
- target[prop] = source[prop];
- }
- }
- }
-
- function isRestorable (obj) {
- return typeof obj === "function" && typeof obj.restore === "function" && obj.restore.sinon;
- }
-
- var sinon = {
- wrapMethod: function wrapMethod(object, property, method) {
- if (!object) {
- throw new TypeError("Should wrap property of object");
- }
-
- if (typeof method != "function") {
- throw new TypeError("Method wrapper should be function");
- }
-
- var wrappedMethod = object[property];
-
- if (!isFunction(wrappedMethod)) {
- throw new TypeError("Attempted to wrap " + (typeof wrappedMethod) + " property " +
- property + " as function");
- }
-
- if (wrappedMethod.restore && wrappedMethod.restore.sinon) {
- throw new TypeError("Attempted to wrap " + property + " which is already wrapped");
- }
-
- if (wrappedMethod.calledBefore) {
- var verb = !!wrappedMethod.returns ? "stubbed" : "spied on";
- throw new TypeError("Attempted to wrap " + property + " which is already " + verb);
- }
-
- // IE 8 does not support hasOwnProperty on the window object.
- var owned = hasOwn.call(object, property);
- object[property] = method;
- method.displayName = property;
-
- method.restore = function () {
- // For prototype properties try to reset by delete first.
- // If this fails (ex: localStorage on mobile safari) then force a reset
- // via direct assignment.
- if (!owned) {
- delete object[property];
- }
- if (object[property] === method) {
- object[property] = wrappedMethod;
- }
- };
-
- method.restore.sinon = true;
- mirrorProperties(method, wrappedMethod);
-
- return method;
- },
-
- extend: function extend(target) {
- for (var i = 1, l = arguments.length; i < l; i += 1) {
- for (var prop in arguments[i]) {
- if (arguments[i].hasOwnProperty(prop)) {
- target[prop] = arguments[i][prop];
- }
-
- // DONT ENUM bug, only care about toString
- if (arguments[i].hasOwnProperty("toString") &&
- arguments[i].toString != target.toString) {
- target.toString = arguments[i].toString;
- }
- }
- }
-
- return target;
- },
-
- create: function create(proto) {
- var F = function () {};
- F.prototype = proto;
- return new F();
- },
-
- deepEqual: function deepEqual(a, b) {
- if (sinon.match && sinon.match.isMatcher(a)) {
- return a.test(b);
- }
- if (typeof a != "object" || typeof b != "object") {
- return a === b;
- }
-
- if (isElement(a) || isElement(b)) {
- return a === b;
- }
-
- if (a === b) {
- return true;
- }
-
- if ((a === null && b !== null) || (a !== null && b === null)) {
- return false;
- }
-
- var aString = Object.prototype.toString.call(a);
- if (aString != Object.prototype.toString.call(b)) {
- return false;
- }
-
- if (aString == "[object Array]") {
- if (a.length !== b.length) {
- return false;
- }
-
- for (var i = 0, l = a.length; i < l; i += 1) {
- if (!deepEqual(a[i], b[i])) {
- return false;
- }
- }
-
- return true;
- }
-
- if (aString == "[object Date]") {
- return a.valueOf() === b.valueOf();
- }
-
- var prop, aLength = 0, bLength = 0;
-
- for (prop in a) {
- aLength += 1;
-
- if (!deepEqual(a[prop], b[prop])) {
- return false;
- }
- }
-
- for (prop in b) {
- bLength += 1;
- }
-
- return aLength == bLength;
- },
-
- functionName: function functionName(func) {
- var name = func.displayName || func.name;
-
- // Use function decomposition as a last resort to get function
- // name. Does not rely on function decomposition to work - if it
- // doesn't debugging will be slightly less informative
- // (i.e. toString will say 'spy' rather than 'myFunc').
- if (!name) {
- var matches = func.toString().match(/function ([^\s\(]+)/);
- name = matches && matches[1];
- }
-
- return name;
- },
-
- functionToString: function toString() {
- if (this.getCall && this.callCount) {
- var thisValue, prop, i = this.callCount;
-
- while (i--) {
- thisValue = this.getCall(i).thisValue;
-
- for (prop in thisValue) {
- if (thisValue[prop] === this) {
- return prop;
- }
- }
- }
- }
-
- return this.displayName || "sinon fake";
- },
-
- getConfig: function (custom) {
- var config = {};
- custom = custom || {};
- var defaults = sinon.defaultConfig;
-
- for (var prop in defaults) {
- if (defaults.hasOwnProperty(prop)) {
- config[prop] = custom.hasOwnProperty(prop) ? custom[prop] : defaults[prop];
- }
- }
-
- return config;
- },
-
- format: function (val) {
- return "" + val;
- },
-
- defaultConfig: {
- injectIntoThis: true,
- injectInto: null,
- properties: ["spy", "stub", "mock", "clock", "server", "requests"],
- useFakeTimers: true,
- useFakeServer: true
- },
-
- timesInWords: function timesInWords(count) {
- return count == 1 && "once" ||
- count == 2 && "twice" ||
- count == 3 && "thrice" ||
- (count || 0) + " times";
- },
-
- calledInOrder: function (spies) {
- for (var i = 1, l = spies.length; i < l; i++) {
- if (!spies[i - 1].calledBefore(spies[i]) || !spies[i].called) {
- return false;
- }
- }
-
- return true;
- },
-
- orderByFirstCall: function (spies) {
- return spies.sort(function (a, b) {
- // uuid, won't ever be equal
- var aCall = a.getCall(0);
- var bCall = b.getCall(0);
- var aId = aCall && aCall.callId || -1;
- var bId = bCall && bCall.callId || -1;
-
- return aId < bId ? -1 : 1;
- });
- },
-
- log: function () {},
-
- logError: function (label, err) {
- var msg = label + " threw exception: "
- sinon.log(msg + "[" + err.name + "] " + err.message);
- if (err.stack) { sinon.log(err.stack); }
-
- setTimeout(function () {
- err.message = msg + err.message;
- throw err;
- }, 0);
- },
-
- typeOf: function (value) {
- if (value === null) {
- return "null";
- }
- else if (value === undefined) {
- return "undefined";
- }
- var string = Object.prototype.toString.call(value);
- return string.substring(8, string.length - 1).toLowerCase();
- },
-
- createStubInstance: function (constructor) {
- if (typeof constructor !== "function") {
- throw new TypeError("The constructor should be a function.");
- }
- return sinon.stub(sinon.create(constructor.prototype));
- },
-
- restore: function (object) {
- if (object !== null && typeof object === "object") {
- for (var prop in object) {
- if (isRestorable(object[prop])) {
- object[prop].restore();
- }
- }
- }
- else if (isRestorable(object)) {
- object.restore();
- }
- }
- };
-
- var isNode = typeof module == "object" && typeof require == "function";
-
- if (isNode) {
- try {
- buster = { format: require("buster-format") };
- } catch (e) {}
- module.exports = sinon;
- module.exports.spy = require("./sinon/spy");
- module.exports.stub = require("./sinon/stub");
- module.exports.mock = require("./sinon/mock");
- module.exports.collection = require("./sinon/collection");
- module.exports.assert = require("./sinon/assert");
- module.exports.sandbox = require("./sinon/sandbox");
- module.exports.test = require("./sinon/test");
- module.exports.testCase = require("./sinon/test_case");
- module.exports.assert = require("./sinon/assert");
- module.exports.match = require("./sinon/match");
- }
-
- if (buster) {
- var formatter = sinon.create(buster.format);
- formatter.quoteStrings = false;
- sinon.format = function () {
- return formatter.ascii.apply(formatter, arguments);
- };
- } else if (isNode) {
- try {
- var util = require("util");
- sinon.format = function (value) {
- return typeof value == "object" && value.toString === Object.prototype.toString ? util.inspect(value) : value;
- };
- } catch (e) {
- /* Node, but no util module - would be very old, but better safe than
- sorry */
- }
- }
-
- return sinon;
-}(typeof buster == "object" && buster));
-
-/* @depend ../sinon.js */
-/*jslint eqeqeq: false, onevar: false, plusplus: false*/
-/*global module, require, sinon*/
-/**
- * Match functions
- *
- * @author Maximilian Antoni (mail@maxantoni.de)
- * @license BSD
- *
- * Copyright (c) 2012 Maximilian Antoni
- */
-
-(function (sinon) {
- var commonJSModule = typeof module == "object" && typeof require == "function";
-
- if (!sinon && commonJSModule) {
- sinon = require("../sinon");
- }
-
- if (!sinon) {
- return;
- }
-
- function assertType(value, type, name) {
- var actual = sinon.typeOf(value);
- if (actual !== type) {
- throw new TypeError("Expected type of " + name + " to be " +
- type + ", but was " + actual);
- }
- }
-
- var matcher = {
- toString: function () {
- return this.message;
- }
- };
-
- function isMatcher(object) {
- return matcher.isPrototypeOf(object);
- }
-
- function matchObject(expectation, actual) {
- if (actual === null || actual === undefined) {
- return false;
- }
- for (var key in expectation) {
- if (expectation.hasOwnProperty(key)) {
- var exp = expectation[key];
- var act = actual[key];
- if (match.isMatcher(exp)) {
- if (!exp.test(act)) {
- return false;
- }
- } else if (sinon.typeOf(exp) === "object") {
- if (!matchObject(exp, act)) {
- return false;
- }
- } else if (!sinon.deepEqual(exp, act)) {
- return false;
- }
- }
- }
- return true;
- }
-
- matcher.or = function (m2) {
- if (!isMatcher(m2)) {
- throw new TypeError("Matcher expected");
- }
- var m1 = this;
- var or = sinon.create(matcher);
- or.test = function (actual) {
- return m1.test(actual) || m2.test(actual);
- };
- or.message = m1.message + ".or(" + m2.message + ")";
- return or;
- };
-
- matcher.and = function (m2) {
- if (!isMatcher(m2)) {
- throw new TypeError("Matcher expected");
- }
- var m1 = this;
- var and = sinon.create(matcher);
- and.test = function (actual) {
- return m1.test(actual) && m2.test(actual);
- };
- and.message = m1.message + ".and(" + m2.message + ")";
- return and;
- };
-
- var match = function (expectation, message) {
- var m = sinon.create(matcher);
- var type = sinon.typeOf(expectation);
- switch (type) {
- case "object":
- if (typeof expectation.test === "function") {
- m.test = function (actual) {
- return expectation.test(actual) === true;
- };
- m.message = "match(" + sinon.functionName(expectation.test) + ")";
- return m;
- }
- var str = [];
- for (var key in expectation) {
- if (expectation.hasOwnProperty(key)) {
- str.push(key + ": " + expectation[key]);
- }
- }
- m.test = function (actual) {
- return matchObject(expectation, actual);
- };
- m.message = "match(" + str.join(", ") + ")";
- break;
- case "number":
- m.test = function (actual) {
- return expectation == actual;
- };
- break;
- case "string":
- m.test = function (actual) {
- if (typeof actual !== "string") {
- return false;
- }
- return actual.indexOf(expectation) !== -1;
- };
- m.message = "match(\"" + expectation + "\")";
- break;
- case "regexp":
- m.test = function (actual) {
- if (typeof actual !== "string") {
- return false;
- }
- return expectation.test(actual);
- };
- break;
- case "function":
- m.test = expectation;
- if (message) {
- m.message = message;
- } else {
- m.message = "match(" + sinon.functionName(expectation) + ")";
- }
- break;
- default:
- m.test = function (actual) {
- return sinon.deepEqual(expectation, actual);
- };
- }
- if (!m.message) {
- m.message = "match(" + expectation + ")";
- }
- return m;
- };
-
- match.isMatcher = isMatcher;
-
- match.any = match(function () {
- return true;
- }, "any");
-
- match.defined = match(function (actual) {
- return actual !== null && actual !== undefined;
- }, "defined");
-
- match.truthy = match(function (actual) {
- return !!actual;
- }, "truthy");
-
- match.falsy = match(function (actual) {
- return !actual;
- }, "falsy");
-
- match.same = function (expectation) {
- return match(function (actual) {
- return expectation === actual;
- }, "same(" + expectation + ")");
- };
-
- match.typeOf = function (type) {
- assertType(type, "string", "type");
- return match(function (actual) {
- return sinon.typeOf(actual) === type;
- }, "typeOf(\"" + type + "\")");
- };
-
- match.instanceOf = function (type) {
- assertType(type, "function", "type");
- return match(function (actual) {
- return actual instanceof type;
- }, "instanceOf(" + sinon.functionName(type) + ")");
- };
-
- function createPropertyMatcher(propertyTest, messagePrefix) {
- return function (property, value) {
- assertType(property, "string", "property");
- var onlyProperty = arguments.length === 1;
- var message = messagePrefix + "(\"" + property + "\"";
- if (!onlyProperty) {
- message += ", " + value;
- }
- message += ")";
- return match(function (actual) {
- if (actual === undefined || actual === null ||
- !propertyTest(actual, property)) {
- return false;
- }
- return onlyProperty || sinon.deepEqual(value, actual[property]);
- }, message);
- };
- }
-
- match.has = createPropertyMatcher(function (actual, property) {
- if (typeof actual === "object") {
- return property in actual;
- }
- return actual[property] !== undefined;
- }, "has");
-
- match.hasOwn = createPropertyMatcher(function (actual, property) {
- return actual.hasOwnProperty(property);
- }, "hasOwn");
-
- match.bool = match.typeOf("boolean");
- match.number = match.typeOf("number");
- match.string = match.typeOf("string");
- match.object = match.typeOf("object");
- match.func = match.typeOf("function");
- match.array = match.typeOf("array");
- match.regexp = match.typeOf("regexp");
- match.date = match.typeOf("date");
-
- if (commonJSModule) {
- module.exports = match;
- } else {
- sinon.match = match;
- }
-}(typeof sinon == "object" && sinon || null));
-
-/**
- * @depend ../sinon.js
- * @depend match.js
- */
-/*jslint eqeqeq: false, onevar: false, plusplus: false*/
-/*global module, require, sinon*/
-/**
- * Spy calls
- *
- * @author Christian Johansen (christian@cjohansen.no)
- * @author Maximilian Antoni (mail@maxantoni.de)
- * @license BSD
- *
- * Copyright (c) 2010-2013 Christian Johansen
- * Copyright (c) 2013 Maximilian Antoni
- */
-
-var commonJSModule = typeof module == "object" && typeof require == "function";
-
-if (!this.sinon && commonJSModule) {
- var sinon = require("../sinon");
-}
-
-(function (sinon) {
- function throwYieldError(proxy, text, args) {
- var msg = sinon.functionName(proxy) + text;
- if (args.length) {
- msg += " Received [" + slice.call(args).join(", ") + "]";
- }
- throw new Error(msg);
- }
-
- var slice = Array.prototype.slice;
-
- var callProto = {
- calledOn: function calledOn(thisValue) {
- if (sinon.match && sinon.match.isMatcher(thisValue)) {
- return thisValue.test(this.thisValue);
- }
- return this.thisValue === thisValue;
- },
-
- calledWith: function calledWith() {
- for (var i = 0, l = arguments.length; i < l; i += 1) {
- if (!sinon.deepEqual(arguments[i], this.args[i])) {
- return false;
- }
- }
-
- return true;
- },
-
- calledWithMatch: function calledWithMatch() {
- for (var i = 0, l = arguments.length; i < l; i += 1) {
- var actual = this.args[i];
- var expectation = arguments[i];
- if (!sinon.match || !sinon.match(expectation).test(actual)) {
- return false;
- }
- }
- return true;
- },
-
- calledWithExactly: function calledWithExactly() {
- return arguments.length == this.args.length &&
- this.calledWith.apply(this, arguments);
- },
-
- notCalledWith: function notCalledWith() {
- return !this.calledWith.apply(this, arguments);
- },
-
- notCalledWithMatch: function notCalledWithMatch() {
- return !this.calledWithMatch.apply(this, arguments);
- },
-
- returned: function returned(value) {
- return sinon.deepEqual(value, this.returnValue);
- },
-
- threw: function threw(error) {
- if (typeof error === "undefined" || !this.exception) {
- return !!this.exception;
- }
-
- return this.exception === error || this.exception.name === error;
- },
-
- calledWithNew: function calledWithNew(thisValue) {
- return this.thisValue instanceof this.proxy;
- },
-
- calledBefore: function (other) {
- return this.callId < other.callId;
- },
-
- calledAfter: function (other) {
- return this.callId > other.callId;
- },
-
- callArg: function (pos) {
- this.args[pos]();
- },
-
- callArgOn: function (pos, thisValue) {
- this.args[pos].apply(thisValue);
- },
-
- callArgWith: function (pos) {
- this.callArgOnWith.apply(this, [pos, null].concat(slice.call(arguments, 1)));
- },
-
- callArgOnWith: function (pos, thisValue) {
- var args = slice.call(arguments, 2);
- this.args[pos].apply(thisValue, args);
- },
-
- "yield": function () {
- this.yieldOn.apply(this, [null].concat(slice.call(arguments, 0)));
- },
-
- yieldOn: function (thisValue) {
- var args = this.args;
- for (var i = 0, l = args.length; i < l; ++i) {
- if (typeof args[i] === "function") {
- args[i].apply(thisValue, slice.call(arguments, 1));
- return;
- }
- }
- throwYieldError(this.proxy, " cannot yield since no callback was passed.", args);
- },
-
- yieldTo: function (prop) {
- this.yieldToOn.apply(this, [prop, null].concat(slice.call(arguments, 1)));
- },
-
- yieldToOn: function (prop, thisValue) {
- var args = this.args;
- for (var i = 0, l = args.length; i < l; ++i) {
- if (args[i] && typeof args[i][prop] === "function") {
- args[i][prop].apply(thisValue, slice.call(arguments, 2));
- return;
- }
- }
- throwYieldError(this.proxy, " cannot yield to '" + prop +
- "' since no callback was passed.", args);
- },
-
- toString: function () {
- var callStr = this.proxy.toString() + "(";
- var args = [];
-
- for (var i = 0, l = this.args.length; i < l; ++i) {
- args.push(sinon.format(this.args[i]));
- }
-
- callStr = callStr + args.join(", ") + ")";
-
- if (typeof this.returnValue != "undefined") {
- callStr += " => " + sinon.format(this.returnValue);
- }
-
- if (this.exception) {
- callStr += " !" + this.exception.name;
-
- if (this.exception.message) {
- callStr += "(" + this.exception.message + ")";
- }
- }
-
- return callStr;
- }
- };
-
- callProto.invokeCallback = callProto.yield;
-
- function createSpyCall(spy, thisValue, args, returnValue, exception, id) {
- if (typeof id !== "number") {
- throw new TypeError("Call id is not a number");
- }
- var proxyCall = sinon.create(callProto);
- proxyCall.proxy = spy;
- proxyCall.thisValue = thisValue;
- proxyCall.args = args;
- proxyCall.returnValue = returnValue;
- proxyCall.exception = exception;
- proxyCall.callId = id;
-
- return proxyCall;
- };
- createSpyCall.toString = callProto.toString; // used by mocks
-
- sinon.spyCall = createSpyCall;
-}(typeof sinon == "object" && sinon || null));
-
-/**
- * @depend ../sinon.js
- */
-/*jslint eqeqeq: false, onevar: false, plusplus: false*/
-/*global module, require, sinon*/
-/**
- * Spy functions
- *
- * @author Christian Johansen (christian@cjohansen.no)
- * @license BSD
- *
- * Copyright (c) 2010-2013 Christian Johansen
- */
-
-(function (sinon) {
- var commonJSModule = typeof module == "object" && typeof require == "function";
- var push = Array.prototype.push;
- var slice = Array.prototype.slice;
- var callId = 0;
-
- function spy(object, property) {
- if (!property && typeof object == "function") {
- return spy.create(object);
- }
-
- if (!object && !property) {
- return spy.create(function () { });
- }
-
- var method = object[property];
- return sinon.wrapMethod(object, property, spy.create(method));
- }
-
- function matchingFake(fakes, args, strict) {
- if (!fakes) {
- return;
- }
-
- var alen = args.length;
-
- for (var i = 0, l = fakes.length; i < l; i++) {
- if (fakes[i].matches(args, strict)) {
- return fakes[i];
- }
- }
- }
-
- function incrementCallCount() {
- this.called = true;
- this.callCount += 1;
- this.notCalled = false;
- this.calledOnce = this.callCount == 1;
- this.calledTwice = this.callCount == 2;
- this.calledThrice = this.callCount == 3;
- }
-
- function createCallProperties() {
- this.firstCall = this.getCall(0);
- this.secondCall = this.getCall(1);
- this.thirdCall = this.getCall(2);
- this.lastCall = this.getCall(this.callCount - 1);
- }
-
- var vars = "a,b,c,d,e,f,g,h,i,j,k,l";
- function createProxy(func) {
- // Retain the function length:
- var p;
- if (func.length) {
- eval("p = (function proxy(" + vars.substring(0, func.length * 2 - 1) +
- ") { return p.invoke(func, this, slice.call(arguments)); });");
- }
- else {
- p = function proxy() {
- return p.invoke(func, this, slice.call(arguments));
- };
- }
- return p;
- }
-
- var uuid = 0;
-
- // Public API
- var spyApi = {
- reset: function () {
- this.called = false;
- this.notCalled = true;
- this.calledOnce = false;
- this.calledTwice = false;
- this.calledThrice = false;
- this.callCount = 0;
- this.firstCall = null;
- this.secondCall = null;
- this.thirdCall = null;
- this.lastCall = null;
- this.args = [];
- this.returnValues = [];
- this.thisValues = [];
- this.exceptions = [];
- this.callIds = [];
- if (this.fakes) {
- for (var i = 0; i < this.fakes.length; i++) {
- this.fakes[i].reset();
- }
- }
- },
-
- create: function create(func) {
- var name;
-
- if (typeof func != "function") {
- func = function () { };
- } else {
- name = sinon.functionName(func);
- }
-
- var proxy = createProxy(func);
-
- sinon.extend(proxy, spy);
- delete proxy.create;
- sinon.extend(proxy, func);
-
- proxy.reset();
- proxy.prototype = func.prototype;
- proxy.displayName = name || "spy";
- proxy.toString = sinon.functionToString;
- proxy._create = sinon.spy.create;
- proxy.id = "spy#" + uuid++;
-
- return proxy;
- },
-
- invoke: function invoke(func, thisValue, args) {
- var matching = matchingFake(this.fakes, args);
- var exception, returnValue;
-
- incrementCallCount.call(this);
- push.call(this.thisValues, thisValue);
- push.call(this.args, args);
- push.call(this.callIds, callId++);
-
- try {
- if (matching) {
- returnValue = matching.invoke(func, thisValue, args);
- } else {
- returnValue = (this.func || func).apply(thisValue, args);
- }
- } catch (e) {
- push.call(this.returnValues, undefined);
- exception = e;
- throw e;
- } finally {
- push.call(this.exceptions, exception);
- }
-
- push.call(this.returnValues, returnValue);
-
- createCallProperties.call(this);
-
- return returnValue;
- },
-
- getCall: function getCall(i) {
- if (i < 0 || i >= this.callCount) {
- return null;
- }
-
- return sinon.spyCall(this, this.thisValues[i], this.args[i],
- this.returnValues[i], this.exceptions[i],
- this.callIds[i]);
- },
-
- calledBefore: function calledBefore(spyFn) {
- if (!this.called) {
- return false;
- }
-
- if (!spyFn.called) {
- return true;
- }
-
- return this.callIds[0] < spyFn.callIds[spyFn.callIds.length - 1];
- },
-
- calledAfter: function calledAfter(spyFn) {
- if (!this.called || !spyFn.called) {
- return false;
- }
-
- return this.callIds[this.callCount - 1] > spyFn.callIds[spyFn.callCount - 1];
- },
-
- withArgs: function () {
- var args = slice.call(arguments);
-
- if (this.fakes) {
- var match = matchingFake(this.fakes, args, true);
-
- if (match) {
- return match;
- }
- } else {
- this.fakes = [];
- }
-
- var original = this;
- var fake = this._create();
- fake.matchingAguments = args;
- push.call(this.fakes, fake);
-
- fake.withArgs = function () {
- return original.withArgs.apply(original, arguments);
- };
-
- for (var i = 0; i < this.args.length; i++) {
- if (fake.matches(this.args[i])) {
- incrementCallCount.call(fake);
- push.call(fake.thisValues, this.thisValues[i]);
- push.call(fake.args, this.args[i]);
- push.call(fake.returnValues, this.returnValues[i]);
- push.call(fake.exceptions, this.exceptions[i]);
- push.call(fake.callIds, this.callIds[i]);
- }
- }
- createCallProperties.call(fake);
-
- return fake;
- },
-
- matches: function (args, strict) {
- var margs = this.matchingAguments;
-
- if (margs.length <= args.length &&
- sinon.deepEqual(margs, args.slice(0, margs.length))) {
- return !strict || margs.length == args.length;
- }
- },
-
- printf: function (format) {
- var spy = this;
- var args = slice.call(arguments, 1);
- var formatter;
-
- return (format || "").replace(/%(.)/g, function (match, specifyer) {
- formatter = spyApi.formatters[specifyer];
-
- if (typeof formatter == "function") {
- return formatter.call(null, spy, args);
- } else if (!isNaN(parseInt(specifyer), 10)) {
- return sinon.format(args[specifyer - 1]);
- }
-
- return "%" + specifyer;
- });
- }
- };
-
- function delegateToCalls(method, matchAny, actual, notCalled) {
- spyApi[method] = function () {
- if (!this.called) {
- if (notCalled) {
- return notCalled.apply(this, arguments);
- }
- return false;
- }
-
- var currentCall;
- var matches = 0;
-
- for (var i = 0, l = this.callCount; i < l; i += 1) {
- currentCall = this.getCall(i);
-
- if (currentCall[actual || method].apply(currentCall, arguments)) {
- matches += 1;
-
- if (matchAny) {
- return true;
- }
- }
- }
-
- return matches === this.callCount;
- };
- }
-
- delegateToCalls("calledOn", true);
- delegateToCalls("alwaysCalledOn", false, "calledOn");
- delegateToCalls("calledWith", true);
- delegateToCalls("calledWithMatch", true);
- delegateToCalls("alwaysCalledWith", false, "calledWith");
- delegateToCalls("alwaysCalledWithMatch", false, "calledWithMatch");
- delegateToCalls("calledWithExactly", true);
- delegateToCalls("alwaysCalledWithExactly", false, "calledWithExactly");
- delegateToCalls("neverCalledWith", false, "notCalledWith",
- function () { return true; });
- delegateToCalls("neverCalledWithMatch", false, "notCalledWithMatch",
- function () { return true; });
- delegateToCalls("threw", true);
- delegateToCalls("alwaysThrew", false, "threw");
- delegateToCalls("returned", true);
- delegateToCalls("alwaysReturned", false, "returned");
- delegateToCalls("calledWithNew", true);
- delegateToCalls("alwaysCalledWithNew", false, "calledWithNew");
- delegateToCalls("callArg", false, "callArgWith", function () {
- throw new Error(this.toString() + " cannot call arg since it was not yet invoked.");
- });
- spyApi.callArgWith = spyApi.callArg;
- delegateToCalls("callArgOn", false, "callArgOnWith", function () {
- throw new Error(this.toString() + " cannot call arg since it was not yet invoked.");
- });
- spyApi.callArgOnWith = spyApi.callArgOn;
- delegateToCalls("yield", false, "yield", function () {
- throw new Error(this.toString() + " cannot yield since it was not yet invoked.");
- });
- // "invokeCallback" is an alias for "yield" since "yield" is invalid in strict mode.
- spyApi.invokeCallback = spyApi.yield;
- delegateToCalls("yieldOn", false, "yieldOn", function () {
- throw new Error(this.toString() + " cannot yield since it was not yet invoked.");
- });
- delegateToCalls("yieldTo", false, "yieldTo", function (property) {
- throw new Error(this.toString() + " cannot yield to '" + property +
- "' since it was not yet invoked.");
- });
- delegateToCalls("yieldToOn", false, "yieldToOn", function (property) {
- throw new Error(this.toString() + " cannot yield to '" + property +
- "' since it was not yet invoked.");
- });
-
- spyApi.formatters = {
- "c": function (spy) {
- return sinon.timesInWords(spy.callCount);
- },
-
- "n": function (spy) {
- return spy.toString();
- },
-
- "C": function (spy) {
- var calls = [];
-
- for (var i = 0, l = spy.callCount; i < l; ++i) {
- var stringifiedCall = " " + spy.getCall(i).toString();
- if (/\n/.test(calls[i - 1])) {
- stringifiedCall = "\n" + stringifiedCall;
- }
- push.call(calls, stringifiedCall);
- }
-
- return calls.length > 0 ? "\n" + calls.join("\n") : "";
- },
-
- "t": function (spy) {
- var objects = [];
-
- for (var i = 0, l = spy.callCount; i < l; ++i) {
- push.call(objects, sinon.format(spy.thisValues[i]));
- }
-
- return objects.join(", ");
- },
-
- "*": function (spy, args) {
- var formatted = [];
-
- for (var i = 0, l = args.length; i < l; ++i) {
- push.call(formatted, sinon.format(args[i]));
- }
-
- return formatted.join(", ");
- }
- };
-
- sinon.extend(spy, spyApi);
-
- spy.spyCall = sinon.spyCall;
-
- if (commonJSModule) {
- module.exports = spy;
- } else {
- sinon.spy = spy;
- }
-}(typeof sinon == "object" && sinon || null));
-
-/**
- * @depend ../sinon.js
- * @depend spy.js
- */
-/*jslint eqeqeq: false, onevar: false*/
-/*global module, require, sinon*/
-/**
- * Stub functions
- *
- * @author Christian Johansen (christian@cjohansen.no)
- * @license BSD
- *
- * Copyright (c) 2010-2013 Christian Johansen
- */
-
-(function (sinon) {
- var commonJSModule = typeof module == "object" && typeof require == "function";
-
- if (!sinon && commonJSModule) {
- sinon = require("../sinon");
- }
-
- if (!sinon) {
- return;
- }
-
- function stub(object, property, func) {
- if (!!func && typeof func != "function") {
- throw new TypeError("Custom stub should be function");
- }
-
- var wrapper;
-
- if (func) {
- wrapper = sinon.spy && sinon.spy.create ? sinon.spy.create(func) : func;
- } else {
- wrapper = stub.create();
- }
-
- if (!object && !property) {
- return sinon.stub.create();
- }
-
- if (!property && !!object && typeof object == "object") {
- for (var prop in object) {
- if (typeof object[prop] === "function") {
- stub(object, prop);
- }
- }
-
- return object;
- }
-
- return sinon.wrapMethod(object, property, wrapper);
- }
-
- function getChangingValue(stub, property) {
- var index = stub.callCount - 1;
- var values = stub[property];
- var prop = index in values ? values[index] : values[values.length - 1];
- stub[property + "Last"] = prop;
-
- return prop;
- }
-
- function getCallback(stub, args) {
- var callArgAt = getChangingValue(stub, "callArgAts");
-
- if (callArgAt < 0) {
- var callArgProp = getChangingValue(stub, "callArgProps");
-
- for (var i = 0, l = args.length; i < l; ++i) {
- if (!callArgProp && typeof args[i] == "function") {
- return args[i];
- }
-
- if (callArgProp && args[i] &&
- typeof args[i][callArgProp] == "function") {
- return args[i][callArgProp];
- }
- }
-
- return null;
- }
-
- return args[callArgAt];
- }
-
- var join = Array.prototype.join;
-
- function getCallbackError(stub, func, args) {
- if (stub.callArgAtsLast < 0) {
- var msg;
-
- if (stub.callArgPropsLast) {
- msg = sinon.functionName(stub) +
- " expected to yield to '" + stub.callArgPropsLast +
- "', but no object with such a property was passed."
- } else {
- msg = sinon.functionName(stub) +
- " expected to yield, but no callback was passed."
- }
-
- if (args.length > 0) {
- msg += " Received [" + join.call(args, ", ") + "]";
- }
-
- return msg;
- }
-
- return "argument at index " + stub.callArgAtsLast + " is not a function: " + func;
- }
-
- var nextTick = (function () {
- if (typeof process === "object" && typeof process.nextTick === "function") {
- return process.nextTick;
- } else if (typeof setImmediate === "function") {
- return setImmediate;
- } else {
- return function (callback) {
- setTimeout(callback, 0);
- };
- }
- })();
-
- function callCallback(stub, args) {
- if (stub.callArgAts.length > 0) {
- var func = getCallback(stub, args);
-
- if (typeof func != "function") {
- throw new TypeError(getCallbackError(stub, func, args));
- }
-
- var callbackArguments = getChangingValue(stub, "callbackArguments");
- var callbackContext = getChangingValue(stub, "callbackContexts");
-
- if (stub.callbackAsync) {
- nextTick(function() {
- func.apply(callbackContext, callbackArguments);
- });
- } else {
- func.apply(callbackContext, callbackArguments);
- }
- }
- }
-
- var uuid = 0;
-
- sinon.extend(stub, (function () {
- var slice = Array.prototype.slice, proto;
-
- function throwsException(error, message) {
- if (typeof error == "string") {
- this.exception = new Error(message || "");
- this.exception.name = error;
- } else if (!error) {
- this.exception = new Error("Error");
- } else {
- this.exception = error;
- }
-
- return this;
- }
-
- proto = {
- create: function create() {
- var functionStub = function () {
-
- callCallback(functionStub, arguments);
-
- if (functionStub.exception) {
- throw functionStub.exception;
- } else if (typeof functionStub.returnArgAt == 'number') {
- return arguments[functionStub.returnArgAt];
- } else if (functionStub.returnThis) {
- return this;
- }
- return functionStub.returnValue;
- };
-
- functionStub.id = "stub#" + uuid++;
- var orig = functionStub;
- functionStub = sinon.spy.create(functionStub);
- functionStub.func = orig;
-
- functionStub.callArgAts = [];
- functionStub.callbackArguments = [];
- functionStub.callbackContexts = [];
- functionStub.callArgProps = [];
-
- sinon.extend(functionStub, stub);
- functionStub._create = sinon.stub.create;
- functionStub.displayName = "stub";
- functionStub.toString = sinon.functionToString;
-
- return functionStub;
- },
-
- resetBehavior: function () {
- var i;
-
- this.callArgAts = [];
- this.callbackArguments = [];
- this.callbackContexts = [];
- this.callArgProps = [];
-
- delete this.returnValue;
- delete this.returnArgAt;
- this.returnThis = false;
-
- if (this.fakes) {
- for (i = 0; i < this.fakes.length; i++) {
- this.fakes[i].resetBehavior();
- }
- }
- },
-
- returns: function returns(value) {
- this.returnValue = value;
-
- return this;
- },
-
- returnsArg: function returnsArg(pos) {
- if (typeof pos != "number") {
- throw new TypeError("argument index is not number");
- }
-
- this.returnArgAt = pos;
-
- return this;
- },
-
- returnsThis: function returnsThis() {
- this.returnThis = true;
-
- return this;
- },
-
- "throws": throwsException,
- throwsException: throwsException,
-
- callsArg: function callsArg(pos) {
- if (typeof pos != "number") {
- throw new TypeError("argument index is not number");
- }
-
- this.callArgAts.push(pos);
- this.callbackArguments.push([]);
- this.callbackContexts.push(undefined);
- this.callArgProps.push(undefined);
-
- return this;
- },
-
- callsArgOn: function callsArgOn(pos, context) {
- if (typeof pos != "number") {
- throw new TypeError("argument index is not number");
- }
- if (typeof context != "object") {
- throw new TypeError("argument context is not an object");
- }
-
- this.callArgAts.push(pos);
- this.callbackArguments.push([]);
- this.callbackContexts.push(context);
- this.callArgProps.push(undefined);
-
- return this;
- },
-
- callsArgWith: function callsArgWith(pos) {
- if (typeof pos != "number") {
- throw new TypeError("argument index is not number");
- }
-
- this.callArgAts.push(pos);
- this.callbackArguments.push(slice.call(arguments, 1));
- this.callbackContexts.push(undefined);
- this.callArgProps.push(undefined);
-
- return this;
- },
-
- callsArgOnWith: function callsArgWith(pos, context) {
- if (typeof pos != "number") {
- throw new TypeError("argument index is not number");
- }
- if (typeof context != "object") {
- throw new TypeError("argument context is not an object");
- }
-
- this.callArgAts.push(pos);
- this.callbackArguments.push(slice.call(arguments, 2));
- this.callbackContexts.push(context);
- this.callArgProps.push(undefined);
-
- return this;
- },
-
- yields: function () {
- this.callArgAts.push(-1);
- this.callbackArguments.push(slice.call(arguments, 0));
- this.callbackContexts.push(undefined);
- this.callArgProps.push(undefined);
-
- return this;
- },
-
- yieldsOn: function (context) {
- if (typeof context != "object") {
- throw new TypeError("argument context is not an object");
- }
-
- this.callArgAts.push(-1);
- this.callbackArguments.push(slice.call(arguments, 1));
- this.callbackContexts.push(context);
- this.callArgProps.push(undefined);
-
- return this;
- },
-
- yieldsTo: function (prop) {
- this.callArgAts.push(-1);
- this.callbackArguments.push(slice.call(arguments, 1));
- this.callbackContexts.push(undefined);
- this.callArgProps.push(prop);
-
- return this;
- },
-
- yieldsToOn: function (prop, context) {
- if (typeof context != "object") {
- throw new TypeError("argument context is not an object");
- }
-
- this.callArgAts.push(-1);
- this.callbackArguments.push(slice.call(arguments, 2));
- this.callbackContexts.push(context);
- this.callArgProps.push(prop);
-
- return this;
- }
- };
-
- // create asynchronous versions of callsArg* and yields* methods
- for (var method in proto) {
- // need to avoid creating anotherasync versions of the newly added async methods
- if (proto.hasOwnProperty(method) &&
- method.match(/^(callsArg|yields|thenYields$)/) &&
- !method.match(/Async/)) {
- proto[method + 'Async'] = (function (syncFnName) {
- return function () {
- this.callbackAsync = true;
- return this[syncFnName].apply(this, arguments);
- };
- })(method);
- }
- }
-
- return proto;
-
- }()));
-
- if (commonJSModule) {
- module.exports = stub;
- } else {
- sinon.stub = stub;
- }
-}(typeof sinon == "object" && sinon || null));
-
-/**
- * @depend ../sinon.js
- * @depend stub.js
- */
-/*jslint eqeqeq: false, onevar: false, nomen: false*/
-/*global module, require, sinon*/
-/**
- * Mock functions.
- *
- * @author Christian Johansen (christian@cjohansen.no)
- * @license BSD
- *
- * Copyright (c) 2010-2013 Christian Johansen
- */
-
-(function (sinon) {
- var commonJSModule = typeof module == "object" && typeof require == "function";
- var push = [].push;
-
- if (!sinon && commonJSModule) {
- sinon = require("../sinon");
- }
-
- if (!sinon) {
- return;
- }
-
- function mock(object) {
- if (!object) {
- return sinon.expectation.create("Anonymous mock");
- }
-
- return mock.create(object);
- }
-
- sinon.mock = mock;
-
- sinon.extend(mock, (function () {
- function each(collection, callback) {
- if (!collection) {
- return;
- }
-
- for (var i = 0, l = collection.length; i < l; i += 1) {
- callback(collection[i]);
- }
- }
-
- return {
- create: function create(object) {
- if (!object) {
- throw new TypeError("object is null");
- }
-
- var mockObject = sinon.extend({}, mock);
- mockObject.object = object;
- delete mockObject.create;
-
- return mockObject;
- },
-
- expects: function expects(method) {
- if (!method) {
- throw new TypeError("method is falsy");
- }
-
- if (!this.expectations) {
- this.expectations = {};
- this.proxies = [];
- }
-
- if (!this.expectations[method]) {
- this.expectations[method] = [];
- var mockObject = this;
-
- sinon.wrapMethod(this.object, method, function () {
- return mockObject.invokeMethod(method, this, arguments);
- });
-
- push.call(this.proxies, method);
- }
-
- var expectation = sinon.expectation.create(method);
- push.call(this.expectations[method], expectation);
-
- return expectation;
- },
-
- restore: function restore() {
- var object = this.object;
-
- each(this.proxies, function (proxy) {
- if (typeof object[proxy].restore == "function") {
- object[proxy].restore();
- }
- });
- },
-
- verify: function verify() {
- var expectations = this.expectations || {};
- var messages = [], met = [];
-
- each(this.proxies, function (proxy) {
- each(expectations[proxy], function (expectation) {
- if (!expectation.met()) {
- push.call(messages, expectation.toString());
- } else {
- push.call(met, expectation.toString());
- }
- });
- });
-
- this.restore();
-
- if (messages.length > 0) {
- sinon.expectation.fail(messages.concat(met).join("\n"));
- } else {
- sinon.expectation.pass(messages.concat(met).join("\n"));
- }
-
- return true;
- },
-
- invokeMethod: function invokeMethod(method, thisValue, args) {
- var expectations = this.expectations && this.expectations[method];
- var length = expectations && expectations.length || 0, i;
-
- for (i = 0; i < length; i += 1) {
- if (!expectations[i].met() &&
- expectations[i].allowsCall(thisValue, args)) {
- return expectations[i].apply(thisValue, args);
- }
- }
-
- var messages = [], available, exhausted = 0;
-
- for (i = 0; i < length; i += 1) {
- if (expectations[i].allowsCall(thisValue, args)) {
- available = available || expectations[i];
- } else {
- exhausted += 1;
- }
- push.call(messages, " " + expectations[i].toString());
- }
-
- if (exhausted === 0) {
- return available.apply(thisValue, args);
- }
-
- messages.unshift("Unexpected call: " + sinon.spyCall.toString.call({
- proxy: method,
- args: args
- }));
-
- sinon.expectation.fail(messages.join("\n"));
- }
- };
- }()));
-
- var times = sinon.timesInWords;
-
- sinon.expectation = (function () {
- var slice = Array.prototype.slice;
- var _invoke = sinon.spy.invoke;
-
- function callCountInWords(callCount) {
- if (callCount == 0) {
- return "never called";
- } else {
- return "called " + times(callCount);
- }
- }
-
- function expectedCallCountInWords(expectation) {
- var min = expectation.minCalls;
- var max = expectation.maxCalls;
-
- if (typeof min == "number" && typeof max == "number") {
- var str = times(min);
-
- if (min != max) {
- str = "at least " + str + " and at most " + times(max);
- }
-
- return str;
- }
-
- if (typeof min == "number") {
- return "at least " + times(min);
- }
-
- return "at most " + times(max);
- }
-
- function receivedMinCalls(expectation) {
- var hasMinLimit = typeof expectation.minCalls == "number";
- return !hasMinLimit || expectation.callCount >= expectation.minCalls;
- }
-
- function receivedMaxCalls(expectation) {
- if (typeof expectation.maxCalls != "number") {
- return false;
- }
-
- return expectation.callCount == expectation.maxCalls;
- }
-
- return {
- minCalls: 1,
- maxCalls: 1,
-
- create: function create(methodName) {
- var expectation = sinon.extend(sinon.stub.create(), sinon.expectation);
- delete expectation.create;
- expectation.method = methodName;
-
- return expectation;
- },
-
- invoke: function invoke(func, thisValue, args) {
- this.verifyCallAllowed(thisValue, args);
-
- return _invoke.apply(this, arguments);
- },
-
- atLeast: function atLeast(num) {
- if (typeof num != "number") {
- throw new TypeError("'" + num + "' is not number");
- }
-
- if (!this.limitsSet) {
- this.maxCalls = null;
- this.limitsSet = true;
- }
-
- this.minCalls = num;
-
- return this;
- },
-
- atMost: function atMost(num) {
- if (typeof num != "number") {
- throw new TypeError("'" + num + "' is not number");
- }
-
- if (!this.limitsSet) {
- this.minCalls = null;
- this.limitsSet = true;
- }
-
- this.maxCalls = num;
-
- return this;
- },
-
- never: function never() {
- return this.exactly(0);
- },
-
- once: function once() {
- return this.exactly(1);
- },
-
- twice: function twice() {
- return this.exactly(2);
- },
-
- thrice: function thrice() {
- return this.exactly(3);
- },
-
- exactly: function exactly(num) {
- if (typeof num != "number") {
- throw new TypeError("'" + num + "' is not a number");
- }
-
- this.atLeast(num);
- return this.atMost(num);
- },
-
- met: function met() {
- return !this.failed && receivedMinCalls(this);
- },
-
- verifyCallAllowed: function verifyCallAllowed(thisValue, args) {
- if (receivedMaxCalls(this)) {
- this.failed = true;
- sinon.expectation.fail(this.method + " already called " + times(this.maxCalls));
- }
-
- if ("expectedThis" in this && this.expectedThis !== thisValue) {
- sinon.expectation.fail(this.method + " called with " + thisValue + " as thisValue, expected " +
- this.expectedThis);
- }
-
- if (!("expectedArguments" in this)) {
- return;
- }
-
- if (!args) {
- sinon.expectation.fail(this.method + " received no arguments, expected " +
- sinon.format(this.expectedArguments));
- }
-
- if (args.length < this.expectedArguments.length) {
- sinon.expectation.fail(this.method + " received too few arguments (" + sinon.format(args) +
- "), expected " + sinon.format(this.expectedArguments));
- }
-
- if (this.expectsExactArgCount &&
- args.length != this.expectedArguments.length) {
- sinon.expectation.fail(this.method + " received too many arguments (" + sinon.format(args) +
- "), expected " + sinon.format(this.expectedArguments));
- }
-
- for (var i = 0, l = this.expectedArguments.length; i < l; i += 1) {
- if (!sinon.deepEqual(this.expectedArguments[i], args[i])) {
- sinon.expectation.fail(this.method + " received wrong arguments " + sinon.format(args) +
- ", expected " + sinon.format(this.expectedArguments));
- }
- }
- },
-
- allowsCall: function allowsCall(thisValue, args) {
- if (this.met() && receivedMaxCalls(this)) {
- return false;
- }
-
- if ("expectedThis" in this && this.expectedThis !== thisValue) {
- return false;
- }
-
- if (!("expectedArguments" in this)) {
- return true;
- }
-
- args = args || [];
-
- if (args.length < this.expectedArguments.length) {
- return false;
- }
-
- if (this.expectsExactArgCount &&
- args.length != this.expectedArguments.length) {
- return false;
- }
-
- for (var i = 0, l = this.expectedArguments.length; i < l; i += 1) {
- if (!sinon.deepEqual(this.expectedArguments[i], args[i])) {
- return false;
- }
- }
-
- return true;
- },
-
- withArgs: function withArgs() {
- this.expectedArguments = slice.call(arguments);
- return this;
- },
-
- withExactArgs: function withExactArgs() {
- this.withArgs.apply(this, arguments);
- this.expectsExactArgCount = true;
- return this;
- },
-
- on: function on(thisValue) {
- this.expectedThis = thisValue;
- return this;
- },
-
- toString: function () {
- var args = (this.expectedArguments || []).slice();
-
- if (!this.expectsExactArgCount) {
- push.call(args, "[...]");
- }
-
- var callStr = sinon.spyCall.toString.call({
- proxy: this.method || "anonymous mock expectation",
- args: args
- });
-
- var message = callStr.replace(", [...", "[, ...") + " " +
- expectedCallCountInWords(this);
-
- if (this.met()) {
- return "Expectation met: " + message;
- }
-
- return "Expected " + message + " (" +
- callCountInWords(this.callCount) + ")";
- },
-
- verify: function verify() {
- if (!this.met()) {
- sinon.expectation.fail(this.toString());
- } else {
- sinon.expectation.pass(this.toString());
- }
-
- return true;
- },
-
- pass: function(message) {
- sinon.assert.pass(message);
- },
- fail: function (message) {
- var exception = new Error(message);
- exception.name = "ExpectationError";
-
- throw exception;
- }
- };
- }());
-
- if (commonJSModule) {
- module.exports = mock;
- } else {
- sinon.mock = mock;
- }
-}(typeof sinon == "object" && sinon || null));
-
-/**
- * @depend ../sinon.js
- * @depend stub.js
- * @depend mock.js
- */
-/*jslint eqeqeq: false, onevar: false, forin: true*/
-/*global module, require, sinon*/
-/**
- * Collections of stubs, spies and mocks.
- *
- * @author Christian Johansen (christian@cjohansen.no)
- * @license BSD
- *
- * Copyright (c) 2010-2013 Christian Johansen
- */
-
-(function (sinon) {
- var commonJSModule = typeof module == "object" && typeof require == "function";
- var push = [].push;
- var hasOwnProperty = Object.prototype.hasOwnProperty;
-
- if (!sinon && commonJSModule) {
- sinon = require("../sinon");
- }
-
- if (!sinon) {
- return;
- }
-
- function getFakes(fakeCollection) {
- if (!fakeCollection.fakes) {
- fakeCollection.fakes = [];
- }
-
- return fakeCollection.fakes;
- }
-
- function each(fakeCollection, method) {
- var fakes = getFakes(fakeCollection);
-
- for (var i = 0, l = fakes.length; i < l; i += 1) {
- if (typeof fakes[i][method] == "function") {
- fakes[i][method]();
- }
- }
- }
-
- function compact(fakeCollection) {
- var fakes = getFakes(fakeCollection);
- var i = 0;
- while (i < fakes.length) {
- fakes.splice(i, 1);
- }
- }
-
- var collection = {
- verify: function resolve() {
- each(this, "verify");
- },
-
- restore: function restore() {
- each(this, "restore");
- compact(this);
- },
-
- verifyAndRestore: function verifyAndRestore() {
- var exception;
-
- try {
- this.verify();
- } catch (e) {
- exception = e;
- }
-
- this.restore();
-
- if (exception) {
- throw exception;
- }
- },
-
- add: function add(fake) {
- push.call(getFakes(this), fake);
- return fake;
- },
-
- spy: function spy() {
- return this.add(sinon.spy.apply(sinon, arguments));
- },
-
- stub: function stub(object, property, value) {
- if (property) {
- var original = object[property];
-
- if (typeof original != "function") {
- if (!hasOwnProperty.call(object, property)) {
- throw new TypeError("Cannot stub non-existent own property " + property);
- }
-
- object[property] = value;
-
- return this.add({
- restore: function () {
- object[property] = original;
- }
- });
- }
- }
- if (!property && !!object && typeof object == "object") {
- var stubbedObj = sinon.stub.apply(sinon, arguments);
-
- for (var prop in stubbedObj) {
- if (typeof stubbedObj[prop] === "function") {
- this.add(stubbedObj[prop]);
- }
- }
-
- return stubbedObj;
- }
-
- return this.add(sinon.stub.apply(sinon, arguments));
- },
-
- mock: function mock() {
- return this.add(sinon.mock.apply(sinon, arguments));
- },
-
- inject: function inject(obj) {
- var col = this;
-
- obj.spy = function () {
- return col.spy.apply(col, arguments);
- };
-
- obj.stub = function () {
- return col.stub.apply(col, arguments);
- };
-
- obj.mock = function () {
- return col.mock.apply(col, arguments);
- };
-
- return obj;
- }
- };
-
- if (commonJSModule) {
- module.exports = collection;
- } else {
- sinon.collection = collection;
- }
-}(typeof sinon == "object" && sinon || null));
-
-/*jslint eqeqeq: false, plusplus: false, evil: true, onevar: false, browser: true, forin: false*/
-/*global module, require, window*/
-/**
- * Fake timer API
- * setTimeout
- * setInterval
- * clearTimeout
- * clearInterval
- * tick
- * reset
- * Date
- *
- * Inspired by jsUnitMockTimeOut from JsUnit
- *
- * @author Christian Johansen (christian@cjohansen.no)
- * @license BSD
- *
- * Copyright (c) 2010-2013 Christian Johansen
- */
-
-if (typeof sinon == "undefined") {
- var sinon = {};
-}
-
-(function (global) {
- var id = 1;
-
- function addTimer(args, recurring) {
- if (args.length === 0) {
- throw new Error("Function requires at least 1 parameter");
- }
-
- var toId = id++;
- var delay = args[1] || 0;
-
- if (!this.timeouts) {
- this.timeouts = {};
- }
-
- this.timeouts[toId] = {
- id: toId,
- func: args[0],
- callAt: this.now + delay,
- invokeArgs: Array.prototype.slice.call(args, 2)
- };
-
- if (recurring === true) {
- this.timeouts[toId].interval = delay;
- }
-
- return toId;
- }
-
- function parseTime(str) {
- if (!str) {
- return 0;
- }
-
- var strings = str.split(":");
- var l = strings.length, i = l;
- var ms = 0, parsed;
-
- if (l > 3 || !/^(\d\d:){0,2}\d\d?$/.test(str)) {
- throw new Error("tick only understands numbers and 'h:m:s'");
- }
-
- while (i--) {
- parsed = parseInt(strings[i], 10);
-
- if (parsed >= 60) {
- throw new Error("Invalid time " + str);
- }
-
- ms += parsed * Math.pow(60, (l - i - 1));
- }
-
- return ms * 1000;
- }
-
- function createObject(object) {
- var newObject;
-
- if (Object.create) {
- newObject = Object.create(object);
- } else {
- var F = function () {};
- F.prototype = object;
- newObject = new F();
- }
-
- newObject.Date.clock = newObject;
- return newObject;
- }
-
- sinon.clock = {
- now: 0,
-
- create: function create(now) {
- var clock = createObject(this);
-
- if (typeof now == "number") {
- clock.now = now;
- }
-
- if (!!now && typeof now == "object") {
- throw new TypeError("now should be milliseconds since UNIX epoch");
- }
-
- return clock;
- },
-
- setTimeout: function setTimeout(callback, timeout) {
- return addTimer.call(this, arguments, false);
- },
-
- clearTimeout: function clearTimeout(timerId) {
- if (!this.timeouts) {
- this.timeouts = [];
- }
-
- if (timerId in this.timeouts) {
- delete this.timeouts[timerId];
- }
- },
-
- setInterval: function setInterval(callback, timeout) {
- return addTimer.call(this, arguments, true);
- },
-
- clearInterval: function clearInterval(timerId) {
- this.clearTimeout(timerId);
- },
-
- tick: function tick(ms) {
- ms = typeof ms == "number" ? ms : parseTime(ms);
- var tickFrom = this.now, tickTo = this.now + ms, previous = this.now;
- var timer = this.firstTimerInRange(tickFrom, tickTo);
-
- var firstException;
- while (timer && tickFrom <= tickTo) {
- if (this.timeouts[timer.id]) {
- tickFrom = this.now = timer.callAt;
- try {
- this.callTimer(timer);
- } catch (e) {
- firstException = firstException || e;
- }
- }
-
- timer = this.firstTimerInRange(previous, tickTo);
- previous = tickFrom;
- }
-
- this.now = tickTo;
-
- if (firstException) {
- throw firstException;
- }
-
- return this.now;
- },
-
- firstTimerInRange: function (from, to) {
- var timer, smallest, originalTimer;
-
- for (var id in this.timeouts) {
- if (this.timeouts.hasOwnProperty(id)) {
- if (this.timeouts[id].callAt < from || this.timeouts[id].callAt > to) {
- continue;
- }
-
- if (!smallest || this.timeouts[id].callAt < smallest) {
- originalTimer = this.timeouts[id];
- smallest = this.timeouts[id].callAt;
-
- timer = {
- func: this.timeouts[id].func,
- callAt: this.timeouts[id].callAt,
- interval: this.timeouts[id].interval,
- id: this.timeouts[id].id,
- invokeArgs: this.timeouts[id].invokeArgs
- };
- }
- }
- }
-
- return timer || null;
- },
-
- callTimer: function (timer) {
- if (typeof timer.interval == "number") {
- this.timeouts[timer.id].callAt += timer.interval;
- } else {
- delete this.timeouts[timer.id];
- }
-
- try {
- if (typeof timer.func == "function") {
- timer.func.apply(null, timer.invokeArgs);
- } else {
- eval(timer.func);
- }
- } catch (e) {
- var exception = e;
- }
-
- if (!this.timeouts[timer.id]) {
- if (exception) {
- throw exception;
- }
- return;
- }
-
- if (exception) {
- throw exception;
- }
- },
-
- reset: function reset() {
- this.timeouts = {};
- },
-
- Date: (function () {
- var NativeDate = Date;
-
- function ClockDate(year, month, date, hour, minu
<TRUNCATED>
[02/26] git commit: updated refs/heads/1.4.x to 81b1601
Posted by dj...@apache.org.
Remove couchdb_updates files (content already in top-level LICENSE/NOTICE).
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/1769fb75
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/1769fb75
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/1769fb75
Branch: refs/heads/1.4.x
Commit: 1769fb75937418dc3548b445a363b35a7585fd90
Parents: 4bd7cad
Author: Dirkjan Ochtman <dj...@apache.org>
Authored: Wed Aug 7 18:00:37 2013 +0200
Committer: Dirkjan Ochtman <dj...@apache.org>
Committed: Wed Aug 7 18:00:37 2013 +0200
----------------------------------------------------------------------
src/couch_dbupdates/LICENSE | 22 ----------------------
src/couch_dbupdates/NOTICE | 6 ------
src/couch_dbupdates/README.md | 32 --------------------------------
3 files changed, 60 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/1769fb75/src/couch_dbupdates/LICENSE
----------------------------------------------------------------------
diff --git a/src/couch_dbupdates/LICENSE b/src/couch_dbupdates/LICENSE
deleted file mode 100644
index a089916..0000000
--- a/src/couch_dbupdates/LICENSE
+++ /dev/null
@@ -1,22 +0,0 @@
-2009-2012 (c) BenoƮt Chesneau <be...@e-engura.org>
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/1769fb75/src/couch_dbupdates/NOTICE
----------------------------------------------------------------------
diff --git a/src/couch_dbupdates/NOTICE b/src/couch_dbupdates/NOTICE
deleted file mode 100644
index ee00a85..0000000
--- a/src/couch_dbupdates/NOTICE
+++ /dev/null
@@ -1,6 +0,0 @@
-couch_dbupdates
----------------
-
-2012 (c) BenoƮt Chesneau <be...@refuge.io>
-
-couch_dbupdates is released under the Apache License 2.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/1769fb75/src/couch_dbupdates/README.md
----------------------------------------------------------------------
diff --git a/src/couch_dbupdates/README.md b/src/couch_dbupdates/README.md
deleted file mode 100644
index c683102..0000000
--- a/src/couch_dbupdates/README.md
+++ /dev/null
@@ -1,32 +0,0 @@
-# couch_dbupdates
-
-`couch_dbupdates` is a simple couchdb modules to receive databases
-events in couchdb node.
-
-It's actually **supported by all the [refuge](http://refuge.io) projects**:
-
-- [refuge](https://github.com/refuge/refuge)
-- [rcouch](https://github.com/refuge/rcouch)
-- [rcouch_template](https://github.com/refuge/rcouch_template)
-
-
-## HTTP API
-
-To get db events, do a GET to `/_db_updates` .
-
-You can pass an optional query parameters:
-
-* `feed` The feed can be `longpoll` (default) for longpolling, `eventsource`
- for event stream or `continuous` for continuous feed.
-* `timeout`: timeout before the longpolling connection close or when the
- heartbeat is emitted.
-* `heartbeat`: true, or false. an empty line is emittend when the
- timeout occurs to maintain the connection active.
-
-
-## Example of usage
-
- $ curl http://127.0.0.1:5984/_db_updates?feed=continuous
- {"type":"created","db_name":"testdb"}
- {"type":"updated","db_name":"testdb"}
- {"type":"deleted","db_name":"testdb"}
[05/26] Remove fauxton from 1.4.x branch.
Posted by dj...@apache.org.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/test/mocha/sinon-chai.js
----------------------------------------------------------------------
diff --git a/src/fauxton/test/mocha/sinon-chai.js b/src/fauxton/test/mocha/sinon-chai.js
deleted file mode 100644
index 26cee36..0000000
--- a/src/fauxton/test/mocha/sinon-chai.js
+++ /dev/null
@@ -1,109 +0,0 @@
-(function (sinonChai) {
- "use strict";
-
- // Module systems magic dance.
-
- if (typeof require === "function" && typeof exports === "object" && typeof module === "object") {
- // NodeJS
- module.exports = sinonChai;
- } else if (typeof define === "function" && define.amd) {
- // AMD
- define(function () {
- return sinonChai;
- });
- } else {
- // Other environment (usually <script> tag): plug in to global chai instance directly.
- chai.use(sinonChai);
- }
-}(function sinonChai(chai, utils) {
- "use strict";
-
- var slice = Array.prototype.slice;
-
- function isSpy(putativeSpy) {
- return typeof putativeSpy === "function" &&
- typeof putativeSpy.getCall === "function" &&
- typeof putativeSpy.calledWithExactly === "function";
- }
-
- function isCall(putativeCall) {
- return putativeCall && isSpy(putativeCall.proxy);
- }
-
- function assertCanWorkWith(assertion) {
- if (!isSpy(assertion._obj) && !isCall(assertion._obj)) {
- throw new TypeError(utils.inspect(assertion._obj) + " is not a spy or a call to a spy!");
- }
- }
-
- function getMessages(spy, action, nonNegatedSuffix, always, args) {
- var verbPhrase = always ? "always have " : "have ";
- nonNegatedSuffix = nonNegatedSuffix || "";
- if (isSpy(spy.proxy)) {
- spy = spy.proxy;
- }
-
- function printfArray(array) {
- return spy.printf.apply(spy, array);
- }
-
- return {
- affirmative: printfArray(["expected %n to " + verbPhrase + action + nonNegatedSuffix].concat(args)),
- negative: printfArray(["expected %n to not " + verbPhrase + action].concat(args))
- };
- }
-
- function sinonProperty(name, action, nonNegatedSuffix) {
- utils.addProperty(chai.Assertion.prototype, name, function () {
- assertCanWorkWith(this);
-
- var messages = getMessages(this._obj, action, nonNegatedSuffix, false);
- this.assert(this._obj[name], messages.affirmative, messages.negative);
- });
- }
-
- function createSinonMethodHandler(sinonName, action, nonNegatedSuffix) {
- return function () {
- assertCanWorkWith(this);
-
- var alwaysSinonMethod = "always" + sinonName[0].toUpperCase() + sinonName.substring(1);
- var shouldBeAlways = utils.flag(this, "always") && typeof this._obj[alwaysSinonMethod] === "function";
- var sinonMethod = shouldBeAlways ? alwaysSinonMethod : sinonName;
-
- var messages = getMessages(this._obj, action, nonNegatedSuffix, shouldBeAlways, slice.call(arguments));
- this.assert(this._obj[sinonMethod].apply(this._obj, arguments), messages.affirmative, messages.negative);
- };
- }
-
- function sinonMethodAsProperty(name, action, nonNegatedSuffix) {
- var handler = createSinonMethodHandler(name, action, nonNegatedSuffix);
- utils.addProperty(chai.Assertion.prototype, name, handler);
- }
-
- function exceptionalSinonMethod(chaiName, sinonName, action, nonNegatedSuffix) {
- var handler = createSinonMethodHandler(sinonName, action, nonNegatedSuffix);
- utils.addMethod(chai.Assertion.prototype, chaiName, handler);
- }
-
- function sinonMethod(name, action, nonNegatedSuffix) {
- exceptionalSinonMethod(name, name, action, nonNegatedSuffix);
- }
-
- utils.addProperty(chai.Assertion.prototype, "always", function () {
- utils.flag(this, "always", true);
- });
-
- sinonProperty("called", "been called", " at least once, but it was never called");
- sinonProperty("calledOnce", "been called exactly once", ", but it was called %c%C");
- sinonProperty("calledTwice", "been called exactly twice", ", but it was called %c%C");
- sinonProperty("calledThrice", "been called exactly thrice", ", but it was called %c%C");
- sinonMethodAsProperty("calledWithNew", "been called with new");
- sinonMethod("calledBefore", "been called before %1");
- sinonMethod("calledAfter", "been called after %1");
- sinonMethod("calledOn", "been called with %1 as this", ", but it was called with %t instead");
- sinonMethod("calledWith", "been called with arguments %*", "%C");
- sinonMethod("calledWithExactly", "been called with exact arguments %*", "%C");
- sinonMethod("calledWithMatch", "been called with arguments matching %*", "%C");
- sinonMethod("returned", "returned %1");
- exceptionalSinonMethod("thrown", "threw", "thrown %1");
-}));
[19/26] Remove fauxton from 1.4.x branch.
Posted by dj...@apache.org.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/js/libs/codemirror.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/codemirror.js b/src/fauxton/assets/js/libs/codemirror.js
deleted file mode 100644
index 532dd89..0000000
--- a/src/fauxton/assets/js/libs/codemirror.js
+++ /dev/null
@@ -1,3231 +0,0 @@
-// CodeMirror version 2.32
-//
-// All functions that need access to the editor's state live inside
-// the CodeMirror function. Below that, at the bottom of the file,
-// some utilities are defined.
-
-// CodeMirror is the only global var we claim
-var CodeMirror = (function() {
- // This is the function that produces an editor instance. Its
- // closure is used to store the editor state.
- function CodeMirror(place, givenOptions) {
- // Determine effective options based on given values and defaults.
- var options = {}, defaults = CodeMirror.defaults;
- for (var opt in defaults)
- if (defaults.hasOwnProperty(opt))
- options[opt] = (givenOptions && givenOptions.hasOwnProperty(opt) ? givenOptions : defaults)[opt];
-
- // The element in which the editor lives.
- var wrapper = document.createElement("div");
- wrapper.className = "CodeMirror" + (options.lineWrapping ? " CodeMirror-wrap" : "");
- // This mess creates the base DOM structure for the editor.
- wrapper.innerHTML =
- '<div style="overflow: hidden; position: relative; width: 3px; height: 0px;">' + // Wraps and hides input textarea
- '<textarea style="position: absolute; padding: 0; width: 1px; height: 1em" wrap="off" ' +
- 'autocorrect="off" autocapitalize="off"></textarea></div>' +
- '<div class="CodeMirror-scrollbar">' + // The vertical scrollbar. Horizontal scrolling is handled by the scroller itself.
- '<div class="CodeMirror-scrollbar-inner">' + // The empty scrollbar content, used solely for managing the scrollbar thumb.
- '</div></div>' + // This must be before the scroll area because it's float-right.
- '<div class="CodeMirror-scroll" tabindex="-1">' +
- '<div style="position: relative">' + // Set to the height of the text, causes scrolling
- '<div style="position: relative">' + // Moved around its parent to cover visible view
- '<div class="CodeMirror-gutter"><div class="CodeMirror-gutter-text"></div></div>' +
- // Provides positioning relative to (visible) text origin
- '<div class="CodeMirror-lines"><div style="position: relative; z-index: 0">' +
- // Used to measure text size
- '<div style="position: absolute; width: 100%; height: 0px; overflow: hidden; visibility: hidden;"></div>' +
- '<pre class="CodeMirror-cursor"> </pre>' + // Absolutely positioned blinky cursor
- '<pre class="CodeMirror-cursor" style="visibility: hidden"> </pre>' + // Used to force a width
- '<div style="position: relative; z-index: -1"></div><div></div>' + // DIVs containing the selection and the actual code
- '</div></div></div></div></div>';
- if (place.appendChild) place.appendChild(wrapper); else place(wrapper);
- // I've never seen more elegant code in my life.
- var inputDiv = wrapper.firstChild, input = inputDiv.firstChild,
- scroller = wrapper.lastChild, code = scroller.firstChild,
- mover = code.firstChild, gutter = mover.firstChild, gutterText = gutter.firstChild,
- lineSpace = gutter.nextSibling.firstChild, measure = lineSpace.firstChild,
- cursor = measure.nextSibling, widthForcer = cursor.nextSibling,
- selectionDiv = widthForcer.nextSibling, lineDiv = selectionDiv.nextSibling,
- scrollbar = inputDiv.nextSibling, scrollbarInner = scrollbar.firstChild;
- themeChanged(); keyMapChanged();
- // Needed to hide big blue blinking cursor on Mobile Safari
- if (ios) input.style.width = "0px";
- if (!webkit) scroller.draggable = true;
- lineSpace.style.outline = "none";
- if (options.tabindex != null) input.tabIndex = options.tabindex;
- if (options.autofocus) focusInput();
- if (!options.gutter && !options.lineNumbers) gutter.style.display = "none";
- // Needed to handle Tab key in KHTML
- if (khtml) inputDiv.style.height = "1px", inputDiv.style.position = "absolute";
-
- // Check for OS X >= 10.7. If so, we need to force a width on the scrollbar, and
- // make it overlap the content. (But we only do this if the scrollbar doesn't already
- // have a natural width. If the mouse is plugged in or the user sets the system pref
- // to always show scrollbars, the scrollbar shouldn't overlap.)
- if (mac_geLion) {
- scrollbar.className += (overlapScrollbars() ? " cm-sb-overlap" : " cm-sb-nonoverlap");
- } else if (ie_lt8) {
- // Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).
- scrollbar.className += " cm-sb-ie7";
- }
-
- // Check for problem with IE innerHTML not working when we have a
- // P (or similar) parent node.
- try { stringWidth("x"); }
- catch (e) {
- if (e.message.match(/runtime/i))
- e = new Error("A CodeMirror inside a P-style element does not work in Internet Explorer. (innerHTML bug)");
- throw e;
- }
-
- // Delayed object wrap timeouts, making sure only one is active. blinker holds an interval.
- var poll = new Delayed(), highlight = new Delayed(), blinker;
-
- // mode holds a mode API object. doc is the tree of Line objects,
- // work an array of lines that should be parsed, and history the
- // undo history (instance of History constructor).
- var mode, doc = new BranchChunk([new LeafChunk([new Line("")])]), work, focused;
- loadMode();
- // The selection. These are always maintained to point at valid
- // positions. Inverted is used to remember that the user is
- // selecting bottom-to-top.
- var sel = {from: {line: 0, ch: 0}, to: {line: 0, ch: 0}, inverted: false};
- // Selection-related flags. shiftSelecting obviously tracks
- // whether the user is holding shift.
- var shiftSelecting, lastClick, lastDoubleClick, lastScrollTop = 0, lastScrollLeft = 0, draggingText,
- overwrite = false, suppressEdits = false;
- // Variables used by startOperation/endOperation to track what
- // happened during the operation.
- var updateInput, userSelChange, changes, textChanged, selectionChanged, leaveInputAlone,
- gutterDirty, callbacks;
- // Current visible range (may be bigger than the view window).
- var displayOffset = 0, showingFrom = 0, showingTo = 0, lastSizeC = 0;
- // bracketHighlighted is used to remember that a bracket has been
- // marked.
- var bracketHighlighted;
- // Tracks the maximum line length so that the horizontal scrollbar
- // can be kept static when scrolling.
- var maxLine = "", updateMaxLine = false, maxLineChanged = true;
- var tabCache = {};
-
- // Initialize the content.
- operation(function(){setValue(options.value || ""); updateInput = false;})();
- var history = new History();
-
- // Register our event handlers.
- connect(scroller, "mousedown", operation(onMouseDown));
- connect(scroller, "dblclick", operation(onDoubleClick));
- connect(lineSpace, "selectstart", e_preventDefault);
- // Gecko browsers fire contextmenu *after* opening the menu, at
- // which point we can't mess with it anymore. Context menu is
- // handled in onMouseDown for Gecko.
- if (!gecko) connect(scroller, "contextmenu", onContextMenu);
- connect(scroller, "scroll", onScroll);
- connect(scrollbar, "scroll", onScroll);
- connect(scrollbar, "mousedown", function() {if (focused) setTimeout(focusInput, 0);});
- connect(scroller, "mousewheel", onMouseWheel);
- connect(scroller, "DOMMouseScroll", onMouseWheel);
- connect(window, "resize", function() {updateDisplay(true);});
- connect(input, "keyup", operation(onKeyUp));
- connect(input, "input", fastPoll);
- connect(input, "keydown", operation(onKeyDown));
- connect(input, "keypress", operation(onKeyPress));
- connect(input, "focus", onFocus);
- connect(input, "blur", onBlur);
-
- if (options.dragDrop) {
- connect(scroller, "dragstart", onDragStart);
- function drag_(e) {
- if (options.onDragEvent && options.onDragEvent(instance, addStop(e))) return;
- e_stop(e);
- }
- connect(scroller, "dragenter", drag_);
- connect(scroller, "dragover", drag_);
- connect(scroller, "drop", operation(onDrop));
- }
- connect(scroller, "paste", function(){focusInput(); fastPoll();});
- connect(input, "paste", fastPoll);
- connect(input, "cut", operation(function(){
- if (!options.readOnly) replaceSelection("");
- }));
-
- // Needed to handle Tab key in KHTML
- if (khtml) connect(code, "mouseup", function() {
- if (document.activeElement == input) input.blur();
- focusInput();
- });
-
- // IE throws unspecified error in certain cases, when
- // trying to access activeElement before onload
- var hasFocus; try { hasFocus = (document.activeElement == input); } catch(e) { }
- if (hasFocus || options.autofocus) setTimeout(onFocus, 20);
- else onBlur();
-
- function isLine(l) {return l >= 0 && l < doc.size;}
- // The instance object that we'll return. Mostly calls out to
- // local functions in the CodeMirror function. Some do some extra
- // range checking and/or clipping. operation is used to wrap the
- // call so that changes it makes are tracked, and the display is
- // updated afterwards.
- var instance = wrapper.CodeMirror = {
- getValue: getValue,
- setValue: operation(setValue),
- getSelection: getSelection,
- replaceSelection: operation(replaceSelection),
- focus: function(){window.focus(); focusInput(); onFocus(); fastPoll();},
- setOption: function(option, value) {
- var oldVal = options[option];
- options[option] = value;
- if (option == "mode" || option == "indentUnit") loadMode();
- else if (option == "readOnly" && value == "nocursor") {onBlur(); input.blur();}
- else if (option == "readOnly" && !value) {resetInput(true);}
- else if (option == "theme") themeChanged();
- else if (option == "lineWrapping" && oldVal != value) operation(wrappingChanged)();
- else if (option == "tabSize") updateDisplay(true);
- else if (option == "keyMap") keyMapChanged();
- if (option == "lineNumbers" || option == "gutter" || option == "firstLineNumber" || option == "theme") {
- gutterChanged();
- updateDisplay(true);
- }
- },
- getOption: function(option) {return options[option];},
- undo: operation(undo),
- redo: operation(redo),
- indentLine: operation(function(n, dir) {
- if (typeof dir != "string") {
- if (dir == null) dir = options.smartIndent ? "smart" : "prev";
- else dir = dir ? "add" : "subtract";
- }
- if (isLine(n)) indentLine(n, dir);
- }),
- indentSelection: operation(indentSelected),
- historySize: function() {return {undo: history.done.length, redo: history.undone.length};},
- clearHistory: function() {history = new History();},
- setHistory: function(histData) {
- history = new History();
- history.done = histData.done;
- history.undone = histData.undone;
- },
- getHistory: function() {
- history.time = 0;
- return {done: history.done.concat([]), undone: history.undone.concat([])};
- },
- matchBrackets: operation(function(){matchBrackets(true);}),
- getTokenAt: operation(function(pos) {
- pos = clipPos(pos);
- return getLine(pos.line).getTokenAt(mode, getStateBefore(pos.line), pos.ch);
- }),
- getStateAfter: function(line) {
- line = clipLine(line == null ? doc.size - 1: line);
- return getStateBefore(line + 1);
- },
- cursorCoords: function(start, mode) {
- if (start == null) start = sel.inverted;
- return this.charCoords(start ? sel.from : sel.to, mode);
- },
- charCoords: function(pos, mode) {
- pos = clipPos(pos);
- if (mode == "local") return localCoords(pos, false);
- if (mode == "div") return localCoords(pos, true);
- return pageCoords(pos);
- },
- coordsChar: function(coords) {
- var off = eltOffset(lineSpace);
- return coordsChar(coords.x - off.left, coords.y - off.top);
- },
- markText: operation(markText),
- setBookmark: setBookmark,
- findMarksAt: findMarksAt,
- setMarker: operation(addGutterMarker),
- clearMarker: operation(removeGutterMarker),
- setLineClass: operation(setLineClass),
- hideLine: operation(function(h) {return setLineHidden(h, true);}),
- showLine: operation(function(h) {return setLineHidden(h, false);}),
- onDeleteLine: function(line, f) {
- if (typeof line == "number") {
- if (!isLine(line)) return null;
- line = getLine(line);
- }
- (line.handlers || (line.handlers = [])).push(f);
- return line;
- },
- lineInfo: lineInfo,
- addWidget: function(pos, node, scroll, vert, horiz) {
- pos = localCoords(clipPos(pos));
- var top = pos.yBot, left = pos.x;
- node.style.position = "absolute";
- code.appendChild(node);
- if (vert == "over") top = pos.y;
- else if (vert == "near") {
- var vspace = Math.max(scroller.offsetHeight, doc.height * textHeight()),
- hspace = Math.max(code.clientWidth, lineSpace.clientWidth) - paddingLeft();
- if (pos.yBot + node.offsetHeight > vspace && pos.y > node.offsetHeight)
- top = pos.y - node.offsetHeight;
- if (left + node.offsetWidth > hspace)
- left = hspace - node.offsetWidth;
- }
- node.style.top = (top + paddingTop()) + "px";
- node.style.left = node.style.right = "";
- if (horiz == "right") {
- left = code.clientWidth - node.offsetWidth;
- node.style.right = "0px";
- } else {
- if (horiz == "left") left = 0;
- else if (horiz == "middle") left = (code.clientWidth - node.offsetWidth) / 2;
- node.style.left = (left + paddingLeft()) + "px";
- }
- if (scroll)
- scrollIntoView(left, top, left + node.offsetWidth, top + node.offsetHeight);
- },
-
- lineCount: function() {return doc.size;},
- clipPos: clipPos,
- getCursor: function(start) {
- if (start == null) start = sel.inverted;
- return copyPos(start ? sel.from : sel.to);
- },
- somethingSelected: function() {return !posEq(sel.from, sel.to);},
- setCursor: operation(function(line, ch, user) {
- if (ch == null && typeof line.line == "number") setCursor(line.line, line.ch, user);
- else setCursor(line, ch, user);
- }),
- setSelection: operation(function(from, to, user) {
- (user ? setSelectionUser : setSelection)(clipPos(from), clipPos(to || from));
- }),
- getLine: function(line) {if (isLine(line)) return getLine(line).text;},
- getLineHandle: function(line) {if (isLine(line)) return getLine(line);},
- setLine: operation(function(line, text) {
- if (isLine(line)) replaceRange(text, {line: line, ch: 0}, {line: line, ch: getLine(line).text.length});
- }),
- removeLine: operation(function(line) {
- if (isLine(line)) replaceRange("", {line: line, ch: 0}, clipPos({line: line+1, ch: 0}));
- }),
- replaceRange: operation(replaceRange),
- getRange: function(from, to, lineSep) {return getRange(clipPos(from), clipPos(to), lineSep);},
-
- triggerOnKeyDown: operation(onKeyDown),
- execCommand: function(cmd) {return commands[cmd](instance);},
- // Stuff used by commands, probably not much use to outside code.
- moveH: operation(moveH),
- deleteH: operation(deleteH),
- moveV: operation(moveV),
- toggleOverwrite: function() {
- if(overwrite){
- overwrite = false;
- cursor.className = cursor.className.replace(" CodeMirror-overwrite", "");
- } else {
- overwrite = true;
- cursor.className += " CodeMirror-overwrite";
- }
- },
-
- posFromIndex: function(off) {
- var lineNo = 0, ch;
- doc.iter(0, doc.size, function(line) {
- var sz = line.text.length + 1;
- if (sz > off) { ch = off; return true; }
- off -= sz;
- ++lineNo;
- });
- return clipPos({line: lineNo, ch: ch});
- },
- indexFromPos: function (coords) {
- if (coords.line < 0 || coords.ch < 0) return 0;
- var index = coords.ch;
- doc.iter(0, coords.line, function (line) {
- index += line.text.length + 1;
- });
- return index;
- },
- scrollTo: function(x, y) {
- if (x != null) scroller.scrollLeft = x;
- if (y != null) scrollbar.scrollTop = y;
- updateDisplay([]);
- },
- getScrollInfo: function() {
- return {x: scroller.scrollLeft, y: scrollbar.scrollTop,
- height: scrollbar.scrollHeight, width: scroller.scrollWidth};
- },
- setSize: function(width, height) {
- function interpret(val) {
- val = String(val);
- return /^\d+$/.test(val) ? val + "px" : val;
- }
- if (width != null) wrapper.style.width = interpret(width);
- if (height != null) scroller.style.height = interpret(height);
- },
-
- operation: function(f){return operation(f)();},
- compoundChange: function(f){return compoundChange(f);},
- refresh: function(){
- updateDisplay(true, null, lastScrollTop);
- if (scrollbar.scrollHeight > lastScrollTop)
- scrollbar.scrollTop = lastScrollTop;
- },
- getInputField: function(){return input;},
- getWrapperElement: function(){return wrapper;},
- getScrollerElement: function(){return scroller;},
- getGutterElement: function(){return gutter;}
- };
-
- function getLine(n) { return getLineAt(doc, n); }
- function updateLineHeight(line, height) {
- gutterDirty = true;
- var diff = height - line.height;
- for (var n = line; n; n = n.parent) n.height += diff;
- }
-
- function setValue(code) {
- var top = {line: 0, ch: 0};
- updateLines(top, {line: doc.size - 1, ch: getLine(doc.size-1).text.length},
- splitLines(code), top, top);
- updateInput = true;
- }
- function getValue(lineSep) {
- var text = [];
- doc.iter(0, doc.size, function(line) { text.push(line.text); });
- return text.join(lineSep || "\n");
- }
-
- function onScroll(e) {
- if (scroller.scrollTop) {
- scrollbar.scrollTop += scroller.scrollTop;
- scroller.scrollTop = 0;
- }
- if (lastScrollTop != scrollbar.scrollTop || lastScrollLeft != scroller.scrollLeft) {
- lastScrollTop = scrollbar.scrollTop;
- lastScrollLeft = scroller.scrollLeft;
- updateDisplay([]);
- if (options.fixedGutter) gutter.style.left = scroller.scrollLeft + "px";
- if (options.onScroll) options.onScroll(instance);
- }
- }
-
- function onMouseDown(e) {
- setShift(e_prop(e, "shiftKey"));
- // Check whether this is a click in a widget
- for (var n = e_target(e); n != wrapper; n = n.parentNode)
- if (n.parentNode == code && n != mover) return;
-
- // See if this is a click in the gutter
- for (var n = e_target(e); n != wrapper; n = n.parentNode)
- if (n.parentNode == gutterText) {
- if (options.onGutterClick)
- options.onGutterClick(instance, indexOf(gutterText.childNodes, n) + showingFrom, e);
- return e_preventDefault(e);
- }
-
- var start = posFromMouse(e);
-
- switch (e_button(e)) {
- case 3:
- if (gecko) onContextMenu(e);
- return;
- case 2:
- if (start) setCursor(start.line, start.ch, true);
- setTimeout(focusInput, 20);
- e_preventDefault(e);
- return;
- }
- // For button 1, if it was clicked inside the editor
- // (posFromMouse returning non-null), we have to adjust the
- // selection.
- if (!start) {if (e_target(e) == scroller) e_preventDefault(e); return;}
-
- if (!focused) onFocus();
-
- var now = +new Date, type = "single";
- if (lastDoubleClick && lastDoubleClick.time > now - 400 && posEq(lastDoubleClick.pos, start)) {
- type = "triple";
- e_preventDefault(e);
- setTimeout(focusInput, 20);
- selectLine(start.line);
- } else if (lastClick && lastClick.time > now - 400 && posEq(lastClick.pos, start)) {
- type = "double";
- lastDoubleClick = {time: now, pos: start};
- e_preventDefault(e);
- var word = findWordAt(start);
- setSelectionUser(word.from, word.to);
- } else { lastClick = {time: now, pos: start}; }
-
- var last = start, going;
- if (options.dragDrop && dragAndDrop && !options.readOnly && !posEq(sel.from, sel.to) &&
- !posLess(start, sel.from) && !posLess(sel.to, start) && type == "single") {
- // Let the drag handler handle this.
- if (webkit) scroller.draggable = true;
- function dragEnd(e2) {
- if (webkit) scroller.draggable = false;
- draggingText = false;
- up(); drop();
- if (Math.abs(e.clientX - e2.clientX) + Math.abs(e.clientY - e2.clientY) < 10) {
- e_preventDefault(e2);
- setCursor(start.line, start.ch, true);
- focusInput();
- }
- }
- var up = connect(document, "mouseup", operation(dragEnd), true);
- var drop = connect(scroller, "drop", operation(dragEnd), true);
- draggingText = true;
- // IE's approach to draggable
- if (scroller.dragDrop) scroller.dragDrop();
- return;
- }
- e_preventDefault(e);
- if (type == "single") setCursor(start.line, start.ch, true);
-
- var startstart = sel.from, startend = sel.to;
-
- function doSelect(cur) {
- if (type == "single") {
- setSelectionUser(start, cur);
- } else if (type == "double") {
- var word = findWordAt(cur);
- if (posLess(cur, startstart)) setSelectionUser(word.from, startend);
- else setSelectionUser(startstart, word.to);
- } else if (type == "triple") {
- if (posLess(cur, startstart)) setSelectionUser(startend, clipPos({line: cur.line, ch: 0}));
- else setSelectionUser(startstart, clipPos({line: cur.line + 1, ch: 0}));
- }
- }
-
- function extend(e) {
- var cur = posFromMouse(e, true);
- if (cur && !posEq(cur, last)) {
- if (!focused) onFocus();
- last = cur;
- doSelect(cur);
- updateInput = false;
- var visible = visibleLines();
- if (cur.line >= visible.to || cur.line < visible.from)
- going = setTimeout(operation(function(){extend(e);}), 150);
- }
- }
-
- function done(e) {
- clearTimeout(going);
- var cur = posFromMouse(e);
- if (cur) doSelect(cur);
- e_preventDefault(e);
- focusInput();
- updateInput = true;
- move(); up();
- }
- var move = connect(document, "mousemove", operation(function(e) {
- clearTimeout(going);
- e_preventDefault(e);
- if (!ie && !e_button(e)) done(e);
- else extend(e);
- }), true);
- var up = connect(document, "mouseup", operation(done), true);
- }
- function onDoubleClick(e) {
- for (var n = e_target(e); n != wrapper; n = n.parentNode)
- if (n.parentNode == gutterText) return e_preventDefault(e);
- e_preventDefault(e);
- }
- function onDrop(e) {
- if (options.onDragEvent && options.onDragEvent(instance, addStop(e))) return;
- e.preventDefault();
- var pos = posFromMouse(e, true), files = e.dataTransfer.files;
- if (!pos || options.readOnly) return;
- if (files && files.length && window.FileReader && window.File) {
- function loadFile(file, i) {
- var reader = new FileReader;
- reader.onload = function() {
- text[i] = reader.result;
- if (++read == n) {
- pos = clipPos(pos);
- operation(function() {
- var end = replaceRange(text.join(""), pos, pos);
- setSelectionUser(pos, end);
- })();
- }
- };
- reader.readAsText(file);
- }
- var n = files.length, text = Array(n), read = 0;
- for (var i = 0; i < n; ++i) loadFile(files[i], i);
- } else {
- // Don't do a replace if the drop happened inside of the selected text.
- if (draggingText && !(posLess(pos, sel.from) || posLess(sel.to, pos))) return;
- try {
- var text = e.dataTransfer.getData("Text");
- if (text) {
- compoundChange(function() {
- var curFrom = sel.from, curTo = sel.to;
- setSelectionUser(pos, pos);
- if (draggingText) replaceRange("", curFrom, curTo);
- replaceSelection(text);
- focusInput();
- });
- }
- }
- catch(e){}
- }
- }
- function onDragStart(e) {
- var txt = getSelection();
- e.dataTransfer.setData("Text", txt);
-
- // Use dummy image instead of default browsers image.
- if (gecko || chrome || opera) {
- var img = document.createElement('img');
- img.scr = 'data:image/gif;base64,R0lGODdhAgACAIAAAAAAAP///ywAAAAAAgACAAACAoRRADs='; //1x1 image
- e.dataTransfer.setDragImage(img, 0, 0);
- }
- }
-
- function doHandleBinding(bound, dropShift) {
- if (typeof bound == "string") {
- bound = commands[bound];
- if (!bound) return false;
- }
- var prevShift = shiftSelecting;
- try {
- if (options.readOnly) suppressEdits = true;
- if (dropShift) shiftSelecting = null;
- bound(instance);
- } catch(e) {
- if (e != Pass) throw e;
- return false;
- } finally {
- shiftSelecting = prevShift;
- suppressEdits = false;
- }
- return true;
- }
- function handleKeyBinding(e) {
- // Handle auto keymap transitions
- var startMap = getKeyMap(options.keyMap), next = startMap.auto;
- clearTimeout(maybeTransition);
- if (next && !isModifierKey(e)) maybeTransition = setTimeout(function() {
- if (getKeyMap(options.keyMap) == startMap) {
- options.keyMap = (next.call ? next.call(null, instance) : next);
- }
- }, 50);
-
- var name = keyNames[e_prop(e, "keyCode")], handled = false;
- if (name == null || e.altGraphKey) return false;
- if (e_prop(e, "altKey")) name = "Alt-" + name;
- if (e_prop(e, "ctrlKey")) name = "Ctrl-" + name;
- if (e_prop(e, "metaKey")) name = "Cmd-" + name;
-
- var stopped = false;
- function stop() { stopped = true; }
-
- if (e_prop(e, "shiftKey")) {
- handled = lookupKey("Shift-" + name, options.extraKeys, options.keyMap,
- function(b) {return doHandleBinding(b, true);}, stop)
- || lookupKey(name, options.extraKeys, options.keyMap, function(b) {
- if (typeof b == "string" && /^go[A-Z]/.test(b)) return doHandleBinding(b);
- }, stop);
- } else {
- handled = lookupKey(name, options.extraKeys, options.keyMap, doHandleBinding, stop);
- }
- if (stopped) handled = false;
- if (handled) {
- e_preventDefault(e);
- restartBlink();
- if (ie) { e.oldKeyCode = e.keyCode; e.keyCode = 0; }
- }
- return handled;
- }
- function handleCharBinding(e, ch) {
- var handled = lookupKey("'" + ch + "'", options.extraKeys,
- options.keyMap, function(b) { return doHandleBinding(b, true); });
- if (handled) {
- e_preventDefault(e);
- restartBlink();
- }
- return handled;
- }
-
- var lastStoppedKey = null, maybeTransition;
- function onKeyDown(e) {
- if (!focused) onFocus();
- if (ie && e.keyCode == 27) { e.returnValue = false; }
- if (pollingFast) { if (readInput()) pollingFast = false; }
- if (options.onKeyEvent && options.onKeyEvent(instance, addStop(e))) return;
- var code = e_prop(e, "keyCode");
- // IE does strange things with escape.
- setShift(code == 16 || e_prop(e, "shiftKey"));
- // First give onKeyEvent option a chance to handle this.
- var handled = handleKeyBinding(e);
- if (opera) {
- lastStoppedKey = handled ? code : null;
- // Opera has no cut event... we try to at least catch the key combo
- if (!handled && code == 88 && e_prop(e, mac ? "metaKey" : "ctrlKey"))
- replaceSelection("");
- }
- }
- function onKeyPress(e) {
- if (pollingFast) readInput();
- if (options.onKeyEvent && options.onKeyEvent(instance, addStop(e))) return;
- var keyCode = e_prop(e, "keyCode"), charCode = e_prop(e, "charCode");
- if (opera && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return;}
- if (((opera && (!e.which || e.which < 10)) || khtml) && handleKeyBinding(e)) return;
- var ch = String.fromCharCode(charCode == null ? keyCode : charCode);
- if (options.electricChars && mode.electricChars && options.smartIndent && !options.readOnly) {
- if (mode.electricChars.indexOf(ch) > -1)
- setTimeout(operation(function() {indentLine(sel.to.line, "smart");}), 75);
- }
- if (handleCharBinding(e, ch)) return;
- fastPoll();
- }
- function onKeyUp(e) {
- if (options.onKeyEvent && options.onKeyEvent(instance, addStop(e))) return;
- if (e_prop(e, "keyCode") == 16) shiftSelecting = null;
- }
-
- function onFocus() {
- if (options.readOnly == "nocursor") return;
- if (!focused) {
- if (options.onFocus) options.onFocus(instance);
- focused = true;
- if (scroller.className.search(/\bCodeMirror-focused\b/) == -1)
- scroller.className += " CodeMirror-focused";
- if (!leaveInputAlone) resetInput(true);
- }
- slowPoll();
- restartBlink();
- }
- function onBlur() {
- if (focused) {
- if (options.onBlur) options.onBlur(instance);
- focused = false;
- if (bracketHighlighted)
- operation(function(){
- if (bracketHighlighted) { bracketHighlighted(); bracketHighlighted = null; }
- })();
- scroller.className = scroller.className.replace(" CodeMirror-focused", "");
- }
- clearInterval(blinker);
- setTimeout(function() {if (!focused) shiftSelecting = null;}, 150);
- }
-
- function chopDelta(delta) {
- // Make sure we always scroll a little bit for any nonzero delta.
- if (delta > 0.0 && delta < 1.0) return 1;
- else if (delta > -1.0 && delta < 0.0) return -1;
- else return Math.round(delta);
- }
-
- function onMouseWheel(e) {
- var deltaX = 0, deltaY = 0;
- if (e.type == "DOMMouseScroll") { // Firefox
- var delta = -e.detail * 8.0;
- if (e.axis == e.HORIZONTAL_AXIS) deltaX = delta;
- else if (e.axis == e.VERTICAL_AXIS) deltaY = delta;
- } else if (e.wheelDeltaX !== undefined && e.wheelDeltaY !== undefined) { // WebKit
- deltaX = e.wheelDeltaX / 3.0;
- deltaY = e.wheelDeltaY / 3.0;
- } else if (e.wheelDelta !== undefined) { // IE or Opera
- deltaY = e.wheelDelta / 3.0;
- }
-
- var scrolled = false;
- deltaX = chopDelta(deltaX);
- deltaY = chopDelta(deltaY);
- if ((deltaX > 0 && scroller.scrollLeft > 0) ||
- (deltaX < 0 && scroller.scrollLeft + scroller.clientWidth < scroller.scrollWidth)) {
- scroller.scrollLeft -= deltaX;
- scrolled = true;
- }
- if ((deltaY > 0 && scrollbar.scrollTop > 0) ||
- (deltaY < 0 && scrollbar.scrollTop + scrollbar.clientHeight < scrollbar.scrollHeight)) {
- scrollbar.scrollTop -= deltaY;
- scrolled = true;
- }
- if (scrolled) e_stop(e);
- }
-
- // Replace the range from from to to by the strings in newText.
- // Afterwards, set the selection to selFrom, selTo.
- function updateLines(from, to, newText, selFrom, selTo) {
- if (suppressEdits) return;
- if (history) {
- var old = [];
- doc.iter(from.line, to.line + 1, function(line) { old.push(line.text); });
- history.addChange(from.line, newText.length, old);
- while (history.done.length > options.undoDepth) history.done.shift();
- }
- updateLinesNoUndo(from, to, newText, selFrom, selTo);
- }
- function unredoHelper(from, to) {
- if (!from.length) return;
- var set = from.pop(), out = [];
- for (var i = set.length - 1; i >= 0; i -= 1) {
- var change = set[i];
- var replaced = [], end = change.start + change.added;
- doc.iter(change.start, end, function(line) { replaced.push(line.text); });
- out.push({start: change.start, added: change.old.length, old: replaced});
- var pos = {line: change.start + change.old.length - 1,
- ch: editEnd(replaced[replaced.length-1], change.old[change.old.length-1])};
- updateLinesNoUndo({line: change.start, ch: 0}, {line: end - 1, ch: getLine(end-1).text.length}, change.old, pos, pos);
- }
- updateInput = true;
- to.push(out);
- }
- function undo() {unredoHelper(history.done, history.undone);}
- function redo() {unredoHelper(history.undone, history.done);}
-
- function updateLinesNoUndo(from, to, newText, selFrom, selTo) {
- if (suppressEdits) return;
- var recomputeMaxLength = false, maxLineLength = maxLine.length;
- if (!options.lineWrapping)
- doc.iter(from.line, to.line + 1, function(line) {
- if (!line.hidden && line.text.length == maxLineLength) {recomputeMaxLength = true; return true;}
- });
- if (from.line != to.line || newText.length > 1) gutterDirty = true;
-
- var nlines = to.line - from.line, firstLine = getLine(from.line), lastLine = getLine(to.line);
- // First adjust the line structure, taking some care to leave highlighting intact.
- if (from.ch == 0 && to.ch == 0 && newText[newText.length - 1] == "") {
- // This is a whole-line replace. Treated specially to make
- // sure line objects move the way they are supposed to.
- var added = [], prevLine = null;
- if (from.line) {
- prevLine = getLine(from.line - 1);
- prevLine.fixMarkEnds(lastLine);
- } else lastLine.fixMarkStarts();
- for (var i = 0, e = newText.length - 1; i < e; ++i)
- added.push(Line.inheritMarks(newText[i], prevLine));
- if (nlines) doc.remove(from.line, nlines, callbacks);
- if (added.length) doc.insert(from.line, added);
- } else if (firstLine == lastLine) {
- if (newText.length == 1)
- firstLine.replace(from.ch, to.ch, newText[0]);
- else {
- lastLine = firstLine.split(to.ch, newText[newText.length-1]);
- firstLine.replace(from.ch, null, newText[0]);
- firstLine.fixMarkEnds(lastLine);
- var added = [];
- for (var i = 1, e = newText.length - 1; i < e; ++i)
- added.push(Line.inheritMarks(newText[i], firstLine));
- added.push(lastLine);
- doc.insert(from.line + 1, added);
- }
- } else if (newText.length == 1) {
- firstLine.replace(from.ch, null, newText[0]);
- lastLine.replace(null, to.ch, "");
- firstLine.append(lastLine);
- doc.remove(from.line + 1, nlines, callbacks);
- } else {
- var added = [];
- firstLine.replace(from.ch, null, newText[0]);
- lastLine.replace(null, to.ch, newText[newText.length-1]);
- firstLine.fixMarkEnds(lastLine);
- for (var i = 1, e = newText.length - 1; i < e; ++i)
- added.push(Line.inheritMarks(newText[i], firstLine));
- if (nlines > 1) doc.remove(from.line + 1, nlines - 1, callbacks);
- doc.insert(from.line + 1, added);
- }
- if (options.lineWrapping) {
- var perLine = Math.max(5, scroller.clientWidth / charWidth() - 3);
- doc.iter(from.line, from.line + newText.length, function(line) {
- if (line.hidden) return;
- var guess = Math.ceil(line.text.length / perLine) || 1;
- if (guess != line.height) updateLineHeight(line, guess);
- });
- } else {
- doc.iter(from.line, from.line + newText.length, function(line) {
- var l = line.text;
- if (!line.hidden && l.length > maxLineLength) {
- maxLine = l; maxLineLength = l.length; maxLineChanged = true;
- recomputeMaxLength = false;
- }
- });
- if (recomputeMaxLength) updateMaxLine = true;
- }
-
- // Add these lines to the work array, so that they will be
- // highlighted. Adjust work lines if lines were added/removed.
- var newWork = [], lendiff = newText.length - nlines - 1;
- for (var i = 0, l = work.length; i < l; ++i) {
- var task = work[i];
- if (task < from.line) newWork.push(task);
- else if (task > to.line) newWork.push(task + lendiff);
- }
- var hlEnd = from.line + Math.min(newText.length, 500);
- highlightLines(from.line, hlEnd);
- newWork.push(hlEnd);
- work = newWork;
- startWorker(100);
- // Remember that these lines changed, for updating the display
- changes.push({from: from.line, to: to.line + 1, diff: lendiff});
- var changeObj = {from: from, to: to, text: newText};
- if (textChanged) {
- for (var cur = textChanged; cur.next; cur = cur.next) {}
- cur.next = changeObj;
- } else textChanged = changeObj;
-
- // Update the selection
- function updateLine(n) {return n <= Math.min(to.line, to.line + lendiff) ? n : n + lendiff;}
- setSelection(clipPos(selFrom), clipPos(selTo),
- updateLine(sel.from.line), updateLine(sel.to.line));
- }
-
- function needsScrollbar() {
- var realHeight = doc.height * textHeight() + 2 * paddingTop();
- return realHeight - 1 > scroller.offsetHeight ? realHeight : false;
- }
-
- function updateVerticalScroll(scrollTop) {
- var scrollHeight = needsScrollbar();
- scrollbar.style.display = scrollHeight ? "block" : "none";
- if (scrollHeight) {
- scrollbarInner.style.height = scrollHeight + "px";
- scrollbar.style.height = scroller.offsetHeight + "px";
- if (scrollTop != null) scrollbar.scrollTop = scrollTop;
- }
- // Position the mover div to align with the current virtual scroll position
- mover.style.top = (displayOffset * textHeight() - scrollbar.scrollTop) + "px";
- }
-
- // On Mac OS X Lion and up, detect whether the mouse is plugged in by measuring
- // the width of a div with a scrollbar in it. If the width is <= 1, then
- // the mouse isn't plugged in and scrollbars should overlap the content.
- function overlapScrollbars() {
- var tmpSb = document.createElement('div'),
- tmpSbInner = document.createElement('div');
- tmpSb.className = "CodeMirror-scrollbar";
- tmpSb.style.cssText = "position: absolute; left: -9999px; height: 100px;";
- tmpSbInner.className = "CodeMirror-scrollbar-inner";
- tmpSbInner.style.height = "200px";
- tmpSb.appendChild(tmpSbInner);
-
- document.body.appendChild(tmpSb);
- var result = (tmpSb.offsetWidth <= 1);
- document.body.removeChild(tmpSb);
- return result;
- }
-
- function computeMaxLength() {
- var maxLineLength = 0;
- maxLine = ""; maxLineChanged = true;
- doc.iter(0, doc.size, function(line) {
- var l = line.text;
- if (!line.hidden && l.length > maxLineLength) {
- maxLineLength = l.length; maxLine = l;
- }
- });
- updateMaxLine = false;
- }
-
- function replaceRange(code, from, to) {
- from = clipPos(from);
- if (!to) to = from; else to = clipPos(to);
- code = splitLines(code);
- function adjustPos(pos) {
- if (posLess(pos, from)) return pos;
- if (!posLess(to, pos)) return end;
- var line = pos.line + code.length - (to.line - from.line) - 1;
- var ch = pos.ch;
- if (pos.line == to.line)
- ch += code[code.length-1].length - (to.ch - (to.line == from.line ? from.ch : 0));
- return {line: line, ch: ch};
- }
- var end;
- replaceRange1(code, from, to, function(end1) {
- end = end1;
- return {from: adjustPos(sel.from), to: adjustPos(sel.to)};
- });
- return end;
- }
- function replaceSelection(code, collapse) {
- replaceRange1(splitLines(code), sel.from, sel.to, function(end) {
- if (collapse == "end") return {from: end, to: end};
- else if (collapse == "start") return {from: sel.from, to: sel.from};
- else return {from: sel.from, to: end};
- });
- }
- function replaceRange1(code, from, to, computeSel) {
- var endch = code.length == 1 ? code[0].length + from.ch : code[code.length-1].length;
- var newSel = computeSel({line: from.line + code.length - 1, ch: endch});
- updateLines(from, to, code, newSel.from, newSel.to);
- }
-
- function getRange(from, to, lineSep) {
- var l1 = from.line, l2 = to.line;
- if (l1 == l2) return getLine(l1).text.slice(from.ch, to.ch);
- var code = [getLine(l1).text.slice(from.ch)];
- doc.iter(l1 + 1, l2, function(line) { code.push(line.text); });
- code.push(getLine(l2).text.slice(0, to.ch));
- return code.join(lineSep || "\n");
- }
- function getSelection(lineSep) {
- return getRange(sel.from, sel.to, lineSep);
- }
-
- var pollingFast = false; // Ensures slowPoll doesn't cancel fastPoll
- function slowPoll() {
- if (pollingFast) return;
- poll.set(options.pollInterval, function() {
- startOperation();
- readInput();
- if (focused) slowPoll();
- endOperation();
- });
- }
- function fastPoll() {
- var missed = false;
- pollingFast = true;
- function p() {
- startOperation();
- var changed = readInput();
- if (!changed && !missed) {missed = true; poll.set(60, p);}
- else {pollingFast = false; slowPoll();}
- endOperation();
- }
- poll.set(20, p);
- }
-
- // Previnput is a hack to work with IME. If we reset the textarea
- // on every change, that breaks IME. So we look for changes
- // compared to the previous content instead. (Modern browsers have
- // events that indicate IME taking place, but these are not widely
- // supported or compatible enough yet to rely on.)
- var prevInput = "";
- function readInput() {
- if (leaveInputAlone || !focused || hasSelection(input) || options.readOnly) return false;
- var text = input.value;
- if (text == prevInput) return false;
- shiftSelecting = null;
- var same = 0, l = Math.min(prevInput.length, text.length);
- while (same < l && prevInput[same] == text[same]) ++same;
- if (same < prevInput.length)
- sel.from = {line: sel.from.line, ch: sel.from.ch - (prevInput.length - same)};
- else if (overwrite && posEq(sel.from, sel.to))
- sel.to = {line: sel.to.line, ch: Math.min(getLine(sel.to.line).text.length, sel.to.ch + (text.length - same))};
- replaceSelection(text.slice(same), "end");
- if (text.length > 1000) { input.value = prevInput = ""; }
- else prevInput = text;
- return true;
- }
- function resetInput(user) {
- if (!posEq(sel.from, sel.to)) {
- prevInput = "";
- input.value = getSelection();
- selectInput(input);
- } else if (user) prevInput = input.value = "";
- }
-
- function focusInput() {
- if (options.readOnly != "nocursor") input.focus();
- }
-
- function scrollEditorIntoView() {
- var rect = cursor.getBoundingClientRect();
- // IE returns bogus coordinates when the instance sits inside of an iframe and the cursor is hidden
- if (ie && rect.top == rect.bottom) return;
- var winH = window.innerHeight || Math.max(document.body.offsetHeight, document.documentElement.offsetHeight);
- if (rect.top < 0 || rect.bottom > winH) scrollCursorIntoView();
- }
- function scrollCursorIntoView() {
- var coords = calculateCursorCoords();
- return scrollIntoView(coords.x, coords.y, coords.x, coords.yBot);
- }
- function calculateCursorCoords() {
- var cursor = localCoords(sel.inverted ? sel.from : sel.to);
- var x = options.lineWrapping ? Math.min(cursor.x, lineSpace.offsetWidth) : cursor.x;
- return {x: x, y: cursor.y, yBot: cursor.yBot};
- }
- function scrollIntoView(x1, y1, x2, y2) {
- var scrollPos = calculateScrollPos(x1, y1, x2, y2), scrolled = false;
- if (scrollPos.scrollLeft != null) {scroller.scrollLeft = scrollPos.scrollLeft; scrolled = true;}
- if (scrollPos.scrollTop != null) {scrollbar.scrollTop = scrollPos.scrollTop; scrolled = true;}
- if (scrolled && options.onScroll) options.onScroll(instance);
- }
- function calculateScrollPos(x1, y1, x2, y2) {
- var pl = paddingLeft(), pt = paddingTop();
- y1 += pt; y2 += pt; x1 += pl; x2 += pl;
- var screen = scroller.clientHeight, screentop = scrollbar.scrollTop, result = {};
- var docBottom = scroller.scrollHeight;
- var atTop = y1 < pt + 10, atBottom = y2 + pt > docBottom - 10;;
- if (y1 < screentop) result.scrollTop = atTop ? 0 : Math.max(0, y1);
- else if (y2 > screentop + screen) result.scrollTop = (atBottom ? docBottom : y2) - screen;
-
- var screenw = scroller.clientWidth, screenleft = scroller.scrollLeft;
- var gutterw = options.fixedGutter ? gutter.clientWidth : 0;
- var atLeft = x1 < gutterw + pl + 10;
- if (x1 < screenleft + gutterw || atLeft) {
- if (atLeft) x1 = 0;
- result.scrollLeft = Math.max(0, x1 - 10 - gutterw);
- } else if (x2 > screenw + screenleft - 3) {
- result.scrollLeft = x2 + 10 - screenw;
- }
- return result;
- }
-
- function visibleLines(scrollTop) {
- var lh = textHeight(), top = (scrollTop != null ? scrollTop : scrollbar.scrollTop) - paddingTop();
- var fromHeight = Math.max(0, Math.floor(top / lh));
- var toHeight = Math.ceil((top + scroller.clientHeight) / lh);
- return {from: lineAtHeight(doc, fromHeight),
- to: lineAtHeight(doc, toHeight)};
- }
- // Uses a set of changes plus the current scroll position to
- // determine which DOM updates have to be made, and makes the
- // updates.
- function updateDisplay(changes, suppressCallback, scrollTop) {
- if (!scroller.clientWidth) {
- showingFrom = showingTo = displayOffset = 0;
- return;
- }
- // Compute the new visible window
- // If scrollTop is specified, use that to determine which lines
- // to render instead of the current scrollbar position.
- var visible = visibleLines(scrollTop);
- // Bail out if the visible area is already rendered and nothing changed.
- if (changes !== true && changes.length == 0 && visible.from > showingFrom && visible.to < showingTo) {
- updateVerticalScroll(scrollTop);
- return;
- }
- var from = Math.max(visible.from - 100, 0), to = Math.min(doc.size, visible.to + 100);
- if (showingFrom < from && from - showingFrom < 20) from = showingFrom;
- if (showingTo > to && showingTo - to < 20) to = Math.min(doc.size, showingTo);
-
- // Create a range of theoretically intact lines, and punch holes
- // in that using the change info.
- var intact = changes === true ? [] :
- computeIntact([{from: showingFrom, to: showingTo, domStart: 0}], changes);
- // Clip off the parts that won't be visible
- var intactLines = 0;
- for (var i = 0; i < intact.length; ++i) {
- var range = intact[i];
- if (range.from < from) {range.domStart += (from - range.from); range.from = from;}
- if (range.to > to) range.to = to;
- if (range.from >= range.to) intact.splice(i--, 1);
- else intactLines += range.to - range.from;
- }
- if (intactLines == to - from && from == showingFrom && to == showingTo) {
- updateVerticalScroll(scrollTop);
- return;
- }
- intact.sort(function(a, b) {return a.domStart - b.domStart;});
-
- var th = textHeight(), gutterDisplay = gutter.style.display;
- lineDiv.style.display = "none";
- patchDisplay(from, to, intact);
- lineDiv.style.display = gutter.style.display = "";
-
- var different = from != showingFrom || to != showingTo || lastSizeC != scroller.clientHeight + th;
- // This is just a bogus formula that detects when the editor is
- // resized or the font size changes.
- if (different) lastSizeC = scroller.clientHeight + th;
- showingFrom = from; showingTo = to;
- displayOffset = heightAtLine(doc, from);
-
- // Since this is all rather error prone, it is honoured with the
- // only assertion in the whole file.
- if (lineDiv.childNodes.length != showingTo - showingFrom)
- throw new Error("BAD PATCH! " + JSON.stringify(intact) + " size=" + (showingTo - showingFrom) +
- " nodes=" + lineDiv.childNodes.length);
-
- function checkHeights() {
- var curNode = lineDiv.firstChild, heightChanged = false;
- doc.iter(showingFrom, showingTo, function(line) {
- if (!line.hidden) {
- var height = Math.round(curNode.offsetHeight / th) || 1;
- if (line.height != height) {
- updateLineHeight(line, height);
- gutterDirty = heightChanged = true;
- }
- }
- curNode = curNode.nextSibling;
- });
- return heightChanged;
- }
-
- if (options.lineWrapping) {
- checkHeights();
- var scrollHeight = needsScrollbar();
- var shouldHaveScrollbar = scrollHeight ? "block" : "none";
- if (scrollbar.style.display != shouldHaveScrollbar) {
- scrollbar.style.display = shouldHaveScrollbar;
- if (scrollHeight) scrollbarInner.style.height = scrollHeight + "px";
- checkHeights();
- }
- }
-
- gutter.style.display = gutterDisplay;
- if (different || gutterDirty) {
- // If the gutter grew in size, re-check heights. If those changed, re-draw gutter.
- updateGutter() && options.lineWrapping && checkHeights() && updateGutter();
- }
- updateVerticalScroll(scrollTop);
- updateSelection();
- if (!suppressCallback && options.onUpdate) options.onUpdate(instance);
- return true;
- }
-
- function computeIntact(intact, changes) {
- for (var i = 0, l = changes.length || 0; i < l; ++i) {
- var change = changes[i], intact2 = [], diff = change.diff || 0;
- for (var j = 0, l2 = intact.length; j < l2; ++j) {
- var range = intact[j];
- if (change.to <= range.from && change.diff)
- intact2.push({from: range.from + diff, to: range.to + diff,
- domStart: range.domStart});
- else if (change.to <= range.from || change.from >= range.to)
- intact2.push(range);
- else {
- if (change.from > range.from)
- intact2.push({from: range.from, to: change.from, domStart: range.domStart});
- if (change.to < range.to)
- intact2.push({from: change.to + diff, to: range.to + diff,
- domStart: range.domStart + (change.to - range.from)});
- }
- }
- intact = intact2;
- }
- return intact;
- }
-
- function patchDisplay(from, to, intact) {
- // The first pass removes the DOM nodes that aren't intact.
- if (!intact.length) lineDiv.innerHTML = "";
- else {
- function killNode(node) {
- var tmp = node.nextSibling;
- node.parentNode.removeChild(node);
- return tmp;
- }
- var domPos = 0, curNode = lineDiv.firstChild, n;
- for (var i = 0; i < intact.length; ++i) {
- var cur = intact[i];
- while (cur.domStart > domPos) {curNode = killNode(curNode); domPos++;}
- for (var j = 0, e = cur.to - cur.from; j < e; ++j) {curNode = curNode.nextSibling; domPos++;}
- }
- while (curNode) curNode = killNode(curNode);
- }
- // This pass fills in the lines that actually changed.
- var nextIntact = intact.shift(), curNode = lineDiv.firstChild, j = from;
- var scratch = document.createElement("div");
- doc.iter(from, to, function(line) {
- if (nextIntact && nextIntact.to == j) nextIntact = intact.shift();
- if (!nextIntact || nextIntact.from > j) {
- if (line.hidden) var html = scratch.innerHTML = "<pre></pre>";
- else {
- var html = '<pre' + (line.className ? ' class="' + line.className + '"' : '') + '>'
- + line.getHTML(makeTab) + '</pre>';
- // Kludge to make sure the styled element lies behind the selection (by z-index)
- if (line.bgClassName)
- html = '<div style="position: relative"><pre class="' + line.bgClassName +
- '" style="position: absolute; left: 0; right: 0; top: 0; bottom: 0; z-index: -2"> </pre>' + html + "</div>";
- }
- scratch.innerHTML = html;
- lineDiv.insertBefore(scratch.firstChild, curNode);
- } else {
- curNode = curNode.nextSibling;
- }
- ++j;
- });
- }
-
- function updateGutter() {
- if (!options.gutter && !options.lineNumbers) return;
- var hText = mover.offsetHeight, hEditor = scroller.clientHeight;
- gutter.style.height = (hText - hEditor < 2 ? hEditor : hText) + "px";
- var html = [], i = showingFrom, normalNode;
- doc.iter(showingFrom, Math.max(showingTo, showingFrom + 1), function(line) {
- if (line.hidden) {
- html.push("<pre></pre>");
- } else {
- var marker = line.gutterMarker;
- var text = options.lineNumbers ? options.lineNumberFormatter(i + options.firstLineNumber) : null;
- if (marker && marker.text)
- text = marker.text.replace("%N%", text != null ? text : "");
- else if (text == null)
- text = "\u00a0";
- html.push((marker && marker.style ? '<pre class="' + marker.style + '">' : "<pre>"), text);
- for (var j = 1; j < line.height; ++j) html.push("<br/> ");
- html.push("</pre>");
- if (!marker) normalNode = i;
- }
- ++i;
- });
- gutter.style.display = "none";
- gutterText.innerHTML = html.join("");
- // Make sure scrolling doesn't cause number gutter size to pop
- if (normalNode != null && options.lineNumbers) {
- var node = gutterText.childNodes[normalNode - showingFrom];
- var minwidth = String(doc.size).length, val = eltText(node.firstChild), pad = "";
- while (val.length + pad.length < minwidth) pad += "\u00a0";
- if (pad) node.insertBefore(document.createTextNode(pad), node.firstChild);
- }
- gutter.style.display = "";
- var resized = Math.abs((parseInt(lineSpace.style.marginLeft) || 0) - gutter.offsetWidth) > 2;
- lineSpace.style.marginLeft = gutter.offsetWidth + "px";
- gutterDirty = false;
- return resized;
- }
- function updateSelection() {
- var collapsed = posEq(sel.from, sel.to);
- var fromPos = localCoords(sel.from, true);
- var toPos = collapsed ? fromPos : localCoords(sel.to, true);
- var headPos = sel.inverted ? fromPos : toPos, th = textHeight();
- var wrapOff = eltOffset(wrapper), lineOff = eltOffset(lineDiv);
- inputDiv.style.top = Math.max(0, Math.min(scroller.offsetHeight, headPos.y + lineOff.top - wrapOff.top)) + "px";
- inputDiv.style.left = Math.max(0, Math.min(scroller.offsetWidth, headPos.x + lineOff.left - wrapOff.left)) + "px";
- if (collapsed) {
- cursor.style.top = headPos.y + "px";
- cursor.style.left = (options.lineWrapping ? Math.min(headPos.x, lineSpace.offsetWidth) : headPos.x) + "px";
- cursor.style.display = "";
- selectionDiv.style.display = "none";
- } else {
- var sameLine = fromPos.y == toPos.y, html = "";
- var clientWidth = lineSpace.clientWidth || lineSpace.offsetWidth;
- var clientHeight = lineSpace.clientHeight || lineSpace.offsetHeight;
- function add(left, top, right, height) {
- var rstyle = quirksMode ? "width: " + (!right ? clientWidth : clientWidth - right - left) + "px"
- : "right: " + right + "px";
- html += '<div class="CodeMirror-selected" style="position: absolute; left: ' + left +
- 'px; top: ' + top + 'px; ' + rstyle + '; height: ' + height + 'px"></div>';
- }
- if (sel.from.ch && fromPos.y >= 0) {
- var right = sameLine ? clientWidth - toPos.x : 0;
- add(fromPos.x, fromPos.y, right, th);
- }
- var middleStart = Math.max(0, fromPos.y + (sel.from.ch ? th : 0));
- var middleHeight = Math.min(toPos.y, clientHeight) - middleStart;
- if (middleHeight > 0.2 * th)
- add(0, middleStart, 0, middleHeight);
- if ((!sameLine || !sel.from.ch) && toPos.y < clientHeight - .5 * th)
- add(0, toPos.y, clientWidth - toPos.x, th);
- selectionDiv.innerHTML = html;
- cursor.style.display = "none";
- selectionDiv.style.display = "";
- }
- }
-
- function setShift(val) {
- if (val) shiftSelecting = shiftSelecting || (sel.inverted ? sel.to : sel.from);
- else shiftSelecting = null;
- }
- function setSelectionUser(from, to) {
- var sh = shiftSelecting && clipPos(shiftSelecting);
- if (sh) {
- if (posLess(sh, from)) from = sh;
- else if (posLess(to, sh)) to = sh;
- }
- setSelection(from, to);
- userSelChange = true;
- }
- // Update the selection. Last two args are only used by
- // updateLines, since they have to be expressed in the line
- // numbers before the update.
- function setSelection(from, to, oldFrom, oldTo) {
- goalColumn = null;
- if (oldFrom == null) {oldFrom = sel.from.line; oldTo = sel.to.line;}
- if (posEq(sel.from, from) && posEq(sel.to, to)) return;
- if (posLess(to, from)) {var tmp = to; to = from; from = tmp;}
-
- // Skip over hidden lines.
- if (from.line != oldFrom) {
- var from1 = skipHidden(from, oldFrom, sel.from.ch);
- // If there is no non-hidden line left, force visibility on current line
- if (!from1) setLineHidden(from.line, false);
- else from = from1;
- }
- if (to.line != oldTo) to = skipHidden(to, oldTo, sel.to.ch);
-
- if (posEq(from, to)) sel.inverted = false;
- else if (posEq(from, sel.to)) sel.inverted = false;
- else if (posEq(to, sel.from)) sel.inverted = true;
-
- if (options.autoClearEmptyLines && posEq(sel.from, sel.to)) {
- var head = sel.inverted ? from : to;
- if (head.line != sel.from.line && sel.from.line < doc.size) {
- var oldLine = getLine(sel.from.line);
- if (/^\s+$/.test(oldLine.text))
- setTimeout(operation(function() {
- if (oldLine.parent && /^\s+$/.test(oldLine.text)) {
- var no = lineNo(oldLine);
- replaceRange("", {line: no, ch: 0}, {line: no, ch: oldLine.text.length});
- }
- }, 10));
- }
- }
-
- sel.from = from; sel.to = to;
- selectionChanged = true;
- }
- function skipHidden(pos, oldLine, oldCh) {
- function getNonHidden(dir) {
- var lNo = pos.line + dir, end = dir == 1 ? doc.size : -1;
- while (lNo != end) {
- var line = getLine(lNo);
- if (!line.hidden) {
- var ch = pos.ch;
- if (toEnd || ch > oldCh || ch > line.text.length) ch = line.text.length;
- return {line: lNo, ch: ch};
- }
- lNo += dir;
- }
- }
- var line = getLine(pos.line);
- var toEnd = pos.ch == line.text.length && pos.ch != oldCh;
- if (!line.hidden) return pos;
- if (pos.line >= oldLine) return getNonHidden(1) || getNonHidden(-1);
- else return getNonHidden(-1) || getNonHidden(1);
- }
- function setCursor(line, ch, user) {
- var pos = clipPos({line: line, ch: ch || 0});
- (user ? setSelectionUser : setSelection)(pos, pos);
- }
-
- function clipLine(n) {return Math.max(0, Math.min(n, doc.size-1));}
- function clipPos(pos) {
- if (pos.line < 0) return {line: 0, ch: 0};
- if (pos.line >= doc.size) return {line: doc.size-1, ch: getLine(doc.size-1).text.length};
- var ch = pos.ch, linelen = getLine(pos.line).text.length;
- if (ch == null || ch > linelen) return {line: pos.line, ch: linelen};
- else if (ch < 0) return {line: pos.line, ch: 0};
- else return pos;
- }
-
- function findPosH(dir, unit) {
- var end = sel.inverted ? sel.from : sel.to, line = end.line, ch = end.ch;
- var lineObj = getLine(line);
- function findNextLine() {
- for (var l = line + dir, e = dir < 0 ? -1 : doc.size; l != e; l += dir) {
- var lo = getLine(l);
- if (!lo.hidden) { line = l; lineObj = lo; return true; }
- }
- }
- function moveOnce(boundToLine) {
- if (ch == (dir < 0 ? 0 : lineObj.text.length)) {
- if (!boundToLine && findNextLine()) ch = dir < 0 ? lineObj.text.length : 0;
- else return false;
- } else ch += dir;
- return true;
- }
- if (unit == "char") moveOnce();
- else if (unit == "column") moveOnce(true);
- else if (unit == "word") {
- var sawWord = false;
- for (;;) {
- if (dir < 0) if (!moveOnce()) break;
- if (isWordChar(lineObj.text.charAt(ch))) sawWord = true;
- else if (sawWord) {if (dir < 0) {dir = 1; moveOnce();} break;}
- if (dir > 0) if (!moveOnce()) break;
- }
- }
- return {line: line, ch: ch};
- }
- function moveH(dir, unit) {
- var pos = dir < 0 ? sel.from : sel.to;
- if (shiftSelecting || posEq(sel.from, sel.to)) pos = findPosH(dir, unit);
- setCursor(pos.line, pos.ch, true);
- }
- function deleteH(dir, unit) {
- if (!posEq(sel.from, sel.to)) replaceRange("", sel.from, sel.to);
- else if (dir < 0) replaceRange("", findPosH(dir, unit), sel.to);
- else replaceRange("", sel.from, findPosH(dir, unit));
- userSelChange = true;
- }
- var goalColumn = null;
- function moveV(dir, unit) {
- var dist = 0, pos = localCoords(sel.inverted ? sel.from : sel.to, true);
- if (goalColumn != null) pos.x = goalColumn;
- if (unit == "page") dist = Math.min(scroller.clientHeight, window.innerHeight || document.documentElement.clientHeight);
- else if (unit == "line") dist = textHeight();
- var target = coordsChar(pos.x, pos.y + dist * dir + 2);
- if (unit == "page") scrollbar.scrollTop += localCoords(target, true).y - pos.y;
- setCursor(target.line, target.ch, true);
- goalColumn = pos.x;
- }
-
- function findWordAt(pos) {
- var line = getLine(pos.line).text;
- var start = pos.ch, end = pos.ch;
- var check = isWordChar(line.charAt(start < line.length ? start : start - 1)) ?
- isWordChar : function(ch) {return !isWordChar(ch);};
- while (start > 0 && check(line.charAt(start - 1))) --start;
- while (end < line.length && check(line.charAt(end))) ++end;
- return {from: {line: pos.line, ch: start}, to: {line: pos.line, ch: end}};
- }
- function selectLine(line) {
- setSelectionUser({line: line, ch: 0}, clipPos({line: line + 1, ch: 0}));
- }
- function indentSelected(mode) {
- if (posEq(sel.from, sel.to)) return indentLine(sel.from.line, mode);
- var e = sel.to.line - (sel.to.ch ? 0 : 1);
- for (var i = sel.from.line; i <= e; ++i) indentLine(i, mode);
- }
-
- function indentLine(n, how) {
- if (!how) how = "add";
- if (how == "smart") {
- if (!mode.indent) how = "prev";
- else var state = getStateBefore(n);
- }
-
- var line = getLine(n), curSpace = line.indentation(options.tabSize),
- curSpaceString = line.text.match(/^\s*/)[0], indentation;
- if (how == "smart") {
- indentation = mode.indent(state, line.text.slice(curSpaceString.length), line.text);
- if (indentation == Pass) how = "prev";
- }
- if (how == "prev") {
- if (n) indentation = getLine(n-1).indentation(options.tabSize);
- else indentation = 0;
- }
- else if (how == "add") indentation = curSpace + options.indentUnit;
- else if (how == "subtract") indentation = curSpace - options.indentUnit;
- indentation = Math.max(0, indentation);
- var diff = indentation - curSpace;
-
- var indentString = "", pos = 0;
- if (options.indentWithTabs)
- for (var i = Math.floor(indentation / options.tabSize); i; --i) {pos += options.tabSize; indentString += "\t";}
- while (pos < indentation) {++pos; indentString += " ";}
-
- replaceRange(indentString, {line: n, ch: 0}, {line: n, ch: curSpaceString.length});
- }
-
- function loadMode() {
- mode = CodeMirror.getMode(options, options.mode);
- doc.iter(0, doc.size, function(line) { line.stateAfter = null; });
- work = [0];
- startWorker();
- }
- function gutterChanged() {
- var visible = options.gutter || options.lineNumbers;
- gutter.style.display = visible ? "" : "none";
- if (visible) gutterDirty = true;
- else lineDiv.parentNode.style.marginLeft = 0;
- }
- function wrappingChanged(from, to) {
- if (options.lineWrapping) {
- wrapper.className += " CodeMirror-wrap";
- var perLine = scroller.clientWidth / charWidth() - 3;
- doc.iter(0, doc.size, function(line) {
- if (line.hidden) return;
- var guess = Math.ceil(line.text.length / perLine) || 1;
- if (guess != 1) updateLineHeight(line, guess);
- });
- lineSpace.style.width = code.style.width = "";
- widthForcer.style.left = "";
- } else {
- wrapper.className = wrapper.className.replace(" CodeMirror-wrap", "");
- maxLine = ""; maxLineChanged = true;
- doc.iter(0, doc.size, function(line) {
- if (line.height != 1 && !line.hidden) updateLineHeight(line, 1);
- if (line.text.length > maxLine.length) maxLine = line.text;
- });
- }
- changes.push({from: 0, to: doc.size});
- }
- function makeTab(col) {
- var w = options.tabSize - col % options.tabSize, cached = tabCache[w];
- if (cached) return cached;
- for (var str = '<span class="cm-tab">', i = 0; i < w; ++i) str += " ";
- return (tabCache[w] = {html: str + "</span>", width: w});
- }
- function themeChanged() {
- scroller.className = scroller.className.replace(/\s*cm-s-\S+/g, "") +
- options.theme.replace(/(^|\s)\s*/g, " cm-s-");
- }
- function keyMapChanged() {
- var style = keyMap[options.keyMap].style;
- wrapper.className = wrapper.className.replace(/\s*cm-keymap-\S+/g, "") +
- (style ? " cm-keymap-" + style : "");
- }
-
- function TextMarker() { this.set = []; }
- TextMarker.prototype.clear = operation(function() {
- var min = Infinity, max = -Infinity;
- for (var i = 0, e = this.set.length; i < e; ++i) {
- var line = this.set[i], mk = line.marked;
- if (!mk || !line.parent) continue;
- var lineN = lineNo(line);
- min = Math.min(min, lineN); max = Math.max(max, lineN);
- for (var j = 0; j < mk.length; ++j)
- if (mk[j].marker == this) mk.splice(j--, 1);
- }
- if (min != Infinity)
- changes.push({from: min, to: max + 1});
- });
- TextMarker.prototype.find = function() {
- var from, to;
- for (var i = 0, e = this.set.length; i < e; ++i) {
- var line = this.set[i], mk = line.marked;
- for (var j = 0; j < mk.length; ++j) {
- var mark = mk[j];
- if (mark.marker == this) {
- if (mark.from != null || mark.to != null) {
- var found = lineNo(line);
- if (found != null) {
- if (mark.from != null) from = {line: found, ch: mark.from};
- if (mark.to != null) to = {line: found, ch: mark.to};
- }
- }
- }
- }
- }
- return {from: from, to: to};
- };
-
- function markText(from, to, className) {
- from = clipPos(from); to = clipPos(to);
- var tm = new TextMarker();
- if (!posLess(from, to)) return tm;
- function add(line, from, to, className) {
- getLine(line).addMark(new MarkedText(from, to, className, tm));
- }
- if (from.line == to.line) add(from.line, from.ch, to.ch, className);
- else {
- add(from.line, from.ch, null, className);
- for (var i = from.line + 1, e = to.line; i < e; ++i)
- add(i, null, null, className);
- add(to.line, null, to.ch, className);
- }
- changes.push({from: from.line, to: to.line + 1});
- return tm;
- }
-
- function setBookmark(pos) {
- pos = clipPos(pos);
- var bm = new Bookmark(pos.ch);
- getLine(pos.line).addMark(bm);
- return bm;
- }
-
- function findMarksAt(pos) {
- pos = clipPos(pos);
- var markers = [], marked = getLine(pos.line).marked;
- if (!marked) return markers;
- for (var i = 0, e = marked.length; i < e; ++i) {
- var m = marked[i];
- if ((m.from == null || m.from <= pos.ch) &&
- (m.to == null || m.to >= pos.ch))
- markers.push(m.marker || m);
- }
- return markers;
- }
-
- function addGutterMarker(line, text, className) {
- if (typeof line == "number") line = getLine(clipLine(line));
- line.gutterMarker = {text: text, style: className};
- gutterDirty = true;
- return line;
- }
- function removeGutterMarker(line) {
- if (typeof line == "number") line = getLine(clipLine(line));
- line.gutterMarker = null;
- gutterDirty = true;
- }
-
- function changeLine(handle, op) {
- var no = handle, line = handle;
- if (typeof handle == "number") line = getLine(clipLine(handle));
- else no = lineNo(handle);
- if (no == null) return null;
- if (op(line, no)) changes.push({from: no, to: no + 1});
- else return null;
- return line;
- }
- function setLineClass(handle, className, bgClassName) {
- return changeLine(handle, function(line) {
- if (line.className != className || line.bgClassName != bgClassName) {
- line.className = className;
- line.bgClassName = bgClassName;
- return true;
- }
- });
- }
- function setLineHidden(handle, hidden) {
- return changeLine(handle, function(line, no) {
- if (line.hidden != hidden) {
- line.hidden = hidden;
- if (!options.lineWrapping) {
- var l = line.text;
- if (hidden && l.length == maxLine.length) {
- updateMaxLine = true;
- } else if (!hidden && l.length > maxLine.length) {
- maxLine = l; updateMaxLine = false;
- }
- }
- updateLineHeight(line, hidden ? 0 : 1);
- var fline = sel.from.line, tline = sel.to.line;
- if (hidden && (fline == no || tline == no)) {
- var from = fline == no ? skipHidden({line: fline, ch: 0}, fline, 0) : sel.from;
- var to = tline == no ? skipHidden({line: tline, ch: 0}, tline, 0) : sel.to;
- // Can't hide the last visible line, we'd have no place to put the cursor
- if (!to) return;
- setSelection(from, to);
- }
- return (gutterDirty = true);
- }
- });
- }
-
- function lineInfo(line) {
- if (typeof line == "number") {
- if (!isLine(line)) return null;
- var n = line;
- line = getLine(line);
- if (!line) return null;
- } else {
- var n = lineNo(line);
- if (n == null) return null;
- }
- var marker = line.gutterMarker;
- return {line: n, handle: line, text: line.text, markerText: marker && marker.text,
- markerClass: marker && marker.style, lineClass: line.className, bgClass: line.bgClassName};
- }
-
- function stringWidth(str) {
- measure.innerHTML = "<pre><span>x</span></pre>";
- measure.firstChild.firstChild.firstChild.nodeValue = str;
- return measure.firstChild.firstChild.offsetWidth || 10;
- }
- // These are used to go from pixel positions to character
- // positions, taking varying character widths into account.
- function charFromX(line, x) {
- if (x <= 0) return 0;
- var lineObj = getLine(line), text = lineObj.text;
- function getX(len) {
- return measureLine(lineObj, len).left;
- }
- var from = 0, fromX = 0, to = text.length, toX;
- // Guess a suitable upper bound for our search.
- var estimated = Math.min(to, Math.ceil(x / charWidth()));
- for (;;) {
- var estX = getX(estimated);
- if (estX <= x && estimated < to) estimated = Math.min(to, Math.ceil(estimated * 1.2));
- else {toX = estX; to = estimated; break;}
- }
- if (x > toX) return to;
- // Try to guess a suitable lower bound as well.
- estimated = Math.floor(to * 0.8); estX = getX(estimated);
- if (estX < x) {from = estimated; fromX = estX;}
- // Do a binary search between these bounds.
- for (;;) {
- if (to - from <= 1) return (toX - x > x - fromX) ? from : to;
- var middle = Math.ceil((from + to) / 2), middleX = getX(middle);
- if (middleX > x) {to = middle; toX = middleX;}
- else {from = middle; fromX = middleX;}
- }
- }
-
- var tempId = "CodeMirror-temp-" + Math.floor(Math.random() * 0xffffff).toString(16);
- function measureLine(line, ch) {
- if (ch == 0) return {top: 0, left: 0};
- var wbr = options.lineWrapping && ch < line.text.length &&
- spanAffectsWrapping.test(line.text.slice(ch - 1, ch + 1));
- measure.innerHTML = "<pre>" + line.getHTML(makeTab, ch, tempId, wbr) + "</pre>";
- var elt = document.getElementById(tempId);
- var top = elt.offsetTop, left = elt.offsetLeft;
- // Older IEs report zero offsets for spans directly after a wrap
- if (ie && top == 0 && left == 0) {
- var backup = document.createElement("span");
- backup.innerHTML = "x";
- elt.parentNode.insertBefore(backup, elt.nextSibling);
- top = backup.offsetTop;
- }
- return {top: top, left: left};
- }
- function localCoords(pos, inLineWrap) {
- var x, lh = textHeight(), y = lh * (heightAtLine(doc, pos.line) - (inLineWrap ? displayOffset : 0));
- if (pos.ch == 0) x = 0;
- else {
- var sp = measureLine(getLine(pos.line), pos.ch);
- x = sp.left;
- if (options.lineWrapping) y += Math.max(0, sp.top);
- }
- return {x: x, y: y, yBot: y + lh};
- }
- // Coords must be lineSpace-local
- function coordsChar(x, y) {
- if (y < 0) y = 0;
- var th = textHeight(), cw = charWidth(), heightPos = displayOffset + Math.floor(y / th);
- var lineNo = lineAtHeight(doc, heightPos);
- if (lineNo >= doc.size) return {line: doc.size - 1, ch: getLine(doc.size - 1).text.length};
- var lineObj = getLine(lineNo), text = lineObj.text;
- var tw = options.lineWrapping, innerOff = tw ? heightPos - heightAtLine(doc, lineNo) : 0;
- if (x <= 0 && innerOff == 0) return {line: lineNo, ch: 0};
- function getX(len) {
- var sp = measureLine(lineObj, len);
- if (tw) {
- var off = Math.round(sp.top / th);
- return Math.max(0, sp.left + (off - innerOff) * scroller.clientWidth);
- }
- return sp.left;
- }
- var from = 0, fromX = 0, to = text.length, toX;
- // Guess a suitable upper bound for our search.
- var estimated = Math.min(to, Math.ceil((x + innerOff * scroller.clientWidth * .9) / cw));
- for (;;) {
- var estX = getX(estimated);
- if (estX <= x && estimated < to) estimated = Math.min(to, Math.ceil(estimated * 1.2));
- else {toX = estX; to = estimated; break;}
- }
- if (x > toX) return {line: lineNo, ch: to};
- // Try to guess a suitable lower bound as well.
- estimated = Math.floor(to * 0.8); estX = getX(estimated);
- if (estX < x) {from = estimated; fromX = estX;}
- // Do a binary search between these bounds.
- for (;;) {
- if (to - from <= 1) return {line: lineNo, ch: (toX - x > x - fromX) ? from : to};
- var middle = Math.ceil((from + to) / 2), middleX = getX(middle);
- if (middleX > x) {to = middle; toX = middleX;}
- else {from = middle; fromX = middleX;}
- }
- }
- function pageCoords(pos) {
- var local = localCoords(pos, true), off = eltOffset(lineSpace);
- return {x: off.left + local.x, y: off.top + local.y, yBot: off.top + local.yBot};
- }
-
- var cachedHeight, cachedHeightFor, measureText;
- function textHeight() {
- if (measureText == null) {
- measureText = "<pre>";
- for (var i = 0; i < 49; ++i) measureText += "x<br/>";
- measureText += "x</pre>";
- }
- var offsetHeight = lineDiv.clientHeight;
- if (offsetHeight == cachedHeightFor) return cachedHeight;
- cachedHeightFor = offsetHeight;
- measure.innerHTML = measureText;
- cachedHeight = measure.firstChild.offsetHeight / 50 || 1;
- measure.innerHTML = "";
- return cachedHeight;
- }
- var cachedWidth, cachedWidthFor = 0;
- function charWidth() {
- if (scroller.clientWidth == cachedWidthFor) return cachedWidth;
- cachedWidthFor = scroller.clientWidth;
- return (cachedWidth = stringWidth("x"));
- }
- function paddingTop() {return lineSpace.offsetTop;}
- function paddingLeft() {return lineSpace.offsetLeft;}
-
- function posFromMouse(e, liberal) {
- var offW = eltOffset(scroller, true), x, y;
- // Fails unpredictably on IE[67] when mouse is dragged around quickly.
- try { x = e.clientX; y = e.clientY; } catch (e) { return null; }
- // This is a mess of a heuristic to try and determine whether a
- // scroll-bar was clicked or not, and to return null if one was
- // (and !liberal).
- if (!liberal && (x - offW.left > scroller.clientWidth || y - offW.top > scroller.clientHeight))
- return null;
- var offL = eltOffset(lineSpace, true);
- return coordsChar(x - offL.left, y - offL.top);
- }
- function onContextMenu(e) {
- var pos = posFromMouse(e), scrollPos = scrollbar.scrollTop;
- if (!pos || opera) return; // Opera is difficult.
- if (posEq(sel.from, sel.to) || posLess(pos, sel.from) || !posLess(pos, sel.to))
- operation(setCursor)(pos.line, pos.ch);
-
- var oldCSS = input.style.cssText;
- inputDiv.style.position = "absolute";
- input.style.cssText = "position: fixed; width: 30px; height: 30px; top: " + (e.clientY - 5) +
- "px; left: " + (e.clientX - 5) + "px; z-index: 1000; background: white; " +
- "border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";
- leaveInputAlone = true;
- var val = input.value = getSelection();
- focusInput();
- selectInput(input);
- function rehide() {
- var newVal = splitLines(input.value).join("\n");
- if (newVal != val && !options.readOnly) operation(replaceSelection)(newVal, "end");
- inputDiv.style.position = "relative";
- input.style.cssText = oldCSS;
- if (ie_lt9) scrollbar.scrollTop = scrollPos;
- leaveInputAlone = false;
- resetInput(true);
- slowPoll();
- }
-
- if (gecko) {
- e_stop(e);
- var mouseup = connect(window, "mouseup", function() {
- mouseup();
- setTimeout(rehide, 20);
- }, true);
- } else {
- setTimeout(rehide, 50);
- }
- }
-
- // Cursor-blinking
- function restartBlink() {
- clearInterval(blinker);
- var on = true;
- cursor.style.visibility = "";
- blinker = setInterval(function() {
- cursor.style.visibility = (on = !on) ? "" : "hidden";
- }, 650);
- }
-
- var matching = {"(": ")>", ")": "(<", "[": "]>", "]": "[<", "{": "}>", "}": "{<"};
- function matchBrackets(autoclear) {
- var head = sel.inverted ? sel.from : sel.to, line = getLine(head.line), pos = head.ch - 1;
- var match = (pos >= 0 && matching[line.text.charAt(pos)]) || matching[line.text.charAt(++pos)];
- if (!match) return;
- var ch = match.charAt(0), forward = match.charAt(1) == ">", d = forward ? 1 : -1, st = line.styles;
- for (var off = pos + 1, i = 0, e = st.length; i < e; i+=2)
- if ((off -= st[i].length) <= 0) {var style = st[i+1]; break;}
-
- var stack = [line.text.charAt(pos)], re = /[(){}[\]]/;
- function scan(line, from, to) {
- if (!line.text) return;
- var st = line.styles, pos = forward ? 0 : line.text.length - 1, cur;
- for (var i = forward ? 0 : st.length - 2, e = forward ? st.length : -2; i != e; i += 2*d) {
- var text = st[i];
- if (st[i+1] != style) {pos += d * text.length; continue;}
- for (var j = forward ? 0 : text.length - 1, te = forward ? text.length : -1; j != te; j += d, pos+=d) {
- if (pos >= from && pos < to && re.test(cur = text.charAt(j))) {
- var match = matching[cur];
- if (match.charAt(1) == ">" == forward) stack.push(cur);
- else if (stack.pop() != match.charAt(0)) return {pos: pos, match: false};
- else if (!stack.length) return {pos: pos, match: true};
- }
- }
- }
- }
- for (var i = head.line, e = forward ? Math.min(i + 100, doc.size) : Math.max(-1, i - 100); i != e; i+=d) {
- var line = getLine(i), first = i == head.line;
- var found = scan(line, first && forward ? pos + 1 : 0, first && !forward ? pos : line.text.length);
- if (found) break;
- }
- if (!found) found = {pos: null, match: false};
- var style = found.match ? "CodeMirror-matchingbracket" : "CodeMirror-nonmatchingbracket";
- var one = markText({line: head.line, ch: pos}, {line: head.line, ch: pos+1}, style),
- two = found.pos != null && markText({line: i, ch: found.pos}, {line: i, ch: found.pos + 1}, style);
- var clear = operation(function(){one.clear(); two && two.clear();});
- if (autoclear) setTimeout(clear, 800);
- else bracketHighlighted = clear;
- }
-
- // Finds the line to start with when starting a parse. Tries to
- // find a line with a stateAfter, so that it can start with a
- // valid state. If that fails, it returns the line with the
- // smallest indentation, which tends to need the least context to
- // parse correctly.
- function findStartLine(n) {
- var minindent, minline;
- for (var search = n, lim = n - 40; search > lim; --search) {
- if (search == 0) return 0;
- var line = getLine(search-1);
- if (line.stateAfter) return search;
- var indented = line.indentation(options.tabSize);
- if (minline == null || minindent > indented) {
- minline = search - 1;
- minindent = indented;
- }
- }
- return minline;
- }
- function getStateBefore(n) {
- var start = findStartLine(n), state = start && getLine(start-1).stateAfter;
- if (!state) state = startState(mode);
- else state = copyState(mode, state);
- doc.iter(start, n, function(line) {
- line.highlight(mode, state, options.tabSize);
- line.stateAfter = copyState(mode, state);
- });
- if (start < n) changes.push({from: start, to: n});
- if (n < doc.size && !getLine(n).stateAfter) work.push(n);
- return state;
- }
- function highlightLines(start, end) {
- var state = getStateBefore(start);
- doc.iter(start, end, function(line) {
- line.highlight(mode, state, options.tabSize);
- line.stateAfter = copyState(mode, state);
- });
- }
- function highlightWorker() {
- var end = +new Date + options.workTime;
- var foundWork = work.length;
- while (work.length) {
- if (!getLine(showingFrom).stateAfter) var task = showingFrom;
- else var task = work.pop();
- if (task >= doc.size) continue;
- var start = findStartLine(task), state = start && getLine(start-1).stateAfter;
- if (state) state = copyState(mode, state);
- else state = startState(mode);
-
- var unchanged = 0, compare = mode.compareStates, realChange = false,
- i = start, bail = false;
- doc.iter(i, doc.size, function(line) {
- var hadState = line.stateAfter;
- if (+new Date > end) {
- work.push(i);
- startWorker(options.workDelay);
- if (realChange) changes.push({from: task, to: i + 1});
- return (bail = true);
- }
- var changed = line.highlight(mode, state, options.tabSize);
- if (changed) realChange = true;
- line.stateAfter = copyState(mode, state);
- var done = null;
- if (compare) {
- var same = hadState && compare(hadState, state);
- if (same != Pass) done = !!same;
- }
- if (done == null) {
- if (changed !== false || !hadState) unchanged = 0;
- else if (++unchanged > 3 && (!mode.indent || mode.indent(hadState, "") == mode.indent(state, "")))
- done = true;
- }
- if (done) return true;
- ++i;
- });
- if (bail) return;
- if (realChange) changes.push({from: task, to: i + 1});
- }
- if (foundWork && options.onHighlightComplete)
- options.onHighlightComplete(instance);
- }
- function startWorker(time) {
- if (!work.length) return;
- highlight.set(time, operation(highlightWorker));
- }
-
- // Operations are used to wrap changes in such a way that each
- // change won't have to update the cursor and display (which would
- // be awkward, slow, and error-prone), but instead updates are
- // batched and then all combined and executed at once.
- function startOperation() {
- updateInput = userSelChange = textChanged = null;
- changes = []; selectionChanged = false; callbacks = [];
- }
- function endOperation() {
- if (updateMaxLine) computeMaxLength();
- if (maxLineChanged && !options.lineWrapping) {
- var cursorWidth = widthForcer.offsetWidth, left = stringWidth(maxLine);
- widthForcer.style.left = left + "px";
- lineSpace.style.minWidth = (left + cursorWidth) + "px";
- maxLineChanged = false;
- }
- var newScrollPos, updated;
- if (selectionChanged) {
- var coords = calculateCursorCoords();
- newScrollPos = calculateScrollPos(coords.x, coords.y, coords.x, coords.yBot);
- }
- if (changes.length) updated = updateDisplay(changes, true, (newScrollPos ? newScrollPos.scrollTop : null));
- else {
- if (selectionChanged) updateSelection();
- if (gutterDirty) updateGutter();
- }
- if (newScrollPos) scrollCursorIntoView();
- if (selectionChanged) {scrollEditorIntoView(); restartBlink();}
-
- if (focused && !leaveInputAlone &&
- (updateInput === true || (updateInput !== false && selectionChanged)))
- resetInput(userSelChange);
-
- if (selectionChanged && options.matchBrackets)
- setTimeout(operation(function() {
- if (bracketHighlighted) {bracketHighlighted(); bracketHighlighted = null;}
- if (posEq(sel.from, sel.to)) matchBrackets(false);
- }), 20);
- var sc = selectionChanged, cbs = callbacks; // these can be reset by callbacks
- if (textChanged && options.onChange && instance)
- options.onChange(instance, textChanged);
- if (sc
<TRUNCATED>
[16/26] Remove fauxton from 1.4.x branch.
Posted by dj...@apache.org.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/js/libs/jshint.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/jshint.js b/src/fauxton/assets/js/libs/jshint.js
deleted file mode 100644
index 6338ee3..0000000
--- a/src/fauxton/assets/js/libs/jshint.js
+++ /dev/null
@@ -1,4529 +0,0 @@
-/*!
- * JSHint, by JSHint Community.
- *
- * Licensed under the same slightly modified MIT license that JSLint is.
- * It stops evil-doers everywhere.
- *
- * JSHint is a derivative work of JSLint:
- *
- * Copyright (c) 2002 Douglas Crockford (www.JSLint.com)
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom
- * the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * The Software shall be used for Good, not Evil.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * JSHint was forked from the 2010-12-16 edition of JSLint.
- *
- */
-
-/*
- JSHINT is a global function. It takes two parameters.
-
- var myResult = JSHINT(source, option);
-
- The first parameter is either a string or an array of strings. If it is a
- string, it will be split on '\n' or '\r'. If it is an array of strings, it
- is assumed that each string represents one line. The source can be a
- JavaScript text or a JSON text.
-
- The second parameter is an optional object of options which control the
- operation of JSHINT. Most of the options are booleans: They are all
- optional and have a default value of false. One of the options, predef,
- can be an array of names, which will be used to declare global variables,
- or an object whose keys are used as global names, with a boolean value
- that determines if they are assignable.
-
- If it checks out, JSHINT returns true. Otherwise, it returns false.
-
- If false, you can inspect JSHINT.errors to find out the problems.
- JSHINT.errors is an array of objects containing these members:
-
- {
- line : The line (relative to 1) at which the lint was found
- character : The character (relative to 1) at which the lint was found
- reason : The problem
- evidence : The text line in which the problem occurred
- raw : The raw message before the details were inserted
- a : The first detail
- b : The second detail
- c : The third detail
- d : The fourth detail
- }
-
- If a fatal error was found, a null will be the last element of the
- JSHINT.errors array.
-
- You can request a data structure which contains JSHint's results.
-
- var myData = JSHINT.data();
-
- It returns a structure with this form:
-
- {
- errors: [
- {
- line: NUMBER,
- character: NUMBER,
- reason: STRING,
- evidence: STRING
- }
- ],
- functions: [
- name: STRING,
- line: NUMBER,
- character: NUMBER,
- last: NUMBER,
- lastcharacter: NUMBER,
- param: [
- STRING
- ],
- closure: [
- STRING
- ],
- var: [
- STRING
- ],
- exception: [
- STRING
- ],
- outer: [
- STRING
- ],
- unused: [
- STRING
- ],
- global: [
- STRING
- ],
- label: [
- STRING
- ]
- ],
- globals: [
- STRING
- ],
- member: {
- STRING: NUMBER
- },
- unused: [
- {
- name: STRING,
- line: NUMBER
- }
- ],
- implieds: [
- {
- name: STRING,
- line: NUMBER
- }
- ],
- urls: [
- STRING
- ],
- json: BOOLEAN
- }
-
- Empty arrays will not be included.
-
-*/
-
-/*jshint
- evil: true, nomen: false, onevar: false, regexp: false, strict: true, boss: true,
- undef: true, maxlen: 100, indent: 4, quotmark: double, unused: true
-*/
-
-/*members "\b", "\t", "\n", "\f", "\r", "!=", "!==", "\"", "%", "(begin)",
- "(breakage)", "(character)", "(context)", "(error)", "(global)", "(identifier)", "(last)",
- "(lastcharacter)", "(line)", "(loopage)", "(name)", "(onevar)", "(params)", "(scope)",
- "(statement)", "(verb)", "(tokens)", "*", "+", "++", "-", "--", "\/", "<", "<=", "==",
- "===", ">", ">=", $, $$, $A, $F, $H, $R, $break, $continue, $w, Abstract, Ajax,
- __filename, __dirname, ActiveXObject, Array, ArrayBuffer, ArrayBufferView, Audio,
- Autocompleter, Assets, Boolean, Builder, Buffer, Browser, COM, CScript, Canvas,
- CustomAnimation, Class, Control, Chain, Color, Cookie, Core, DataView, Date,
- Debug, Draggable, Draggables, Droppables, Document, DomReady, DOMReady, DOMParser, Drag,
- E, Enumerator, Enumerable, Element, Elements, Error, Effect, EvalError, Event,
- Events, FadeAnimation, Field, Flash, Float32Array, Float64Array, Form,
- FormField, Frame, FormData, Function, Fx, GetObject, Group, Hash, HotKey,
- HTMLElement, HTMLAnchorElement, HTMLBaseElement, HTMLBlockquoteElement,
- HTMLBodyElement, HTMLBRElement, HTMLButtonElement, HTMLCanvasElement, HTMLDirectoryElement,
- HTMLDivElement, HTMLDListElement, HTMLFieldSetElement,
- HTMLFontElement, HTMLFormElement, HTMLFrameElement, HTMLFrameSetElement,
- HTMLHeadElement, HTMLHeadingElement, HTMLHRElement, HTMLHtmlElement,
- HTMLIFrameElement, HTMLImageElement, HTMLInputElement, HTMLIsIndexElement,
- HTMLLabelElement, HTMLLayerElement, HTMLLegendElement, HTMLLIElement,
- HTMLLinkElement, HTMLMapElement, HTMLMenuElement, HTMLMetaElement,
- HTMLModElement, HTMLObjectElement, HTMLOListElement, HTMLOptGroupElement,
- HTMLOptionElement, HTMLParagraphElement, HTMLParamElement, HTMLPreElement,
- HTMLQuoteElement, HTMLScriptElement, HTMLSelectElement, HTMLStyleElement,
- HtmlTable, HTMLTableCaptionElement, HTMLTableCellElement, HTMLTableColElement,
- HTMLTableElement, HTMLTableRowElement, HTMLTableSectionElement,
- HTMLTextAreaElement, HTMLTitleElement, HTMLUListElement, HTMLVideoElement,
- Iframe, IframeShim, Image, importScripts, Int16Array, Int32Array, Int8Array,
- Insertion, InputValidator, JSON, Keyboard, Locale, LN10, LN2, LOG10E, LOG2E,
- MAX_VALUE, MIN_VALUE, Mask, Math, MenuItem, MessageChannel, MessageEvent, MessagePort,
- MoveAnimation, MooTools, MutationObserver, Native, NEGATIVE_INFINITY, Node, NodeFilter,
- Number, Object, ObjectRange,
- Option, Options, OverText, PI, POSITIVE_INFINITY, PeriodicalExecuter, Point, Position, Prototype,
- RangeError, Rectangle, ReferenceError, RegExp, ResizeAnimation, Request, RotateAnimation,
- SQRT1_2, SQRT2, ScrollBar, ScriptEngine, ScriptEngineBuildVersion,
- ScriptEngineMajorVersion, ScriptEngineMinorVersion, Scriptaculous, Scroller,
- Slick, Slider, Selector, SharedWorker, String, Style, SyntaxError, Sortable, Sortables,
- SortableObserver, Sound, Spinner, System, Swiff, Text, TextArea, Template,
- Timer, Tips, Type, TypeError, Toggle, Try, "use strict", unescape, URI, URIError, URL,
- VBArray, WSH, WScript, XDomainRequest, Web, Window, XMLDOM, XMLHttpRequest, XMLSerializer,
- XPathEvaluator, XPathException, XPathExpression, XPathNamespace, XPathNSResolver, XPathResult,
- "\\", a, addEventListener, address, alert, apply, applicationCache, arguments, arity,
- asi, atob, b, basic, basicToken, bitwise, block, blur, boolOptions, boss, browser, btoa, c,
- call, callee, caller, camelcase, cases, charAt, charCodeAt, character, clearInterval,
- clearTimeout, close, closed, closure, comment, condition, confirm, console, constructor,
- content, couch, create, css, curly, d, data, datalist, dd, debug, decodeURI,
- decodeURIComponent, defaultStatus, defineClass, deserialize, devel, document,
- dojo, dijit, dojox, define, else, emit, encodeURI, encodeURIComponent,
- eqeq, eqeqeq, eqnull, errors, es5, escape, esnext, eval, event, evidence, evil,
- ex, exception, exec, exps, expr, exports, FileReader, first, floor, focus, forEach,
- forin, fragment, frames, from, fromCharCode, fud, funcscope, funct, function, functions,
- g, gc, getComputedStyle, getRow, getter, getterToken, GLOBAL, global, globals, globalstrict,
- hasOwnProperty, help, history, i, id, identifier, immed, implieds, importPackage, include,
- indent, indexOf, init, ins, instanceOf, isAlpha, isApplicationRunning, isArray,
- isDigit, isFinite, isNaN, iterator, java, join, jshint,
- JSHINT, json, jquery, jQuery, keys, label, labelled, last, lastcharacter, lastsemic, laxbreak,
- laxcomma, latedef, lbp, led, left, length, line, load, loadClass, localStorage, location,
- log, loopfunc, m, match, maxerr, maxlen, member,message, meta, module, moveBy,
- moveTo, mootools, multistr, name, navigator, new, newcap, noarg, node, noempty, nomen,
- nonew, nonstandard, nud, onbeforeunload, onblur, onerror, onevar, onecase, onfocus,
- onload, onresize, onunload, open, openDatabase, openURL, opener, opera, options, outer, param,
- parent, parseFloat, parseInt, passfail, plusplus, postMessage, predef, print, process, prompt,
- proto, prototype, prototypejs, provides, push, quit, quotmark, range, raw, reach, reason, regexp,
- readFile, readUrl, regexdash, removeEventListener, replace, report, require,
- reserved, resizeBy, resizeTo, resolvePath, resumeUpdates, respond, rhino, right,
- runCommand, scroll, screen, scripturl, scrollBy, scrollTo, scrollbar, search, seal, self,
- send, serialize, sessionStorage, setInterval, setTimeout, setter, setterToken, shift, slice,
- smarttabs, sort, spawn, split, stack, status, start, strict, sub, substr, supernew, shadow,
- supplant, sum, sync, test, toLowerCase, toString, toUpperCase, toint32, token, tokens, top,
- trailing, type, typeOf, Uint16Array, Uint32Array, Uint8Array, undef, undefs, unused,
- urls, validthis, value, valueOf, var, vars, version, WebSocket, withstmt, white, window, windows,
- Worker, worker, wsh*/
-
-/*global exports: false */
-
-// We build the application inside a function so that we produce only a single
-// global variable. That function will be invoked immediately, and its return
-// value is the JSHINT function itself.
-
-var JSHINT = (function () {
- "use strict";
-
- var anonname, // The guessed name for anonymous functions.
-
-// These are operators that should not be used with the ! operator.
-
- bang = {
- "<" : true,
- "<=" : true,
- "==" : true,
- "===": true,
- "!==": true,
- "!=" : true,
- ">" : true,
- ">=" : true,
- "+" : true,
- "-" : true,
- "*" : true,
- "/" : true,
- "%" : true
- },
-
- // These are the JSHint boolean options.
- boolOptions = {
- asi : true, // if automatic semicolon insertion should be tolerated
- bitwise : true, // if bitwise operators should not be allowed
- boss : true, // if advanced usage of assignments should be allowed
- browser : true, // if the standard browser globals should be predefined
- camelcase : true, // if identifiers should be required in camel case
- couch : true, // if CouchDB globals should be predefined
- curly : true, // if curly braces around all blocks should be required
- debug : true, // if debugger statements should be allowed
- devel : true, // if logging globals should be predefined (console,
- // alert, etc.)
- dojo : true, // if Dojo Toolkit globals should be predefined
- eqeqeq : true, // if === should be required
- eqnull : true, // if == null comparisons should be tolerated
- es5 : true, // if ES5 syntax should be allowed
- esnext : true, // if es.next specific syntax should be allowed
- evil : true, // if eval should be allowed
- expr : true, // if ExpressionStatement should be allowed as Programs
- forin : true, // if for in statements must filter
- funcscope : true, // if only function scope should be used for scope tests
- globalstrict: true, // if global "use strict"; should be allowed (also
- // enables 'strict')
- immed : true, // if immediate invocations must be wrapped in parens
- iterator : true, // if the `__iterator__` property should be allowed
- jquery : true, // if jQuery globals should be predefined
- lastsemic : true, // if semicolons may be ommitted for the trailing
- // statements inside of a one-line blocks.
- latedef : true, // if the use before definition should not be tolerated
- laxbreak : true, // if line breaks should not be checked
- laxcomma : true, // if line breaks should not be checked around commas
- loopfunc : true, // if functions should be allowed to be defined within
- // loops
- mootools : true, // if MooTools globals should be predefined
- multistr : true, // allow multiline strings
- newcap : true, // if constructor names must be capitalized
- noarg : true, // if arguments.caller and arguments.callee should be
- // disallowed
- node : true, // if the Node.js environment globals should be
- // predefined
- noempty : true, // if empty blocks should be disallowed
- nonew : true, // if using `new` for side-effects should be disallowed
- nonstandard : true, // if non-standard (but widely adopted) globals should
- // be predefined
- nomen : true, // if names should be checked
- onevar : true, // if only one var statement per function should be
- // allowed
- onecase : true, // if one case switch statements should be allowed
- passfail : true, // if the scan should stop on first error
- plusplus : true, // if increment/decrement should not be allowed
- proto : true, // if the `__proto__` property should be allowed
- prototypejs : true, // if Prototype and Scriptaculous globals should be
- // predefined
- regexdash : true, // if unescaped first/last dash (-) inside brackets
- // should be tolerated
- regexp : true, // if the . should not be allowed in regexp literals
- rhino : true, // if the Rhino environment globals should be predefined
- undef : true, // if variables should be declared before used
- unused : true, // if variables should be always used
- scripturl : true, // if script-targeted URLs should be tolerated
- shadow : true, // if variable shadowing should be tolerated
- smarttabs : true, // if smarttabs should be tolerated
- // (http://www.emacswiki.org/emacs/SmartTabs)
- strict : true, // require the "use strict"; pragma
- sub : true, // if all forms of subscript notation are tolerated
- supernew : true, // if `new function () { ... };` and `new Object;`
- // should be tolerated
- trailing : true, // if trailing whitespace rules apply
- validthis : true, // if 'this' inside a non-constructor function is valid.
- // This is a function scoped option only.
- withstmt : true, // if with statements should be allowed
- white : true, // if strict whitespace rules apply
- worker : true, // if Web Worker script symbols should be allowed
- wsh : true // if the Windows Scripting Host environment globals
- // should be predefined
- },
-
- // These are the JSHint options that can take any value
- // (we use this object to detect invalid options)
- valOptions = {
- maxlen: false,
- indent: false,
- maxerr: false,
- predef: false,
- quotmark: false //'single'|'double'|true
- },
-
- // These are JSHint boolean options which are shared with JSLint
- // where the definition in JSHint is opposite JSLint
- invertedOptions = {
- bitwise : true,
- forin : true,
- newcap : true,
- nomen : true,
- plusplus : true,
- regexp : true,
- undef : true,
- white : true,
-
- // Inverted and renamed, use JSHint name here
- eqeqeq : true,
- onevar : true
- },
-
- // These are JSHint boolean options which are shared with JSLint
- // where the name has been changed but the effect is unchanged
- renamedOptions = {
- eqeq : "eqeqeq",
- vars : "onevar",
- windows : "wsh"
- },
-
-
- // browser contains a set of global names which are commonly provided by a
- // web browser environment.
- browser = {
- ArrayBuffer : false,
- ArrayBufferView : false,
- Audio : false,
- addEventListener : false,
- applicationCache : false,
- atob : false,
- blur : false,
- btoa : false,
- clearInterval : false,
- clearTimeout : false,
- close : false,
- closed : false,
- DataView : false,
- DOMParser : false,
- defaultStatus : false,
- document : false,
- event : false,
- FileReader : false,
- Float32Array : false,
- Float64Array : false,
- FormData : false,
- focus : false,
- frames : false,
- getComputedStyle : false,
- HTMLElement : false,
- HTMLAnchorElement : false,
- HTMLBaseElement : false,
- HTMLBlockquoteElement : false,
- HTMLBodyElement : false,
- HTMLBRElement : false,
- HTMLButtonElement : false,
- HTMLCanvasElement : false,
- HTMLDirectoryElement : false,
- HTMLDivElement : false,
- HTMLDListElement : false,
- HTMLFieldSetElement : false,
- HTMLFontElement : false,
- HTMLFormElement : false,
- HTMLFrameElement : false,
- HTMLFrameSetElement : false,
- HTMLHeadElement : false,
- HTMLHeadingElement : false,
- HTMLHRElement : false,
- HTMLHtmlElement : false,
- HTMLIFrameElement : false,
- HTMLImageElement : false,
- HTMLInputElement : false,
- HTMLIsIndexElement : false,
- HTMLLabelElement : false,
- HTMLLayerElement : false,
- HTMLLegendElement : false,
- HTMLLIElement : false,
- HTMLLinkElement : false,
- HTMLMapElement : false,
- HTMLMenuElement : false,
- HTMLMetaElement : false,
- HTMLModElement : false,
- HTMLObjectElement : false,
- HTMLOListElement : false,
- HTMLOptGroupElement : false,
- HTMLOptionElement : false,
- HTMLParagraphElement : false,
- HTMLParamElement : false,
- HTMLPreElement : false,
- HTMLQuoteElement : false,
- HTMLScriptElement : false,
- HTMLSelectElement : false,
- HTMLStyleElement : false,
- HTMLTableCaptionElement : false,
- HTMLTableCellElement : false,
- HTMLTableColElement : false,
- HTMLTableElement : false,
- HTMLTableRowElement : false,
- HTMLTableSectionElement : false,
- HTMLTextAreaElement : false,
- HTMLTitleElement : false,
- HTMLUListElement : false,
- HTMLVideoElement : false,
- history : false,
- Int16Array : false,
- Int32Array : false,
- Int8Array : false,
- Image : false,
- length : false,
- localStorage : false,
- location : false,
- MessageChannel : false,
- MessageEvent : false,
- MessagePort : false,
- moveBy : false,
- moveTo : false,
- MutationObserver : false,
- name : false,
- Node : false,
- NodeFilter : false,
- navigator : false,
- onbeforeunload : true,
- onblur : true,
- onerror : true,
- onfocus : true,
- onload : true,
- onresize : true,
- onunload : true,
- open : false,
- openDatabase : false,
- opener : false,
- Option : false,
- parent : false,
- print : false,
- removeEventListener : false,
- resizeBy : false,
- resizeTo : false,
- screen : false,
- scroll : false,
- scrollBy : false,
- scrollTo : false,
- sessionStorage : false,
- setInterval : false,
- setTimeout : false,
- SharedWorker : false,
- status : false,
- top : false,
- Uint16Array : false,
- Uint32Array : false,
- Uint8Array : false,
- WebSocket : false,
- window : false,
- Worker : false,
- XMLHttpRequest : false,
- XMLSerializer : false,
- XPathEvaluator : false,
- XPathException : false,
- XPathExpression : false,
- XPathNamespace : false,
- XPathNSResolver : false,
- XPathResult : false
- },
-
- couch = {
- "require" : false,
- respond : false,
- getRow : false,
- emit : false,
- send : false,
- start : false,
- sum : false,
- log : false,
- exports : false,
- module : false,
- provides : false
- },
-
- declared, // Globals that were declared using /*global ... */ syntax.
-
- devel = {
- alert : false,
- confirm : false,
- console : false,
- Debug : false,
- opera : false,
- prompt : false
- },
-
- dojo = {
- dojo : false,
- dijit : false,
- dojox : false,
- define : false,
- "require" : false
- },
-
- funct, // The current function
-
- functionicity = [
- "closure", "exception", "global", "label",
- "outer", "unused", "var"
- ],
-
- functions, // All of the functions
-
- global, // The global scope
- implied, // Implied globals
- inblock,
- indent,
- jsonmode,
-
- jquery = {
- "$" : false,
- jQuery : false
- },
-
- lines,
- lookahead,
- member,
- membersOnly,
-
- mootools = {
- "$" : false,
- "$$" : false,
- Assets : false,
- Browser : false,
- Chain : false,
- Class : false,
- Color : false,
- Cookie : false,
- Core : false,
- Document : false,
- DomReady : false,
- DOMReady : false,
- Drag : false,
- Element : false,
- Elements : false,
- Event : false,
- Events : false,
- Fx : false,
- Group : false,
- Hash : false,
- HtmlTable : false,
- Iframe : false,
- IframeShim : false,
- InputValidator : false,
- instanceOf : false,
- Keyboard : false,
- Locale : false,
- Mask : false,
- MooTools : false,
- Native : false,
- Options : false,
- OverText : false,
- Request : false,
- Scroller : false,
- Slick : false,
- Slider : false,
- Sortables : false,
- Spinner : false,
- Swiff : false,
- Tips : false,
- Type : false,
- typeOf : false,
- URI : false,
- Window : false
- },
-
- nexttoken,
-
- node = {
- __filename : false,
- __dirname : false,
- Buffer : false,
- console : false,
- exports : true, // In Node it is ok to exports = module.exports = foo();
- GLOBAL : false,
- global : false,
- module : false,
- process : false,
- require : false,
- setTimeout : false,
- clearTimeout : false,
- setInterval : false,
- clearInterval : false
- },
-
- noreach,
- option,
- predefined, // Global variables defined by option
- prereg,
- prevtoken,
-
- prototypejs = {
- "$" : false,
- "$$" : false,
- "$A" : false,
- "$F" : false,
- "$H" : false,
- "$R" : false,
- "$break" : false,
- "$continue" : false,
- "$w" : false,
- Abstract : false,
- Ajax : false,
- Class : false,
- Enumerable : false,
- Element : false,
- Event : false,
- Field : false,
- Form : false,
- Hash : false,
- Insertion : false,
- ObjectRange : false,
- PeriodicalExecuter: false,
- Position : false,
- Prototype : false,
- Selector : false,
- Template : false,
- Toggle : false,
- Try : false,
- Autocompleter : false,
- Builder : false,
- Control : false,
- Draggable : false,
- Draggables : false,
- Droppables : false,
- Effect : false,
- Sortable : false,
- SortableObserver : false,
- Sound : false,
- Scriptaculous : false
- },
-
- quotmark,
-
- rhino = {
- defineClass : false,
- deserialize : false,
- gc : false,
- help : false,
- importPackage: false,
- "java" : false,
- load : false,
- loadClass : false,
- print : false,
- quit : false,
- readFile : false,
- readUrl : false,
- runCommand : false,
- seal : false,
- serialize : false,
- spawn : false,
- sync : false,
- toint32 : false,
- version : false
- },
-
- scope, // The current scope
- stack,
-
- // standard contains the global names that are provided by the
- // ECMAScript standard.
- standard = {
- Array : false,
- Boolean : false,
- Date : false,
- decodeURI : false,
- decodeURIComponent : false,
- encodeURI : false,
- encodeURIComponent : false,
- Error : false,
- "eval" : false,
- EvalError : false,
- Function : false,
- hasOwnProperty : false,
- isFinite : false,
- isNaN : false,
- JSON : false,
- Math : false,
- Number : false,
- Object : false,
- parseInt : false,
- parseFloat : false,
- RangeError : false,
- ReferenceError : false,
- RegExp : false,
- String : false,
- SyntaxError : false,
- TypeError : false,
- URIError : false
- },
-
- // widely adopted global names that are not part of ECMAScript standard
- nonstandard = {
- escape : false,
- unescape : false
- },
-
- directive,
- syntax = {},
- tab,
- token,
- urls,
- useESNextSyntax,
- warnings,
-
- worker = {
- importScripts : true,
- postMessage : true,
- self : true
- },
-
- wsh = {
- ActiveXObject : true,
- Enumerator : true,
- GetObject : true,
- ScriptEngine : true,
- ScriptEngineBuildVersion : true,
- ScriptEngineMajorVersion : true,
- ScriptEngineMinorVersion : true,
- VBArray : true,
- WSH : true,
- WScript : true,
- XDomainRequest : true
- };
-
- // Regular expressions. Some of these are stupidly long.
- var ax, cx, tx, nx, nxg, lx, ix, jx, ft;
- (function () {
- /*jshint maxlen:300 */
-
- // unsafe comment or string
- ax = /@cc|<\/?|script|\]\s*\]|<\s*!|</i;
-
- // unsafe characters that are silently deleted by one or more browsers
- cx = /[\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/;
-
- // token
- tx = /^\s*([(){}\[.,:;'"~\?\]#@]|==?=?|\/(\*(jshint|jslint|members?|global)?|=|\/)?|\*[\/=]?|\+(?:=|\++)?|-(?:=|-+)?|%=?|&[&=]?|\|[|=]?|>>?>?=?|<([\/=!]|\!(\[|--)?|<=?)?|\^=?|\!=?=?|[a-zA-Z_$][a-zA-Z0-9_$]*|[0-9]+([xX][0-9a-fA-F]+|\.[0-9]*)?([eE][+\-]?[0-9]+)?)/;
-
- // characters in strings that need escapement
- nx = /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/;
- nxg = /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
-
- // star slash
- lx = /\*\/|\/\*/;
-
- // identifier
- ix = /^([a-zA-Z_$][a-zA-Z0-9_$]*)$/;
-
- // javascript url
- jx = /^(?:javascript|jscript|ecmascript|vbscript|mocha|livescript)\s*:/i;
-
- // catches /* falls through */ comments
- ft = /^\s*\/\*\s*falls\sthrough\s*\*\/\s*$/;
- }());
-
- function F() {} // Used by Object.create
-
- function is_own(object, name) {
- // The object.hasOwnProperty method fails when the property under consideration
- // is named 'hasOwnProperty'. So we have to use this more convoluted form.
- return Object.prototype.hasOwnProperty.call(object, name);
- }
-
- function checkOption(name, t) {
- if (valOptions[name] === undefined && boolOptions[name] === undefined) {
- warning("Bad option: '" + name + "'.", t);
- }
- }
-
- function isString(obj) {
- return Object.prototype.toString.call(obj) === "[object String]";
- }
-
- // Provide critical ES5 functions to ES3.
-
- if (typeof Array.isArray !== "function") {
- Array.isArray = function (o) {
- return Object.prototype.toString.apply(o) === "[object Array]";
- };
- }
-
- if (!Array.prototype.forEach) {
- Array.prototype.forEach = function (fn, scope) {
- var len = this.length;
-
- for (var i = 0; i < len; i++) {
- fn.call(scope || this, this[i], i, this);
- }
- };
- }
-
- if (typeof Object.create !== "function") {
- Object.create = function (o) {
- F.prototype = o;
- return new F();
- };
- }
-
- if (typeof Object.keys !== "function") {
- Object.keys = function (o) {
- var a = [], k;
- for (k in o) {
- if (is_own(o, k)) {
- a.push(k);
- }
- }
- return a;
- };
- }
-
- // Non standard methods
-
- function isAlpha(str) {
- return (str >= "a" && str <= "z\uffff") ||
- (str >= "A" && str <= "Z\uffff");
- }
-
- function isDigit(str) {
- return (str >= "0" && str <= "9");
- }
-
- function supplant(str, data) {
- return str.replace(/\{([^{}]*)\}/g, function (a, b) {
- var r = data[b];
- return typeof r === "string" || typeof r === "number" ? r : a;
- });
- }
-
- function combine(t, o) {
- var n;
- for (n in o) {
- if (is_own(o, n)) {
- t[n] = o[n];
- }
- }
- }
-
- function assume() {
- if (option.couch) {
- combine(predefined, couch);
- }
-
- if (option.rhino) {
- combine(predefined, rhino);
- }
-
- if (option.prototypejs) {
- combine(predefined, prototypejs);
- }
-
- if (option.node) {
- combine(predefined, node);
- option.globalstrict = true;
- }
-
- if (option.devel) {
- combine(predefined, devel);
- }
-
- if (option.dojo) {
- combine(predefined, dojo);
- }
-
- if (option.browser) {
- combine(predefined, browser);
- }
-
- if (option.nonstandard) {
- combine(predefined, nonstandard);
- }
-
- if (option.jquery) {
- combine(predefined, jquery);
- }
-
- if (option.mootools) {
- combine(predefined, mootools);
- }
-
- if (option.worker) {
- combine(predefined, worker);
- }
-
- if (option.wsh) {
- combine(predefined, wsh);
- }
-
- if (option.esnext) {
- useESNextSyntax();
- }
-
- if (option.globalstrict && option.strict !== false) {
- option.strict = true;
- }
- }
-
-
- // Produce an error warning.
- function quit(message, line, chr) {
- var percentage = Math.floor((line / lines.length) * 100);
-
- throw {
- name: "JSHintError",
- line: line,
- character: chr,
- message: message + " (" + percentage + "% scanned).",
- raw: message
- };
- }
-
- function isundef(scope, m, t, a) {
- return JSHINT.undefs.push([scope, m, t, a]);
- }
-
- function warning(m, t, a, b, c, d) {
- var ch, l, w;
- t = t || nexttoken;
- if (t.id === "(end)") { // `~
- t = token;
- }
- l = t.line || 0;
- ch = t.from || 0;
- w = {
- id: "(error)",
- raw: m,
- evidence: lines[l - 1] || "",
- line: l,
- character: ch,
- a: a,
- b: b,
- c: c,
- d: d
- };
- w.reason = supplant(m, w);
- JSHINT.errors.push(w);
- if (option.passfail) {
- quit("Stopping. ", l, ch);
- }
- warnings += 1;
- if (warnings >= option.maxerr) {
- quit("Too many errors.", l, ch);
- }
- return w;
- }
-
- function warningAt(m, l, ch, a, b, c, d) {
- return warning(m, {
- line: l,
- from: ch
- }, a, b, c, d);
- }
-
- function error(m, t, a, b, c, d) {
- warning(m, t, a, b, c, d);
- }
-
- function errorAt(m, l, ch, a, b, c, d) {
- return error(m, {
- line: l,
- from: ch
- }, a, b, c, d);
- }
-
-
-
-// lexical analysis and token construction
-
- var lex = (function lex() {
- var character, from, line, s;
-
-// Private lex methods
-
- function nextLine() {
- var at,
- tw; // trailing whitespace check
-
- if (line >= lines.length)
- return false;
-
- character = 1;
- s = lines[line];
- line += 1;
-
- // If smarttabs option is used check for spaces followed by tabs only.
- // Otherwise check for any occurence of mixed tabs and spaces.
- // Tabs and one space followed by block comment is allowed.
- if (option.smarttabs)
- at = s.search(/ \t/);
- else
- at = s.search(/ \t|\t [^\*]/);
-
- if (at >= 0)
- warningAt("Mixed spaces and tabs.", line, at + 1);
-
- s = s.replace(/\t/g, tab);
- at = s.search(cx);
-
- if (at >= 0)
- warningAt("Unsafe character.", line, at);
-
- if (option.maxlen && option.maxlen < s.length)
- warningAt("Line too long.", line, s.length);
-
- // Check for trailing whitespaces
- tw = option.trailing && s.match(/^(.*?)\s+$/);
- if (tw && !/^\s+$/.test(s)) {
- warningAt("Trailing whitespace.", line, tw[1].length + 1);
- }
- return true;
- }
-
-// Produce a token object. The token inherits from a syntax symbol.
-
- function it(type, value) {
- var i, t;
-
- function checkName(name) {
- if (!option.proto && name === "__proto__") {
- warningAt("The '{a}' property is deprecated.", line, from, name);
- return;
- }
-
- if (!option.iterator && name === "__iterator__") {
- warningAt("'{a}' is only available in JavaScript 1.7.", line, from, name);
- return;
- }
-
- // Check for dangling underscores unless we're in Node
- // environment and this identifier represents built-in
- // Node globals with underscores.
-
- var hasDangling = /^(_+.*|.*_+)$/.test(name);
-
- if (option.nomen && hasDangling && name !== "_") {
- if (option.node && token.id !== "." && /^(__dirname|__filename)$/.test(name))
- return;
-
- warningAt("Unexpected {a} in '{b}'.", line, from, "dangling '_'", name);
- return;
- }
-
- // Check for non-camelcase names. Names like MY_VAR and
- // _myVar are okay though.
-
- if (option.camelcase) {
- if (name.replace(/^_+/, "").indexOf("_") > -1 && !name.match(/^[A-Z0-9_]*$/)) {
- warningAt("Identifier '{a}' is not in camel case.", line, from, value);
- }
- }
- }
-
- if (type === "(color)" || type === "(range)") {
- t = {type: type};
- } else if (type === "(punctuator)" ||
- (type === "(identifier)" && is_own(syntax, value))) {
- t = syntax[value] || syntax["(error)"];
- } else {
- t = syntax[type];
- }
-
- t = Object.create(t);
-
- if (type === "(string)" || type === "(range)") {
- if (!option.scripturl && jx.test(value)) {
- warningAt("Script URL.", line, from);
- }
- }
-
- if (type === "(identifier)") {
- t.identifier = true;
- checkName(value);
- }
-
- t.value = value;
- t.line = line;
- t.character = character;
- t.from = from;
- i = t.id;
- if (i !== "(endline)") {
- prereg = i &&
- (("(,=:[!&|?{};".indexOf(i.charAt(i.length - 1)) >= 0) ||
- i === "return" ||
- i === "case");
- }
- return t;
- }
-
- // Public lex methods
- return {
- init: function (source) {
- if (typeof source === "string") {
- lines = source
- .replace(/\r\n/g, "\n")
- .replace(/\r/g, "\n")
- .split("\n");
- } else {
- lines = source;
- }
-
- // If the first line is a shebang (#!), make it a blank and move on.
- // Shebangs are used by Node scripts.
- if (lines[0] && lines[0].substr(0, 2) === "#!")
- lines[0] = "";
-
- line = 0;
- nextLine();
- from = 1;
- },
-
- range: function (begin, end) {
- var c, value = "";
- from = character;
- if (s.charAt(0) !== begin) {
- errorAt("Expected '{a}' and instead saw '{b}'.",
- line, character, begin, s.charAt(0));
- }
- for (;;) {
- s = s.slice(1);
- character += 1;
- c = s.charAt(0);
- switch (c) {
- case "":
- errorAt("Missing '{a}'.", line, character, c);
- break;
- case end:
- s = s.slice(1);
- character += 1;
- return it("(range)", value);
- case "\\":
- warningAt("Unexpected '{a}'.", line, character, c);
- }
- value += c;
- }
-
- },
-
-
- // token -- this is called by advance to get the next token
- token: function () {
- var b, c, captures, d, depth, high, i, l, low, q, t, isLiteral, isInRange, n;
-
- function match(x) {
- var r = x.exec(s), r1;
- if (r) {
- l = r[0].length;
- r1 = r[1];
- c = r1.charAt(0);
- s = s.substr(l);
- from = character + l - r1.length;
- character += l;
- return r1;
- }
- }
-
- function string(x) {
- var c, j, r = "", allowNewLine = false;
-
- if (jsonmode && x !== "\"") {
- warningAt("Strings must use doublequote.",
- line, character);
- }
-
- if (option.quotmark) {
- if (option.quotmark === "single" && x !== "'") {
- warningAt("Strings must use singlequote.",
- line, character);
- } else if (option.quotmark === "double" && x !== "\"") {
- warningAt("Strings must use doublequote.",
- line, character);
- } else if (option.quotmark === true) {
- quotmark = quotmark || x;
- if (quotmark !== x) {
- warningAt("Mixed double and single quotes.",
- line, character);
- }
- }
- }
-
- function esc(n) {
- var i = parseInt(s.substr(j + 1, n), 16);
- j += n;
- if (i >= 32 && i <= 126 &&
- i !== 34 && i !== 92 && i !== 39) {
- warningAt("Unnecessary escapement.", line, character);
- }
- character += n;
- c = String.fromCharCode(i);
- }
- j = 0;
-unclosedString: for (;;) {
- while (j >= s.length) {
- j = 0;
-
- var cl = line, cf = from;
- if (!nextLine()) {
- errorAt("Unclosed string.", cl, cf);
- break unclosedString;
- }
-
- if (allowNewLine) {
- allowNewLine = false;
- } else {
- warningAt("Unclosed string.", cl, cf);
- }
- }
- c = s.charAt(j);
- if (c === x) {
- character += 1;
- s = s.substr(j + 1);
- return it("(string)", r, x);
- }
- if (c < " ") {
- if (c === "\n" || c === "\r") {
- break;
- }
- warningAt("Control character in string: {a}.",
- line, character + j, s.slice(0, j));
- } else if (c === "\\") {
- j += 1;
- character += 1;
- c = s.charAt(j);
- n = s.charAt(j + 1);
- switch (c) {
- case "\\":
- case "\"":
- case "/":
- break;
- case "\'":
- if (jsonmode) {
- warningAt("Avoid \\'.", line, character);
- }
- break;
- case "b":
- c = "\b";
- break;
- case "f":
- c = "\f";
- break;
- case "n":
- c = "\n";
- break;
- case "r":
- c = "\r";
- break;
- case "t":
- c = "\t";
- break;
- case "0":
- c = "\0";
- // Octal literals fail in strict mode
- // check if the number is between 00 and 07
- // where 'n' is the token next to 'c'
- if (n >= 0 && n <= 7 && directive["use strict"]) {
- warningAt(
- "Octal literals are not allowed in strict mode.",
- line, character);
- }
- break;
- case "u":
- esc(4);
- break;
- case "v":
- if (jsonmode) {
- warningAt("Avoid \\v.", line, character);
- }
- c = "\v";
- break;
- case "x":
- if (jsonmode) {
- warningAt("Avoid \\x-.", line, character);
- }
- esc(2);
- break;
- case "":
- // last character is escape character
- // always allow new line if escaped, but show
- // warning if option is not set
- allowNewLine = true;
- if (option.multistr) {
- if (jsonmode) {
- warningAt("Avoid EOL escapement.", line, character);
- }
- c = "";
- character -= 1;
- break;
- }
- warningAt("Bad escapement of EOL. Use option multistr if needed.",
- line, character);
- break;
- default:
- warningAt("Bad escapement.", line, character);
- }
- }
- r += c;
- character += 1;
- j += 1;
- }
- }
-
- for (;;) {
- if (!s) {
- return it(nextLine() ? "(endline)" : "(end)", "");
- }
- t = match(tx);
- if (!t) {
- t = "";
- c = "";
- while (s && s < "!") {
- s = s.substr(1);
- }
- if (s) {
- errorAt("Unexpected '{a}'.", line, character, s.substr(0, 1));
- s = "";
- }
- } else {
-
- // identifier
-
- if (isAlpha(c) || c === "_" || c === "$") {
- return it("(identifier)", t);
- }
-
- // number
-
- if (isDigit(c)) {
- if (!isFinite(Number(t))) {
- warningAt("Bad number '{a}'.",
- line, character, t);
- }
- if (isAlpha(s.substr(0, 1))) {
- warningAt("Missing space after '{a}'.",
- line, character, t);
- }
- if (c === "0") {
- d = t.substr(1, 1);
- if (isDigit(d)) {
- if (token.id !== ".") {
- warningAt("Don't use extra leading zeros '{a}'.",
- line, character, t);
- }
- } else if (jsonmode && (d === "x" || d === "X")) {
- warningAt("Avoid 0x-. '{a}'.",
- line, character, t);
- }
- }
- if (t.substr(t.length - 1) === ".") {
- warningAt(
-"A trailing decimal point can be confused with a dot '{a}'.", line, character, t);
- }
- return it("(number)", t);
- }
- switch (t) {
-
- // string
-
- case "\"":
- case "'":
- return string(t);
-
- // // comment
-
- case "//":
- s = "";
- token.comment = true;
- break;
-
- // /* comment
-
- case "/*":
- for (;;) {
- i = s.search(lx);
- if (i >= 0) {
- break;
- }
- if (!nextLine()) {
- errorAt("Unclosed comment.", line, character);
- }
- }
- character += i + 2;
- if (s.substr(i, 1) === "/") {
- errorAt("Nested comment.", line, character);
- }
- s = s.substr(i + 2);
- token.comment = true;
- break;
-
- // /*members /*jshint /*global
-
- case "/*members":
- case "/*member":
- case "/*jshint":
- case "/*jslint":
- case "/*global":
- case "*/":
- return {
- value: t,
- type: "special",
- line: line,
- character: character,
- from: from
- };
-
- case "":
- break;
- // /
- case "/":
- if (token.id === "/=") {
- errorAt("A regular expression literal can be confused with '/='.",
- line, from);
- }
- if (prereg) {
- depth = 0;
- captures = 0;
- l = 0;
- for (;;) {
- b = true;
- c = s.charAt(l);
- l += 1;
- switch (c) {
- case "":
- errorAt("Unclosed regular expression.", line, from);
- return quit("Stopping.", line, from);
- case "/":
- if (depth > 0) {
- warningAt("{a} unterminated regular expression " +
- "group(s).", line, from + l, depth);
- }
- c = s.substr(0, l - 1);
- q = {
- g: true,
- i: true,
- m: true
- };
- while (q[s.charAt(l)] === true) {
- q[s.charAt(l)] = false;
- l += 1;
- }
- character += l;
- s = s.substr(l);
- q = s.charAt(0);
- if (q === "/" || q === "*") {
- errorAt("Confusing regular expression.",
- line, from);
- }
- return it("(regexp)", c);
- case "\\":
- c = s.charAt(l);
- if (c < " ") {
- warningAt(
-"Unexpected control character in regular expression.", line, from + l);
- } else if (c === "<") {
- warningAt(
-"Unexpected escaped character '{a}' in regular expression.", line, from + l, c);
- }
- l += 1;
- break;
- case "(":
- depth += 1;
- b = false;
- if (s.charAt(l) === "?") {
- l += 1;
- switch (s.charAt(l)) {
- case ":":
- case "=":
- case "!":
- l += 1;
- break;
- default:
- warningAt(
-"Expected '{a}' and instead saw '{b}'.", line, from + l, ":", s.charAt(l));
- }
- } else {
- captures += 1;
- }
- break;
- case "|":
- b = false;
- break;
- case ")":
- if (depth === 0) {
- warningAt("Unescaped '{a}'.",
- line, from + l, ")");
- } else {
- depth -= 1;
- }
- break;
- case " ":
- q = 1;
- while (s.charAt(l) === " ") {
- l += 1;
- q += 1;
- }
- if (q > 1) {
- warningAt(
-"Spaces are hard to count. Use {{a}}.", line, from + l, q);
- }
- break;
- case "[":
- c = s.charAt(l);
- if (c === "^") {
- l += 1;
- if (option.regexp) {
- warningAt("Insecure '{a}'.",
- line, from + l, c);
- } else if (s.charAt(l) === "]") {
- errorAt("Unescaped '{a}'.",
- line, from + l, "^");
- }
- }
- if (c === "]") {
- warningAt("Empty class.", line,
- from + l - 1);
- }
- isLiteral = false;
- isInRange = false;
-klass: do {
- c = s.charAt(l);
- l += 1;
- switch (c) {
- case "[":
- case "^":
- warningAt("Unescaped '{a}'.",
- line, from + l, c);
- if (isInRange) {
- isInRange = false;
- } else {
- isLiteral = true;
- }
- break;
- case "-":
- if (isLiteral && !isInRange) {
- isLiteral = false;
- isInRange = true;
- } else if (isInRange) {
- isInRange = false;
- } else if (s.charAt(l) === "]") {
- isInRange = true;
- } else {
- if (option.regexdash !== (l === 2 || (l === 3 &&
- s.charAt(1) === "^"))) {
- warningAt("Unescaped '{a}'.",
- line, from + l - 1, "-");
- }
- isLiteral = true;
- }
- break;
- case "]":
- if (isInRange && !option.regexdash) {
- warningAt("Unescaped '{a}'.",
- line, from + l - 1, "-");
- }
- break klass;
- case "\\":
- c = s.charAt(l);
- if (c < " ") {
- warningAt(
-"Unexpected control character in regular expression.", line, from + l);
- } else if (c === "<") {
- warningAt(
-"Unexpected escaped character '{a}' in regular expression.", line, from + l, c);
- }
- l += 1;
-
- // \w, \s and \d are never part of a character range
- if (/[wsd]/i.test(c)) {
- if (isInRange) {
- warningAt("Unescaped '{a}'.",
- line, from + l, "-");
- isInRange = false;
- }
- isLiteral = false;
- } else if (isInRange) {
- isInRange = false;
- } else {
- isLiteral = true;
- }
- break;
- case "/":
- warningAt("Unescaped '{a}'.",
- line, from + l - 1, "/");
-
- if (isInRange) {
- isInRange = false;
- } else {
- isLiteral = true;
- }
- break;
- case "<":
- if (isInRange) {
- isInRange = false;
- } else {
- isLiteral = true;
- }
- break;
- default:
- if (isInRange) {
- isInRange = false;
- } else {
- isLiteral = true;
- }
- }
- } while (c);
- break;
- case ".":
- if (option.regexp) {
- warningAt("Insecure '{a}'.", line,
- from + l, c);
- }
- break;
- case "]":
- case "?":
- case "{":
- case "}":
- case "+":
- case "*":
- warningAt("Unescaped '{a}'.", line,
- from + l, c);
- }
- if (b) {
- switch (s.charAt(l)) {
- case "?":
- case "+":
- case "*":
- l += 1;
- if (s.charAt(l) === "?") {
- l += 1;
- }
- break;
- case "{":
- l += 1;
- c = s.charAt(l);
- if (c < "0" || c > "9") {
- warningAt(
-"Expected a number and instead saw '{a}'.", line, from + l, c);
- }
- l += 1;
- low = +c;
- for (;;) {
- c = s.charAt(l);
- if (c < "0" || c > "9") {
- break;
- }
- l += 1;
- low = +c + (low * 10);
- }
- high = low;
- if (c === ",") {
- l += 1;
- high = Infinity;
- c = s.charAt(l);
- if (c >= "0" && c <= "9") {
- l += 1;
- high = +c;
- for (;;) {
- c = s.charAt(l);
- if (c < "0" || c > "9") {
- break;
- }
- l += 1;
- high = +c + (high * 10);
- }
- }
- }
- if (s.charAt(l) !== "}") {
- warningAt(
-"Expected '{a}' and instead saw '{b}'.", line, from + l, "}", c);
- } else {
- l += 1;
- }
- if (s.charAt(l) === "?") {
- l += 1;
- }
- if (low > high) {
- warningAt(
-"'{a}' should not be greater than '{b}'.", line, from + l, low, high);
- }
- }
- }
- }
- c = s.substr(0, l - 1);
- character += l;
- s = s.substr(l);
- return it("(regexp)", c);
- }
- return it("(punctuator)", t);
-
- // punctuator
-
- case "#":
- return it("(punctuator)", t);
- default:
- return it("(punctuator)", t);
- }
- }
- }
- }
- };
- }());
-
-
- function addlabel(t, type, token) {
-
- if (t === "hasOwnProperty") {
- warning("'hasOwnProperty' is a really bad name.");
- }
-
- // Define t in the current function in the current scope.
- if (is_own(funct, t) && !funct["(global)"]) {
- if (funct[t] === true) {
- if (option.latedef)
- warning("'{a}' was used before it was defined.", nexttoken, t);
- } else {
- if (!option.shadow && type !== "exception")
- warning("'{a}' is already defined.", nexttoken, t);
- }
- }
-
- funct[t] = type;
-
- if (token) {
- funct["(tokens)"][t] = token;
- }
-
- if (funct["(global)"]) {
- global[t] = funct;
- if (is_own(implied, t)) {
- if (option.latedef)
- warning("'{a}' was used before it was defined.", nexttoken, t);
- delete implied[t];
- }
- } else {
- scope[t] = funct;
- }
- }
-
-
- function doOption() {
- var nt = nexttoken;
- var o = nt.value;
- var quotmarkValue = option.quotmark;
- var predef = {};
- var b, obj, filter, t, tn, v;
-
- switch (o) {
- case "*/":
- error("Unbegun comment.");
- break;
- case "/*members":
- case "/*member":
- o = "/*members";
- if (!membersOnly) {
- membersOnly = {};
- }
- obj = membersOnly;
- option.quotmark = false;
- break;
- case "/*jshint":
- case "/*jslint":
- obj = option;
- filter = boolOptions;
- break;
- case "/*global":
- obj = predef;
- break;
- default:
- error("What?");
- }
-
- t = lex.token();
-loop: for (;;) {
- for (;;) {
- if (t.type === "special" && t.value === "*/") {
- break loop;
- }
- if (t.id !== "(endline)" && t.id !== ",") {
- break;
- }
- t = lex.token();
- }
- if (t.type !== "(string)" && t.type !== "(identifier)" &&
- o !== "/*members") {
- error("Bad option.", t);
- }
-
- v = lex.token();
- if (v.id === ":") {
- v = lex.token();
-
- if (obj === membersOnly) {
- error("Expected '{a}' and instead saw '{b}'.", t, "*/", ":");
- }
-
- if (o === "/*jshint") {
- checkOption(t.value, t);
- }
-
- if (t.value === "indent" && (o === "/*jshint" || o === "/*jslint")) {
- b = +v.value;
- if (typeof b !== "number" || !isFinite(b) || b <= 0 ||
- Math.floor(b) !== b) {
- error("Expected a small integer and instead saw '{a}'.",
- v, v.value);
- }
- obj.white = true;
- obj.indent = b;
- } else if (t.value === "maxerr" && (o === "/*jshint" || o === "/*jslint")) {
- b = +v.value;
- if (typeof b !== "number" || !isFinite(b) || b <= 0 ||
- Math.floor(b) !== b) {
- error("Expected a small integer and instead saw '{a}'.",
- v, v.value);
- }
- obj.maxerr = b;
- } else if (t.value === "maxlen" && (o === "/*jshint" || o === "/*jslint")) {
- b = +v.value;
- if (typeof b !== "number" || !isFinite(b) || b <= 0 ||
- Math.floor(b) !== b) {
- error("Expected a small integer and instead saw '{a}'.",
- v, v.value);
- }
- obj.maxlen = b;
- } else if (t.value === "validthis") {
- if (funct["(global)"]) {
- error("Option 'validthis' can't be used in a global scope.");
- } else {
- if (v.value === "true" || v.value === "false")
- obj[t.value] = v.value === "true";
- else
- error("Bad option value.", v);
- }
- } else if (t.value === "quotmark" && (o === "/*jshint")) {
- switch (v.value) {
- case "true":
- obj.quotmark = true;
- break;
- case "false":
- obj.quotmark = false;
- break;
- case "double":
- case "single":
- obj.quotmark = v.value;
- break;
- default:
- error("Bad option value.", v);
- }
- } else if (v.value === "true" || v.value === "false") {
- if (o === "/*jslint") {
- tn = renamedOptions[t.value] || t.value;
- obj[tn] = v.value === "true";
- if (invertedOptions[tn] !== undefined) {
- obj[tn] = !obj[tn];
- }
- } else {
- obj[t.value] = v.value === "true";
- }
- } else {
- error("Bad option value.", v);
- }
- t = lex.token();
- } else {
- if (o === "/*jshint" || o === "/*jslint") {
- error("Missing option value.", t);
- }
- obj[t.value] = false;
- t = v;
- }
- }
-
- if (o === "/*members") {
- option.quotmark = quotmarkValue;
- }
-
- combine(predefined, predef);
-
- for (var key in predef) {
- if (is_own(predef, key)) {
- declared[key] = nt;
- }
- }
-
- if (filter) {
- assume();
- }
- }
-
-
-// We need a peek function. If it has an argument, it peeks that much farther
-// ahead. It is used to distinguish
-// for ( var i in ...
-// from
-// for ( var i = ...
-
- function peek(p) {
- var i = p || 0, j = 0, t;
-
- while (j <= i) {
- t = lookahead[j];
- if (!t) {
- t = lookahead[j] = lex.token();
- }
- j += 1;
- }
- return t;
- }
-
-
-
-// Produce the next token. It looks for programming errors.
-
- function advance(id, t) {
- switch (token.id) {
- case "(number)":
- if (nexttoken.id === ".") {
- warning("A dot following a number can be confused with a decimal point.", token);
- }
- break;
- case "-":
- if (nexttoken.id === "-" || nexttoken.id === "--") {
- warning("Confusing minusses.");
- }
- break;
- case "+":
- if (nexttoken.id === "+" || nexttoken.id === "++") {
- warning("Confusing plusses.");
- }
- break;
- }
-
- if (token.type === "(string)" || token.identifier) {
- anonname = token.value;
- }
-
- if (id && nexttoken.id !== id) {
- if (t) {
- if (nexttoken.id === "(end)") {
- warning("Unmatched '{a}'.", t, t.id);
- } else {
- warning("Expected '{a}' to match '{b}' from line {c} and instead saw '{d}'.",
- nexttoken, id, t.id, t.line, nexttoken.value);
- }
- } else if (nexttoken.type !== "(identifier)" ||
- nexttoken.value !== id) {
- warning("Expected '{a}' and instead saw '{b}'.",
- nexttoken, id, nexttoken.value);
- }
- }
-
- prevtoken = token;
- token = nexttoken;
- for (;;) {
- nexttoken = lookahead.shift() || lex.token();
- if (nexttoken.id === "(end)" || nexttoken.id === "(error)") {
- return;
- }
- if (nexttoken.type === "special") {
- doOption();
- } else {
- if (nexttoken.id !== "(endline)") {
- break;
- }
- }
- }
- }
-
-
-// This is the heart of JSHINT, the Pratt parser. In addition to parsing, it
-// is looking for ad hoc lint patterns. We add .fud to Pratt's model, which is
-// like .nud except that it is only used on the first token of a statement.
-// Having .fud makes it much easier to define statement-oriented languages like
-// JavaScript. I retained Pratt's nomenclature.
-
-// .nud Null denotation
-// .fud First null denotation
-// .led Left denotation
-// lbp Left binding power
-// rbp Right binding power
-
-// They are elements of the parsing method called Top Down Operator Precedence.
-
- function expression(rbp, initial) {
- var left, isArray = false, isObject = false;
-
- if (nexttoken.id === "(end)")
- error("Unexpected early end of program.", token);
-
- advance();
- if (initial) {
- anonname = "anonymous";
- funct["(verb)"] = token.value;
- }
- if (initial === true && token.fud) {
- left = token.fud();
- } else {
- if (token.nud) {
- left = token.nud();
- } else {
- if (nexttoken.type === "(number)" && token.id === ".") {
- warning("A leading decimal point can be confused with a dot: '.{a}'.",
- token, nexttoken.value);
- advance();
- return token;
- } else {
- error("Expected an identifier and instead saw '{a}'.",
- token, token.id);
- }
- }
- while (rbp < nexttoken.lbp) {
- isArray = token.value === "Array";
- isObject = token.value === "Object";
-
- // #527, new Foo.Array(), Foo.Array(), new Foo.Object(), Foo.Object()
- // Line breaks in IfStatement heads exist to satisfy the checkJSHint
- // "Line too long." error.
- if (left && (left.value || (left.first && left.first.value))) {
- // If the left.value is not "new", or the left.first.value is a "."
- // then safely assume that this is not "new Array()" and possibly
- // not "new Object()"...
- if (left.value !== "new" ||
- (left.first && left.first.value && left.first.value === ".")) {
- isArray = false;
- // ...In the case of Object, if the left.value and token.value
- // are not equal, then safely assume that this not "new Object()"
- if (left.value !== token.value) {
- isObject = false;
- }
- }
- }
-
- advance();
- if (isArray && token.id === "(" && nexttoken.id === ")")
- warning("Use the array literal notation [].", token);
- if (isObject && token.id === "(" && nexttoken.id === ")")
- warning("Use the object literal notation {}.", token);
- if (token.led) {
- left = token.led(left);
- } else {
- error("Expected an operator and instead saw '{a}'.",
- token, token.id);
- }
- }
- }
- return left;
- }
-
-
-// Functions for conformance of style.
-
- function adjacent(left, right) {
- left = left || token;
- right = right || nexttoken;
- if (option.white) {
- if (left.character !== right.from && left.line === right.line) {
- left.from += (left.character - left.from);
- warning("Unexpected space after '{a}'.", left, left.value);
- }
- }
- }
-
- function nobreak(left, right) {
- left = left || token;
- right = right || nexttoken;
- if (option.white && (left.character !== right.from || left.line !== right.line)) {
- warning("Unexpected space before '{a}'.", right, right.value);
- }
- }
-
- function nospace(left, right) {
- left = left || token;
- right = right || nexttoken;
- if (option.white && !left.comment) {
- if (left.line === right.line) {
- adjacent(left, right);
- }
- }
- }
-
- function nonadjacent(left, right) {
- if (option.white) {
- left = left || token;
- right = right || nexttoken;
- if (left.value === ";" && right.value === ";") {
- return;
- }
- if (left.line === right.line && left.character === right.from) {
- left.from += (left.character - left.from);
- warning("Missing space after '{a}'.",
- left, left.value);
- }
- }
- }
-
- function nobreaknonadjacent(left, right) {
- left = left || token;
- right = right || nexttoken;
- if (!option.laxbreak && left.line !== right.line) {
- warning("Bad line breaking before '{a}'.", right, right.id);
- } else if (option.white) {
- left = left || token;
- right = right || nexttoken;
- if (left.character === right.from) {
- left.from += (left.character - left.from);
- warning("Missing space after '{a}'.",
- left, left.value);
- }
- }
- }
-
- function indentation(bias) {
- var i;
- if (option.white && nexttoken.id !== "(end)") {
- i = indent + (bias || 0);
- if (nexttoken.from !== i) {
- warning(
-"Expected '{a}' to have an indentation at {b} instead at {c}.",
-
<TRUNCATED>
[12/26] Remove fauxton from 1.4.x branch.
Posted by dj...@apache.org.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/js/plugins/backbone.layoutmanager.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/plugins/backbone.layoutmanager.js b/src/fauxton/assets/js/plugins/backbone.layoutmanager.js
deleted file mode 100644
index e578c94..0000000
--- a/src/fauxton/assets/js/plugins/backbone.layoutmanager.js
+++ /dev/null
@@ -1,875 +0,0 @@
-/*!
- * backbone.layoutmanager.js v0.8.7
- * Copyright 2013, Tim Branyen (@tbranyen)
- * backbone.layoutmanager.js may be freely distributed under the MIT license.
- */
-(function(window) {
-
-"use strict";
-
-// Hoisted, referenced at the bottom of the source. This caches a list of all
-// LayoutManager options at definition time.
-var keys;
-
-// Localize global dependency references.
-var Backbone = window.Backbone;
-var _ = window._;
-var $ = Backbone.$;
-
-// Used for issuing warnings and debugging.
-var warn = window.console && window.console.warn;
-var trace = window.console && window.console.trace;
-
-// Maintain references to the two `Backbone.View` functions that are
-// overwritten so that they can be proxied.
-var _configure = Backbone.View.prototype._configure;
-var render = Backbone.View.prototype.render;
-
-// Cache these methods for performance.
-var aPush = Array.prototype.push;
-var aConcat = Array.prototype.concat;
-var aSplice = Array.prototype.splice;
-
-// LayoutManager is a wrapper around a `Backbone.View`.
-var LayoutManager = Backbone.View.extend({
- // This named function allows for significantly easier debugging.
- constructor: function Layout(options) {
- // Options may not always be passed to the constructor, this ensures it is
- // always an object.
- options = options || {};
-
- // Grant this View superpowers.
- LayoutManager.setupView(this, options);
-
- // Have Backbone set up the rest of this View.
- Backbone.View.call(this, options);
- },
-
- // Shorthand to `setView` function with the `insert` flag set.
- insertView: function(selector, view) {
- // If the `view` argument exists, then a selector was passed in. This code
- // path will forward the selector on to `setView`.
- if (view) {
- return this.setView(selector, view, true);
- }
-
- // If no `view` argument is defined, then assume the first argument is the
- // View, somewhat now confusingly named `selector`.
- return this.setView(selector, true);
- },
-
- // Iterate over an object and ensure every value is wrapped in an array to
- // ensure they will be inserted, then pass that object to `setViews`.
- insertViews: function(views) {
- // If an array of views was passed it should be inserted into the
- // root view. Much like calling insertView without a selector.
- if (_.isArray(views)) {
- return this.setViews({ "": views });
- }
-
- _.each(views, function(view, selector) {
- views[selector] = _.isArray(view) ? view : [view];
- });
-
- return this.setViews(views);
- },
-
- // Returns the View that matches the `getViews` filter function.
- getView: function(fn) {
- // If `getView` is invoked with undefined as the first argument, then the
- // second argument will be used instead. This is to allow
- // `getViews(undefined, fn)` to work as `getViews(fn)`. Useful for when
- // you are allowing an optional selector.
- if (fn == null) {
- fn = arguments[1];
- }
-
- return this.getViews(fn).first().value();
- },
-
- // Provide a filter function to get a flattened array of all the subviews.
- // If the filter function is omitted it will return all subviews. If a
- // String is passed instead, it will return the Views for that selector.
- getViews: function(fn) {
- // Generate an array of all top level (no deeply nested) Views flattened.
- var views = _.chain(this.views).map(function(view) {
- return _.isArray(view) ? view : [view];
- }, this).flatten().value();
-
- // If the filter argument is a String, then return a chained Version of the
- // elements.
- if (typeof fn === "string") {
- return _.chain([this.views[fn]]).flatten();
- }
-
- // If the argument passed is an Object, then pass it to `_.where`.
- if (typeof fn === "object") {
- return _.chain([_.where(views, fn)]).flatten();
- }
-
- // If a filter function is provided, run it on all Views and return a
- // wrapped chain. Otherwise, simply return a wrapped chain of all Views.
- return _.chain(typeof fn === "function" ? _.filter(views, fn) : views);
- },
-
- // Use this to remove Views, internally uses `getViews` so you can pass the
- // same argument here as you would to that method.
- removeView: function(fn) {
- // Allow an optional selector or function to find the right model and
- // remove nested Views based off the results of the selector or filter.
- return this.getViews(fn).each(function(nestedView) {
- nestedView.remove();
- });
- },
-
- // This takes in a partial name and view instance and assigns them to
- // the internal collection of views. If a view is not a LayoutManager
- // instance, then mix in the LayoutManager prototype. This ensures
- // all Views can be used successfully.
- //
- // Must definitely wrap any render method passed in or defaults to a
- // typical render function `return layout(this).render()`.
- setView: function(name, view, insert) {
- var manager, existing, options;
- // Parent view, the one you are setting a View on.
- var root = this;
-
- // If no name was passed, use an empty string and shift all arguments.
- if (typeof name !== "string") {
- insert = view;
- view = name;
- name = "";
- }
-
- // If the parent views object doesn't exist... create it.
- this.views = this.views || {};
-
- // Shorthand the `__manager__` property.
- manager = view.__manager__;
-
- // Shorthand the View that potentially already exists.
- existing = this.views[name];
-
- // If the View has not been properly set up, throw an Error message
- // indicating that the View needs `manage: true` set.
- if (!manager) {
- throw new Error("Please set `View#manage` property with selector '" +
- name + "' to `true`.");
- }
-
- // Assign options.
- options = view.getAllOptions();
-
- // Add reference to the parentView.
- manager.parent = root;
-
- // Add reference to the placement selector used.
- manager.selector = name;
-
- // Set up event bubbling, inspired by Backbone.ViewMaster. Do not bubble
- // internal events that are triggered.
- view.on("all", function(name) {
- if (name !== "beforeRender" && name !== "afterRender") {
- root.trigger.apply(root, arguments);
- }
- }, view);
-
- // Code path is less complex for Views that are not being inserted. Simply
- // remove existing Views and bail out with the assignment.
- if (!insert) {
- // If the View we are adding has already been rendered, simply inject it
- // into the parent.
- if (manager.hasRendered) {
- // Apply the partial.
- options.partial(root.$el, view.$el, root.__manager__, manager);
- }
-
- // Ensure remove is called when swapping View's.
- if (existing) {
- // If the views are an array, iterate and remove each individually.
- _.each(aConcat.call([], existing), function(nestedView) {
- nestedView.remove();
- });
- }
-
- // Assign to main views object and return for chainability.
- return this.views[name] = view;
- }
-
- // Ensure this.views[name] is an array and push this View to the end.
- this.views[name] = aConcat.call([], existing || [], view);
-
- // Put the view into `insert` mode.
- manager.insert = true;
-
- return view;
- },
-
- // Allows the setting of multiple views instead of a single view.
- setViews: function(views) {
- // Iterate over all the views and use the View's view method to assign.
- _.each(views, function(view, name) {
- // If the view is an array put all views into insert mode.
- if (_.isArray(view)) {
- return _.each(view, function(view) {
- this.insertView(name, view);
- }, this);
- }
-
- // Assign each view using the view function.
- this.setView(name, view);
- }, this);
-
- // Allow for chaining
- return this;
- },
-
- // By default this should find all nested views and render them into
- // the this.el and call done once all of them have successfully been
- // resolved.
- //
- // This function returns a promise that can be chained to determine
- // once all subviews and main view have been rendered into the view.el.
- render: function() {
- var root = this;
- var options = root.getAllOptions();
- var manager = root.__manager__;
- var parent = manager.parent;
- var rentManager = parent && parent.__manager__;
- var def = options.deferred();
-
- // Triggered once the render has succeeded.
- function resolve() {
- var next, afterRender;
-
- // If there is a parent, attach.
- if (parent) {
- if (!options.contains(parent.el, root.el)) {
- // Apply the partial.
- options.partial(parent.$el, root.$el, rentManager, manager);
- }
- }
-
- // Ensure events are always correctly bound after rendering.
- root.delegateEvents();
-
- // Set this View as successfully rendered.
- manager.hasRendered = true;
-
- // Only process the queue if it exists.
- if (next = manager.queue.shift()) {
- // Ensure that the next render is only called after all other
- // `done` handlers have completed. This will prevent `render`
- // callbacks from firing out of order.
- next();
- } else {
- // Once the queue is depleted, remove it, the render process has
- // completed.
- delete manager.queue;
- }
-
- // Reusable function for triggering the afterRender callback and event
- // and setting the hasRendered flag.
- function completeRender() {
- var afterRender = options.afterRender;
-
- if (afterRender) {
- afterRender.call(root, root);
- }
-
- // Always emit an afterRender event.
- root.trigger("afterRender", root);
-
- // If there are multiple top level elements and `el: false` is used,
- // display a warning message and a stack trace.
- if (manager.noel && root.$el.length > 1) {
- // Do not display a warning while testing or if warning suppression
- // is enabled.
- if (warn && !options.suppressWarnings) {
- window.console.warn("Using `el: false` with multiple top level " +
- "elements is not supported.");
-
- // Provide a stack trace if available to aid with debugging.
- if (trace) { window.console.trace(); }
- }
- }
- }
-
- // If the parent is currently rendering, wait until it has completed
- // until calling the nested View's `afterRender`.
- if (rentManager && rentManager.queue) {
- // Wait until the parent View has finished rendering, which could be
- // asynchronous, and trigger afterRender on this View once it has
- // compeleted.
- parent.once("afterRender", completeRender);
- } else {
- // This View and its parent have both rendered.
- completeRender();
- }
-
- return def.resolveWith(root, [root]);
- }
-
- // Actually facilitate a render.
- function actuallyRender() {
- var options = root.getAllOptions();
- var manager = root.__manager__;
- var parent = manager.parent;
- var rentManager = parent && parent.__manager__;
-
- // The `_viewRender` method is broken out to abstract away from having
- // too much code in `actuallyRender`.
- root._render(LayoutManager._viewRender, options).done(function() {
- // If there are no children to worry about, complete the render
- // instantly.
- if (!_.keys(root.views).length) {
- return resolve();
- }
-
- // Create a list of promises to wait on until rendering is done.
- // Since this method will run on all children as well, its sufficient
- // for a full hierarchical.
- var promises = _.map(root.views, function(view) {
- var insert = _.isArray(view);
-
- // If items are being inserted, they will be in a non-zero length
- // Array.
- if (insert && view.length) {
- // Schedule each view to be rendered in order and return a promise
- // representing the result of the final rendering.
- return _.reduce(view.slice(1), function(prevRender, view) {
- return prevRender.then(function() {
- return view.render();
- });
- // The first view should be rendered immediately, and the resulting
- // promise used to initialize the reduction.
- }, view[0].render());
- }
-
- // Only return the fetch deferred, resolve the main deferred after
- // the element has been attached to it's parent.
- return !insert ? view.render() : view;
- });
-
- // Once all nested Views have been rendered, resolve this View's
- // deferred.
- options.when(promises).done(resolve);
- });
- }
-
- // Another render is currently happening if there is an existing queue, so
- // push a closure to render later into the queue.
- if (manager.queue) {
- aPush.call(manager.queue, actuallyRender);
- } else {
- manager.queue = [];
-
- // This the first `render`, preceeding the `queue` so render
- // immediately.
- actuallyRender(root, def);
- }
-
- // Add the View to the deferred so that `view.render().view.el` is
- // possible.
- def.view = root;
-
- // This is the promise that determines if the `render` function has
- // completed or not.
- return def;
- },
-
- // Ensure the cleanup function is called whenever remove is called.
- remove: function() {
- // Force remove itself from its parent.
- LayoutManager._removeView(this, true);
-
- // Call the original remove function.
- return this._remove.apply(this, arguments);
- },
-
- // Merge instance and global options.
- getAllOptions: function() {
- // Instance overrides take precedence, fallback to prototype options.
- return _.extend({}, this, LayoutManager.prototype.options, this.options);
- }
-},
-{
- // Clearable cache.
- _cache: {},
-
- // Creates a deferred and returns a function to call when finished.
- _makeAsync: function(options, done) {
- var handler = options.deferred();
-
- // Used to handle asynchronous renders.
- handler.async = function() {
- handler._isAsync = true;
-
- return done;
- };
-
- return handler;
- },
-
- // This gets passed to all _render methods. The `root` value here is passed
- // from the `manage(this).render()` line in the `_render` function
- _viewRender: function(root, options) {
- var url, contents, fetchAsync, renderedEl;
- var manager = root.__manager__;
-
- // This function is responsible for pairing the rendered template into
- // the DOM element.
- function applyTemplate(rendered) {
- // Actually put the rendered contents into the element.
- if (rendered) {
- // If no container is specified, we must replace the content.
- if (manager.noel) {
- // Trim off the whitespace, since the contents are passed into `$()`.
- rendered = $.trim(rendered);
-
- // Hold a reference to created element as replaceWith doesn't return
- // new el.
- renderedEl = $(rendered);
-
- // Remove extra root elements.
- root.$el.slice(1).remove();
-
- // Swap out the View on the first top level element to avoid
- // duplication.
- root.$el.replaceWith(renderedEl);
-
- // Don't delegate events here - we'll do that in resolve()
- root.setElement(renderedEl, false);
- } else {
- options.html(root.$el, rendered);
- }
- }
-
- // Resolve only after fetch and render have succeeded.
- fetchAsync.resolveWith(root, [root]);
- }
-
- // Once the template is successfully fetched, use its contents to proceed.
- // Context argument is first, since it is bound for partial application
- // reasons.
- function done(context, contents) {
- // Store the rendered template someplace so it can be re-assignable.
- var rendered;
- // This allows the `render` method to be asynchronous as well as `fetch`.
- var renderAsync = LayoutManager._makeAsync(options, function(rendered) {
- applyTemplate(rendered);
- });
-
- // Ensure the cache is up-to-date.
- LayoutManager.cache(url, contents);
-
- // Render the View into the el property.
- if (contents) {
- rendered = options.render.call(renderAsync, contents, context);
- }
-
- // If the function was synchronous, continue execution.
- if (!renderAsync._isAsync) {
- applyTemplate(rendered);
- }
- }
-
- return {
- // This `render` function is what gets called inside of the View render,
- // when `manage(this).render` is called. Returns a promise that can be
- // used to know when the element has been rendered into its parent.
- render: function() {
- var context = root.serialize || options.serialize;
- var template = root.template || options.template;
-
- // If data is a function, immediately call it.
- if (_.isFunction(context)) {
- context = context.call(root);
- }
-
- // This allows for `var done = this.async()` and then `done(contents)`.
- fetchAsync = LayoutManager._makeAsync(options, function(contents) {
- done(context, contents);
- });
-
- // Set the url to the prefix + the view's template property.
- if (typeof template === "string") {
- url = options.prefix + template;
- }
-
- // Check if contents are already cached and if they are, simply process
- // the template with the correct data.
- if (contents = LayoutManager.cache(url)) {
- done(context, contents, url);
-
- return fetchAsync;
- }
-
- // Fetch layout and template contents.
- if (typeof template === "string") {
- contents = options.fetch.call(fetchAsync, options.prefix + template);
- // If the template is already a function, simply call it.
- } else if (typeof template === "function") {
- contents = template;
- // If its not a string and not undefined, pass the value to `fetch`.
- } else if (template != null) {
- contents = options.fetch.call(fetchAsync, template);
- }
-
- // If the function was synchronous, continue execution.
- if (!fetchAsync._isAsync) {
- done(context, contents);
- }
-
- return fetchAsync;
- }
- };
- },
-
- // Remove all nested Views.
- _removeViews: function(root, force) {
- var views;
-
- // Shift arguments around.
- if (typeof root === "boolean") {
- force = root;
- root = this;
- }
-
- // Allow removeView to be called on instances.
- root = root || this;
-
- // Iterate over all of the nested View's and remove.
- root.getViews().each(function(view) {
- // Force doesn't care about if a View has rendered or not.
- if (view.__manager__.hasRendered || force) {
- LayoutManager._removeView(view, force);
- }
- });
- },
-
- // Remove a single nested View.
- _removeView: function(view, force) {
- var parentViews;
- // Shorthand the manager for easier access.
- var manager = view.__manager__;
- // Test for keep.
- var keep = typeof view.keep === "boolean" ? view.keep : view.options.keep;
-
- // Only remove views that do not have `keep` attribute set, unless the
- // View is in `insert` mode and the force flag is set.
- if ((!keep && manager.insert === true) || force) {
- // Clean out the events.
- LayoutManager.cleanViews(view);
-
- // Since we are removing this view, force subviews to remove
- view._removeViews(true);
-
- // Remove the View completely.
- view.$el.remove();
-
- // Bail out early if no parent exists.
- if (!manager.parent) { return; }
-
- // Assign (if they exist) the sibling Views to a property.
- parentViews = manager.parent.views[manager.selector];
-
- // If this is an array of items remove items that are not marked to
- // keep.
- if (_.isArray(parentViews)) {
- // Remove duplicate Views.
- return _.each(_.clone(parentViews), function(view, i) {
- // If the managers match, splice off this View.
- if (view && view.__manager__ === manager) {
- aSplice.call(parentViews, i, 1);
- }
- });
- }
-
- // Otherwise delete the parent selector.
- delete manager.parent.views[manager.selector];
- }
- },
-
- // Cache templates into LayoutManager._cache.
- cache: function(path, contents) {
- // If template path is found in the cache, return the contents.
- if (path in this._cache && contents == null) {
- return this._cache[path];
- // Ensure path and contents aren't undefined.
- } else if (path != null && contents != null) {
- return this._cache[path] = contents;
- }
-
- // If the template is not in the cache, return undefined.
- },
-
- // Accept either a single view or an array of views to clean of all DOM
- // events internal model and collection references and all Backbone.Events.
- cleanViews: function(views) {
- // Clear out all existing views.
- _.each(aConcat.call([], views), function(view) {
- // Remove all custom events attached to this View.
- view.unbind();
-
- // Automatically unbind `model`.
- if (view.model instanceof Backbone.Model) {
- view.model.off(null, null, view);
- }
-
- // Automatically unbind `collection`.
- if (view.collection instanceof Backbone.Collection) {
- view.collection.off(null, null, view);
- }
-
- // Automatically unbind events bound to this View.
- view.stopListening();
-
- // If a custom cleanup method was provided on the view, call it after
- // the initial cleanup is done
- _.result(view.getAllOptions(), "cleanup");
- });
- },
-
- // This static method allows for global configuration of LayoutManager.
- configure: function(options) {
- _.extend(LayoutManager.prototype.options, options);
-
- // Allow LayoutManager to manage Backbone.View.prototype.
- if (options.manage) {
- Backbone.View.prototype.manage = true;
- }
-
- // Disable the element globally.
- if (options.el === false) {
- Backbone.View.prototype.el = false;
- }
-
- // Allow global configuration of `suppressWarnings`.
- if (options.suppressWarnings === true) {
- Backbone.View.prototype.suppressWarnings = true;
- }
- },
-
- // Configure a View to work with the LayoutManager plugin.
- setupView: function(views, options) {
- // Set up all Views passed.
- _.each(aConcat.call([], views), function(view) {
- // If the View has already been setup, no need to do it again.
- if (view.__manager__) {
- return;
- }
-
- var views, declaredViews, viewOptions;
- var proto = LayoutManager.prototype;
- var viewOverrides = _.pick(view, keys);
-
- // Ensure necessary properties are set.
- _.defaults(view, {
- // Ensure a view always has a views object.
- views: {},
-
- // Internal state object used to store whether or not a View has been
- // taken over by layout manager and if it has been rendered into the DOM.
- __manager__: {},
-
- // Add the ability to remove all Views.
- _removeViews: LayoutManager._removeViews,
-
- // Add the ability to remove itself.
- _removeView: LayoutManager._removeView
-
- // Mix in all LayoutManager prototype properties as well.
- }, LayoutManager.prototype);
-
- // Extend the options with the prototype and passed options.
- options = view.options = _.defaults(options || {}, view.options,
- proto.options);
-
- // Ensure view events are properly copied over.
- viewOptions = _.pick(options, aConcat.call(["events"],
- _.values(options.events)));
-
- // Merge the View options into the View.
- _.extend(view, viewOptions);
-
- // If the View still has the Backbone.View#render method, remove it.
- // Don't want it accidentally overriding the LM render.
- if (viewOverrides.render === LayoutManager.prototype.render ||
- viewOverrides.render === Backbone.View.prototype.render) {
- delete viewOverrides.render;
- }
-
- // Pick out the specific properties that can be dynamically added at
- // runtime and ensure they are available on the view object.
- _.extend(options, viewOverrides);
-
- // By default the original Remove function is the Backbone.View one.
- view._remove = Backbone.View.prototype.remove;
-
- // Always use this render function when using LayoutManager.
- view._render = function(manage, options) {
- // Keep the view consistent between callbacks and deferreds.
- var view = this;
- // Shorthand the manager.
- var manager = view.__manager__;
- // Cache these properties.
- var beforeRender = options.beforeRender;
-
- // Ensure all nested Views are properly scrubbed if re-rendering.
- if (manager.hasRendered) {
- this._removeViews();
- }
-
- // If a beforeRender function is defined, call it.
- if (beforeRender) {
- beforeRender.call(this, this);
- }
-
- // Always emit a beforeRender event.
- this.trigger("beforeRender", this);
-
- // Render!
- return manage(this, options).render();
- };
-
- // Ensure the render is always set correctly.
- view.render = LayoutManager.prototype.render;
-
- // If the user provided their own remove override, use that instead of
- // the default.
- if (view.remove !== proto.remove) {
- view._remove = view.remove;
- view.remove = proto.remove;
- }
-
- // Normalize views to exist on either instance or options, default to
- // options.
- views = options.views || view.views;
-
- // Set the internal views, only if selectors have been provided.
- if (_.keys(views).length) {
- // Keep original object declared containing Views.
- declaredViews = views;
-
- // Reset the property to avoid duplication or overwritting.
- view.views = {};
-
- // Set the declared Views.
- view.setViews(declaredViews);
- }
-
- // If a template is passed use that instead.
- if (view.options.template) {
- view.options.template = options.template;
- // Ensure the template is mapped over.
- } else if (view.template) {
- options.template = view.template;
- }
- });
- }
-});
-
-// Convenience assignment to make creating Layout's slightly shorter.
-Backbone.Layout = LayoutManager;
-// Tack on the version.
-LayoutManager.VERSION = "0.8.7";
-
-// Override _configure to provide extra functionality that is necessary in
-// order for the render function reference to be bound during initialize.
-Backbone.View.prototype._configure = function(options) {
- var noel, retVal;
-
- // Remove the container element provided by Backbone.
- if ("el" in options ? options.el === false : this.el === false) {
- noel = true;
- }
-
- // Run the original _configure.
- retVal = _configure.apply(this, arguments);
-
- // If manage is set, do it!
- if (options.manage || this.manage) {
- // Set up this View.
- LayoutManager.setupView(this);
- }
-
- // Assign the `noel` property once we're sure the View we're working with is
- // managed by LayoutManager.
- if (this.__manager__) {
- this.__manager__.noel = noel;
- this.__manager__.suppressWarnings = options.suppressWarnings;
- }
-
- // Act like nothing happened.
- return retVal;
-};
-
-// Default configuration options; designed to be overriden.
-LayoutManager.prototype.options = {
- // Prefix template/layout paths.
- prefix: "",
-
- // Can be used to supply a different deferred implementation.
- deferred: function() {
- return $.Deferred();
- },
-
- // Fetch is passed a path and is expected to return template contents as a
- // function or string.
- fetch: function(path) {
- return _.template($(path).html());
- },
-
- // This is the most common way you will want to partially apply a view into
- // a layout.
- partial: function($root, $el, rentManager, manager) {
- // If selector is specified, attempt to find it.
- if (manager.selector) {
- if (rentManager.noel) {
- var $filtered = $root.filter(manager.selector);
- $root = $filtered.length ? $filtered : $root.find(manager.selector);
- } else {
- $root = $root.find(manager.selector);
- }
- }
-
- // Use the insert method if insert argument is true.
- if (manager.insert) {
- this.insert($root, $el);
- } else {
- this.html($root, $el);
- }
- },
-
- // Override this with a custom HTML method, passed a root element and content
- // (a jQuery collection or a string) to replace the innerHTML with.
- html: function($root, content) {
- $root.html(content);
- },
-
- // Very similar to HTML except this one will appendChild by default.
- insert: function($root, $el) {
- $root.append($el);
- },
-
- // Return a deferred for when all promises resolve/reject.
- when: function(promises) {
- return $.when.apply(null, promises);
- },
-
- // By default, render using underscore's templating.
- render: function(template, context) {
- return template(context);
- },
-
- // A method to determine if a View contains another.
- contains: function(parent, child) {
- return $.contains(parent, child);
- }
-};
-
-// Maintain a list of the keys at define time.
-keys = _.keys(LayoutManager.prototype.options);
-
-})(typeof global === "object" ? global : this);
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/js/plugins/codemirror-javascript.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/plugins/codemirror-javascript.js b/src/fauxton/assets/js/plugins/codemirror-javascript.js
deleted file mode 100644
index 65f11c5..0000000
--- a/src/fauxton/assets/js/plugins/codemirror-javascript.js
+++ /dev/null
@@ -1,361 +0,0 @@
-CodeMirror.defineMode("javascript", function(config, parserConfig) {
- var indentUnit = config.indentUnit;
- var jsonMode = parserConfig.json;
-
- // Tokenizer
-
- var keywords = function(){
- function kw(type) {return {type: type, style: "keyword"};}
- var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c");
- var operator = kw("operator"), atom = {type: "atom", style: "atom"};
- return {
- "if": A, "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B,
- "return": C, "break": C, "continue": C, "new": C, "delete": C, "throw": C,
- "var": kw("var"), "const": kw("var"), "let": kw("var"),
- "function": kw("function"), "catch": kw("catch"),
- "for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"),
- "in": operator, "typeof": operator, "instanceof": operator,
- "true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom
- };
- }();
-
- var isOperatorChar = /[+\-*&%=<>!?|]/;
-
- function chain(stream, state, f) {
- state.tokenize = f;
- return f(stream, state);
- }
-
- function nextUntilUnescaped(stream, end) {
- var escaped = false, next;
- while ((next = stream.next()) != null) {
- if (next == end && !escaped)
- return false;
- escaped = !escaped && next == "\\";
- }
- return escaped;
- }
-
- // Used as scratch variables to communicate multiple values without
- // consing up tons of objects.
- var type, content;
- function ret(tp, style, cont) {
- type = tp; content = cont;
- return style;
- }
-
- function jsTokenBase(stream, state) {
- var ch = stream.next();
- if (ch == '"' || ch == "'")
- return chain(stream, state, jsTokenString(ch));
- else if (/[\[\]{}\(\),;\:\.]/.test(ch))
- return ret(ch);
- else if (ch == "0" && stream.eat(/x/i)) {
- stream.eatWhile(/[\da-f]/i);
- return ret("number", "number");
- }
- else if (/\d/.test(ch) || ch == "-" && stream.eat(/\d/)) {
- stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/);
- return ret("number", "number");
- }
- else if (ch == "/") {
- if (stream.eat("*")) {
- return chain(stream, state, jsTokenComment);
- }
- else if (stream.eat("/")) {
- stream.skipToEnd();
- return ret("comment", "comment");
- }
- else if (state.reAllowed) {
- nextUntilUnescaped(stream, "/");
- stream.eatWhile(/[gimy]/); // 'y' is "sticky" option in Mozilla
- return ret("regexp", "string-2");
- }
- else {
- stream.eatWhile(isOperatorChar);
- return ret("operator", null, stream.current());
- }
- }
- else if (ch == "#") {
- stream.skipToEnd();
- return ret("error", "error");
- }
- else if (isOperatorChar.test(ch)) {
- stream.eatWhile(isOperatorChar);
- return ret("operator", null, stream.current());
- }
- else {
- stream.eatWhile(/[\w\$_]/);
- var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word];
- return (known && state.kwAllowed) ? ret(known.type, known.style, word) :
- ret("variable", "variable", word);
- }
- }
-
- function jsTokenString(quote) {
- return function(stream, state) {
- if (!nextUntilUnescaped(stream, quote))
- state.tokenize = jsTokenBase;
- return ret("string", "string");
- };
- }
-
- function jsTokenComment(stream, state) {
- var maybeEnd = false, ch;
- while (ch = stream.next()) {
- if (ch == "/" && maybeEnd) {
- state.tokenize = jsTokenBase;
- break;
- }
- maybeEnd = (ch == "*");
- }
- return ret("comment", "comment");
- }
-
- // Parser
-
- var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true};
-
- function JSLexical(indented, column, type, align, prev, info) {
- this.indented = indented;
- this.column = column;
- this.type = type;
- this.prev = prev;
- this.info = info;
- if (align != null) this.align = align;
- }
-
- function inScope(state, varname) {
- for (var v = state.localVars; v; v = v.next)
- if (v.name == varname) return true;
- }
-
- function parseJS(state, style, type, content, stream) {
- var cc = state.cc;
- // Communicate our context to the combinators.
- // (Less wasteful than consing up a hundred closures on every call.)
- cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc;
-
- if (!state.lexical.hasOwnProperty("align"))
- state.lexical.align = true;
-
- while(true) {
- var combinator = cc.length ? cc.pop() : jsonMode ? expression : statement;
- if (combinator(type, content)) {
- while(cc.length && cc[cc.length - 1].lex)
- cc.pop()();
- if (cx.marked) return cx.marked;
- if (type == "variable" && inScope(state, content)) return "variable-2";
- return style;
- }
- }
- }
-
- // Combinator utils
-
- var cx = {state: null, column: null, marked: null, cc: null};
- function pass() {
- for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]);
- }
- function cont() {
- pass.apply(null, arguments);
- return true;
- }
- function register(varname) {
- var state = cx.state;
- if (state.context) {
- cx.marked = "def";
- for (var v = state.localVars; v; v = v.next)
- if (v.name == varname) return;
- state.localVars = {name: varname, next: state.localVars};
- }
- }
-
- // Combinators
-
- var defaultVars = {name: "this", next: {name: "arguments"}};
- function pushcontext() {
- if (!cx.state.context) cx.state.localVars = defaultVars;
- cx.state.context = {prev: cx.state.context, vars: cx.state.localVars};
- }
- function popcontext() {
- cx.state.localVars = cx.state.context.vars;
- cx.state.context = cx.state.context.prev;
- }
- function pushlex(type, info) {
- var result = function() {
- var state = cx.state;
- state.lexical = new JSLexical(state.indented, cx.stream.column(), type, null, state.lexical, info)
- };
- result.lex = true;
- return result;
- }
- function poplex() {
- var state = cx.state;
- if (state.lexical.prev) {
- if (state.lexical.type == ")")
- state.indented = state.lexical.indented;
- state.lexical = state.lexical.prev;
- }
- }
- poplex.lex = true;
-
- function expect(wanted) {
- return function expecting(type) {
- if (type == wanted) return cont();
- else if (wanted == ";") return pass();
- else return cont(arguments.callee);
- };
- }
-
- function statement(type) {
- if (type == "var") return cont(pushlex("vardef"), vardef1, expect(";"), poplex);
- if (type == "keyword a") return cont(pushlex("form"), expression, statement, poplex);
- if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
- if (type == "{") return cont(pushlex("}"), block, poplex);
- if (type == ";") return cont();
- if (type == "function") return cont(functiondef);
- if (type == "for") return cont(pushlex("form"), expect("("), pushlex(")"), forspec1, expect(")"),
- poplex, statement, poplex);
- if (type == "variable") return cont(pushlex("stat"), maybelabel);
- if (type == "switch") return cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"),
- block, poplex, poplex);
- if (type == "case") return cont(expression, expect(":"));
- if (type == "default") return cont(expect(":"));
- if (type == "catch") return cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"),
- statement, poplex, popcontext);
- return pass(pushlex("stat"), expression, expect(";"), poplex);
- }
- function expression(type) {
- if (atomicTypes.hasOwnProperty(type)) return cont(maybeoperator);
- if (type == "function") return cont(functiondef);
- if (type == "keyword c") return cont(maybeexpression);
- if (type == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeoperator);
- if (type == "operator") return cont(expression);
- if (type == "[") return cont(pushlex("]"), commasep(expression, "]"), poplex, maybeoperator);
- if (type == "{") return cont(pushlex("}"), commasep(objprop, "}"), poplex, maybeoperator);
- return cont();
- }
- function maybeexpression(type) {
- if (type.match(/[;\}\)\],]/)) return pass();
- return pass(expression);
- }
-
- function maybeoperator(type, value) {
- if (type == "operator" && /\+\+|--/.test(value)) return cont(maybeoperator);
- if (type == "operator" || type == ":") return cont(expression);
- if (type == ";") return;
- if (type == "(") return cont(pushlex(")"), commasep(expression, ")"), poplex, maybeoperator);
- if (type == ".") return cont(property, maybeoperator);
- if (type == "[") return cont(pushlex("]"), expression, expect("]"), poplex, maybeoperator);
- }
- function maybelabel(type) {
- if (type == ":") return cont(poplex, statement);
- return pass(maybeoperator, expect(";"), poplex);
- }
- function property(type) {
- if (type == "variable") {cx.marked = "property"; return cont();}
- }
- function objprop(type) {
- if (type == "variable") cx.marked = "property";
- if (atomicTypes.hasOwnProperty(type)) return cont(expect(":"), expression);
- }
- function commasep(what, end) {
- function proceed(type) {
- if (type == ",") return cont(what, proceed);
- if (type == end) return cont();
- return cont(expect(end));
- }
- return function commaSeparated(type) {
- if (type == end) return cont();
- else return pass(what, proceed);
- };
- }
- function block(type) {
- if (type == "}") return cont();
- return pass(statement, block);
- }
- function vardef1(type, value) {
- if (type == "variable"){register(value); return cont(vardef2);}
- return cont();
- }
- function vardef2(type, value) {
- if (value == "=") return cont(expression, vardef2);
- if (type == ",") return cont(vardef1);
- }
- function forspec1(type) {
- if (type == "var") return cont(vardef1, forspec2);
- if (type == ";") return pass(forspec2);
- if (type == "variable") return cont(formaybein);
- return pass(forspec2);
- }
- function formaybein(type, value) {
- if (value == "in") return cont(expression);
- return cont(maybeoperator, forspec2);
- }
- function forspec2(type, value) {
- if (type == ";") return cont(forspec3);
- if (value == "in") return cont(expression);
- return cont(expression, expect(";"), forspec3);
- }
- function forspec3(type) {
- if (type != ")") cont(expression);
- }
- function functiondef(type, value) {
- if (type == "variable") {register(value); return cont(functiondef);}
- if (type == "(") return cont(pushlex(")"), pushcontext, commasep(funarg, ")"), poplex, statement, popcontext);
- }
- function funarg(type, value) {
- if (type == "variable") {register(value); return cont();}
- }
-
- // Interface
-
- return {
- startState: function(basecolumn) {
- return {
- tokenize: jsTokenBase,
- reAllowed: true,
- kwAllowed: true,
- cc: [],
- lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
- localVars: parserConfig.localVars,
- context: parserConfig.localVars && {vars: parserConfig.localVars},
- indented: 0
- };
- },
-
- token: function(stream, state) {
- if (stream.sol()) {
- if (!state.lexical.hasOwnProperty("align"))
- state.lexical.align = false;
- state.indented = stream.indentation();
- }
- if (stream.eatSpace()) return null;
- var style = state.tokenize(stream, state);
- if (type == "comment") return style;
- state.reAllowed = !!(type == "operator" || type == "keyword c" || type.match(/^[\[{}\(,;:]$/));
- state.kwAllowed = type != '.';
- return parseJS(state, style, type, content, stream);
- },
-
- indent: function(state, textAfter) {
- if (state.tokenize != jsTokenBase) return 0;
- var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical;
- if (lexical.type == "stat" && firstChar == "}") lexical = lexical.prev;
- var type = lexical.type, closing = firstChar == type;
- if (type == "vardef") return lexical.indented + 4;
- else if (type == "form" && firstChar == "{") return lexical.indented;
- else if (type == "stat" || type == "form") return lexical.indented + indentUnit;
- else if (lexical.info == "switch" && !closing)
- return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit);
- else if (lexical.align) return lexical.column + (closing ? 0 : 1);
- else return lexical.indented + (closing ? 0 : indentUnit);
- },
-
- electricChars: ":{}"
- };
-});
-
-CodeMirror.defineMIME("text/javascript", "javascript");
-CodeMirror.defineMIME("application/json", {name: "javascript", json: true});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/js/plugins/jquery.form.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/plugins/jquery.form.js b/src/fauxton/assets/js/plugins/jquery.form.js
deleted file mode 100644
index e3126ca..0000000
--- a/src/fauxton/assets/js/plugins/jquery.form.js
+++ /dev/null
@@ -1,1190 +0,0 @@
-/*!
- * jQuery Form Plugin
- * version: 3.35.0-2013.05.23
- * @requires jQuery v1.5 or later
- * Copyright (c) 2013 M. Alsup
- * Examples and documentation at: http://malsup.com/jquery/form/
- * Project repository: https://github.com/malsup/form
- * Dual licensed under the MIT and GPL licenses.
- * https://github.com/malsup/form#copyright-and-license
- */
-/*global ActiveXObject */
-;(function($) {
-"use strict";
-
-/*
- Usage Note:
- -----------
- Do not use both ajaxSubmit and ajaxForm on the same form. These
- functions are mutually exclusive. Use ajaxSubmit if you want
- to bind your own submit handler to the form. For example,
-
- $(document).ready(function() {
- $('#myForm').on('submit', function(e) {
- e.preventDefault(); // <-- important
- $(this).ajaxSubmit({
- target: '#output'
- });
- });
- });
-
- Use ajaxForm when you want the plugin to manage all the event binding
- for you. For example,
-
- $(document).ready(function() {
- $('#myForm').ajaxForm({
- target: '#output'
- });
- });
-
- You can also use ajaxForm with delegation (requires jQuery v1.7+), so the
- form does not have to exist when you invoke ajaxForm:
-
- $('#myForm').ajaxForm({
- delegation: true,
- target: '#output'
- });
-
- When using ajaxForm, the ajaxSubmit function will be invoked for you
- at the appropriate time.
-*/
-
-/**
- * Feature detection
- */
-var feature = {};
-feature.fileapi = $("<input type='file'/>").get(0).files !== undefined;
-feature.formdata = window.FormData !== undefined;
-
-var hasProp = !!$.fn.prop;
-
-// attr2 uses prop when it can but checks the return type for
-// an expected string. this accounts for the case where a form
-// contains inputs with names like "action" or "method"; in those
-// cases "prop" returns the element
-$.fn.attr2 = function() {
- if ( ! hasProp )
- return this.attr.apply(this, arguments);
- var val = this.prop.apply(this, arguments);
- if ( ( val && val.jquery ) || typeof val === 'string' )
- return val;
- return this.attr.apply(this, arguments);
-};
-
-/**
- * ajaxSubmit() provides a mechanism for immediately submitting
- * an HTML form using AJAX.
- */
-$.fn.ajaxSubmit = function(options) {
- /*jshint scripturl:true */
-
- // fast fail if nothing selected (http://dev.jquery.com/ticket/2752)
- if (!this.length) {
- log('ajaxSubmit: skipping submit process - no element selected');
- return this;
- }
-
- var method, action, url, $form = this;
-
- if (typeof options == 'function') {
- options = { success: options };
- }
-
- method = options.type || this.attr2('method');
- action = options.url || this.attr2('action');
-
- url = (typeof action === 'string') ? $.trim(action) : '';
- url = url || window.location.href || '';
- if (url) {
- // clean url (don't include hash vaue)
- url = (url.match(/^([^#]+)/)||[])[1];
- }
-
- options = $.extend(true, {
- url: url,
- success: $.ajaxSettings.success,
- type: method || 'GET',
- iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank'
- }, options);
-
- // hook for manipulating the form data before it is extracted;
- // convenient for use with rich editors like tinyMCE or FCKEditor
- var veto = {};
- this.trigger('form-pre-serialize', [this, options, veto]);
- if (veto.veto) {
- log('ajaxSubmit: submit vetoed via form-pre-serialize trigger');
- return this;
- }
-
- // provide opportunity to alter form data before it is serialized
- if (options.beforeSerialize && options.beforeSerialize(this, options) === false) {
- log('ajaxSubmit: submit aborted via beforeSerialize callback');
- return this;
- }
-
- var traditional = options.traditional;
- if ( traditional === undefined ) {
- traditional = $.ajaxSettings.traditional;
- }
-
- var elements = [];
- var qx, a = this.formToArray(options.semantic, elements);
- if (options.data) {
- options.extraData = options.data;
- qx = $.param(options.data, traditional);
- }
-
- // give pre-submit callback an opportunity to abort the submit
- if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) {
- log('ajaxSubmit: submit aborted via beforeSubmit callback');
- return this;
- }
-
- // fire vetoable 'validate' event
- this.trigger('form-submit-validate', [a, this, options, veto]);
- if (veto.veto) {
- log('ajaxSubmit: submit vetoed via form-submit-validate trigger');
- return this;
- }
-
- var q = $.param(a, traditional);
- if (qx) {
- q = ( q ? (q + '&' + qx) : qx );
- }
- if (options.type.toUpperCase() == 'GET') {
- options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q;
- options.data = null; // data is null for 'get'
- }
- else {
- options.data = q; // data is the query string for 'post'
- }
-
- var callbacks = [];
- if (options.resetForm) {
- callbacks.push(function() { $form.resetForm(); });
- }
- if (options.clearForm) {
- callbacks.push(function() { $form.clearForm(options.includeHidden); });
- }
-
- // perform a load on the target only if dataType is not provided
- if (!options.dataType && options.target) {
- var oldSuccess = options.success || function(){};
- callbacks.push(function(data) {
- var fn = options.replaceTarget ? 'replaceWith' : 'html';
- $(options.target)[fn](data).each(oldSuccess, arguments);
- });
- }
- else if (options.success) {
- callbacks.push(options.success);
- }
-
- options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg
- var context = options.context || this ; // jQuery 1.4+ supports scope context
- for (var i=0, max=callbacks.length; i < max; i++) {
- callbacks[i].apply(context, [data, status, xhr || $form, $form]);
- }
- };
-
- if (options.error) {
- var oldError = options.error;
- options.error = function(xhr, status, error) {
- var context = options.context || this;
- oldError.apply(context, [xhr, status, error, $form]);
- };
- }
-
- if (options.complete) {
- var oldComplete = options.complete;
- options.complete = function(xhr, status) {
- var context = options.context || this;
- oldComplete.apply(context, [xhr, status, $form]);
- };
- }
-
- // are there files to upload?
-
- // [value] (issue #113), also see comment:
- // https://github.com/malsup/form/commit/588306aedba1de01388032d5f42a60159eea9228#commitcomment-2180219
- var fileInputs = $('input[type=file]:enabled[value!=""]', this);
-
- var hasFileInputs = fileInputs.length > 0;
- var mp = 'multipart/form-data';
- var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp);
-
- var fileAPI = feature.fileapi && feature.formdata;
- log("fileAPI :" + fileAPI);
- var shouldUseFrame = (hasFileInputs || multipart) && !fileAPI;
-
- var jqxhr;
-
- // options.iframe allows user to force iframe mode
- // 06-NOV-09: now defaulting to iframe mode if file input is detected
- if (options.iframe !== false && (options.iframe || shouldUseFrame)) {
- // hack to fix Safari hang (thanks to Tim Molendijk for this)
- // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d
- if (options.closeKeepAlive) {
- $.get(options.closeKeepAlive, function() {
- jqxhr = fileUploadIframe(a);
- });
- }
- else {
- jqxhr = fileUploadIframe(a);
- }
- }
- else if ((hasFileInputs || multipart) && fileAPI) {
- jqxhr = fileUploadXhr(a);
- }
- else {
- jqxhr = $.ajax(options);
- }
-
- $form.removeData('jqxhr').data('jqxhr', jqxhr);
-
- // clear element array
- for (var k=0; k < elements.length; k++)
- elements[k] = null;
-
- // fire 'notify' event
- this.trigger('form-submit-notify', [this, options]);
- return this;
-
- // utility fn for deep serialization
- function deepSerialize(extraData){
- var serialized = $.param(extraData, options.traditional).split('&');
- var len = serialized.length;
- var result = [];
- var i, part;
- for (i=0; i < len; i++) {
- // #252; undo param space replacement
- serialized[i] = serialized[i].replace(/\+/g,' ');
- part = serialized[i].split('=');
- // #278; use array instead of object storage, favoring array serializations
- result.push([decodeURIComponent(part[0]), decodeURIComponent(part[1])]);
- }
- return result;
- }
-
- // XMLHttpRequest Level 2 file uploads (big hat tip to francois2metz)
- function fileUploadXhr(a) {
- var formdata = new FormData();
-
- for (var i=0; i < a.length; i++) {
- formdata.append(a[i].name, a[i].value);
- }
-
- if (options.extraData) {
- var serializedData = deepSerialize(options.extraData);
- for (i=0; i < serializedData.length; i++)
- if (serializedData[i])
- formdata.append(serializedData[i][0], serializedData[i][1]);
- }
-
- options.data = null;
-
- var s = $.extend(true, {}, $.ajaxSettings, options, {
- contentType: false,
- processData: false,
- cache: false,
- type: method || 'POST'
- });
-
- if (options.uploadProgress) {
- // workaround because jqXHR does not expose upload property
- s.xhr = function() {
- var xhr = jQuery.ajaxSettings.xhr();
- if (xhr.upload) {
- xhr.upload.addEventListener('progress', function(event) {
- var percent = 0;
- var position = event.loaded || event.position; /*event.position is deprecated*/
- var total = event.total;
- if (event.lengthComputable) {
- percent = Math.ceil(position / total * 100);
- }
- options.uploadProgress(event, position, total, percent);
- }, false);
- }
- return xhr;
- };
- }
-
- s.data = null;
- var beforeSend = s.beforeSend;
- s.beforeSend = function(xhr, o) {
- o.data = formdata;
- if(beforeSend)
- beforeSend.call(this, xhr, o);
- };
- return $.ajax(s);
- }
-
- // private function for handling file uploads (hat tip to YAHOO!)
- function fileUploadIframe(a) {
- var form = $form[0], el, i, s, g, id, $io, io, xhr, sub, n, timedOut, timeoutHandle;
- var deferred = $.Deferred();
-
- if (a) {
- // ensure that every serialized input is still enabled
- for (i=0; i < elements.length; i++) {
- el = $(elements[i]);
- if ( hasProp )
- el.prop('disabled', false);
- else
- el.removeAttr('disabled');
- }
- }
-
- s = $.extend(true, {}, $.ajaxSettings, options);
- s.context = s.context || s;
- id = 'jqFormIO' + (new Date().getTime());
- if (s.iframeTarget) {
- $io = $(s.iframeTarget);
- n = $io.attr2('name');
- if (!n)
- $io.attr2('name', id);
- else
- id = n;
- }
- else {
- $io = $('<iframe name="' + id + '" src="'+ s.iframeSrc +'" />');
- $io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });
- }
- io = $io[0];
-
-
- xhr = { // mock object
- aborted: 0,
- responseText: null,
- responseXML: null,
- status: 0,
- statusText: 'n/a',
- getAllResponseHeaders: function() {},
- getResponseHeader: function() {},
- setRequestHeader: function() {},
- abort: function(status) {
- var e = (status === 'timeout' ? 'timeout' : 'aborted');
- log('aborting upload... ' + e);
- this.aborted = 1;
-
- try { // #214, #257
- if (io.contentWindow.document.execCommand) {
- io.contentWindow.document.execCommand('Stop');
- }
- }
- catch(ignore) {}
-
- $io.attr('src', s.iframeSrc); // abort op in progress
- xhr.error = e;
- if (s.error)
- s.error.call(s.context, xhr, e, status);
- if (g)
- $.event.trigger("ajaxError", [xhr, s, e]);
- if (s.complete)
- s.complete.call(s.context, xhr, e);
- }
- };
-
- g = s.global;
- // trigger ajax global events so that activity/block indicators work like normal
- if (g && 0 === $.active++) {
- $.event.trigger("ajaxStart");
- }
- if (g) {
- $.event.trigger("ajaxSend", [xhr, s]);
- }
-
- if (s.beforeSend && s.beforeSend.call(s.context, xhr, s) === false) {
- if (s.global) {
- $.active--;
- }
- deferred.reject();
- return deferred;
- }
- if (xhr.aborted) {
- deferred.reject();
- return deferred;
- }
-
- // add submitting element to data if we know it
- sub = form.clk;
- if (sub) {
- n = sub.name;
- if (n && !sub.disabled) {
- s.extraData = s.extraData || {};
- s.extraData[n] = sub.value;
- if (sub.type == "image") {
- s.extraData[n+'.x'] = form.clk_x;
- s.extraData[n+'.y'] = form.clk_y;
- }
- }
- }
-
- var CLIENT_TIMEOUT_ABORT = 1;
- var SERVER_ABORT = 2;
-
- function getDoc(frame) {
- /* it looks like contentWindow or contentDocument do not
- * carry the protocol property in ie8, when running under ssl
- * frame.document is the only valid response document, since
- * the protocol is know but not on the other two objects. strange?
- * "Same origin policy" http://en.wikipedia.org/wiki/Same_origin_policy
- */
-
- var doc = null;
-
- // IE8 cascading access check
- try {
- if (frame.contentWindow) {
- doc = frame.contentWindow.document;
- }
- } catch(err) {
- // IE8 access denied under ssl & missing protocol
- log('cannot get iframe.contentWindow document: ' + err);
- }
-
- if (doc) { // successful getting content
- return doc;
- }
-
- try { // simply checking may throw in ie8 under ssl or mismatched protocol
- doc = frame.contentDocument ? frame.contentDocument : frame.document;
- } catch(err) {
- // last attempt
- log('cannot get iframe.contentDocument: ' + err);
- doc = frame.document;
- }
- return doc;
- }
-
- // Rails CSRF hack (thanks to Yvan Barthelemy)
- var csrf_token = $('meta[name=csrf-token]').attr('content');
- var csrf_param = $('meta[name=csrf-param]').attr('content');
- if (csrf_param && csrf_token) {
- s.extraData = s.extraData || {};
- s.extraData[csrf_param] = csrf_token;
- }
-
- // take a breath so that pending repaints get some cpu time before the upload starts
- function doSubmit() {
- // make sure form attrs are set
- var t = $form.attr2('target'), a = $form.attr2('action');
-
- // update form attrs in IE friendly way
- form.setAttribute('target',id);
- if (!method) {
- form.setAttribute('method', 'POST');
- }
- if (a != s.url) {
- form.setAttribute('action', s.url);
- }
-
- // ie borks in some cases when setting encoding
- if (! s.skipEncodingOverride && (!method || /post/i.test(method))) {
- $form.attr({
- encoding: 'multipart/form-data',
- enctype: 'multipart/form-data'
- });
- }
-
- // support timout
- if (s.timeout) {
- timeoutHandle = setTimeout(function() { timedOut = true; cb(CLIENT_TIMEOUT_ABORT); }, s.timeout);
- }
-
- // look for server aborts
- function checkState() {
- try {
- var state = getDoc(io).readyState;
- log('state = ' + state);
- if (state && state.toLowerCase() == 'uninitialized')
- setTimeout(checkState,50);
- }
- catch(e) {
- log('Server abort: ' , e, ' (', e.name, ')');
- cb(SERVER_ABORT);
- if (timeoutHandle)
- clearTimeout(timeoutHandle);
- timeoutHandle = undefined;
- }
- }
-
- // add "extra" data to form if provided in options
- var extraInputs = [];
- try {
- if (s.extraData) {
- for (var n in s.extraData) {
- if (s.extraData.hasOwnProperty(n)) {
- // if using the $.param format that allows for multiple values with the same name
- if($.isPlainObject(s.extraData[n]) && s.extraData[n].hasOwnProperty('name') && s.extraData[n].hasOwnProperty('value')) {
- extraInputs.push(
- $('<input type="hidden" name="'+s.extraData[n].name+'">').val(s.extraData[n].value)
- .appendTo(form)[0]);
- } else {
- extraInputs.push(
- $('<input type="hidden" name="'+n+'">').val(s.extraData[n])
- .appendTo(form)[0]);
- }
- }
- }
- }
-
- if (!s.iframeTarget) {
- // add iframe to doc and submit the form
- $io.appendTo('body');
- if (io.attachEvent)
- io.attachEvent('onload', cb);
- else
- io.addEventListener('load', cb, false);
- }
- setTimeout(checkState,15);
-
- try {
- form.submit();
- } catch(err) {
- // just in case form has element with name/id of 'submit'
- var submitFn = document.createElement('form').submit;
- submitFn.apply(form);
- }
- }
- finally {
- // reset attrs and remove "extra" input elements
- form.setAttribute('action',a);
- if(t) {
- form.setAttribute('target', t);
- } else {
- $form.removeAttr('target');
- }
- $(extraInputs).remove();
- }
- }
-
- if (s.forceSync) {
- doSubmit();
- }
- else {
- setTimeout(doSubmit, 10); // this lets dom updates render
- }
-
- var data, doc, domCheckCount = 50, callbackProcessed;
-
- function cb(e) {
- if (xhr.aborted || callbackProcessed) {
- return;
- }
-
- doc = getDoc(io);
- if(!doc) {
- log('cannot access response document');
- e = SERVER_ABORT;
- }
- if (e === CLIENT_TIMEOUT_ABORT && xhr) {
- xhr.abort('timeout');
- deferred.reject(xhr, 'timeout');
- return;
- }
- else if (e == SERVER_ABORT && xhr) {
- xhr.abort('server abort');
- deferred.reject(xhr, 'error', 'server abort');
- return;
- }
-
- if (!doc || doc.location.href == s.iframeSrc) {
- // response not received yet
- if (!timedOut)
- return;
- }
- if (io.detachEvent)
- io.detachEvent('onload', cb);
- else
- io.removeEventListener('load', cb, false);
-
- var status = 'success', errMsg;
- try {
- if (timedOut) {
- throw 'timeout';
- }
-
- var isXml = s.dataType == 'xml' || doc.XMLDocument || $.isXMLDoc(doc);
- log('isXml='+isXml);
- if (!isXml && window.opera && (doc.body === null || !doc.body.innerHTML)) {
- if (--domCheckCount) {
- // in some browsers (Opera) the iframe DOM is not always traversable when
- // the onload callback fires, so we loop a bit to accommodate
- log('requeing onLoad callback, DOM not available');
- setTimeout(cb, 250);
- return;
- }
- // let this fall through because server response could be an empty document
- //log('Could not access iframe DOM after mutiple tries.');
- //throw 'DOMException: not available';
- }
-
- //log('response detected');
- var docRoot = doc.body ? doc.body : doc.documentElement;
- xhr.responseText = docRoot ? docRoot.innerHTML : null;
- xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
- if (isXml)
- s.dataType = 'xml';
- xhr.getResponseHeader = function(header){
- var headers = {'content-type': s.dataType};
- return headers[header];
- };
- // support for XHR 'status' & 'statusText' emulation :
- if (docRoot) {
- xhr.status = Number( docRoot.getAttribute('status') ) || xhr.status;
- xhr.statusText = docRoot.getAttribute('statusText') || xhr.statusText;
- }
-
- var dt = (s.dataType || '').toLowerCase();
- var scr = /(json|script|text)/.test(dt);
- if (scr || s.textarea) {
- // see if user embedded response in textarea
- var ta = doc.getElementsByTagName('textarea')[0];
- if (ta) {
- xhr.responseText = ta.value;
- // support for XHR 'status' & 'statusText' emulation :
- xhr.status = Number( ta.getAttribute('status') ) || xhr.status;
- xhr.statusText = ta.getAttribute('statusText') || xhr.statusText;
- }
- else if (scr) {
- // account for browsers injecting pre around json response
- var pre = doc.getElementsByTagName('pre')[0];
- var b = doc.getElementsByTagName('body')[0];
- if (pre) {
- xhr.responseText = pre.textContent ? pre.textContent : pre.innerText;
- }
- else if (b) {
- xhr.responseText = b.textContent ? b.textContent : b.innerText;
- }
- }
- }
- else if (dt == 'xml' && !xhr.responseXML && xhr.responseText) {
- xhr.responseXML = toXml(xhr.responseText);
- }
-
- try {
- data = httpData(xhr, dt, s);
- }
- catch (err) {
- status = 'parsererror';
- xhr.error = errMsg = (err || status);
- }
- }
- catch (err) {
- log('error caught: ',err);
- status = 'error';
- xhr.error = errMsg = (err || status);
- }
-
- if (xhr.aborted) {
- log('upload aborted');
- status = null;
- }
-
- if (xhr.status) { // we've set xhr.status
- status = (xhr.status >= 200 && xhr.status < 300 || xhr.status === 304) ? 'success' : 'error';
- }
-
- // ordering of these callbacks/triggers is odd, but that's how $.ajax does it
- if (status === 'success') {
- if (s.success)
- s.success.call(s.context, data, 'success', xhr);
- deferred.resolve(xhr.responseText, 'success', xhr);
- if (g)
- $.event.trigger("ajaxSuccess", [xhr, s]);
- }
- else if (status) {
- if (errMsg === undefined)
- errMsg = xhr.statusText;
- if (s.error)
- s.error.call(s.context, xhr, status, errMsg);
- deferred.reject(xhr, 'error', errMsg);
- if (g)
- $.event.trigger("ajaxError", [xhr, s, errMsg]);
- }
-
- if (g)
- $.event.trigger("ajaxComplete", [xhr, s]);
-
- if (g && ! --$.active) {
- $.event.trigger("ajaxStop");
- }
-
- if (s.complete)
- s.complete.call(s.context, xhr, status);
-
- callbackProcessed = true;
- if (s.timeout)
- clearTimeout(timeoutHandle);
-
- // clean up
- setTimeout(function() {
- if (!s.iframeTarget)
- $io.remove();
- xhr.responseXML = null;
- }, 100);
- }
-
- var toXml = $.parseXML || function(s, doc) { // use parseXML if available (jQuery 1.5+)
- if (window.ActiveXObject) {
- doc = new ActiveXObject('Microsoft.XMLDOM');
- doc.async = 'false';
- doc.loadXML(s);
- }
- else {
- doc = (new DOMParser()).parseFromString(s, 'text/xml');
- }
- return (doc && doc.documentElement && doc.documentElement.nodeName != 'parsererror') ? doc : null;
- };
- var parseJSON = $.parseJSON || function(s) {
- /*jslint evil:true */
- return window['eval']('(' + s + ')');
- };
-
- var httpData = function( xhr, type, s ) { // mostly lifted from jq1.4.4
-
- var ct = xhr.getResponseHeader('content-type') || '',
- xml = type === 'xml' || !type && ct.indexOf('xml') >= 0,
- data = xml ? xhr.responseXML : xhr.responseText;
-
- if (xml && data.documentElement.nodeName === 'parsererror') {
- if ($.error)
- $.error('parsererror');
- }
- if (s && s.dataFilter) {
- data = s.dataFilter(data, type);
- }
- if (typeof data === 'string') {
- if (type === 'json' || !type && ct.indexOf('json') >= 0) {
- data = parseJSON(data);
- } else if (type === "script" || !type && ct.indexOf("javascript") >= 0) {
- $.globalEval(data);
- }
- }
- return data;
- };
-
- return deferred;
- }
-};
-
-/**
- * ajaxForm() provides a mechanism for fully automating form submission.
- *
- * The advantages of using this method instead of ajaxSubmit() are:
- *
- * 1: This method will include coordinates for <input type="image" /> elements (if the element
- * is used to submit the form).
- * 2. This method will include the submit element's name/value data (for the element that was
- * used to submit the form).
- * 3. This method binds the submit() method to the form for you.
- *
- * The options argument for ajaxForm works exactly as it does for ajaxSubmit. ajaxForm merely
- * passes the options argument along after properly binding events for submit elements and
- * the form itself.
- */
-$.fn.ajaxForm = function(options) {
- options = options || {};
- options.delegation = options.delegation && $.isFunction($.fn.on);
-
- // in jQuery 1.3+ we can fix mistakes with the ready state
- if (!options.delegation && this.length === 0) {
- var o = { s: this.selector, c: this.context };
- if (!$.isReady && o.s) {
- log('DOM not ready, queuing ajaxForm');
- $(function() {
- $(o.s,o.c).ajaxForm(options);
- });
- return this;
- }
- // is your DOM ready? http://docs.jquery.com/Tutorials:Introducing_$(document).ready()
- log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)'));
- return this;
- }
-
- if ( options.delegation ) {
- $(document)
- .off('submit.form-plugin', this.selector, doAjaxSubmit)
- .off('click.form-plugin', this.selector, captureSubmittingElement)
- .on('submit.form-plugin', this.selector, options, doAjaxSubmit)
- .on('click.form-plugin', this.selector, options, captureSubmittingElement);
- return this;
- }
-
- return this.ajaxFormUnbind()
- .bind('submit.form-plugin', options, doAjaxSubmit)
- .bind('click.form-plugin', options, captureSubmittingElement);
-};
-
-// private event handlers
-function doAjaxSubmit(e) {
- /*jshint validthis:true */
- var options = e.data;
- if (!e.isDefaultPrevented()) { // if event has been canceled, don't proceed
- e.preventDefault();
- $(this).ajaxSubmit(options);
- }
-}
-
-function captureSubmittingElement(e) {
- /*jshint validthis:true */
- var target = e.target;
- var $el = $(target);
- if (!($el.is("[type=submit],[type=image]"))) {
- // is this a child element of the submit el? (ex: a span within a button)
- var t = $el.closest('[type=submit]');
- if (t.length === 0) {
- return;
- }
- target = t[0];
- }
- var form = this;
- form.clk = target;
- if (target.type == 'image') {
- if (e.offsetX !== undefined) {
- form.clk_x = e.offsetX;
- form.clk_y = e.offsetY;
- } else if (typeof $.fn.offset == 'function') {
- var offset = $el.offset();
- form.clk_x = e.pageX - offset.left;
- form.clk_y = e.pageY - offset.top;
- } else {
- form.clk_x = e.pageX - target.offsetLeft;
- form.clk_y = e.pageY - target.offsetTop;
- }
- }
- // clear form vars
- setTimeout(function() { form.clk = form.clk_x = form.clk_y = null; }, 100);
-}
-
-
-// ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm
-$.fn.ajaxFormUnbind = function() {
- return this.unbind('submit.form-plugin click.form-plugin');
-};
-
-/**
- * formToArray() gathers form element data into an array of objects that can
- * be passed to any of the following ajax functions: $.get, $.post, or load.
- * Each object in the array has both a 'name' and 'value' property. An example of
- * an array for a simple login form might be:
- *
- * [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
- *
- * It is this array that is passed to pre-submit callback functions provided to the
- * ajaxSubmit() and ajaxForm() methods.
- */
-$.fn.formToArray = function(semantic, elements) {
- var a = [];
- if (this.length === 0) {
- return a;
- }
-
- var form = this[0];
- var els = semantic ? form.getElementsByTagName('*') : form.elements;
- if (!els) {
- return a;
- }
-
- var i,j,n,v,el,max,jmax;
- for(i=0, max=els.length; i < max; i++) {
- el = els[i];
- n = el.name;
- if (!n || el.disabled) {
- continue;
- }
-
- if (semantic && form.clk && el.type == "image") {
- // handle image inputs on the fly when semantic == true
- if(form.clk == el) {
- a.push({name: n, value: $(el).val(), type: el.type });
- a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
- }
- continue;
- }
-
- v = $.fieldValue(el, true);
- if (v && v.constructor == Array) {
- if (elements)
- elements.push(el);
- for(j=0, jmax=v.length; j < jmax; j++) {
- a.push({name: n, value: v[j]});
- }
- }
- else if (feature.fileapi && el.type == 'file') {
- if (elements)
- elements.push(el);
- var files = el.files;
- if (files.length) {
- for (j=0; j < files.length; j++) {
- a.push({name: n, value: files[j], type: el.type});
- }
- }
- else {
- // #180
- a.push({ name: n, value: '', type: el.type });
- }
- }
- else if (v !== null && typeof v != 'undefined') {
- if (elements)
- elements.push(el);
- a.push({name: n, value: v, type: el.type, required: el.required});
- }
- }
-
- if (!semantic && form.clk) {
- // input type=='image' are not found in elements array! handle it here
- var $input = $(form.clk), input = $input[0];
- n = input.name;
- if (n && !input.disabled && input.type == 'image') {
- a.push({name: n, value: $input.val()});
- a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
- }
- }
- return a;
-};
-
-/**
- * Serializes form data into a 'submittable' string. This method will return a string
- * in the format: name1=value1&name2=value2
- */
-$.fn.formSerialize = function(semantic) {
- //hand off to jQuery.param for proper encoding
- return $.param(this.formToArray(semantic));
-};
-
-/**
- * Serializes all field elements in the jQuery object into a query string.
- * This method will return a string in the format: name1=value1&name2=value2
- */
-$.fn.fieldSerialize = function(successful) {
- var a = [];
- this.each(function() {
- var n = this.name;
- if (!n) {
- return;
- }
- var v = $.fieldValue(this, successful);
- if (v && v.constructor == Array) {
- for (var i=0,max=v.length; i < max; i++) {
- a.push({name: n, value: v[i]});
- }
- }
- else if (v !== null && typeof v != 'undefined') {
- a.push({name: this.name, value: v});
- }
- });
- //hand off to jQuery.param for proper encoding
- return $.param(a);
-};
-
-/**
- * Returns the value(s) of the element in the matched set. For example, consider the following form:
- *
- * <form><fieldset>
- * <input name="A" type="text" />
- * <input name="A" type="text" />
- * <input name="B" type="checkbox" value="B1" />
- * <input name="B" type="checkbox" value="B2"/>
- * <input name="C" type="radio" value="C1" />
- * <input name="C" type="radio" value="C2" />
- * </fieldset></form>
- *
- * var v = $('input[type=text]').fieldValue();
- * // if no values are entered into the text inputs
- * v == ['','']
- * // if values entered into the text inputs are 'foo' and 'bar'
- * v == ['foo','bar']
- *
- * var v = $('input[type=checkbox]').fieldValue();
- * // if neither checkbox is checked
- * v === undefined
- * // if both checkboxes are checked
- * v == ['B1', 'B2']
- *
- * var v = $('input[type=radio]').fieldValue();
- * // if neither radio is checked
- * v === undefined
- * // if first radio is checked
- * v == ['C1']
- *
- * The successful argument controls whether or not the field element must be 'successful'
- * (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
- * The default value of the successful argument is true. If this value is false the value(s)
- * for each element is returned.
- *
- * Note: This method *always* returns an array. If no valid value can be determined the
- * array will be empty, otherwise it will contain one or more values.
- */
-$.fn.fieldValue = function(successful) {
- for (var val=[], i=0, max=this.length; i < max; i++) {
- var el = this[i];
- var v = $.fieldValue(el, successful);
- if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length)) {
- continue;
- }
- if (v.constructor == Array)
- $.merge(val, v);
- else
- val.push(v);
- }
- return val;
-};
-
-/**
- * Returns the value of the field element.
- */
-$.fieldValue = function(el, successful) {
- var n = el.name, t = el.type, tag = el.tagName.toLowerCase();
- if (successful === undefined) {
- successful = true;
- }
-
- if (successful && (!n || el.disabled || t == 'reset' || t == 'button' ||
- (t == 'checkbox' || t == 'radio') && !el.checked ||
- (t == 'submit' || t == 'image') && el.form && el.form.clk != el ||
- tag == 'select' && el.selectedIndex == -1)) {
- return null;
- }
-
- if (tag == 'select') {
- var index = el.selectedIndex;
- if (index < 0) {
- return null;
- }
- var a = [], ops = el.options;
- var one = (t == 'select-one');
- var max = (one ? index+1 : ops.length);
- for(var i=(one ? index : 0); i < max; i++) {
- var op = ops[i];
- if (op.selected) {
- var v = op.value;
- if (!v) { // extra pain for IE...
- v = (op.attributes && op.attributes['value'] && !(op.attributes['value'].specified)) ? op.text : op.value;
- }
- if (one) {
- return v;
- }
- a.push(v);
- }
- }
- return a;
- }
- return $(el).val();
-};
-
-/**
- * Clears the form data. Takes the following actions on the form's input fields:
- * - input text fields will have their 'value' property set to the empty string
- * - select elements will have their 'selectedIndex' property set to -1
- * - checkbox and radio inputs will have their 'checked' property set to false
- * - inputs of type submit, button, reset, and hidden will *not* be effected
- * - button elements will *not* be effected
- */
-$.fn.clearForm = function(includeHidden) {
- return this.each(function() {
- $('input,select,textarea', this).clearFields(includeHidden);
- });
-};
-
-/**
- * Clears the selected form elements.
- */
-$.fn.clearFields = $.fn.clearInputs = function(includeHidden) {
- var re = /^(?:color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week)$/i; // 'hidden' is not in this list
- return this.each(function() {
- var t = this.type, tag = this.tagName.toLowerCase();
- if (re.test(t) || tag == 'textarea') {
- this.value = '';
- }
- else if (t == 'checkbox' || t == 'radio') {
- this.checked = false;
- }
- else if (tag == 'select') {
- this.selectedIndex = -1;
- }
- else if (t == "file") {
- if (/MSIE/.test(navigator.userAgent)) {
- $(this).replaceWith($(this).clone(true));
- } else {
- $(this).val('');
- }
- }
- else if (includeHidden) {
- // includeHidden can be the value true, or it can be a selector string
- // indicating a special test; for example:
- // $('#myForm').clearForm('.special:hidden')
- // the above would clean hidden inputs that have the class of 'special'
- if ( (includeHidden === true && /hidden/.test(t)) ||
- (typeof includeHidden == 'string' && $(this).is(includeHidden)) )
- this.value = '';
- }
- });
-};
-
-/**
- * Resets the form data. Causes all form elements to be reset to their original value.
- */
-$.fn.resetForm = function() {
- return this.each(function() {
- // guard against an input with the name of 'reset'
- // note that IE reports the reset function as an 'object'
- if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType)) {
- this.reset();
- }
- });
-};
-
-/**
- * Enables or disables any matching elements.
- */
-$.fn.enable = function(b) {
- if (b === undefined) {
- b = true;
- }
- return this.each(function() {
- this.disabled = !b;
- });
-};
-
-/**
- * Checks/unchecks any matching checkboxes or radio buttons and
- * selects/deselects and matching option elements.
- */
-$.fn.selected = function(select) {
- if (select === undefined) {
- select = true;
- }
- return this.each(function() {
- var t = this.type;
- if (t == 'checkbox' || t == 'radio') {
- this.checked = select;
- }
- else if (this.tagName.toLowerCase() == 'option') {
- var $sel = $(this).parent('select');
- if (select && $sel[0] && $sel[0].type == 'select-one') {
- // deselect all other options
- $sel.find('option').selected(false);
- }
- this.selected = select;
- }
- });
-};
-
-// expose debug var
-$.fn.ajaxSubmit.debug = false;
-
-// helper fn for console logging
-function log() {
- if (!$.fn.ajaxSubmit.debug)
- return;
- var msg = '[jquery.form] ' + Array.prototype.join.call(arguments,'');
- if (window.console && window.console.log) {
- window.console.log(msg);
- }
- else if (window.opera && window.opera.postError) {
- window.opera.postError(msg);
- }
-}
-
-})(jQuery);
[13/26] Remove fauxton from 1.4.x branch.
Posted by dj...@apache.org.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a2b7d6a1/src/fauxton/assets/js/libs/require.js
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/js/libs/require.js b/src/fauxton/assets/js/libs/require.js
deleted file mode 100644
index 2109a25..0000000
--- a/src/fauxton/assets/js/libs/require.js
+++ /dev/null
@@ -1,2045 +0,0 @@
-/** vim: et:ts=4:sw=4:sts=4
- * @license RequireJS 2.1.6 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
- * Available via the MIT or new BSD license.
- * see: http://github.com/jrburke/requirejs for details
- */
-//Not using strict: uneven strict support in browsers, #392, and causes
-//problems with requirejs.exec()/transpiler plugins that may not be strict.
-/*jslint regexp: true, nomen: true, sloppy: true */
-/*global window, navigator, document, importScripts, setTimeout, opera */
-
-var requirejs, require, define;
-(function (global) {
- var req, s, head, baseElement, dataMain, src,
- interactiveScript, currentlyAddingScript, mainScript, subPath,
- version = '2.1.6',
- commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
- cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
- jsSuffixRegExp = /\.js$/,
- currDirRegExp = /^\.\//,
- op = Object.prototype,
- ostring = op.toString,
- hasOwn = op.hasOwnProperty,
- ap = Array.prototype,
- apsp = ap.splice,
- isBrowser = !!(typeof window !== 'undefined' && navigator && window.document),
- isWebWorker = !isBrowser && typeof importScripts !== 'undefined',
- //PS3 indicates loaded and complete, but need to wait for complete
- //specifically. Sequence is 'loading', 'loaded', execution,
- // then 'complete'. The UA check is unfortunate, but not sure how
- //to feature test w/o causing perf issues.
- readyRegExp = isBrowser && navigator.platform === 'PLAYSTATION 3' ?
- /^complete$/ : /^(complete|loaded)$/,
- defContextName = '_',
- //Oh the tragedy, detecting opera. See the usage of isOpera for reason.
- isOpera = typeof opera !== 'undefined' && opera.toString() === '[object Opera]',
- contexts = {},
- cfg = {},
- globalDefQueue = [],
- useInteractive = false;
-
- function isFunction(it) {
- return ostring.call(it) === '[object Function]';
- }
-
- function isArray(it) {
- return ostring.call(it) === '[object Array]';
- }
-
- /**
- * Helper function for iterating over an array. If the func returns
- * a true value, it will break out of the loop.
- */
- function each(ary, func) {
- if (ary) {
- var i;
- for (i = 0; i < ary.length; i += 1) {
- if (ary[i] && func(ary[i], i, ary)) {
- break;
- }
- }
- }
- }
-
- /**
- * Helper function for iterating over an array backwards. If the func
- * returns a true value, it will break out of the loop.
- */
- function eachReverse(ary, func) {
- if (ary) {
- var i;
- for (i = ary.length - 1; i > -1; i -= 1) {
- if (ary[i] && func(ary[i], i, ary)) {
- break;
- }
- }
- }
- }
-
- function hasProp(obj, prop) {
- return hasOwn.call(obj, prop);
- }
-
- function getOwn(obj, prop) {
- return hasProp(obj, prop) && obj[prop];
- }
-
- /**
- * Cycles over properties in an object and calls a function for each
- * property value. If the function returns a truthy value, then the
- * iteration is stopped.
- */
- function eachProp(obj, func) {
- var prop;
- for (prop in obj) {
- if (hasProp(obj, prop)) {
- if (func(obj[prop], prop)) {
- break;
- }
- }
- }
- }
-
- /**
- * Simple function to mix in properties from source into target,
- * but only if target does not already have a property of the same name.
- */
- function mixin(target, source, force, deepStringMixin) {
- if (source) {
- eachProp(source, function (value, prop) {
- if (force || !hasProp(target, prop)) {
- if (deepStringMixin && typeof value !== 'string') {
- if (!target[prop]) {
- target[prop] = {};
- }
- mixin(target[prop], value, force, deepStringMixin);
- } else {
- target[prop] = value;
- }
- }
- });
- }
- return target;
- }
-
- //Similar to Function.prototype.bind, but the 'this' object is specified
- //first, since it is easier to read/figure out what 'this' will be.
- function bind(obj, fn) {
- return function () {
- return fn.apply(obj, arguments);
- };
- }
-
- function scripts() {
- return document.getElementsByTagName('script');
- }
-
- function defaultOnError(err) {
- throw err;
- }
-
- //Allow getting a global that expressed in
- //dot notation, like 'a.b.c'.
- function getGlobal(value) {
- if (!value) {
- return value;
- }
- var g = global;
- each(value.split('.'), function (part) {
- g = g[part];
- });
- return g;
- }
-
- /**
- * Constructs an error with a pointer to an URL with more information.
- * @param {String} id the error ID that maps to an ID on a web page.
- * @param {String} message human readable error.
- * @param {Error} [err] the original error, if there is one.
- *
- * @returns {Error}
- */
- function makeError(id, msg, err, requireModules) {
- var e = new Error(msg + '\nhttp://requirejs.org/docs/errors.html#' + id);
- e.requireType = id;
- e.requireModules = requireModules;
- if (err) {
- e.originalError = err;
- }
- return e;
- }
-
- if (typeof define !== 'undefined') {
- //If a define is already in play via another AMD loader,
- //do not overwrite.
- return;
- }
-
- if (typeof requirejs !== 'undefined') {
- if (isFunction(requirejs)) {
- //Do not overwrite and existing requirejs instance.
- return;
- }
- cfg = requirejs;
- requirejs = undefined;
- }
-
- //Allow for a require config object
- if (typeof require !== 'undefined' && !isFunction(require)) {
- //assume it is a config object.
- cfg = require;
- require = undefined;
- }
-
- function newContext(contextName) {
- var inCheckLoaded, Module, context, handlers,
- checkLoadedTimeoutId,
- config = {
- //Defaults. Do not set a default for map
- //config to speed up normalize(), which
- //will run faster if there is no default.
- waitSeconds: 7,
- baseUrl: './',
- paths: {},
- pkgs: {},
- shim: {},
- config: {}
- },
- registry = {},
- //registry of just enabled modules, to speed
- //cycle breaking code when lots of modules
- //are registered, but not activated.
- enabledRegistry = {},
- undefEvents = {},
- defQueue = [],
- defined = {},
- urlFetched = {},
- requireCounter = 1,
- unnormalizedCounter = 1;
-
- /**
- * Trims the . and .. from an array of path segments.
- * It will keep a leading path segment if a .. will become
- * the first path segment, to help with module name lookups,
- * which act like paths, but can be remapped. But the end result,
- * all paths that use this function should look normalized.
- * NOTE: this method MODIFIES the input array.
- * @param {Array} ary the array of path segments.
- */
- function trimDots(ary) {
- var i, part;
- for (i = 0; ary[i]; i += 1) {
- part = ary[i];
- if (part === '.') {
- ary.splice(i, 1);
- i -= 1;
- } else if (part === '..') {
- if (i === 1 && (ary[2] === '..' || ary[0] === '..')) {
- //End of the line. Keep at least one non-dot
- //path segment at the front so it can be mapped
- //correctly to disk. Otherwise, there is likely
- //no path mapping for a path starting with '..'.
- //This can still fail, but catches the most reasonable
- //uses of ..
- break;
- } else if (i > 0) {
- ary.splice(i - 1, 2);
- i -= 2;
- }
- }
- }
- }
-
- /**
- * Given a relative module name, like ./something, normalize it to
- * a real name that can be mapped to a path.
- * @param {String} name the relative name
- * @param {String} baseName a real name that the name arg is relative
- * to.
- * @param {Boolean} applyMap apply the map config to the value. Should
- * only be done if this normalization is for a dependency ID.
- * @returns {String} normalized name
- */
- function normalize(name, baseName, applyMap) {
- var pkgName, pkgConfig, mapValue, nameParts, i, j, nameSegment,
- foundMap, foundI, foundStarMap, starI,
- baseParts = baseName && baseName.split('/'),
- normalizedBaseParts = baseParts,
- map = config.map,
- starMap = map && map['*'];
-
- //Adjust any relative paths.
- if (name && name.charAt(0) === '.') {
- //If have a base name, try to normalize against it,
- //otherwise, assume it is a top-level require that will
- //be relative to baseUrl in the end.
- if (baseName) {
- if (getOwn(config.pkgs, baseName)) {
- //If the baseName is a package name, then just treat it as one
- //name to concat the name with.
- normalizedBaseParts = baseParts = [baseName];
- } else {
- //Convert baseName to array, and lop off the last part,
- //so that . matches that 'directory' and not name of the baseName's
- //module. For instance, baseName of 'one/two/three', maps to
- //'one/two/three.js', but we want the directory, 'one/two' for
- //this normalization.
- normalizedBaseParts = baseParts.slice(0, baseParts.length - 1);
- }
-
- name = normalizedBaseParts.concat(name.split('/'));
- trimDots(name);
-
- //Some use of packages may use a . path to reference the
- //'main' module name, so normalize for that.
- pkgConfig = getOwn(config.pkgs, (pkgName = name[0]));
- name = name.join('/');
- if (pkgConfig && name === pkgName + '/' + pkgConfig.main) {
- name = pkgName;
- }
- } else if (name.indexOf('./') === 0) {
- // No baseName, so this is ID is resolved relative
- // to baseUrl, pull off the leading dot.
- name = name.substring(2);
- }
- }
-
- //Apply map config if available.
- if (applyMap && map && (baseParts || starMap)) {
- nameParts = name.split('/');
-
- for (i = nameParts.length; i > 0; i -= 1) {
- nameSegment = nameParts.slice(0, i).join('/');
-
- if (baseParts) {
- //Find the longest baseName segment match in the config.
- //So, do joins on the biggest to smallest lengths of baseParts.
- for (j = baseParts.length; j > 0; j -= 1) {
- mapValue = getOwn(map, baseParts.slice(0, j).join('/'));
-
- //baseName segment has config, find if it has one for
- //this name.
- if (mapValue) {
- mapValue = getOwn(mapValue, nameSegment);
- if (mapValue) {
- //Match, update name to the new value.
- foundMap = mapValue;
- foundI = i;
- break;
- }
- }
- }
- }
-
- if (foundMap) {
- break;
- }
-
- //Check for a star map match, but just hold on to it,
- //if there is a shorter segment match later in a matching
- //config, then favor over this star map.
- if (!foundStarMap && starMap && getOwn(starMap, nameSegment)) {
- foundStarMap = getOwn(starMap, nameSegment);
- starI = i;
- }
- }
-
- if (!foundMap && foundStarMap) {
- foundMap = foundStarMap;
- foundI = starI;
- }
-
- if (foundMap) {
- nameParts.splice(0, foundI, foundMap);
- name = nameParts.join('/');
- }
- }
-
- return name;
- }
-
- function removeScript(name) {
- if (isBrowser) {
- each(scripts(), function (scriptNode) {
- if (scriptNode.getAttribute('data-requiremodule') === name &&
- scriptNode.getAttribute('data-requirecontext') === context.contextName) {
- scriptNode.parentNode.removeChild(scriptNode);
- return true;
- }
- });
- }
- }
-
- function hasPathFallback(id) {
- var pathConfig = getOwn(config.paths, id);
- if (pathConfig && isArray(pathConfig) && pathConfig.length > 1) {
- removeScript(id);
- //Pop off the first array value, since it failed, and
- //retry
- pathConfig.shift();
- context.require.undef(id);
- context.require([id]);
- return true;
- }
- }
-
- //Turns a plugin!resource to [plugin, resource]
- //with the plugin being undefined if the name
- //did not have a plugin prefix.
- function splitPrefix(name) {
- var prefix,
- index = name ? name.indexOf('!') : -1;
- if (index > -1) {
- prefix = name.substring(0, index);
- name = name.substring(index + 1, name.length);
- }
- return [prefix, name];
- }
-
- /**
- * Creates a module mapping that includes plugin prefix, module
- * name, and path. If parentModuleMap is provided it will
- * also normalize the name via require.normalize()
- *
- * @param {String} name the module name
- * @param {String} [parentModuleMap] parent module map
- * for the module name, used to resolve relative names.
- * @param {Boolean} isNormalized: is the ID already normalized.
- * This is true if this call is done for a define() module ID.
- * @param {Boolean} applyMap: apply the map config to the ID.
- * Should only be true if this map is for a dependency.
- *
- * @returns {Object}
- */
- function makeModuleMap(name, parentModuleMap, isNormalized, applyMap) {
- var url, pluginModule, suffix, nameParts,
- prefix = null,
- parentName = parentModuleMap ? parentModuleMap.name : null,
- originalName = name,
- isDefine = true,
- normalizedName = '';
-
- //If no name, then it means it is a require call, generate an
- //internal name.
- if (!name) {
- isDefine = false;
- name = '_@r' + (requireCounter += 1);
- }
-
- nameParts = splitPrefix(name);
- prefix = nameParts[0];
- name = nameParts[1];
-
- if (prefix) {
- prefix = normalize(prefix, parentName, applyMap);
- pluginModule = getOwn(defined, prefix);
- }
-
- //Account for relative paths if there is a base name.
- if (name) {
- if (prefix) {
- if (pluginModule && pluginModule.normalize) {
- //Plugin is loaded, use its normalize method.
- normalizedName = pluginModule.normalize(name, function (name) {
- return normalize(name, parentName, applyMap);
- });
- } else {
- normalizedName = normalize(name, parentName, applyMap);
- }
- } else {
- //A regular module.
- normalizedName = normalize(name, parentName, applyMap);
-
- //Normalized name may be a plugin ID due to map config
- //application in normalize. The map config values must
- //already be normalized, so do not need to redo that part.
- nameParts = splitPrefix(normalizedName);
- prefix = nameParts[0];
- normalizedName = nameParts[1];
- isNormalized = true;
-
- url = context.nameToUrl(normalizedName);
- }
- }
-
- //If the id is a plugin id that cannot be determined if it needs
- //normalization, stamp it with a unique ID so two matching relative
- //ids that may conflict can be separate.
- suffix = prefix && !pluginModule && !isNormalized ?
- '_unnormalized' + (unnormalizedCounter += 1) :
- '';
-
- return {
- prefix: prefix,
- name: normalizedName,
- parentMap: parentModuleMap,
- unnormalized: !!suffix,
- url: url,
- originalName: originalName,
- isDefine: isDefine,
- id: (prefix ?
- prefix + '!' + normalizedName :
- normalizedName) + suffix
- };
- }
-
- function getModule(depMap) {
- var id = depMap.id,
- mod = getOwn(registry, id);
-
- if (!mod) {
- mod = registry[id] = new context.Module(depMap);
- }
-
- return mod;
- }
-
- function on(depMap, name, fn) {
- var id = depMap.id,
- mod = getOwn(registry, id);
-
- if (hasProp(defined, id) &&
- (!mod || mod.defineEmitComplete)) {
- if (name === 'defined') {
- fn(defined[id]);
- }
- } else {
- mod = getModule(depMap);
- if (mod.error && name === 'error') {
- fn(mod.error);
- } else {
- mod.on(name, fn);
- }
- }
- }
-
- function onError(err, errback) {
- var ids = err.requireModules,
- notified = false;
-
- if (errback) {
- errback(err);
- } else {
- each(ids, function (id) {
- var mod = getOwn(registry, id);
- if (mod) {
- //Set error on module, so it skips timeout checks.
- mod.error = err;
- if (mod.events.error) {
- notified = true;
- mod.emit('error', err);
- }
- }
- });
-
- if (!notified) {
- req.onError(err);
- }
- }
- }
-
- /**
- * Internal method to transfer globalQueue items to this context's
- * defQueue.
- */
- function takeGlobalQueue() {
- //Push all the globalDefQueue items into the context's defQueue
- if (globalDefQueue.length) {
- //Array splice in the values since the context code has a
- //local var ref to defQueue, so cannot just reassign the one
- //on context.
- apsp.apply(defQueue,
- [defQueue.length - 1, 0].concat(globalDefQueue));
- globalDefQueue = [];
- }
- }
-
- handlers = {
- 'require': function (mod) {
- if (mod.require) {
- return mod.require;
- } else {
- return (mod.require = context.makeRequire(mod.map));
- }
- },
- 'exports': function (mod) {
- mod.usingExports = true;
- if (mod.map.isDefine) {
- if (mod.exports) {
- return mod.exports;
- } else {
- return (mod.exports = defined[mod.map.id] = {});
- }
- }
- },
- 'module': function (mod) {
- if (mod.module) {
- return mod.module;
- } else {
- return (mod.module = {
- id: mod.map.id,
- uri: mod.map.url,
- config: function () {
- var c,
- pkg = getOwn(config.pkgs, mod.map.id);
- // For packages, only support config targeted
- // at the main module.
- c = pkg ? getOwn(config.config, mod.map.id + '/' + pkg.main) :
- getOwn(config.config, mod.map.id);
- return c || {};
- },
- exports: defined[mod.map.id]
- });
- }
- }
- };
-
- function cleanRegistry(id) {
- //Clean up machinery used for waiting modules.
- delete registry[id];
- delete enabledRegistry[id];
- }
-
- function breakCycle(mod, traced, processed) {
- var id = mod.map.id;
-
- if (mod.error) {
- mod.emit('error', mod.error);
- } else {
- traced[id] = true;
- each(mod.depMaps, function (depMap, i) {
- var depId = depMap.id,
- dep = getOwn(registry, depId);
-
- //Only force things that have not completed
- //being defined, so still in the registry,
- //and only if it has not been matched up
- //in the module already.
- if (dep && !mod.depMatched[i] && !processed[depId]) {
- if (getOwn(traced, depId)) {
- mod.defineDep(i, defined[depId]);
- mod.check(); //pass false?
- } else {
- breakCycle(dep, traced, processed);
- }
- }
- });
- processed[id] = true;
- }
- }
-
- function checkLoaded() {
- var map, modId, err, usingPathFallback,
- waitInterval = config.waitSeconds * 1000,
- //It is possible to disable the wait interval by using waitSeconds of 0.
- expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(),
- noLoads = [],
- reqCalls = [],
- stillLoading = false,
- needCycleCheck = true;
-
- //Do not bother if this call was a result of a cycle break.
- if (inCheckLoaded) {
- return;
- }
-
- inCheckLoaded = true;
-
- //Figure out the state of all the modules.
- eachProp(enabledRegistry, function (mod) {
- map = mod.map;
- modId = map.id;
-
- //Skip things that are not enabled or in error state.
- if (!mod.enabled) {
- return;
- }
-
- if (!map.isDefine) {
- reqCalls.push(mod);
- }
-
- if (!mod.error) {
- //If the module should be executed, and it has not
- //been inited and time is up, remember it.
- if (!mod.inited && expired) {
- if (hasPathFallback(modId)) {
- usingPathFallback = true;
- stillLoading = true;
- } else {
- noLoads.push(modId);
- removeScript(modId);
- }
- } else if (!mod.inited && mod.fetched && map.isDefine) {
- stillLoading = true;
- if (!map.prefix) {
- //No reason to keep looking for unfinished
- //loading. If the only stillLoading is a
- //plugin resource though, keep going,
- //because it may be that a plugin resource
- //is waiting on a non-plugin cycle.
- return (needCycleCheck = false);
- }
- }
- }
- });
-
- if (expired && noLoads.length) {
- //If wait time expired, throw error of unloaded modules.
- err = makeError('timeout', 'Load timeout for modules: ' + noLoads, null, noLoads);
- err.contextName = context.contextName;
- return onError(err);
- }
-
- //Not expired, check for a cycle.
- if (needCycleCheck) {
- each(reqCalls, function (mod) {
- breakCycle(mod, {}, {});
- });
- }
-
- //If still waiting on loads, and the waiting load is something
- //other than a plugin resource, or there are still outstanding
- //scripts, then just try back later.
- if ((!expired || usingPathFallback) && stillLoading) {
- //Something is still waiting to load. Wait for it, but only
- //if a timeout is not already in effect.
- if ((isBrowser || isWebWorker) && !checkLoadedTimeoutId) {
- checkLoadedTimeoutId = setTimeout(function () {
- checkLoadedTimeoutId = 0;
- checkLoaded();
- }, 50);
- }
- }
-
- inCheckLoaded = false;
- }
-
- Module = function (map) {
- this.events = getOwn(undefEvents, map.id) || {};
- this.map = map;
- this.shim = getOwn(config.shim, map.id);
- this.depExports = [];
- this.depMaps = [];
- this.depMatched = [];
- this.pluginMaps = {};
- this.depCount = 0;
-
- /* this.exports this.factory
- this.depMaps = [],
- this.enabled, this.fetched
- */
- };
-
- Module.prototype = {
- init: function (depMaps, factory, errback, options) {
- options = options || {};
-
- //Do not do more inits if already done. Can happen if there
- //are multiple define calls for the same module. That is not
- //a normal, common case, but it is also not unexpected.
- if (this.inited) {
- return;
- }
-
- this.factory = factory;
-
- if (errback) {
- //Register for errors on this module.
- this.on('error', errback);
- } else if (this.events.error) {
- //If no errback already, but there are error listeners
- //on this module, set up an errback to pass to the deps.
- errback = bind(this, function (err) {
- this.emit('error', err);
- });
- }
-
- //Do a copy of the dependency array, so that
- //source inputs are not modified. For example
- //"shim" deps are passed in here directly, and
- //doing a direct modification of the depMaps array
- //would affect that config.
- this.depMaps = depMaps && depMaps.slice(0);
-
- this.errback = errback;
-
- //Indicate this module has be initialized
- this.inited = true;
-
- this.ignore = options.ignore;
-
- //Could have option to init this module in enabled mode,
- //or could have been previously marked as enabled. However,
- //the dependencies are not known until init is called. So
- //if enabled previously, now trigger dependencies as enabled.
- if (options.enabled || this.enabled) {
- //Enable this module and dependencies.
- //Will call this.check()
- this.enable();
- } else {
- this.check();
- }
- },
-
- defineDep: function (i, depExports) {
- //Because of cycles, defined callback for a given
- //export can be called more than once.
- if (!this.depMatched[i]) {
- this.depMatched[i] = true;
- this.depCount -= 1;
- this.depExports[i] = depExports;
- }
- },
-
- fetch: function () {
- if (this.fetched) {
- return;
- }
- this.fetched = true;
-
- context.startTime = (new Date()).getTime();
-
- var map = this.map;
-
- //If the manager is for a plugin managed resource,
- //ask the plugin to load it now.
- if (this.shim) {
- context.makeRequire(this.map, {
- enableBuildCallback: true
- })(this.shim.deps || [], bind(this, function () {
- return map.prefix ? this.callPlugin() : this.load();
- }));
- } else {
- //Regular dependency.
- return map.prefix ? this.callPlugin() : this.load();
- }
- },
-
- load: function () {
- var url = this.map.url;
-
- //Regular dependency.
- if (!urlFetched[url]) {
- urlFetched[url] = true;
- context.load(this.map.id, url);
- }
- },
-
- /**
- * Checks if the module is ready to define itself, and if so,
- * define it.
- */
- check: function () {
- if (!this.enabled || this.enabling) {
- return;
- }
-
- var err, cjsModule,
- id = this.map.id,
- depExports = this.depExports,
- exports = this.exports,
- factory = this.factory;
-
- if (!this.inited) {
- this.fetch();
- } else if (this.error) {
- this.emit('error', this.error);
- } else if (!this.defining) {
- //The factory could trigger another require call
- //that would result in checking this module to
- //define itself again. If already in the process
- //of doing that, skip this work.
- this.defining = true;
-
- if (this.depCount < 1 && !this.defined) {
- if (isFunction(factory)) {
- //If there is an error listener, favor passing
- //to that instead of throwing an error. However,
- //only do it for define()'d modules. require
- //errbacks should not be called for failures in
- //their callbacks (#699). However if a global
- //onError is set, use that.
- if ((this.events.error && this.map.isDefine) ||
- req.onError !== defaultOnError) {
- try {
- exports = context.execCb(id, factory, depExports, exports);
- } catch (e) {
- err = e;
- }
- } else {
- exports = context.execCb(id, factory, depExports, exports);
- }
-
- if (this.map.isDefine) {
- //If setting exports via 'module' is in play,
- //favor that over return value and exports. After that,
- //favor a non-undefined return value over exports use.
- cjsModule = this.module;
- if (cjsModule &&
- cjsModule.exports !== undefined &&
- //Make sure it is not already the exports value
- cjsModule.exports !== this.exports) {
- exports = cjsModule.exports;
- } else if (exports === undefined && this.usingExports) {
- //exports already set the defined value.
- exports = this.exports;
- }
- }
-
- if (err) {
- err.requireMap = this.map;
- err.requireModules = this.map.isDefine ? [this.map.id] : null;
- err.requireType = this.map.isDefine ? 'define' : 'require';
- return onError((this.error = err));
- }
-
- } else {
- //Just a literal value
- exports = factory;
- }
-
- this.exports = exports;
-
- if (this.map.isDefine && !this.ignore) {
- defined[id] = exports;
-
- if (req.onResourceLoad) {
- req.onResourceLoad(context, this.map, this.depMaps);
- }
- }
-
- //Clean up
- cleanRegistry(id);
-
- this.defined = true;
- }
-
- //Finished the define stage. Allow calling check again
- //to allow define notifications below in the case of a
- //cycle.
- this.defining = false;
-
- if (this.defined && !this.defineEmitted) {
- this.defineEmitted = true;
- this.emit('defined', this.exports);
- this.defineEmitComplete = true;
- }
-
- }
- },
-
- callPlugin: function () {
- var map = this.map,
- id = map.id,
- //Map already normalized the prefix.
- pluginMap = makeModuleMap(map.prefix);
-
- //Mark this as a dependency for this plugin, so it
- //can be traced for cycles.
- this.depMaps.push(pluginMap);
-
- on(pluginMap, 'defined', bind(this, function (plugin) {
- var load, normalizedMap, normalizedMod,
- name = this.map.name,
- parentName = this.map.parentMap ? this.map.parentMap.name : null,
- localRequire = context.makeRequire(map.parentMap, {
- enableBuildCallback: true
- });
-
- //If current map is not normalized, wait for that
- //normalized name to load instead of continuing.
- if (this.map.unnormalized) {
- //Normalize the ID if the plugin allows it.
- if (plugin.normalize) {
- name = plugin.normalize(name, function (name) {
- return normalize(name, parentName, true);
- }) || '';
- }
-
- //prefix and name should already be normalized, no need
- //for applying map config again either.
- normalizedMap = makeModuleMap(map.prefix + '!' + name,
- this.map.parentMap);
- on(normalizedMap,
- 'defined', bind(this, function (value) {
- this.init([], function () { return value; }, null, {
- enabled: true,
- ignore: true
- });
- }));
-
- normalizedMod = getOwn(registry, normalizedMap.id);
- if (normalizedMod) {
- //Mark this as a dependency for this plugin, so it
- //can be traced for cycles.
- this.depMaps.push(normalizedMap);
-
- if (this.events.error) {
- normalizedMod.on('error', bind(this, function (err) {
- this.emit('error', err);
- }));
- }
- normalizedMod.enable();
- }
-
- return;
- }
-
- load = bind(this, function (value) {
- this.init([], function () { return value; }, null, {
- enabled: true
- });
- });
-
- load.error = bind(this, function (err) {
- this.inited = true;
- this.error = err;
- err.requireModules = [id];
-
- //Remove temp unnormalized modules for this module,
- //since they will never be resolved otherwise now.
- eachProp(registry, function (mod) {
- if (mod.map.id.indexOf(id + '_unnormalized') === 0) {
- cleanRegistry(mod.map.id);
- }
- });
-
- onError(err);
- });
-
- //Allow plugins to load other code without having to know the
- //context or how to 'complete' the load.
- load.fromText = bind(this, function (text, textAlt) {
- /*jslint evil: true */
- var moduleName = map.name,
- moduleMap = makeModuleMap(moduleName),
- hasInteractive = useInteractive;
-
- //As of 2.1.0, support just passing the text, to reinforce
- //fromText only being called once per resource. Still
- //support old style of passing moduleName but discard
- //that moduleName in favor of the internal ref.
- if (textAlt) {
- text = textAlt;
- }
-
- //Turn off interactive script matching for IE for any define
- //calls in the text, then turn it back on at the end.
- if (hasInteractive) {
- useInteractive = false;
- }
-
- //Prime the system by creating a module instance for
- //it.
- getModule(moduleMap);
-
- //Transfer any config to this other module.
- if (hasProp(config.config, id)) {
- config.config[moduleName] = config.config[id];
- }
-
- try {
- req.exec(text);
- } catch (e) {
- return onError(makeError('fromtexteval',
- 'fromText eval for ' + id +
- ' failed: ' + e,
- e,
- [id]));
- }
-
- if (hasInteractive) {
- useInteractive = true;
- }
-
- //Mark this as a dependency for the plugin
- //resource
- this.depMaps.push(moduleMap);
-
- //Support anonymous modules.
- context.completeLoad(moduleName);
-
- //Bind the value of that module to the value for this
- //resource ID.
- localRequire([moduleName], load);
- });
-
- //Use parentName here since the plugin's name is not reliable,
- //could be some weird string with no path that actually wants to
- //reference the parentName's path.
- plugin.load(map.name, localRequire, load, config);
- }));
-
- context.enable(pluginMap, this);
- this.pluginMaps[pluginMap.id] = pluginMap;
- },
-
- enable: function () {
- enabledRegistry[this.map.id] = this;
- this.enabled = true;
-
- //Set flag mentioning that the module is enabling,
- //so that immediate calls to the defined callbacks
- //for dependencies do not trigger inadvertent load
- //with the depCount still being zero.
- this.enabling = true;
-
- //Enable each dependency
- each(this.depMaps, bind(this, function (depMap, i) {
- var id, mod, handler;
-
- if (typeof depMap === 'string') {
- //Dependency needs to be converted to a depMap
- //and wired up to this module.
- depMap = makeModuleMap(depMap,
- (this.map.isDefine ? this.map : this.map.parentMap),
- false,
- !this.skipMap);
- this.depMaps[i] = depMap;
-
- handler = getOwn(handlers, depMap.id);
-
- if (handler) {
- this.depExports[i] = handler(this);
- return;
- }
-
- this.depCount += 1;
-
- on(depMap, 'defined', bind(this, function (depExports) {
- this.defineDep(i, depExports);
- this.check();
- }));
-
- if (this.errback) {
- on(depMap, 'error', bind(this, this.errback));
- }
- }
-
- id = depMap.id;
- mod = registry[id];
-
- //Skip special modules like 'require', 'exports', 'module'
- //Also, don't call enable if it is already enabled,
- //important in circular dependency cases.
- if (!hasProp(handlers, id) && mod && !mod.enabled) {
- context.enable(depMap, this);
- }
- }));
-
- //Enable each plugin that is used in
- //a dependency
- eachProp(this.pluginMaps, bind(this, function (pluginMap) {
- var mod = getOwn(registry, pluginMap.id);
- if (mod && !mod.enabled) {
- context.enable(pluginMap, this);
- }
- }));
-
- this.enabling = false;
-
- this.check();
- },
-
- on: function (name, cb) {
- var cbs = this.events[name];
- if (!cbs) {
- cbs = this.events[name] = [];
- }
- cbs.push(cb);
- },
-
- emit: function (name, evt) {
- each(this.events[name], function (cb) {
- cb(evt);
- });
- if (name === 'error') {
- //Now that the error handler was triggered, remove
- //the listeners, since this broken Module instance
- //can stay around for a while in the registry.
- delete this.events[name];
- }
- }
- };
-
- function callGetModule(args) {
- //Skip modules already defined.
- if (!hasProp(defined, args[0])) {
- getModule(makeModuleMap(args[0], null, true)).init(args[1], args[2]);
- }
- }
-
- function removeListener(node, func, name, ieName) {
- //Favor detachEvent because of IE9
- //issue, see attachEvent/addEventListener comment elsewhere
- //in this file.
- if (node.detachEvent && !isOpera) {
- //Probably IE. If not it will throw an error, which will be
- //useful to know.
- if (ieName) {
- node.detachEvent(ieName, func);
- }
- } else {
- node.removeEventListener(name, func, false);
- }
- }
-
- /**
- * Given an event from a script node, get the requirejs info from it,
- * and then removes the event listeners on the node.
- * @param {Event} evt
- * @returns {Object}
- */
- function getScriptData(evt) {
- //Using currentTarget instead of target for Firefox 2.0's sake. Not
- //all old browsers will be supported, but this one was easy enough
- //to support and still makes sense.
- var node = evt.currentTarget || evt.srcElement;
-
- //Remove the listeners once here.
- removeListener(node, context.onScriptLoad, 'load', 'onreadystatechange');
- removeListener(node, context.onScriptError, 'error');
-
- return {
- node: node,
- id: node && node.getAttribute('data-requiremodule')
- };
- }
-
- function intakeDefines() {
- var args;
-
- //Any defined modules in the global queue, intake them now.
- takeGlobalQueue();
-
- //Make sure any remaining defQueue items get properly processed.
- while (defQueue.length) {
- args = defQueue.shift();
- if (args[0] === null) {
- return onError(makeError('mismatch', 'Mismatched anonymous define() module: ' + args[args.length - 1]));
- } else {
- //args are id, deps, factory. Should be normalized by the
- //define() function.
- callGetModule(args);
- }
- }
- }
-
- context = {
- config: config,
- contextName: contextName,
- registry: registry,
- defined: defined,
- urlFetched: urlFetched,
- defQueue: defQueue,
- Module: Module,
- makeModuleMap: makeModuleMap,
- nextTick: req.nextTick,
- onError: onError,
-
- /**
- * Set a configuration for the context.
- * @param {Object} cfg config object to integrate.
- */
- configure: function (cfg) {
- //Make sure the baseUrl ends in a slash.
- if (cfg.baseUrl) {
- if (cfg.baseUrl.charAt(cfg.baseUrl.length - 1) !== '/') {
- cfg.baseUrl += '/';
- }
- }
-
- //Save off the paths and packages since they require special processing,
- //they are additive.
- var pkgs = config.pkgs,
- shim = config.shim,
- objs = {
- paths: true,
- config: true,
- map: true
- };
-
- eachProp(cfg, function (value, prop) {
- if (objs[prop]) {
- if (prop === 'map') {
- if (!config.map) {
- config.map = {};
- }
- mixin(config[prop], value, true, true);
- } else {
- mixin(config[prop], value, true);
- }
- } else {
- config[prop] = value;
- }
- });
-
- //Merge shim
- if (cfg.shim) {
- eachProp(cfg.shim, function (value, id) {
- //Normalize the structure
- if (isArray(value)) {
- value = {
- deps: value
- };
- }
- if ((value.exports || value.init) && !value.exportsFn) {
- value.exportsFn = context.makeShimExports(value);
- }
- shim[id] = value;
- });
- config.shim = shim;
- }
-
- //Adjust packages if necessary.
- if (cfg.packages) {
- each(cfg.packages, function (pkgObj) {
- var location;
-
- pkgObj = typeof pkgObj === 'string' ? { name: pkgObj } : pkgObj;
- location = pkgObj.location;
-
- //Create a brand new object on pkgs, since currentPackages can
- //be passed in again, and config.pkgs is the internal transformed
- //state for all package configs.
- pkgs[pkgObj.name] = {
- name: pkgObj.name,
- location: location || pkgObj.name,
- //Remove leading dot in main, so main paths are normalized,
- //and remove any trailing .js, since different package
- //envs have different conventions: some use a module name,
- //some use a file name.
- main: (pkgObj.main || 'main')
- .replace(currDirRegExp, '')
- .replace(jsSuffixRegExp, '')
- };
- });
-
- //Done with modifications, assing packages back to context config
- config.pkgs = pkgs;
- }
-
- //If there are any "waiting to execute" modules in the registry,
- //update the maps for them, since their info, like URLs to load,
- //may have changed.
- eachProp(registry, function (mod, id) {
- //If module already has init called, since it is too
- //late to modify them, and ignore unnormalized ones
- //since they are transient.
- if (!mod.inited && !mod.map.unnormalized) {
- mod.map = makeModuleMap(id);
- }
- });
-
- //If a deps array or a config callback is specified, then call
- //require with those args. This is useful when require is defined as a
- //config object before require.js is loaded.
- if (cfg.deps || cfg.callback) {
- context.require(cfg.deps || [], cfg.callback);
- }
- },
-
- makeShimExports: function (value) {
- function fn() {
- var ret;
- if (value.init) {
- ret = value.init.apply(global, arguments);
- }
- return ret || (value.exports && getGlobal(value.exports));
- }
- return fn;
- },
-
- makeRequire: function (relMap, options) {
- options = options || {};
-
- function localRequire(deps, callback, errback) {
- var id, map, requireMod;
-
- if (options.enableBuildCallback && callback && isFunction(callback)) {
- callback.__requireJsBuild = true;
- }
-
- if (typeof deps === 'string') {
- if (isFunction(callback)) {
- //Invalid call
- return onError(makeError('requireargs', 'Invalid require call'), errback);
- }
-
- //If require|exports|module are requested, get the
- //value for them from the special handlers. Caveat:
- //this only works while module is being defined.
- if (relMap && hasProp(handlers, deps)) {
- return handlers[deps](registry[relMap.id]);
- }
-
- //Synchronous access to one module. If require.get is
- //available (as in the Node adapter), prefer that.
- if (req.get) {
- return req.get(context, deps, relMap, localRequire);
- }
-
- //Normalize module name, if it contains . or ..
- map = makeModuleMap(deps, relMap, false, true);
- id = map.id;
-
- if (!hasProp(defined, id)) {
- return onError(makeError('notloaded', 'Module name "' +
- id +
- '" has not been loaded yet for context: ' +
- contextName +
- (relMap ? '' : '. Use require([])')));
- }
- return defined[id];
- }
-
- //Grab defines waiting in the global queue.
- intakeDefines();
-
- //Mark all the dependencies as needing to be loaded.
- context.nextTick(function () {
- //Some defines could have been added since the
- //require call, collect them.
- intakeDefines();
-
- requireMod = getModule(makeModuleMap(null, relMap));
-
- //Store if map config should be applied to this require
- //call for dependencies.
- requireMod.skipMap = options.skipMap;
-
- requireMod.init(deps, callback, errback, {
- enabled: true
- });
-
- checkLoaded();
- });
-
- return localRequire;
- }
-
- mixin(localRequire, {
- isBrowser: isBrowser,
-
- /**
- * Converts a module name + .extension into an URL path.
- * *Requires* the use of a module name. It does not support using
- * plain URLs like nameToUrl.
- */
- toUrl: function (moduleNamePlusExt) {
- var ext,
- index = moduleNamePlusExt.lastIndexOf('.'),
- segment = moduleNamePlusExt.split('/')[0],
- isRelative = segment === '.' || segment === '..';
-
- //Have a file extension alias, and it is not the
- //dots from a relative path.
- if (index !== -1 && (!isRelative || index > 1)) {
- ext = moduleNamePlusExt.substring(index, moduleNamePlusExt.length);
- moduleNamePlusExt = moduleNamePlusExt.substring(0, index);
- }
-
- return context.nameToUrl(normalize(moduleNamePlusExt,
- relMap && relMap.id, true), ext, true);
- },
-
- defined: function (id) {
- return hasProp(defined, makeModuleMap(id, relMap, false, true).id);
- },
-
- specified: function (id) {
- id = makeModuleMap(id, relMap, false, true).id;
- return hasProp(defined, id) || hasProp(registry, id);
- }
- });
-
- //Only allow undef on top level require calls
- if (!relMap) {
- localRequire.undef = function (id) {
- //Bind any waiting define() calls to this context,
- //fix for #408
- takeGlobalQueue();
-
- var map = makeModuleMap(id, relMap, true),
- mod = getOwn(registry, id);
-
- delete defined[id];
- delete urlFetched[map.url];
- delete undefEvents[id];
-
- if (mod) {
- //Hold on to listeners in case the
- //module will be attempted to be reloaded
- //using a different config.
- if (mod.events.defined) {
- undefEvents[id] = mod.events;
- }
-
- cleanRegistry(id);
- }
- };
- }
-
- return localRequire;
- },
-
- /**
- * Called to enable a module if it is still in the registry
- * awaiting enablement. A second arg, parent, the parent module,
- * is passed in for context, when this method is overriden by
- * the optimizer. Not shown here to keep code compact.
- */
- enable: function (depMap) {
- var mod = getOwn(registry, depMap.id);
- if (mod) {
- getModule(depMap).enable();
- }
- },
-
- /**
- * Internal method used by environment adapters to complete a load event.
- * A load event could be a script load or just a load pass from a synchronous
- * load call.
- * @param {String} moduleName the name of the module to potentially complete.
- */
- completeLoad: function (moduleName) {
- var found, args, mod,
- shim = getOwn(config.shim, moduleName) || {},
- shExports = shim.exports;
-
- takeGlobalQueue();
-
- while (defQueue.length) {
- args = defQueue.shift();
- if (args[0] === null) {
- args[0] = moduleName;
- //If already found an anonymous module and bound it
- //to this name, then this is some other anon module
- //waiting for its completeLoad to fire.
- if (found) {
- break;
- }
- found = true;
- } else if (args[0] === moduleName) {
- //Found matching define call for this script!
- found = true;
- }
-
- callGetModule(args);
- }
-
- //Do this after the cycle of callGetModule in case the result
- //of those calls/init calls changes the registry.
- mod = getOwn(registry, moduleName);
-
- if (!found && !hasProp(defined, moduleName) && mod && !mod.inited) {
- if (config.enforceDefine && (!shExports || !getGlobal(shExports))) {
- if (hasPathFallback(moduleName)) {
- return;
- } else {
- return onError(makeError('nodefine',
- 'No define call for ' + moduleName,
- null,
- [moduleName]));
- }
- } else {
- //A script that does not call define(), so just simulate
- //the call for it.
- callGetModule([moduleName, (shim.deps || []), shim.exportsFn]);
- }
- }
-
- checkLoaded();
- },
-
- /**
- * Converts a module name to a file path. Supports cases where
- * moduleName may actually be just an URL.
- * Note that it **does not** call normalize on the moduleName,
- * it is assumed to have already been normalized. This is an
- * internal API, not a public one. Use toUrl for the public API.
- */
- nameToUrl: function (moduleName, ext, skipExt) {
- var paths, pkgs, pkg, pkgPath, syms, i, parentModule, url,
- parentPath;
-
- //If a colon is in the URL, it indicates a protocol is used and it is just
- //an URL to a file, or if it starts with a slash, contains a query arg (i.e. ?)
- //or ends with .js, then assume the user meant to use an url and not a module id.
- //The slash is important for protocol-less URLs as well as full paths.
- if (req.jsExtRegExp.test(moduleName)) {
- //Just a plain path, not module name lookup, so just return it.
- //Add extension if it is included. This is a bit wonky, only non-.js things pass
- //an extension, this method probably needs to be reworked.
- url = moduleName + (ext || '');
- } else {
- //A module that needs to be converted to a path.
- paths = config.paths;
- pkgs = config.pkgs;
-
- syms = moduleName.split('/');
- //For each module name segment, see if there is a path
- //registered for it. Start with most specific name
- //and work up from it.
- for (i = syms.length; i > 0; i -= 1) {
- parentModule = syms.slice(0, i).join('/');
- pkg = getOwn(pkgs, parentModule);
- parentPath = getOwn(paths, parentModule);
- if (parentPath) {
- //If an array, it means there are a few choices,
- //Choose the one that is desired
- if (isArray(parentPath)) {
- parentPath = parentPath[0];
- }
- syms.splice(0, i, parentPath);
- break;
- } else if (pkg) {
- //If module name is just the package name, then looking
- //for the main module.
- if (moduleName === pkg.name) {
- pkgPath = pkg.location + '/' + pkg.main;
- } else {
- pkgPath = pkg.location;
- }
- syms.splice(0, i, pkgPath);
- break;
- }
- }
-
- //Join the path parts together, then figure out if baseUrl is needed.
- url = syms.join('/');
- url += (ext || (/\?/.test(url) || skipExt ? '' : '.js'));
- url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url;
- }
-
- return config.urlArgs ? url +
- ((url.indexOf('?') === -1 ? '?' : '&') +
- config.urlArgs) : url;
- },
-
- //Delegates to req.load. Broken out as a separate function to
- //allow overriding in the optimizer.
- load: function (id, url) {
- req.load(context, id, url);
- },
-
- /**
- * Executes a module callback function. Broken out as a separate function
- * solely to allow the build system to sequence the files in the built
- * layer in the right sequence.
- *
- * @private
- */
- execCb: function (name, callback, args, exports) {
- return callback.apply(exports, args);
- },
-
- /**
- * callback for script loads, used to check status of loading.
- *
- * @param {Event} evt the event from the browser for the script
- * that was loaded.
- */
- onScriptLoad: function (evt) {
- //Using currentTarget instead of target for Firefox 2.0's sake. Not
- //all old browsers will be supported, but this one was easy enough
- //to support and still makes sense.
- if (evt.type === 'load' ||
- (readyRegExp.test((evt.currentTarget || evt.srcElement).readyState))) {
- //Reset interactive script so a script node is not held onto for
- //to long.
- interactiveScript = null;
-
- //Pull out the name of the module and the context.
- var data = getScriptData(evt);
- context.completeLoad(data.id);
- }
- },
-
- /**
- * Callback for script errors.
- */
- onScriptError: function (evt) {
- var data = getScriptData(evt);
- if (!hasPathFallback(data.id)) {
- return onError(makeError('scripterror', 'Script error for: ' + data.id, evt, [data.id]));
- }
- }
- };
-
- context.require = context.makeRequire();
- return context;
- }
-
- /**
- * Main entry point.
- *
- * If the only argument to require is a string, then the module that
- * is represented by that string is fetched for the appropriate context.
- *
- * If the first argument is an array, then it will be treated as an array
- * of dependency string names to fetch. An optional function callback can
- * be specified to execute when all of those dependencies are available.
- *
- * Make a local req variable to help Caja compliance (it assumes things
- * on a require that are not standardized), and to give a short
- * name for minification/local scope use.
- */
- req = requirejs = function (deps, callback, errback, optional) {
-
- //Find the right context, use default
- var context, config,
- contextName = defContextName;
-
- // Determine if have config object in the call.
- if (!isArray(deps) && typeof deps !== 'string') {
- // deps is a config object
- config = deps;
- if (isArray(callback)) {
- // Adjust args if there are dependencies
- deps = callback;
- callback = errback;
- errback = optional;
- } else {
- deps = [];
- }
- }
-
- if (config && config.context) {
- contextName = config.context;
- }
-
- context = getOwn(contexts, contextName);
- if (!context) {
- context = contexts[contextName] = req.s.newContext(contextName);
- }
-
- if (config) {
- context.configure(config);
- }
-
- return context.require(deps, callback, errback);
- };
-
- /**
- * Support require.config() to make it easier to cooperate with other
- * AMD loaders on globally agreed names.
- */
- req.config = function (config) {
- return req(config);
- };
-
- /**
- * Execute something after the current tick
- * of the event loop. Override for other envs
- * that have a better solution than setTimeout.
- * @param {Function} fn function to execute later.
- */
- req.nextTick = typeof setTimeout !== 'undefined' ? function (fn) {
- setTimeout(fn, 4);
- } : function (fn) { fn(); };
-
- /**
- * Export require as a global, but only if it does not already exist.
- */
- if (!require) {
- require = req;
- }
-
- req.version = version;
-
- //Used to filter out dependencies that are already paths.
- req.jsExtRegExp = /^\/|:|\?|\.js$/;
- req.isBrowser = isBrowser;
- s = req.s = {
- contexts: contexts,
- newContext: newContext
- };
-
- //Create default context.
- req({});
-
- //Exports some context-sensitive methods on global require.
- each([
- 'toUrl',
- 'undef',
- 'defined',
- 'specified'
- ], function (prop) {
- //Reference from contexts instead of early binding to default context,
- //so that during builds, the latest instance of the default context
- //with its config gets used.
- req[prop] = function () {
- var ctx = contexts[defContextName];
- return ctx.require[prop].apply(ctx, arguments);
- };
- });
-
- if (isBrowser) {
- head = s.head = document.getElementsByTagName('head')[0];
- //If BASE tag is in play, using appendChild is a problem for IE6.
- //When that browser dies, this can be removed. Details in this jQuery bug:
- //http://dev.jquery.com/ticket/2709
- baseElement = document.getElementsByTagName('base')[0];
- if (baseElement) {
- head = s.head = baseElement.parentNode;
- }
- }
-
- /**
- * Any errors that require explicitly generates will be passed to this
- * function. Intercept/override it if you want custom error handling.
- * @param {Error} err the error object.
- */
- req.onError = defaultOnError;
-
- /**
- * Does the request to load a module for the browser case.
- * Make this a separate function to allow other environments
- * to override it.
- *
- * @param {Object} context the require context to find state.
- * @param {String} moduleName the name of the module.
- * @param {Object} url the URL to the module.
- */
- req.load = function (context, moduleName, url) {
- var config = (context && context.config) || {},
- node;
- if (isBrowser) {
- //In the browser so use a script tag
- node = config.xhtml ?
- document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') :
- document.createElement('script');
- node.type = config.scriptType || 'text/javascript';
- node.charset = 'utf-8';
- node.async = true;
-
- node.setAttribute('data-requirecontext', context.contextName);
- node.setAttribute('data-requiremodule', moduleName);
-
- //Set up load listener. Test attachEvent first because IE9 has
- //a subtle issue in its addEventListener and script onload firings
- //that do not match the behavior of all other browsers with
- //addEventListener support, which fire the onload event for a
- //script right after the script execution. See:
- //https://connect.microsoft.com/IE/feedback/details/648057/script-onload-event-is-not-fired-immediately-after-script-execution
- //UNFORTUNATELY Opera implements attachEvent but does not follow the script
- //script execution mode.
- if (node.attachEvent &&
- //Check if node.attachEvent is artificially added by custom script or
- //natively supported by browser
- //read https://github.com/jrburke/requirejs/issues/187
- //if we can NOT find [native code] then it must NOT natively supported.
- //in IE8, node.attachEvent does not have toString()
- //Note the test for "[native code" with no closing brace, see:
- //https://github.com/jrburke/requirejs/issues/273
- !(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) &&
- !isOpera) {
- //Probably IE. IE (at least 6-8) do not fire
- //script onload right after executing the script, so
- //we cannot tie the anonymous define call to a name.
- //However, IE reports the script as being in 'interactive'
- //readyState at the time of the define call.
- useInteractive = true;
-
- node.attachEvent('onreadystatechange', context.onScriptLoad);
- //It would be great to add an error handler here to catch
- //404s in IE9+. However, onreadystatechange will fire before
- //the error handler, so that does not help. If addEventListener
- //is used, then IE will fire error before load, but we cannot
- //use that pathway given the connect.microsoft.com issue
- //mentioned above about not doing the 'script execute,
- //then fire the script load event listener before execute
- //next script' that other browsers do.
- //Best hope: IE10 fixes the issues,
- //and then destroys all installs of IE 6-9.
- //node.attachEvent('onerror', context.onScriptError);
- } else {
- node.addEventListener('load', context.onScriptLoad, false);
- node.addEventListener('error', context.onScriptError, false);
- }
- node.src = url;
-
- //For some cache cases in IE 6-8, the script executes before the end
- //of the appendChild execution, so to tie an anonymous define
- //call to the module name (which is stored on the node), hold on
- //to a reference to this node, but clear after the DOM insertion.
- currentlyAddingScript = node;
- if (baseElement) {
- head.insertBefore(node, baseElement);
- } else {
- head.appendChild(node);
- }
- currentlyAddingScript = null;
-
- return node;
- } else if (isWebWorker) {
- try {
- //In a web worker, use importScripts. This is not a very
- //efficient use of importScripts, importScripts will block until
- //its script is downloaded and evaluated. However, if web workers
- //are in play, the expectation that a build has been done so that
- //only one script needs to be loaded anyway. This may need to be
- //reevaluated if other use cases become common.
- importScripts(url);
-
- //Account for anonymous modules
- context.completeLoad(moduleName);
- } catch (e) {
- context.onError(makeError('importscripts',
- 'importScripts failed for ' +
- moduleName + ' at ' + url,
- e,
- [moduleName]));
- }
- }
- };
-
- function getInteractiveScript() {
- if (interactiveScript && interactiveScript.readyState === 'interactive') {
- return interactiveScript;
- }
-
- eachReverse(scripts(), function (script) {
- if (script.readyState === 'interactive') {
- return (interactiveScript = script);
- }
- });
- return interactiveScript;
- }
-
- //Look for a data-main script attribute, which could also adjust the baseUrl.
- if (isBrowser) {
- //Figure out baseUrl. Get it from the script tag with require.js in it.
- eachReverse(scripts(), function (script) {
- //Set the 'head' where we can append children by
- //using the script's parent.
- if (!head) {
- head = script.parentNode;
- }
-
- //Look for a data-main attribute to set main script for the page
- //to load. If it is there, the path to data main becomes the
- //baseUrl, if it is not already set.
- dataMain = script.getAttribute('data-main');
- if (dataMain) {
- //Preserve dataMain in case it is a path (i.e. contains '?')
- mainScript = dataMain;
-
- //Set final baseUrl if there is not already an explicit one.
- if (!cfg.baseUrl) {
- //Pull off the directory of data-main for use as the
- //baseUrl.
- src = mainScript.split('/');
- mainScript = src.pop();
- subPath = src.length ? src.join('/') + '/' : './';
-
- cfg.baseUrl = subPath;
- }
-
- //Strip off any trailing .js since mainScript is now
- //like a module name.
- mainScript = mainScript.replace(jsSuffixRegExp, '');
-
- //If mainScript is still a path, fall back to dataMain
- if (req.jsExtRegExp.test(mainScript)) {
- mainScript = dataMain;
- }
-
- //Put the data-main script in the files to load.
- cfg.deps = cfg.deps ? cfg.deps.concat(mainScript) : [mainScript];
-
- return true;
- }
- });
- }
-
- /**
- * The function that handles definitions of modules. Differs from
- * require() in that a string for the module should be the first argument,
- * and the function to execute after dependencies are loaded should
- * return a value to define the module corresponding to the first argument's
- * name.
- */
- define = function (name, deps, callback) {
- var node, context;
-
- //Allow for anonymous modules
- if (typeof name !== 'string') {
- //Adjust args appropriately
- callback = deps;
- deps = name;
- name = null;
- }
-
- //This module may not have dependencies
- if (!isArray(deps)) {
- callback = deps;
- deps = null;
- }
-
- //If no name, and callback is a function, then figure out if it a
- //CommonJS thing with dependencies.
- if (!deps && isFunction(callback)) {
- deps = [];
- //Remove comments from the callback string,
- //look for require calls, and pull them into the dependencies,
- //but only if there are function args.
- if (callback.length) {
- callback
- .toString()
- .replace(commentRegExp, '')
- .replace(cjsRequireRegExp, function (match, dep) {
- deps.push(dep);
- });
-
- //May be a CommonJS thing even without require calls, but still
- //could use exports, and module. Avoid doing exports and module
- //work though if it just needs require.
- //REQUIRES the function to expect the CommonJS variables in the
- //order listed below.
- deps = (callback.length === 1 ? ['require'] : ['require', 'exports', 'module']).concat(deps);
- }
- }
-
- //If in IE 6-8 and hit an anonymous define() call, do the interactive
- //work.
- if (useInteractive) {
- node = currentlyAddingScript || getInteractiveScript();
- if (node) {
- if (!name) {
- name = node.getAttribute('data-requiremodule');
- }
- context = contexts[node.getAttribute('data-requirecontext')];
- }
- }
-
- //Always save off evaluating the def call until the script onload handler.
- //This allows multiple modules to be in a file without prematurely
- //tracing dependencies, and allows for anonymous module support,
- //where the module name is not known until the script onload event
- //occurs. If no context, use the global queue, and get it processed
- //in the onscript load callback.
- (context ? context.defQueue : globalDefQueue).push([name, deps, callback]);
- };
-
- define.amd = {
- jQuery: true
- };
-
-
- /**
- * Executes the text. Normally just uses eval, but can be modified
- * to use a better, environment-specific call. Only used for transpiling
- * loader plugins, not for plain JS modules.
- * @param {String} text the text to execute/evaluate.
- */
- req.exec = function (text) {
- /*jslint evil: true */
- return eval(text);
- };
-
- //Set up with config info.
- req(cfg);
-}(this));