From 201464cb44fb062e3704092f76a28fdeb916ae9c Mon Sep 17 00:00:00 2001
From: Shannon
Date: Fri, 2 Jan 2015 14:25:11 +1100
Subject: [PATCH] Fixes: U4-5918 Update Underscore.js and also updates our
usage of bower with the correct grunt-bower plugin, this massively simplifies
bower usage and paves the way to start using bower for all JS components.
---
src/Umbraco.Web.UI.Client/bower.json | 52 +-
src/Umbraco.Web.UI.Client/gruntFile.js | 844 ++++++------
.../lib/underscore/underscore-min.js | 5 -
.../lib/underscore/underscore.js | 1189 -----------------
src/Umbraco.Web.UI.Client/package.json | 97 +-
.../src/canvasdesigner.loader.js | 2 +-
.../src/canvasdesigner/index.html | 2 +-
.../src/common/services/assets.service.js | 6 +-
src/Umbraco.Web.UI.Client/src/index.html | 8 +-
.../src/install.loader.js | 2 +-
.../src/installer/installer.html | 6 +-
src/Umbraco.Web.UI.Client/src/loader.js | 2 +-
.../propertyeditors/tags/tags.controller.js | 2 +-
.../test/config/karma.conf.js | 4 +-
.../Umbraco/Views/AuthorizeUpgrade.cshtml | 2 +-
.../Umbraco/js/install.loader.js | 2 +-
.../umbraco/Install/Views/Index.cshtml | 2 +-
.../umbraco/Views/Default.cshtml | 2 +-
src/Umbraco.Web/UI/JavaScript/JsInitialize.js | 2 +-
19 files changed, 516 insertions(+), 1715 deletions(-)
delete mode 100644 src/Umbraco.Web.UI.Client/lib/underscore/underscore-min.js
delete mode 100644 src/Umbraco.Web.UI.Client/lib/underscore/underscore.js
diff --git a/src/Umbraco.Web.UI.Client/bower.json b/src/Umbraco.Web.UI.Client/bower.json
index 9a48d14d7a..d1e0efd476 100644
--- a/src/Umbraco.Web.UI.Client/bower.json
+++ b/src/Umbraco.Web.UI.Client/bower.json
@@ -1,22 +1,34 @@
{
- "name": "Umbraco",
- "version": "7",
- "homepage": "https://github.com/umbraco/Umbraco-CMS",
- "authors": [
- "Shannon "
- ],
- "description": "Umbraco CMS",
- "license": "MIT",
- "private": true,
- "ignore": [
- "**/.*",
- "node_modules",
- "bower_components",
- "test",
- "tests"
- ],
- "dependencies": {
- "typeahead.js": "~0.10.5",
- "rgrove-lazyload": "*"
- }
+ "name": "Umbraco",
+ "version": "7",
+ "homepage": "https://github.com/umbraco/Umbraco-CMS",
+ "authors": [
+ "Shannon "
+ ],
+ "description": "Umbraco CMS",
+ "license": "MIT",
+ "private": true,
+ "ignore": [
+ "**/.*",
+ "node_modules",
+ "bower_components",
+ "test",
+ "tests"
+ ],
+ "dependencies": {
+ "typeahead.js": "~0.10.5",
+ "underscore": "~1.7.0",
+ "rgrove-lazyload": "*"
+ },
+ "exportsOverride": {
+ "rgrove-lazyload": {
+ "": "lazyload.js"
+ },
+ "typeahead.js": {
+ "": "dist/typeahead.bundle.min.js"
+ },
+ "underscore": {
+ "": "underscore-min.{js,map}"
+ }
+ }
}
diff --git a/src/Umbraco.Web.UI.Client/gruntFile.js b/src/Umbraco.Web.UI.Client/gruntFile.js
index 76028f1f04..ef636d2ada 100644
--- a/src/Umbraco.Web.UI.Client/gruntFile.js
+++ b/src/Umbraco.Web.UI.Client/gruntFile.js
@@ -1,463 +1,445 @@
module.exports = function (grunt) {
+
- // Default task.
- grunt.registerTask('default', ['jshint:dev','build','karma:unit']);
+ // Default task.
+ grunt.registerTask('default', ['jshint:dev', 'build', 'karma:unit']);
grunt.registerTask('dev', ['jshint:dev', 'build-dev', 'webserver', 'open:dev', 'watch']);
grunt.registerTask('docserve', ['docs:api', 'connect:docserver', 'open:docs', 'watch:docs']);
grunt.registerTask('vs', ['jshint:dev', 'build-dev', 'watch']);
//TODO: Too much watching, this brings windows to it's knees when in dev mode
- //run by the watch task
- grunt.registerTask('watch-js', ['jshint:dev','concat','copy:app','copy:mocks','copy:canvasdesigner','copy:vs', 'karma:unit']);
- grunt.registerTask('watch-less', ['recess:build', 'recess:installer', 'recess:canvasdesigner','copy:canvasdesigner', 'copy:assets', 'copy:vs']);
- grunt.registerTask('watch-html', ['copy:views', 'copy:vs']);
- grunt.registerTask('watch-installer', ['concat:install', 'concat:installJs', 'copy:installer', 'copy:vs']);
- grunt.registerTask('watch-canvasdesigner', ['copy:canvasdesigner', 'concat:canvasdesignerJs', 'copy:vs']);
- grunt.registerTask('watch-test', ['jshint:dev', 'karma:unit']);
+ //run by the watch task
+ grunt.registerTask('watch-js', ['jshint:dev', 'concat', 'copy:app', 'copy:mocks', 'copy:canvasdesigner', 'copy:vs', 'karma:unit']);
+ grunt.registerTask('watch-less', ['recess:build', 'recess:installer', 'recess:canvasdesigner', 'copy:canvasdesigner', 'copy:assets', 'copy:vs']);
+ grunt.registerTask('watch-html', ['copy:views', 'copy:vs']);
+ grunt.registerTask('watch-installer', ['concat:install', 'concat:installJs', 'copy:installer', 'copy:vs']);
+ grunt.registerTask('watch-canvasdesigner', ['copy:canvasdesigner', 'concat:canvasdesignerJs', 'copy:vs']);
+ grunt.registerTask('watch-test', ['jshint:dev', 'karma:unit']);
- //triggered from grunt dev or grunt
- grunt.registerTask('build', ['clean', 'concat', 'recess:min', 'recess:installer', 'recess:canvasdesigner', 'bower', 'copy']);
-
- //build-dev doesn't min - we are trying to speed this up and we don't want minified stuff when we are in dev mode
- grunt.registerTask('build-dev', ['clean', 'concat', 'recess:build', 'recess:installer', 'copy']);
+ //triggered from grunt dev or grunt
+ grunt.registerTask('build', ['clean', 'concat', 'recess:min', 'recess:installer', 'recess:canvasdesigner', 'bower', 'copy']);
- //utillity tasks
- grunt.registerTask('docs', ['ngdocs']);
- grunt.registerTask('webserver', ['connect:devserver']);
+ //build-dev doesn't min - we are trying to speed this up and we don't want minified stuff when we are in dev mode
+ grunt.registerTask('build-dev', ['clean', 'concat', 'recess:build', 'recess:installer', 'bower', 'copy']);
+
+ //utillity tasks
+ grunt.registerTask('docs', ['ngdocs']);
+ grunt.registerTask('webserver', ['connect:devserver']);
- // Print a timestamp (useful for when watching)
- grunt.registerTask('timestamp', function() {
- grunt.log.subhead(Date());
- });
+ // Print a timestamp (useful for when watching)
+ grunt.registerTask('timestamp', function () {
+ grunt.log.subhead(Date());
+ });
- // Custom task to run the bower dependency installer
- // tried, a few other things but this seems to work the best.
- // https://coderwall.com/p/xnkdqw
- grunt.registerTask('bower', 'Get js packages listed in bower.json',
- function () {
- var bower = require('bower');
- var done = this.async();
-
- bower.commands.install(undefined, { }, { interactive: false })
- .on('log', function (data) {
- grunt.log.write(data.message + "\n");
- })
- .on('error', function (data) {
- grunt.log.write(data.message + "\n");
- done(false);
- })
- .on('end', function (data) {
- done();
- });
- }
- );
-
-
- // Project configuration.
- grunt.initConfig({
- buildVersion: grunt.option('buildversion') || '7',
- connect: {
- devserver: {
- options: {
- port: 9990,
- hostname: '0.0.0.0',
- base: './build',
- middleware: function(connect, options){
- return [
- //uncomment to enable CSP
- // util.csp(),
- //util.rewrite(),
- connect.favicon('images/favicon.ico'),
- connect.static(options.base),
- connect.directory(options.base)
- ];
- }
- }
- },
- testserver: {},
- docserver: {
- options: {
- port: 8880,
- hostname: '0.0.0.0',
- base: './docs/api',
- middleware: function(connect, options){
- return [
- //uncomment to enable CSP
- // util.csp(),
- //util.rewrite(),
- connect.static(options.base),
- connect.directory(options.base)
- ];
- }
- }
- },
- },
-
- open : {
- dev : {
- path: 'http://localhost:9990/belle/'
- },
- docs : {
- path: 'http://localhost:8880/index.html'
- }
- },
-
- distdir: 'build/belle',
- bowerfiles: 'bower_components',
- vsdir: '../Umbraco.Web.UI/umbraco',
- pkg: grunt.file.readJSON('package.json'),
- banner:
- '/*! <%= pkg.title || pkg.name %>\n' +
- '<%= pkg.homepage ? " * " + pkg.homepage + "\\n" : "" %>' +
- ' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %>;\n' +
- ' * Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %>\n */\n',
- src: {
- js: ['src/**/*.js', 'src/*.js'],
- common: ['src/common/**/*.js'],
- specs: ['test/**/*.spec.js'],
- scenarios: ['test/**/*.scenario.js'],
- samples: ['sample files/*.js'],
- html: ['src/index.html','src/install.html'],
-
- everything:['src/**/*.*', 'test/**/*.*', 'docs/**/*.*'],
-
- tpl: {
- app: ['src/views/**/*.html'],
- common: ['src/common/**/*.tpl.html']
- },
- less: ['src/less/belle.less'], // recess:build doesn't accept ** in its file patterns
- prod: ['<%= distdir %>/js/*.js']
- },
-
- clean: ['<%= distdir %>/*'],
-
- copy: {
- assets: {
- files: [{ dest: '<%= distdir %>/assets', src : '**', expand: true, cwd: 'src/assets/' }]
- },
-
- config: {
- files: [{ dest: '<%= distdir %>/../config', src : '**', expand: true, cwd: 'src/config/' }]
- },
-
- // Copies over the files downloaded by bower
- bower: {
- files: [
- {
- dest: '<%= distdir %>/lib/typeahead/typeahead.bundle.min.js',
- src: 'bower_components/typeahead.js/dist/typeahead.bundle.min.js'
- },
- {
- dest: '<%= distdir %>/lib/lazyload/lazyload.min.js',
- src: 'bower_components/rgrove-lazyload/lazyload.js'
+ // Project configuration.
+ grunt.initConfig({
+ buildVersion: grunt.option('buildversion') || '7',
+ connect: {
+ devserver: {
+ options: {
+ port: 9990,
+ hostname: '0.0.0.0',
+ base: './build',
+ middleware: function (connect, options) {
+ return [
+ //uncomment to enable CSP
+ // util.csp(),
+ //util.rewrite(),
+ connect.favicon('images/favicon.ico'),
+ connect.static(options.base),
+ connect.directory(options.base)
+ ];
+ }
}
- ]
- },
-
-
- installer: {
- files: [{ dest: '<%= distdir %>/views/install', src : '**/*.html', expand: true, cwd: 'src/installer/steps' }]
- },
-
- canvasdesigner: {
- files: [
- { dest: '<%= distdir %>/preview', src: '**/*.html', expand: true, cwd: 'src/canvasdesigner' },
- { dest: '<%= distdir %>/preview/editors', src: '**/*.html', expand: true, cwd: 'src/canvasdesigner/editors' },
- { dest: '<%= distdir %>/assets/less', src: '**/*.less', expand: true, cwd: 'src/canvasdesigner/editors' },
- { dest: '<%= distdir %>/js', src: 'canvasdesigner.config.js', expand: true, cwd: 'src/canvasdesigner/config' },
- { dest: '<%= distdir %>/js', src: 'canvasdesigner.palettes.js', expand: true, cwd: 'src/canvasdesigner/config' },
- { dest: '<%= distdir %>/js', src: 'canvasdesigner.front.js', expand: true, cwd: 'src/canvasdesigner' }
- ]
- },
-
- vendor: {
- files: [{ dest: '<%= distdir %>/lib', src : '**', expand: true, cwd: 'lib/' }]
- },
- views: {
- files: [{ dest: '<%= distdir %>/views', src : ['**/*.*', '!**/*.controller.js'], expand: true, cwd: 'src/views/' }]
- },
- app: {
- files: [
- { dest: '<%= distdir %>/js', src : '*.js', expand: true, cwd: 'src/' }
- ]
- },
- mocks: {
- files: [{ dest: '<%= distdir %>/js', src : '*.js', expand: true, cwd: 'src/common/mocks/' }]
- },
- vs: {
- files: [
- //everything except the index.html root file!
- //then we need to figure out how to not copy all the test stuff either!?
- { dest: '<%= vsdir %>/assets', src: '**', expand: true, cwd: '<%= distdir %>/assets' },
- { dest: '<%= vsdir %>/js', src: '**', expand: true, cwd: '<%= distdir %>/js' },
- { dest: '<%= vsdir %>/lib', src: '**', expand: true, cwd: '<%= distdir %>/lib' },
- { dest: '<%= vsdir %>/views', src: '**', expand: true, cwd: '<%= distdir %>/views' },
- { dest: '<%= vsdir %>/preview', src: '**', expand: true, cwd: '<%= distdir %>/preview' }
- ]
- }
- },
-
- karma: {
- unit: { configFile: 'test/config/karma.conf.js', keepalive: true },
- e2e: { configFile: 'test/config/e2e.js', keepalive: true },
- watch: { configFile: 'test/config/unit.js', singleRun:false, autoWatch: true, keepalive: true }
- },
-
- concat:{
- index: {
- src: ['src/index.html'],
- dest: '<%= distdir %>/index.html',
- options: {
- process: true
- }
- },
- install: {
- src: ['src/installer/installer.html'],
- dest: '<%= distdir %>/installer.html',
- options: {
- process: true
- }
+ },
+ testserver: {},
+ docserver: {
+ options: {
+ port: 8880,
+ hostname: '0.0.0.0',
+ base: './docs/api',
+ middleware: function (connect, options) {
+ return [
+ //uncomment to enable CSP
+ // util.csp(),
+ //util.rewrite(),
+ connect.static(options.base),
+ connect.directory(options.base)
+ ];
+ }
+ }
+ },
},
- installJs: {
- src: ['src/installer/**/*.js'],
- dest: '<%= distdir %>/js/umbraco.installer.js',
- options: {
- banner: "<%= banner %>\n(function() { \n\n angular.module('umbraco.install', []); \n",
- footer: "\n\n})();"
- }
+ open: {
+ dev: {
+ path: 'http://localhost:9990/belle/'
+ },
+ docs: {
+ path: 'http://localhost:8880/index.html'
+ }
},
- canvasdesignerJs: {
- src: ['src/canvasdesigner/canvasdesigner.global.js', 'src/canvasdesigner/canvasdesigner.controller.js', 'src/canvasdesigner/editors/*.js', 'src/canvasdesigner/lib/*.js'],
- dest: '<%= distdir %>/js/canvasdesigner.panel.js'
+
+ distdir: 'build/belle',
+ vsdir: '../Umbraco.Web.UI/umbraco',
+ pkg: grunt.file.readJSON('package.json'),
+ banner:
+ '/*! <%= pkg.title || pkg.name %>\n' +
+ '<%= pkg.homepage ? " * " + pkg.homepage + "\\n" : "" %>' +
+ ' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %>;\n' +
+ ' * Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %>\n */\n',
+ src: {
+ js: ['src/**/*.js', 'src/*.js'],
+ common: ['src/common/**/*.js'],
+ specs: ['test/**/*.spec.js'],
+ scenarios: ['test/**/*.scenario.js'],
+ samples: ['sample files/*.js'],
+ html: ['src/index.html', 'src/install.html'],
+
+ everything: ['src/**/*.*', 'test/**/*.*', 'docs/**/*.*'],
+
+ tpl: {
+ app: ['src/views/**/*.html'],
+ common: ['src/common/**/*.tpl.html']
+ },
+ less: ['src/less/belle.less'], // recess:build doesn't accept ** in its file patterns
+ prod: ['<%= distdir %>/js/*.js']
},
- controllers: {
- src:['src/controllers/**/*.controller.js','src/views/**/*.controller.js'],
- dest: '<%= distdir %>/js/umbraco.controllers.js',
- options: {
- banner: "<%= banner %>\n(function() { \n\n",
- footer: "\n\n})();"
- }
+
+ clean: ['<%= distdir %>/*'],
+
+ copy: {
+ assets: {
+ files: [{ dest: '<%= distdir %>/assets', src: '**', expand: true, cwd: 'src/assets/' }]
+ },
+
+ config: {
+ files: [{ dest: '<%= distdir %>/../config', src: '**', expand: true, cwd: 'src/config/' }]
+ },
+
+ installer: {
+ files: [{ dest: '<%= distdir %>/views/install', src: '**/*.html', expand: true, cwd: 'src/installer/steps' }]
+ },
+
+ canvasdesigner: {
+ files: [
+ { dest: '<%= distdir %>/preview', src: '**/*.html', expand: true, cwd: 'src/canvasdesigner' },
+ { dest: '<%= distdir %>/preview/editors', src: '**/*.html', expand: true, cwd: 'src/canvasdesigner/editors' },
+ { dest: '<%= distdir %>/assets/less', src: '**/*.less', expand: true, cwd: 'src/canvasdesigner/editors' },
+ { dest: '<%= distdir %>/js', src: 'canvasdesigner.config.js', expand: true, cwd: 'src/canvasdesigner/config' },
+ { dest: '<%= distdir %>/js', src: 'canvasdesigner.palettes.js', expand: true, cwd: 'src/canvasdesigner/config' },
+ { dest: '<%= distdir %>/js', src: 'canvasdesigner.front.js', expand: true, cwd: 'src/canvasdesigner' }
+ ]
+ },
+
+ vendor: {
+ files: [{ dest: '<%= distdir %>/lib', src: '**', expand: true, cwd: 'lib/' }]
+ },
+ views: {
+ files: [{ dest: '<%= distdir %>/views', src: ['**/*.*', '!**/*.controller.js'], expand: true, cwd: 'src/views/' }]
+ },
+ app: {
+ files: [
+ { dest: '<%= distdir %>/js', src: '*.js', expand: true, cwd: 'src/' }
+ ]
+ },
+ mocks: {
+ files: [{ dest: '<%= distdir %>/js', src: '*.js', expand: true, cwd: 'src/common/mocks/' }]
+ },
+ vs: {
+ files: [
+ //everything except the index.html root file!
+ //then we need to figure out how to not copy all the test stuff either!?
+ { dest: '<%= vsdir %>/assets', src: '**', expand: true, cwd: '<%= distdir %>/assets' },
+ { dest: '<%= vsdir %>/js', src: '**', expand: true, cwd: '<%= distdir %>/js' },
+ { dest: '<%= vsdir %>/views', src: '**', expand: true, cwd: '<%= distdir %>/views' },
+ { dest: '<%= vsdir %>/preview', src: '**', expand: true, cwd: '<%= distdir %>/preview' },
+ { dest: '<%= vsdir %>/lib', src: '**', expand: true, cwd: '<%= distdir %>/lib' }
+ ]
+ }
},
- services: {
- src:['src/common/services/*.js'],
- dest: '<%= distdir %>/js/umbraco.services.js',
- options: {
- banner: "<%= banner %>\n(function() { \n\n",
- footer: "\n\n})();"
- }
+
+ karma: {
+ unit: { configFile: 'test/config/karma.conf.js', keepalive: true },
+ e2e: { configFile: 'test/config/e2e.js', keepalive: true },
+ watch: { configFile: 'test/config/unit.js', singleRun: false, autoWatch: true, keepalive: true }
},
- security: {
- src:['src/common/security/*.js'],
- dest: '<%= distdir %>/js/umbraco.security.js',
- options: {
- banner: "<%= banner %>\n(function() { \n\n",
- footer: "\n\n})();"
- }
+
+ concat: {
+ index: {
+ src: ['src/index.html'],
+ dest: '<%= distdir %>/index.html',
+ options: {
+ process: true
+ }
+ },
+ install: {
+ src: ['src/installer/installer.html'],
+ dest: '<%= distdir %>/installer.html',
+ options: {
+ process: true
+ }
+ },
+
+ installJs: {
+ src: ['src/installer/**/*.js'],
+ dest: '<%= distdir %>/js/umbraco.installer.js',
+ options: {
+ banner: "<%= banner %>\n(function() { \n\n angular.module('umbraco.install', []); \n",
+ footer: "\n\n})();"
+ }
+ },
+ canvasdesignerJs: {
+ src: ['src/canvasdesigner/canvasdesigner.global.js', 'src/canvasdesigner/canvasdesigner.controller.js', 'src/canvasdesigner/editors/*.js', 'src/canvasdesigner/lib/*.js'],
+ dest: '<%= distdir %>/js/canvasdesigner.panel.js'
+ },
+ controllers: {
+ src: ['src/controllers/**/*.controller.js', 'src/views/**/*.controller.js'],
+ dest: '<%= distdir %>/js/umbraco.controllers.js',
+ options: {
+ banner: "<%= banner %>\n(function() { \n\n",
+ footer: "\n\n})();"
+ }
+ },
+ services: {
+ src: ['src/common/services/*.js'],
+ dest: '<%= distdir %>/js/umbraco.services.js',
+ options: {
+ banner: "<%= banner %>\n(function() { \n\n",
+ footer: "\n\n})();"
+ }
+ },
+ security: {
+ src: ['src/common/security/*.js'],
+ dest: '<%= distdir %>/js/umbraco.security.js',
+ options: {
+ banner: "<%= banner %>\n(function() { \n\n",
+ footer: "\n\n})();"
+ }
+ },
+ resources: {
+ src: ['src/common/resources/*.js'],
+ dest: '<%= distdir %>/js/umbraco.resources.js',
+ options: {
+ banner: "<%= banner %>\n(function() { \n\n",
+ footer: "\n\n})();"
+ }
+ },
+ testing: {
+ src: ['src/common/mocks/*/*.js'],
+ dest: '<%= distdir %>/js/umbraco.testing.js',
+ options: {
+ banner: "<%= banner %>\n(function() { \n\n",
+ footer: "\n\n})();"
+ }
+ },
+ directives: {
+ src: ['src/common/directives/**/*.js'],
+ dest: '<%= distdir %>/js/umbraco.directives.js',
+ options: {
+ banner: "<%= banner %>\n(function() { \n\n",
+ footer: "\n\n})();"
+ }
+ },
+ filters: {
+ src: ['src/common/filters/*.js'],
+ dest: '<%= distdir %>/js/umbraco.filters.js',
+ options: {
+ banner: "<%= banner %>\n(function() { \n\n",
+ footer: "\n\n})();"
+ }
+ }
},
- resources: {
- src:['src/common/resources/*.js'],
- dest: '<%= distdir %>/js/umbraco.resources.js',
- options: {
- banner: "<%= banner %>\n(function() { \n\n",
- footer: "\n\n})();"
- }
+
+ uglify: {
+ options: {
+ mangle: true
+ },
+ combine: {
+ files: {
+ '<%= distdir %>/js/umbraco.min.js': ['<%= distdir %>/js/umbraco.*.js']
+ }
+ }
},
- testing: {
- src:['src/common/mocks/*/*.js'],
- dest: '<%= distdir %>/js/umbraco.testing.js',
- options: {
- banner: "<%= banner %>\n(function() { \n\n",
- footer: "\n\n})();"
- }
+
+ recess: {
+ build: {
+ files: {
+ '<%= distdir %>/assets/css/<%= pkg.name %>.css':
+ ['<%= src.less %>']
+ },
+ options: {
+ compile: true
+ }
+ },
+ installer: {
+ files: {
+ '<%= distdir %>/assets/css/installer.css':
+ ['src/less/installer.less']
+ },
+ options: {
+ compile: true
+ }
+ },
+ canvasdesigner: {
+ files: {
+ '<%= distdir %>/assets/css/canvasdesigner.css':
+ ['src/less/canvasdesigner.less', 'src/less/helveticons.less']
+ },
+ options: {
+ compile: true
+ }
+ },
+ min: {
+ files: {
+ '<%= distdir %>/assets/css/<%= pkg.name %>.css': ['<%= src.less %>']
+ },
+ options: {
+ compile: true,
+ compress: true
+ }
+ }
},
- directives: {
- src:['src/common/directives/**/*.js'],
- dest: '<%= distdir %>/js/umbraco.directives.js',
- options: {
- banner: "<%= banner %>\n(function() { \n\n",
- footer: "\n\n})();"
- }
+
+
+ watch: {
+ css: {
+ files: 'src/**/*.less',
+ tasks: ['watch-less', 'timestamp'],
+ options: {
+ livereload: true,
+ },
+ },
+ js: {
+ files: ['src/**/*.js', 'src/*.js'],
+ tasks: ['watch-js', 'timestamp'],
+ },
+ test: {
+ files: ['test/**/*.js'],
+ tasks: ['watch-test', 'timestamp'],
+ },
+ installer: {
+ files: ['src/installer/**/*.*'],
+ tasks: ['watch-installer', 'timestamp'],
+ },
+ canvasdesigner: {
+ files: ['src/canvasdesigner/**/*.*'],
+ tasks: ['watch-canvasdesigner', 'timestamp'],
+ },
+ html: {
+ files: ['src/views/**/*.html', 'src/*.html'],
+ tasks: ['watch-html', 'timestamp']
+ }
},
- filters: {
- src:['src/common/filters/*.js'],
- dest: '<%= distdir %>/js/umbraco.filters.js',
- options: {
- banner: "<%= banner %>\n(function() { \n\n",
- footer: "\n\n})();"
- }
+
+
+ ngdocs: {
+ options: {
+ dest: 'docs/api',
+ startPage: '/api',
+ title: "Umbraco 7",
+ html5Mode: false,
+ },
+ api: {
+ src: ['src/common/**/*.js', 'docs/src/api/**/*.ngdoc'],
+ title: 'API Documentation'
+ },
+ tutorials: {
+ src: ['docs/src/tutorials/**/*.ngdoc'],
+ title: 'Tutorials'
+ }
+ },
+
+ jshint: {
+ dev: {
+ files: {
+ src: ['<%= src.common %>', '<%= src.specs %>', '<%= src.scenarios %>', '<%= src.samples %>']
+ },
+ options: {
+ curly: true,
+ eqeqeq: true,
+ immed: true,
+ latedef: true,
+ newcap: true,
+ noarg: true,
+ sub: true,
+ boss: true,
+ //NOTE: This is required so it doesn't barf on reserved words like delete when doing $http.delete
+ es5: true,
+ eqnull: true,
+ //NOTE: we need to use eval sometimes so ignore it
+ evil: true,
+ //NOTE: we need to check for strings such as "javascript:" so don't throw errors regarding those
+ scripturl: true,
+ //NOTE: we ignore tabs vs spaces because enforcing that causes lots of errors depending on the text editor being used
+ smarttabs: true,
+ globals: {}
+ }
+ },
+ build: {
+ files: {
+ src: ['<%= src.prod %>']
+ },
+ options: {
+ curly: true,
+ eqeqeq: true,
+ immed: true,
+ latedef: true,
+ newcap: true,
+ noarg: true,
+ sub: true,
+ boss: true,
+ //NOTE: This is required so it doesn't barf on reserved words like delete when doing $http.delete
+ es5: true,
+ eqnull: true,
+ //NOTE: we need to use eval sometimes so ignore it
+ evil: true,
+ //NOTE: we need to check for strings such as "javascript:" so don't throw errors regarding those
+ scripturl: true,
+ //NOTE: we ignore tabs vs spaces because enforcing that causes lots of errors depending on the text editor being used
+ smarttabs: true,
+ globalstrict: true,
+ globals: { $: false, jQuery: false, define: false, require: false, window: false }
+ }
+ }
+ },
+
+ bower: {
+ install: {
+ options: {
+ targetDir: "<%= distdir %>/lib",
+ cleanTargetDir: false,
+ layout: function (type, component, source) {
+
+ var path = require('path');
+
+ //this is the same as 'byComponent', however we will not allow
+ // folders with '.' in them since the grunt copy task does not like that
+ var componentWithoutPeriod = component.replace(".", "-");
+ return path.join(componentWithoutPeriod, type);
+ }
+ }
+ }
}
- },
-
- uglify: {
- options: {
- mangle: true
- },
- combine: {
- files: {
- '<%= distdir %>/js/umbraco.min.js': ['<%= distdir %>/js/umbraco.*.js']
- }
- }
- },
-
- recess: {
- build: {
- files: {
- '<%= distdir %>/assets/css/<%= pkg.name %>.css':
- ['<%= src.less %>'] },
- options: {
- compile: true
- }
- },
- installer: {
- files: {
- '<%= distdir %>/assets/css/installer.css':
- ['src/less/installer.less'] },
- options: {
- compile: true
- }
- },
- canvasdesigner: {
- files: {
- '<%= distdir %>/assets/css/canvasdesigner.css':
- ['src/less/canvasdesigner.less', 'src/less/helveticons.less']
- },
- options: {
- compile: true
- }
- },
- min: {
- files: {
- '<%= distdir %>/assets/css/<%= pkg.name %>.css': ['<%= src.less %>']
- },
- options: {
- compile: true,
- compress: true
- }
- }
- },
-
-
- watch:{
- css: {
- files: 'src/**/*.less',
- tasks: ['watch-less', 'timestamp'],
- options: {
- livereload: true,
- },
- },
- js: {
- files: ['src/**/*.js', 'src/*.js'],
- tasks: ['watch-js', 'timestamp'],
- },
- test: {
- files: ['test/**/*.js'],
- tasks: ['watch-test', 'timestamp'],
- },
- installer: {
- files: ['src/installer/**/*.*'],
- tasks: ['watch-installer', 'timestamp'],
- },
- canvasdesigner: {
- files: ['src/canvasdesigner/**/*.*'],
- tasks: ['watch-canvasdesigner', 'timestamp'],
- },
- html: {
- files: ['src/views/**/*.html', 'src/*.html'],
- tasks:['watch-html','timestamp']
- }
- },
-
-
- ngdocs: {
- options: {
- dest: 'docs/api',
- startPage: '/api',
- title: "Umbraco 7",
- html5Mode: false,
- },
- api: {
- src: ['src/common/**/*.js', 'docs/src/api/**/*.ngdoc'],
- title: 'API Documentation'
- },
- tutorials: {
- src: ['docs/src/tutorials/**/*.ngdoc'],
- title: 'Tutorials'
- }
- },
-
- jshint:{
- dev:{
- files: {
- src: ['<%= src.common %>', '<%= src.specs %>', '<%= src.scenarios %>', '<%= src.samples %>']
- },
- options:{
- curly:true,
- eqeqeq:true,
- immed:true,
- latedef:true,
- newcap:true,
- noarg:true,
- sub:true,
- boss: true,
- //NOTE: This is required so it doesn't barf on reserved words like delete when doing $http.delete
- es5: true,
- eqnull: true,
- //NOTE: we need to use eval sometimes so ignore it
- evil: true,
- //NOTE: we need to check for strings such as "javascript:" so don't throw errors regarding those
- scripturl: true,
- //NOTE: we ignore tabs vs spaces because enforcing that causes lots of errors depending on the text editor being used
- smarttabs: true,
- globals:{}
- }
- },
- build:{
- files: {
- src: ['<%= src.prod %>']
- },
- options:{
- curly:true,
- eqeqeq:true,
- immed:true,
- latedef:true,
- newcap:true,
- noarg:true,
- sub:true,
- boss: true,
- //NOTE: This is required so it doesn't barf on reserved words like delete when doing $http.delete
- es5: true,
- eqnull: true,
- //NOTE: we need to use eval sometimes so ignore it
- evil: true,
- //NOTE: we need to check for strings such as "javascript:" so don't throw errors regarding those
- scripturl: true,
- //NOTE: we ignore tabs vs spaces because enforcing that causes lots of errors depending on the text editor being used
- smarttabs: true,
- globalstrict:true,
- globals:{$:false, jQuery:false,define:false,require:false,window:false}
- }
- }
- }
- });
+ });
- grunt.loadNpmTasks('grunt-contrib-concat');
- grunt.loadNpmTasks('grunt-contrib-jshint');
- grunt.loadNpmTasks('grunt-contrib-clean');
- grunt.loadNpmTasks('grunt-contrib-copy');
- grunt.loadNpmTasks('grunt-contrib-uglify');
- grunt.loadNpmTasks('grunt-contrib-watch');
- grunt.loadNpmTasks('grunt-recess');
+ grunt.loadNpmTasks('grunt-contrib-concat');
+ grunt.loadNpmTasks('grunt-contrib-jshint');
+ grunt.loadNpmTasks('grunt-contrib-clean');
+ grunt.loadNpmTasks('grunt-contrib-copy');
+ grunt.loadNpmTasks('grunt-contrib-uglify');
+ grunt.loadNpmTasks('grunt-contrib-watch');
+ grunt.loadNpmTasks('grunt-recess');
- grunt.loadNpmTasks('grunt-karma');
+ grunt.loadNpmTasks('grunt-karma');
- grunt.loadNpmTasks('grunt-open');
- grunt.loadNpmTasks('grunt-contrib-connect');
-
- grunt.loadNpmTasks('grunt-ngdocs');
+ grunt.loadNpmTasks('grunt-open');
+ grunt.loadNpmTasks('grunt-contrib-connect');
+ grunt.loadNpmTasks('grunt-bower-task');
+ grunt.loadNpmTasks('grunt-ngdocs');
};
diff --git a/src/Umbraco.Web.UI.Client/lib/underscore/underscore-min.js b/src/Umbraco.Web.UI.Client/lib/underscore/underscore-min.js
deleted file mode 100644
index 83292f0902..0000000000
--- a/src/Umbraco.Web.UI.Client/lib/underscore/underscore-min.js
+++ /dev/null
@@ -1,5 +0,0 @@
-// Underscore.js 1.4.1
-// http://underscorejs.org
-// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
-// Underscore may be freely distributed under the MIT license.
-(function(){var e=this,t=e._,n={},r=Array.prototype,i=Object.prototype,s=Function.prototype,o=r.push,u=r.slice,a=r.concat,f=r.unshift,l=i.toString,c=i.hasOwnProperty,h=r.forEach,p=r.map,d=r.reduce,v=r.reduceRight,m=r.filter,g=r.every,y=r.some,b=r.indexOf,w=r.lastIndexOf,E=Array.isArray,S=Object.keys,x=s.bind,T=function(e){if(e instanceof T)return e;if(!(this instanceof T))return new T(e);this._wrapped=e};typeof exports!="undefined"?(typeof module!="undefined"&&module.exports&&(exports=module.exports=T),exports._=T):e._=T,T.VERSION="1.4.1";var N=T.each=T.forEach=function(e,t,r){if(h&&e.forEach===h)e.forEach(t,r);else if(e.length===+e.length){for(var i=0,s=e.length;i2;if(d&&e.reduce===d)return r&&(t=T.bind(t,r)),i?e.reduce(t,n):e.reduce(t);N(e,function(e,s,o){i?n=t.call(r,n,e,s,o):(n=e,i=!0)});if(!i)throw new TypeError("Reduce of empty array with no initial value");return n},T.reduceRight=T.foldr=function(e,t,n,r){var i=arguments.length>2;if(v&&e.reduceRight===v)return r&&(t=T.bind(t,r)),arguments.length>2?e.reduceRight(t,n):e.reduceRight(t);var s=e.length;if(s!==+s){var o=T.keys(e);s=o.length}N(e,function(u,a,f){a=o?o[--s]:--s,i?n=t.call(r,n,e[a],a,f):(n=e[a],i=!0)});if(!i)throw new TypeError("Reduce of empty array with no initial value");return n},T.find=T.detect=function(e,t,n){var r;return C(e,function(e,i,s){if(t.call(n,e,i,s))return r=e,!0}),r},T.filter=T.select=function(e,t,n){var r=[];return m&&e.filter===m?e.filter(t,n):(N(e,function(e,i,s){t.call(n,e,i,s)&&(r[r.length]=e)}),r)},T.reject=function(e,t,n){var r=[];return N(e,function(e,i,s){t.call(n,e,i,s)||(r[r.length]=e)}),r},T.every=T.all=function(e,t,r){t||(t=T.identity);var i=!0;return g&&e.every===g?e.every(t,r):(N(e,function(e,s,o){if(!(i=i&&t.call(r,e,s,o)))return n}),!!i)};var C=T.some=T.any=function(e,t,r){t||(t=T.identity);var i=!1;return y&&e.some===y?e.some(t,r):(N(e,function(e,s,o){if(i||(i=t.call(r,e,s,o)))return n}),!!i)};T.contains=T.include=function(e,t){var n=!1;return b&&e.indexOf===b?e.indexOf(t)!=-1:(n=C(e,function(e){return e===t}),n)},T.invoke=function(e,t){var n=u.call(arguments,2);return T.map(e,function(e){return(T.isFunction(t)?t:e[t]).apply(e,n)})},T.pluck=function(e,t){return T.map(e,function(e){return e[t]})},T.where=function(e,t){return T.isEmpty(t)?[]:T.filter(e,function(e){for(var n in t)if(t[n]!==e[n])return!1;return!0})},T.max=function(e,t,n){if(!t&&T.isArray(e)&&e[0]===+e[0]&&e.length<65535)return Math.max.apply(Math,e);if(!t&&T.isEmpty(e))return-Infinity;var r={computed:-Infinity};return N(e,function(e,i,s){var o=t?t.call(n,e,i,s):e;o>=r.computed&&(r={value:e,computed:o})}),r.value},T.min=function(e,t,n){if(!t&&T.isArray(e)&&e[0]===+e[0]&&e.length<65535)return Math.min.apply(Math,e);if(!t&&T.isEmpty(e))return Infinity;var r={computed:Infinity};return N(e,function(e,i,s){var o=t?t.call(n,e,i,s):e;or||n===void 0)return 1;if(n>>1;n.call(r,e[u])=0})})},T.difference=function(e){var t=a.apply(r,u.call(arguments,1));return T.filter(e,function(e){return!T.contains(t,e)})},T.zip=function(){var e=u.call(arguments),t=T.max(T.pluck(e,"length")),n=new Array(t);for(var r=0;r=0;n--)t=[e[n].apply(this,t)];return t[0]}},T.after=function(e,t){return e<=0?t():function(){if(--e<1)return t.apply(this,arguments)}},T.keys=S||function(e){if(e!==Object(e))throw new TypeError("Invalid object");var t=[];for(var n in e)T.has(e,n)&&(t[t.length]=n);return t},T.values=function(e){var t=[];for(var n in e)T.has(e,n)&&t.push(e[n]);return t},T.pairs=function(e){var t=[];for(var n in e)T.has(e,n)&&t.push([n,e[n]]);return t},T.invert=function(e){var t={};for(var n in e)T.has(e,n)&&(t[e[n]]=n);return t},T.functions=T.methods=function(e){var t=[];for(var n in e)T.isFunction(e[n])&&t.push(n);return t.sort()},T.extend=function(e){return N(u.call(arguments,1),function(t){for(var n in t)e[n]=t[n]}),e},T.pick=function(e){var t={},n=a.apply(r,u.call(arguments,1));return N(n,function(n){n in e&&(t[n]=e[n])}),t},T.omit=function(e){var t={},n=a.apply(r,u.call(arguments,1));for(var i in e)T.contains(n,i)||(t[i]=e[i]);return t},T.defaults=function(e){return N(u.call(arguments,1),function(t){for(var n in t)e[n]==null&&(e[n]=t[n])}),e},T.clone=function(e){return T.isObject(e)?T.isArray(e)?e.slice():T.extend({},e):e},T.tap=function(e,t){return t(e),e};var M=function(e,t,n,r){if(e===t)return e!==0||1/e==1/t;if(e==null||t==null)return e===t;e instanceof T&&(e=e._wrapped),t instanceof T&&(t=t._wrapped);var i=l.call(e);if(i!=l.call(t))return!1;switch(i){case"[object String]":return e==String(t);case"[object Number]":return e!=+e?t!=+t:e==0?1/e==1/t:e==+t;case"[object Date]":case"[object Boolean]":return+e==+t;case"[object RegExp]":return e.source==t.source&&e.global==t.global&&e.multiline==t.multiline&&e.ignoreCase==t.ignoreCase}if(typeof e!="object"||typeof t!="object")return!1;var s=n.length;while(s--)if(n[s]==e)return r[s]==t;n.push(e),r.push(t);var o=0,u=!0;if(i=="[object Array]"){o=e.length,u=o==t.length;if(u)while(o--)if(!(u=M(e[o],t[o],n,r)))break}else{var a=e.constructor,f=t.constructor;if(a!==f&&!(T.isFunction(a)&&a instanceof a&&T.isFunction(f)&&f instanceof f))return!1;for(var c in e)if(T.has(e,c)){o++;if(!(u=T.has(t,c)&&M(e[c],t[c],n,r)))break}if(u){for(c in t)if(T.has(t,c)&&!(o--))break;u=!o}}return n.pop(),r.pop(),u};T.isEqual=function(e,t){return M(e,t,[],[])},T.isEmpty=function(e){if(e==null)return!0;if(T.isArray(e)||T.isString(e))return e.length===0;for(var t in e)if(T.has(e,t))return!1;return!0},T.isElement=function(e){return!!e&&e.nodeType===1},T.isArray=E||function(e){return l.call(e)=="[object Array]"},T.isObject=function(e){return e===Object(e)},N(["Arguments","Function","String","Number","Date","RegExp"],function(e){T["is"+e]=function(t){return l.call(t)=="[object "+e+"]"}}),T.isArguments(arguments)||(T.isArguments=function(e){return!!e&&!!T.has(e,"callee")}),typeof /./!="function"&&(T.isFunction=function(e){return typeof e=="function"}),T.isFinite=function(e){return T.isNumber(e)&&isFinite(e)},T.isNaN=function(e){return T.isNumber(e)&&e!=+e},T.isBoolean=function(e){return e===!0||e===!1||l.call(e)=="[object Boolean]"},T.isNull=function(e){return e===null},T.isUndefined=function(e){return e===void 0},T.has=function(e,t){return c.call(e,t)},T.noConflict=function(){return e._=t,this},T.identity=function(e){return e},T.times=function(e,t,n){for(var r=0;r":">",'"':""","'":"'","/":"/"}};_.unescape=T.invert(_.escape);var D={escape:new RegExp("["+T.keys(_.escape).join("")+"]","g"),unescape:new RegExp("("+T.keys(_.unescape).join("|")+")","g")};T.each(["escape","unescape"],function(e){T[e]=function(t){return t==null?"":(""+t).replace(D[e],function(t){return _[e][t]})}}),T.result=function(e,t){if(e==null)return null;var n=e[t];return T.isFunction(n)?n.call(e):n},T.mixin=function(e){N(T.functions(e),function(t){var n=T[t]=e[t];T.prototype[t]=function(){var e=[this._wrapped];return o.apply(e,arguments),F.call(this,n.apply(T,e))}})};var P=0;T.uniqueId=function(e){var t=P++;return e?e+t:t},T.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var H=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},j=/\\|'|\r|\n|\t|\u2028|\u2029/g;T.template=function(e,t,n){n=T.defaults({},n,T.templateSettings);var r=new RegExp([(n.escape||H).source,(n.interpolate||H).source,(n.evaluate||H).source].join("|")+"|$","g"),i=0,s="__p+='";e.replace(r,function(t,n,r,o,u){s+=e.slice(i,u).replace(j,function(e){return"\\"+B[e]}),s+=n?"'+\n((__t=("+n+"))==null?'':_.escape(__t))+\n'":r?"'+\n((__t=("+r+"))==null?'':__t)+\n'":o?"';\n"+o+"\n__p+='":"",i=u+t.length}),s+="';\n",n.variable||(s="with(obj||{}){\n"+s+"}\n"),s="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+s+"return __p;\n";try{var o=new Function(n.variable||"obj","_",s)}catch(u){throw u.source=s,u}if(t)return o(t,T);var a=function(e){return o.call(this,e,T)};return a.source="function("+(n.variable||"obj")+"){\n"+s+"}",a},T.chain=function(e){return T(e).chain()};var F=function(e){return this._chain?T(e).chain():e};T.mixin(T),N(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=r[e];T.prototype[e]=function(){var n=this._wrapped;return t.apply(n,arguments),(e=="shift"||e=="splice")&&n.length===0&&delete n[0],F.call(this,n)}}),N(["concat","join","slice"],function(e){var t=r[e];T.prototype[e]=function(){return F.call(this,t.apply(this._wrapped,arguments))}}),T.extend(T.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this);
\ No newline at end of file
diff --git a/src/Umbraco.Web.UI.Client/lib/underscore/underscore.js b/src/Umbraco.Web.UI.Client/lib/underscore/underscore.js
deleted file mode 100644
index 446b5a08fe..0000000000
--- a/src/Umbraco.Web.UI.Client/lib/underscore/underscore.js
+++ /dev/null
@@ -1,1189 +0,0 @@
-// Underscore.js 1.4.1
-// http://underscorejs.org
-// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
-// Underscore may be freely distributed under the MIT license.
-
-(function() {
-
- // Baseline setup
- // --------------
-
- // Establish the root object, `window` in the browser, or `global` on the server.
- var root = this;
-
- // Save the previous value of the `_` variable.
- var previousUnderscore = root._;
-
- // Establish the object that gets returned to break out of a loop iteration.
- var breaker = {};
-
- // Save bytes in the minified (but not gzipped) version:
- var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype;
-
- // Create quick reference variables for speed access to core prototypes.
- var push = ArrayProto.push,
- slice = ArrayProto.slice,
- concat = ArrayProto.concat,
- unshift = ArrayProto.unshift,
- toString = ObjProto.toString,
- hasOwnProperty = ObjProto.hasOwnProperty;
-
- // All **ECMAScript 5** native function implementations that we hope to use
- // are declared here.
- var
- nativeForEach = ArrayProto.forEach,
- nativeMap = ArrayProto.map,
- nativeReduce = ArrayProto.reduce,
- nativeReduceRight = ArrayProto.reduceRight,
- nativeFilter = ArrayProto.filter,
- nativeEvery = ArrayProto.every,
- nativeSome = ArrayProto.some,
- nativeIndexOf = ArrayProto.indexOf,
- nativeLastIndexOf = ArrayProto.lastIndexOf,
- nativeIsArray = Array.isArray,
- nativeKeys = Object.keys,
- nativeBind = FuncProto.bind;
-
- // Create a safe reference to the Underscore object for use below.
- var _ = function(obj) {
- if (obj instanceof _) return obj;
- if (!(this instanceof _)) return new _(obj);
- this._wrapped = obj;
- };
-
- // Export the Underscore object for **Node.js**, with
- // backwards-compatibility for the old `require()` API. If we're in
- // the browser, add `_` as a global object via a string identifier,
- // for Closure Compiler "advanced" mode.
- if (typeof exports !== 'undefined') {
- if (typeof module !== 'undefined' && module.exports) {
- exports = module.exports = _;
- }
- exports._ = _;
- } else {
- root['_'] = _;
- }
-
- // Current version.
- _.VERSION = '1.4.1';
-
- // Collection Functions
- // --------------------
-
- // The cornerstone, an `each` implementation, aka `forEach`.
- // Handles objects with the built-in `forEach`, arrays, and raw objects.
- // Delegates to **ECMAScript 5**'s native `forEach` if available.
- var each = _.each = _.forEach = function(obj, iterator, context) {
- if (nativeForEach && obj.forEach === nativeForEach) {
- obj.forEach(iterator, context);
- } else if (obj.length === +obj.length) {
- for (var i = 0, l = obj.length; i < l; i++) {
- if (iterator.call(context, obj[i], i, obj) === breaker) return;
- }
- } else {
- for (var key in obj) {
- if (_.has(obj, key)) {
- if (iterator.call(context, obj[key], key, obj) === breaker) return;
- }
- }
- }
- };
-
- // Return the results of applying the iterator to each element.
- // Delegates to **ECMAScript 5**'s native `map` if available.
- _.map = _.collect = function(obj, iterator, context) {
- var results = [];
- if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context);
- each(obj, function(value, index, list) {
- results[results.length] = iterator.call(context, value, index, list);
- });
- return results;
- };
-
- // **Reduce** builds up a single result from a list of values, aka `inject`,
- // or `foldl`. Delegates to **ECMAScript 5**'s native `reduce` if available.
- _.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) {
- var initial = arguments.length > 2;
- if (nativeReduce && obj.reduce === nativeReduce) {
- if (context) iterator = _.bind(iterator, context);
- return initial ? obj.reduce(iterator, memo) : obj.reduce(iterator);
- }
- each(obj, function(value, index, list) {
- if (!initial) {
- memo = value;
- initial = true;
- } else {
- memo = iterator.call(context, memo, value, index, list);
- }
- });
- if (!initial) throw new TypeError('Reduce of empty array with no initial value');
- return memo;
- };
-
- // The right-associative version of reduce, also known as `foldr`.
- // Delegates to **ECMAScript 5**'s native `reduceRight` if available.
- _.reduceRight = _.foldr = function(obj, iterator, memo, context) {
- var initial = arguments.length > 2;
- if (nativeReduceRight && obj.reduceRight === nativeReduceRight) {
- if (context) iterator = _.bind(iterator, context);
- return arguments.length > 2 ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator);
- }
- var length = obj.length;
- if (length !== +length) {
- var keys = _.keys(obj);
- length = keys.length;
- }
- each(obj, function(value, index, list) {
- index = keys ? keys[--length] : --length;
- if (!initial) {
- memo = obj[index];
- initial = true;
- } else {
- memo = iterator.call(context, memo, obj[index], index, list);
- }
- });
- if (!initial) throw new TypeError('Reduce of empty array with no initial value');
- return memo;
- };
-
- // Return the first value which passes a truth test. Aliased as `detect`.
- _.find = _.detect = function(obj, iterator, context) {
- var result;
- any(obj, function(value, index, list) {
- if (iterator.call(context, value, index, list)) {
- result = value;
- return true;
- }
- });
- return result;
- };
-
- // Return all the elements that pass a truth test.
- // Delegates to **ECMAScript 5**'s native `filter` if available.
- // Aliased as `select`.
- _.filter = _.select = function(obj, iterator, context) {
- var results = [];
- if (nativeFilter && obj.filter === nativeFilter) return obj.filter(iterator, context);
- each(obj, function(value, index, list) {
- if (iterator.call(context, value, index, list)) results[results.length] = value;
- });
- return results;
- };
-
- // Return all the elements for which a truth test fails.
- _.reject = function(obj, iterator, context) {
- var results = [];
- each(obj, function(value, index, list) {
- if (!iterator.call(context, value, index, list)) results[results.length] = value;
- });
- return results;
- };
-
- // Determine whether all of the elements match a truth test.
- // Delegates to **ECMAScript 5**'s native `every` if available.
- // Aliased as `all`.
- _.every = _.all = function(obj, iterator, context) {
- iterator || (iterator = _.identity);
- var result = true;
- if (nativeEvery && obj.every === nativeEvery) return obj.every(iterator, context);
- each(obj, function(value, index, list) {
- if (!(result = result && iterator.call(context, value, index, list))) return breaker;
- });
- return !!result;
- };
-
- // Determine if at least one element in the object matches a truth test.
- // Delegates to **ECMAScript 5**'s native `some` if available.
- // Aliased as `any`.
- var any = _.some = _.any = function(obj, iterator, context) {
- iterator || (iterator = _.identity);
- var result = false;
- if (nativeSome && obj.some === nativeSome) return obj.some(iterator, context);
- each(obj, function(value, index, list) {
- if (result || (result = iterator.call(context, value, index, list))) return breaker;
- });
- return !!result;
- };
-
- // Determine if the array or object contains a given value (using `===`).
- // Aliased as `include`.
- _.contains = _.include = function(obj, target) {
- var found = false;
- if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1;
- found = any(obj, function(value) {
- return value === target;
- });
- return found;
- };
-
- // Invoke a method (with arguments) on every item in a collection.
- _.invoke = function(obj, method) {
- var args = slice.call(arguments, 2);
- return _.map(obj, function(value) {
- return (_.isFunction(method) ? method : value[method]).apply(value, args);
- });
- };
-
- // Convenience version of a common use case of `map`: fetching a property.
- _.pluck = function(obj, key) {
- return _.map(obj, function(value){ return value[key]; });
- };
-
- // Convenience version of a common use case of `filter`: selecting only objects
- // with specific `key:value` pairs.
- _.where = function(obj, attrs) {
- if (_.isEmpty(attrs)) return [];
- return _.filter(obj, function(value) {
- for (var key in attrs) {
- if (attrs[key] !== value[key]) return false;
- }
- return true;
- });
- };
-
- // Return the maximum element or (element-based computation).
- // Can't optimize arrays of integers longer than 65,535 elements.
- // See: https://bugs.webkit.org/show_bug.cgi?id=80797
- _.max = function(obj, iterator, context) {
- if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) {
- return Math.max.apply(Math, obj);
- }
- if (!iterator && _.isEmpty(obj)) return -Infinity;
- var result = {computed : -Infinity};
- each(obj, function(value, index, list) {
- var computed = iterator ? iterator.call(context, value, index, list) : value;
- computed >= result.computed && (result = {value : value, computed : computed});
- });
- return result.value;
- };
-
- // Return the minimum element (or element-based computation).
- _.min = function(obj, iterator, context) {
- if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) {
- return Math.min.apply(Math, obj);
- }
- if (!iterator && _.isEmpty(obj)) return Infinity;
- var result = {computed : Infinity};
- each(obj, function(value, index, list) {
- var computed = iterator ? iterator.call(context, value, index, list) : value;
- computed < result.computed && (result = {value : value, computed : computed});
- });
- return result.value;
- };
-
- // Shuffle an array.
- _.shuffle = function(obj) {
- var rand;
- var index = 0;
- var shuffled = [];
- each(obj, function(value) {
- rand = _.random(index++);
- shuffled[index - 1] = shuffled[rand];
- shuffled[rand] = value;
- });
- return shuffled;
- };
-
- // An internal function to generate lookup iterators.
- var lookupIterator = function(value) {
- return _.isFunction(value) ? value : function(obj){ return obj[value]; };
- };
-
- // Sort the object's values by a criterion produced by an iterator.
- _.sortBy = function(obj, value, context) {
- var iterator = lookupIterator(value);
- return _.pluck(_.map(obj, function(value, index, list) {
- return {
- value : value,
- index : index,
- criteria : iterator.call(context, value, index, list)
- };
- }).sort(function(left, right) {
- var a = left.criteria;
- var b = right.criteria;
- if (a !== b) {
- if (a > b || a === void 0) return 1;
- if (a < b || b === void 0) return -1;
- }
- return left.index < right.index ? -1 : 1;
- }), 'value');
- };
-
- // An internal function used for aggregate "group by" operations.
- var group = function(obj, value, context, behavior) {
- var result = {};
- var iterator = lookupIterator(value);
- each(obj, function(value, index) {
- var key = iterator.call(context, value, index, obj);
- behavior(result, key, value);
- });
- return result;
- };
-
- // Groups the object's values by a criterion. Pass either a string attribute
- // to group by, or a function that returns the criterion.
- _.groupBy = function(obj, value, context) {
- return group(obj, value, context, function(result, key, value) {
- (_.has(result, key) ? result[key] : (result[key] = [])).push(value);
- });
- };
-
- // Counts instances of an object that group by a certain criterion. Pass
- // either a string attribute to count by, or a function that returns the
- // criterion.
- _.countBy = function(obj, value, context) {
- return group(obj, value, context, function(result, key, value) {
- if (!_.has(result, key)) result[key] = 0;
- result[key]++;
- });
- };
-
- // Use a comparator function to figure out the smallest index at which
- // an object should be inserted so as to maintain order. Uses binary search.
- _.sortedIndex = function(array, obj, iterator, context) {
- iterator = iterator == null ? _.identity : lookupIterator(iterator);
- var value = iterator.call(context, obj);
- var low = 0, high = array.length;
- while (low < high) {
- var mid = (low + high) >>> 1;
- iterator.call(context, array[mid]) < value ? low = mid + 1 : high = mid;
- }
- return low;
- };
-
- // Safely convert anything iterable into a real, live array.
- _.toArray = function(obj) {
- if (!obj) return [];
- if (obj.length === +obj.length) return slice.call(obj);
- return _.values(obj);
- };
-
- // Return the number of elements in an object.
- _.size = function(obj) {
- return (obj.length === +obj.length) ? obj.length : _.keys(obj).length;
- };
-
- // Array Functions
- // ---------------
-
- // Get the first element of an array. Passing **n** will return the first N
- // values in the array. Aliased as `head` and `take`. The **guard** check
- // allows it to work with `_.map`.
- _.first = _.head = _.take = function(array, n, guard) {
- return (n != null) && !guard ? slice.call(array, 0, n) : array[0];
- };
-
- // Returns everything but the last entry of the array. Especially useful on
- // the arguments object. Passing **n** will return all the values in
- // the array, excluding the last N. The **guard** check allows it to work with
- // `_.map`.
- _.initial = function(array, n, guard) {
- return slice.call(array, 0, array.length - ((n == null) || guard ? 1 : n));
- };
-
- // Get the last element of an array. Passing **n** will return the last N
- // values in the array. The **guard** check allows it to work with `_.map`.
- _.last = function(array, n, guard) {
- if ((n != null) && !guard) {
- return slice.call(array, Math.max(array.length - n, 0));
- } else {
- return array[array.length - 1];
- }
- };
-
- // Returns everything but the first entry of the array. Aliased as `tail` and `drop`.
- // Especially useful on the arguments object. Passing an **n** will return
- // the rest N values in the array. The **guard**
- // check allows it to work with `_.map`.
- _.rest = _.tail = _.drop = function(array, n, guard) {
- return slice.call(array, (n == null) || guard ? 1 : n);
- };
-
- // Trim out all falsy values from an array.
- _.compact = function(array) {
- return _.filter(array, function(value){ return !!value; });
- };
-
- // Internal implementation of a recursive `flatten` function.
- var flatten = function(input, shallow, output) {
- each(input, function(value) {
- if (_.isArray(value)) {
- shallow ? push.apply(output, value) : flatten(value, shallow, output);
- } else {
- output.push(value);
- }
- });
- return output;
- };
-
- // Return a completely flattened version of an array.
- _.flatten = function(array, shallow) {
- return flatten(array, shallow, []);
- };
-
- // Return a version of the array that does not contain the specified value(s).
- _.without = function(array) {
- return _.difference(array, slice.call(arguments, 1));
- };
-
- // Produce a duplicate-free version of the array. If the array has already
- // been sorted, you have the option of using a faster algorithm.
- // Aliased as `unique`.
- _.uniq = _.unique = function(array, isSorted, iterator, context) {
- var initial = iterator ? _.map(array, iterator, context) : array;
- var results = [];
- var seen = [];
- each(initial, function(value, index) {
- if (isSorted ? (!index || seen[seen.length - 1] !== value) : !_.contains(seen, value)) {
- seen.push(value);
- results.push(array[index]);
- }
- });
- return results;
- };
-
- // Produce an array that contains the union: each distinct element from all of
- // the passed-in arrays.
- _.union = function() {
- return _.uniq(concat.apply(ArrayProto, arguments));
- };
-
- // Produce an array that contains every item shared between all the
- // passed-in arrays.
- _.intersection = function(array) {
- var rest = slice.call(arguments, 1);
- return _.filter(_.uniq(array), function(item) {
- return _.every(rest, function(other) {
- return _.indexOf(other, item) >= 0;
- });
- });
- };
-
- // Take the difference between one array and a number of other arrays.
- // Only the elements present in just the first array will remain.
- _.difference = function(array) {
- var rest = concat.apply(ArrayProto, slice.call(arguments, 1));
- return _.filter(array, function(value){ return !_.contains(rest, value); });
- };
-
- // Zip together multiple lists into a single array -- elements that share
- // an index go together.
- _.zip = function() {
- var args = slice.call(arguments);
- var length = _.max(_.pluck(args, 'length'));
- var results = new Array(length);
- for (var i = 0; i < length; i++) {
- results[i] = _.pluck(args, "" + i);
- }
- return results;
- };
-
- // Converts lists into objects. Pass either a single array of `[key, value]`
- // pairs, or two parallel arrays of the same length -- one of keys, and one of
- // the corresponding values.
- _.object = function(list, values) {
- var result = {};
- for (var i = 0, l = list.length; i < l; i++) {
- if (values) {
- result[list[i]] = values[i];
- } else {
- result[list[i][0]] = list[i][1];
- }
- }
- return result;
- };
-
- // If the browser doesn't supply us with indexOf (I'm looking at you, **MSIE**),
- // we need this function. Return the position of the first occurrence of an
- // item in an array, or -1 if the item is not included in the array.
- // Delegates to **ECMAScript 5**'s native `indexOf` if available.
- // If the array is large and already in sort order, pass `true`
- // for **isSorted** to use binary search.
- _.indexOf = function(array, item, isSorted) {
- var i = 0, l = array.length;
- if (isSorted) {
- if (typeof isSorted == 'number') {
- i = (isSorted < 0 ? Math.max(0, l + isSorted) : isSorted);
- } else {
- i = _.sortedIndex(array, item);
- return array[i] === item ? i : -1;
- }
- }
- if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item, isSorted);
- for (; i < l; i++) if (array[i] === item) return i;
- return -1;
- };
-
- // Delegates to **ECMAScript 5**'s native `lastIndexOf` if available.
- _.lastIndexOf = function(array, item, from) {
- var hasIndex = from != null;
- if (nativeLastIndexOf && array.lastIndexOf === nativeLastIndexOf) {
- return hasIndex ? array.lastIndexOf(item, from) : array.lastIndexOf(item);
- }
- var i = (hasIndex ? from : array.length);
- while (i--) if (array[i] === item) return i;
- return -1;
- };
-
- // Generate an integer Array containing an arithmetic progression. A port of
- // the native Python `range()` function. See
- // [the Python documentation](http://docs.python.org/library/functions.html#range).
- _.range = function(start, stop, step) {
- if (arguments.length <= 1) {
- stop = start || 0;
- start = 0;
- }
- step = arguments[2] || 1;
-
- var len = Math.max(Math.ceil((stop - start) / step), 0);
- var idx = 0;
- var range = new Array(len);
-
- while(idx < len) {
- range[idx++] = start;
- start += step;
- }
-
- return range;
- };
-
- // Function (ahem) Functions
- // ------------------
-
- // Reusable constructor function for prototype setting.
- var ctor = function(){};
-
- // Create a function bound to a given object (assigning `this`, and arguments,
- // optionally). Binding with arguments is also known as `curry`.
- // Delegates to **ECMAScript 5**'s native `Function.bind` if available.
- // We check for `func.bind` first, to fail fast when `func` is undefined.
- _.bind = function bind(func, context) {
- var bound, args;
- if (func.bind === nativeBind && nativeBind) return nativeBind.apply(func, slice.call(arguments, 1));
- if (!_.isFunction(func)) throw new TypeError;
- args = slice.call(arguments, 2);
- return bound = function() {
- if (!(this instanceof bound)) return func.apply(context, args.concat(slice.call(arguments)));
- ctor.prototype = func.prototype;
- var self = new ctor;
- var result = func.apply(self, args.concat(slice.call(arguments)));
- if (Object(result) === result) return result;
- return self;
- };
- };
-
- // Bind all of an object's methods to that object. Useful for ensuring that
- // all callbacks defined on an object belong to it.
- _.bindAll = function(obj) {
- var funcs = slice.call(arguments, 1);
- if (funcs.length == 0) funcs = _.functions(obj);
- each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); });
- return obj;
- };
-
- // Memoize an expensive function by storing its results.
- _.memoize = function(func, hasher) {
- var memo = {};
- hasher || (hasher = _.identity);
- return function() {
- var key = hasher.apply(this, arguments);
- return _.has(memo, key) ? memo[key] : (memo[key] = func.apply(this, arguments));
- };
- };
-
- // Delays a function for the given number of milliseconds, and then calls
- // it with the arguments supplied.
- _.delay = function(func, wait) {
- var args = slice.call(arguments, 2);
- return setTimeout(function(){ return func.apply(null, args); }, wait);
- };
-
- // Defers a function, scheduling it to run after the current call stack has
- // cleared.
- _.defer = function(func) {
- return _.delay.apply(_, [func, 1].concat(slice.call(arguments, 1)));
- };
-
- // Returns a function, that, when invoked, will only be triggered at most once
- // during a given window of time.
- _.throttle = function(func, wait) {
- var context, args, timeout, throttling, more, result;
- var whenDone = _.debounce(function(){ more = throttling = false; }, wait);
- return function() {
- context = this; args = arguments;
- var later = function() {
- timeout = null;
- if (more) {
- result = func.apply(context, args);
- }
- whenDone();
- };
- if (!timeout) timeout = setTimeout(later, wait);
- if (throttling) {
- more = true;
- } else {
- throttling = true;
- result = func.apply(context, args);
- }
- whenDone();
- return result;
- };
- };
-
- // Returns a function, that, as long as it continues to be invoked, will not
- // be triggered. The function will be called after it stops being called for
- // N milliseconds. If `immediate` is passed, trigger the function on the
- // leading edge, instead of the trailing.
- _.debounce = function(func, wait, immediate) {
- var timeout, result;
- return function() {
- var context = this, args = arguments;
- var later = function() {
- timeout = null;
- if (!immediate) result = func.apply(context, args);
- };
- var callNow = immediate && !timeout;
- clearTimeout(timeout);
- timeout = setTimeout(later, wait);
- if (callNow) result = func.apply(context, args);
- return result;
- };
- };
-
- // Returns a function that will be executed at most one time, no matter how
- // often you call it. Useful for lazy initialization.
- _.once = function(func) {
- var ran = false, memo;
- return function() {
- if (ran) return memo;
- ran = true;
- memo = func.apply(this, arguments);
- func = null;
- return memo;
- };
- };
-
- // Returns the first function passed as an argument to the second,
- // allowing you to adjust arguments, run code before and after, and
- // conditionally execute the original function.
- _.wrap = function(func, wrapper) {
- return function() {
- var args = [func];
- push.apply(args, arguments);
- return wrapper.apply(this, args);
- };
- };
-
- // Returns a function that is the composition of a list of functions, each
- // consuming the return value of the function that follows.
- _.compose = function() {
- var funcs = arguments;
- return function() {
- var args = arguments;
- for (var i = funcs.length - 1; i >= 0; i--) {
- args = [funcs[i].apply(this, args)];
- }
- return args[0];
- };
- };
-
- // Returns a function that will only be executed after being called N times.
- _.after = function(times, func) {
- if (times <= 0) return func();
- return function() {
- if (--times < 1) {
- return func.apply(this, arguments);
- }
- };
- };
-
- // Object Functions
- // ----------------
-
- // Retrieve the names of an object's properties.
- // Delegates to **ECMAScript 5**'s native `Object.keys`
- _.keys = nativeKeys || function(obj) {
- if (obj !== Object(obj)) throw new TypeError('Invalid object');
- var keys = [];
- for (var key in obj) if (_.has(obj, key)) keys[keys.length] = key;
- return keys;
- };
-
- // Retrieve the values of an object's properties.
- _.values = function(obj) {
- var values = [];
- for (var key in obj) if (_.has(obj, key)) values.push(obj[key]);
- return values;
- };
-
- // Convert an object into a list of `[key, value]` pairs.
- _.pairs = function(obj) {
- var pairs = [];
- for (var key in obj) if (_.has(obj, key)) pairs.push([key, obj[key]]);
- return pairs;
- };
-
- // Invert the keys and values of an object. The values must be serializable.
- _.invert = function(obj) {
- var result = {};
- for (var key in obj) if (_.has(obj, key)) result[obj[key]] = key;
- return result;
- };
-
- // Return a sorted list of the function names available on the object.
- // Aliased as `methods`
- _.functions = _.methods = function(obj) {
- var names = [];
- for (var key in obj) {
- if (_.isFunction(obj[key])) names.push(key);
- }
- return names.sort();
- };
-
- // Extend a given object with all the properties in passed-in object(s).
- _.extend = function(obj) {
- each(slice.call(arguments, 1), function(source) {
- for (var prop in source) {
- obj[prop] = source[prop];
- }
- });
- return obj;
- };
-
- // Return a copy of the object only containing the whitelisted properties.
- _.pick = function(obj) {
- var copy = {};
- var keys = concat.apply(ArrayProto, slice.call(arguments, 1));
- each(keys, function(key) {
- if (key in obj) copy[key] = obj[key];
- });
- return copy;
- };
-
- // Return a copy of the object without the blacklisted properties.
- _.omit = function(obj) {
- var copy = {};
- var keys = concat.apply(ArrayProto, slice.call(arguments, 1));
- for (var key in obj) {
- if (!_.contains(keys, key)) copy[key] = obj[key];
- }
- return copy;
- };
-
- // Fill in a given object with default properties.
- _.defaults = function(obj) {
- each(slice.call(arguments, 1), function(source) {
- for (var prop in source) {
- if (obj[prop] == null) obj[prop] = source[prop];
- }
- });
- return obj;
- };
-
- // Create a (shallow-cloned) duplicate of an object.
- _.clone = function(obj) {
- if (!_.isObject(obj)) return obj;
- return _.isArray(obj) ? obj.slice() : _.extend({}, obj);
- };
-
- // Invokes interceptor with the obj, and then returns obj.
- // The primary purpose of this method is to "tap into" a method chain, in
- // order to perform operations on intermediate results within the chain.
- _.tap = function(obj, interceptor) {
- interceptor(obj);
- return obj;
- };
-
- // Internal recursive comparison function for `isEqual`.
- var eq = function(a, b, aStack, bStack) {
- // Identical objects are equal. `0 === -0`, but they aren't identical.
- // See the Harmony `egal` proposal: http://wiki.ecmascript.org/doku.php?id=harmony:egal.
- if (a === b) return a !== 0 || 1 / a == 1 / b;
- // A strict comparison is necessary because `null == undefined`.
- if (a == null || b == null) return a === b;
- // Unwrap any wrapped objects.
- if (a instanceof _) a = a._wrapped;
- if (b instanceof _) b = b._wrapped;
- // Compare `[[Class]]` names.
- var className = toString.call(a);
- if (className != toString.call(b)) return false;
- switch (className) {
- // Strings, numbers, dates, and booleans are compared by value.
- case '[object String]':
- // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
- // equivalent to `new String("5")`.
- return a == String(b);
- case '[object Number]':
- // `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for
- // other numeric values.
- return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b);
- case '[object Date]':
- case '[object Boolean]':
- // Coerce dates and booleans to numeric primitive values. Dates are compared by their
- // millisecond representations. Note that invalid dates with millisecond representations
- // of `NaN` are not equivalent.
- return +a == +b;
- // RegExps are compared by their source patterns and flags.
- case '[object RegExp]':
- return a.source == b.source &&
- a.global == b.global &&
- a.multiline == b.multiline &&
- a.ignoreCase == b.ignoreCase;
- }
- if (typeof a != 'object' || typeof b != 'object') return false;
- // Assume equality for cyclic structures. The algorithm for detecting cyclic
- // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
- var length = aStack.length;
- while (length--) {
- // Linear search. Performance is inversely proportional to the number of
- // unique nested structures.
- if (aStack[length] == a) return bStack[length] == b;
- }
- // Add the first object to the stack of traversed objects.
- aStack.push(a);
- bStack.push(b);
- var size = 0, result = true;
- // Recursively compare objects and arrays.
- if (className == '[object Array]') {
- // Compare array lengths to determine if a deep comparison is necessary.
- size = a.length;
- result = size == b.length;
- if (result) {
- // Deep compare the contents, ignoring non-numeric properties.
- while (size--) {
- if (!(result = eq(a[size], b[size], aStack, bStack))) break;
- }
- }
- } else {
- // Objects with different constructors are not equivalent, but `Object`s
- // from different frames are.
- var aCtor = a.constructor, bCtor = b.constructor;
- if (aCtor !== bCtor && !(_.isFunction(aCtor) && (aCtor instanceof aCtor) &&
- _.isFunction(bCtor) && (bCtor instanceof bCtor))) {
- return false;
- }
- // Deep compare objects.
- for (var key in a) {
- if (_.has(a, key)) {
- // Count the expected number of properties.
- size++;
- // Deep compare each member.
- if (!(result = _.has(b, key) && eq(a[key], b[key], aStack, bStack))) break;
- }
- }
- // Ensure that both objects contain the same number of properties.
- if (result) {
- for (key in b) {
- if (_.has(b, key) && !(size--)) break;
- }
- result = !size;
- }
- }
- // Remove the first object from the stack of traversed objects.
- aStack.pop();
- bStack.pop();
- return result;
- };
-
- // Perform a deep comparison to check if two objects are equal.
- _.isEqual = function(a, b) {
- return eq(a, b, [], []);
- };
-
- // Is a given array, string, or object empty?
- // An "empty" object has no enumerable own-properties.
- _.isEmpty = function(obj) {
- if (obj == null) return true;
- if (_.isArray(obj) || _.isString(obj)) return obj.length === 0;
- for (var key in obj) if (_.has(obj, key)) return false;
- return true;
- };
-
- // Is a given value a DOM element?
- _.isElement = function(obj) {
- return !!(obj && obj.nodeType === 1);
- };
-
- // Is a given value an array?
- // Delegates to ECMA5's native Array.isArray
- _.isArray = nativeIsArray || function(obj) {
- return toString.call(obj) == '[object Array]';
- };
-
- // Is a given variable an object?
- _.isObject = function(obj) {
- return obj === Object(obj);
- };
-
- // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp.
- each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp'], function(name) {
- _['is' + name] = function(obj) {
- return toString.call(obj) == '[object ' + name + ']';
- };
- });
-
- // Define a fallback version of the method in browsers (ahem, IE), where
- // there isn't any inspectable "Arguments" type.
- if (!_.isArguments(arguments)) {
- _.isArguments = function(obj) {
- return !!(obj && _.has(obj, 'callee'));
- };
- }
-
- // Optimize `isFunction` if appropriate.
- if (typeof (/./) !== 'function') {
- _.isFunction = function(obj) {
- return typeof obj === 'function';
- };
- }
-
- // Is a given object a finite number?
- _.isFinite = function(obj) {
- return _.isNumber(obj) && isFinite(obj);
- };
-
- // Is the given value `NaN`? (NaN is the only number which does not equal itself).
- _.isNaN = function(obj) {
- return _.isNumber(obj) && obj != +obj;
- };
-
- // Is a given value a boolean?
- _.isBoolean = function(obj) {
- return obj === true || obj === false || toString.call(obj) == '[object Boolean]';
- };
-
- // Is a given value equal to null?
- _.isNull = function(obj) {
- return obj === null;
- };
-
- // Is a given variable undefined?
- _.isUndefined = function(obj) {
- return obj === void 0;
- };
-
- // Shortcut function for checking if an object has a given property directly
- // on itself (in other words, not on a prototype).
- _.has = function(obj, key) {
- return hasOwnProperty.call(obj, key);
- };
-
- // Utility Functions
- // -----------------
-
- // Run Underscore.js in *noConflict* mode, returning the `_` variable to its
- // previous owner. Returns a reference to the Underscore object.
- _.noConflict = function() {
- root._ = previousUnderscore;
- return this;
- };
-
- // Keep the identity function around for default iterators.
- _.identity = function(value) {
- return value;
- };
-
- // Run a function **n** times.
- _.times = function(n, iterator, context) {
- for (var i = 0; i < n; i++) iterator.call(context, i);
- };
-
- // Return a random integer between min and max (inclusive).
- _.random = function(min, max) {
- if (max == null) {
- max = min;
- min = 0;
- }
- return min + (0 | Math.random() * (max - min + 1));
- };
-
- // List of HTML entities for escaping.
- var entityMap = {
- escape: {
- '&': '&',
- '<': '<',
- '>': '>',
- '"': '"',
- "'": ''',
- '/': '/'
- }
- };
- entityMap.unescape = _.invert(entityMap.escape);
-
- // Regexes containing the keys and values listed immediately above.
- var entityRegexes = {
- escape: new RegExp('[' + _.keys(entityMap.escape).join('') + ']', 'g'),
- unescape: new RegExp('(' + _.keys(entityMap.unescape).join('|') + ')', 'g')
- };
-
- // Functions for escaping and unescaping strings to/from HTML interpolation.
- _.each(['escape', 'unescape'], function(method) {
- _[method] = function(string) {
- if (string == null) return '';
- return ('' + string).replace(entityRegexes[method], function(match) {
- return entityMap[method][match];
- });
- };
- });
-
- // If the value of the named property is a function then invoke it;
- // otherwise, return it.
- _.result = function(object, property) {
- if (object == null) return null;
- var value = object[property];
- return _.isFunction(value) ? value.call(object) : value;
- };
-
- // Add your own custom functions to the Underscore object.
- _.mixin = function(obj) {
- each(_.functions(obj), function(name){
- var func = _[name] = obj[name];
- _.prototype[name] = function() {
- var args = [this._wrapped];
- push.apply(args, arguments);
- return result.call(this, func.apply(_, args));
- };
- });
- };
-
- // Generate a unique integer id (unique within the entire client session).
- // Useful for temporary DOM ids.
- var idCounter = 0;
- _.uniqueId = function(prefix) {
- var id = idCounter++;
- return prefix ? prefix + id : id;
- };
-
- // By default, Underscore uses ERB-style template delimiters, change the
- // following template settings to use alternative delimiters.
- _.templateSettings = {
- evaluate : /<%([\s\S]+?)%>/g,
- interpolate : /<%=([\s\S]+?)%>/g,
- escape : /<%-([\s\S]+?)%>/g
- };
-
- // When customizing `templateSettings`, if you don't want to define an
- // interpolation, evaluation or escaping regex, we need one that is
- // guaranteed not to match.
- var noMatch = /(.)^/;
-
- // Certain characters need to be escaped so that they can be put into a
- // string literal.
- var escapes = {
- "'": "'",
- '\\': '\\',
- '\r': 'r',
- '\n': 'n',
- '\t': 't',
- '\u2028': 'u2028',
- '\u2029': 'u2029'
- };
-
- var escaper = /\\|'|\r|\n|\t|\u2028|\u2029/g;
-
- // JavaScript micro-templating, similar to John Resig's implementation.
- // Underscore templating handles arbitrary delimiters, preserves whitespace,
- // and correctly escapes quotes within interpolated code.
- _.template = function(text, data, settings) {
- settings = _.defaults({}, settings, _.templateSettings);
-
- // Combine delimiters into one regular expression via alternation.
- var matcher = new RegExp([
- (settings.escape || noMatch).source,
- (settings.interpolate || noMatch).source,
- (settings.evaluate || noMatch).source
- ].join('|') + '|$', 'g');
-
- // Compile the template source, escaping string literals appropriately.
- var index = 0;
- var source = "__p+='";
- text.replace(matcher, function(match, escape, interpolate, evaluate, offset) {
- source += text.slice(index, offset)
- .replace(escaper, function(match) { return '\\' + escapes[match]; });
- source +=
- escape ? "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'" :
- interpolate ? "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'" :
- evaluate ? "';\n" + evaluate + "\n__p+='" : '';
- index = offset + match.length;
- });
- source += "';\n";
-
- // If a variable is not specified, place data values in local scope.
- if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n';
-
- source = "var __t,__p='',__j=Array.prototype.join," +
- "print=function(){__p+=__j.call(arguments,'');};\n" +
- source + "return __p;\n";
-
- try {
- var render = new Function(settings.variable || 'obj', '_', source);
- } catch (e) {
- e.source = source;
- throw e;
- }
-
- if (data) return render(data, _);
- var template = function(data) {
- return render.call(this, data, _);
- };
-
- // Provide the compiled function source as a convenience for precompilation.
- template.source = 'function(' + (settings.variable || 'obj') + '){\n' + source + '}';
-
- return template;
- };
-
- // Add a "chain" function, which will delegate to the wrapper.
- _.chain = function(obj) {
- return _(obj).chain();
- };
-
- // OOP
- // ---------------
- // If Underscore is called as a function, it returns a wrapped object that
- // can be used OO-style. This wrapper holds altered versions of all the
- // underscore functions. Wrapped objects may be chained.
-
- // Helper function to continue chaining intermediate results.
- var result = function(obj) {
- return this._chain ? _(obj).chain() : obj;
- };
-
- // Add all of the Underscore functions to the wrapper object.
- _.mixin(_);
-
- // Add all mutator Array functions to the wrapper.
- each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {
- var method = ArrayProto[name];
- _.prototype[name] = function() {
- var obj = this._wrapped;
- method.apply(obj, arguments);
- if ((name == 'shift' || name == 'splice') && obj.length === 0) delete obj[0];
- return result.call(this, obj);
- };
- });
-
- // Add all accessor Array functions to the wrapper.
- each(['concat', 'join', 'slice'], function(name) {
- var method = ArrayProto[name];
- _.prototype[name] = function() {
- return result.call(this, method.apply(this._wrapped, arguments));
- };
- });
-
- _.extend(_.prototype, {
-
- // Start chaining a wrapped Underscore object.
- chain: function() {
- this._chain = true;
- return this;
- },
-
- // Extracts the result from a wrapped and chained object.
- value: function() {
- return this._wrapped;
- }
-
- });
-
-}).call(this);
diff --git a/src/Umbraco.Web.UI.Client/package.json b/src/Umbraco.Web.UI.Client/package.json
index b9fa69ccb4..b8ac55d60c 100644
--- a/src/Umbraco.Web.UI.Client/package.json
+++ b/src/Umbraco.Web.UI.Client/package.json
@@ -1,48 +1,49 @@
-{
- "author": "Umbraco HQ",
- "name": "umbraco",
- "homepage": "https://github.com/umbraco/umbraco-cms/",
- "version": "7.1.2",
- "repository": {
- "type": "git",
- "url": "git@github.com:umbraco/umbraco-cms.git"
- },
- "bugs": {
- "url": "https://issues.umbraco.org"
- },
- "licenses": [
- {
- "type": "MIT",
- "url": "https://github.com/umbraco/Umbraco-CMS/blob/7.0.0/docs/License.txt"
- }
- ],
- "engines": {
- "node": ">= 0.8.4"
- },
- "dependencies": {},
- "devDependencies": {
- "grunt": "~0.4.0",
- "phantomjs": "~1.9.1-0",
- "grunt-recess": "~0.3",
- "grunt-contrib-clean": "~0.4.0",
- "grunt-contrib-copy": "~0.4.0",
- "grunt-contrib-jshint": "~0.2.0",
- "grunt-contrib-concat": "~0.1.3",
- "grunt-contrib-uglify": "~0.1.1",
- "grunt-html2js": "~0.1.0",
- "grunt-contrib-watch": "~0.3.1",
- "grunt-open": "~0.2.0",
- "grunt-contrib-connect": "~0.3.0",
- "grunt-karma": "~0.5",
- "karma-chrome-launcher": "0.0.2",
- "karma-script-launcher": "0.0.1",
- "karma-firefox-launcher": "0.0.2",
- "karma-jasmine": "0.0.1",
- "karma-requirejs": "0.0.1",
- "karma-coffee-preprocessor": "0.0.1",
- "karma": "~0.9",
- "karma-phantomjs-launcher": "0.0.2",
- "grunt-ngdocs": "~0.1.2",
- "bower": "~1.3.3"
- }
-}
+{
+ "author": "Umbraco HQ",
+ "name": "umbraco",
+ "homepage": "https://github.com/umbraco/umbraco-cms/",
+ "version": "7.1.2",
+ "repository": {
+ "type": "git",
+ "url": "git@github.com:umbraco/umbraco-cms.git"
+ },
+ "bugs": {
+ "url": "https://issues.umbraco.org"
+ },
+ "licenses": [
+ {
+ "type": "MIT",
+ "url": "https://github.com/umbraco/Umbraco-CMS/blob/7.0.0/docs/License.txt"
+ }
+ ],
+ "engines": {
+ "node": ">= 0.8.4"
+ },
+ "dependencies": {},
+ "devDependencies": {
+ "bower": "~1.3.3",
+ "grunt": "~0.4.0",
+ "grunt-bower-task": "^0.4.0",
+ "grunt-contrib-clean": "~0.4.0",
+ "grunt-contrib-concat": "~0.1.3",
+ "grunt-contrib-connect": "~0.3.0",
+ "grunt-contrib-copy": "~0.7.0",
+ "grunt-contrib-jshint": "~0.2.0",
+ "grunt-contrib-uglify": "~0.1.1",
+ "grunt-contrib-watch": "~0.3.1",
+ "grunt-html2js": "~0.1.0",
+ "grunt-karma": "~0.5",
+ "grunt-ngdocs": "~0.1.2",
+ "grunt-open": "~0.2.0",
+ "grunt-recess": "~0.3",
+ "karma": "~0.9",
+ "karma-chrome-launcher": "0.0.2",
+ "karma-coffee-preprocessor": "0.0.1",
+ "karma-firefox-launcher": "0.0.2",
+ "karma-jasmine": "0.0.1",
+ "karma-phantomjs-launcher": "0.0.2",
+ "karma-requirejs": "0.0.1",
+ "karma-script-launcher": "0.0.1",
+ "phantomjs": "~1.9.1-0"
+ }
+}
diff --git a/src/Umbraco.Web.UI.Client/src/canvasdesigner.loader.js b/src/Umbraco.Web.UI.Client/src/canvasdesigner.loader.js
index fa8dbdcaff..64e8d46a30 100644
--- a/src/Umbraco.Web.UI.Client/src/canvasdesigner.loader.js
+++ b/src/Umbraco.Web.UI.Client/src/canvasdesigner.loader.js
@@ -2,7 +2,7 @@ LazyLoad.js([
'/Umbraco/lib/jquery/jquery-2.0.3.min.js',
'/Umbraco/lib/jquery/jquery-ui-1.10.4.custom.min.js',
'/Umbraco/lib/angular/1.1.5/angular.min.js',
- '/Umbraco/lib/underscore/underscore.js',
+ '/Umbraco/lib/underscore/underscore-min.js',
'/Umbraco/js/app.js',
'/Umbraco/js/umbraco.resources.js',
'/Umbraco/js/umbraco.services.js',
diff --git a/src/Umbraco.Web.UI.Client/src/canvasdesigner/index.html b/src/Umbraco.Web.UI.Client/src/canvasdesigner/index.html
index 0da6dcb021..e6c7bb9a77 100644
--- a/src/Umbraco.Web.UI.Client/src/canvasdesigner/index.html
+++ b/src/Umbraco.Web.UI.Client/src/canvasdesigner/index.html
@@ -151,7 +151,7 @@
Styles saved and published
-
+
-
+
@@ -22,7 +22,7 @@
-
-
+
+
diff --git a/src/Umbraco.Web.UI.Client/src/common/services/assets.service.js b/src/Umbraco.Web.UI.Client/src/common/services/assets.service.js
index 94a84f0749..057e9c3b27 100644
--- a/src/Umbraco.Web.UI.Client/src/common/services/assets.service.js
+++ b/src/Umbraco.Web.UI.Client/src/common/services/assets.service.js
@@ -230,11 +230,11 @@ angular.module('umbraco.services')
asset.state = "loaded";
asset.deferred.resolve(true);
}else{
- asset.state = "loaded";
+ asset.state = "loaded";
angularHelper.safeApply(scope, function () {
asset.deferred.resolve(true);
- });
- }
+ });
+ }
});
});
}else{
diff --git a/src/Umbraco.Web.UI.Client/src/index.html b/src/Umbraco.Web.UI.Client/src/index.html
index 6a1b32b03f..a16987ce2c 100644
--- a/src/Umbraco.Web.UI.Client/src/index.html
+++ b/src/Umbraco.Web.UI.Client/src/index.html
@@ -1,4 +1,4 @@
-
+