Grunt with Bower package manager

Change-Id: I4ee64dcf625e20bca1f8dd51ba542d93f3cbd85c
This commit is contained in:
astepanchuk 2013-11-28 11:58:00 +02:00 committed by Vitaly Kramskikh
parent 4b59d64e15
commit 5a4078eb5b
23 changed files with 143 additions and 20294 deletions

1
.gitignore vendored
View File

@ -22,6 +22,7 @@ nailgun.log
lock
node_modules
nailgun/static/js/libs/bower
.idea
.DS_Store

View File

@ -100,9 +100,14 @@ Setup for Web UI Tests
Running Nailgun in Fake Mode
----------------------------
#. Populate the database from fixtures::
#. Fetch JS dependencies::
cd nailgun
npm install
grunt bower
#. Populate the database from fixtures::
./manage.py syncdb
./manage.py loaddefault # It loads all basic fixtures listed in settings.yaml
./manage.py loaddata nailgun/fixtures/sample_environment.json # Loads fake nodes

3
nailgun/.bowerrc Normal file
View File

@ -0,0 +1,3 @@
{
"directory": "bower"
}

View File

@ -12,45 +12,64 @@
* 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) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
requirejs: {
compile: {
options: {
baseUrl: '.',
appDir: 'static',
dir: grunt.option('static-dir') || '/tmp/static_compressed',
mainConfigFile: 'static/js/main.js',
modules: [{name: 'js/main'}],
waitSeconds: 60,
optimize: 'uglify2',
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
requirejs: {
compile: {
options: {
baseUrl: ".",
appDir: "static",
dir: grunt.option('static-dir') || "/tmp/static_compressed",
mainConfigFile: "static/js/main.js",
modules: [{name: "js/main"}],
waitSeconds: 60,
optimize: "uglify2",
}
}
},
jslint: {
client: {
src: [
'static/js/*.js',
'static/js/views/*.js',
],
directives: {
predef: ['requirejs', 'require', 'define', 'app', 'Backbone', '$', '_'],
ass: true,
browser: true,
unparam: true,
nomen: true,
eqeq: true,
vars: true,
white: true,
es5: false
}
}
},
bower: {
install: {
options: {
//set install to true to load Bower packages from inet
install: true,
targetDir: 'static/js/libs/bower',
verbose: true,
cleanTargetDir: false,
cleanBowerDir: true,
layout: "byComponent",
bowerOptions: {
production: true,
install: '--offline'
}
}
}
}
}
},
jslint: {
client: {
src: [
'static/js/*.js',
'static/js/views/*.js',
],
directives: {
predef: ['requirejs', 'require', 'define', 'app', 'Backbone', '$', '_'],
ass: true,
browser: true,
unparam: true,
nomen: true,
eqeq: true,
vars: true,
white: true,
es5: false
}
}
}
});
});
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-jslint');
grunt.registerTask('build', ['requirejs']);
};
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-jslint');
grunt.loadNpmTasks('grunt-bower-task');
grunt.registerTask('build', ['bower', 'requirejs']);
grunt.registerTask('default', ['build']);
};

54
nailgun/bower.json Normal file
View File

@ -0,0 +1,54 @@
{
"name": "fuel-web",
"dependencies": {
"jquery": "1.9.1",
"requirejs": "2.1.4",
"requirejs-text": "2.0.5",
"lodash": "1.1.1",
"retina.js": "1.1.0",
"autoNumeric": "http://github.com/BobKnothe/autoNumeric/zipball/1.9.12",
"jquery.timeout": "http://jquery-timeout.googlecode.com/files/jquery.timeout-1.1.0.js",
"backbone.stickit": "https://raw.github.com/NYTimes/backbone.stickit/b450a07b2cecb3ad0343096f29e0332d5f9508b0/backbone.stickit.js",
"i18next": "1.7.1",
"backbone-deep-model": "0.10.4"
},
"exportsOverride": {
"jquery": {
"js": "jquery.js"
},
"requirejs": {
"js": "require.js"
},
"requirejs-text": {
"js": "text.js"
},
"lodash": {
"js": "lodash.js"
},
"retina.js": {
"js": "src/retina.js"
},
"autoNumeric": {
"js": "autoNumeric.js"
},
"jquery.timeout": {
"js": "index.js"
},
"backbone.stickit": {
"js": "index.js"
},
"i18next": {
"js": "release/i18next-1.7.1.js"
},
"backbone-deep-model": {
"js": "distribution/deep-model.js"
}
},
"ignore": [
"**/.*",
"node_modules",
"test",
"tests"
],
"private": true
}

View File

@ -13,6 +13,8 @@
"less": "~1.5.1",
"grunt-jslint": "~1.1.1",
"grunt-contrib-requirejs": "~0.4.1",
"grunt-contrib-less": "~0.8.2"
"grunt-contrib-less": "~0.8.2",
"grunt-bower": "~0.7.0",
"grunt-bower-task": "~0.3.4"
}
}
}

View File

@ -13,7 +13,7 @@
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script data-main="/static/js/main" src="/static/js/libs/require.js"></script>
<script data-main="/static/js/main" src="/static/js/libs/bower/requirejs/js/require.js"></script>
</head>
<body>

File diff suppressed because it is too large Load Diff

View File

