Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: cloudchen/grunt-template-jasmine-requirejs
base: master
...
head fork: jaredstehler/grunt-template-jasmine-steal
compare: master
  • 11 commits
  • 18 files changed
  • 0 commit comments
  • 2 contributors
3  .gitignore
View
@@ -1,2 +1,5 @@
node_modules
npm-debug.log
+_SpecRunner.html
+.grunt
+
21 Gruntfile.js
View
@@ -40,21 +40,22 @@ module.exports = function(grunt) {
},
connect: {
test: {
- port: 8000,
- base: '.'
+ options: {
+ port: '?'
+ }
}
},
jasmine: {
- requirejs: {
- src: 'test/fixtures/requirejs/src/**/*.js',
+ steal: {
options: {
- specs: 'test/fixtures/requirejs/spec/*Spec.js',
- helpers: 'test/fixtures/requirejs/spec/*Helper.js',
- host: 'http://127.0.0.1:<%= connect.test.port %>/',
+ specs: 'test/fixtures/steal/spec/*Spec.js',
+ host: 'http://127.0.0.1:<%= connect.test.options.port %>/',
template : require('./'),
templateOptions: {
- requireConfig : {
- baseUrl: './test/fixtures/requirejs/src/'
+ steal : {
+ map: {
+ 'test': '../../test'
+ }
}
}
}
@@ -67,7 +68,7 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-jasmine');
grunt.loadNpmTasks('grunt-contrib-connect');
- grunt.registerTask('test', ['connect', 'jasmine:requirejs']);
+ grunt.registerTask('test', ['connect', 'jasmine:steal']);
// Default task.
grunt.registerTask('default', ['jshint','test']);
68 README.md
View
@@ -1,27 +1,34 @@
-RequireJS template for Jasmine unit tests
+Steal template for Jasmine unit tests
-----------------------------------------
## Installation
```
-npm install grunt-template-jasmine-requirejs --save-dev
+npm install grunt-template-jasmine-steal --save-dev
```
## Template Options
-### templateOptions.version
+### templateOptions.steal.url
Type: `String`
-Options: `2.1.1` `2.1.2`
-Default: latest requirejs version included
+Default: path to steal.js (defaults to internal version, probably not desired)
-The version of requirejs to use. Since this template is relatively recent, only versions 2.1.1 and 2.1.2 are
+The steal script to use.
-### templateOptions.requireConfig
+### templateOptions.steal.map
Type: `Object`
-This object is `JSON.stringify()`-ed into the template and passed into `require.config()`
+This object is `JSON.stringify()`-ed into the template and passed into `steal.map()`
+### templateOptions.steal.executed
+Type: `Object`
+
+This object is `JSON.stringify()`-ed into the template and passed into `steal.executed()`
+
+### templateOptions.steal.options
+Type: `Object`
+This object is `JSON.stringify()`-ed into the template and set as the default steal options object in the page, before steal is loaded.
## Sample usage
@@ -30,20 +37,30 @@ This object is `JSON.stringify()`-ed into the template and passed into `require.
grunt.initConfig({
connect: {
test : {
- port : 8000
+ options: {
+ base : '.',
+ port : '?'
+ }
}
- }
+ },
+
jasmine: {
taskName: {
src: 'src/**/*.js',
options: {
specs: 'spec/*Spec.js',
helpers: 'spec/*Helper.js',
- host: 'http://127.0.0.1:8000/',
- template: require('grunt-template-jasmine-requirejs'),
+ host: 'http://127.0.0.1:<%= connect.test.options.port %>/',
+ template: require('grunt-template-jasmine-steal'),
templateOptions: {
- requireConfig: {
- baseUrl: 'src/'
+ steal: {
+ url: 'src/steal/steal.js',
+ map: {
+ '.grunt': '../.grunt'
+ },
+ options: {
+ logLevel: 3
+ }
}
}
}
@@ -57,18 +74,19 @@ grunt.initConfig({
[grunt-contrib-connect]: https://github.com/gruntjs/grunt-contrib-connect
-## RequireJS notes
+## Steal notes
-If you end up using this template, it's worth looking at the
-[source]() in order to familiarize yourself with how it loads your files. The load process
-consists of a series of nested `require` blocks, incrementally loading your source and specs:
+With this template, you can use steal in your spec files the same way you would in the
+rest of your application.
```js
-require([*YOUR SOURCE*], function() {
- require([*YOUR SPECS*], function() {
- require([*GRUNT-CONTRIB-JASMINE FILES*], function() {
- // at this point your tests are already running.
- }
- }
-}
+/* example widget_spec.js */
+steal('widget.js', function() {
+
+ describe('the widget', function() {
+ it('is a widget', function() {
+ expect(window.Widget).toBeDefined();
+ })
+ })
+})
```
28 package.json
View
@@ -1,29 +1,33 @@
{
- "name": "grunt-template-jasmine-requirejs",
- "version": "0.1.0",
- "description": "Requirejs template for grunt-contrib-jasmine",
- "main": "src/template-jasmine-requirejs.js",
+ "name": "grunt-template-jasmine-steal",
+ "version": "0.3.1",
+ "description": "StealJS template for grunt-contrib-jasmine",
+ "main": "src/template-jasmine-steal.js",
"scripts": {
"test": "grunt test"
},
"repository": {
"type": "git",
- "url": "https://github.com/jsoverson/grunt-template-jasmine-requirejs"
+ "url": "https://github.com/jaredstehler/grunt-template-jasmine-steal"
},
"keywords": [
"grunt",
"template",
- "requirejs",
+ "steal",
"jasmine",
"test"
],
- "author": "Jarrod Overson",
+ "author": "Jared Stehler",
+ "contributors": ["Jarrod Overson"],
"license": "BSD",
"devDependencies": {
- "grunt-contrib-jshint": "~0.1.1rc5",
- "grunt-contrib-watch": "~0.1.4",
- "grunt": "~0.4.0rc5",
- "grunt-contrib-jasmine": "~0.3.0rc5",
- "grunt-contrib-connect": "~0.1.0"
+ "grunt-contrib-jshint": "~0.4.3",
+ "grunt-contrib-watch": "~0.3.1",
+ "grunt-contrib-connect": "~0.3.0",
+ "grunt-lib-phantomjs": "~0.3.0"
+ },
+ "dependencies": {
+ "grunt": "~0.4.0",
+ "grunt-contrib-jasmine": "~0.4.2"
}
}
49 src/template-jasmine-requirejs.js
View
@@ -1,49 +0,0 @@
-
-"use strict";
-
-var template = __dirname + '/templates/jasmine-requirejs.html',
- requirejs = {
- '2.1.1' : __dirname + '/../vendor/require-2.1.1.js',
- '2.1.2' : __dirname + '/../vendor/require-2.1.1.js'
- };
-
-exports.process = function(grunt, task, context) {
-
- var version = context.options.version;
-
- // find the latest version if none given
- if (!version) {
- version = Object.keys(requirejs).sort().pop();
- }
-
- var src = context.scripts.src;
- var baseUrl = context.options.requireConfig && context.options.requireConfig.baseUrl;
- if (!baseUrl) {
- baseUrl = '/';
- }
-
- // Remove baseUrl and .js from src files
- src.forEach(function(script, i){
- if (baseUrl) {
- script = script.replace(new RegExp('^' + baseUrl),"");
- }
- src[i] = script.replace(/\.js$/,"");
- });
-
- // Prepend loaderPlugins to the appropriate files
- if (context.options.loaderPlugin) {
- Object.keys(context.options.loaderPlugin).forEach(function(type){
- if (context[type]) {
- context[type].forEach(function(file,i){
- context[type][i] = context.options.loaderPlugin[type] + '!' + file;
- });
- }
- });
- }
-
- task.copyTempFile(requirejs[version],'require.js');
-
- var source = grunt.file.read(template);
- return grunt.util._.template(source, context);
-};
-
45 src/template-jasmine-steal.js
View
@@ -0,0 +1,45 @@
+
+"use strict";
+
+var template = __dirname + '/templates/jasmine-steal.html',
+ steal = {
+ '3.2.3' : __dirname + '/../vendor/steal-3.2.3'
+ };
+
+exports.process = function(grunt, task, context) {
+ context.options.stealOptions = context.options.stealOptions || {};
+
+ var stealUrl = context.options.steal.url;
+
+ // find the latest version if none given
+ if (!stealUrl) {
+ stealUrl = '.grunt/grunt-contrib-jasmine/steal/steal.js';
+ }
+
+ var stealRoot = stealUrl.substring(0, stealUrl.indexOf('steal/steal.js'));
+
+ context.options.steal.url = stealUrl;
+
+ context.fn = {
+ pathify: function(s) {
+ var stealRel = new RegExp('^.*' + stealRoot),
+ baseRel = /^\.\//,
+ supportRel = /^\.grunt\//,
+ absBase = '';
+
+ if(s.indexOf(stealRoot) === -1 && s.indexOf('.grunt') === -1) {
+ absBase = '/';
+ }
+
+ return absBase + s.replace(stealRel, '').replace(baseRel, '').replace(supportRel, '/.grunt/');
+ }
+ };
+
+ // put steal into place
+ task.copyTempFile(steal['3.2.3'] + '/steal.js','steal/steal.js');
+ task.copyTempFile(steal['3.2.3'] + '/dev/dev.js','steal/dev/dev.js');
+
+ var source = grunt.file.read(template);
+ return grunt.util._.template(source, context);
+};
+
42 src/templates/jasmine-requirejs.html
View
@@ -1,42 +0,0 @@
-<!doctype html>
-<html>
-<head>
- <meta charset="utf-8">
- <title>Jasmine Spec Runner</title>
-
- <% with (scripts) { %>
- <% [].concat(jasmine, vendor, helpers).forEach(function(script){ %>
- <script src="<%= script %>"></script>
- <% }) %>
- <% }; %>
-
- <script src="<%= temp %>/require.js"></script>
- <script>
- <% if (options.requireConfig) { %>
- require.config(<%= JSON.stringify(options.requireConfig) %>);
- <% } %>
- </script>
- <% css.forEach(function(style){ %>
- <link rel="stylesheet" type="text/css" href="<%= style %>">
- <% }) %>
- <script>
- require([
- <% scripts.src.forEach(function(script, i){ %>
- <% if (options.requireConfig && options.requireConfig.baseUrl) script = script.replace(new RegExp('^' + options.requireConfig.baseUrl),""); %>
- <% if (options.loaderPlugin) script = options.loaderPlugin + '!' + script %>
- '<%= script.replace(/\.js$/,"") %>' <%= i < scripts.src.length-1 ? ',' : '' %>
- <% }) %>
- ],
- function(){
- require(['<%= [].concat(scripts.specs,scripts.reporters).join("','") %>'], function(){
- require(['<%= scripts.start.join("','") %>'], function(){
- // good to go! Our tests should already be running.
- })
- })
- }
- )
- </script>
-</head>
-<body>
-</body>
-</html>
56 src/templates/jasmine-steal.html
View
@@ -0,0 +1,56 @@
+<!doctype html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Jasmine Spec Runner</title>
+
+ <% if(options.steal.options) { %>
+ <script>
+ steal = <%= JSON.stringify(options.steal.options) %>
+ </script>
+ <% } %>
+
+ <script src="<%= options.steal.url %>"></script>
+
+ <% if (options.steal.map) { %>
+ <script>
+ steal.map(<%= JSON.stringify(options.steal.map) %>);
+ </script>
+ <% } %>
+
+ <% if(options.steal.executed) { %>
+ <script>
+ <% options.steal.executed.forEach(function(script) { %>
+ steal.executed("<%= script %>");
+ <% }) %>
+ </script>
+ <% } %>
+
+ <% css.forEach(function(style){ %>
+ <link rel="stylesheet" type="text/css" href="<%= style %>">
+ <% }) %>
+
+ <script>
+ steal
+
+ <% with (scripts) { %>
+ <% [].concat(jasmine, vendor, helpers).forEach(function(script){ %>
+ .then("<%= fn.pathify(script) %>")
+ <% }) %>
+ <% }; %>
+
+
+ <% scripts.specs.forEach(function(script, i){ %>
+ .then("<%= fn.pathify(script) %>")
+ <% }) %>
+ <% scripts.reporters.forEach(function(script, i){ %>
+ .then("<%= fn.pathify(script) %>")
+ <% }) %>
+ <% scripts.start.forEach(function(script, i){ %>
+ .then("<%= fn.pathify(script) %>")
+ <% }) %>
+ </script>
+</head>
+<body>
+</body>
+</html>
10 test/fixtures/requirejs/spec/SumSpec.js
View
@@ -1,10 +0,0 @@
-
-describe('Example AMD test', function(){
- var math = require('math');
-
- describe('Sum', function(){
- it('Should add two numbers together', function(){
- expect(math.sum(2,10)).toEqual(12);
- })
- })
-});
5 test/fixtures/requirejs/src/math.js
View
@@ -1,5 +0,0 @@
-define(['sum'],function(sum){
- return {
- sum : sum
- }
-})
5 test/fixtures/requirejs/src/sum.js
View
@@ -1,5 +0,0 @@
-define(function(){
- return function(a,b){
- return a + b;
- }
-})
10 test/fixtures/steal/spec/SumSpec.js
View
@@ -0,0 +1,10 @@
+steal('/test/fixtures/steal/src/math.js', function() {
+
+ describe('Example Steal test', function(){
+ it('Should add two numbers together', function(){
+ expect(sum(2,10)).toEqual(12);
+ });
+ })
+
+});
+
1  test/fixtures/steal/src/math.js
View
@@ -0,0 +1 @@
+steal('./sum.js');
6 test/fixtures/steal/src/sum.js
View
@@ -0,0 +1,6 @@
+steal(function() {
+ window.sum = function(a, b){
+ return a + b;
+ };
+});
+
34 vendor/require-2.1.1.js
View
@@ -1,34 +0,0 @@
-/*
- RequireJS 2.1.1 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
- Available via the MIT or new BSD license.
- see: http://github.com/jrburke/requirejs for details
-*/
-var requirejs,require,define;
-(function(W){function D(b){return M.call(b)==="[object Function]"}function E(b){return M.call(b)==="[object Array]"}function t(b,c){if(b){var d;for(d=0;d<b.length;d+=1)if(b[d]&&c(b[d],d,b))break}}function N(b,c){if(b){var d;for(d=b.length-1;d>-1;d-=1)if(b[d]&&c(b[d],d,b))break}}function A(b,c){for(var d in b)if(b.hasOwnProperty(d)&&c(b[d],d))break}function O(b,c,d,g){c&&A(c,function(c,j){if(d||!F.call(b,j))g&&typeof c!=="string"?(b[j]||(b[j]={}),O(b[j],c,d,g)):b[j]=c});return b}function r(b,c){return function(){return c.apply(b,
-arguments)}}function X(b){if(!b)return b;var c=W;t(b.split("."),function(b){c=c[b]});return c}function G(b,c,d,g){c=Error(c+"\nhttp://requirejs.org/docs/errors.html#"+b);c.requireType=b;c.requireModules=g;if(d)c.originalError=d;return c}function ba(){if(H&&H.readyState==="interactive")return H;N(document.getElementsByTagName("script"),function(b){if(b.readyState==="interactive")return H=b});return H}var g,s,u,y,q,B,H,I,Y,Z,ca=/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,da=/[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
-$=/\.js$/,ea=/^\.\//;s=Object.prototype;var M=s.toString,F=s.hasOwnProperty,fa=Array.prototype.splice,v=!!(typeof window!=="undefined"&&navigator&&document),aa=!v&&typeof importScripts!=="undefined",ga=v&&navigator.platform==="PLAYSTATION 3"?/^complete$/:/^(complete|loaded)$/,R=typeof opera!=="undefined"&&opera.toString()==="[object Opera]",w={},n={},P=[],J=!1;if(typeof define==="undefined"){if(typeof requirejs!=="undefined"){if(D(requirejs))return;n=requirejs;requirejs=void 0}typeof require!=="undefined"&&
-!D(require)&&(n=require,require=void 0);g=requirejs=function(b,c,d,p){var i,j="_";!E(b)&&typeof b!=="string"&&(i=b,E(c)?(b=c,c=d,d=p):b=[]);if(i&&i.context)j=i.context;(p=w[j])||(p=w[j]=g.s.newContext(j));i&&p.configure(i);return p.require(b,c,d)};g.config=function(b){return g(b)};g.nextTick=typeof setTimeout!=="undefined"?function(b){setTimeout(b,4)}:function(b){b()};require||(require=g);g.version="2.1.1";g.jsExtRegExp=/^\/|:|\?|\.js$/;g.isBrowser=v;s=g.s={contexts:w,newContext:function(b){function c(a,
-f,x){var e,m,b,c,d,h,i,g=f&&f.split("/");e=g;var j=k.map,l=j&&j["*"];if(a&&a.charAt(0)===".")if(f){e=k.pkgs[f]?g=[f]:g.slice(0,g.length-1);f=a=e.concat(a.split("/"));for(e=0;f[e];e+=1)if(m=f[e],m===".")f.splice(e,1),e-=1;else if(m==="..")if(e===1&&(f[2]===".."||f[0]===".."))break;else e>0&&(f.splice(e-1,2),e-=2);e=k.pkgs[f=a[0]];a=a.join("/");e&&a===f+"/"+e.main&&(a=f)}else a.indexOf("./")===0&&(a=a.substring(2));if(x&&(g||l)&&j){f=a.split("/");for(e=f.length;e>0;e-=1){b=f.slice(0,e).join("/");if(g)for(m=
-g.length;m>0;m-=1)if(x=j[g.slice(0,m).join("/")])if(x=x[b]){c=x;d=e;break}if(c)break;!h&&l&&l[b]&&(h=l[b],i=e)}!c&&h&&(c=h,d=i);c&&(f.splice(0,d,c),a=f.join("/"))}return a}function d(a){v&&t(document.getElementsByTagName("script"),function(f){if(f.getAttribute("data-requiremodule")===a&&f.getAttribute("data-requirecontext")===h.contextName)return f.parentNode.removeChild(f),!0})}function p(a){var f=k.paths[a];if(f&&E(f)&&f.length>1)return d(a),f.shift(),h.require.undef(a),h.require([a]),!0}function i(a){var f,
-b=a?a.indexOf("!"):-1;b>-1&&(f=a.substring(0,b),a=a.substring(b+1,a.length));return[f,a]}function j(a,f,b,e){var m,K,d=null,g=f?f.name:null,j=a,l=!0,k="";a||(l=!1,a="_@r"+(M+=1));a=i(a);d=a[0];a=a[1];d&&(d=c(d,g,e),K=o[d]);a&&(d?k=K&&K.normalize?K.normalize(a,function(a){return c(a,g,e)}):c(a,g,e):(k=c(a,g,e),a=i(k),d=a[0],k=a[1],b=!0,m=h.nameToUrl(k)));b=d&&!K&&!b?"_unnormalized"+(N+=1):"";return{prefix:d,name:k,parentMap:f,unnormalized:!!b,url:m,originalName:j,isDefine:l,id:(d?d+"!"+k:k)+b}}function n(a){var f=
-a.id,b=l[f];b||(b=l[f]=new h.Module(a));return b}function q(a,f,b){var e=a.id,m=l[e];if(F.call(o,e)&&(!m||m.defineEmitComplete))f==="defined"&&b(o[e]);else n(a).on(f,b)}function z(a,f){var b=a.requireModules,e=!1;if(f)f(a);else if(t(b,function(f){if(f=l[f])f.error=a,f.events.error&&(e=!0,f.emit("error",a))}),!e)g.onError(a)}function s(){P.length&&(fa.apply(C,[C.length-1,0].concat(P)),P=[])}function u(a,f,b){var e=a.map.id;a.error?a.emit("error",a.error):(f[e]=!0,t(a.depMaps,function(e,c){var d=e.id,
-g=l[d];g&&!a.depMatched[c]&&!b[d]&&(f[d]?(a.defineDep(c,o[d]),a.check()):u(g,f,b))}),b[e]=!0)}function w(){var a,f,b,e,m=(b=k.waitSeconds*1E3)&&h.startTime+b<(new Date).getTime(),c=[],g=[],i=!1,j=!0;if(!S){S=!0;A(l,function(b){a=b.map;f=a.id;if(b.enabled&&(a.isDefine||g.push(b),!b.error))if(!b.inited&&m)p(f)?i=e=!0:(c.push(f),d(f));else if(!b.inited&&b.fetched&&a.isDefine&&(i=!0,!a.prefix))return j=!1});if(m&&c.length)return b=G("timeout","Load timeout for modules: "+c,null,c),b.contextName=h.contextName,
-z(b);j&&t(g,function(a){u(a,{},{})});if((!m||e)&&i)if((v||aa)&&!T)T=setTimeout(function(){T=0;w()},50);S=!1}}function y(a){n(j(a[0],null,!0)).init(a[1],a[2])}function B(a){var a=a.currentTarget||a.srcElement,b=h.onScriptLoad;a.detachEvent&&!R?a.detachEvent("onreadystatechange",b):a.removeEventListener("load",b,!1);b=h.onScriptError;a.detachEvent&&!R||a.removeEventListener("error",b,!1);return{node:a,id:a&&a.getAttribute("data-requiremodule")}}function I(){var a;for(s();C.length;)if(a=C.shift(),a[0]===
-null)return z(G("mismatch","Mismatched anonymous define() module: "+a[a.length-1]));else y(a)}var S,U,h,L,T,k={waitSeconds:7,baseUrl:"./",paths:{},pkgs:{},shim:{},map:{},config:{}},l={},V={},C=[],o={},Q={},M=1,N=1;L={require:function(a){return a.require?a.require:a.require=h.makeRequire(a.map)},exports:function(a){a.usingExports=!0;if(a.map.isDefine)return a.exports?a.exports:a.exports=o[a.map.id]={}},module:function(a){return a.module?a.module:a.module={id:a.map.id,uri:a.map.url,config:function(){return k.config&&
-k.config[a.map.id]||{}},exports:o[a.map.id]}}};U=function(a){this.events=V[a.id]||{};this.map=a;this.shim=k.shim[a.id];this.depExports=[];this.depMaps=[];this.depMatched=[];this.pluginMaps={};this.depCount=0};U.prototype={init:function(a,b,c,e){e=e||{};if(!this.inited){this.factory=b;if(c)this.on("error",c);else this.events.error&&(c=r(this,function(a){this.emit("error",a)}));this.depMaps=a&&a.slice(0);this.errback=c;this.inited=!0;this.ignore=e.ignore;e.enabled||this.enabled?this.enable():this.check()}},
-defineDep:function(a,b){this.depMatched[a]||(this.depMatched[a]=!0,this.depCount-=1,this.depExports[a]=b)},fetch:function(){if(!this.fetched){this.fetched=!0;h.startTime=(new Date).getTime();var a=this.map;if(this.shim)h.makeRequire(this.map,{enableBuildCallback:!0})(this.shim.deps||[],r(this,function(){return a.prefix?this.callPlugin():this.load()}));else return a.prefix?this.callPlugin():this.load()}},load:function(){var a=this.map.url;Q[a]||(Q[a]=!0,h.load(this.map.id,a))},check:function(){if(this.enabled&&
-!this.enabling){var a,b,c=this.map.id;b=this.depExports;var e=this.exports,m=this.factory;if(this.inited)if(this.error)this.emit("error",this.error);else{if(!this.defining){this.defining=!0;if(this.depCount<1&&!this.defined){if(D(m)){if(this.events.error)try{e=h.execCb(c,m,b,e)}catch(d){a=d}else e=h.execCb(c,m,b,e);if(this.map.isDefine)if((b=this.module)&&b.exports!==void 0&&b.exports!==this.exports)e=b.exports;else if(e===void 0&&this.usingExports)e=this.exports;if(a)return a.requireMap=this.map,
-a.requireModules=[this.map.id],a.requireType="define",z(this.error=a)}else e=m;this.exports=e;if(this.map.isDefine&&!this.ignore&&(o[c]=e,g.onResourceLoad))g.onResourceLoad(h,this.map,this.depMaps);delete l[c];this.defined=!0}this.defining=!1;if(this.defined&&!this.defineEmitted)this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete=!0}}else this.fetch()}},callPlugin:function(){var a=this.map,b=a.id,d=j(a.prefix);this.depMaps.push(d);q(d,"defined",r(this,function(e){var m,
-d;d=this.map.name;var x=this.map.parentMap?this.map.parentMap.name:null,i=h.makeRequire(a.parentMap,{enableBuildCallback:!0,skipMap:!0});if(this.map.unnormalized){if(e.normalize&&(d=e.normalize(d,function(a){return c(a,x,!0)})||""),e=j(a.prefix+"!"+d,this.map.parentMap),q(e,"defined",r(this,function(a){this.init([],function(){return a},null,{enabled:!0,ignore:!0})})),d=l[e.id]){this.depMaps.push(e);if(this.events.error)d.on("error",r(this,function(a){this.emit("error",a)}));d.enable()}}else m=r(this,
-function(a){this.init([],function(){return a},null,{enabled:!0})}),m.error=r(this,function(a){this.inited=!0;this.error=a;a.requireModules=[b];A(l,function(a){a.map.id.indexOf(b+"_unnormalized")===0&&delete l[a.map.id]});z(a)}),m.fromText=r(this,function(b,e){var f=a.name,c=j(f),d=J;e&&(b=e);d&&(J=!1);n(c);try{g.exec(b)}catch(x){throw Error("fromText eval for "+f+" failed: "+x);}d&&(J=!0);this.depMaps.push(c);h.completeLoad(f);i([f],m)}),e.load(a.name,i,m,k)}));h.enable(d,this);this.pluginMaps[d.id]=
-d},enable:function(){this.enabling=this.enabled=!0;t(this.depMaps,r(this,function(a,b){var c,e;if(typeof a==="string"){a=j(a,this.map.isDefine?this.map:this.map.parentMap,!1,!this.skipMap);this.depMaps[b]=a;if(c=L[a.id]){this.depExports[b]=c(this);return}this.depCount+=1;q(a,"defined",r(this,function(a){this.defineDep(b,a);this.check()}));this.errback&&q(a,"error",this.errback)}c=a.id;e=l[c];!L[c]&&e&&!e.enabled&&h.enable(a,this)}));A(this.pluginMaps,r(this,function(a){var b=l[a.id];b&&!b.enabled&&
-h.enable(a,this)}));this.enabling=!1;this.check()},on:function(a,b){var c=this.events[a];c||(c=this.events[a]=[]);c.push(b)},emit:function(a,b){t(this.events[a],function(a){a(b)});a==="error"&&delete this.events[a]}};h={config:k,contextName:b,registry:l,defined:o,urlFetched:Q,defQueue:C,Module:U,makeModuleMap:j,nextTick:g.nextTick,configure:function(a){a.baseUrl&&a.baseUrl.charAt(a.baseUrl.length-1)!=="/"&&(a.baseUrl+="/");var b=k.pkgs,c=k.shim,e={paths:!0,config:!0,map:!0};A(a,function(a,b){e[b]?
-b==="map"?O(k[b],a,!0,!0):O(k[b],a,!0):k[b]=a});if(a.shim)A(a.shim,function(a,b){E(a)&&(a={deps:a});if(a.exports&&!a.exportsFn)a.exportsFn=h.makeShimExports(a);c[b]=a}),k.shim=c;if(a.packages)t(a.packages,function(a){a=typeof a==="string"?{name:a}:a;b[a.name]={name:a.name,location:a.location||a.name,main:(a.main||"main").replace(ea,"").replace($,"")}}),k.pkgs=b;A(l,function(a,b){if(!a.inited&&!a.map.unnormalized)a.map=j(b)});if(a.deps||a.callback)h.require(a.deps||[],a.callback)},makeShimExports:function(a){return function(){var b;
-a.init&&(b=a.init.apply(W,arguments));return b||X(a.exports)}},makeRequire:function(a,f){function d(e,c,i){var k,p;if(f.enableBuildCallback&&c&&D(c))c.__requireJsBuild=!0;if(typeof e==="string"){if(D(c))return z(G("requireargs","Invalid require call"),i);if(a&&L[e])return L[e](l[a.id]);if(g.get)return g.get(h,e,a);k=j(e,a,!1,!0);k=k.id;return!F.call(o,k)?z(G("notloaded",'Module name "'+k+'" has not been loaded yet for context: '+b+(a?"":". Use require([])"))):o[k]}I();h.nextTick(function(){I();p=
-n(j(null,a));p.skipMap=f.skipMap;p.init(e,c,i,{enabled:!0});w()});return d}f=f||{};O(d,{isBrowser:v,toUrl:function(b){var d=b.lastIndexOf("."),f=null;d!==-1&&(f=b.substring(d,b.length),b=b.substring(0,d));return h.nameToUrl(c(b,a&&a.id,!0),f)},defined:function(b){b=j(b,a,!1,!0).id;return F.call(o,b)},specified:function(b){b=j(b,a,!1,!0).id;return F.call(o,b)||F.call(l,b)}});if(!a)d.undef=function(b){s();var c=j(b,a,!0),d=l[b];delete o[b];delete Q[c.url];delete V[b];if(d){if(d.events.defined)V[b]=
-d.events;delete l[b]}};return d},enable:function(a){l[a.id]&&n(a).enable()},completeLoad:function(a){var b,c,d=k.shim[a]||{},g=d.exports;for(s();C.length;){c=C.shift();if(c[0]===null){c[0]=a;if(b)break;b=!0}else c[0]===a&&(b=!0);y(c)}c=l[a];if(!b&&!o[a]&&c&&!c.inited)if(k.enforceDefine&&(!g||!X(g)))if(p(a))return;else return z(G("nodefine","No define call for "+a,null,[a]));else y([a,d.deps||[],d.exportsFn]);w()},nameToUrl:function(a,b){var c,d,i,h,j,l;if(g.jsExtRegExp.test(a))h=a+(b||"");else{c=
-k.paths;d=k.pkgs;h=a.split("/");for(j=h.length;j>0;j-=1)if(l=h.slice(0,j).join("/"),i=d[l],l=c[l]){E(l)&&(l=l[0]);h.splice(0,j,l);break}else if(i){c=a===i.name?i.location+"/"+i.main:i.location;h.splice(0,j,c);break}h=h.join("/");h+=b||(/\?/.test(h)?"":".js");h=(h.charAt(0)==="/"||h.match(/^[\w\+\.\-]+:/)?"":k.baseUrl)+h}return k.urlArgs?h+((h.indexOf("?")===-1?"?":"&")+k.urlArgs):h},load:function(a,b){g.load(h,a,b)},execCb:function(a,b,c,d){return b.apply(d,c)},onScriptLoad:function(a){if(a.type===
-"load"||ga.test((a.currentTarget||a.srcElement).readyState))H=null,a=B(a),h.completeLoad(a.id)},onScriptError:function(a){var b=B(a);if(!p(b.id))return z(G("scripterror","Script error",a,[b.id]))}};h.require=h.makeRequire();return h}};g({});t(["toUrl","undef","defined","specified"],function(b){g[b]=function(){var c=w._;return c.require[b].apply(c,arguments)}});if(v&&(u=s.head=document.getElementsByTagName("head")[0],y=document.getElementsByTagName("base")[0]))u=s.head=y.parentNode;g.onError=function(b){throw b;
-};g.load=function(b,c,d){var g=b&&b.config||{},i;if(v)return i=g.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml","html:script"):document.createElement("script"),i.type=g.scriptType||"text/javascript",i.charset="utf-8",i.async=!0,i.setAttribute("data-requirecontext",b.contextName),i.setAttribute("data-requiremodule",c),i.attachEvent&&!(i.attachEvent.toString&&i.attachEvent.toString().indexOf("[native code")<0)&&!R?(J=!0,i.attachEvent("onreadystatechange",b.onScriptLoad)):(i.addEventListener("load",
-b.onScriptLoad,!1),i.addEventListener("error",b.onScriptError,!1)),i.src=d,I=i,y?u.insertBefore(i,y):u.appendChild(i),I=null,i;else aa&&(importScripts(d),b.completeLoad(c))};v&&N(document.getElementsByTagName("script"),function(b){if(!u)u=b.parentNode;if(q=b.getAttribute("data-main")){if(!n.baseUrl)B=q.split("/"),Y=B.pop(),Z=B.length?B.join("/")+"/":"./",n.baseUrl=Z,q=Y;q=q.replace($,"");n.deps=n.deps?n.deps.concat(q):[q];return!0}});define=function(b,c,d){var g,i;typeof b!=="string"&&(d=c,c=b,b=
-null);E(c)||(d=c,c=[]);!c.length&&D(d)&&d.length&&(d.toString().replace(ca,"").replace(da,function(b,d){c.push(d)}),c=(d.length===1?["require"]:["require","exports","module"]).concat(c));if(J&&(g=I||ba()))b||(b=g.getAttribute("data-requiremodule")),i=w[g.getAttribute("data-requirecontext")];(i?i.defQueue:P).push([b,c,d])};define.amd={jQuery:!0};g.exec=function(b){return eval(b)};g(n)}})(this);
35 vendor/require-2.1.2.js
View
@@ -1,35 +0,0 @@
-/*
- RequireJS 2.1.2 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
- Available via the MIT or new BSD license.
- see: http://github.com/jrburke/requirejs for details
-*/
-var requirejs,require,define;
-(function(Y){function H(b){return"[object Function]"===L.call(b)}function I(b){return"[object Array]"===L.call(b)}function x(b,c){if(b){var d;for(d=0;d<b.length&&(!b[d]||!c(b[d],d,b));d+=1);}}function M(b,c){if(b){var d;for(d=b.length-1;-1<d&&(!b[d]||!c(b[d],d,b));d-=1);}}function r(b,c){return da.call(b,c)}function i(b,c){return r(b,c)&&b[c]}function E(b,c){for(var d in b)if(r(b,d)&&c(b[d],d))break}function Q(b,c,d,i){c&&E(c,function(c,h){if(d||!r(b,h))i&&"string"!==typeof c?(b[h]||(b[h]={}),Q(b[h],
-c,d,i)):b[h]=c});return b}function t(b,c){return function(){return c.apply(b,arguments)}}function Z(b){if(!b)return b;var c=Y;x(b.split("."),function(b){c=c[b]});return c}function J(b,c,d,i){c=Error(c+"\nhttp://requirejs.org/docs/errors.html#"+b);c.requireType=b;c.requireModules=i;d&&(c.originalError=d);return c}function ea(b){function c(a,g,v){var e,n,b,c,d,j,f,h=g&&g.split("/");e=h;var l=m.map,k=l&&l["*"];if(a&&"."===a.charAt(0))if(g){e=i(m.pkgs,g)?h=[g]:h.slice(0,h.length-1);g=a=e.concat(a.split("/"));
-for(e=0;g[e];e+=1)if(n=g[e],"."===n)g.splice(e,1),e-=1;else if(".."===n)if(1===e&&(".."===g[2]||".."===g[0]))break;else 0<e&&(g.splice(e-1,2),e-=2);e=i(m.pkgs,g=a[0]);a=a.join("/");e&&a===g+"/"+e.main&&(a=g)}else 0===a.indexOf("./")&&(a=a.substring(2));if(v&&(h||k)&&l){g=a.split("/");for(e=g.length;0<e;e-=1){b=g.slice(0,e).join("/");if(h)for(n=h.length;0<n;n-=1)if(v=i(l,h.slice(0,n).join("/")))if(v=i(v,b)){c=v;d=e;break}if(c)break;!j&&(k&&i(k,b))&&(j=i(k,b),f=e)}!c&&j&&(c=j,d=f);c&&(g.splice(0,d,
-c),a=g.join("/"))}return a}function d(a){z&&x(document.getElementsByTagName("script"),function(g){if(g.getAttribute("data-requiremodule")===a&&g.getAttribute("data-requirecontext")===j.contextName)return g.parentNode.removeChild(g),!0})}function y(a){var g=i(m.paths,a);if(g&&I(g)&&1<g.length)return d(a),g.shift(),j.require.undef(a),j.require([a]),!0}function f(a){var g,b=a?a.indexOf("!"):-1;-1<b&&(g=a.substring(0,b),a=a.substring(b+1,a.length));return[g,a]}function h(a,g,b,e){var n,u,d=null,h=g?g.name:
-null,l=a,m=!0,k="";a||(m=!1,a="_@r"+(L+=1));a=f(a);d=a[0];a=a[1];d&&(d=c(d,h,e),u=i(p,d));a&&(d?k=u&&u.normalize?u.normalize(a,function(a){return c(a,h,e)}):c(a,h,e):(k=c(a,h,e),a=f(k),d=a[0],k=a[1],b=!0,n=j.nameToUrl(k)));b=d&&!u&&!b?"_unnormalized"+(M+=1):"";return{prefix:d,name:k,parentMap:g,unnormalized:!!b,url:n,originalName:l,isDefine:m,id:(d?d+"!"+k:k)+b}}function q(a){var g=a.id,b=i(k,g);b||(b=k[g]=new j.Module(a));return b}function s(a,g,b){var e=a.id,n=i(k,e);if(r(p,e)&&(!n||n.defineEmitComplete))"defined"===
-g&&b(p[e]);else q(a).on(g,b)}function C(a,g){var b=a.requireModules,e=!1;if(g)g(a);else if(x(b,function(g){if(g=i(k,g))g.error=a,g.events.error&&(e=!0,g.emit("error",a))}),!e)l.onError(a)}function w(){R.length&&(fa.apply(F,[F.length-1,0].concat(R)),R=[])}function A(a,g,b){var e=a.map.id;a.error?a.emit("error",a.error):(g[e]=!0,x(a.depMaps,function(e,c){var d=e.id,h=i(k,d);h&&(!a.depMatched[c]&&!b[d])&&(i(g,d)?(a.defineDep(c,p[d]),a.check()):A(h,g,b))}),b[e]=!0)}function B(){var a,g,b,e,n=(b=1E3*m.waitSeconds)&&
-j.startTime+b<(new Date).getTime(),c=[],h=[],f=!1,l=!0;if(!T){T=!0;E(k,function(b){a=b.map;g=a.id;if(b.enabled&&(a.isDefine||h.push(b),!b.error))if(!b.inited&&n)y(g)?f=e=!0:(c.push(g),d(g));else if(!b.inited&&(b.fetched&&a.isDefine)&&(f=!0,!a.prefix))return l=!1});if(n&&c.length)return b=J("timeout","Load timeout for modules: "+c,null,c),b.contextName=j.contextName,C(b);l&&x(h,function(a){A(a,{},{})});if((!n||e)&&f)if((z||$)&&!U)U=setTimeout(function(){U=0;B()},50);T=!1}}function D(a){r(p,a[0])||
-q(h(a[0],null,!0)).init(a[1],a[2])}function G(a){var a=a.currentTarget||a.srcElement,b=j.onScriptLoad;a.detachEvent&&!V?a.detachEvent("onreadystatechange",b):a.removeEventListener("load",b,!1);b=j.onScriptError;(!a.detachEvent||V)&&a.removeEventListener("error",b,!1);return{node:a,id:a&&a.getAttribute("data-requiremodule")}}function K(){var a;for(w();F.length;){a=F.shift();if(null===a[0])return C(J("mismatch","Mismatched anonymous define() module: "+a[a.length-1]));D(a)}}var T,W,j,N,U,m={waitSeconds:7,
-baseUrl:"./",paths:{},pkgs:{},shim:{},map:{},config:{}},k={},X={},F=[],p={},S={},L=1,M=1;N={require:function(a){return a.require?a.require:a.require=j.makeRequire(a.map)},exports:function(a){a.usingExports=!0;if(a.map.isDefine)return a.exports?a.exports:a.exports=p[a.map.id]={}},module:function(a){return a.module?a.module:a.module={id:a.map.id,uri:a.map.url,config:function(){return m.config&&i(m.config,a.map.id)||{}},exports:p[a.map.id]}}};W=function(a){this.events=i(X,a.id)||{};this.map=a;this.shim=
-i(m.shim,a.id);this.depExports=[];this.depMaps=[];this.depMatched=[];this.pluginMaps={};this.depCount=0};W.prototype={init:function(a,b,c,e){e=e||{};if(!this.inited){this.factory=b;if(c)this.on("error",c);else this.events.error&&(c=t(this,function(a){this.emit("error",a)}));this.depMaps=a&&a.slice(0);this.errback=c;this.inited=!0;this.ignore=e.ignore;e.enabled||this.enabled?this.enable():this.check()}},defineDep:function(a,b){this.depMatched[a]||(this.depMatched[a]=!0,this.depCount-=1,this.depExports[a]=
-b)},fetch:function(){if(!this.fetched){this.fetched=!0;j.startTime=(new Date).getTime();var a=this.map;if(this.shim)j.makeRequire(this.map,{enableBuildCallback:!0})(this.shim.deps||[],t(this,function(){return a.prefix?this.callPlugin():this.load()}));else return a.prefix?this.callPlugin():this.load()}},load:function(){var a=this.map.url;S[a]||(S[a]=!0,j.load(this.map.id,a))},check:function(){if(this.enabled&&!this.enabling){var a,b,c=this.map.id;b=this.depExports;var e=this.exports,n=this.factory;
-if(this.inited)if(this.error)this.emit("error",this.error);else{if(!this.defining){this.defining=!0;if(1>this.depCount&&!this.defined){if(H(n)){if(this.events.error)try{e=j.execCb(c,n,b,e)}catch(d){a=d}else e=j.execCb(c,n,b,e);this.map.isDefine&&((b=this.module)&&void 0!==b.exports&&b.exports!==this.exports?e=b.exports:void 0===e&&this.usingExports&&(e=this.exports));if(a)return a.requireMap=this.map,a.requireModules=[this.map.id],a.requireType="define",C(this.error=a)}else e=n;this.exports=e;if(this.map.isDefine&&
-!this.ignore&&(p[c]=e,l.onResourceLoad))l.onResourceLoad(j,this.map,this.depMaps);delete k[c];this.defined=!0}this.defining=!1;this.defined&&!this.defineEmitted&&(this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete=!0)}}else this.fetch()}},callPlugin:function(){var a=this.map,b=a.id,d=h(a.prefix);this.depMaps.push(d);s(d,"defined",t(this,function(e){var n,d;d=this.map.name;var v=this.map.parentMap?this.map.parentMap.name:null,f=j.makeRequire(a.parentMap,{enableBuildCallback:!0,
-skipMap:!0});if(this.map.unnormalized){if(e.normalize&&(d=e.normalize(d,function(a){return c(a,v,!0)})||""),e=h(a.prefix+"!"+d,this.map.parentMap),s(e,"defined",t(this,function(a){this.init([],function(){return a},null,{enabled:!0,ignore:!0})})),d=i(k,e.id)){this.depMaps.push(e);if(this.events.error)d.on("error",t(this,function(a){this.emit("error",a)}));d.enable()}}else n=t(this,function(a){this.init([],function(){return a},null,{enabled:!0})}),n.error=t(this,function(a){this.inited=!0;this.error=
-a;a.requireModules=[b];E(k,function(a){0===a.map.id.indexOf(b+"_unnormalized")&&delete k[a.map.id]});C(a)}),n.fromText=t(this,function(e,c){var d=a.name,u=h(d),v=O;c&&(e=c);v&&(O=!1);q(u);r(m.config,b)&&(m.config[d]=m.config[b]);try{l.exec(e)}catch(k){throw Error("fromText eval for "+d+" failed: "+k);}v&&(O=!0);this.depMaps.push(u);j.completeLoad(d);f([d],n)}),e.load(a.name,f,n,m)}));j.enable(d,this);this.pluginMaps[d.id]=d},enable:function(){this.enabling=this.enabled=!0;x(this.depMaps,t(this,function(a,
-b){var c,e;if("string"===typeof a){a=h(a,this.map.isDefine?this.map:this.map.parentMap,!1,!this.skipMap);this.depMaps[b]=a;if(c=i(N,a.id)){this.depExports[b]=c(this);return}this.depCount+=1;s(a,"defined",t(this,function(a){this.defineDep(b,a);this.check()}));this.errback&&s(a,"error",this.errback)}c=a.id;e=k[c];!r(N,c)&&(e&&!e.enabled)&&j.enable(a,this)}));E(this.pluginMaps,t(this,function(a){var b=i(k,a.id);b&&!b.enabled&&j.enable(a,this)}));this.enabling=!1;this.check()},on:function(a,b){var c=
-this.events[a];c||(c=this.events[a]=[]);c.push(b)},emit:function(a,b){x(this.events[a],function(a){a(b)});"error"===a&&delete this.events[a]}};j={config:m,contextName:b,registry:k,defined:p,urlFetched:S,defQueue:F,Module:W,makeModuleMap:h,nextTick:l.nextTick,configure:function(a){a.baseUrl&&"/"!==a.baseUrl.charAt(a.baseUrl.length-1)&&(a.baseUrl+="/");var b=m.pkgs,c=m.shim,e={paths:!0,config:!0,map:!0};E(a,function(a,b){e[b]?"map"===b?Q(m[b],a,!0,!0):Q(m[b],a,!0):m[b]=a});a.shim&&(E(a.shim,function(a,
-b){I(a)&&(a={deps:a});if((a.exports||a.init)&&!a.exportsFn)a.exportsFn=j.makeShimExports(a);c[b]=a}),m.shim=c);a.packages&&(x(a.packages,function(a){a="string"===typeof a?{name:a}:a;b[a.name]={name:a.name,location:a.location||a.name,main:(a.main||"main").replace(ga,"").replace(aa,"")}}),m.pkgs=b);E(k,function(a,b){!a.inited&&!a.map.unnormalized&&(a.map=h(b))});if(a.deps||a.callback)j.require(a.deps||[],a.callback)},makeShimExports:function(a){return function(){var b;a.init&&(b=a.init.apply(Y,arguments));
-return b||a.exports&&Z(a.exports)}},makeRequire:function(a,d){function f(e,c,u){var i,m;d.enableBuildCallback&&(c&&H(c))&&(c.__requireJsBuild=!0);if("string"===typeof e){if(H(c))return C(J("requireargs","Invalid require call"),u);if(a&&r(N,e))return N[e](k[a.id]);if(l.get)return l.get(j,e,a);i=h(e,a,!1,!0);i=i.id;return!r(p,i)?C(J("notloaded",'Module name "'+i+'" has not been loaded yet for context: '+b+(a?"":". Use require([])"))):p[i]}K();j.nextTick(function(){K();m=q(h(null,a));m.skipMap=d.skipMap;
-m.init(e,c,u,{enabled:!0});B()});return f}d=d||{};Q(f,{isBrowser:z,toUrl:function(b){var d=b.lastIndexOf("."),g=null;-1!==d&&(g=b.substring(d,b.length),b=b.substring(0,d));return j.nameToUrl(c(b,a&&a.id,!0),g)},defined:function(b){return r(p,h(b,a,!1,!0).id)},specified:function(b){b=h(b,a,!1,!0).id;return r(p,b)||r(k,b)}});a||(f.undef=function(b){w();var c=h(b,a,!0),d=i(k,b);delete p[b];delete S[c.url];delete X[b];d&&(d.events.defined&&(X[b]=d.events),delete k[b])});return f},enable:function(a){i(k,
-a.id)&&q(a).enable()},completeLoad:function(a){var b,c,d=i(m.shim,a)||{},h=d.exports;for(w();F.length;){c=F.shift();if(null===c[0]){c[0]=a;if(b)break;b=!0}else c[0]===a&&(b=!0);D(c)}c=i(k,a);if(!b&&!r(p,a)&&c&&!c.inited){if(m.enforceDefine&&(!h||!Z(h)))return y(a)?void 0:C(J("nodefine","No define call for "+a,null,[a]));D([a,d.deps||[],d.exportsFn])}B()},nameToUrl:function(a,b){var c,d,h,f,j,k;if(l.jsExtRegExp.test(a))f=a+(b||"");else{c=m.paths;d=m.pkgs;f=a.split("/");for(j=f.length;0<j;j-=1)if(k=
-f.slice(0,j).join("/"),h=i(d,k),k=i(c,k)){I(k)&&(k=k[0]);f.splice(0,j,k);break}else if(h){c=a===h.name?h.location+"/"+h.main:h.location;f.splice(0,j,c);break}f=f.join("/");f+=b||(/\?/.test(f)?"":".js");f=("/"===f.charAt(0)||f.match(/^[\w\+\.\-]+:/)?"":m.baseUrl)+f}return m.urlArgs?f+((-1===f.indexOf("?")?"?":"&")+m.urlArgs):f},load:function(a,b){l.load(j,a,b)},execCb:function(a,b,c,d){return b.apply(d,c)},onScriptLoad:function(a){if("load"===a.type||ha.test((a.currentTarget||a.srcElement).readyState))P=
-null,a=G(a),j.completeLoad(a.id)},onScriptError:function(a){var b=G(a);if(!y(b.id))return C(J("scripterror","Script error",a,[b.id]))}};j.require=j.makeRequire();return j}var l,w,A,D,s,G,P,K,ba,ca,ia=/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,ja=/[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,aa=/\.js$/,ga=/^\.\//;w=Object.prototype;var L=w.toString,da=w.hasOwnProperty,fa=Array.prototype.splice,z=!!("undefined"!==typeof window&&navigator&&document),$=!z&&"undefined"!==typeof importScripts,ha=z&&
-"PLAYSTATION 3"===navigator.platform?/^complete$/:/^(complete|loaded)$/,V="undefined"!==typeof opera&&"[object Opera]"===opera.toString(),B={},q={},R=[],O=!1;if("undefined"===typeof define){if("undefined"!==typeof requirejs){if(H(requirejs))return;q=requirejs;requirejs=void 0}"undefined"!==typeof require&&!H(require)&&(q=require,require=void 0);l=requirejs=function(b,c,d,y){var f,h="_";!I(b)&&"string"!==typeof b&&(f=b,I(c)?(b=c,c=d,d=y):b=[]);f&&f.context&&(h=f.context);(y=i(B,h))||(y=B[h]=l.s.newContext(h));
-f&&y.configure(f);return y.require(b,c,d)};l.config=function(b){return l(b)};l.nextTick="undefined"!==typeof setTimeout?function(b){setTimeout(b,4)}:function(b){b()};require||(require=l);l.version="2.1.2";l.jsExtRegExp=/^\/|:|\?|\.js$/;l.isBrowser=z;w=l.s={contexts:B,newContext:ea};l({});x(["toUrl","undef","defined","specified"],function(b){l[b]=function(){var c=B._;return c.require[b].apply(c,arguments)}});if(z&&(A=w.head=document.getElementsByTagName("head")[0],D=document.getElementsByTagName("base")[0]))A=
-w.head=D.parentNode;l.onError=function(b){throw b;};l.load=function(b,c,d){var i=b&&b.config||{},f;if(z)return f=i.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml","html:script"):document.createElement("script"),f.type=i.scriptType||"text/javascript",f.charset="utf-8",f.async=!0,f.setAttribute("data-requirecontext",b.contextName),f.setAttribute("data-requiremodule",c),f.attachEvent&&!(f.attachEvent.toString&&0>f.attachEvent.toString().indexOf("[native code"))&&!V?(O=!0,f.attachEvent("onreadystatechange",
-b.onScriptLoad)):(f.addEventListener("load",b.onScriptLoad,!1),f.addEventListener("error",b.onScriptError,!1)),f.src=d,K=f,D?A.insertBefore(f,D):A.appendChild(f),K=null,f;$&&(importScripts(d),b.completeLoad(c))};z&&M(document.getElementsByTagName("script"),function(b){A||(A=b.parentNode);if(s=b.getAttribute("data-main"))return q.baseUrl||(G=s.split("/"),ba=G.pop(),ca=G.length?G.join("/")+"/":"./",q.baseUrl=ca,s=ba),s=s.replace(aa,""),q.deps=q.deps?q.deps.concat(s):[s],!0});define=function(b,c,d){var i,
-f;"string"!==typeof b&&(d=c,c=b,b=null);I(c)||(d=c,c=[]);!c.length&&H(d)&&d.length&&(d.toString().replace(ia,"").replace(ja,function(b,d){c.push(d)}),c=(1===d.length?["require"]:["require","exports","module"]).concat(c));if(O){if(!(i=K))P&&"interactive"===P.readyState||M(document.getElementsByTagName("script"),function(b){if("interactive"===b.readyState)return P=b}),i=P;i&&(b||(b=i.getAttribute("data-requiremodule")),f=B[i.getAttribute("data-requirecontext")])}(f?f.defQueue:R).push([b,c,d])};define.amd=
-{jQuery:!0};l.exec=function(b){return eval(b)};l(q)}})(this);
107 vendor/steal-3.2.3/dev/dev.js
View
@@ -0,0 +1,107 @@
+/*global window: false, console: true, opera: true */
+//
+/**
+ * @class steal.dev
+ * @parent stealjs
+ * Provides helper functions for development that get removed when put in production mode.
+ * This means you can leave <code>steal.dev.log("hello world")</code> in your code and it
+ * will get removed in prodution.
+ * <h3>Examples</h3>
+ * @codestart
+ * steal.dev.log("Something is happening");
+ * steal.dev.warn("Something bad is happening");
+ * @codeend
+ */
+steal.dev = {
+ regexps: {
+ colons: /::/,
+ words: /([A-Z]+)([A-Z][a-z])/g,
+ lowerUpper: /([a-z\d])([A-Z])/g,
+ dash: /([a-z\d])([A-Z])/g
+ },
+ underscore: function( s ) {
+ var regs = this.regexps;
+ return s.replace(regs.colons, '/').
+ replace(regs.words, '$1_$2').
+ replace(regs.lowerUpper, '$1_$2').
+ replace(regs.dash, '_').toLowerCase();
+ },
+ isHappyName: function( name ) {
+ //make sure names are close to the current path
+ var path = steal.cur().path.replace(/\.[^$]+$/, "").split('/'),
+ //make sure parts in name match
+ parts = name.split('.');
+
+ for ( var i = 0; i < parts.length && path.length; i++ ) {
+ if (path[i] && parts[i].toLowerCase() != path[i] && this.underscore(parts[i]) != path[i] && this.underscore(parts[i]) != path[i].replace(/_controller/, "") ) {
+ this.warn("Are you sure " + name + " belongs in " + steal.cur().path);
+ }
+ }
+
+
+ },
+
+ logLevel : 0,
+ /**
+ * Adds a warning message to the console.
+ * @codestart
+ * steal.dev.warn("something evil");
+ * @codeend
+ * @param {String} out the message
+ */
+ warn: function( out ) {
+ if(steal.options.logLevel < 2){
+ Array.prototype.unshift.call(arguments, 'steal.js WARN:');
+ if ( window.console && console.warn ) {
+ this._logger( "warn", Array.prototype.slice.call(arguments) );
+ } else if ( window.console && console.log ) {
+ this._logger( "log", Array.prototype.slice.call(arguments) );
+ } else if ( window.opera && window.opera.postError ) {
+ opera.postError("steal.js WARNING: " + out);
+ }
+ }
+
+ },
+ /**
+ * Adds a message to the console.
+ * @codestart
+ * steal.dev.log("hi");
+ * @codeend
+ * @param {String} out the message
+ */
+ log: function( out ) {
+ if (steal.options.logLevel < 1) {
+ if (window.console && console.log) {
+ Array.prototype.unshift.call(arguments, 'steal.js INFO:');
+ this._logger( "log", Array.prototype.slice.call(arguments) );
+ }
+ else if (window.opera && window.opera.postError) {
+ opera.postError("steal.js INFO: " + out);
+ }
+ }
+ },
+ _logger:function(type, arr){
+ if(console.log.apply){
+ console[type].apply(console, arr)
+ } else {
+ console[type](arr)
+ }
+ }
+};
+
+//stuff for jmvc
+/**
+ * @class jQuery
+ * @constructor blah
+ */
+
+//
+/**
+ * @class jQuery.fn
+ * @constructor blah
+ */
+//
+/**
+ * @class jQuery.event.special
+ */
+// as fasf sa
2,098 vendor/steal-3.2.3/steal.js
View
@@ -0,0 +1,2098 @@
+(function(){
+
+ // Gets the window (even if there is none)
+ var win = (function(){return this}).call(null),
+ // String constants (for better minification)
+ STR_ONLOAD = "onload",
+ STR_ONERROR = "onerror",
+ STR_ONREADYSTATECHANGE = "onreadystatechange",
+ STR_CREATE_ELEMENT = 'createElement',
+ STR_GET_BY_TAG = 'getElementsByTagName',
+
+ // the document ( might not exist in rhino )
+ doc = win.document,
+
+ // creates a script tag
+ scriptTag = function() {
+ var start = doc[STR_CREATE_ELEMENT]('script');
+ start.type = 'text/javascript';
+ return start;
+ },
+ // a function that returns the head element
+ // creates and caches the lookup if necessary
+ head = function() {
+ var d = doc,
+ de = d.documentElement,
+ heads = d[STR_GET_BY_TAG]("head"),
+ hd = heads[0];
+ if (! hd ) {
+ hd = d[STR_CREATE_ELEMENT]('head');
+ de.insertBefore(hd, de.firstChild);
+ }
+ // replace head so it runs fast next time.
+ head = function(){
+ return hd;
+ }
+ return hd;
+ },
+ // extends one object with another
+ extend = function( d, s ) {
+ for ( var p in s ) {
+ d[p] = s[p];
+ }
+ return d;
+ },
+ // a jQuery-like $.each
+ each = function(arr, cb){
+ for(var i =0, len = arr.length; i <len; i++){
+ cb.call(arr[i],i,arr[i])
+ }
+ return arr;
+ },
+ // makes an array of things
+ makeArray = function(args){
+ var arr = [];
+ each(args, function(i, str){arr[i] = str});
+ return arr;
+ },
+ // testing support for various browser behaviors
+ support = {
+ // does onerror work in script tags?
+ error: doc && (function(){
+ var script = scriptTag();
+ script.setAttribute( "onerror", "return;" );
+ return typeof script["onerror"] === "function" ?
+ true : "onerror" in script
+ })(),
+ // If scripts support interactive ready state.
+ // This is set later.
+ interactive: false,
+ attachEvent : doc && scriptTag().attachEvent
+ },
+ // a startup function that will be called when steal is ready
+ startup = function(){},
+ // the old steal value
+ oldsteal = win.steal,
+ // if oldsteal is an object
+ // we use it as options to configure steal
+ opts = typeof oldsteal == 'object' ? oldsteal : {};
+
+ // =============================== STEAL ===============================
+
+ /**
+ * @class steal
+ * @parent stealjs
+ *
+ * __steal__ is a function that loads scripts, css, and
+ * other resources into your application.
+ *
+ * steal(FILE_or_FUNCTION, ...)
+ *
+ * ## Quick Walkthrough
+ *
+ * Add a script tag that loads <code>steal/steal.js</code> and add
+ * the path to the first file to load in the query string like:
+ *
+ * &lt;script type='text/javascript'
+ * src='../steal/steal.js?myapp/myapp.js'>
+ * &lt;/script>
+ *
+ * Then, start loading things and using them like:
+ *
+ * steal('myapp/tabs.js',
+ * 'myapp/slider.js',
+ * 'myapp/style.css',function(){
+ *
+ * // tabs and slider have loaded
+ * $('#tabs').tabs();
+ * $('#slider').slider()
+ * })
+ *
+ * Make sure your widgets load their dependencies too:
+ *
+ * // myapp/tabs.js
+ * steal('jquery', function(){
+ * $.fn.tabs = function(){
+ * ...
+ * }
+ * })
+ *
+ * ## Examples:
+ *
+ * // Loads ROOT/jquery/controller/controller.js
+ * steal('jquery/controller')
+ * steal('jquery/controller/controller.js')
+ *
+ * // Loads coffee script type and a coffee file relative to
+ * // the current file
+ * steal('steal/coffee').then('./mycoffee.coffee')
+ *
+ * // Load 2 files and dependencies in parallel and
+ * // callback when both have completed
+ * steal('jquery/controller','jquery/model', function(){
+ * // $.Controller and $.Model are available
+ * })
+ *
+ * // Loads a coffee script with a non-standard extension (cf)
+ * // relative to the current page and instructs the build
+ * // system to not package it (but it will still be loaded).
+ * steal({
+ * src: "./foo.cf",
+ * packaged: false,
+ * type: "coffee"
+ * })
+ *
+ * The following is a longer walkthrough of how to install
+ * and use steal:
+ *
+ * ## Adding steal to a page
+ *
+ * After installing StealJS (or JavaScriptMVC),
+ * find the <code>steal</code> folder with
+ * <code>steal/steal.js</code>.
+ *
+ * To use steal, add a script tag
+ * to <code>steal/steal.js</code> to your
+ * html pages.
+ *
+ * This walkthrough assumes you have the steal script
+ * in <code>public/steal/steal.js</code> and a directory
+ * structure like:
+ *
+ * @codestart text
+ * /public
+ * /steal
+ * /pages
+ * myapp.html
+ * /myapp
+ * myapp.js
+ * jquery.js
+ * jquery.ui.tabs.js
+ * @codeend
+ *
+ * To use steal in <code>public/pages/myapp.html</code>,
+ * add a script tag in <code>myapp.html</code>:
+ *
+ * @codestart html
+ * &lt;script type='text/javascript'
+ * src='../steal/steal.js'>
+ * &lt;/script>
+ * @codeend
+ *
+ * <div class='whisper'>PRO TIP: Bottom load your scripts. It
+ * will increase your application's percieved response time.</div>
+ *
+ * ## Loading the First Script
+ *
+ * Once steal has been added to your page, it's time
+ * to load scripts. We want to load <code>myapp.js</code>
+ * and have it load <code>jquery.js</code> and
+ * <code>jquery.ui.tabs.js</code>.
+ *
+ * By default, steal likes your scripts
+ * to be within in the [steal.static.root steal.root] folder. The [steal.root] the
+ * folder contains the <code>steal</code> folder. In this example,
+ * it is the <code>public</code> folder.
+ *
+ * To load <code>myapp/myapp.js</code>, we have two options:
+ *
+ * #### Add a script tag
+ *
+ * Add a script tag after the steal
+ * script that 'steals' <code>myapp.js</code> like:
+ *
+ * @codestart html
+ * &lt;script type='text/javascript'>
+ * steal('myapp/myapp.js')
+ * &lt;/script>
+ * @codeend
+ *
+ * #### Add the script parameter
+ *
+ * The most common (and shortest) way to load <code>myapp.js</code>
+ * is to add the script path to the steal script's src after in the
+ * query params. So, instead of adding a script, we change
+ * the steal script from:
+ *
+ * @codestart html
+ * &lt;script type='text/javascript'
+ * src='../steal/steal.js'>
+ * &lt;/script>
+ * @codeend
+ *
+ * To
+ *
+ * @codestart html
+ * &lt;script type='text/javascript'
+ * src='../steal/steal.js?<b>myapp/myapp.js</b>'>
+ * &lt;/script>
+ * @codeend
+ *
+ * <div class='whisper'>PRO TIP: You can also just add
+ * <code>?myapp</code> to the query string.</div>
+ *
+ * ## Loading Scripts
+ *
+ * We want to load <code>jquery.js</code> and
+ * <code>jquery.ui.tabs.js</code> into the page and then
+ * add then create a tabs widget. First we need to load
+ * <code>jquery.js</code>.
+ *
+ * By default, steal loads script relative to [steal.root]. To
+ * load <code>myapp/jquery.js</code> we can the following to
+ * <code>myapp.js</code>:
+ *
+ * steal('myapp/jquery.js');
+ *
+ * But, we can also load relative to <code>myapp.js</code> like:
+ *
+ * steal('./jquery.js');
+ *
+ * Next, we need to load <code>jquery.ui.tabs.js</code>. You
+ * might expect something like:
+ *
+ * steal('./jquery.js','./jquery.ui.tabs.js')
+ *
+ * to work. But there are two problems / complications:
+ *
+ * - steal loads scripts in parallel and runs out of order
+ * - <code>jquery.ui.tabs.js</code> depends on jQuery being loaded
+ *
+ * This means that steal might load <code>jquery.ui.tabs.js</code>
+ * before <code>jquery.js</code>. But this is easily fixed.
+ *
+ * [steal.static.then] waits until all previous scripts have loaded and
+ * run before loading scripts after it. We can load <code>jquery.ui.tabs.js</code>
+ * after <code>jquery.js</code> like:
+ *
+ * steal('./jquery.js').then('./jquery.ui.tabs.js')
+ *
+ * Finally, we need to add tabs to the page after
+ * the tabs's widget has loaded. We can add a callback function to
+ * steal that will get called when all previous scripts have finished
+ * loading:
+ *
+ * steal('./jquery.js').then('./jquery.ui.tabs.js', function($){
+ * $('#tabs').tabs();
+ * })
+ *
+ * ## Other Info
+ *
+ * ### Exclude Code Blocks From Production
+ *
+ * To exclude code blocks from being included in
+ * production builds, add the following around
+ * the code blocks.
+ *
+ * //!steal-remove-start
+ * code to be removed at build
+ * //!steal-remove-end
+ *
+ * ### Lookup Paths
+ *
+ * By default steal loads resources relative
+ * to [steal.static.root steal.root]. For example, the following
+ * loads foo.js in <code>steal.root</code>:
+ *
+ * steal('foo.js'); // loads //foo.js
+ *
+ * This is the same as writing:
+ *
+ * steal('//foo.js');
+ *
+ * Steal uses <code>'//'</code> to designate the [steal.static.root steal.root]
+ * folder.
+ *
+ * To load relative to the current file, add <code>"./"</code> or
+ * <code>"../"</code>:
+ *
+ * steal("./bar.js","../folder/zed.js");
+ *
+ * Often, scripts can be found in a folder within the same
+ * name. For example, [jQuery.Controller $.Controller] is
+ * in <code>//jquery/controller/controller.js</code>. For convience,
+ * if steal is provided a path without an extension like:
+ *
+ * steal('FOLDER/PLUGIN');
+ *
+ * It is the same as writing:
+ *
+ * steal('FOLDER/PLUGIN/PLUGIN.js')
+ *
+ * This means that <code>//jquery/controller/controller.js</code>
+ * can be loaded like:
+ *
+ * steal('jquery/controller')
+ *
+ * ### Types
+ *
+ * steal can load resources other than JavaScript.
+ *
+ *
+ * @constructor
+ *
+ * Loads resources specified by each argument. By default, resources
+ * are loaded in parallel and run in any order.
+ *
+ *
+ * @param {String|Function|Object} resource...
+ *
+ * Each argument specifies a resource. Resources can
+ * be given as a:
+ *
+ * ### Object
+ *
+ * An object that specifies the loading and build
+ * behavior of a resource.
+ *
+ * steal({
+ * src: "myfile.cf",
+ * type: "coffee",
+ * packaged: true,
+ * unique: true,
+ * ignore: false,
+ * waits: false
+ * })
+ *
+ * The available options are:
+ *
+ * - __src__ {*String*} - the path to the resource.
+ *
+ * - __waits__ {*Boolean default=false*} - true the resource should wait
+ * for prior steals to load and run. False if the resource should load and run in
+ * parallel. This defaults to true for functions.
+ *
+ * - __unique__ {*Boolean default=true*} - true if this is a unique resource
+ * that 'owns' this url. This is true for files, false for functions.
+ *
+ * - __ignore__ {*Boolean default=false*} - true if this resource should
+ * not be built into a production file and not loaded in
+ * production. This is great for script that should only be available
+ * in development mode.
+ *
+ * - __packaged__ {*Boolean default=true*} - true if the script should be built
+ * into the production file. false if the script should not be built
+ * into the production file, but still loaded. This is useful for
+ * loading 'packages'.
+ *
+ * - __type__ {*String default="js"*} - the type of the resource. This
+ * is typically inferred from the src.
+ *
+ * ### __String__
+ *
+ * Specifies src of the resource. For example:
+ *
+ * steal('./file.js')
+ *
+ * Is the same as calling:
+ *
+ * steal({src: './file.js'})
+ *
+ * ### __Function__
+ *
+ * A callback function that runs when all previous steals
+ * have completed.
+ *
+ * steal('jquery', 'foo',function(){
+ * // jquery and foo have finished loading
+ * // and runing
+ * })
+ *
+ * @return {steal} the steal object for chaining
+ */
+ function steal() {
+ // convert arguments into an array
+ var args = makeArray(arguments);
+ pending.push.apply(pending, args);
+ // steal.after is called everytime steal is called
+ // it kicks off loading these files
+ steal.after(args);
+ // return steal for chaining
+ return steal;
+ };
+
+
+ // =============================== PATHS .8 ============================
+
+// things that matter ...
+// - the current file being loaded
+// - the location of the page
+// - the file
+
+ /**
+ * @class
+ * Used for getting information out of a path
+ * @constructor
+ * Takes a path
+ * @param {String} path
+ */
+ steal.File = function( path ) {
+ // if new was not used, use it.
+ if ( this.constructor != steal.File ) {
+ return new steal.File(path);
+ }
+ // save the path
+ this.path = typeof path == 'string'? path : path.path;
+ };
+ // alias steal.File to File
+ var File = steal.File,
+
+ // a reference to the current file
+ curFile;
+
+ // get and sets the current file
+ File.cur = function(newCurFile){
+ if(newCurFile !== undefined){
+ curFile = File(newCurFile);
+ }else{
+ return curFile || File("");
+ }
+ };
+
+
+ extend(File.prototype,
+ /**
+ * @prototype
+ */
+ {
+ // Removes hash and querystring
+ clean: function() {
+ return this.path.match(/([^\?#]*)/)[1];
+ },
+ // gets the files extension
+ ext : function(){
+ var match = this.clean().match(/\.([\w\d]+)$/)
+ return match ? match[1] : "";
+ },
+ // Returns everything before the last /
+ dir: function() {
+ // remove any query string
+ var cleaned = this.clean(),
+ // get the last /
+ last = cleaned.lastIndexOf('/'),
+ // if there is a last /, get everything up to that point
+ dir = (last != -1) ? cleaned.substring(0, last) : '';
+ // make sure we aren't left with just https/ or file:/
+ return /^(https?:\/|file:\/)$/.test(dir) ? cleaned : dir;
+ },
+ // Returns everything after the last /
+ filename: function() {
+ var cleaned = this.clean(),
+ last = cleaned.lastIndexOf('/'),
+ filename = (last != -1) ? cleaned.substring(last+1, cleaned.length) : cleaned;
+ return /^(https?:\/|file:\/)$/.test(filename) ? cleaned : filename;
+ },
+ // Returns the domain for the current path.
+ // Returns null if the domain is a file.
+ domain: function() {
+ var http = this.path.match(/^(?:https?:\/\/)([^\/]*)/);
+ return http ? http[1] : null;
+ },
+ /**
+ * Joins a url onto a path. One way of understanding this is that your File object represents your current location, and calling join() is analogous to "cd" on a command line.
+ * @codestart
+ * new steal.File("d/e").join("../a/b/c"); // Yields the path "d/a/b/c"
+ * @codeend
+ * @param {String} url
+ */
+ join: function( url ) {
+ return File(url).joinFrom(this.path);
+ },
+
+ /**
+ * Returns the path of this file referenced from another url or path.
+ *
+ * new steal.File('a/b.c').joinFrom('/d/e')//-> /d/e/a/b.c
+ *
+ * @param {String} url
+ * @param {Boolean} expand if the path should be expanded
+ * @return {String}
+ */
+ joinFrom: function( url, expand ) {
+ var u = File(url);
+
+ // if this.path is absolutely referenced
+ if ( this.protocol() ) { //if we are absolutely referenced
+
+ //try to shorten the path as much as possible:
+ var firstDomain = this.domain(),
+ secondDomain = u.domain();
+
+ // if domains are equal, shorten
+ if ( firstDomain && firstDomain == secondDomain ) {
+
+ return this.toReferenceFromSameDomain(url);
+ } else {
+ // if there is no domain or not equal, use our path
+ return this.path;
+ }
+
+ // the path is the same as the folder the page is in
+ } else if ( url === steal.pageUrl().dir() && !expand ) {
+
+ return this.path;
+
+ } else if ( this.isLocalAbsolute() ) { // we are a path like /page.js
+
+ return (u.domain() ? u.protocol() + "//" + u.domain() : "" )+ this.path;
+
+ } else { //we have 2 relative paths, remove folders with every ../
+
+ if ( url === '' ) {
+ return this.path.replace(/\/$/, '');
+ }
+
+ var urls = url.split('/'),
+ paths = this.path.split('/'),
+ path = paths[0];
+
+ //if we are joining from a folder like cookbook/, remove the last empty part
+ if ( url.match(/\/$/) ) {
+ urls.pop();
+ }
+ // for each .. remove one folder
+ while ( path == '..' && paths.length > 0 ) {
+ // if we've emptied out, folders, just break
+ // leaving any additional ../s
+ if(! urls.pop() ){
+ break;
+ }
+ paths.shift();
+
+ path = paths[0];
+ }
+ return urls.concat(paths).join('/');
+ }
+ },
+ // Returns true if the file is relative to a domain or a protocol
+ relative: function() {
+ return this.path.match(/^(https?:|file:|\/)/) === null;
+ },
+ /**
+ * Returns the relative path between two paths with common folders.
+ * @codestart
+ * new steal.File('a/b/c/x/y').toReferenceFromSameDomain('a/b/c/d/e')//-> ../../x/y
+ * @codeend
+ * @param {Object} url
+ * @return {String}
+ */
+ toReferenceFromSameDomain: function( url ) {
+ var parts = this.path.split('/'),
+ other_parts = url.split('/'),
+ result = '';
+ while ( parts.length > 0 && other_parts.length > 0 && parts[0] == other_parts[0] ) {
+ parts.shift();
+ other_parts.shift();
+ }
+ each(other_parts, function(){ result += '../'; })
+ return result + parts.join('/');
+ },
+ /**
+ * Is the file on the same domain as our page.
+ */
+ isCrossDomain: function() {
+ return this.isLocalAbsolute() ? false : this.domain() != File(win.location.href).domain();
+ },
+ isLocalAbsolute: function() {
+ return this.path.indexOf('/') === 0;
+ },
+ protocol: function() {
+ var match = this.path.match(/^(https?:|file:)/);
+ return match && match[0];
+ },
+ /**
+ * For a given path, a given working directory, and file location, update the path so
+ * it points to a location relative to steal's root.
+ *
+ * We want everything relative to steal's root so the same app can work in multiple pages.
+ *
+ * ./files/a.js = steals a.js
+ * ./files/a = a/a.js
+ * files/a = //files/a/a.js
+ * files/a.js = loads //files/a.js
+ */
+ normalize: function() {
+
+ var current = File.cur().dir(),
+ //if you are cross domain from the page, and providing a path that doesn't have an domain
+ path = this.path;
+ if (/^\/\//.test(this.path)) { //if path is rooted from steal's root (DEPRECATED)
+ path = this.path.substr(2);
+ }
+ else if (/^\.\//.test(this.path)) { // should be relative
+ this.path = this.path.substr(2);
+ path = this.joinFrom(current);
+ this.path = "./" + this.path;
+ }
+ else if (/^[^\.|\/]/.test(this.path)) {}
+ else {
+ if (this.relative() ||
+ File.cur().isCrossDomain() && //if current file is on another domain and
+ !this.protocol()) { //this file doesn't have a protocol
+ path = this.joinFrom(current);
+ }
+ }
+
+ return path;
+ }
+ });
+
+ var pending = [],
+ s = steal,
+ id = 0,
+ steals = {};
+
+ // this is for methods on a 'steal instance'. A file can be in one of a few states:
+ // created - the steal instance is created, but we haven't started loading it yet
+ // this happens when thens are used
+ // loading - (loading=true) By calling load, this will tell steal to load a file
+ // loaded - (isLoaded=true) The file has been run, but its dependency files have been completed
+ // complete - all of this files dependencies have loaded and completed.
+ steal.p = {
+ // adds a new steal and throws an error if the script doesn't load
+ // this also checks the steals map
+ make: function(options){
+
+ var stel = new steal.p.init(options),
+ rootSrc = stel.options.rootSrc;
+
+ if(stel.unique && rootSrc){
+ // the .js is b/c we are not adding that automatically until
+ // load because we defer 'type' determination until then
+ if(!steals[rootSrc] && ! steals[rootSrc+".js"]){ //if we haven't loaded it before
+ steals[rootSrc] = stel;
+ } else{ // already have this steal
+ stel = steals[rootSrc];
+ // extend the old stolen file with any new options
+ extend(stel.options, typeof options === "string" ? {} : options)
+ }
+ }
+
+ return stel;
+ },
+ init: function( options ) {
+ this.dependencies = [];
+ // id for debugging
+ this.id = (++id);
+
+ // if we have no options, we are the global init ... set ourselves up ...
+ if(!options){ //global init cur ...
+ this.options = {};
+ this.waits = false;
+ this.pack = "production.js";
+ }
+ //handle callback functions
+ else if ( typeof options == 'function' ) {
+ var path = File.cur().path;
+
+ this.options = {
+ fn : function() {
+
+ //set the path ..
+ File.cur(path);
+
+ // call the function, someday soon this will be requireJS-like
+ options(steal.send || win.jQuery || steal);
+ },
+ rootSrc: path,
+ orig: options,
+ type: "fn"
+ }
+ // this has nothing to do with 'loading' options
+ this.waits = true;
+ this.unique = false;
+ } else {
+
+ // save the original options
+ this.orig = options;
+
+ this.options = steal.makeOptions(extend({},
+ typeof options == 'string' ? { src: options } : options));
+
+ this.waits = this.options.waits || false;
+ this.unique = true;
+ }
+ },
+ complete : function(){
+ this.completed = true;
+ },
+ /**
+ * @hide
+ * After the script has been loaded and run
+ *
+ * - check what else has been stolen, load them
+ * - mark yourself as complete when everything is completed
+ * - this is where all the actions is
+ */
+
+ loaded: function(script){
+ var myqueue,
+ stel,
+ src = (script && script.src) || this.options.src,
+ rootSrc = this.options.rootSrc;
+
+ //set yourself as the current file
+ File.cur(rootSrc);
+
+ // mark yourself as 'loaded'.
+ this.isLoaded = true;
+
+ // If we are IE, get the queue from interactives
+ // TODO move this out of this function
+ if (support.interactive && src) {
+ myqueue = interactives[src];
+ }
+ // is there a case in IE where, this makes sense?
+ // in other browsers, the queue of items to load is
+ // what is in pending
+ if(!myqueue){
+ myqueue = pending.slice(0);
+ pending = [];
+ }
+
+ // if we have nothing, mark us as complete (resolve if deferred)
+ if(!myqueue.length){
+ this.complete();
+ return;
+ }
+
+ // now we have to figure out how to wire up our pending steals
+ var self = this,
+ set = [],
+ // the current
+ joiner,
+ initial = [],
+
+ isProduction = steal.options.env == 'production',
+
+ files = [],
+
+ // a helper that basically does a join
+ // when everything in arr's func method is called,
+ // call func2 on obj
+ whenEach = function(arr, func, obj, func2){
+ var big = [obj, func2];
+ each(arr, function(i, item){
+ big.unshift(item, func)
+ });
+ when.apply(steal, big);
+ },
+ // a helper that does the oposite of a join. When
+ // obj's func method is called, call func2 on all items.
+ whenThe = function(obj, func, items, func2){
+ each(items, function(i, item){
+ when(obj, func, item, func2)
+ })
+ };
+
+
+ //now go through what you stole and hook everything up
+ //BUT, we go through backwards
+ each(myqueue.reverse(), function(i, item){
+
+ //in production, ignore ignored items (like steal/dev
+ if(isProduction && item.ignore){
+ return;
+ }
+
+ // make a steal object
+ stel = steal.p.make( item );
+
+ // add it as a dependency, circular are not allowed
+ self.dependencies.unshift(stel)
+
+
+ if(stel.waits === false){ // file
+ // on the current
+ files.push(stel);
+
+ }else{ // function
+
+ // essentially have to bind current files to call previous joiner's load
+ // and to wait for current stel's complete
+
+ if(!joiner){ // if no previous joiner, then we are at the start of a file
+
+ // when they are complete, complete the file
+ whenEach( files.concat(stel), "complete", self, "complete");
+
+ // if there was a function then files, then end, function loads all files
+ if(files.length){
+ whenThe(stel,"complete", files ,"load")
+ }
+
+ } else { // function, file1, file2, file3, joiner function
+
+ whenEach(files.concat(stel) , "complete", joiner, "load");
+
+ // make stel complete load files
+ whenThe(stel,"complete", files.length ? files : [joiner] ,"load")
+
+ }
+ // the joiner is the previous thing
+ joiner = stel;
+ files = [];
+
+ }
+ });
+
+ // now we should be left with the starting files
+ if(files.length){
+ // we have initial files
+ // if there is a joiner, we need to load it when the initial files are complete
+ if(joiner){
+ whenEach(files, "complete", joiner, "load");
+ } else {
+ whenEach(files, "complete", self, "complete");
+ }
+ // reverse it back and load each initial file
+ each(files.reverse(), function(){
+ this.load();
+ });
+ } else if(joiner){
+ // we have inital function
+ joiner.load()
+ } else {
+ // we had nothing
+ self.complete();
+ }
+
+ },
+ /**
+ * Loads this steal
+ */
+ load: function(returnScript) {
+ // if we are already loading / loaded
+ if(this.loading || this.isLoaded){
+ return;
+ }
+ this.loading = true;
+ var self = this;
+ // get yourself
+ steal.require(this.options, function load_calling_loaded(script){
+ self.loaded(script);
+ }, function(error, src){
+ win.clearTimeout && win.clearTimeout(self.completeTimeout)
+ throw "steal.js : "+self.options.src+" not completed"
+ });
+
+ }
+
+ };
+ steal.p.init.prototype = steal.p;
+ /**
+ * @add steal
+ */
+ // =============================== STATIC API ===============================
+ var page;
+ /**
+ * @static
+ */
+ extend(steal,{
+ /**
+ * @attribute root
+ * The location of the steal folder.
+ */
+ root : File(""),
+ /**
+ * Gets or sets the path from the current page to
+ * steal's (or JavaScriptMVC's) root folder. When passed a src, it sets the root folder.
+ * Otherwise, it returns the path to the root folder.
+ *
+ * This is the path from which
+ * all plugins are stolen. When you steal a plugin like steal("jquery/controller"),
+ * the plugin path is joined with this rootUrl to create a full path
+ * to the controller.js file.
+ *
+ * By default, the rootUrl is calculated from the
+ * steal script and the window location. For example, if the
+ * script tag looks like this:
+ *
+ * <script type='text/javascript' src='../../steal/steal.js?ui/app'></script>
+ *
+ * rootUrl will be set to "../../".
+ * Setting the rootUrl can be useful if you want to have
+ * steal.js in a different location.
+ *
+ * ## Example
+ *
+ * The following sets steal root to a different folder.
+ *
+ * steal.rootUrl("../../jmvc/")
+ *
+ * This appends <code>"../../jmvc"</code> to paths
+ * loaded from [steal.static.root]. In some strange cases this might be desirable if
+ * plugin folders are in a different location from the steal directory.
+ *
+ * It also sets the current url to this directory so the first calls to steal work relative to the root JMVC directory.
+ *
+ * @param {String} [src] a relative path from the current page to the root directory of JMVC, like ../../
+ * @return {String} returns the last path passed to rootUrl
+ */
+ rootUrl : function(src){
+ if (src !== undefined) {
+ steal.root = File(src);
+
+ // set cur with the location
+ var cleaned = steal.pageUrl(),
+ loc = cleaned.join(src);
+
+ File.cur( cleaned.toReferenceFromSameDomain(loc) );
+ return steal;
+ } else {
+ return steal.root.path;
+ }
+ },
+ extend : extend,
+ /**
+ * @function pageUrl
+ * Gets or sets the location of the page using
+ * steal. This defaults to the window's location.
+ *
+ * However, sometimes it is necessary to
+ * have steal believe it is making requests from
+ * another page.
+ *
+ * @param {String} [newPage] a path to the page using steal (probably the windows location)
+ * @return {steal.File} returns the last path to a page passed to pageUrl, converted to a steal.File object
+ */
+ pageUrl : function(newPage){
+ if(newPage){
+ page = File( File(newPage).clean() );
+ return steal;
+ } else{
+ return page || File("");
+ }
+ },
+ //gets and sets which page steal thinks it's at
+ // TODO: make location change-able ...
+ /**
+ * Gets the currently running script location.
+ *
+ * @return String
+ */
+ cur: function( file ) {
+ if (file === undefined) {
+ return File.cur();
+ } else {
+ File.cur(file);
+ return steal;
+ }
+ },
+ isRhino: win.load && win.readUrl && win.readFile,
+ /**
+ * @attribute options
+ * Configurable options
+ */
+ options : {
+ env : 'development',
+ // TODO: document this
+ loadProduction : true
+ },
+ /**
+ * @hide
+ * when a 'unique' steal gets added ...
+ * @param {Object} stel
+ */
+ add : function(stel){
+ steals[stel.rootSrc] = stel;
+ },
+ /**
+ * @hide
+ * Makes options
+ * @param {Object} options
+ */
+ makeOptions : function(options){
+
+ var ext = File(options.src).ext();
+ if (!ext) {
+ // if first character of path is a . or /, just load this file
+ if (options.src.indexOf(".") == 0 || options.src.indexOf("/") == 0) {
+ options.src = options.src + ".js"
+ }
+ // else, load as a plugin
+ else {
+ options.src = options.src + "/" + File(options.src).filename() + ".js";
+ }
+ }
+
+ var orig = options.src,
+ // path relative to the current files path
+ // this is done relative to jmvcroot
+ normalized = steal.File(orig).normalize(),
+ protocol = steal.File(options.src).protocol();
+
+ extend(options,{
+ originalSrc : options.src,
+ rootSrc : normalized,
+ // path from the page
+ src : steal.root.join(normalized),
+ // "file:" or "http:" depending on what protocol the request uses
+ protocol: protocol || (doc? location.protocol: "file:")
+ });
+ options.originalSrc = options.src;
+
+ return options;
+ },
+ /**
+ * Calls steal, but waits until all previous steals
+ * have completed loading until loading the
+ * files passed to the arguments.
+ */
+ then : function(){
+ var args = typeof arguments[0] == 'function' ?
+ arguments : [function(){}].concat(makeArray( arguments ) )
+ return steal.apply(win, args );
+ },
+ /**
+ * Listens to events on Steal
+ * @param {String} event
+ * @param {Function} listener
+ */
+ bind: function(event, listener){
+ if(!events[event]){
+ events[event] = []
+ }
+ var special = steal.events[event]
+ if(special && special.add){
+ listener = special.add(listener);
+ }
+ listener && events[event].push(listener);
+ return steal;
+ },
+ one : function(event, listener){
+ steal.bind(event,function(){
+ listener.apply(this, arguments);
+ steal.unbind(event, arguments.callee);
+ });
+ return steal;
+ },
+ events : {},
+ /**
+ * Unbinds an event listener on steal
+ * @param {Object} event
+ * @param {Object} listener
+ */
+ unbind : function(event, listener){
+ var evs = events[event] || [],
+ i = 0;
+ while(i < evs.length){
+ if(listener === evs[i]){
+ evs.splice(i,1);
+ }else{
+ i++;
+ }
+ }
+ },
+ trigger : function(event, arg){
+ var arr = events[event] || [],
+ copy = [];
+ // array items might be removed during each iteration (with unbind), so we iterate over a copy
+ for(var i =0, len = arr.length; i <len; i++){
+ copy[i] = arr[i];
+ }
+ each(copy, function(i,f){
+ f(arg);
+ })
+ },
+ /**
+ * @hide
+ * Used to tell steal that it is loading a number of plugins
+ */
+ loading : function(){
+ // we don't use IE's interactive script functionality while production scripts are loading
+ useInteractive = false;
+ each(arguments, function(i, arg){
+ var stel = steal.p.make( arg );
+ stel.loading = true;
+ });
+ },
+ // a dummy function to add things to after the stel is created, but before
+ // loaded is called
+ preloaded : function(){},
+ // called when a script has loaded via production
+ loaded: function(name){
+ // create the steal, mark it as loading, then as loaded
+ var stel = steal.p.make( name );
+ stel.loading = true;
+ convert(stel, "complete");
+
+ steal.preloaded(stel);
+ stel.loaded()
+ return steal;
+ }
+ });
+
+ var events = {};
+ startup = before(startup, function(){
+
+ steal.pageUrl(win.location ? win.location.href : "");
+
+ })
+
+
+ // =============================== TYPE SYSTEM ===============================
+
+ var types = steal.types = {};
+
+
+ steal.
+ /**
+ * Registers a type. You define the type of the file, the basic type it converts to, and a
+ * conversion function where you convert the original file to JS or CSS. This is modeled after the
+ * [http://api.jquery.com/extending-ajax/#Converters AJAX converters] in jQuery.
+ *
+ * Types are designed to make it simple to switch between steal's development and production modes. In development mode, the types are converted
+ * in the browser to allow devs to see changes as they work. When the app is built, these converter functions are run by the build process,
+ * and the processed text is inserted into the production script, optimized for performance.
+ *
+ * Here's an example converting files of type .foo to JavaScript. Foo is a fake language that saves global variables defined like. A .foo file might
+ * look like this:
+ *
+ * REQUIRED FOO
+ *
+ * To define this type, you'd call steal.type like this:
+ *
+ * steal.type("foo js", function(options, original, success, error){
+ * var parts = options.text.split(" ")
+ * options.text = parts[0]+"='"+parts[1]+"'";
+ * success();
+ * });
+ *
+ * The method we provide is called with the text of .foo files in options.text. We parse the file, create
+ * JavaScript and put it in options.text. Couldn't be simpler.
+ *
+ * Here's an example, converting [http://jashkenas.github.com/coffee-script/ coffeescript] to JavaScript:
+ *
+ * steal.type("coffee js", function(options, original, success, error){
+ * options.text = CoffeeScript.compile(options.text);
+ * success();
+ * });
+ *
+ * In this example, any time steal encounters a file with
+ * extension .coffee, it will call the given
+ * converter method. CoffeeScript.compile takes the text of the file, converts it from coffeescript to javascript,
+ * and saves the JavaScript text in options.text.
+ *
+ * Similarly, languages on top of CSS, like [http://lesscss.org/ LESS], can be converted to CSS:
+ *
+ * steal.type("less css", function(options, original, success, error){
+ * new (less.Parser)({
+ * optimization: less.optimization,
+ * paths: []
+ * }).parse(options.text, function (e, root) {
+ * options.text = root.toCSS();
+ * success();
+ * });
+ * });
+ *
+ * This simple type system could be used to convert any file type to be used in your JavaScript app. For example,
+ * [http://fdik.org/yml/ yml] could be used for configuration. jQueryMX uses steal.type to support JS templates, such as EJS, TMPL, and others.
+ *
+ * @param {String} type A string that defines the new type being defined and the type being converted to,
+ * separated by a space, like "coffee js".
+ *
+ * There can be more than two steps used in conversion, such as "ejs view
+ * js". This will define a method that converts .ejs files to .view files. There should be another converter for "view js"
+ * that makes this final conversion to JS.
+ *
+ * @param {Function} cb( options, original, success, error ) a callback function that converts the new file type
+ * to a basic type. This method needs to do two things: 1) save the text of the converted file in options.text
+ * and 2) call success() when the conversion is done (it can work asynchronously).
+ *
+ * - __options__ - the steal options for this file, including path information
+ * - __original__ - the original argument passed to steal, which might be a path or a function
+ * - __success__ - a method to call when the file is converted and processed successfully
+ * - __error__ - a method called if the conversion fails or the file doesn't exist
+ */
+ type = function(type, cb){
+ var typs = type.split(" ");
+
+ if(!cb){
+ return types[typs.shift()].require
+ }
+
+ types[typs.shift()] = {
+ require : cb,
+ convert: typs
+ };
+ };
+ // adds a type (js by default) and buildType (css, js)
+ // this should happen right before loading
+ // however, what if urls are different
+ // because one file has JS and another does not?
+ // we could check if it matches something with .js because foo.less.js SHOULD
+ // be rare
+ steal.p.load = before(steal.p.load, function(){
+ var raw = this.options;
+
+ // if it's a string, get it's extension and check if
+ // it is a registered type, if it is ... set the type
+ if(!raw.type){
+ var ext = File(raw.src).ext();
+ if(!ext && !types[ext]){
+ ext = "js";
+ }
+ raw.type = ext;
+ }
+ if (!types[raw.type]){
+ throw "steal.js - type " + raw.type + " has not been loaded.";
+ }
+ var converters = types[raw.type].convert;
+ raw.buildType = converters.length ? converters[converters.length - 1] : raw.type;
+ });
+
+ steal.
+ /**
+ * Called for every file that is loaded. It sets up a string of methods called for each type in the conversion chain and calls each type one by one.
+ *
+ * For example, if the file is a coffeescript file, here's what happens:
+ *
+ * - The "text" type converter is called first. This will perform an AJAX request for the file and save it in options.text.
+ * - Then the coffee type converter is called (the user provided method). This converts the text from coffeescript to JavaScript.
+ * - Finally the "js" type converter is called, which inserts the JavaScript in the page as a script tag that is executed.
+ *
+ * @param {Object} options the steal options for this file, including path information
+ * @param {Function} success a method to call when the file is converted and processed successfully
+ * @param {Function} error a method called if the conversion fails or the file doesn't exist
+ */
+ require = function(options, success, error){
+ // get the type
+ var type = types[options.type],
+ converters;
+
+ // if this has converters, make it get the text first, then pass it to the type
+ if(type.convert.length){
+ converters = type.convert.slice(0);
+ converters.unshift('text', options.type)
+ } else {
+ converters = [options.type]
+ }
+ require(options, converters, success, error)
+ };
+ function require(options, converters, success, error){
+
+ var type = types[converters.shift()];
+
+ type.require(options, function require_continue_check(){
+ // if we have more types to convert
+ if(converters.length){
+ require(options, converters, success, error)
+ } else { // otherwise this is the final
+ success.apply(this, arguments);
+ }
+ }, error)
+ };
+
+
+// =============================== TYPES ===============================
+
+// a clean up script that prevents memory leaks and removes the
+// script
+var cleanUp = function(script) {
+ script[ STR_ONREADYSTATECHANGE ]
+ = script[ STR_ONLOAD ]
+ = script[STR_ONERROR]
+ = null;
+
+ head().removeChild( script );
+ },
+ // the last inserted script, needed for IE
+ lastInserted,
+ // if the state is done
+ stateCheck = /loaded|complete/;