added price per unit to item details page
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
class AddDescriptionSuffixToUnit < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :units, :description_suffix, :string
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddNumberOfPiecesSuffixToUnit < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :units, :number_of_pieces_suffix, :string
|
||||
end
|
||||
end
|
||||
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20150118082022) do
|
||||
ActiveRecord::Schema.define(version: 20150130041842) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
@@ -62,7 +62,9 @@ ActiveRecord::Schema.define(version: 20150118082022) do
|
||||
|
||||
create_table "units", force: :cascade do |t|
|
||||
t.string "name"
|
||||
t.string "short_name", limit: 4
|
||||
t.string "short_name", limit: 4
|
||||
t.string "description_suffix"
|
||||
t.string "number_of_pieces_suffix"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
18
front-api/node_modules/Backbone.Mutators/.editorconfig
generated
vendored
Normal file
18
front-api/node_modules/Backbone.Mutators/.editorconfig
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
; EditorConfig is awesome: http://EditorConfig.org
|
||||
|
||||
root = true ; top-most EditorConfig file
|
||||
|
||||
; Unix-style newlines with a newline ending every file
|
||||
[*]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
|
||||
; Space indention of 4 for all js files
|
||||
[*.js]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
; Indentation override for the node based Gruntfile
|
||||
[Gruntfile.js]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
35
front-api/node_modules/Backbone.Mutators/.jshintrc
generated
vendored
Normal file
35
front-api/node_modules/Backbone.Mutators/.jshintrc
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"curly": true,
|
||||
"eqeqeq": true,
|
||||
"forin": true,
|
||||
"immed": true,
|
||||
"latedef": true,
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"sub": true,
|
||||
"undef": true,
|
||||
"unused": true,
|
||||
"boss": true,
|
||||
"eqnull": true,
|
||||
"es5": true,
|
||||
"node": false,
|
||||
"browser": true,
|
||||
"jquery": true,
|
||||
"laxbreak": true,
|
||||
"globals": {
|
||||
"ok": true,
|
||||
"expect": true,
|
||||
"test": true,
|
||||
"module": true,
|
||||
"__dirname": true,
|
||||
"asyncTest": true,
|
||||
"start": true,
|
||||
"equal": true,
|
||||
"_": true,
|
||||
"Backbone": true,
|
||||
"exports": true,
|
||||
"require": true,
|
||||
"define": true,
|
||||
"process": true
|
||||
}
|
||||
}
|
||||
2
front-api/node_modules/Backbone.Mutators/.npmignore
generated
vendored
Normal file
2
front-api/node_modules/Backbone.Mutators/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
report
|
||||
docs
|
||||
15
front-api/node_modules/Backbone.Mutators/.travis.yml
generated
vendored
Normal file
15
front-api/node_modules/Backbone.Mutators/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
---
|
||||
language: node_js
|
||||
node_js:
|
||||
- 0.8
|
||||
before_script:
|
||||
- npm install grunt-cli -g
|
||||
- npm install backbone@~1.x
|
||||
- grunt travis --verbose
|
||||
env:
|
||||
matrix:
|
||||
- secure: ! 'iDVcf5UvrZqr05dnnJx5guL+Vp+TW+gX/IA1H20sl4XxzgQhXWtcvpMGLckY
|
||||
|
||||
YgI5lQmR3nIakU0/3hm8wd+RnXM04Ss+XLe6Bu2gNkNxpPuP9JMZRPdFNdsB
|
||||
|
||||
NgzgpvREUGViRC4zITqjeJuKUaY4eM8un3k7f2Fqh0XD9QZ29KU='
|
||||
181
front-api/node_modules/Backbone.Mutators/Gruntfile.js
generated
vendored
Normal file
181
front-api/node_modules/Backbone.Mutators/Gruntfile.js
generated
vendored
Normal file
@@ -0,0 +1,181 @@
|
||||
/*global module:false*/
|
||||
module.exports = function(grunt) {
|
||||
|
||||
// Project configuration.
|
||||
grunt.initConfig({
|
||||
pkg: grunt.file.readJSON('package.json'),
|
||||
|
||||
jshint: {
|
||||
options: {
|
||||
jshintrc:'.jshintrc'
|
||||
},
|
||||
all: ['Gruntfile.js', 'src/*.js', 'test/*.js']
|
||||
},
|
||||
|
||||
qunit: {
|
||||
options: {
|
||||
'--web-security':'no',
|
||||
timeout: 40000,
|
||||
coverage: {
|
||||
src: ['src/*.js'],
|
||||
instrumentedFiles: 'temp',
|
||||
htmlReport: 'report/coverage'
|
||||
}
|
||||
},
|
||||
all: ['test/index.html']
|
||||
},
|
||||
|
||||
complexity: {
|
||||
generic: {
|
||||
src: ['src/*.js'],
|
||||
options: {
|
||||
errorsOnly: false,
|
||||
cyclomatic: 8,
|
||||
halstead: 31,
|
||||
maintainability: 100
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
plato: {
|
||||
bc: {
|
||||
src: ['src/backbone.mutators.js'],
|
||||
dest: 'docs/complexity',
|
||||
options: {
|
||||
jshint : grunt.file.readJSON('.jshintrc')
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
'saucelabs-qunit': {
|
||||
all: {
|
||||
options: {
|
||||
username: 'asciidisco',
|
||||
urls: ['http://rawgithub.com/asciidisco/Backbone.Mutators/master/test/index_sauce.html'],
|
||||
tunnelTimeout: 100000,
|
||||
testTimeout: 100000,
|
||||
testname: 'Backbone.Mutators',
|
||||
tags: ['backbone', 'plugin', 'mutators', 'unittest'],
|
||||
build: process.env.TRAVIS_JOB_ID,
|
||||
browsers: [ {
|
||||
browserName: 'internet explorer',
|
||||
platform: 'XP',
|
||||
version: '6'
|
||||
}, {
|
||||
browserName: 'internet explorer',
|
||||
platform: 'XP',
|
||||
version: '7'
|
||||
}, {
|
||||
browserName: 'internet explorer',
|
||||
platform: 'Windows 7',
|
||||
version: '8'
|
||||
}, {
|
||||
browserName: 'internet explorer',
|
||||
platform: 'Windows 7',
|
||||
version: '9'
|
||||
}, {
|
||||
browserName: 'firefox',
|
||||
platform: 'Windows 7',
|
||||
version: '21'
|
||||
}, {
|
||||
browserName: 'chrome',
|
||||
platform: 'Windows 7'
|
||||
}, {
|
||||
browserName: 'opera',
|
||||
platform: 'Windows 2008',
|
||||
version: '12'
|
||||
}]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
nodeunit: {
|
||||
all: ['test/*node_test.js']
|
||||
},
|
||||
|
||||
concat: {
|
||||
options: {
|
||||
stripBanners: true,
|
||||
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %>\n' +
|
||||
'------------------------------\n' +
|
||||
'Build @ <%= grunt.template.today("yyyy-mm-dd") %>\n' +
|
||||
'Documentation and Full License Available at:\n' +
|
||||
'<%= pkg.homepage %>\n' +
|
||||
'<%= pkg.repository.url %>\n' +
|
||||
'Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %>\n\n' +
|
||||
'Permission is hereby granted, free of charge, to any person obtaining a\n' +
|
||||
'copy of this software and associated documentation files (the "Software"),\n' +
|
||||
'to deal in the Software without restriction, including without limitation\n' +
|
||||
'the rights to use, copy, modify, merge, publish, distribute, sublicense,\n' +
|
||||
'and/or sell copies of the Software, and to permit persons to whom the\n\n' +
|
||||
'Software is furnished to do so, subject to the following conditions:\n' +
|
||||
'The above copyright notice and this permission notice shall be included in\n' +
|
||||
'all copies or substantial portions of the Software.\n\n' +
|
||||
'THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\n' +
|
||||
'EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n' +
|
||||
'FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n' +
|
||||
'IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n' +
|
||||
'DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\n' +
|
||||
'ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n' +
|
||||
'IN THE SOFTWARE.*/\n'
|
||||
},
|
||||
dist: {
|
||||
src: ['src/<%= pkg.name.toLowerCase() %>.js'],
|
||||
dest: '<%= pkg.name.toLowerCase() %>.js'
|
||||
}
|
||||
},
|
||||
|
||||
uglify: {
|
||||
options: {
|
||||
banner: '<%= concat.options.banner %>'
|
||||
},
|
||||
dist: {
|
||||
files: {
|
||||
'<%= pkg.name.toLowerCase() %>.min.js': ['<%= pkg.name.toLowerCase() %>.js']
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
docco: {
|
||||
debug: {
|
||||
src: ['src/*.js'],
|
||||
options: {
|
||||
output: 'docs/literal'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
yuidoc: {
|
||||
compile: {
|
||||
name: '<%= pkg.name %>',
|
||||
description: '<%= pkg.description %>',
|
||||
version: '<%= pkg.version %>',
|
||||
options: {
|
||||
linkNatives: true,
|
||||
selleck: true,
|
||||
paths: 'src/',
|
||||
outdir: 'docs/api'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Load 3rd party tasks
|
||||
grunt.loadNpmTasks('grunt-contrib-concat');
|
||||
grunt.loadNpmTasks('grunt-contrib-jshint');
|
||||
grunt.loadNpmTasks('grunt-qunit-istanbul');
|
||||
grunt.loadNpmTasks('grunt-contrib-uglify');
|
||||
grunt.loadNpmTasks('grunt-contrib-nodeunit');
|
||||
grunt.loadNpmTasks('grunt-contrib-yuidoc');
|
||||
grunt.loadNpmTasks('grunt-saucelabs');
|
||||
grunt.loadNpmTasks('grunt-complexity');
|
||||
grunt.loadNpmTasks('grunt-docco');
|
||||
grunt.loadNpmTasks('grunt-plato');
|
||||
|
||||
// Default task.
|
||||
grunt.registerTask('default', ['jshint', 'complexity', 'qunit', 'nodeunit', 'concat', 'uglify']);
|
||||
grunt.registerTask('travis', ['jshint', 'complexity', 'qunit']);
|
||||
|
||||
|
||||
};
|
||||
393
front-api/node_modules/Backbone.Mutators/README.md
generated
vendored
Normal file
393
front-api/node_modules/Backbone.Mutators/README.md
generated
vendored
Normal file
@@ -0,0 +1,393 @@
|
||||
## Backbone.Mutators
|
||||
Backbone plugin to override getters and setters with logic
|
||||
|
||||
## Build Status, Project Page, Annotated Source & Tests
|
||||
[](http://travis-ci.org/asciidisco/Backbone.Mutators)
|
||||
[](https://saucelabs.com/u/asciidisco)<br /><br />
|
||||
[Project Page](http://asciidisco.github.com/Backbone.Mutators/index.html)<br />
|
||||
[Docs](http://asciidisco.github.com/Backbone.Mutators/docs/backbone.mutators.html)<br />
|
||||
[Tests](http://asciidisco.github.com/Backbone.Mutators/test/index.html)<br />
|
||||
[NPM registry](http://search.npmjs.org/#/Backbone.Mutators)
|
||||
|
||||
## Introduction
|
||||
Ever wanted Backbone to have getters and setters you can override with your own logic?
|
||||
Yes?! Then Backbone.Mutators is the missing tool in your chain...
|
||||
|
||||
## Installation
|
||||
|
||||
The plugin itself implements the Universal Module Definition (UMD).
|
||||
You can use it with a CommonJS like loader, or with an AMD loader or via
|
||||
vanilla javascript.
|
||||
|
||||
The plugin has two dependencies, underscore.js and backbone.js
|
||||
|
||||
### Download
|
||||
You can directly download the
|
||||
[Development Version](https://raw.github.com/asciidisco/Backbone.Mutators/master/backbone.mutators.js)
|
||||
or the
|
||||
[Production Version](https://raw.github.com/asciidisco/Backbone.Mutators/master/backbone.mutators.min.js)
|
||||
from the root folder
|
||||
|
||||
### VOLO
|
||||
```shell
|
||||
$ volo add Backbone.Mutators
|
||||
```
|
||||
|
||||
### NPM
|
||||
```shell
|
||||
$ npm install Backbone.Mutators
|
||||
```
|
||||
|
||||
## Integration
|
||||
|
||||
### AMD
|
||||
```javascript
|
||||
// AMD
|
||||
require(['underscore', 'backbone', 'path/to/backbone.mutators'], function (_, Backbone, Mutators) {
|
||||
/* Do stuff with Backbone here */
|
||||
});
|
||||
```
|
||||
|
||||
### CommonJS
|
||||
```javascript
|
||||
// CommonJS
|
||||
var _ = require('underscore');
|
||||
var Backbone = require('backbone');
|
||||
var Mutators = require('backbone.mutators');
|
||||
```
|
||||
|
||||
### Vanilla JS
|
||||
```html
|
||||
<!-- Vanilla javascript -->
|
||||
<script src="path/to/underscore.js"></script>
|
||||
<script src="path/to/backbone.js"></script>
|
||||
<script src="path/to/backbone.mutators.js"></script>
|
||||
<script>
|
||||
console.log(Backbone.Mutators); // Backbone and the Mutators property are globals
|
||||
</script>
|
||||
```
|
||||
|
||||
## Usage
|
||||
Some lines of code explain more then thousand words...
|
||||
|
||||
### Basic usage
|
||||
```javascript
|
||||
var User = Backbone.Model.extend({
|
||||
// Define mutator properties
|
||||
mutators: {
|
||||
fullname: function () {
|
||||
return this.get('firstname') + ' ' + this.get('lastname');
|
||||
}
|
||||
},
|
||||
defaults: {
|
||||
firstname: 'Sugar',
|
||||
lastname: 'Daddy'
|
||||
}
|
||||
});
|
||||
|
||||
var user = new User();
|
||||
// use get to get the 'mutated' value
|
||||
user.get('fullname') // 'Sugar Daddy'
|
||||
// serialize the model and see the 'mutated' value in the resulting JSON
|
||||
user.toJSON() // '{firstname: 'Sugar', lastname: 'Daddy', fullname: 'Sugar Daddy'}'
|
||||
```
|
||||
|
||||
### Override getters
|
||||
```javascript
|
||||
var State = Backbone.Model.extend({
|
||||
// Define mutator properties
|
||||
mutators: {
|
||||
status: function () {
|
||||
return this.get('status') === true ? 'Workish' : 'Bad bad error';
|
||||
}
|
||||
},
|
||||
defaults: {
|
||||
status: true
|
||||
}
|
||||
});
|
||||
|
||||
var state = new State();
|
||||
// use get to get the 'mutated' value
|
||||
state.get('status') // 'Workish'
|
||||
// serialize the model and see the 'mutated' value in the resulting JSON
|
||||
state.toJSON() // '{status: 'Workish'}'
|
||||
```
|
||||
|
||||
### Use setters
|
||||
```javascript
|
||||
var User = Backbone.Model.extend({
|
||||
// Define mutator properties
|
||||
mutators: {
|
||||
fullname: {
|
||||
set: function (key, value, options, set) {
|
||||
var names = value.split(' ');
|
||||
this.set('firstname', names[0], options);
|
||||
this.set('lastname', names[1], options);
|
||||
},
|
||||
get: function () {
|
||||
return this.get('firstname') + ' ' + this.get('lastname');
|
||||
}
|
||||
}
|
||||
},
|
||||
defaults: {
|
||||
firstname: 'Sugar',
|
||||
lastname: 'Daddy'
|
||||
}
|
||||
});
|
||||
|
||||
var user = new User();
|
||||
// use get to get the 'mutated' value
|
||||
user.set('fullname', 'Big Mama', {silent: true});
|
||||
// serialize the model and see the 'mutated' value in the resulting JSON
|
||||
user.get('fullname') // 'Big Mama'
|
||||
user.get('firstname'); // 'Big'
|
||||
user.get('lastname'); // 'Mama'
|
||||
```
|
||||
|
||||
### Catch model events
|
||||
```javascript
|
||||
var User = Backbone.Model.extend({
|
||||
// Define mutator properties
|
||||
mutators: {
|
||||
fullname: {
|
||||
set: function (key, value, options, set) {
|
||||
var names = value.split(' ');
|
||||
this.set('firstname', names[0], options);
|
||||
this.set('lastname', names[1], options);
|
||||
},
|
||||
get: function () {
|
||||
return this.get('firstname') + ' ' + this.get('lastname');
|
||||
}
|
||||
}
|
||||
},
|
||||
defaults: {
|
||||
firstname: 'Sugar',
|
||||
lastname: 'Daddy'
|
||||
}
|
||||
});
|
||||
|
||||
var user = new User();
|
||||
|
||||
// bind mutator event
|
||||
user.bind('mutators:set:fullname', function () {
|
||||
console.log('Somebody sets a full name');
|
||||
});
|
||||
|
||||
// bind model events
|
||||
user.bind('change:firstname', function () {
|
||||
console.log('Somebody changed the first name');
|
||||
});
|
||||
|
||||
// bind model events
|
||||
user.bind('change:lastname', function () {
|
||||
console.log('Somebody changed the last name');
|
||||
});
|
||||
|
||||
// use get to get the 'mutated' value
|
||||
user.set('fullname', 'Big Mama');
|
||||
|
||||
// serialize the model and see the 'mutated' value in the resulting JSON
|
||||
user.get('fullname') // 'Big Mama'
|
||||
user.get('firstname'); // 'Big'
|
||||
user.get('lastname'); // 'Mama'
|
||||
```
|
||||
|
||||
### Silence mutator events (while keeping the model events fired)
|
||||
```javascript
|
||||
var User = Backbone.Model.extend({
|
||||
// Define mutator properties
|
||||
mutators: {
|
||||
fullname: {
|
||||
set: function (key, value, options, set) {
|
||||
var names = value.split(' ');
|
||||
this.set('firstname', names[0], options);
|
||||
this.set('lastname', names[1], options);
|
||||
},
|
||||
get: function () {
|
||||
return this.get('firstname') + ' ' + this.get('lastname');
|
||||
}
|
||||
}
|
||||
},
|
||||
defaults: {
|
||||
firstname: 'Sugar',
|
||||
lastname: 'Daddy'
|
||||
}
|
||||
});
|
||||
|
||||
var user = new User();
|
||||
|
||||
// bind mutator event
|
||||
// will never be run
|
||||
user.bind('mutators:set:fullname', function () {
|
||||
console.log('Somebody sets a full name');
|
||||
});
|
||||
|
||||
// bind model events
|
||||
// will still run
|
||||
user.bind('change:firstname', function () {
|
||||
console.log('Somebody changed the first name');
|
||||
});
|
||||
|
||||
// bind model events
|
||||
// will still run
|
||||
user.bind('change:lastname', function () {
|
||||
console.log('Somebody changed the last name');
|
||||
});
|
||||
|
||||
// use get to get the 'mutated' value
|
||||
user.set('fullname', 'Big Mama', {mutators: {silence: true}});
|
||||
|
||||
// serialize the model and see the 'mutated' value in the resulting JSON
|
||||
user.get('fullname') // 'Big Mama'
|
||||
user.get('firstname'); // 'Big'
|
||||
user.get('lastname'); // 'Mama'
|
||||
```
|
||||
|
||||
### Use mutated setters and call the original setter within
|
||||
```javascript
|
||||
var Spicy = Backbone.Model.extend({
|
||||
// Define mutator properties
|
||||
mutators: {
|
||||
iAcceptOnlyLowercaseStuff: {
|
||||
set: function (key, value, options, set) {
|
||||
// call the original setter with the lowercased value
|
||||
set(key, value.toLowerCase(), options);
|
||||
}
|
||||
}
|
||||
},
|
||||
defaults: {
|
||||
iAcceptOnlyLowercaseStuff: 'sugar'
|
||||
}
|
||||
});
|
||||
|
||||
var spicy = new Spicy();
|
||||
// use get to get the 'mutated' value
|
||||
spicy.set('iAcceptOnlyLowercaseStuff', 'SALT');
|
||||
spicy.get('iAcceptOnlyLowercaseStuff') // 'salt'
|
||||
```
|
||||
|
||||
### Define one getter / setter method
|
||||
```javascript
|
||||
var User = Backbone.Model.extend({
|
||||
// Define mutator properties
|
||||
mutators: {
|
||||
fullname: function (key, value, options, set) {
|
||||
if(key){
|
||||
var names = value.split(' ');
|
||||
this.set('firstname', names[0], options);
|
||||
this.set('lastname', names[1], options);
|
||||
}
|
||||
|
||||
return this.get('firstname') + ' ' + this.get('lastname');
|
||||
}
|
||||
},
|
||||
defaults: {
|
||||
firstname: 'Sugar',
|
||||
lastname: 'Daddy'
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### Define multiple mutators
|
||||
```javascript
|
||||
var User = Backbone.Model.extend({
|
||||
// Define mutator properties
|
||||
mutators: {
|
||||
fullname: {
|
||||
set: function (key, value, options, set) {
|
||||
var names = value.split(' ');
|
||||
this.set('firstname', names[0], options);
|
||||
this.set('lastname', names[1], options);
|
||||
}
|
||||
get: function () {
|
||||
return this.get('firstname') + ' ' + this.get('lastname');
|
||||
}
|
||||
},
|
||||
password: function () {
|
||||
return md5(this.password);
|
||||
}
|
||||
},
|
||||
defaults: {
|
||||
firstname: 'Sugar',
|
||||
lastname: 'Daddy'
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### Define a getter as transient
|
||||
Defining a getter as transient means that it will be omitted when Backbone saves the model. This is
|
||||
useful if the backend system (whatever Backbone is syncing to) fails if you send it a property that does
|
||||
not actually exist on the model. Note that this only works for mutators defined with a `get()`
|
||||
function.
|
||||
|
||||
In the example below, the `fullName` property will be available when toJSON is called under
|
||||
non-syncing circumstances--for example, when providing this model to a template--but will be omitted
|
||||
from the JSON when sync is called (because you called the `sync()` or `save()` method), and will not
|
||||
be sent to the server.
|
||||
```javascript
|
||||
var Model = Backbone.Model.extend({
|
||||
defaults:{
|
||||
firstName:"Iain",
|
||||
middleInit:"M",
|
||||
lastName:"Banks"
|
||||
},
|
||||
mutators:{
|
||||
fullName:{
|
||||
get: function() {
|
||||
var fullName = this.get("firstName");
|
||||
fullName += " " + this.get("middleInit");
|
||||
fullName += ". " + this.get("lastName");
|
||||
return fullName;
|
||||
},
|
||||
transient: true
|
||||
}
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
## Further reading
|
||||
James Brown ([@ibjhb](https://github.com/ibjhb/Exploring-Backbone.Mutators))
|
||||
has written a blog article about Mutators ([Exploring Backbone.Mutators](http://ja.mesbrown.com/2012/03/exploring-backbone-mutators-plugin/))
|
||||
|
||||
## Changelog
|
||||
|
||||
### 0.4.4
|
||||
+ Add mutator dependancies and change events [#33](https://github.com/asciidisco/Backbone.Mutators/commit/7c7626456991dd4de5419e7a5a0bd3e62090297f)
|
||||
|
||||
### 0.4.3
|
||||
+ Made compatible with browserify [#32](https://github.com/asciidisco/Backbone.Mutators/commit/0d7f846727ae9b546bba203d4c4b7c2ff5704222)
|
||||
+ Backbone dependency version bump [#32](https://github.com/asciidisco/Backbone.Mutators/commit/5c0db12e34aaa5f0fac39b76a9bf8c44e1bea641)
|
||||
|
||||
### 0.4.2
|
||||
+ Fixes [#20](https://github.com/asciidisco/Backbone.Mutators/issues/20)
|
||||
|
||||
### 0.4.1
|
||||
+ Fixes [#22](https://github.com/asciidisco/Backbone.Mutators/pull/22)
|
||||
+ Fixes [#24](https://github.com/asciidisco/Backbone.Mutators/pull/24)
|
||||
|
||||
### 0.3.1
|
||||
+ Change get context to modal instead of attributes
|
||||
+ Added single getter / setter method
|
||||
|
||||
### 0.3.1
|
||||
+ Change get context to modal instead of attributes
|
||||
+ Added single getter / setter method
|
||||
|
||||
### 0.3.0
|
||||
+ Removed the Cake based build process and moved to grunt
|
||||
+ Mutators now integrates itself to backbone, no more manual extending needed
|
||||
+ Added the {mutator: {silent: true}} option to prevent mutator set events from firering
|
||||
+ Added unit tests for the new features
|
||||
+ Moved from jslint to jshint
|
||||
+ Tweaked docs
|
||||
+ Removed not needed jquery and qunit-logging submodule / npm dependencies
|
||||
|
||||
### 0.2.0
|
||||
+ Added the original Backbone.Model.set function as a fourth paramter for the mutated set
|
||||
+ Added a 'mutators:set:{{YOUR_MUTATOR_PROPERTY}}' event when setting mutated properties
|
||||
+ Added unit tests for the new features
|
||||
+ Extended/fixed documentation
|
||||
+ Added inline version tag [NOTE: Version 0.2.0 is fully backwards compatible]
|
||||
|
||||
### 0.1.0
|
||||
+ Initial Release
|
||||
207
front-api/node_modules/Backbone.Mutators/backbone.mutators.js
generated
vendored
Normal file
207
front-api/node_modules/Backbone.Mutators/backbone.mutators.js
generated
vendored
Normal file
@@ -0,0 +1,207 @@
|
||||
/*! Backbone.Mutators - v0.4.4
|
||||
------------------------------
|
||||
Build @ 2014-12-02
|
||||
Documentation and Full License Available at:
|
||||
http://asciidisco.github.com/Backbone.Mutators/index.html
|
||||
git://github.com/asciidisco/Backbone.Mutators.git
|
||||
Copyright (c) 2014 Sebastian Golasch <public@asciidisco.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 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 (root, factory, undef) {
|
||||
'use strict';
|
||||
|
||||
if (typeof exports === 'object') {
|
||||
// Node. Does not work with strict CommonJS, but
|
||||
// only CommonJS-like enviroments that support module.exports,
|
||||
// like Node.
|
||||
module.exports = factory(require('underscore'), require('backbone'));
|
||||
} else if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define(['underscore', 'backbone'], function (_, Backbone) {
|
||||
// Check if we use the AMD branch of Back
|
||||
_ = _ === undef ? root._ : _;
|
||||
Backbone = Backbone === undef ? root.Backbone : Backbone;
|
||||
return (root.returnExportsGlobal = factory(_, Backbone, root));
|
||||
});
|
||||
} else {
|
||||
// Browser globals
|
||||
root.returnExportsGlobal = factory(root._, root.Backbone);
|
||||
}
|
||||
|
||||
// Usage:
|
||||
//
|
||||
// Note: This plugin is UMD compatible, you can use it in node, amd and vanilla js envs
|
||||
//
|
||||
// Vanilla JS:
|
||||
// <script src="underscore.js"></script>
|
||||
// <script src="backbone.js"></script>
|
||||
// <script src="backbone.mutators.js"></script>
|
||||
//
|
||||
// Node:
|
||||
// var _ = require('underscore');
|
||||
// var Backbone = require('backbone');
|
||||
// var Mutators = require('backbone.mutators');
|
||||
//
|
||||
//
|
||||
// AMD:
|
||||
// define(['underscore', 'backbone', 'backbone.mutators'], function (_, Backbone, Mutators) {
|
||||
// // insert sample from below
|
||||
// return User;
|
||||
// });
|
||||
//
|
||||
// var User = Backbone.Model.extend({
|
||||
// mutators: {
|
||||
// fullname: function () {
|
||||
// return this.firstname + ' ' + this.lastname;
|
||||
// }
|
||||
// },
|
||||
//
|
||||
// defaults: {
|
||||
// firstname: 'Sebastian',
|
||||
// lastname: 'Golasch'
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// var user = new User();
|
||||
// user.get('fullname') // returns 'Sebastian Golasch'
|
||||
// user.toJSON() // return '{firstname: 'Sebastian', lastname: 'Golasch', fullname: 'Sebastian Golasch'}'
|
||||
|
||||
}(this, function (_, Backbone, root, undef) {
|
||||
'use strict';
|
||||
|
||||
// check if we use the amd branch of backbone and underscore
|
||||
Backbone = Backbone === undef ? root.Backbone : Backbone;
|
||||
_ = _ === undef ? root._ : _;
|
||||
|
||||
// extend backbones model prototype with the mutator functionality
|
||||
var Mutator = function () {},
|
||||
oldGet = Backbone.Model.prototype.get,
|
||||
oldSet = Backbone.Model.prototype.set,
|
||||
oldToJson = Backbone.Model.prototype.toJSON;
|
||||
|
||||
// This is necessary to ensure that Models declared without the mutators object do not throw and error
|
||||
Mutator.prototype.mutators = {};
|
||||
|
||||
// override get functionality to fetch the mutator props
|
||||
Mutator.prototype.get = function (attr) {
|
||||
var isMutator = this.mutators !== undef;
|
||||
|
||||
// check if we have a getter mutation
|
||||
if (isMutator === true && _.isFunction(this.mutators[attr]) === true) {
|
||||
return this.mutators[attr].call(this);
|
||||
}
|
||||
|
||||
// check if we have a deeper nested getter mutation
|
||||
if (isMutator === true && _.isObject(this.mutators[attr]) === true && _.isFunction(this.mutators[attr].get) === true) {
|
||||
return this.mutators[attr].get.call(this);
|
||||
}
|
||||
|
||||
return oldGet.call(this, attr);
|
||||
};
|
||||
|
||||
// override set functionality to set the mutator props
|
||||
Mutator.prototype.set = function (key, value, options) {
|
||||
var isMutator = this.mutators !== undef,
|
||||
ret = null,
|
||||
attrs = null;
|
||||
|
||||
ret = oldSet.call(this, key, value, options);
|
||||
|
||||
// seamleassly stolen from backbone core
|
||||
// check if the setter action is triggered
|
||||
// using key <-> value or object
|
||||
if (_.isObject(key) || key === null) {
|
||||
attrs = key;
|
||||
options = value;
|
||||
} else {
|
||||
attrs = {};
|
||||
attrs[key] = value;
|
||||
}
|
||||
|
||||
// check if we have a deeper nested setter mutation
|
||||
if (isMutator === true && _.isObject(this.mutators[key]) === true) {
|
||||
|
||||
// check if we need to set a single value
|
||||
if (_.isFunction(this.mutators[key].set) === true) {
|
||||
ret = this.mutators[key].set.call(this, key, attrs[key], options, _.bind(oldSet, this));
|
||||
} else if(_.isFunction(this.mutators[key])){
|
||||
ret = this.mutators[key].call(this, key, attrs[key], options, _.bind(oldSet, this));
|
||||
}
|
||||
}
|
||||
|
||||
if (isMutator === true && _.isObject(attrs)) {
|
||||
_.each(attrs, _.bind(function (attr, attrKey) {
|
||||
if (_.isObject(this.mutators[attrKey]) === true) {
|
||||
// check if we need to set a single value
|
||||
|
||||
var meth = this.mutators[attrKey];
|
||||
if(_.isFunction(meth.set)){
|
||||
meth = meth.set;
|
||||
}
|
||||
|
||||
if(_.isFunction(meth)){
|
||||
if (options === undef || (_.isObject(options) === true && options.silent !== true && (options.mutators !== undef && options.mutators.silent !== true))) {
|
||||
this.trigger('mutators:set:' + attrKey);
|
||||
}
|
||||
meth.call(this, attrKey, attr, options, _.bind(oldSet, this));
|
||||
}
|
||||
|
||||
}
|
||||
}, this));
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
// override toJSON functionality to serialize mutator properties
|
||||
Mutator.prototype.toJSON = function (options) {
|
||||
// fetch ye olde values
|
||||
var attr = oldToJson.call(this),
|
||||
isSaving,
|
||||
isTransient;
|
||||
// iterate over all mutators (if there are some)
|
||||
_.each(this.mutators, _.bind(function (mutator, name) {
|
||||
// check if we have some getter mutations
|
||||
if (_.isObject(this.mutators[name]) === true && _.isFunction(this.mutators[name].get)) {
|
||||
isSaving = _.has(options || {}, 'emulateHTTP');
|
||||
isTransient = this.mutators[name].transient;
|
||||
if (!isSaving || !isTransient) {
|
||||
attr[name] = _.bind(this.mutators[name].get, this)();
|
||||
}
|
||||
} else if (_.isFunction(this.mutators[name])) {
|
||||
attr[name] = _.bind(this.mutators[name], this)();
|
||||
}
|
||||
}, this));
|
||||
|
||||
return attr;
|
||||
};
|
||||
|
||||
// override get functionality to get HTML-escaped the mutator props
|
||||
Mutator.prototype.escape = function (attr){
|
||||
var val = this.get(attr);
|
||||
return _.escape(val == null ? '' : '' + val);
|
||||
};
|
||||
|
||||
// extend the models prototype
|
||||
_.extend(Backbone.Model.prototype, Mutator.prototype);
|
||||
|
||||
// make mutators globally available under the Backbone namespace
|
||||
Backbone.Mutators = Mutator;
|
||||
return Mutator;
|
||||
}));
|
||||
26
front-api/node_modules/Backbone.Mutators/backbone.mutators.min.js
generated
vendored
Normal file
26
front-api/node_modules/Backbone.Mutators/backbone.mutators.min.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
/*! Backbone.Mutators - v0.4.4
|
||||
------------------------------
|
||||
Build @ 2014-12-02
|
||||
Documentation and Full License Available at:
|
||||
http://asciidisco.github.com/Backbone.Mutators/index.html
|
||||
git://github.com/asciidisco/Backbone.Mutators.git
|
||||
Copyright (c) 2014 Sebastian Golasch <public@asciidisco.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 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(a,b,c){"use strict";"object"==typeof exports?module.exports=b(require("underscore"),require("backbone")):"function"==typeof define&&define.amd?define(["underscore","backbone"],function(d,e){return d=d===c?a._:d,e=e===c?a.Backbone:e,a.returnExportsGlobal=b(d,e,a)}):a.returnExportsGlobal=b(a._,a.Backbone)}(this,function(a,b,c,d){"use strict";b=b===d?c.Backbone:b,a=a===d?c._:a;var e=function(){},f=b.Model.prototype.get,g=b.Model.prototype.set,h=b.Model.prototype.toJSON;return e.prototype.mutators={},e.prototype.get=function(b){var c=this.mutators!==d;return c===!0&&a.isFunction(this.mutators[b])===!0?this.mutators[b].call(this):c===!0&&a.isObject(this.mutators[b])===!0&&a.isFunction(this.mutators[b].get)===!0?this.mutators[b].get.call(this):f.call(this,b)},e.prototype.set=function(b,c,e){var f=this.mutators!==d,h=null,i=null;return h=g.call(this,b,c,e),a.isObject(b)||null===b?(i=b,e=c):(i={},i[b]=c),f===!0&&a.isObject(this.mutators[b])===!0&&(a.isFunction(this.mutators[b].set)===!0?h=this.mutators[b].set.call(this,b,i[b],e,a.bind(g,this)):a.isFunction(this.mutators[b])&&(h=this.mutators[b].call(this,b,i[b],e,a.bind(g,this)))),f===!0&&a.isObject(i)&&a.each(i,a.bind(function(b,c){if(a.isObject(this.mutators[c])===!0){var f=this.mutators[c];a.isFunction(f.set)&&(f=f.set),a.isFunction(f)&&((e===d||a.isObject(e)===!0&&e.silent!==!0&&e.mutators!==d&&e.mutators.silent!==!0)&&this.trigger("mutators:set:"+c),f.call(this,c,b,e,a.bind(g,this)))}},this)),h},e.prototype.toJSON=function(b){var c,d,e=h.call(this);return a.each(this.mutators,a.bind(function(f,g){a.isObject(this.mutators[g])===!0&&a.isFunction(this.mutators[g].get)?(c=a.has(b||{},"emulateHTTP"),d=this.mutators[g].transient,c&&d||(e[g]=a.bind(this.mutators[g].get,this)())):a.isFunction(this.mutators[g])&&(e[g]=a.bind(this.mutators[g],this)())},this)),e},e.prototype.escape=function(b){var c=this.get(b);return a.escape(null==c?"":""+c)},a.extend(b.Model.prototype,e.prototype),b.Mutators=e,e});
|
||||
9
front-api/node_modules/Backbone.Mutators/bower.json
generated
vendored
Normal file
9
front-api/node_modules/Backbone.Mutators/bower.json
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "Backbone.Mutators",
|
||||
"version": "0.4.4",
|
||||
"main": "backbone.mutators.js",
|
||||
"dependencies": {
|
||||
"underscore": ">=1.4.4",
|
||||
"backbone": ">=1.0.0"
|
||||
}
|
||||
}
|
||||
28
front-api/node_modules/Backbone.Mutators/bower_components/backbone/.bower.json
generated
vendored
Normal file
28
front-api/node_modules/Backbone.Mutators/bower_components/backbone/.bower.json
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "backbone",
|
||||
"version": "1.1.2",
|
||||
"main": "backbone.js",
|
||||
"dependencies": {
|
||||
"underscore": ">=1.5.0"
|
||||
},
|
||||
"ignore": [
|
||||
"backbone-min.js",
|
||||
"docs",
|
||||
"examples",
|
||||
"test",
|
||||
"*.yml",
|
||||
"*.map",
|
||||
".html",
|
||||
"*.ico"
|
||||
],
|
||||
"homepage": "https://github.com/jashkenas/backbone",
|
||||
"_release": "1.1.2",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "1.1.2",
|
||||
"commit": "53f77901a4ea9c7cf75d3db93ddddf491998d90f"
|
||||
},
|
||||
"_source": "git://github.com/jashkenas/backbone.git",
|
||||
"_target": ">=1.0.0",
|
||||
"_originalSource": "backbone"
|
||||
}
|
||||
7
front-api/node_modules/Backbone.Mutators/bower_components/backbone/.npmignore
generated
vendored
Normal file
7
front-api/node_modules/Backbone.Mutators/bower_components/backbone/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
test/
|
||||
Rakefile
|
||||
docs/
|
||||
raw/
|
||||
examples/
|
||||
index.html
|
||||
.jshintrc
|
||||
2
front-api/node_modules/Backbone.Mutators/bower_components/backbone/CNAME
generated
vendored
Normal file
2
front-api/node_modules/Backbone.Mutators/bower_components/backbone/CNAME
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
backbonejs.org
|
||||
|
||||
22
front-api/node_modules/Backbone.Mutators/bower_components/backbone/CONTRIBUTING.md
generated
vendored
Normal file
22
front-api/node_modules/Backbone.Mutators/bower_components/backbone/CONTRIBUTING.md
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
## How to Open a Backbone.js Ticket
|
||||
|
||||
* Do not use tickets to ask for help with (debugging) your application. Ask on
|
||||
the [mailing list](https://groups.google.com/forum/#!forum/backbonejs),
|
||||
in the IRC channel (`#documentcloud` on Freenode), or if you understand your
|
||||
specific problem, on [StackOverflow](http://stackoverflow.com/questions/tagged/backbone.js).
|
||||
|
||||
* Before you open a ticket or send a pull request,
|
||||
[search](https://github.com/jashkenas/backbone/issues) for previous
|
||||
discussions about the same feature or issue. Add to the earlier ticket if you
|
||||
find one.
|
||||
|
||||
* Before sending a pull request for a feature or bug fix, be sure to have
|
||||
[tests](http://backbonejs.org/test/).
|
||||
|
||||
* Use the same coding style as the rest of the
|
||||
[codebase](https://github.com/jashkenas/backbone/blob/master/backbone.js).
|
||||
|
||||
* In your pull request, do not add documentation or rebuild the minified
|
||||
`backbone-min.js` file. We'll do that before cutting a new release.
|
||||
|
||||
* All pull requests should be made to the `master` branch.
|
||||
22
front-api/node_modules/Backbone.Mutators/bower_components/backbone/LICENSE
generated
vendored
Normal file
22
front-api/node_modules/Backbone.Mutators/bower_components/backbone/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
Copyright (c) 2010-2014 Jeremy Ashkenas, DocumentCloud
|
||||
|
||||
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.
|
||||
29
front-api/node_modules/Backbone.Mutators/bower_components/backbone/README.md
generated
vendored
Normal file
29
front-api/node_modules/Backbone.Mutators/bower_components/backbone/README.md
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
____ __ __
|
||||
/\ _`\ /\ \ /\ \ __
|
||||
\ \ \ \ \ __ ___\ \ \/'\\ \ \____ ___ ___ __ /\_\ ____
|
||||
\ \ _ <' /'__`\ /'___\ \ , < \ \ '__`\ / __`\ /' _ `\ /'__`\ \/\ \ /',__\
|
||||
\ \ \ \ \/\ \ \.\_/\ \__/\ \ \\`\\ \ \ \ \/\ \ \ \/\ \/\ \/\ __/ __ \ \ \/\__, `\
|
||||
\ \____/\ \__/.\_\ \____\\ \_\ \_\ \_,__/\ \____/\ \_\ \_\ \____\/\_\_\ \ \/\____/
|
||||
\/___/ \/__/\/_/\/____/ \/_/\/_/\/___/ \/___/ \/_/\/_/\/____/\/_/\ \_\ \/___/
|
||||
\ \____/
|
||||
\/___/
|
||||
(_'_______________________________________________________________________________'_)
|
||||
(_.———————————————————————————————————————————————————————————————————————————————._)
|
||||
|
||||
|
||||
Backbone supplies structure to JavaScript-heavy applications by providing models key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing application over a RESTful JSON interface.
|
||||
|
||||
For Docs, License, Tests, pre-packed downloads, and everything else, really, see:
|
||||
http://backbonejs.org
|
||||
|
||||
To suggest a feature, report a bug, or general discussion:
|
||||
http://github.com/jashkenas/backbone/issues
|
||||
|
||||
Backbone is an open-sourced component of DocumentCloud:
|
||||
https://github.com/documentcloud
|
||||
|
||||
Many thanks to our contributors:
|
||||
http://github.com/jashkenas/backbone/contributors
|
||||
|
||||
Special thanks to Robert Kieffer for the original philosophy behind Backbone.
|
||||
http://github.com/broofa
|
||||
1608
front-api/node_modules/Backbone.Mutators/bower_components/backbone/backbone.js
generated
vendored
Normal file
1608
front-api/node_modules/Backbone.Mutators/bower_components/backbone/backbone.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
9
front-api/node_modules/Backbone.Mutators/bower_components/backbone/bower.json
generated
vendored
Normal file
9
front-api/node_modules/Backbone.Mutators/bower_components/backbone/bower.json
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"name" : "backbone",
|
||||
"version" : "1.1.2",
|
||||
"main" : "backbone.js",
|
||||
"dependencies" : {
|
||||
"underscore" : ">=1.5.0"
|
||||
},
|
||||
"ignore" : ["backbone-min.js", "docs", "examples", "test", "*.yml", "*.map", ".html", "*.ico"]
|
||||
}
|
||||
13
front-api/node_modules/Backbone.Mutators/bower_components/backbone/component.json
generated
vendored
Normal file
13
front-api/node_modules/Backbone.Mutators/bower_components/backbone/component.json
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"name" : "backbone",
|
||||
"version" : "1.1.2",
|
||||
"description" : "Give your JS App some Backbone with Models, Views, Collections, and Events.",
|
||||
"keywords" : ["model", "view", "controller", "router", "server", "client", "browser"],
|
||||
"repo" : "jashkenas/backbone",
|
||||
"dependencies" : {
|
||||
"jashkenas/underscore" : "*"
|
||||
},
|
||||
"main" : "backbone.js",
|
||||
"scripts" : ["backbone.js"],
|
||||
"license" : "MIT"
|
||||
}
|
||||
1
front-api/node_modules/Backbone.Mutators/bower_components/backbone/index.js
generated
vendored
Normal file
1
front-api/node_modules/Backbone.Mutators/bower_components/backbone/index.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('./backbone');
|
||||
28
front-api/node_modules/Backbone.Mutators/bower_components/backbone/package.json
generated
vendored
Normal file
28
front-api/node_modules/Backbone.Mutators/bower_components/backbone/package.json
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"name" : "backbone",
|
||||
"description" : "Give your JS App some Backbone with Models, Views, Collections, and Events.",
|
||||
"url" : "http://backbonejs.org",
|
||||
"keywords" : ["model", "view", "controller", "router", "server", "client", "browser"],
|
||||
"author" : "Jeremy Ashkenas <jeremy@documentcloud.org>",
|
||||
"dependencies" : {
|
||||
"underscore" : ">=1.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"phantomjs": "1.9.0-1",
|
||||
"docco": "0.6.1",
|
||||
"coffee-script": "1.6.1"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "phantomjs test/vendor/runner.js test/index.html?noglobals=true && coffee test/model.coffee",
|
||||
"build": "uglifyjs backbone.js --mangle --source-map backbone-min.map -o backbone-min.js",
|
||||
"doc": "docco backbone.js && docco examples/todos/todos.js examples/backbone.localstorage.js",
|
||||
"lint": "jsl -nofilelisting -nologo -conf docs/jsl.conf -process backbone.js"
|
||||
},
|
||||
"main" : "backbone.js",
|
||||
"version" : "1.1.2",
|
||||
"license" : "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jashkenas/backbone.git"
|
||||
}
|
||||
}
|
||||
23
front-api/node_modules/Backbone.Mutators/bower_components/underscore/LICENSE
generated
vendored
Normal file
23
front-api/node_modules/Backbone.Mutators/bower_components/underscore/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
Copyright (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative
|
||||
Reporters & Editors
|
||||
|
||||
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.
|
||||
22
front-api/node_modules/Backbone.Mutators/bower_components/underscore/README.md
generated
vendored
Normal file
22
front-api/node_modules/Backbone.Mutators/bower_components/underscore/README.md
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
__
|
||||
/\ \ __
|
||||
__ __ ___ \_\ \ __ _ __ ____ ___ ___ _ __ __ /\_\ ____
|
||||
/\ \/\ \ /' _ `\ /'_ \ /'__`\/\ __\/ ,__\ / ___\ / __`\/\ __\/'__`\ \/\ \ /',__\
|
||||
\ \ \_\ \/\ \/\ \/\ \ \ \/\ __/\ \ \//\__, `\/\ \__//\ \ \ \ \ \//\ __/ __ \ \ \/\__, `\
|
||||
\ \____/\ \_\ \_\ \___,_\ \____\\ \_\\/\____/\ \____\ \____/\ \_\\ \____\/\_\ _\ \ \/\____/
|
||||
\/___/ \/_/\/_/\/__,_ /\/____/ \/_/ \/___/ \/____/\/___/ \/_/ \/____/\/_//\ \_\ \/___/
|
||||
\ \____/
|
||||
\/___/
|
||||
|
||||
Underscore.js is a utility-belt library for JavaScript that provides
|
||||
support for the usual functional suspects (each, map, reduce, filter...)
|
||||
without extending any core JavaScript objects.
|
||||
|
||||
For Docs, License, Tests, and pre-packed downloads, see:
|
||||
http://underscorejs.org
|
||||
|
||||
Underscore is an open-sourced component of DocumentCloud:
|
||||
https://github.com/documentcloud
|
||||
|
||||
Many thanks to our contributors:
|
||||
https://github.com/jashkenas/underscore/contributors
|
||||
41
front-api/node_modules/Backbone.Mutators/bower_components/underscore/package.json
generated
vendored
Normal file
41
front-api/node_modules/Backbone.Mutators/bower_components/underscore/package.json
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"name": "underscore",
|
||||
"description": "JavaScript's functional programming helper library.",
|
||||
"homepage": "http://underscorejs.org",
|
||||
"keywords": [
|
||||
"util",
|
||||
"functional",
|
||||
"server",
|
||||
"client",
|
||||
"browser"
|
||||
],
|
||||
"author": "Jeremy Ashkenas <jeremy@documentcloud.org>",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/jashkenas/underscore.git"
|
||||
},
|
||||
"main": "underscore.js",
|
||||
"version": "1.7.0",
|
||||
"devDependencies": {
|
||||
"docco": "0.6.x",
|
||||
"phantomjs": "1.9.7-1",
|
||||
"uglify-js": "2.4.x",
|
||||
"eslint": "0.6.x"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "phantomjs test/vendor/runner.js test/index.html?noglobals=true && eslint underscore.js test/*.js test/vendor/runner.js",
|
||||
"build": "uglifyjs underscore.js -c \"evaluate=false\" --comments \"/ .*/\" -m --source-map underscore-min.map -o underscore-min.js",
|
||||
"doc": "docco underscore.js"
|
||||
},
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "https://raw.github.com/jashkenas/underscore/master/LICENSE"
|
||||
}
|
||||
],
|
||||
"files": [
|
||||
"underscore.js",
|
||||
"underscore-min.js",
|
||||
"LICENSE"
|
||||
]
|
||||
}
|
||||
6
front-api/node_modules/Backbone.Mutators/bower_components/underscore/underscore-min.js
generated
vendored
Normal file
6
front-api/node_modules/Backbone.Mutators/bower_components/underscore/underscore-min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1415
front-api/node_modules/Backbone.Mutators/bower_components/underscore/underscore.js
generated
vendored
Normal file
1415
front-api/node_modules/Backbone.Mutators/bower_components/underscore/underscore.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
4
front-api/node_modules/Backbone.Mutators/node_modules/underscore/.npmignore
generated
vendored
Normal file
4
front-api/node_modules/Backbone.Mutators/node_modules/underscore/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
test/
|
||||
Rakefile
|
||||
docs/
|
||||
raw/
|
||||
5
front-api/node_modules/Backbone.Mutators/node_modules/underscore/.travis.yml
generated
vendored
Normal file
5
front-api/node_modules/Backbone.Mutators/node_modules/underscore/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 0.8
|
||||
notifications:
|
||||
email: false
|
||||
1
front-api/node_modules/Backbone.Mutators/node_modules/underscore/CNAME
generated
vendored
Normal file
1
front-api/node_modules/Backbone.Mutators/node_modules/underscore/CNAME
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
underscorejs.org
|
||||
9
front-api/node_modules/Backbone.Mutators/node_modules/underscore/CONTRIBUTING.md
generated
vendored
Normal file
9
front-api/node_modules/Backbone.Mutators/node_modules/underscore/CONTRIBUTING.md
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
## How to contribute to Underscore.js
|
||||
|
||||
* Before you open a ticket or send a pull request, [search](https://github.com/documentcloud/underscore/issues) for previous discussions about the same feature or issue. Add to the earlier ticket if you find one.
|
||||
|
||||
* Before sending a pull request for a feature, be sure to have [tests](http://underscorejs.org/test/).
|
||||
|
||||
* Use the same coding style as the rest of the [codebase](https://github.com/documentcloud/underscore/blob/master/underscore.js).
|
||||
|
||||
* In your pull request, do not add documentation or re-build the minified `underscore-min.js` file. We'll do those things before cutting a new release.
|
||||
22
front-api/node_modules/Backbone.Mutators/node_modules/underscore/LICENSE
generated
vendored
Normal file
22
front-api/node_modules/Backbone.Mutators/node_modules/underscore/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
Copyright (c) 2009-2013 Jeremy Ashkenas, DocumentCloud
|
||||
|
||||
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.
|
||||
19
front-api/node_modules/Backbone.Mutators/node_modules/underscore/README.md
generated
vendored
Normal file
19
front-api/node_modules/Backbone.Mutators/node_modules/underscore/README.md
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
__
|
||||
/\ \ __
|
||||
__ __ ___ \_\ \ __ _ __ ____ ___ ___ _ __ __ /\_\ ____
|
||||
/\ \/\ \ /' _ `\ /'_ \ /'__`\/\ __\/ ,__\ / ___\ / __`\/\ __\/'__`\ \/\ \ /',__\
|
||||
\ \ \_\ \/\ \/\ \/\ \ \ \/\ __/\ \ \//\__, `\/\ \__//\ \ \ \ \ \//\ __/ __ \ \ \/\__, `\
|
||||
\ \____/\ \_\ \_\ \___,_\ \____\\ \_\\/\____/\ \____\ \____/\ \_\\ \____\/\_\ _\ \ \/\____/
|
||||
\/___/ \/_/\/_/\/__,_ /\/____/ \/_/ \/___/ \/____/\/___/ \/_/ \/____/\/_//\ \_\ \/___/
|
||||
\ \____/
|
||||
\/___/
|
||||
|
||||
Underscore.js is a utility-belt library for JavaScript that provides
|
||||
support for the usual functional suspects (each, map, reduce, filter...)
|
||||
without extending any core JavaScript objects.
|
||||
|
||||
For Docs, License, Tests, and pre-packed downloads, see:
|
||||
http://underscorejs.org
|
||||
|
||||
Many thanks to our contributors:
|
||||
https://github.com/documentcloud/underscore/contributors
|
||||
BIN
front-api/node_modules/Backbone.Mutators/node_modules/underscore/favicon.ico
generated
vendored
Normal file
BIN
front-api/node_modules/Backbone.Mutators/node_modules/underscore/favicon.ico
generated
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
2467
front-api/node_modules/Backbone.Mutators/node_modules/underscore/index.html
generated
vendored
Normal file
2467
front-api/node_modules/Backbone.Mutators/node_modules/underscore/index.html
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
front-api/node_modules/Backbone.Mutators/node_modules/underscore/index.js
generated
vendored
Normal file
1
front-api/node_modules/Backbone.Mutators/node_modules/underscore/index.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('./underscore');
|
||||
52
front-api/node_modules/Backbone.Mutators/node_modules/underscore/package.json
generated
vendored
Normal file
52
front-api/node_modules/Backbone.Mutators/node_modules/underscore/package.json
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"name": "underscore",
|
||||
"description": "JavaScript's functional programming helper library.",
|
||||
"homepage": "http://underscorejs.org",
|
||||
"keywords": [
|
||||
"util",
|
||||
"functional",
|
||||
"server",
|
||||
"client",
|
||||
"browser"
|
||||
],
|
||||
"author": {
|
||||
"name": "Jeremy Ashkenas",
|
||||
"email": "jeremy@documentcloud.org"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/documentcloud/underscore.git"
|
||||
},
|
||||
"main": "underscore.js",
|
||||
"version": "1.4.4",
|
||||
"devDependencies": {
|
||||
"phantomjs": "0.2.2"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "phantomjs test/vendor/runner.js test/index.html?noglobals=true"
|
||||
},
|
||||
"_id": "underscore@1.4.4",
|
||||
"dist": {
|
||||
"shasum": "61a6a32010622afa07963bf325203cf12239d604",
|
||||
"tarball": "http://registry.npmjs.org/underscore/-/underscore-1.4.4.tgz"
|
||||
},
|
||||
"_npmVersion": "1.1.63",
|
||||
"_npmUser": {
|
||||
"name": "jashkenas",
|
||||
"email": "jashkenas@gmail.com"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "jashkenas",
|
||||
"email": "jashkenas@gmail.com"
|
||||
}
|
||||
],
|
||||
"directories": {},
|
||||
"_shasum": "61a6a32010622afa07963bf325203cf12239d604",
|
||||
"_resolved": "https://registry.npmjs.org/underscore/-/underscore-1.4.4.tgz",
|
||||
"_from": "underscore@1.4.4",
|
||||
"bugs": {
|
||||
"url": "https://github.com/documentcloud/underscore/issues"
|
||||
},
|
||||
"readme": "ERROR: No README data found!"
|
||||
}
|
||||
1
front-api/node_modules/Backbone.Mutators/node_modules/underscore/underscore-min.js
generated
vendored
Normal file
1
front-api/node_modules/Backbone.Mutators/node_modules/underscore/underscore-min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1226
front-api/node_modules/Backbone.Mutators/node_modules/underscore/underscore.js
generated
vendored
Normal file
1226
front-api/node_modules/Backbone.Mutators/node_modules/underscore/underscore.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
79
front-api/node_modules/Backbone.Mutators/package.json
generated
vendored
Normal file
79
front-api/node_modules/Backbone.Mutators/package.json
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
{
|
||||
"name": "Backbone.Mutators",
|
||||
"version": "0.4.4",
|
||||
"description": "Backbone plugin to override getters and setters with logic",
|
||||
"homepage": "http://asciidisco.github.com/Backbone.Mutators/index.html",
|
||||
"keywords": [
|
||||
"backbone",
|
||||
"plugin",
|
||||
"mutator",
|
||||
"getter",
|
||||
"setter",
|
||||
"client",
|
||||
"browser"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/asciidisco/Backbone.Mutators.git"
|
||||
},
|
||||
"author": {
|
||||
"name": "Sebastian Golasch",
|
||||
"email": "public@asciidisco.com"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "asciidisco",
|
||||
"email": "public@asciidisco.com"
|
||||
}
|
||||
],
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "http://mit-license.org/"
|
||||
}
|
||||
],
|
||||
"lib": ".",
|
||||
"main": "backbone.mutators.js",
|
||||
"devDependencies": {
|
||||
"backbone": "^1.1.2",
|
||||
"grunt": "~0.4.x",
|
||||
"grunt-complexity": "~0.1.x",
|
||||
"grunt-contrib-concat": "~0.3.x",
|
||||
"grunt-contrib-jshint": "~0.2.x",
|
||||
"grunt-contrib-nodeunit": "~0.1.x",
|
||||
"grunt-contrib-uglify": "~0.2.x",
|
||||
"grunt-contrib-yuidoc": "~0.4.x",
|
||||
"grunt-docco": "~0.2.x",
|
||||
"grunt-plato": "~0.2.x",
|
||||
"grunt-qunit-istanbul": "~0.1.x",
|
||||
"grunt-saucelabs": "~4.0.0",
|
||||
"qunitjs": "~1.11.x",
|
||||
"underscore": "^1.4.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"underscore": "~1.4.x"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"backbone": "~1.x"
|
||||
},
|
||||
"gitHead": "ea71ddb34761578b080b0e1d0be024bac830e56d",
|
||||
"bugs": {
|
||||
"url": "https://github.com/asciidisco/Backbone.Mutators/issues"
|
||||
},
|
||||
"_id": "Backbone.Mutators@0.4.4",
|
||||
"scripts": {},
|
||||
"_shasum": "45a247fdd1603a455be55319cee632d0222a2e98",
|
||||
"_from": "backbone.mutators@*",
|
||||
"_npmVersion": "1.4.14",
|
||||
"_npmUser": {
|
||||
"name": "asciidisco",
|
||||
"email": "public@asciidisco.com"
|
||||
},
|
||||
"dist": {
|
||||
"shasum": "45a247fdd1603a455be55319cee632d0222a2e98",
|
||||
"tarball": "http://registry.npmjs.org/Backbone.Mutators/-/Backbone.Mutators-0.4.4.tgz"
|
||||
},
|
||||
"directories": {},
|
||||
"_resolved": "https://registry.npmjs.org/Backbone.Mutators/-/Backbone.Mutators-0.4.4.tgz",
|
||||
"readme": "ERROR: No README data found!"
|
||||
}
|
||||
182
front-api/node_modules/Backbone.Mutators/src/backbone.mutators.js
generated
vendored
Normal file
182
front-api/node_modules/Backbone.Mutators/src/backbone.mutators.js
generated
vendored
Normal file
@@ -0,0 +1,182 @@
|
||||
(function (root, factory, undef) {
|
||||
'use strict';
|
||||
|
||||
if (typeof exports === 'object') {
|
||||
// Node. Does not work with strict CommonJS, but
|
||||
// only CommonJS-like enviroments that support module.exports,
|
||||
// like Node.
|
||||
module.exports = factory(require('underscore'), require('backbone'));
|
||||
} else if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define(['underscore', 'backbone'], function (_, Backbone) {
|
||||
// Check if we use the AMD branch of Back
|
||||
_ = _ === undef ? root._ : _;
|
||||
Backbone = Backbone === undef ? root.Backbone : Backbone;
|
||||
return (root.returnExportsGlobal = factory(_, Backbone, root));
|
||||
});
|
||||
} else {
|
||||
// Browser globals
|
||||
root.returnExportsGlobal = factory(root._, root.Backbone);
|
||||
}
|
||||
|
||||
// Usage:
|
||||
//
|
||||
// Note: This plugin is UMD compatible, you can use it in node, amd and vanilla js envs
|
||||
//
|
||||
// Vanilla JS:
|
||||
// <script src="underscore.js"></script>
|
||||
// <script src="backbone.js"></script>
|
||||
// <script src="backbone.mutators.js"></script>
|
||||
//
|
||||
// Node:
|
||||
// var _ = require('underscore');
|
||||
// var Backbone = require('backbone');
|
||||
// var Mutators = require('backbone.mutators');
|
||||
//
|
||||
//
|
||||
// AMD:
|
||||
// define(['underscore', 'backbone', 'backbone.mutators'], function (_, Backbone, Mutators) {
|
||||
// // insert sample from below
|
||||
// return User;
|
||||
// });
|
||||
//
|
||||
// var User = Backbone.Model.extend({
|
||||
// mutators: {
|
||||
// fullname: function () {
|
||||
// return this.firstname + ' ' + this.lastname;
|
||||
// }
|
||||
// },
|
||||
//
|
||||
// defaults: {
|
||||
// firstname: 'Sebastian',
|
||||
// lastname: 'Golasch'
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// var user = new User();
|
||||
// user.get('fullname') // returns 'Sebastian Golasch'
|
||||
// user.toJSON() // return '{firstname: 'Sebastian', lastname: 'Golasch', fullname: 'Sebastian Golasch'}'
|
||||
|
||||
}(this, function (_, Backbone, root, undef) {
|
||||
'use strict';
|
||||
|
||||
// check if we use the amd branch of backbone and underscore
|
||||
Backbone = Backbone === undef ? root.Backbone : Backbone;
|
||||
_ = _ === undef ? root._ : _;
|
||||
|
||||
// extend backbones model prototype with the mutator functionality
|
||||
var Mutator = function () {},
|
||||
oldGet = Backbone.Model.prototype.get,
|
||||
oldSet = Backbone.Model.prototype.set,
|
||||
oldToJson = Backbone.Model.prototype.toJSON;
|
||||
|
||||
// This is necessary to ensure that Models declared without the mutators object do not throw and error
|
||||
Mutator.prototype.mutators = {};
|
||||
|
||||
// override get functionality to fetch the mutator props
|
||||
Mutator.prototype.get = function (attr) {
|
||||
var isMutator = this.mutators !== undef;
|
||||
|
||||
// check if we have a getter mutation
|
||||
if (isMutator === true && _.isFunction(this.mutators[attr]) === true) {
|
||||
return this.mutators[attr].call(this);
|
||||
}
|
||||
|
||||
// check if we have a deeper nested getter mutation
|
||||
if (isMutator === true && _.isObject(this.mutators[attr]) === true && _.isFunction(this.mutators[attr].get) === true) {
|
||||
return this.mutators[attr].get.call(this);
|
||||
}
|
||||
|
||||
return oldGet.call(this, attr);
|
||||
};
|
||||
|
||||
// override set functionality to set the mutator props
|
||||
Mutator.prototype.set = function (key, value, options) {
|
||||
var isMutator = this.mutators !== undef,
|
||||
ret = null,
|
||||
attrs = null;
|
||||
|
||||
ret = oldSet.call(this, key, value, options);
|
||||
|
||||
// seamleassly stolen from backbone core
|
||||
// check if the setter action is triggered
|
||||
// using key <-> value or object
|
||||
if (_.isObject(key) || key === null) {
|
||||
attrs = key;
|
||||
options = value;
|
||||
} else {
|
||||
attrs = {};
|
||||
attrs[key] = value;
|
||||
}
|
||||
|
||||
// check if we have a deeper nested setter mutation
|
||||
if (isMutator === true && _.isObject(this.mutators[key]) === true) {
|
||||
|
||||
// check if we need to set a single value
|
||||
if (_.isFunction(this.mutators[key].set) === true) {
|
||||
ret = this.mutators[key].set.call(this, key, attrs[key], options, _.bind(oldSet, this));
|
||||
} else if(_.isFunction(this.mutators[key])){
|
||||
ret = this.mutators[key].call(this, key, attrs[key], options, _.bind(oldSet, this));
|
||||
}
|
||||
}
|
||||
|
||||
if (isMutator === true && _.isObject(attrs)) {
|
||||
_.each(attrs, _.bind(function (attr, attrKey) {
|
||||
if (_.isObject(this.mutators[attrKey]) === true) {
|
||||
// check if we need to set a single value
|
||||
|
||||
var meth = this.mutators[attrKey];
|
||||
if(_.isFunction(meth.set)){
|
||||
meth = meth.set;
|
||||
}
|
||||
|
||||
if(_.isFunction(meth)){
|
||||
if (options === undef || (_.isObject(options) === true && options.silent !== true && (options.mutators !== undef && options.mutators.silent !== true))) {
|
||||
this.trigger('mutators:set:' + attrKey);
|
||||
}
|
||||
meth.call(this, attrKey, attr, options, _.bind(oldSet, this));
|
||||
}
|
||||
|
||||
}
|
||||
}, this));
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
// override toJSON functionality to serialize mutator properties
|
||||
Mutator.prototype.toJSON = function (options) {
|
||||
// fetch ye olde values
|
||||
var attr = oldToJson.call(this),
|
||||
isSaving,
|
||||
isTransient;
|
||||
// iterate over all mutators (if there are some)
|
||||
_.each(this.mutators, _.bind(function (mutator, name) {
|
||||
// check if we have some getter mutations
|
||||
if (_.isObject(this.mutators[name]) === true && _.isFunction(this.mutators[name].get)) {
|
||||
isSaving = _.has(options || {}, 'emulateHTTP');
|
||||
isTransient = this.mutators[name].transient;
|
||||
if (!isSaving || !isTransient) {
|
||||
attr[name] = _.bind(this.mutators[name].get, this)();
|
||||
}
|
||||
} else if (_.isFunction(this.mutators[name])) {
|
||||
attr[name] = _.bind(this.mutators[name], this)();
|
||||
}
|
||||
}, this));
|
||||
|
||||
return attr;
|
||||
};
|
||||
|
||||
// override get functionality to get HTML-escaped the mutator props
|
||||
Mutator.prototype.escape = function (attr){
|
||||
var val = this.get(attr);
|
||||
return _.escape(val == null ? '' : '' + val);
|
||||
};
|
||||
|
||||
// extend the models prototype
|
||||
_.extend(Backbone.Model.prototype, Mutator.prototype);
|
||||
|
||||
// make mutators globally available under the Backbone namespace
|
||||
Backbone.Mutators = Mutator;
|
||||
return Mutator;
|
||||
}));
|
||||
20
front-api/node_modules/Backbone.Mutators/test/index.html
generated
vendored
Normal file
20
front-api/node_modules/Backbone.Mutators/test/index.html
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>Backbone.Mutators Testsuite</title>
|
||||
<link rel="stylesheet" href="../node_modules/qunitjs/qunit/qunit.css" type="text/css" media="screen">
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="qunit-header">Backbone.Mutators Testsuite</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
<script src="../node_modules/qunitjs/qunit/qunit.js"></script>
|
||||
<script src="../bower_components/underscore/underscore.js"></script>
|
||||
<script src="../bower_components/backbone/backbone.js"></script>
|
||||
<script src="../src/backbone.mutators.js"></script>
|
||||
<script src="tests.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
27
front-api/node_modules/Backbone.Mutators/test/index_sauce.html
generated
vendored
Normal file
27
front-api/node_modules/Backbone.Mutators/test/index_sauce.html
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>Backbone.Mutators Testsuite</title>
|
||||
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.11.0.css" type="text/css" media="screen">
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="qunit-header">Backbone.Mutators Testsuite</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
<script src="http://code.jquery.com/jquery.js"></script>
|
||||
<script src="http://code.jquery.com/qunit/qunit-1.11.0.js"></script>
|
||||
<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore.js"></script>
|
||||
<script src="http://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.0.0/backbone.js"></script>
|
||||
<script src="../src/backbone.mutators.js"></script>
|
||||
<script>
|
||||
var global_test_results = null;
|
||||
QUnit.done = function (test_results) {
|
||||
global_test_results = test_results;
|
||||
};
|
||||
</script>
|
||||
<script src="tests.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
513
front-api/node_modules/Backbone.Mutators/test/node_test.js
generated
vendored
Normal file
513
front-api/node_modules/Backbone.Mutators/test/node_test.js
generated
vendored
Normal file
@@ -0,0 +1,513 @@
|
||||
var _ = require('underscore');
|
||||
var Backbone = require('backbone');
|
||||
require('../src/backbone.mutators');
|
||||
|
||||
exports['require'] = {
|
||||
|
||||
"can get 'normal' value": function (test) {
|
||||
test.expect(2);
|
||||
var Model = Backbone.Model.extend({
|
||||
mutators: {
|
||||
fullname: function () {
|
||||
return this.firstname + ' ' + this.lastname;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
model.set('firstname', 'Sebastian');
|
||||
model.set('lastname', 'Golasch');
|
||||
|
||||
test.equal(model.get('firstname'), 'Sebastian', 'Can get unmutated firstname');
|
||||
test.equal(model.get('lastname'), 'Golasch', 'Can get unmutated lastname');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"can get 'mutated' value (newly created)": function (test) {
|
||||
test.expect(3);
|
||||
var Model = Backbone.Model.extend({
|
||||
mutators: {
|
||||
fullname: function () {
|
||||
return this.get('firstname') + ' ' + this.get('lastname');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
model.set('firstname', 'Sebastian');
|
||||
model.set('lastname', 'Golasch');
|
||||
test.equal(model.get('firstname'), 'Sebastian', 'Can get unmutated firstname');
|
||||
test.equal(model.get('lastname'), 'Golasch', 'Can get unmutated lastname');
|
||||
test.equal(model.get('fullname'), 'Sebastian Golasch', 'Can get mutated fullname');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"can get 'mutated' value (overridden)": function (test) {
|
||||
test.expect(5);
|
||||
var Model = Backbone.Model.extend({
|
||||
mutators: {
|
||||
status: function (key, value, options, set) {
|
||||
if(key){
|
||||
set('status', value);
|
||||
}
|
||||
|
||||
return { status: this.attributes.status, overallStatus: this.get('overallStatus'), underestimatedNonOverallStatus: this.get('underestimatedNonOverallStatus') };
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
model.set('overallStatus', 1);
|
||||
model.set('underestimatedNonOverallStatus', 3);
|
||||
model.set('status', 2);
|
||||
|
||||
test.equal(model.get('overallStatus'), 1, 'Can get unmutated overallStatus');
|
||||
test.equal(model.get('underestimatedNonOverallStatus'), 3, 'Can get unmutated underestimatedNonOverallStatus');
|
||||
test.equal(model.get('status').status, 2, 'Can get mutated status');
|
||||
test.equal(model.get('status').overallStatus, 1, 'Can get mutated status');
|
||||
test.equal(model.get('status').underestimatedNonOverallStatus, 3, 'Can get mutated status');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"can get 'normal' value - object context": function (test) {
|
||||
test.expect(2);
|
||||
var Model = Backbone.Model.extend({
|
||||
mutators: {
|
||||
fullanme: {
|
||||
get: function () {
|
||||
return this.get('firstname') + ' ' + this.get('lastname');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
model.set('firstname', 'Sebastian');
|
||||
model.set('lastname', 'Golasch');
|
||||
|
||||
test.equal(model.get('firstname'), 'Sebastian', 'Can get unmutated firstname');
|
||||
test.equal(model.get('lastname'), 'Golasch', 'Can get unmutated lastname');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"can get 'mutated' value (newly created) - object context": function (test) {
|
||||
test.expect(3);
|
||||
var Model = Backbone.Model.extend({
|
||||
mutators: {
|
||||
fullname: {
|
||||
get: function () {
|
||||
return this.get('firstname') + ' ' + this.get('lastname');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
model.set('firstname', 'Sebastian');
|
||||
model.set('lastname', 'Golasch');
|
||||
|
||||
test.equal(model.get('firstname'), 'Sebastian', 'Can get unmutated firstname');
|
||||
test.equal(model.get('lastname'), 'Golasch', 'Can get unmutated lastname');
|
||||
test.equal(model.get('fullname'), 'Sebastian Golasch', 'Can get mutated fullname');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"can get 'mutated' value (overridden) - object context": function (test) {
|
||||
test.expect(5);
|
||||
var Model = Backbone.Model.extend({
|
||||
mutators: {
|
||||
status: {
|
||||
get: function () {
|
||||
return { status: this.attributes.status, overallStatus: this.get('overallStatus'), underestimatedNonOverallStatus: this.get('underestimatedNonOverallStatus') };
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
model.set('overallStatus', 1);
|
||||
model.set('underestimatedNonOverallStatus', 3);
|
||||
model.set('status', 2);
|
||||
|
||||
test.equal(model.get('overallStatus'), 1, 'Can get unmutated overallStatus');
|
||||
test.equal(model.get('underestimatedNonOverallStatus'), 3, 'Can get unmutated underestimatedNonOverallStatus');
|
||||
test.equal(model.get('status').status, 2, 'Can get mutated status');
|
||||
test.equal(model.get('status').overallStatus, 1, 'Can get mutated status');
|
||||
test.equal(model.get('status').underestimatedNonOverallStatus, 3, 'Can get mutated status');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"can set 'normal' value (key <-> value)": function (test) {
|
||||
test.expect(1);
|
||||
var Model = Backbone.Model.extend({
|
||||
mutators: {
|
||||
status: {
|
||||
set: function () {
|
||||
return { status: this.attributes.status, overallStatus: this.get('overallStatus'), underestimatedNonOverallStatus: this.get('underestimatedNonOverallStatus') };
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
model.set('overallStatus', 1);
|
||||
|
||||
test.equal(model.get('overallStatus'), 1, 'Can get unmutated overallStatus');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"can set 'mutated' value (key <-> value)": function (test) {
|
||||
test.expect(2);
|
||||
var Model = Backbone.Model.extend({
|
||||
mutators: {
|
||||
status: {
|
||||
set: function (key, value, options) {
|
||||
this.set('pState', value.pState, options);
|
||||
this.set('aState', value.aState, options);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
model.set('status', {pState: 1, aState: 2});
|
||||
|
||||
test.equal(model.get('pState'), 1, 'Can get mutated pState');
|
||||
test.equal(model.get('aState'), 2, 'Can get mutated aState');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"can set 'normal' value (object)": function (test) {
|
||||
test.expect(1);
|
||||
var Model = Backbone.Model.extend({
|
||||
mutators: {
|
||||
status: {
|
||||
set: function () {
|
||||
return { status: this.attributes.status, overallStatus: this.get('overallStatus'), underestimatedNonOverallStatus: this.get('underestimatedNonOverallStatus') };
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
model.set({overallStatus: 1});
|
||||
|
||||
test.equal(model.get('overallStatus'), 1, 'Can get unmutated overallStatus');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"can set attribute objects": function (test) {
|
||||
test.expect(3);
|
||||
var Model = Backbone.Model.extend({
|
||||
mutators: {
|
||||
fullname: {
|
||||
set: function (key, value, options) {
|
||||
var names = value.split(' ');
|
||||
this.set('firstname', names[0], options);
|
||||
this.set('lastname', names[1], options);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
model.set({ fullname: 'Sebastian Golasch', admin: true });
|
||||
|
||||
test.equal(model.get('firstname'), 'Sebastian', 'Can get the firstname');
|
||||
test.equal(model.get('lastname'), 'Golasch', 'Can get the lastname');
|
||||
test.equal(model.get('admin'), true, 'Can get the admin status');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"can set newly created 'mutated' value (object)": function (test) {
|
||||
test.expect(2);
|
||||
var Model = Backbone.Model.extend({
|
||||
mutators: {
|
||||
status: {
|
||||
set: function (key, value, options) {
|
||||
this.set('pState', value.pState, options);
|
||||
this.set('aState', value.aState, options);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
model.set({status: {pState: 1, aState: 2, dState: 3}});
|
||||
|
||||
test.equal(model.get('pState'), 1, 'Can get mutated pState');
|
||||
test.equal(model.get('aState'), 2, 'Can get mutated aState');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"can set 'mutated' value (object)": function (test) {
|
||||
test.expect(4);
|
||||
var Model = Backbone.Model.extend({
|
||||
mutators: {
|
||||
status: {
|
||||
set: function (key, value, options, set) {
|
||||
if(_.isString(value)){
|
||||
set(key, value);
|
||||
} else {
|
||||
this.set('pState', value.pState, options);
|
||||
this.set('aState', value.aState, options);
|
||||
if (value.pState === 1) {
|
||||
set(key, 'supercool', options);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
defaults: {
|
||||
status: 'awkward'
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
|
||||
test.equal(model.get('status'), 'awkward', 'Can get unmodified value');
|
||||
model.set({status: {pState: 1, aState: 2, dState: 3}});
|
||||
test.equal(model.get('status'), 'supercool', 'Can get mutated status value');
|
||||
test.equal(model.get('pState'), 1, 'Can get mutated pState');
|
||||
test.equal(model.get('aState'), 2, 'Can get mutated aState');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"can set a 'mutated' value and fire event": function (test) {
|
||||
test.expect(3);
|
||||
var Model = Backbone.Model.extend({
|
||||
mutators: {
|
||||
status: {
|
||||
set: function (key, value, options, set) {
|
||||
set(key, value.toLowerCase(), options);
|
||||
}
|
||||
}
|
||||
},
|
||||
defaults: {
|
||||
status: 'awkward'
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
|
||||
model.bind('mutators:set:status', function () {
|
||||
test.ok(true, 'Callback called');
|
||||
});
|
||||
|
||||
test.equal(model.get('status'), 'awkward', 'Can get unmodified value');
|
||||
model.set({status: 'SUPERCOOL'});
|
||||
test.equal(model.get('status'), 'supercool', 'Can get mutated status value');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"can set 'mutated' value and fire a mutated event": function (test) {
|
||||
test.expect(2);
|
||||
var Model = Backbone.Model.extend({
|
||||
mutators: {
|
||||
status: {
|
||||
set: function (key, value, options, set) {
|
||||
set(key, value.toLowerCase(), options);
|
||||
}
|
||||
}
|
||||
},
|
||||
defaults: {
|
||||
status: 'awkward'
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
|
||||
model.bind('mutators:set:status', function () {
|
||||
test.ok(true, 'Callback called (And this shouldn´t happen)');
|
||||
});
|
||||
|
||||
test.equal(model.get('status'), 'awkward', 'Can get unmodified value');
|
||||
model.set('status', 'SUPERCOOL', {silent: true});
|
||||
test.equal(model.get('status'), 'supercool', 'Can get mutated status value');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"can set 'mutated' value and fire event": function (test) {
|
||||
test.expect(4);
|
||||
var Model = Backbone.Model.extend({
|
||||
mutators: {
|
||||
status: {
|
||||
set: function (key, value, options, set) {
|
||||
set(key, value.toLowerCase(), options);
|
||||
}
|
||||
}
|
||||
},
|
||||
defaults: {
|
||||
status: 'awkward'
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
|
||||
model.bind('mutators:set:status', function () {
|
||||
test.ok(true, 'Callback called (And this shouldn´t happen)');
|
||||
});
|
||||
|
||||
model.bind('change:status', function () {
|
||||
test.ok(true, 'Callback called (And this should happen)');
|
||||
});
|
||||
|
||||
test.equal(model.get('status'), 'awkward', 'Can get unmodified value');
|
||||
model.set('status', 'SUPERCOOL', {mutators: {silent: true}});
|
||||
test.equal(model.get('status'), 'supercool', 'Can get mutated status value');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"can serialize an unmutated model": function (test) {
|
||||
test.expect(2);
|
||||
var Model = Backbone.Model.extend({
|
||||
defaults: {
|
||||
a: 'a',
|
||||
b: 'b'
|
||||
}
|
||||
});
|
||||
|
||||
test.equal((new Model()).toJSON().a, 'a', 'can serialize unmutated model');
|
||||
test.equal((new Model()).toJSON().b, 'b', 'can serialize unmutated model');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"can serialize mutated model": function (test) {
|
||||
test.expect(3);
|
||||
var Model = Backbone.Model.extend({
|
||||
defaults: {
|
||||
a: 'a',
|
||||
b: 'b'
|
||||
},
|
||||
mutators: {
|
||||
state: function () {
|
||||
return this.get('a') + ', ' + this.get('b');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test.equal((new Model()).toJSON().a, 'a', 'can serialize mutated model');
|
||||
test.equal((new Model()).get('state'), 'a, b', 'can serialize mutated model');
|
||||
test.equal((new Model()).toJSON().state, 'a, b', 'can serialize mutated model');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"can serialize mutated model with only a setter": function (test) {
|
||||
test.expect(2);
|
||||
var Model = Backbone.Model.extend({
|
||||
mutators: {
|
||||
status: {
|
||||
set: function (key, value, options, set) {
|
||||
set(key, value.toLowerCase(), options);
|
||||
}
|
||||
}
|
||||
},
|
||||
defaults: {
|
||||
status: 'awkward'
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
|
||||
test.equal(model.toJSON().status, 'awkward', 'can serialize mutated model with only a setter');
|
||||
model.set('status', 'SUPERCOOL', {mutators: {silent: true}});
|
||||
test.equal(model.toJSON().status, 'supercool', 'can serialize mutated model with only a setter');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"can escape mutated properties": function (test) {
|
||||
test.expect(2);
|
||||
var Model = Backbone.Model.extend({
|
||||
defaults: {
|
||||
a: 'a',
|
||||
b: 'b'
|
||||
},
|
||||
mutators: {
|
||||
b: function () {
|
||||
return 'c';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
test.equal(model.get('b'), 'c');
|
||||
model.set('b', 'foobar');
|
||||
test.equal(model.get('b'), 'c');
|
||||
test.done();
|
||||
},
|
||||
|
||||
"can get/set using single method": function (test) {
|
||||
test.expect(6);
|
||||
var Model = Backbone.Model.extend({
|
||||
mutators:{
|
||||
state:function(key, value){
|
||||
if(key){
|
||||
this.set("a", value);
|
||||
test.equal(arguments.length, 4);
|
||||
return null; //prevents ret from returning
|
||||
}
|
||||
return this.get("a");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
var value = "happy";
|
||||
model.set('state', value);
|
||||
|
||||
test.equal(model.get('state'), value);
|
||||
var new_state = "excited",
|
||||
new_level = 10;
|
||||
|
||||
//set multiple
|
||||
model.set({
|
||||
level:new_level,
|
||||
state:new_state
|
||||
});
|
||||
|
||||
test.equal(model.get('state'), new_state);
|
||||
test.equal(model.get('level'), new_level);
|
||||
test.done();
|
||||
},
|
||||
|
||||
"can omit transient variables from JSON when saving": function(test) {
|
||||
test.expect(4);
|
||||
var Model = Backbone.Model.extend({
|
||||
defaults:{
|
||||
firstName:"Iain",
|
||||
middleInit:"M",
|
||||
lastName:"Banks"
|
||||
},
|
||||
mutators:{
|
||||
fullName:{
|
||||
get: function() {
|
||||
var fullName = this.get("firstName");
|
||||
fullName += " " + this.get("middleInit");
|
||||
fullName += ". " + this.get("lastName");
|
||||
return fullName;
|
||||
},
|
||||
transient: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
// First make sure we didn't break the accessor (or the normal model property
|
||||
// access)
|
||||
test.equal(model.get("fullName"), "Iain M. Banks");
|
||||
test.equal(model.get("firstName"), "Iain");
|
||||
|
||||
// Ensure that a normal toJSON call (like you'd use with a template) includes
|
||||
// the computed value
|
||||
var modelToJSON = model.toJSON();
|
||||
test.equal(modelToJSON.fullName, "Iain M. Banks");
|
||||
|
||||
// Backbone always sets 'emulateHTTP' to true or (usually) false when syncing,
|
||||
// so we use the existence of that property as a proxy for "yes I'm syncing"
|
||||
var modelToJSONSync = model.toJSON({emulateHTTP:false});
|
||||
test.equal(typeof modelToJSONSync.fullName, "undefined");
|
||||
test.done();
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
494
front-api/node_modules/Backbone.Mutators/test/tests.js
generated
vendored
Normal file
494
front-api/node_modules/Backbone.Mutators/test/tests.js
generated
vendored
Normal file
@@ -0,0 +1,494 @@
|
||||
module('Backbone.Mutators');
|
||||
|
||||
test("can get 'normal' value", function () {
|
||||
expect(2);
|
||||
var Model = Backbone.Model.extend({
|
||||
mutators: {
|
||||
fullname: function () {
|
||||
return this.firstname + ' ' + this.lastname;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
model.set('firstname', 'Sebastian');
|
||||
model.set('lastname', 'Golasch');
|
||||
|
||||
equal(model.get('firstname'), 'Sebastian', 'Can get unmutated firstname');
|
||||
equal(model.get('lastname'), 'Golasch', 'Can get unmutated lastname');
|
||||
});
|
||||
|
||||
test("can get 'mutated' value (newly created)", function () {
|
||||
expect(3);
|
||||
var Model = Backbone.Model.extend({
|
||||
mutators: {
|
||||
fullname: function () {
|
||||
return this.get('firstname') + ' ' + this.get('lastname');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
model.set('firstname', 'Sebastian');
|
||||
model.set('lastname', 'Golasch');
|
||||
equal(model.get('firstname'), 'Sebastian', 'Can get unmutated firstname');
|
||||
equal(model.get('lastname'), 'Golasch', 'Can get unmutated lastname');
|
||||
equal(model.get('fullname'), 'Sebastian Golasch', 'Can get mutated fullname');
|
||||
});
|
||||
|
||||
test("can get 'mutated' value (overridden)", function () {
|
||||
expect(5);
|
||||
var Model = Backbone.Model.extend({
|
||||
mutators: {
|
||||
status: function (key, value, options, set) {
|
||||
if(key){
|
||||
set('status', value);
|
||||
}
|
||||
|
||||
return { status: this.attributes.status, overallStatus: this.get('overallStatus'), underestimatedNonOverallStatus: this.get('underestimatedNonOverallStatus') };
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
model.set('overallStatus', 1);
|
||||
model.set('underestimatedNonOverallStatus', 3);
|
||||
model.set('status', 2);
|
||||
|
||||
equal(model.get('overallStatus'), 1, 'Can get unmutated overallStatus');
|
||||
equal(model.get('underestimatedNonOverallStatus'), 3, 'Can get unmutated underestimatedNonOverallStatus');
|
||||
equal(model.get('status').status, 2, 'Can get mutated status');
|
||||
equal(model.get('status').overallStatus, 1, 'Can get mutated status');
|
||||
equal(model.get('status').underestimatedNonOverallStatus, 3, 'Can get mutated status');
|
||||
});
|
||||
|
||||
test("can get 'normal' value - object context", function () {
|
||||
expect(2);
|
||||
var Model = Backbone.Model.extend({
|
||||
mutators: {
|
||||
fullanme: {
|
||||
get: function () {
|
||||
return this.get('firstname') + ' ' + this.get('lastname');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
model.set('firstname', 'Sebastian');
|
||||
model.set('lastname', 'Golasch');
|
||||
|
||||
equal(model.get('firstname'), 'Sebastian', 'Can get unmutated firstname');
|
||||
equal(model.get('lastname'), 'Golasch', 'Can get unmutated lastname');
|
||||
});
|
||||
|
||||
test("can get 'mutated' value (newly created) - object context", function () {
|
||||
expect(3);
|
||||
var Model = Backbone.Model.extend({
|
||||
mutators: {
|
||||
fullname: {
|
||||
get: function () {
|
||||
return this.get('firstname') + ' ' + this.get('lastname');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
model.set('firstname', 'Sebastian');
|
||||
model.set('lastname', 'Golasch');
|
||||
|
||||
equal(model.get('firstname'), 'Sebastian', 'Can get unmutated firstname');
|
||||
equal(model.get('lastname'), 'Golasch', 'Can get unmutated lastname');
|
||||
equal(model.get('fullname'), 'Sebastian Golasch', 'Can get mutated fullname');
|
||||
});
|
||||
|
||||
test("can get 'mutated' value (overridden) - object context", function () {
|
||||
expect(5);
|
||||
var Model = Backbone.Model.extend({
|
||||
mutators: {
|
||||
status: {
|
||||
get: function () {
|
||||
return { status: this.attributes.status, overallStatus: this.get('overallStatus'), underestimatedNonOverallStatus: this.get('underestimatedNonOverallStatus') };
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
model.set('overallStatus', 1);
|
||||
model.set('underestimatedNonOverallStatus', 3);
|
||||
model.set('status', 2);
|
||||
|
||||
equal(model.get('overallStatus'), 1, 'Can get unmutated overallStatus');
|
||||
equal(model.get('underestimatedNonOverallStatus'), 3, 'Can get unmutated underestimatedNonOverallStatus');
|
||||
equal(model.get('status').status, 2, 'Can get mutated status');
|
||||
equal(model.get('status').overallStatus, 1, 'Can get mutated status');
|
||||
equal(model.get('status').underestimatedNonOverallStatus, 3, 'Can get mutated status');
|
||||
});
|
||||
|
||||
test("can set 'normal' value (key <-> value)", function () {
|
||||
expect(1);
|
||||
var Model = Backbone.Model.extend({
|
||||
mutators: {
|
||||
status: {
|
||||
set: function () {
|
||||
return { status: this.attributes.status, overallStatus: this.get('overallStatus'), underestimatedNonOverallStatus: this.get('underestimatedNonOverallStatus') };
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
model.set('overallStatus', 1);
|
||||
|
||||
equal(model.get('overallStatus'), 1, 'Can get unmutated overallStatus');
|
||||
});
|
||||
|
||||
test("can set 'mutated' value (key <-> value)", function () {
|
||||
expect(2);
|
||||
var Model = Backbone.Model.extend({
|
||||
mutators: {
|
||||
status: {
|
||||
set: function (key, value, options) {
|
||||
this.set('pState', value.pState, options);
|
||||
this.set('aState', value.aState, options);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
model.set('status', {pState: 1, aState: 2});
|
||||
|
||||
equal(model.get('pState'), 1, 'Can get mutated pState');
|
||||
equal(model.get('aState'), 2, 'Can get mutated aState');
|
||||
});
|
||||
|
||||
test("can set 'normal' value (object)", function () {
|
||||
expect(1);
|
||||
var Model = Backbone.Model.extend({
|
||||
mutators: {
|
||||
status: {
|
||||
set: function () {
|
||||
return { status: this.attributes.status, overallStatus: this.get('overallStatus'), underestimatedNonOverallStatus: this.get('underestimatedNonOverallStatus') };
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
model.set({overallStatus: 1});
|
||||
|
||||
equal(model.get('overallStatus'), 1, 'Can get unmutated overallStatus');
|
||||
});
|
||||
|
||||
test("can set attribute objects", function () {
|
||||
expect(3);
|
||||
var Model = Backbone.Model.extend({
|
||||
mutators: {
|
||||
fullname: {
|
||||
set: function (key, value, options) {
|
||||
var names = value.split(' ');
|
||||
this.set('firstname', names[0], options);
|
||||
this.set('lastname', names[1], options);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
model.set({ fullname: 'Sebastian Golasch', admin: true });
|
||||
|
||||
equal(model.get('firstname'), 'Sebastian', 'Can get the firstname');
|
||||
equal(model.get('lastname'), 'Golasch', 'Can get the lastname');
|
||||
equal(model.get('admin'), true, 'Can get the admin status');
|
||||
});
|
||||
|
||||
test("can set newly created 'mutated' value (object)", function () {
|
||||
expect(2);
|
||||
var Model = Backbone.Model.extend({
|
||||
mutators: {
|
||||
status: {
|
||||
set: function (key, value, options) {
|
||||
this.set('pState', value.pState, options);
|
||||
this.set('aState', value.aState, options);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
model.set({status: {pState: 1, aState: 2, dState: 3}});
|
||||
|
||||
equal(model.get('pState'), 1, 'Can get mutated pState');
|
||||
equal(model.get('aState'), 2, 'Can get mutated aState');
|
||||
});
|
||||
|
||||
test("can set 'mutated' value (object)", function () {
|
||||
expect(4);
|
||||
var Model = Backbone.Model.extend({
|
||||
mutators: {
|
||||
status: {
|
||||
set: function (key, value, options, set) {
|
||||
if(_.isString(value)){
|
||||
set(key, value);
|
||||
} else {
|
||||
this.set('pState', value.pState, options);
|
||||
this.set('aState', value.aState, options);
|
||||
if (value.pState === 1) {
|
||||
set(key, 'supercool', options);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
defaults: {
|
||||
status: 'awkward'
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
|
||||
equal(model.get('status'), 'awkward', 'Can get unmodified value');
|
||||
model.set({status: {pState: 1, aState: 2, dState: 3}});
|
||||
equal(model.get('status'), 'supercool', 'Can get mutated status value');
|
||||
equal(model.get('pState'), 1, 'Can get mutated pState');
|
||||
equal(model.get('aState'), 2, 'Can get mutated aState');
|
||||
|
||||
});
|
||||
|
||||
test("can set 'mutated' value and fire event", function () {
|
||||
expect(3);
|
||||
var Model = Backbone.Model.extend({
|
||||
mutators: {
|
||||
status: {
|
||||
set: function (key, value, options, set) {
|
||||
set(key, value.toLowerCase(), options);
|
||||
}
|
||||
}
|
||||
},
|
||||
defaults: {
|
||||
status: 'awkward'
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
|
||||
model.bind('mutators:set:status', function () {
|
||||
ok(true, 'Callback called');
|
||||
});
|
||||
|
||||
equal(model.get('status'), 'awkward', 'Can get unmodified value');
|
||||
model.set({status: 'SUPERCOOL'});
|
||||
equal(model.get('status'), 'supercool', 'Can get mutated status value');
|
||||
|
||||
});
|
||||
|
||||
test("can set 'mutated' value and fire event", function () {
|
||||
expect(2);
|
||||
var Model = Backbone.Model.extend({
|
||||
mutators: {
|
||||
status: {
|
||||
set: function (key, value, options, set) {
|
||||
set(key, value.toLowerCase(), options);
|
||||
}
|
||||
}
|
||||
},
|
||||
defaults: {
|
||||
status: 'awkward'
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
|
||||
model.bind('mutators:set:status', function () {
|
||||
ok(true, 'Callback called (And this shouldn´t happen)');
|
||||
});
|
||||
|
||||
equal(model.get('status'), 'awkward', 'Can get unmodified value');
|
||||
model.set('status', 'SUPERCOOL', {silent: true});
|
||||
equal(model.get('status'), 'supercool', 'Can get mutated status value');
|
||||
|
||||
});
|
||||
|
||||
test("can set 'mutated' value and fire event", function () {
|
||||
expect(4);
|
||||
var Model = Backbone.Model.extend({
|
||||
mutators: {
|
||||
status: {
|
||||
set: function (key, value, options, set) {
|
||||
set(key, value.toLowerCase(), options);
|
||||
}
|
||||
}
|
||||
},
|
||||
defaults: {
|
||||
status: 'awkward'
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
|
||||
model.bind('mutators:set:status', function () {
|
||||
ok(true, 'Callback called (And this shouldn´t happen)');
|
||||
});
|
||||
|
||||
model.bind('change:status', function () {
|
||||
ok(true, 'Callback called (And this should happen)');
|
||||
});
|
||||
|
||||
equal(model.get('status'), 'awkward', 'Can get unmodified value');
|
||||
model.set('status', 'SUPERCOOL', {mutators: {silent: true}});
|
||||
equal(model.get('status'), 'supercool', 'Can get mutated status value');
|
||||
|
||||
});
|
||||
|
||||
test("can serialize an unmutated model", function () {
|
||||
expect(2);
|
||||
var Model = Backbone.Model.extend({
|
||||
defaults: {
|
||||
a: 'a',
|
||||
b: 'b'
|
||||
}
|
||||
});
|
||||
|
||||
equal((new Model()).toJSON().a, 'a', 'can serialize unmutated model');
|
||||
equal((new Model()).toJSON().b, 'b', 'can serialize unmutated model');
|
||||
});
|
||||
|
||||
test("can serialize mutated model", function () {
|
||||
expect(3);
|
||||
var Model = Backbone.Model.extend({
|
||||
defaults: {
|
||||
a: 'a',
|
||||
b: 'b'
|
||||
},
|
||||
mutators: {
|
||||
state: function () {
|
||||
return this.get('a') + ', ' + this.get('b');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
equal((new Model()).toJSON().a, 'a', 'can serialize mutated model');
|
||||
equal((new Model()).get('state'), 'a, b', 'can serialize mutated model');
|
||||
equal((new Model()).toJSON().state, 'a, b', 'can serialize mutated model');
|
||||
});
|
||||
|
||||
test("can serialize mutated model with only a setter", function () {
|
||||
expect(2);
|
||||
var Model = Backbone.Model.extend({
|
||||
mutators: {
|
||||
status: {
|
||||
set: function (key, value, options, set) {
|
||||
set(key, value.toLowerCase(), options);
|
||||
}
|
||||
}
|
||||
},
|
||||
defaults: {
|
||||
status: 'awkward'
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
|
||||
equal(model.toJSON().status, 'awkward', 'can serialize mutated model');
|
||||
model.set('status', 'SUPERCOOL', {mutators: {silent: true}});
|
||||
equal(model.toJSON().status, 'supercool', 'can serialize mutated model');
|
||||
});
|
||||
|
||||
test("can escape mutated properties", function () {
|
||||
expect(2);
|
||||
var Model = Backbone.Model.extend({
|
||||
defaults: {
|
||||
a: 'a',
|
||||
b: 'b'
|
||||
},
|
||||
mutators: {
|
||||
b: function () {
|
||||
return 'c';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
equal(model.get('b'), 'c');
|
||||
model.set('b', 'foobar');
|
||||
equal(model.get('b'), 'c');
|
||||
});
|
||||
|
||||
test("can get/set using single method", 6, function(){
|
||||
|
||||
var Model = Backbone.Model.extend({
|
||||
mutators:{
|
||||
state:function(key, value){
|
||||
if(key){
|
||||
this.set("a", value);
|
||||
|
||||
equal(arguments.length, 4);
|
||||
return null; //prevents ret from returning
|
||||
}
|
||||
|
||||
return this.get("a");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
|
||||
var value = "happy";
|
||||
model.set('state', value);
|
||||
|
||||
equal(model.get('state'), value);
|
||||
|
||||
var new_state = "excited",
|
||||
new_level = 10;
|
||||
|
||||
|
||||
//set multiple
|
||||
model.set({
|
||||
level:new_level,
|
||||
state:new_state
|
||||
});
|
||||
|
||||
equal(model.get('state'), new_state);
|
||||
equal(model.get('level'), new_level);
|
||||
|
||||
});
|
||||
|
||||
test("can omit transient variables from JSON when saving", 4, function() {
|
||||
var Model = Backbone.Model.extend({
|
||||
defaults:{
|
||||
firstName:"Iain",
|
||||
middleInit:"M",
|
||||
lastName:"Banks"
|
||||
},
|
||||
mutators:{
|
||||
fullName:{
|
||||
get: function() {
|
||||
var fullName = this.get("firstName");
|
||||
fullName += " " + this.get("middleInit");
|
||||
fullName += ". " + this.get("lastName");
|
||||
return fullName;
|
||||
},
|
||||
transient: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var model = new Model();
|
||||
// First make sure we didn't break the accessor (or the normal model property
|
||||
// access)
|
||||
equal(model.get("fullName"), "Iain M. Banks");
|
||||
equal(model.get("firstName"), "Iain");
|
||||
|
||||
// Ensure that a normal toJSON call (like you'd use with a template) includes
|
||||
// the computed value
|
||||
var modelToJSON = model.toJSON();
|
||||
equal(modelToJSON.fullName, "Iain M. Banks");
|
||||
|
||||
// Backbone always sets 'emulateHTTP' to true or (usually) false when syncing,
|
||||
// so we use the existence of that property as a proxy for "yes I'm syncing"
|
||||
var modelToJSONSync = model.toJSON({emulateHTTP:false});
|
||||
equal(typeof modelToJSONSync.fullName, "undefined");
|
||||
});
|
||||
2
front-api/node_modules/Backbone.Mutators/testem.yml
generated
vendored
Normal file
2
front-api/node_modules/Backbone.Mutators/testem.yml
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
framework: qunit
|
||||
test_page: test/index.html
|
||||
7
front-api/node_modules/backbone/.npmignore
generated
vendored
Normal file
7
front-api/node_modules/backbone/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
test/
|
||||
Rakefile
|
||||
docs/
|
||||
raw/
|
||||
examples/
|
||||
index.html
|
||||
.jshintrc
|
||||
5
front-api/node_modules/backbone/.travis.yml
generated
vendored
Normal file
5
front-api/node_modules/backbone/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 0.8
|
||||
notifications:
|
||||
email: false
|
||||
2
front-api/node_modules/backbone/CNAME
generated
vendored
Normal file
2
front-api/node_modules/backbone/CNAME
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
backbonejs.org
|
||||
|
||||
22
front-api/node_modules/backbone/CONTRIBUTING.md
generated
vendored
Normal file
22
front-api/node_modules/backbone/CONTRIBUTING.md
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
## How to Open a Backbone.js Ticket
|
||||
|
||||
* Do not use tickets to ask for help with (debugging) your application. Ask on
|
||||
the [mailing list](https://groups.google.com/forum/#!forum/backbonejs),
|
||||
in the IRC channel (`#documentcloud` on Freenode), or if you understand your
|
||||
specific problem, on [StackOverflow](http://stackoverflow.com/questions/tagged/backbone.js).
|
||||
|
||||
* Before you open a ticket or send a pull request,
|
||||
[search](https://github.com/jashkenas/backbone/issues) for previous
|
||||
discussions about the same feature or issue. Add to the earlier ticket if you
|
||||
find one.
|
||||
|
||||
* Before sending a pull request for a feature or bug fix, be sure to have
|
||||
[tests](http://backbonejs.org/test/).
|
||||
|
||||
* Use the same coding style as the rest of the
|
||||
[codebase](https://github.com/jashkenas/backbone/blob/master/backbone.js).
|
||||
|
||||
* In your pull request, do not add documentation or rebuild the minified
|
||||
`backbone-min.js` file. We'll do that before cutting a new release.
|
||||
|
||||
* All pull requests should be made to the `master` branch.
|
||||
22
front-api/node_modules/backbone/LICENSE
generated
vendored
Normal file
22
front-api/node_modules/backbone/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
Copyright (c) 2010-2014 Jeremy Ashkenas, DocumentCloud
|
||||
|
||||
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.
|
||||
29
front-api/node_modules/backbone/README.md
generated
vendored
Normal file
29
front-api/node_modules/backbone/README.md
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
____ __ __
|
||||
/\ _`\ /\ \ /\ \ __
|
||||
\ \ \ \ \ __ ___\ \ \/'\\ \ \____ ___ ___ __ /\_\ ____
|
||||
\ \ _ <' /'__`\ /'___\ \ , < \ \ '__`\ / __`\ /' _ `\ /'__`\ \/\ \ /',__\
|
||||
\ \ \ \ \/\ \ \.\_/\ \__/\ \ \\`\\ \ \ \ \/\ \ \ \/\ \/\ \/\ __/ __ \ \ \/\__, `\
|
||||
\ \____/\ \__/.\_\ \____\\ \_\ \_\ \_,__/\ \____/\ \_\ \_\ \____\/\_\_\ \ \/\____/
|
||||
\/___/ \/__/\/_/\/____/ \/_/\/_/\/___/ \/___/ \/_/\/_/\/____/\/_/\ \_\ \/___/
|
||||
\ \____/
|
||||
\/___/
|
||||
(_'_______________________________________________________________________________'_)
|
||||
(_.———————————————————————————————————————————————————————————————————————————————._)
|
||||
|
||||
|
||||
Backbone supplies structure to JavaScript-heavy applications by providing models key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing application over a RESTful JSON interface.
|
||||
|
||||
For Docs, License, Tests, pre-packed downloads, and everything else, really, see:
|
||||
http://backbonejs.org
|
||||
|
||||
To suggest a feature, report a bug, or general discussion:
|
||||
http://github.com/jashkenas/backbone/issues
|
||||
|
||||
Backbone is an open-sourced component of DocumentCloud:
|
||||
https://github.com/documentcloud
|
||||
|
||||
Many thanks to our contributors:
|
||||
http://github.com/jashkenas/backbone/contributors
|
||||
|
||||
Special thanks to Robert Kieffer for the original philosophy behind Backbone.
|
||||
http://github.com/broofa
|
||||
2
front-api/node_modules/backbone/backbone-min.js
generated
vendored
Normal file
2
front-api/node_modules/backbone/backbone-min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
front-api/node_modules/backbone/backbone-min.map
generated
vendored
Normal file
1
front-api/node_modules/backbone/backbone-min.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1608
front-api/node_modules/backbone/backbone.js
generated
vendored
Normal file
1608
front-api/node_modules/backbone/backbone.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
9
front-api/node_modules/backbone/bower.json
generated
vendored
Normal file
9
front-api/node_modules/backbone/bower.json
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"name" : "backbone",
|
||||
"version" : "1.1.2",
|
||||
"main" : "backbone.js",
|
||||
"dependencies" : {
|
||||
"underscore" : ">=1.5.0"
|
||||
},
|
||||
"ignore" : ["backbone-min.js", "docs", "examples", "test", "*.yml", "*.map", ".html", "*.ico"]
|
||||
}
|
||||
13
front-api/node_modules/backbone/component.json
generated
vendored
Normal file
13
front-api/node_modules/backbone/component.json
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"name" : "backbone",
|
||||
"version" : "1.1.2",
|
||||
"description" : "Give your JS App some Backbone with Models, Views, Collections, and Events.",
|
||||
"keywords" : ["model", "view", "controller", "router", "server", "client", "browser"],
|
||||
"repo" : "jashkenas/backbone",
|
||||
"dependencies" : {
|
||||
"jashkenas/underscore" : "*"
|
||||
},
|
||||
"main" : "backbone.js",
|
||||
"scripts" : ["backbone.js"],
|
||||
"license" : "MIT"
|
||||
}
|
||||
BIN
front-api/node_modules/backbone/favicon.ico
generated
vendored
Normal file
BIN
front-api/node_modules/backbone/favicon.ico
generated
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.2 KiB |
1
front-api/node_modules/backbone/index.js
generated
vendored
Normal file
1
front-api/node_modules/backbone/index.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('./backbone');
|
||||
23
front-api/node_modules/backbone/node_modules/underscore/LICENSE
generated
vendored
Normal file
23
front-api/node_modules/backbone/node_modules/underscore/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
Copyright (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative
|
||||
Reporters & Editors
|
||||
|
||||
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.
|
||||
22
front-api/node_modules/backbone/node_modules/underscore/README.md
generated
vendored
Normal file
22
front-api/node_modules/backbone/node_modules/underscore/README.md
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
__
|
||||
/\ \ __
|
||||
__ __ ___ \_\ \ __ _ __ ____ ___ ___ _ __ __ /\_\ ____
|
||||
/\ \/\ \ /' _ `\ /'_ \ /'__`\/\ __\/ ,__\ / ___\ / __`\/\ __\/'__`\ \/\ \ /',__\
|
||||
\ \ \_\ \/\ \/\ \/\ \ \ \/\ __/\ \ \//\__, `\/\ \__//\ \ \ \ \ \//\ __/ __ \ \ \/\__, `\
|
||||
\ \____/\ \_\ \_\ \___,_\ \____\\ \_\\/\____/\ \____\ \____/\ \_\\ \____\/\_\ _\ \ \/\____/
|
||||
\/___/ \/_/\/_/\/__,_ /\/____/ \/_/ \/___/ \/____/\/___/ \/_/ \/____/\/_//\ \_\ \/___/
|
||||
\ \____/
|
||||
\/___/
|
||||
|
||||
Underscore.js is a utility-belt library for JavaScript that provides
|
||||
support for the usual functional suspects (each, map, reduce, filter...)
|
||||
without extending any core JavaScript objects.
|
||||
|
||||
For Docs, License, Tests, and pre-packed downloads, see:
|
||||
http://underscorejs.org
|
||||
|
||||
Underscore is an open-sourced component of DocumentCloud:
|
||||
https://github.com/documentcloud
|
||||
|
||||
Many thanks to our contributors:
|
||||
https://github.com/jashkenas/underscore/contributors
|
||||
70
front-api/node_modules/backbone/node_modules/underscore/package.json
generated
vendored
Normal file
70
front-api/node_modules/backbone/node_modules/underscore/package.json
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"name": "underscore",
|
||||
"description": "JavaScript's functional programming helper library.",
|
||||
"homepage": "http://underscorejs.org",
|
||||
"keywords": [
|
||||
"util",
|
||||
"functional",
|
||||
"server",
|
||||
"client",
|
||||
"browser"
|
||||
],
|
||||
"author": {
|
||||
"name": "Jeremy Ashkenas",
|
||||
"email": "jeremy@documentcloud.org"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/jashkenas/underscore.git"
|
||||
},
|
||||
"main": "underscore.js",
|
||||
"version": "1.7.0",
|
||||
"devDependencies": {
|
||||
"docco": "0.6.x",
|
||||
"phantomjs": "1.9.7-1",
|
||||
"uglify-js": "2.4.x",
|
||||
"eslint": "0.6.x"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "phantomjs test/vendor/runner.js test/index.html?noglobals=true && eslint underscore.js test/*.js test/vendor/runner.js",
|
||||
"build": "uglifyjs underscore.js -c \"evaluate=false\" --comments \"/ .*/\" -m --source-map underscore-min.map -o underscore-min.js",
|
||||
"doc": "docco underscore.js"
|
||||
},
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "https://raw.github.com/jashkenas/underscore/master/LICENSE"
|
||||
}
|
||||
],
|
||||
"files": [
|
||||
"underscore.js",
|
||||
"underscore-min.js",
|
||||
"LICENSE"
|
||||
],
|
||||
"gitHead": "da996e665deb0b69b257e80e3e257c04fde4191c",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jashkenas/underscore/issues"
|
||||
},
|
||||
"_id": "underscore@1.7.0",
|
||||
"_shasum": "6bbaf0877500d36be34ecaa584e0db9fef035209",
|
||||
"_from": "underscore@>=1.5.0",
|
||||
"_npmVersion": "1.4.24",
|
||||
"_npmUser": {
|
||||
"name": "jashkenas",
|
||||
"email": "jashkenas@gmail.com"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "jashkenas",
|
||||
"email": "jashkenas@gmail.com"
|
||||
}
|
||||
],
|
||||
"dist": {
|
||||
"shasum": "6bbaf0877500d36be34ecaa584e0db9fef035209",
|
||||
"tarball": "http://registry.npmjs.org/underscore/-/underscore-1.7.0.tgz"
|
||||
},
|
||||
"directories": {},
|
||||
"_resolved": "https://registry.npmjs.org/underscore/-/underscore-1.7.0.tgz",
|
||||
"readme": " __\n /\\ \\ __\n __ __ ___ \\_\\ \\ __ _ __ ____ ___ ___ _ __ __ /\\_\\ ____\n /\\ \\/\\ \\ /' _ `\\ /'_ \\ /'__`\\/\\ __\\/ ,__\\ / ___\\ / __`\\/\\ __\\/'__`\\ \\/\\ \\ /',__\\\n \\ \\ \\_\\ \\/\\ \\/\\ \\/\\ \\ \\ \\/\\ __/\\ \\ \\//\\__, `\\/\\ \\__//\\ \\ \\ \\ \\ \\//\\ __/ __ \\ \\ \\/\\__, `\\\n \\ \\____/\\ \\_\\ \\_\\ \\___,_\\ \\____\\\\ \\_\\\\/\\____/\\ \\____\\ \\____/\\ \\_\\\\ \\____\\/\\_\\ _\\ \\ \\/\\____/\n \\/___/ \\/_/\\/_/\\/__,_ /\\/____/ \\/_/ \\/___/ \\/____/\\/___/ \\/_/ \\/____/\\/_//\\ \\_\\ \\/___/\n \\ \\____/\n \\/___/\n\nUnderscore.js is a utility-belt library for JavaScript that provides\nsupport for the usual functional suspects (each, map, reduce, filter...)\nwithout extending any core JavaScript objects.\n\nFor Docs, License, Tests, and pre-packed downloads, see:\nhttp://underscorejs.org\n\nUnderscore is an open-sourced component of DocumentCloud:\nhttps://github.com/documentcloud\n\nMany thanks to our contributors:\nhttps://github.com/jashkenas/underscore/contributors\n",
|
||||
"readmeFilename": "README.md"
|
||||
}
|
||||
6
front-api/node_modules/backbone/node_modules/underscore/underscore-min.js
generated
vendored
Normal file
6
front-api/node_modules/backbone/node_modules/underscore/underscore-min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1415
front-api/node_modules/backbone/node_modules/underscore/underscore.js
generated
vendored
Normal file
1415
front-api/node_modules/backbone/node_modules/underscore/underscore.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
64
front-api/node_modules/backbone/package.json
generated
vendored
Normal file
64
front-api/node_modules/backbone/package.json
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
{
|
||||
"name": "backbone",
|
||||
"description": "Give your JS App some Backbone with Models, Views, Collections, and Events.",
|
||||
"url": "http://backbonejs.org",
|
||||
"keywords": [
|
||||
"model",
|
||||
"view",
|
||||
"controller",
|
||||
"router",
|
||||
"server",
|
||||
"client",
|
||||
"browser"
|
||||
],
|
||||
"author": {
|
||||
"name": "Jeremy Ashkenas",
|
||||
"email": "jeremy@documentcloud.org"
|
||||
},
|
||||
"dependencies": {
|
||||
"underscore": ">=1.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"phantomjs": "1.9.0-1",
|
||||
"docco": "0.6.1",
|
||||
"coffee-script": "1.6.1"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "phantomjs test/vendor/runner.js test/index.html?noglobals=true && coffee test/model.coffee",
|
||||
"build": "uglifyjs backbone.js --mangle --source-map backbone-min.map -o backbone-min.js",
|
||||
"doc": "docco backbone.js && docco examples/todos/todos.js examples/backbone.localstorage.js",
|
||||
"lint": "jsl -nofilelisting -nologo -conf docs/jsl.conf -process backbone.js"
|
||||
},
|
||||
"main": "backbone.js",
|
||||
"version": "1.1.2",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jashkenas/backbone.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/jashkenas/backbone/issues"
|
||||
},
|
||||
"homepage": "https://github.com/jashkenas/backbone",
|
||||
"_id": "backbone@1.1.2",
|
||||
"dist": {
|
||||
"shasum": "c2c04c66bf87268fb82c177acebeff7d37ba6f2d",
|
||||
"tarball": "http://registry.npmjs.org/backbone/-/backbone-1.1.2.tgz"
|
||||
},
|
||||
"_from": "backbone@>=1.0.0 <2.0.0",
|
||||
"_npmVersion": "1.3.21",
|
||||
"_npmUser": {
|
||||
"name": "jashkenas",
|
||||
"email": "jashkenas@gmail.com"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "jashkenas",
|
||||
"email": "jashkenas@gmail.com"
|
||||
}
|
||||
],
|
||||
"directories": {},
|
||||
"_shasum": "c2c04c66bf87268fb82c177acebeff7d37ba6f2d",
|
||||
"_resolved": "https://registry.npmjs.org/backbone/-/backbone-1.1.2.tgz",
|
||||
"readme": "ERROR: No README data found!"
|
||||
}
|
||||
@@ -28,8 +28,11 @@ var ItemWithDetailsPage = React.createClass({
|
||||
<div className="col-md-7">
|
||||
<h3> {this.state.item.get('name')} </h3>
|
||||
<div>
|
||||
|
||||
<div className='h4'> {this.state.item.get('list_price')} KM</div>
|
||||
<div className='h5'>{this.state.item.get('pricePerUnit')}</div>
|
||||
|
||||
|
||||
|
||||
<div> {this.state.item.get('description')}</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -4,16 +4,8 @@ var Globals = require('../globals');
|
||||
var Item = Backbone.Model.extend({
|
||||
urlRoot : Globals.ApiUrl + '/item',
|
||||
|
||||
getFrontEndUrl : function(withHashPrefix) {
|
||||
var hashPrefix = "";
|
||||
if (withHashPrefix) {
|
||||
hashPrefix = "#!/";
|
||||
}
|
||||
var slug = this.get('name').toLowerCase().replace(/\s+/g,"-");
|
||||
return hashPrefix + "artikal/" + this.get('id') + "/" + slug
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -1,9 +1,22 @@
|
||||
var Backbone = require('backbone');
|
||||
var Globals = require('../globals');
|
||||
var Mutators = require('backbone.mutators');
|
||||
|
||||
var ItemWithDetails = Backbone.Model.extend({
|
||||
urlRoot : Globals.ApiUrl + '/item'
|
||||
|
||||
urlRoot: Globals.ApiUrl + '/item',
|
||||
mutators: {
|
||||
pricePerUnit: function() {
|
||||
var unitsInPack = this.get('units_in_pack');
|
||||
if (unitsInPack == undefined || unitsInPack <= 1) return "";
|
||||
unitsInPack = parseFloat(unitsInPack).toFixed(0);
|
||||
var price = parseFloat(this.get('list_price')).toFixed(2)
|
||||
var pricePerUnit = (price / unitsInPack).toFixed(2);
|
||||
var descriptionSuffix = this.get('unit').description_suffix;
|
||||
return (+pricePerUnit).toString() + " KM " + descriptionSuffix;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
module.exports = ItemWithDetails;
|
||||
|
||||
module.exports = ItemWithDetails;
|
||||
@@ -19,9 +19,9 @@
|
||||
"grunt-contrib-connect": "~0.9.0",
|
||||
"grunt-contrib-uglify": "~0.7.0",
|
||||
"grunt-contrib-watch": "~0.6.1",
|
||||
"merry-go-round": "^0.1.1",
|
||||
"reactify": "~0.17.1",
|
||||
"underscore": "^1.7.0"
|
||||
"underscore": "^1.7.0",
|
||||
"Backbone.Mutators": "~0.4.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "~0.12.2",
|
||||
|
||||
Reference in New Issue
Block a user