@ -1,500 +0,0 @@
(function(Backbone) {
var $ = Backbone.$ || window.jQuery || window.Zepto;
// Backbone.Stickit Namespace
// --------------------------
Backbone.Stickit = {
_handlers: [],
addHandler: function(handlers) {
// Fill-in default values.
handlers = _.map(_.flatten([handlers]), function(handler) {
return _.extend({
updateModel: true,
updateView: true,
updateMethod: 'text'
}, handler);
});
this._handlers = this._handlers.concat(handlers);
}
};
// Backbone.View Mixins
// --------------------
_.extend(Backbone.View.prototype, {
// Collection of model event bindings.
// [{model,event,fn}, ...]
_modelBindings: null,
// Unbind the model and event bindings from `this._modelBindings` and
// `this.$el`. If the optional `model` parameter is defined, then only
// delete bindings for the given `model` and its corresponding view events.
unstickit: function(model) {
var models = [];
_.each(this._modelBindings, function(binding, i) {
if (model && binding.model !== model) return false;
binding.model.off(binding.event, binding.fn);
models.push(binding.model);
delete this._modelBindings[i];
}, this);
// Trigger an event for each model that was unbound.
_.invoke(_.uniq(models), 'trigger', 'stickit:unstuck', this.cid);
// Cleanup the null values.
this._modelBindings = _.compact(this._modelBindings);
this.$el.off('.stickit' + (model ? '.' + model.cid : ''));
},
// Using `this.bindings` configuration or the `optionalBindingsConfig`, binds `this.model`
// or the `optionalModel` to elements in the view.
stickit: function(optionalModel, optionalBindingsConfig) {
var model = optionalModel || this.model,
namespace = '.stickit.' + model.cid,
bindings = optionalBindingsConfig || this.bindings || {};
this._modelBindings || (this._modelBindings = []);
this.unstickit(model);
// Iterate through the selectors in the bindings configuration and configure
// the various options for each field.
_.each(bindings, function(v, selector) {
var $el, options, modelAttr, config,
binding = bindings[selector] || {},
bindId = _.uniqueId();
// Support ':el' selector - special case selector for the view managed delegate.
$el = selector === ':el' ? this.$el : this.$(selector);
// Fail fast if the selector didn't match an element.
if (!$el.length) return;
// Allow shorthand setting of model attributes - `'selector':'observe'`.
if (_.isString(binding)) binding = {observe:binding};
// Handle case where `observe` is in the form of a function.
if (_.isFunction(binding.observe)) binding.observe = binding.observe.call(this);
config = getConfiguration($el, binding);
modelAttr = config.observe;
// Create the model set options with a unique `bindId` so that we
// can avoid double-binding in the `change:attribute` event handler.
config.bindId = bindId;
// Add a reference to the view for handlers of stickitChange events
config.view = this;
options = _.extend({stickitChange:config}, config.setOptions);
initializeAttributes(this, $el, config, model, modelAttr);
initializeVisible(this, $el, config, model, modelAttr);
if (modelAttr) {
// Setup one-way, form element to model, bindings.
_.each(config.events, function(type) {
var event = type + namespace;
var method = function(event) {
var val = config.getVal.call(this, $el, event, config, _.rest(arguments));
// Don't update the model if false is returned from the `updateModel` configuration.
if (evaluateBoolean(this, config.updateModel, val, config))
setAttr(model, modelAttr, val, options, this, config);
};
if (selector === ':el') this.$el.on(event, method);
else this.$el.on(event, selector, method);
}, this);
// Setup a `change:modelAttr` observer to keep the view element in sync.
// `modelAttr` may be an array of attributes or a single string value.
_.each(_.flatten([modelAttr]), function(attr) {
observeModelEvent(model, this, 'change:'+attr, function(model, val, options) {
var changeId = options && options.stickitChange && options.stickitChange.bindId || null;
if (changeId !== bindId)
updateViewBindEl(this, $el, config, getAttr(model, modelAttr, config, this), model);
});
}, this);
updateViewBindEl(this, $el, config, getAttr(model, modelAttr, config, this), model, true);
}
model.once('stickit:unstuck', function(cid) {
if (cid === this.cid) applyViewFn(this, config.destroy, $el, model, config);
}, this);
// After each binding is setup, call the `initialize` callback.
applyViewFn(this, config.initialize, $el, model, config);
}, this);
// Wrap `view.remove` to unbind stickit model and dom events.
var remove = this.remove;
this.remove = function() {
var ret = this;
this.unstickit();
if (remove) ret = remove.apply(this, _.rest(arguments));
return ret;
};
}
});
// Helpers
// -------
// Evaluates the given `path` (in object/dot-notation) relative to the given
// `obj`. If the path is null/undefined, then the given `obj` is returned.
var evaluatePath = function(obj, path) {
var parts = (path || '').split('.');
var result = _.reduce(parts, function(memo, i) { return memo[i]; }, obj);
return result == null ? obj : result;
};
// If the given `fn` is a string, then view[fn] is called, otherwise it is
// a function that should be executed.
var applyViewFn = function(view, fn) {
if (fn) return (_.isString(fn) ? view[fn] : fn).apply(view, _.rest(arguments, 2));
};
var getSelectedOption = function($select) { return $select.find('option').not(function(){ return !this.selected; }); };
// Given a function, string (view function reference), or a boolean
// value, returns the truthy result. Any other types evaluate as false.
var evaluateBoolean = function(view, reference) {
if (_.isBoolean(reference)) return reference;
else if (_.isFunction(reference) || _.isString(reference))
return applyViewFn.apply(this, arguments);
return false;
};
// Setup a model event binding with the given function, and track the event
// in the view's _modelBindings.
var observeModelEvent = function(model, view, event, fn) {
model.on(event, fn, view);
view._modelBindings.push({model:model, event:event, fn:fn});
};
// Prepares the given `val`ue and sets it into the `model`.
var setAttr = function(model, attr, val, options, context, config) {
if (config.onSet) val = applyViewFn(context, config.onSet, val, config);
model.set(attr, val, options);
};
// Returns the given `attr`'s value from the `model`, escaping and
// formatting if necessary. If `attr` is an array, then an array of
// respective values will be returned.
var getAttr = function(model, attr, config, context) {
var val,
retrieveVal = function(field) {
return model[config.escape ? 'escape' : 'get'](field);
},
sanitizeVal = function(val) {
return val == null ? '' : val;
};
val = _.isArray(attr) ? _.map(attr, retrieveVal) : retrieveVal(attr);
if (config.onGet) val = applyViewFn(context, config.onGet, val, config);
return _.isArray(val) ? _.map(val, sanitizeVal) : sanitizeVal(val);
};
// Find handlers in `Backbone.Stickit._handlers` with selectors that match
// `$el` and generate a configuration by mixing them in the order that they
// were found with the given `binding`.
var getConfiguration = Backbone.Stickit.getConfiguration = function($el, binding) {
var handlers = [{
updateModel: false,
updateMethod: 'text',
update: function($el, val, m, opts) { if ($el[opts.updateMethod]) $el[opts.updateMethod](val); },
getVal: function($el, e, opts) { return $el[opts.updateMethod](); }
}];
handlers = handlers.concat(_.filter(Backbone.Stickit._handlers, function(handler) {
return $el.is(handler.selector);
}));
handlers.push(binding);
var config = _.extend.apply(_, handlers);
// `updateView` is defaulted to false for configutrations with
// `visible`; otherwise, `updateView` is defaulted to true.
if (config.visible && !_.has(config, 'updateView')) config.updateView = false;
else if (!_.has(config, 'updateView')) config.updateView = true;
delete config.selector;
return config;
};
// Setup the attributes configuration - a list that maps an attribute or
// property `name`, to an `observe`d model attribute, using an optional
// `onGet` formatter.
//
// attributes: [{
// name: 'attributeOrPropertyName',
// observe: 'modelAttrName'
// onGet: function(modelAttrVal, modelAttrName) { ... }
// }, ...]
//
var initializeAttributes = function(view, $el, config, model, modelAttr) {
var props = ['autofocus', 'autoplay', 'async', 'checked', 'controls', 'defer', 'disabled', 'hidden', 'indeterminate', 'loop', 'multiple', 'open', 'readonly', 'required', 'scoped', 'selected'];
_.each(config.attributes || [], function(attrConfig) {
var lastClass = '', observed, updateAttr;
attrConfig = _.clone(attrConfig);
observed = attrConfig.observe || (attrConfig.observe = modelAttr),
updateAttr = function() {
var updateType = _.indexOf(props, attrConfig.name, true) > -1 ? 'prop' : 'attr',
val = getAttr(model, observed, attrConfig, view);
// If it is a class then we need to remove the last value and add the new.
if (attrConfig.name === 'class') {
$el.removeClass(lastClass).addClass(val);
lastClass = val;
}
else $el[updateType](attrConfig.name, val);
};
_.each(_.flatten([observed]), function(attr) {
observeModelEvent(model, view, 'change:' + attr, updateAttr);
});
updateAttr();
});
};
// If `visible` is configured, then the view element will be shown/hidden
// based on the truthiness of the modelattr's value or the result of the
// given callback. If a `visibleFn` is also supplied, then that callback
// will be executed to manually handle showing/hiding the view element.
//
// observe: 'isRight',
// visible: true, // or function(val, options) {}
// visibleFn: function($el, isVisible, options) {} // optional handler
//
var initializeVisible = function(view, $el, config, model, modelAttr) {
if (config.visible == null) return;
var visibleCb = function() {
var visible = config.visible,
visibleFn = config.visibleFn,
val = getAttr(model, modelAttr, config, view),
isVisible = !!val;
// If `visible` is a function then it should return a boolean result to show/hide.
if (_.isFunction(visible) || _.isString(visible)) isVisible = applyViewFn(view, visible, val, config);
// Either use the custom `visibleFn`, if provided, or execute the standard show/hide.
if (visibleFn) applyViewFn(view, visibleFn, $el, isVisible, config);
else {
$el.toggle(isVisible);
}
};
_.each(_.flatten([modelAttr]), function(attr) {
observeModelEvent(model, view, 'change:' + attr, visibleCb);
});
visibleCb();
};
// Update the value of `$el` using the given configuration and trigger the
// `afterUpdate` callback. This action may be blocked by `config.updateView`.
//
// update: function($el, val, model, options) {}, // handler for updating
// updateView: true, // defaults to true
// afterUpdate: function($el, val, options) {} // optional callback
//
var updateViewBindEl = function(view, $el, config, val, model, isInitializing) {
if (!evaluateBoolean(view, config.updateView, val, config)) return;
applyViewFn(view, config.update, $el, val, model, config);
if (!isInitializing) applyViewFn(view, config.afterUpdate, $el, val, config);
};
// Default Handlers
// ----------------
Backbone.Stickit.addHandler([{
selector: '[contenteditable="true"]',
updateMethod: 'html',
events: ['input', 'change']
}, {
selector: 'input',
events: ['propertychange', 'input', 'change'],
update: function($el, val) { $el.val(val); },
getVal: function($el) {
return $el.val();
}
}, {
selector: 'textarea',
events: ['propertychange', 'input', 'change'],
update: function($el, val) { $el.val(val); },
getVal: function($el) { return $el.val(); }
}, {
selector: 'input[type="radio"]',
events: ['change'],
update: function($el, val) {
$el.filter('[value="'+val+'"]').prop('checked', true);
},
getVal: function($el) {
return $el.filter(':checked').val();
}
}, {
selector: 'input[type="checkbox"]',
events: ['change'],
update: function($el, val, model, options) {
if ($el.length > 1) {
// There are multiple checkboxes so we need to go through them and check
// any that have value attributes that match what's in the array of `val`s.
val || (val = []);
_.each($el, function(el) {
if (_.indexOf(val, $(el).val()) > -1) $(el).prop('checked', true);
else $(el).prop('checked', false);
});
} else {
if (_.isBoolean(val)) $el.prop('checked', val);
else $el.prop('checked', val === $el.val());
}
},
getVal: function($el) {
var val;
if ($el.length > 1) {
val = _.reduce($el, function(memo, el) {
if ($(el).prop('checked')) memo.push($(el).val());
return memo;
}, []);
} else {
val = $el.prop('checked');
// If the checkbox has a value attribute defined, then
// use that value. Most browsers use "on" as a default.
var boxval = $el.val();
if (boxval !== 'on' && boxval != null) {
val = val ? $el.val() : null;
}
}
return val;
}
}, {
selector: 'select',
events: ['change'],
update: function($el, val, model, options) {
var optList,
selectConfig = options.selectOptions,
list = selectConfig && selectConfig.collection || undefined,
isMultiple = $el.prop('multiple');
// If there are no `selectOptions` then we assume that the `<select>`
// is pre-rendered and that we need to generate the collection.
if (!selectConfig) {
selectConfig = {};
var getList = function($el) {
return $el.map(function() {
return {value:this.value, label:this.text};
}).get();
};
if ($el.find('optgroup').length) {
list = {opt_labels:[]};
// Search for options without optgroup
if ($el.find('> option').length) {
list.opt_labels.push(undefined);
_.each($el.find('> option'), function(el) {
list[undefined] = getList($(el));
});
}
_.each($el.find('optgroup'), function(el) {
var label = $(el).attr('label');
list.opt_labels.push(label);
list[label] = getList($(el).find('option'));
});
} else {
list = getList($el.find('option'));
}
}
// Fill in default label and path values.
selectConfig.valuePath = selectConfig.valuePath || 'value';
selectConfig.labelPath = selectConfig.labelPath || 'label';
var addSelectOptions = function(optList, $el, fieldVal) {
_.each(optList, function(obj) {
var option = $('<option/>'), optionVal = obj;
var fillOption = function(text, val) {
option.text(text);
optionVal = val;
// Save the option value as data so that we can reference it later.
option.data('stickit_bind_val', optionVal);
if (!_.isArray(optionVal) && !_.isObject(optionVal)) option.val(optionVal);
};
if (obj === '__default__')
fillOption(selectConfig.defaultOption.label, selectConfig.defaultOption.value);
else
fillOption(evaluatePath(obj, selectConfig.labelPath), evaluatePath(obj, selectConfig.valuePath));
// Determine if this option is selected.
if (!isMultiple && optionVal != null && fieldVal != null && optionVal === fieldVal || (_.isObject(fieldVal) && _.isEqual(optionVal, fieldVal)))
option.prop('selected', true);
else if (isMultiple && _.isArray(fieldVal)) {
_.each(fieldVal, function(val) {
if (_.isObject(val)) val = evaluatePath(val, selectConfig.valuePath);
if (val === optionVal || (_.isObject(val) && _.isEqual(optionVal, val)))
option.prop('selected', true);
});
}
$el.append(option);
});
};
$el.html('');
// The `list` configuration is a function that returns the options list or a string
// which represents the path to the list relative to `window` or the view/`this`.
var evaluate = function(view, list) {
var context = window;
if (list.indexOf('this.') === 0) context = view;
list = list.replace(/^[a-z]*\.(.+)$/, '$1');
return evaluatePath(context, list);
};
if (_.isString(list)) optList = evaluate(this, list);
else if (_.isFunction(list)) optList = applyViewFn(this, list, $el, options);
else optList = list;
// Support Backbone.Collection and deserialize.
if (optList instanceof Backbone.Collection) optList = optList.toJSON();
if (selectConfig.defaultOption) {
addSelectOptions(["__default__"], $el)
}
if (_.isArray(optList)) {
addSelectOptions(optList, $el, val);
} else if (optList.opt_labels) {
// To define a select with optgroups, format selectOptions.collection as an object
// with an 'opt_labels' property, as in the following:
//
// {
// 'opt_labels': ['Looney Tunes', 'Three Stooges'],
// 'Looney Tunes': [{id: 1, name: 'Bugs Bunny'}, {id: 2, name: 'Donald Duck'}],
// 'Three Stooges': [{id: 3, name : 'moe'}, {id: 4, name : 'larry'}, {id: 5, name : 'curly'}]
// }
//
_.each(optList.opt_labels, function(label) {
var $group = $('<optgroup/>').attr('label', label);
addSelectOptions(optList[label], $group, val);
$el.append($group);
});
// With no 'opt_labels' parameter, the object is assumed to be a simple value-label map.
// Pass a selectOptions.comparator to override the default order of alphabetical by label.
} else {
var opts = [], opt;
for (var i in optList) {
opt = {};
opt[selectConfig.valuePath] = i;
opt[selectConfig.labelPath] = optList[i];
opts.push(opt);
}
addSelectOptions(_.sortBy(opts, selectConfig.comparator || selectConfig.labelPath), $el, val);
}
},
getVal: function($el) {
var val;
if ($el.prop('multiple')) {
val = $(getSelectedOption($el).map(function() {
return $(this).data('stickit_bind_val');
})).get();
} else {
val = getSelectedOption($el).data('stickit_bind_val');
}
return val;
}
}]);
})(Backbone);

View File

@ -1,438 +0,0 @@
/*jshint expr:true eqnull:true */
/**
*
* Backbone.DeepModel v0.10.4
*
* Copyright (c) 2013 Charles Davison, Pow Media Ltd
*
* https://github.com/powmedia/backbone-deep-model
* Licensed under the MIT License
*/
/**
* Underscore mixins for deep objects
*
* Based on https://gist.github.com/echong/3861963
*/
(function() {
var arrays, basicObjects, deepClone, deepExtend, deepExtendCouple, isBasicObject,
__slice = [].slice;
deepClone = function(obj) {
var func, isArr;
if (!_.isObject(obj) || _.isFunction(obj)) {
return obj;
}
if (obj instanceof Backbone.Collection || obj instanceof Backbone.Model) {
return obj;
}
if (_.isDate(obj)) {
return new Date(obj.getTime());
}
if (_.isRegExp(obj)) {
return new RegExp(obj.source, obj.toString().replace(/.*\//, ""));
}
isArr = _.isArray(obj || _.isArguments(obj));
func = function(memo, value, key) {
if (isArr) {
memo.push(deepClone(value));
} else {
memo[key] = deepClone(value);
}
return memo;
};
return _.reduce(obj, func, isArr ? [] : {});
};
isBasicObject = function(object) {
if (object == null) return false;
return (object.prototype === {}.prototype || object.prototype === Object.prototype) && _.isObject(object) && !_.isArray(object) && !_.isFunction(object) && !_.isDate(object) && !_.isRegExp(object) && !_.isArguments(object);
};
basicObjects = function(object) {
return _.filter(_.keys(object), function(key) {
return isBasicObject(object[key]);
});
};
arrays = function(object) {
return _.filter(_.keys(object), function(key) {
return _.isArray(object[key]);
});
};
deepExtendCouple = function(destination, source, maxDepth) {
var combine, recurse, sharedArrayKey, sharedArrayKeys, sharedObjectKey, sharedObjectKeys, _i, _j, _len, _len1;
if (maxDepth == null) {
maxDepth = 20;
}
if (maxDepth <= 0) {
console.warn('_.deepExtend(): Maximum depth of recursion hit.');
return _.extend(destination, source);
}
sharedObjectKeys = _.intersection(basicObjects(destination), basicObjects(source));
recurse = function(key) {
return source[key] = deepExtendCouple(destination[key], source[key], maxDepth - 1);
};
for (_i = 0, _len = sharedObjectKeys.length; _i < _len; _i++) {
sharedObjectKey = sharedObjectKeys[_i];
recurse(sharedObjectKey);
}
sharedArrayKeys = _.intersection(arrays(destination), arrays(source));
combine = function(key) {
return source[key] = _.union(destination[key], source[key]);
};
for (_j = 0, _len1 = sharedArrayKeys.length; _j < _len1; _j++) {
sharedArrayKey = sharedArrayKeys[_j];
combine(sharedArrayKey);
}
return _.extend(destination, source);
};
deepExtend = function() {
var finalObj, maxDepth, objects, _i;
objects = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), maxDepth = arguments[_i++];
if (!_.isNumber(maxDepth)) {
objects.push(maxDepth);
maxDepth = 20;
}
if (objects.length <= 1) {
return objects[0];
}
if (maxDepth <= 0) {
return _.extend.apply(this, objects);
}
finalObj = objects.shift();
while (objects.length > 0) {
finalObj = deepExtendCouple(finalObj, deepClone(objects.shift()), maxDepth);
}
return finalObj;
};
_.mixin({
deepClone: deepClone,
isBasicObject: isBasicObject,
basicObjects: basicObjects,
arrays: arrays,
deepExtend: deepExtend
});
}).call(this);
/**
* Main source
*/
;(function(factory) {
if (typeof define === 'function' && define.amd) {
// AMD
define(['underscore', 'backbone'], factory);
} else {
// globals
factory(_, Backbone);
}
}(function(_, Backbone) {
/**
* Takes a nested object and returns a shallow object keyed with the path names
* e.g. { "level1.level2": "value" }
*
* @param {Object} Nested object e.g. { level1: { level2: 'value' } }
* @return {Object} Shallow object with path names e.g. { 'level1.level2': 'value' }
*/
function objToPaths(obj) {
var ret = {},
separator = DeepModel.keyPathSeparator;
for (var key in obj) {
var val = obj[key];
if (val && val.constructor === Object && !_.isEmpty(val)) {
//Recursion for embedded objects
var obj2 = objToPaths(val);
for (var key2 in obj2) {
var val2 = obj2[key2];
ret[key + separator + key2] = val2;
}
} else {
ret[key] = val;
}
}
return ret;
}
/**
* @param {Object} Object to fetch attribute from
* @param {String} Object path e.g. 'user.name'
* @return {Mixed}
*/
function getNested(obj, path, return_exists) {
var separator = DeepModel.keyPathSeparator;
var fields = path.split(separator);
var result = obj;
return_exists || (return_exists === false);
for (var i = 0, n = fields.length; i < n; i++) {
if (return_exists && !_.has(result, fields[i])) {
return false;
}
result = result[fields[i]];
if (result == null && i < n - 1) {
result = {};
}
if (typeof result === 'undefined') {
if (return_exists)
{
return true;
}
return result;
}
}
if (return_exists)
{
return true;
}
return result;
}
/**
* @param {Object} obj Object to fetch attribute from
* @param {String} path Object path e.g. 'user.name'
* @param {Object} [options] Options
* @param {Boolean} [options.unset] Whether to delete the value
* @param {Mixed} Value to set
*/
function setNested(obj, path, val, options) {
options = options || {};
var separator = DeepModel.keyPathSeparator;
var fields = path.split(separator);
var result = obj;
for (var i = 0, n = fields.length; i < n && result !== undefined ; i++) {
var field = fields[i];
//If the last in the path, set the value
if (i === n - 1) {
options.unset ? delete result[field] : result[field] = val;
} else {
//Create the child object if it doesn't exist, or isn't an object
if (typeof result[field] === 'undefined' || ! _.isObject(result[field])) {
result[field] = {};
}
//Move onto the next part of the path
result = result[field];
}
}
}
function deleteNested(obj, path) {
setNested(obj, path, null, { unset: true });
}
var DeepModel = Backbone.Model.extend({
// Override constructor
// Support having nested defaults by using _.deepExtend instead of _.extend
constructor: function(attributes, options) {
var defaults;
var attrs = attributes || {};
this.cid = _.uniqueId('c');
this.attributes = {};
if (options && options.collection) this.collection = options.collection;
if (options && options.parse) attrs = this.parse(attrs, options) || {};
if (defaults = _.result(this, 'defaults')) {
//<custom code>
// Replaced the call to _.defaults with _.deepExtend.
attrs = _.deepExtend({}, defaults, attrs);
//</custom code>
}
this.set(attrs, options);
this.changed = {};
this.initialize.apply(this, arguments);
},
// Return a copy of the model's `attributes` object.
toJSON: function(options) {
return _.deepClone(this.attributes);
},
// Override get
// Supports nested attributes via the syntax 'obj.attr' e.g. 'author.user.name'
get: function(attr) {
return getNested(this.attributes, attr);
},
// Override set
// Supports nested attributes via the syntax 'obj.attr' e.g. 'author.user.name'
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 = _.deepClone(this.attributes); //<custom>: Replaced _.clone with _.deepClone
this.changed = {};
}
current = this.attributes, prev = this._previousAttributes;
// Check for changes of `id`.
if (this.idAttribute in attrs) this.id = attrs[this.idAttribute];
//<custom code>
attrs = objToPaths(attrs);
//</custom code>
// For each `set` attribute, update or delete the current value.
for (attr in attrs) {
val = attrs[attr];
//<custom code>: Using getNested, setNested and deleteNested
if (!_.isEqual(getNested(current, attr), val)) changes.push(attr);
if (!_.isEqual(getNested(prev, attr), val)) {
setNested(this.changed, attr, val);
} else {
deleteNested(this.changed, attr);
}
unset ? deleteNested(current, attr) : setNested(current, attr, val);
//</custom code>
}
// Trigger all relevant attribute changes.
if (!silent) {
if (changes.length) this._pending = true;
//<custom code>
var separator = DeepModel.keyPathSeparator;
for (var i = 0, l = changes.length; i < l; i++) {
var key = changes[i];
this.trigger('change:' + key, this, getNested(current, key), options);
var fields = key.split(separator);
//Trigger change events for parent keys with wildcard (*) notation
for(var n = fields.length - 1; n > 0; n--) {
var parentKey = _.first(fields, n).join(separator),
wildcardKey = parentKey + separator + '*';
this.trigger('change:' + wildcardKey, this, getNested(current, parentKey), options);
}
//</custom code>
}
}
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;
},
// Clear all attributes on the model, firing `"change"` unless you choose
// to silence it.
clear: function(options) {
var attrs = {};
var shallowAttributes = objToPaths(this.attributes);
for (var key in shallowAttributes) 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 getNested(this.changed, attr) !== undefined;
},
// 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) {
//<custom code>: objToPaths
if (!diff) return this.hasChanged() ? objToPaths(this.changed) : false;
//</custom code>
var old = this._changing ? this._previousAttributes : this.attributes;
//<custom code>
diff = objToPaths(diff);
old = objToPaths(old);
//</custom code>
var val, changed = false;
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;
//<custom code>
return getNested(this._previousAttributes, attr);
//</custom code>
},
// Get all of the attributes of the model at the time of the previous
// `"change"` event.
previousAttributes: function() {
//<custom code>
return _.deepClone(this._previousAttributes);
//</custom code>
}
});
//Config; override in your app to customise
DeepModel.keyPathSeparator = '.';
//Exports
Backbone.DeepModel = DeepModel;
//For use in NodeJS
if (typeof module != 'undefined') module.exports = DeepModel;
return Backbone;
}));

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,49 +0,0 @@
/**
* jquery.timeout.js
*
* Copyright (c) 2011 Thomas Kemmer <tkemmer@computer.org>
*
* http://code.google.com/p/jquery-timeout/
*
* 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.
*/
;(function($) {
$.timeout = function(delay) {
var args = Array.prototype.slice.call(arguments, 1);
var deferred = $.Deferred(function(deferred) {
deferred.timeoutID = window.setTimeout(function() {
deferred.resolveWith(deferred, args);
}, delay);
deferred.fail(function() {
window.clearTimeout(deferred.timeoutID);
});
});
return $.extend(deferred.promise(), {
clear: function() {
deferred.rejectWith(deferred, arguments);
}
});
};
})(jQuery);

File diff suppressed because it is too large Load Diff

View File

@ -1,35 +0,0 @@
/*
RequireJS 2.1.4 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
*/
var requirejs,require,define;
(function(Y){function I(b){return"[object Function]"===L.call(b)}function J(b){return"[object Array]"===L.call(b)}function x(b,c){if(b){var d;for(d=0;d<b.length&&(!b[d]||!c(b[d],d,b));d+=1);}}function M(b,c){if(b){var d;for(d=b.length-1;-1<d&&(!b[d]||!c(b[d],d,b));d-=1);}}function r(b,c){return da.call(b,c)}function i(b,c){return r(b,c)&&b[c]}function E(b,c){for(var d in b)if(r(b,d)&&c(b[d],d))break}function Q(b,c,d,i){c&&E(c,function(c,h){if(d||!r(b,h))i&&"string"!==typeof c?(b[h]||(b[h]={}),Q(b[h],
c,d,i)):b[h]=c});return b}function t(b,c){return function(){return c.apply(b,arguments)}}function Z(b){if(!b)return b;var c=Y;x(b.split("."),function(b){c=c[b]});return c}function F(b,c,d,i){c=Error(c+"\nhttp://requirejs.org/docs/errors.html#"+b);c.requireType=b;c.requireModules=i;d&&(c.originalError=d);return c}function ea(b){function c(a,f,v){var e,n,b,c,d,k,g,h=f&&f.split("/");e=h;var l=m.map,j=l&&l["*"];if(a&&"."===a.charAt(0))if(f){e=i(m.pkgs,f)?h=[f]:h.slice(0,h.length-1);f=a=e.concat(a.split("/"));
for(e=0;f[e];e+=1)if(n=f[e],"."===n)f.splice(e,1),e-=1;else if(".."===n)if(1===e&&(".."===f[2]||".."===f[0]))break;else 0<e&&(f.splice(e-1,2),e-=2);e=i(m.pkgs,f=a[0]);a=a.join("/");e&&a===f+"/"+e.main&&(a=f)}else 0===a.indexOf("./")&&(a=a.substring(2));if(v&&(h||j)&&l){f=a.split("/");for(e=f.length;0<e;e-=1){b=f.slice(0,e).join("/");if(h)for(n=h.length;0<n;n-=1)if(v=i(l,h.slice(0,n).join("/")))if(v=i(v,b)){c=v;d=e;break}if(c)break;!k&&(j&&i(j,b))&&(k=i(j,b),g=e)}!c&&k&&(c=k,d=g);c&&(f.splice(0,d,
c),a=f.join("/"))}return a}function d(a){z&&x(document.getElementsByTagName("script"),function(f){if(f.getAttribute("data-requiremodule")===a&&f.getAttribute("data-requirecontext")===k.contextName)return f.parentNode.removeChild(f),!0})}function y(a){var f=i(m.paths,a);if(f&&J(f)&&1<f.length)return d(a),f.shift(),k.require.undef(a),k.require([a]),!0}function g(a){var f,b=a?a.indexOf("!"):-1;-1<b&&(f=a.substring(0,b),a=a.substring(b+1,a.length));return[f,a]}function h(a,f,b,e){var n,u,d=null,h=f?f.name:
null,l=a,m=!0,j="";a||(m=!1,a="_@r"+(L+=1));a=g(a);d=a[0];a=a[1];d&&(d=c(d,h,e),u=i(p,d));a&&(d?j=u&&u.normalize?u.normalize(a,function(a){return c(a,h,e)}):c(a,h,e):(j=c(a,h,e),a=g(j),d=a[0],j=a[1],b=!0,n=k.nameToUrl(j)));b=d&&!u&&!b?"_unnormalized"+(M+=1):"";return{prefix:d,name:j,parentMap:f,unnormalized:!!b,url:n,originalName:l,isDefine:m,id:(d?d+"!"+j:j)+b}}function q(a){var f=a.id,b=i(j,f);b||(b=j[f]=new k.Module(a));return b}function s(a,f,b){var e=a.id,n=i(j,e);if(r(p,e)&&(!n||n.defineEmitComplete))"defined"===
f&&b(p[e]);else q(a).on(f,b)}function A(a,f){var b=a.requireModules,e=!1;if(f)f(a);else if(x(b,function(f){if(f=i(j,f))f.error=a,f.events.error&&(e=!0,f.emit("error",a))}),!e)l.onError(a)}function w(){R.length&&(fa.apply(G,[G.length-1,0].concat(R)),R=[])}function B(a,f,b){var e=a.map.id;a.error?a.emit("error",a.error):(f[e]=!0,x(a.depMaps,function(e,c){var d=e.id,h=i(j,d);h&&(!a.depMatched[c]&&!b[d])&&(i(f,d)?(a.defineDep(c,p[d]),a.check()):B(h,f,b))}),b[e]=!0)}function C(){var a,f,b,e,n=(b=1E3*m.waitSeconds)&&
k.startTime+b<(new Date).getTime(),c=[],h=[],g=!1,l=!0;if(!T){T=!0;E(j,function(b){a=b.map;f=a.id;if(b.enabled&&(a.isDefine||h.push(b),!b.error))if(!b.inited&&n)y(f)?g=e=!0:(c.push(f),d(f));else if(!b.inited&&(b.fetched&&a.isDefine)&&(g=!0,!a.prefix))return l=!1});if(n&&c.length)return b=F("timeout","Load timeout for modules: "+c,null,c),b.contextName=k.contextName,A(b);l&&x(h,function(a){B(a,{},{})});if((!n||e)&&g)if((z||$)&&!U)U=setTimeout(function(){U=0;C()},50);T=!1}}function D(a){r(p,a[0])||
q(h(a[0],null,!0)).init(a[1],a[2])}function H(a){var a=a.currentTarget||a.srcElement,b=k.onScriptLoad;a.detachEvent&&!V?a.detachEvent("onreadystatechange",b):a.removeEventListener("load",b,!1);b=k.onScriptError;(!a.detachEvent||V)&&a.removeEventListener("error",b,!1);return{node:a,id:a&&a.getAttribute("data-requiremodule")}}function K(){var a;for(w();G.length;){a=G.shift();if(null===a[0])return A(F("mismatch","Mismatched anonymous define() module: "+a[a.length-1]));D(a)}}var T,W,k,N,U,m={waitSeconds:7,
baseUrl:"./",paths:{},pkgs:{},shim:{},map:{},config:{}},j={},X={},G=[],p={},S={},L=1,M=1;N={require:function(a){return a.require?a.require:a.require=k.makeRequire(a.map)},exports:function(a){a.usingExports=!0;if(a.map.isDefine)return a.exports?a.exports:a.exports=p[a.map.id]={}},module:function(a){return a.module?a.module:a.module={id:a.map.id,uri:a.map.url,config:function(){return m.config&&i(m.config,a.map.id)||{}},exports:p[a.map.id]}}};W=function(a){this.events=i(X,a.id)||{};this.map=a;this.shim=
i(m.shim,a.id);this.depExports=[];this.depMaps=[];this.depMatched=[];this.pluginMaps={};this.depCount=0};W.prototype={init:function(a,b,c,e){e=e||{};if(!this.inited){this.factory=b;if(c)this.on("error",c);else this.events.error&&(c=t(this,function(a){this.emit("error",a)}));this.depMaps=a&&a.slice(0);this.errback=c;this.inited=!0;this.ignore=e.ignore;e.enabled||this.enabled?this.enable():this.check()}},defineDep:function(a,b){this.depMatched[a]||(this.depMatched[a]=!0,this.depCount-=1,this.depExports[a]=
b)},fetch:function(){if(!this.fetched){this.fetched=!0;k.startTime=(new Date).getTime();var a=this.map;if(this.shim)k.makeRequire(this.map,{enableBuildCallback:!0})(this.shim.deps||[],t(this,function(){return a.prefix?this.callPlugin():this.load()}));else return a.prefix?this.callPlugin():this.load()}},load:function(){var a=this.map.url;S[a]||(S[a]=!0,k.load(this.map.id,a))},check:function(){if(this.enabled&&!this.enabling){var a,b,c=this.map.id;b=this.depExports;var e=this.exports,n=this.factory;
if(this.inited)if(this.error)this.emit("error",this.error);else{if(!this.defining){this.defining=!0;if(1>this.depCount&&!this.defined){if(I(n)){if(this.events.error)try{e=k.execCb(c,n,b,e)}catch(d){a=d}else e=k.execCb(c,n,b,e);this.map.isDefine&&((b=this.module)&&void 0!==b.exports&&b.exports!==this.exports?e=b.exports:void 0===e&&this.usingExports&&(e=this.exports));if(a)return a.requireMap=this.map,a.requireModules=[this.map.id],a.requireType="define",A(this.error=a)}else e=n;this.exports=e;if(this.map.isDefine&&
!this.ignore&&(p[c]=e,l.onResourceLoad))l.onResourceLoad(k,this.map,this.depMaps);delete j[c];this.defined=!0}this.defining=!1;this.defined&&!this.defineEmitted&&(this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete=!0)}}else this.fetch()}},callPlugin:function(){var a=this.map,b=a.id,d=h(a.prefix);this.depMaps.push(d);s(d,"defined",t(this,function(e){var n,d;d=this.map.name;var v=this.map.parentMap?this.map.parentMap.name:null,g=k.makeRequire(a.parentMap,{enableBuildCallback:!0});
if(this.map.unnormalized){if(e.normalize&&(d=e.normalize(d,function(a){return c(a,v,!0)})||""),e=h(a.prefix+"!"+d,this.map.parentMap),s(e,"defined",t(this,function(a){this.init([],function(){return a},null,{enabled:!0,ignore:!0})})),d=i(j,e.id)){this.depMaps.push(e);if(this.events.error)d.on("error",t(this,function(a){this.emit("error",a)}));d.enable()}}else n=t(this,function(a){this.init([],function(){return a},null,{enabled:!0})}),n.error=t(this,function(a){this.inited=!0;this.error=a;a.requireModules=
[b];E(j,function(a){0===a.map.id.indexOf(b+"_unnormalized")&&delete j[a.map.id]});A(a)}),n.fromText=t(this,function(e,c){var d=a.name,u=h(d),v=O;c&&(e=c);v&&(O=!1);q(u);r(m.config,b)&&(m.config[d]=m.config[b]);try{l.exec(e)}catch(j){return A(F("fromtexteval","fromText eval for "+b+" failed: "+j,j,[b]))}v&&(O=!0);this.depMaps.push(u);k.completeLoad(d);g([d],n)}),e.load(a.name,g,n,m)}));k.enable(d,this);this.pluginMaps[d.id]=d},enable:function(){this.enabling=this.enabled=!0;x(this.depMaps,t(this,function(a,
b){var c,e;if("string"===typeof a){a=h(a,this.map.isDefine?this.map:this.map.parentMap,!1,!this.skipMap);this.depMaps[b]=a;if(c=i(N,a.id)){this.depExports[b]=c(this);return}this.depCount+=1;s(a,"defined",t(this,function(a){this.defineDep(b,a);this.check()}));this.errback&&s(a,"error",this.errback)}c=a.id;e=j[c];!r(N,c)&&(e&&!e.enabled)&&k.enable(a,this)}));E(this.pluginMaps,t(this,function(a){var b=i(j,a.id);b&&!b.enabled&&k.enable(a,this)}));this.enabling=!1;this.check()},on:function(a,b){var c=
this.events[a];c||(c=this.events[a]=[]);c.push(b)},emit:function(a,b){x(this.events[a],function(a){a(b)});"error"===a&&delete this.events[a]}};k={config:m,contextName:b,registry:j,defined:p,urlFetched:S,defQueue:G,Module:W,makeModuleMap:h,nextTick:l.nextTick,configure:function(a){a.baseUrl&&"/"!==a.baseUrl.charAt(a.baseUrl.length-1)&&(a.baseUrl+="/");var b=m.pkgs,c=m.shim,e={paths:!0,config:!0,map:!0};E(a,function(a,b){e[b]?"map"===b?Q(m[b],a,!0,!0):Q(m[b],a,!0):m[b]=a});a.shim&&(E(a.shim,function(a,
b){J(a)&&(a={deps:a});if((a.exports||a.init)&&!a.exportsFn)a.exportsFn=k.makeShimExports(a);c[b]=a}),m.shim=c);a.packages&&(x(a.packages,function(a){a="string"===typeof a?{name:a}:a;b[a.name]={name:a.name,location:a.location||a.name,main:(a.main||"main").replace(ga,"").replace(aa,"")}}),m.pkgs=b);E(j,function(a,b){!a.inited&&!a.map.unnormalized&&(a.map=h(b))});if(a.deps||a.callback)k.require(a.deps||[],a.callback)},makeShimExports:function(a){return function(){var b;a.init&&(b=a.init.apply(Y,arguments));
return b||a.exports&&Z(a.exports)}},makeRequire:function(a,d){function g(e,c,u){var i,m;d.enableBuildCallback&&(c&&I(c))&&(c.__requireJsBuild=!0);if("string"===typeof e){if(I(c))return A(F("requireargs","Invalid require call"),u);if(a&&r(N,e))return N[e](j[a.id]);if(l.get)return l.get(k,e,a);i=h(e,a,!1,!0);i=i.id;return!r(p,i)?A(F("notloaded",'Module name "'+i+'" has not been loaded yet for context: '+b+(a?"":". Use require([])"))):p[i]}K();k.nextTick(function(){K();m=q(h(null,a));m.skipMap=d.skipMap;
m.init(e,c,u,{enabled:!0});C()});return g}d=d||{};Q(g,{isBrowser:z,toUrl:function(b){var d,f=b.lastIndexOf("."),h=b.split("/")[0];if(-1!==f&&(!("."===h||".."===h)||1<f))d=b.substring(f,b.length),b=b.substring(0,f);b=k.nameToUrl(c(b,a&&a.id,!0),d||".fake");return d?b:b.substring(0,b.length-5)},defined:function(b){return r(p,h(b,a,!1,!0).id)},specified:function(b){b=h(b,a,!1,!0).id;return r(p,b)||r(j,b)}});a||(g.undef=function(b){w();var c=h(b,a,!0),d=i(j,b);delete p[b];delete S[c.url];delete X[b];
d&&(d.events.defined&&(X[b]=d.events),delete j[b])});return g},enable:function(a){i(j,a.id)&&q(a).enable()},completeLoad:function(a){var b,c,d=i(m.shim,a)||{},h=d.exports;for(w();G.length;){c=G.shift();if(null===c[0]){c[0]=a;if(b)break;b=!0}else c[0]===a&&(b=!0);D(c)}c=i(j,a);if(!b&&!r(p,a)&&c&&!c.inited){if(m.enforceDefine&&(!h||!Z(h)))return y(a)?void 0:A(F("nodefine","No define call for "+a,null,[a]));D([a,d.deps||[],d.exportsFn])}C()},nameToUrl:function(a,b){var c,d,h,g,k,j;if(l.jsExtRegExp.test(a))g=
a+(b||"");else{c=m.paths;d=m.pkgs;g=a.split("/");for(k=g.length;0<k;k-=1)if(j=g.slice(0,k).join("/"),h=i(d,j),j=i(c,j)){J(j)&&(j=j[0]);g.splice(0,k,j);break}else if(h){c=a===h.name?h.location+"/"+h.main:h.location;g.splice(0,k,c);break}g=g.join("/");g+=b||(/\?/.test(g)?"":".js");g=("/"===g.charAt(0)||g.match(/^[\w\+\.\-]+:/)?"":m.baseUrl)+g}return m.urlArgs?g+((-1===g.indexOf("?")?"?":"&")+m.urlArgs):g},load:function(a,b){l.load(k,a,b)},execCb:function(a,b,c,d){return b.apply(d,c)},onScriptLoad:function(a){if("load"===
a.type||ha.test((a.currentTarget||a.srcElement).readyState))P=null,a=H(a),k.completeLoad(a.id)},onScriptError:function(a){var b=H(a);if(!y(b.id))return A(F("scripterror","Script error",a,[b.id]))}};k.require=k.makeRequire();return k}var l,w,B,D,s,H,P,K,ba,ca,ia=/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,ja=/[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,aa=/\.js$/,ga=/^\.\//;w=Object.prototype;var L=w.toString,da=w.hasOwnProperty,fa=Array.prototype.splice,z=!!("undefined"!==typeof window&&navigator&&
document),$=!z&&"undefined"!==typeof importScripts,ha=z&&"PLAYSTATION 3"===navigator.platform?/^complete$/:/^(complete|loaded)$/,V="undefined"!==typeof opera&&"[object Opera]"===opera.toString(),C={},q={},R=[],O=!1;if("undefined"===typeof define){if("undefined"!==typeof requirejs){if(I(requirejs))return;q=requirejs;requirejs=void 0}"undefined"!==typeof require&&!I(require)&&(q=require,require=void 0);l=requirejs=function(b,c,d,y){var g,h="_";!J(b)&&"string"!==typeof b&&(g=b,J(c)?(b=c,c=d,d=y):b=[]);
g&&g.context&&(h=g.context);(y=i(C,h))||(y=C[h]=l.s.newContext(h));g&&y.configure(g);return y.require(b,c,d)};l.config=function(b){return l(b)};l.nextTick="undefined"!==typeof setTimeout?function(b){setTimeout(b,4)}:function(b){b()};require||(require=l);l.version="2.1.4";l.jsExtRegExp=/^\/|:|\?|\.js$/;l.isBrowser=z;w=l.s={contexts:C,newContext:ea};l({});x(["toUrl","undef","defined","specified"],function(b){l[b]=function(){var c=C._;return c.require[b].apply(c,arguments)}});if(z&&(B=w.head=document.getElementsByTagName("head")[0],
D=document.getElementsByTagName("base")[0]))B=w.head=D.parentNode;l.onError=function(b){throw b;};l.load=function(b,c,d){var i=b&&b.config||{},g;if(z)return g=i.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml","html:script"):document.createElement("script"),g.type=i.scriptType||"text/javascript",g.charset="utf-8",g.async=!0,g.setAttribute("data-requirecontext",b.contextName),g.setAttribute("data-requiremodule",c),g.attachEvent&&!(g.attachEvent.toString&&0>g.attachEvent.toString().indexOf("[native code"))&&
!V?(O=!0,g.attachEvent("onreadystatechange",b.onScriptLoad)):(g.addEventListener("load",b.onScriptLoad,!1),g.addEventListener("error",b.onScriptError,!1)),g.src=d,K=g,D?B.insertBefore(g,D):B.appendChild(g),K=null,g;$&&(importScripts(d),b.completeLoad(c))};z&&M(document.getElementsByTagName("script"),function(b){B||(B=b.parentNode);if(s=b.getAttribute("data-main"))return q.baseUrl||(H=s.split("/"),ba=H.pop(),ca=H.length?H.join("/")+"/":"./",q.baseUrl=ca,s=ba),s=s.replace(aa,""),q.deps=q.deps?q.deps.concat(s):
[s],!0});define=function(b,c,d){var i,g;"string"!==typeof b&&(d=c,c=b,b=null);J(c)||(d=c,c=[]);!c.length&&I(d)&&d.length&&(d.toString().replace(ia,"").replace(ja,function(b,d){c.push(d)}),c=(1===d.length?["require"]:["require","exports","module"]).concat(c));if(O){if(!(i=K))P&&"interactive"===P.readyState||M(document.getElementsByTagName("script"),function(b){if("interactive"===b.readyState)return P=b}),i=P;i&&(b||(b=i.getAttribute("data-requiremodule")),g=C[i.getAttribute("data-requirecontext")])}(g?
g.defQueue:R).push([b,c,d])};define.amd={jQuery:!0};l.exec=function(b){return eval(b)};l(q)}})(this);

View File

@ -1,164 +0,0 @@
/**
* MIT License
*
* Copyright (C) 2012 Imulus
*
* Copyright (C) 2012 Ben Atkin
*
*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.
*/
(function() {
var root = (typeof exports == 'undefined' ? window : exports);
var config = {
// Ensure Content-Type is an image before trying to load @2x image
// https://github.com/imulus/retinajs/pull/45)
check_mime_type: true
};
root.Retina = Retina;
function Retina() {}
Retina.configure = function(options) {
if (options == null) options = {};
for (var prop in options) config[prop] = options[prop];
};
Retina.init = function(context) {
if (context == null) context = root;
var existing_onload = context.onload || new Function;
var cssName = "/static/css/retina.css";
var head = document.getElementsByTagName('head')[0];
var link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = cssName;
head.appendChild(link);
context.onload = function() {
var images = document.getElementsByTagName("img"), retinaImages = [], i, image;
for (i = 0; i < images.length; i++) {
image = images[i];
retinaImages.push(new RetinaImage(image));
}
existing_onload();
}
};
Retina.isRetina = function(){
var mediaQuery = "(-webkit-min-device-pixel-ratio: 1.5),\
(min--moz-device-pixel-ratio: 1.5),\
(-o-min-device-pixel-ratio: 3/2),\
(min-resolution: 1.5dppx)";
if (root.devicePixelRatio > 1)
return true;
if (root.matchMedia && root.matchMedia(mediaQuery).matches)
return true;
return false;
};
root.RetinaImagePath = RetinaImagePath;
function RetinaImagePath(path, at_2x_path) {
this.path = path;
if (typeof at_2x_path !== "undefined" && at_2x_path !== null) {
this.at_2x_path = at_2x_path;
this.perform_check = false;
} else {
this.at_2x_path = path.replace(/\.\w+$/, function(match) { return "@2x" + match; });
this.perform_check = true;
}
}
RetinaImagePath.confirmed_paths = [];
RetinaImagePath.prototype.is_external = function() {
return !!(this.path.match(/^https?\:/i) && !this.path.match('//' + document.domain) )
}
RetinaImagePath.prototype.check_2x_variant = function(callback) {
var http, that = this;
if (this.is_external()) {
return callback(false);
} else if (!this.perform_check && typeof this.at_2x_path !== "undefined" && this.at_2x_path !== null) {
return callback(true);
} else if (this.at_2x_path in RetinaImagePath.confirmed_paths) {
return callback(true);
} else {
http = new XMLHttpRequest;
http.open('HEAD', this.at_2x_path);
http.onreadystatechange = function() {
if (http.readyState != 4) {
return callback(false);
}
if (http.status >= 200 && http.status <= 399) {
if (config.check_mime_type) {
var type = http.getResponseHeader('Content-Type');
if (type == null || !type.match(/^image/i)) {
return callback(false);
}
}
RetinaImagePath.confirmed_paths.push(that.at_2x_path);
return callback(true);
} else {
return callback(false);
}
}
http.send();
}
}
function RetinaImage(el) {
this.el = el;
this.path = new RetinaImagePath(this.el.getAttribute('src'), this.el.getAttribute('data-at2x'));
var that = this;
this.path.check_2x_variant(function(hasVariant) {
if (hasVariant) that.swap();
});
}
root.RetinaImage = RetinaImage;
RetinaImage.prototype.swap = function(path) {
if (typeof path == 'undefined') path = this.path.at_2x_path;
var that = this;
function load() {
if (! that.el.complete) {
setTimeout(load, 5);
} else {
that.el.setAttribute('width', that.el.offsetWidth);
that.el.setAttribute('height', that.el.offsetHeight);
that.el.setAttribute('src', path);
}
}
load();
}
if (Retina.isRetina()) {
Retina.init(root);
}
})();

View File

@ -1,332 +0,0 @@
/**
* @license RequireJS text 2.0.5 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
* Available via the MIT or new BSD license.
* see: http://github.com/requirejs/text for details
*/
/*jslint regexp: true */
/*global require: false, XMLHttpRequest: false, ActiveXObject: false,
define: false, window: false, process: false, Packages: false,
java: false, location: false */
define(['module'], function (module) {
'use strict';
var text, fs,
progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'],
xmlRegExp = /^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im,
bodyRegExp = /<body[^>]*>\s*([\s\S]+)\s*<\/body>/im,
hasLocation = typeof location !== 'undefined' && location.href,
defaultProtocol = hasLocation && location.protocol && location.protocol.replace(/\:/, ''),
defaultHostName = hasLocation && location.hostname,
defaultPort = hasLocation && (location.port || undefined),
buildMap = [],
masterConfig = (module.config && module.config()) || {};
text = {
version: '2.0.5',
strip: function (content) {
//Strips <?xml ...?> declarations so that external SVG and XML
//documents can be added to a document without worry. Also, if the string
//is an HTML document, only the part inside the body tag is returned.
if (content) {
content = content.replace(xmlRegExp, "");
var matches = content.match(bodyRegExp);
if (matches) {
content = matches[1];
}
} else {
content = "";
}
return content;
},
jsEscape: function (content) {
return content.replace(/(['\\])/g, '\\$1')
.replace(/[\f]/g, "\\f")
.replace(/[\b]/g, "\\b")
.replace(/[\n]/g, "\\n")
.replace(/[\t]/g, "\\t")
.replace(/[\r]/g, "\\r")
.replace(/[\u2028]/g, "\\u2028")
.replace(/[\u2029]/g, "\\u2029");
},
createXhr: masterConfig.createXhr || function () {
//Would love to dump the ActiveX crap in here. Need IE 6 to die first.
var xhr, i, progId;
if (typeof XMLHttpRequest !== "undefined") {
return new XMLHttpRequest();
} else if (typeof ActiveXObject !== "undefined") {
for (i = 0; i < 3; i += 1) {
progId = progIds[i];
try {
xhr = new ActiveXObject(progId);
} catch (e) {}
if (xhr) {
progIds = [progId]; // so faster next time
break;
}
}
}
return xhr;
},
/**
* Parses a resource name into its component parts. Resource names
* look like: module/name.ext!strip, where the !strip part is
* optional.
* @param {String} name the resource name
* @returns {Object} with properties "moduleName", "ext" and "strip"
* where strip is a boolean.
*/
parseName: function (name) {
var modName, ext, temp,
strip = false,
index = name.indexOf("."),
isRelative = name.indexOf('./') === 0 ||
name.indexOf('../') === 0;
if (index !== -1 && (!isRelative || index > 1)) {
modName = name.substring(0, index);
ext = name.substring(index + 1, name.length);
} else {
modName = name;
}
temp = ext || modName;
index = temp.indexOf("!");
if (index !== -1) {
//Pull off the strip arg.
strip = temp.substring(index + 1) === "strip";
temp = temp.substring(0, index);
if (ext) {
ext = temp;
} else {
modName = temp;
}
}
return {
moduleName: modName,
ext: ext,
strip: strip
};
},
xdRegExp: /^((\w+)\:)?\/\/([^\/\\]+)/,
/**
* Is an URL on another domain. Only works for browser use, returns
* false in non-browser environments. Only used to know if an
* optimized .js version of a text resource should be loaded
* instead.
* @param {String} url
* @returns Boolean
*/
useXhr: function (url, protocol, hostname, port) {
var uProtocol, uHostName, uPort,
match = text.xdRegExp.exec(url);
if (!match) {
return true;
}
uProtocol = match[2];
uHostName = match[3];
uHostName = uHostName.split(':');
uPort = uHostName[1];
uHostName = uHostName[0];
return (!uProtocol || uProtocol === protocol) &&
(!uHostName || uHostName.toLowerCase() === hostname.toLowerCase()) &&
((!uPort && !uHostName) || uPort === port);
},
finishLoad: function (name, strip, content, onLoad) {
content = strip ? text.strip(content) : content;
if (masterConfig.isBuild) {
buildMap[name] = content;
}
onLoad(content);
},
load: function (name, req, onLoad, config) {
//Name has format: some.module.filext!strip
//The strip part is optional.
//if strip is present, then that means only get the string contents
//inside a body tag in an HTML string. For XML/SVG content it means
//removing the <?xml ...?> declarations so the content can be inserted
//into the current doc without problems.
// Do not bother with the work if a build and text will
// not be inlined.
if (config.isBuild && !config.inlineText) {
onLoad();
return;
}
masterConfig.isBuild = config.isBuild;
var parsed = text.parseName(name),
nonStripName = parsed.moduleName +
(parsed.ext ? '.' + parsed.ext : ''),
url = req.toUrl(nonStripName),
useXhr = (masterConfig.useXhr) ||
text.useXhr;
//Load the text. Use XHR if possible and in a browser.
if (!hasLocation || useXhr(url, defaultProtocol, defaultHostName, defaultPort)) {
text.get(url, function (content) {
text.finishLoad(name, parsed.strip, content, onLoad);
}, function (err) {
if (onLoad.error) {
onLoad.error(err);
}
});
} else {
//Need to fetch the resource across domains. Assume
//the resource has been optimized into a JS module. Fetch
//by the module name + extension, but do not include the
//!strip part to avoid file system issues.
req([nonStripName], function (content) {
text.finishLoad(parsed.moduleName + '.' + parsed.ext,
parsed.strip, content, onLoad);
});
}
},
write: function (pluginName, moduleName, write, config) {
if (buildMap.hasOwnProperty(moduleName)) {
var content = text.jsEscape(buildMap[moduleName]);
write.asModule(pluginName + "!" + moduleName,
"define(function () { return '" +
content +
"';});\n");
}
},
writeFile: function (pluginName, moduleName, req, write, config) {
var parsed = text.parseName(moduleName),
extPart = parsed.ext ? '.' + parsed.ext : '',
nonStripName = parsed.moduleName + extPart,
//Use a '.js' file name so that it indicates it is a
//script that can be loaded across domains.
fileName = req.toUrl(parsed.moduleName + extPart) + '.js';
//Leverage own load() method to load plugin value, but only
//write out values that do not have the strip argument,
//to avoid any potential issues with ! in file names.
text.load(nonStripName, req, function (value) {
//Use own write() method to construct full module value.
//But need to create shell that translates writeFile's
//write() to the right interface.
var textWrite = function (contents) {
return write(fileName, contents);
};
textWrite.asModule = function (moduleName, contents) {
return write.asModule(moduleName, fileName, contents);
};
text.write(pluginName, nonStripName, textWrite, config);
}, config);
}
};
if (masterConfig.env === 'node' || (!masterConfig.env &&
typeof process !== "undefined" &&
process.versions &&
!!process.versions.node)) {
//Using special require.nodeRequire, something added by r.js.
fs = require.nodeRequire('fs');
text.get = function (url, callback) {
var file = fs.readFileSync(url, 'utf8');
//Remove BOM (Byte Mark Order) from utf8 files if it is there.
if (file.indexOf('\uFEFF') === 0) {
file = file.substring(1);
}
callback(file);
};
} else if (masterConfig.env === 'xhr' || (!masterConfig.env &&
text.createXhr())) {
text.get = function (url, callback, errback, headers) {
var xhr = text.createXhr(), header;
xhr.open('GET', url, true);
//Allow plugins direct access to xhr headers
if (headers) {
for (header in headers) {
if (headers.hasOwnProperty(header)) {
xhr.setRequestHeader(header.toLowerCase(), headers[header]);
}
}
}
//Allow overrides specified in config
if (masterConfig.onXhr) {
masterConfig.onXhr(xhr, url);
}
xhr.onreadystatechange = function (evt) {
var status, err;
//Do not explicitly handle errors, those should be
//visible via console output in the browser.
if (xhr.readyState === 4) {
status = xhr.status;
if (status > 399 && status < 600) {
//An http 4xx or 5xx error. Signal an error.
err = new Error(url + ' HTTP status: ' + status);
err.xhr = xhr;
errback(err);
} else {
callback(xhr.responseText);
}
}
};
xhr.send(null);
};
} else if (masterConfig.env === 'rhino' || (!masterConfig.env &&
typeof Packages !== 'undefined' && typeof java !== 'undefined')) {
//Why Java, why is this so awkward?
text.get = function (url, callback) {
var stringBuffer, line,
encoding = "utf-8",
file = new java.io.File(url),
lineSeparator = java.lang.System.getProperty("line.separator"),
input = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(file), encoding)),
content = '';
try {
stringBuffer = new java.lang.StringBuffer();
line = input.readLine();
// Byte Order Mark (BOM) - The Unicode Standard, version 3.0, page 324
// http://www.unicode.org/faq/utf_bom.html
// Note that when we use utf-8, the BOM should appear as "EF BB BF", but it doesn't due to this bug in the JDK:
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4508058
if (line && line.length() && line.charAt(0) === 0xfeff) {
// Eat the BOM, since we've already found the encoding on this file,
// and we plan to concatenating this buffer with others; the BOM should
// only appear at the top of a file.
line = line.substring(1);
}
stringBuffer.append(line);
while ((line = input.readLine()) !== null) {
stringBuffer.append(lineSeparator);
stringBuffer.append(line);
}
//Make sure we return a JavaScript string and not a Java string.
content = String(stringBuffer.toString()); //String
} finally {
input.close();
}
callback(content);
};
}
return text;
});

View File

@ -12,27 +12,28 @@
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
**/
**/
requirejs.config({
baseUrl: 'static',
urlArgs: '_=' + (new Date()).getTime(),
waitSeconds: 60,
paths: {
jquery: 'js/libs/jquery-1.9.1',
'jquery-checkbox': 'js/libs/jquery.checkbox',
'jquery-timeout': 'js/libs/jquery.timeout',
'jquery-ui': 'js/libs/jquery-ui-1.10.2.custom',
'jquery-autoNumeric': 'js/libs/autoNumeric',
i18next: 'js/libs/i18next-1.7.1',
'jquery': 'js/libs/bower/jquery/js/jquery',
'jquery-checkbox': 'js/libs/custom/jquery.checkbox',
'jquery-timeout': 'js/libs/bower/jquery.timeout/js/index',
'jquery-ui': 'js/libs/custom/jquery-ui-1.10.2.custom',
'jquery-autoNumeric': 'js/libs/bower/autoNumeric/js/autoNumeric',
utils: 'js/utils',
underscore: 'js/libs/lodash',
backbone: 'js/libs/backbone',
stickit: 'js/libs/backbone.stickit',
deepModel: 'js/libs/deep-model',
coccyx: 'js/libs/coccyx',
bootstrap: 'js/libs/bootstrap.min',
text: 'js/libs/text',
retina: 'js/libs/retina',
lodash: 'js/libs/bower/lodash/js/lodash',
backbone: 'js/libs/custom/backbone',
stickit: 'js/libs/bower/backbone.stickit/js/index',
coccyx: 'js/libs/custom/coccyx',
bootstrap: 'js/libs/custom/bootstrap.min',
text: 'js/libs/bower/requirejs-text/js/text',
retina: 'js/libs/bower/retina.js/js/retina',
i18next: 'js/libs/bower/i18next/js/i18next-1.7.1',
underscore: 'js/libs/bower/lodash/js/lodash',
deepModel: 'js/libs/bower/backbone-deep-model/js/deep-model',
app: 'js/app',
models: 'js/models',
collections: 'js/collections',