Browse Source

amber loaded by require.js, still ...

... problems with dependencies; sometimes
subclass loads before superclass exists.
Herbert Vojčík 10 years ago
parent
commit
97ce4d6029

+ 21 - 11
index.html

@@ -1,14 +1,24 @@
-<!DOCTYPE html> 
-<html> 
+<!DOCTYPE html>
+<html>
 
-  <head> 
-    <title>Amber Smalltalk</title> 
-    <meta http-equiv="content-type" content="text/html; charset=utf-8" /> 
-    <meta name="author" content="Nicolas Petton" /> 
-    <script type='text/javascript' src='js/amber.js'></script> 
-  </head> 
+<head>
+    <title>Amber Smalltalk</title>
+    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
+    <meta name="author" content="Nicolas Petton"/>
+    <script type='text/javascript' src='js/lib/require.min.js'></script>
+    <script type='text/javascript' src='js/lib/amber-in-browser.js'></script>
+</head>
 
-  <body> 
-    <script type='text/javascript'> loadAmber({ready: function() {smalltalk.Browser._open()}}) </script> 
-  </body> 
+<body>
+<script type='text/javascript'>
+    require(
+            ["amber-full-devel"],
+            function () {
+                smalltalk.initialize();
+
+                smalltalk.Browser._open()
+            }
+    );
+</script>
+</body>
 </html> 

+ 10 - 0
js/lib/amber-core-deploy.js

@@ -0,0 +1,10 @@
+define([
+    'amber/Kernel-Objects.deploy',
+    'amber/Kernel-Classes.deploy',
+    'amber/Kernel-Methods.deploy',
+    'amber/Kernel-Collections.deploy',
+    'amber/Kernel-Exceptions.deploy',
+    'amber/Kernel-Transcript.deploy',
+    'amber/Kernel-Announcements.deploy',
+    'amber/Canvas.deploy'
+], {});

+ 36 - 0
js/lib/amber-full-devel.js

@@ -0,0 +1,36 @@
+define([
+    'jquery-ui',
+    'jQuery/jquery.textarea',
+    'CodeMirror/codemirror',
+    'CodeMirror/smalltalk',
+    'CodeMirror/addon/hint/show-hint',
+    'css!CodeMirror/codemirror',
+    'css!CodeMirror/theme/ambiance',
+    'css!CodeMirror/addon/hint/show-hint',
+    'css!CodeMirror/amber',
+    'css!../../css/amber',
+    'amber/Kernel-Objects',
+    'amber/Kernel-Classes',
+    'amber/Kernel-Methods',
+    'amber/Kernel-Collections',
+    'amber/Kernel-Exceptions',
+    'amber/Kernel-Transcript',
+    'amber/Kernel-Announcements',
+    'amber/Canvas',
+    'amber/SUnit',
+    'amber/Importer-Exporter',
+    'amber/Compiler-Exceptions',
+    'amber/Compiler-Core',
+    'amber/Compiler-AST',
+    'amber/Compiler-Semantic',
+    'amber/Compiler-IR',
+    'amber/Compiler-Inlining',
+    'amber/Compiler-Interpreter',
+    'amber/Compiler-Tests',
+    'amber/parser',
+    'amber/IDE',
+    'amber/Examples',
+    'amber/Benchfib',
+    'amber/Kernel-Tests',
+    'amber/SUnit-Tests'
+], {});

+ 51 - 0
js/lib/amber-in-browser.js

@@ -0,0 +1,51 @@
+/* Amber package loading
+ usage example:
+ TODO
+ */
+
+var require;
+
+require = function (require) {
+    var scripts = document.getElementsByTagName("script");
+    var src = scripts[ scripts.length - 1 ].src;
+    var home = resolveViaDOM(src).replace(/[^\/]+$/, "");
+
+    function resolveViaDOM(url) {
+        var a = document.createElement("a");
+        a.href = url;
+        return a.href;
+    }
+
+    var config = {
+        baseUrl: home,
+        paths: {
+            'amber': '..',
+            'jquery': 'jQuery/jquery-1.8.2.min',
+            'jquery-ui': 'jQuery/jquery-ui-1.8.16.custom.min',
+            'smalltalk': '../boot'
+        },
+        map: {
+            '*': {
+                'css': 'require-css-0.0.6/css'
+            }
+        },
+        shim: {
+            'CodeMirror/smalltalk': {
+                deps: [ 'CodeMirror/codemirror']
+            },
+            'CodeMirror/addon/hint/show-hint': {
+                deps: [ 'CodeMirror/codemirror']
+            }
+        },
+        deps: [
+            'jquery', 'es5-shim-2.0.2/es5-shim.min', 'es5-shim-2.0.2/es5-sham.min', 'smalltalk'
+        ]
+    };
+
+    if (require) {
+        require.config(config);
+        return require;
+    } else {
+        return config;
+    }
+}(require);

+ 10 - 0
js/lib/require-css-0.0.6/LICENSE

@@ -0,0 +1,10 @@
+MIT License
+-----------
+
+Copyright (C) 2013 Guy Bedford
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

+ 229 - 0
js/lib/require-css-0.0.6/README.md

@@ -0,0 +1,229 @@
+require-css
+===========
+
+RequireJS CSS requiring and optimization.
+
+Useful for writing modular CSS dependencies alongside scripts. For an example of widget rendering see [ZestJS](http://zestjs.org).
+
+For LESS inclusion, use [require-less](https://github.com/guybedford/require-less), which behaves and builds the css exactly like this module apart from the preprocessing step.
+
+Overview
+--------
+
+Allows the construction of scripts that can require CSS, using the simple RequireJS syntax:
+
+```javascript
+define(['css!styles/main'], function() {
+  //code that requires the stylesheet: styles/main.css
+});
+```
+
+### CSS Requiring
+* Fully compatible in IE 6 - 10, Chrome 3 - 26, Firefox 3.5 - 19, Opera 10 - 12, iOS, Android
+* Cross-domain style loading
+* Line numbers in dev inspector correlate with correct CSS file
+
+### CSS Building
+* **CSS builds** When run as part of a build with the RequireJS optimizer, `css!` dependencies are automatically inlined into the built layer within the JavaScript, fully compatible with layering. CSS injection is performed as soon as the layer is loaded.
+* **Option to build separate layer CSS files** A `separateCSS` build parameter allows for built layers to output their css files separately, instead of inline with the JavaScript, for manual inclusion.
+* **CSS compression** CSS redundancy compression is supported through the external library, [csso](https://github.com/css/csso).
+
+Installation and Setup
+----------------------
+
+Download the require-css folder manually or use [volo](https://github.com/volojs/volo)(`npm install volo -g`):
+
+```bash
+volo add guybedford/require-css
+```
+
+To allow the direct `css!` usage, add the following [map configuration](http://requirejs.org/docs/api.html#config-map) in RequireJS:
+
+```javascript
+map: {
+  '*': {
+    'css': 'require-css/css' // or whatever the path to require-css is
+  }
+}
+```
+
+Use Cases and Benefits
+----------------------
+
+### Motivation
+
+The use case for RequireCSS came out of a need to manage templates and their CSS together. 
+The idea being that a CSS require can be a dependency of the code that dynamically renders a template. 
+When writing a large dynamic application, with templates being rendered on the client-side, it can be beneficial to inject the CSS as templates are required instead 
+of dumping all the CSS together separately. The added benefit of this is then being able to build the CSS naturally with the RequireJS optimizer, 
+which also supports [separate build layers](http://requirejs.org/docs/1.0/docs/faq-optimization.html#priority) as needed.
+
+### Script-inlined CSS Benefits
+
+By default, during the build CSS is compressed and inlined as a string within the layer that injects the CSS when run.
+
+If the layer is included as a `<script>` tag, only one browser request is needed instead of many separate CSS requests with `<link>` tags.
+
+Even better than including a layer as a `<script>` tag is to include the layer dynamically with a non-blocking require. 
+Then the page can be displayed while the layer is still loading asynchronously in the background. 
+In this case, the CSS that goes with a template being dynamically rendered is loaded with that same script asynchronously. 
+No longer does it need to sit in a `<link>` tag that blocks the page display unnecessarily.
+
+Modular CSS
+-----------
+
+RequireCSS implies a CSS modularisation where styles can be scoped directly to the render code that they are bundled with.
+
+Just like JS requires, the order of CSS injection can't be guaranteed. The idea here is that whenever there are style overrides, they should
+be based on using a more specific selector with an extra id or class at the base, and not assuming a CSS load order. Reset and global styles are a repeated dependency of all 
+modular styles that build on top of them.
+
+Optimizer Configuration
+-----------------------
+
+### Basic Usage
+
+Optimizer configuration:
+
+```javascript
+{
+  modules: [
+  {
+    name: 'mymodule'
+  }
+  ]
+}
+```
+
+If the contents of 'mymodule' are:
+
+```javascript
+  define(['css!style', 'css!page'], function(css) {
+    //...
+  });
+```
+
+Then the optimizer output would be:
+
+-mymodule.js containing:
+ style.css and page.css which will be dynamically injected
+ 
+### Configuration Notes
+
+In order for the layer to inject the CSS it will make a runtime require to `css`. It is important to ensure that the
+map configuration locating `css` is provided before this injection in the script.
+
+If using the standard configuration pattern:
+
+main.js:
+```javascript
+  requirejs.config({
+    map: {
+      '*': {
+        'css': 'require-css/css'
+      }
+    }
+  });
+  require(['app']);
+```
+
+then the configuration will be written by the optimizer as the last item in the layer, meaning the `css` module will not be located in
+time for injection.
+
+To ensure this doesn't happen, use the following configuration pattern:
+
+main.js:
+```javascript
+  require(['config'], function() {
+    require(['app']);
+  });
+```
+
+Or build the config first into layer using the `create` and `include` build properties.
+
+[More details here](https://github.com/jrburke/requirejs/pull/595#issuecomment-16346519)
+
+### Separate File Output
+
+To output the CSS to a separate file, use the configuration:
+
+```javascript
+{
+  separateCSS: true,
+  modules: [
+  {
+    name: 'mymodule'
+  }
+  ]
+}
+```
+
+This will then output all the css to the file `mymodule.css`. This configuration can also be placed on the module object itself for layer-specific settings.
+
+Optimization is fully compatible with exclude and include.
+
+**Note: Optimization will only work when using r.js version 2.1.0 or later (released Oct 4 2012)**
+
+
+CSS Compression
+---------------
+
+CSS compression is supported with [csso](https://github.com/css/csso).
+
+To enable the CSS compression, install csso with npm:
+
+```
+  npm install csso -g
+```
+
+The build log will display the compression results.
+
+When running the r.js optimizer through NodeJS, sometimes the global module isn't found. In this case install csso as a local node module so it can be found.
+
+
+Conditional CSS
+---
+
+Some styles are conditional on the environment. For example mobile stylesheets and IE-specific stylesheets.
+
+To manage this, use the [Require-IS](https://github.com/guybedford/require-is) module. 
+
+With Require-IS, one can do:
+
+```javascript
+require(['is!mobile?css!mobile-css'], function(css) {
+  //...
+});
+```
+
+Mobile detection can be defined through a detection script in Require-IS, such as:
+
+mobile.js:
+```javascript
+define(function() {
+  return navigator.userAgent.match(/iPhone/); //(just iphone detection as an example)
+});
+```
+
+Separate build layers can then be made for mobile specific use. Read more at the [Require-IS](https://github.com/guybedford/require-is) project page.
+
+Injection methods
+-----------------
+
+* When loading a CSS file or external CSS file, a `<link>` tag is used. Cross-browser support comes through a number of careful browser conditions for this.
+* When using Require-LESS parsing or when injecting CSS from the built `<script>` tag, a CSS `<style>` injection is used.
+
+If CSS resources such as images are important to be loaded first, these can be added to the require through a loader plugin that can act as a preloader such as [image](https://github.com/millermedeiros/requirejs-plugins) or [font](https://github.com/millermedeiros/requirejs-plugins). Then a require can be written of the form:
+
+```javascript
+require(['css!my-css', 'image!preload-background-image.jpg', 'font!google,families:[Tangerine]']);
+```
+
+Roadmap
+-------
+* ~~Comprehensive CSS minification including style reduction~~
+* ~~LESS extension~~
+* Sprite compilation
+* Source maps?
+
+Suggestions always appreciated - feel free to post a feature request.

+ 5 - 0
js/lib/require-css-0.0.6/bower.json

@@ -0,0 +1,5 @@
+{
+  "name": "require-css",
+  "version": "0.0.6",
+  "ignore": ["example", "test", ".gitignore"]
+}

+ 251 - 0
js/lib/require-css-0.0.6/css-builder.js

@@ -0,0 +1,251 @@
+define(['require', './normalize'], function(req, normalize) {
+  var nodePrint = function() {};
+  if (requirejs.tools)
+    requirejs.tools.useLib(function(req) {
+      req(['node/print'], function(_nodePrint) {
+        nodePrint = _nodePrint;
+      }, function(){});
+    });
+  
+  var cssAPI = {};
+  
+  function compress(css) {
+    if (typeof process !== "undefined" && process.versions && !!process.versions.node && require.nodeRequire) {
+      try {
+        var csso = require.nodeRequire('csso');
+        var csslen = css.length;
+        css = csso.justDoIt(css);
+        nodePrint('Compressed CSS output to ' + Math.round(css.length / csslen * 100) + '%.');
+        return css;
+      }
+      catch(e) {
+        nodePrint('Compression module not installed. Use "npm install csso -g" to enable.');
+        return css;
+      }
+    }
+    nodePrint('Compression not supported outside of nodejs environments.');
+    return css;
+  }
+  
+  //load file code - stolen from text plugin
+  function loadFile(path) {
+    if (typeof process !== "undefined" && process.versions && !!process.versions.node && require.nodeRequire) {
+      var fs = require.nodeRequire('fs');
+      var file = fs.readFileSync(path, 'utf8');
+      if (file.indexOf('\uFEFF') === 0)
+        return file.substring(1);
+      return file;
+    }
+    else {
+      var file = new java.io.File(path),
+        lineSeparator = java.lang.System.getProperty("line.separator"),
+        input = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(file), 'utf-8')),
+        stringBuffer, line;
+      try {
+        stringBuffer = new java.lang.StringBuffer();
+        line = input.readLine();
+        if (line && line.length() && line.charAt(0) === 0xfeff)
+          line = line.substring(1);
+        stringBuffer.append(line);
+        while ((line = input.readLine()) !== null) {
+          stringBuffer.append(lineSeparator).append(line);
+        }
+        return String(stringBuffer.toString());
+      }
+      finally {
+        input.close();
+      }
+    }
+  }
+  
+  
+  function saveFile(path, data) {
+    if (typeof process !== "undefined" && process.versions && !!process.versions.node && require.nodeRequire) {
+      var fs = require.nodeRequire('fs');
+      fs.writeFileSync(path, data, 'utf8');
+    }
+    else {
+      var content = new java.lang.String(data);
+      var output = new java.io.BufferedWriter(new java.io.OutputStreamWriter(new java.io.FileOutputStream(path), 'utf-8'));
+  
+      try {
+        output.write(content, 0, content.length());
+        output.flush();
+      }
+      finally {
+        output.close();
+      }
+    }
+  }
+  
+  //when adding to the link buffer, paths are normalised to the baseUrl
+  //when removing from the link buffer, paths are normalised to the output file path
+  function escape(content) {
+    return content.replace(/(["'\\])/g, '\\$1')
+      .replace(/[\f]/g, "\\f")
+      .replace(/[\b]/g, "\\b")
+      .replace(/[\n]/g, "\\n")
+      .replace(/[\t]/g, "\\t")
+      .replace(/[\r]/g, "\\r");
+  }
+
+  // NB add @media query support for media imports
+  var importRegEx = /@import\s*(url)?\s*(('([^']*)'|"([^"]*)")|\(('([^']*)'|"([^"]*)"|([^\)]*))\))\s*;?/g;
+
+  var loadCSSFile = function(fileUrl) {
+    var css = loadFile(fileUrl);
+
+    // normalize the css (except import statements)
+    css = normalize(css, fileUrl, baseUrl, cssBase);
+
+    // detect all import statements in the css and normalize
+    var importUrls = [];
+    var importIndex = [];
+    var importLength = [];
+    var match;
+    while (match = importRegEx.exec(css)) {
+      var importUrl = match[4] || match[5] || match[7] || match[8] || match[9];
+
+      // normalize import url
+      if (importUrl.substr(importUrl.length - 5, 5) != '.less' && importUrl.substr(importUrl.length - 4, 4) != '.css')
+        importUrl += '.css';
+
+      // contains a protocol
+      if (importUrl.match(/:\/\//))
+        continue;
+
+      // relative to css base
+      if (importUrl.substr(0, 1) == '/' && cssBase)
+        importUrl = cssBase + importUrl;
+      else
+        importUrl = baseUrl + importUrl;
+
+      importUrls.push(importUrl);
+      importIndex.push(importRegEx.lastIndex - match[0].length);
+      importLength.push(match[0].length);
+    }
+
+    // load the import stylesheets and substitute into the css
+    for (var i = 0; i < importUrls.length; i++)
+      (function(i) {
+        var importCSS = loadCSSFile(importUrls[i]);
+        css = css.substr(0, importIndex[i]) + importCSS + css.substr(importIndex[i] + importLength[i]);
+        var lenDiff = importCSS.length - importLength[i];
+        for (var j = i + 1; j < importUrls.length; j++)
+          importIndex[j] += lenDiff;
+      })(i);
+
+    return css;
+  }
+  
+
+  var baseUrl;  
+  var cssBase;
+  var curModule;
+  cssAPI.load = function(name, req, load, config, parse) {
+    if (!baseUrl)
+      baseUrl = config.baseUrl;
+    
+    if (!cssBase)
+      cssBase = config.cssBase;
+
+    if (config.modules) {
+      //run through the module list - the first one without a layer set is the current layer we are in
+      //allows to track the current layer number for layer-specific config
+      for (var i = 0; i < config.modules.length; i++)
+        if (config.modules[i].layer === undefined) {
+          curModule = i;
+          break;
+        }
+    }
+    
+    //store config
+    cssAPI.config = cssAPI.config || config;
+
+    name += !parse ? '.css' : '.less';
+
+    var fileUrl = req.toUrl(name);
+
+    //external URLS don't get added (just like JS requires)
+    if (fileUrl.substr(0, 7) == 'http://' || fileUrl.substr(0, 8) == 'https://')
+      return;
+
+    //add to the buffer
+    _cssBuffer[name] = loadCSSFile(fileUrl);
+
+    // parse if necessary
+    if (parse)
+      _cssBuffer[name] = parse(_cssBuffer[name]);
+
+    load();
+  }
+  
+  cssAPI.normalize = function(name, normalize) {
+    if (name.substr(name.length - 4, 4) == '.css')
+      name = name.substr(0, name.length - 4);
+    return normalize(name);
+  }
+  
+  //list of cssIds included in this layer
+  var _layerBuffer = [];
+  var _cssBuffer = [];
+  cssAPI.write = function(pluginName, moduleName, write, parse) {
+    //external URLS don't get added (just like JS requires)
+    if (moduleName.substr(0, 7) == 'http://' || moduleName.substr(0, 8) == 'https://')
+      return;
+    
+    var resourceName = moduleName + (!parse ? '.css' : '.less');
+    _layerBuffer.push(_cssBuffer[resourceName]);
+
+    var separateCSS = false;
+    if (cssAPI.config.separateCSS)
+      separateCSS = true;
+    if (typeof curModule == 'number' && cssAPI.config.modules[curModule].separateCSS !== undefined)
+      separateCSS = cssAPI.config.modules[curModule].separateCSS;
+    if (separateCSS)
+      write.asModule(pluginName + '!' + moduleName, 'define(function(){})');
+    else
+      write("requirejs.s.contexts._.nextTick = function(f){f()}; require(['css'], function(css) { css.addBuffer('" + resourceName + "'); }); requirejs.s.contexts._.nextTick = requirejs.nextTick;");
+  }
+  
+  cssAPI.onLayerEnd = function(write, data, parser) {
+    firstWrite = true;
+    //separateCSS parameter set either globally or as a layer setting
+    var separateCSS = false;
+    if (cssAPI.config.separateCSS)
+      separateCSS = true;
+    if (typeof curModule == 'number' && cssAPI.config.modules[curModule].separateCSS !== undefined)
+      separateCSS = cssAPI.config.modules[curModule].separateCSS;
+    curModule = null;
+    
+    //calculate layer css
+    var css = _layerBuffer.join('');
+    
+    if (separateCSS) {
+      nodePrint('Writing CSS! file: ' + data.name + '\n');
+      
+      //calculate the css output path for this layer
+      var path = this.config.appDir ? this.config.baseUrl + data.name + '.css' : cssAPI.config.out.replace(/\.js$/, '.css');
+      
+      //renormalize the css to the output path
+      var output = compress(normalize(css, baseUrl, path));
+      
+      saveFile(path, output);
+    }
+    else {
+      if (css == '')
+        return;
+      //write the injection and layer index into the layer
+      //prepare the css
+      css = escape(compress(css));
+      
+      //the code below overrides async require functionality to ensure instant buffer injection
+      write("requirejs.s.contexts._.nextTick = function(f){f()}; require(['css'], function(css) { css.setBuffer('" + css + (parser ? "', true" : "'") + "); }); requirejs.s.contexts._.nextTick = requirejs.nextTick; ");
+    }
+    
+    //clear layer buffer for next layer
+    _layerBuffer = [];
+  }
+  
+  return cssAPI;
+});

+ 435 - 0
js/lib/require-css-0.0.6/css.js

@@ -0,0 +1,435 @@
+/*
+ * Require-CSS RequireJS css! loader plugin
+ * Guy Bedford 2013
+ * MIT
+ */
+
+/*
+ *
+ * Usage:
+ *  require(['css!./mycssFile']);
+ *
+ * NB leave out the '.css' extension.
+ *
+ * - Fully supports cross origin CSS loading
+ * - Works with builds
+ *
+ * Tested and working in (up to latest versions as of March 2013):
+ * Android
+ * iOS 6
+ * IE 6 - 10
+ * Chome 3 - 26
+ * Firefox 3.5 - 19
+ * Opera 10 - 12
+ * 
+ * browserling.com used for virtual testing environment
+ *
+ * Credit to B Cavalier & J Hann for the elegant IE 6 - 9 hack.
+ * 
+ * Sources that helped along the way:
+ * - https://developer.mozilla.org/en-US/docs/Browser_detection_using_the_user_agent
+ * - http://www.phpied.com/when-is-a-stylesheet-really-loaded/
+ * - https://github.com/cujojs/curl/blob/master/src/curl/plugin/css.js
+ *
+ */
+
+define(['./normalize'], function(normalize) {
+  function indexOf(a, e) { for (var i=0, l=a.length; i < l; i++) if (a[i] === e) return i; return -1 }
+
+  if (typeof window == 'undefined')
+    return { load: function(n, r, load){ load() } };
+
+  // set to true to enable test prompts for device testing
+  var testing = false;
+  
+  var head = document.getElementsByTagName('head')[0];
+
+  var engine = window.navigator.userAgent.match(/Trident\/([^ ;]*)|AppleWebKit\/([^ ;]*)|Opera\/([^ ;]*)|rv\:([^ ;]*)(.*?)Gecko\/([^ ;]*)|MSIE\s([^ ;]*)/);
+  var hackLinks = false;
+
+  if (!engine) {}
+  else if (engine[1] || engine[7]) {
+    hackLinks = parseInt(engine[1]) < 6 || parseInt(engine[7]) <= 9;
+    engine = 'trident';
+  }
+  else if (engine[2]) {
+    // unfortunately style querying still doesnt work with onload callback in webkit
+    hackLinks = true;
+    engine = 'webkit';
+  }
+  else if (engine[3]) {
+    // engine = 'opera';
+  }
+  else if (engine[4]) {
+    hackLinks = parseInt(engine[4]) < 18;
+    engine = 'gecko';
+  }
+  else if (testing)
+    alert('Engine detection failed');
+  
+  //main api object
+  var cssAPI = {};
+
+  var absUrlRegEx = /^\/|([^\:\/]*:)/;
+  
+  cssAPI.pluginBuilder = './css-builder';
+
+  // used by layer builds to register their css buffers
+  
+  // the current layer buffer items (from addBuffer)
+  var curBuffer = [];
+
+  // the callbacks for buffer loads
+  var onBufferLoad = {};
+
+  // the full list of resources in the buffer
+  var bufferResources = [];
+
+  cssAPI.addBuffer = function(resourceId) {
+    // just in case layer scripts are included twice, also check
+    // against the previous buffers
+    if (indexOf(curBuffer, resourceId) != -1)
+      return;
+    if (indexOf(bufferResources, resourceId) != -1)
+      return;
+    curBuffer.push(resourceId);
+    bufferResources.push(resourceId);
+  }
+  cssAPI.setBuffer = function(css, isLess) {
+    var pathname = window.location.pathname.split('/');
+    pathname.pop();
+    pathname = pathname.join('/') + '/';
+
+    var baseParts = require.toUrl('base_url').split('/');
+    baseParts.pop();
+    var baseUrl = baseParts.join('/') + '/';
+    baseUrl = normalize.convertURIBase(baseUrl, pathname, '/');
+    if (!baseUrl.match(absUrlRegEx))
+      baseUrl = '/' + baseUrl;
+    if (baseUrl.substr(baseUrl.length - 1, 1) != '/')
+      baseUrl = baseUrl + '/';
+
+    cssAPI.inject(normalize(css, baseUrl, pathname));
+
+    // set up attach callback if registered
+    // clear the current buffer for the next layer
+    // (just the less or css part as we have two buffers in one effectively)
+    for (var i = 0; i < curBuffer.length; i++) {
+      // find the resources in the less or css buffer dependening which one this is
+      if ((isLess && curBuffer[i].substr(curBuffer[i].length - 5, 5) == '.less') ||
+        (!isLess && curBuffer[i].substr(curBuffer[i].length - 4, 4) == '.css')) {
+        (function(resourceId) {
+          // mark that the onBufferLoad is about to be called (set to true if not already a callback function)
+          onBufferLoad[resourceId] = onBufferLoad[resourceId] || true;
+
+          // set a short timeout (as injection isn't instant in Chrome), then call the load
+          setTimeout(function() {
+            if (typeof onBufferLoad[resourceId] == 'function')
+              onBufferLoad[resourceId]();
+            // remove from onBufferLoad to indicate loaded
+            delete onBufferLoad[resourceId];
+          }, 7);
+        })(curBuffer[i]);
+
+        // remove the current resource from the buffer
+        curBuffer.splice(i--, 1);
+      }
+    }
+  }
+  cssAPI.attachBuffer = function(resourceId, load) {
+    // attach can happen during buffer collecting, or between injection and callback
+    // we assume it is not possible to attach multiple callbacks
+    // requirejs plugin load function ensures this by queueing duplicate calls
+
+    // check if the resourceId is in the current buffer
+    for (var i = 0; i < curBuffer.length; i++)
+      if (curBuffer[i] == resourceId) {
+        onBufferLoad[resourceId] = load;
+        return true;
+      }
+
+    // check if the resourceId is waiting for injection callback
+    // (onBufferLoad === true is a shortcut indicator for this)
+    if (onBufferLoad[resourceId] === true) {
+      onBufferLoad[resourceId] = load;
+      return true;
+    }
+
+    // if it's in the full buffer list and not either of the above, its loaded already
+    if (indexOf(bufferResources, resourceId) != -1) {
+      load();
+      return true;
+    }
+  }
+
+  var webkitLoadCheck = function(link, callback) {
+    setTimeout(function() {
+      for (var i = 0; i < document.styleSheets.length; i++) {
+        var sheet = document.styleSheets[i];
+        if (sheet.href == link.href)
+          return callback();
+      }
+      webkitLoadCheck(link, callback);
+    }, 10);
+  }
+
+  var mozillaLoadCheck = function(style, callback) {
+    setTimeout(function() {
+      try {
+        style.sheet.cssRules;
+        return callback();
+      } catch (e){}
+      mozillaLoadCheck(style, callback);
+    }, 10);
+  }
+
+  // ie link detection, as adapted from https://github.com/cujojs/curl/blob/master/src/curl/plugin/css.js
+  if (engine == 'trident' && hackLinks) {
+    var ieStyles = [],
+      ieQueue = [],
+      ieStyleCnt = 0;
+    var ieLoad = function(url, callback) {
+      var style;
+      ieQueue.push({
+        url: url,
+        cb: callback
+      });
+      style = ieStyles.shift();
+      if (!style && ieStyleCnt++ < 12) {
+        style = document.createElement('style');
+        head.appendChild(style);
+      }
+      ieLoadNextImport(style);
+    }
+    var ieLoadNextImport = function(style) {
+      var curImport = ieQueue.shift();
+      if (!curImport) {
+        style.onload = noop;
+        ieStyles.push(style);
+        return;  
+      }
+      style.onload = function() {
+        curImport.cb(curImport.ss);
+        ieLoadNextImport(style);
+      };
+      var curSheet = style.styleSheet;
+      curImport.ss = curSheet.imports[curSheet.addImport(curImport.url)];
+    }
+  }
+
+  // uses the <link> load method
+  var createLink = function(url) {
+    var link = document.createElement('link');
+    link.type = 'text/css';
+    link.rel = 'stylesheet';
+    link.href = url;
+    return link;
+  }
+
+  var noop = function(){}
+
+  cssAPI.linkLoad = function(url, callback) {
+    var timeout = setTimeout(function() {
+      if (testing) alert('timeout');
+      callback();
+    }, waitSeconds * 1000 - 100);
+    var _callback = function() {
+      clearTimeout(timeout);
+      if (link)
+        link.onload = noop;
+      // for style querying, a short delay still seems necessary
+      setTimeout(callback, 7);
+    }
+    if (!hackLinks) {
+      var link = createLink(url);
+      link.onload = _callback;
+      head.appendChild(link);
+    }
+    // hacks
+    else {
+      if (engine == 'webkit') {
+        var link = createLink(url);
+        webkitLoadCheck(link, _callback);
+        head.appendChild(link);
+      }
+      else if (engine == 'gecko') {
+        var style = document.createElement('style');
+        style.textContent = '@import "' + url + '"';
+        mozillaLoadCheck(style, _callback);
+        head.appendChild(style);
+      }
+      else if (engine == 'trident')
+        ieLoad(url, _callback);
+    }
+  }
+
+  /* injection api */
+  var progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];
+  var fileCache = {};
+  var get = function(url, callback, errback) {
+    if (fileCache[url]) {
+      callback(fileCache[url]);
+      return;
+    }
+
+    var xhr, i, progId;
+    if (typeof XMLHttpRequest !== 'undefined')
+      xhr = new XMLHttpRequest();
+    else if (typeof ActiveXObject !== 'undefined')
+      for (i = 0; i < 3; i += 1) {
+        progId = progIds[i];
+        try {
+          xhr = new ActiveXObject(progId);
+        }
+        catch (e) {}
+  
+        if (xhr) {
+          progIds = [progId];  // so faster next time
+          break;
+        }
+      }
+    
+    xhr.open('GET', url, requirejs.inlineRequire ? false : true);
+  
+    xhr.onreadystatechange = function (evt) {
+      var status, err;
+      //Do not explicitly handle errors, those should be
+      //visible via console output in the browser.
+      if (xhr.readyState === 4) {
+        status = xhr.status;
+        if (status > 399 && status < 600) {
+          //An http 4xx or 5xx error. Signal an error.
+          err = new Error(url + ' HTTP status: ' + status);
+          err.xhr = xhr;
+          errback(err);
+        }
+        else {
+          fileCache[url] = xhr.responseText;
+          callback(xhr.responseText);
+        }
+      }
+    };
+    
+    xhr.send(null);
+  }
+  //uses the <style> load method
+  var styleCnt = 0;
+  var curStyle;
+  cssAPI.inject = function(css) {
+    if (styleCnt < 31) {
+      curStyle = document.createElement('style');
+      curStyle.type = 'text/css';
+      head.appendChild(curStyle);
+      styleCnt++;
+    }
+    if (curStyle.styleSheet)
+      curStyle.styleSheet.cssText += css;
+    else
+      curStyle.appendChild(document.createTextNode(css));
+  }
+  
+  // NB add @media query support for media imports
+  var importRegEx = /@import\s*(url)?\s*(('([^']*)'|"([^"]*)")|\(('([^']*)'|"([^"]*)"|([^\)]*))\))\s*;?/g;
+
+  var pathname = window.location.pathname.split('/');
+  pathname.pop();
+  pathname = pathname.join('/') + '/';
+
+  var loadCSS = function(fileUrl, callback, errback) {
+
+    //make file url absolute
+    if (!fileUrl.match(absUrlRegEx))
+      fileUrl = '/' + normalize.convertURIBase(fileUrl, pathname, '/');
+
+    get(fileUrl, function(css) {
+
+      // normalize the css (except import statements)
+      css = normalize(css, fileUrl, pathname);
+
+      // detect all import statements in the css and normalize
+      var importUrls = [];
+      var importIndex = [];
+      var importLength = [];
+      var match;
+      while (match = importRegEx.exec(css)) {
+        var importUrl = match[4] || match[5] || match[7] || match[8] || match[9];
+
+        importUrls.push(importUrl);
+        importIndex.push(importRegEx.lastIndex - match[0].length);
+        importLength.push(match[0].length);
+      }
+
+      // load the import stylesheets and substitute into the css
+      var completeCnt = 0;
+      for (var i = 0; i < importUrls.length; i++)
+        (function(i) {
+          loadCSS(importUrls[i], function(importCSS) {
+            css = css.substr(0, importIndex[i]) + importCSS + css.substr(importIndex[i] + importLength[i]);
+            var lenDiff = importCSS.length - importLength[i];
+            for (var j = i + 1; j < importUrls.length; j++)
+              importIndex[j] += lenDiff;
+            completeCnt++;
+            if (completeCnt == importUrls.length) {
+              callback(css);
+            }
+          }, errback);
+        })(i);
+
+      if (importUrls.length == 0)
+        callback(css);
+    }, errback);
+  }
+
+  
+  cssAPI.normalize = function(name, normalize) {
+    if (name.substr(name.length - 4, 4) == '.css')
+      name = name.substr(0, name.length - 4);
+    
+    return normalize(name);
+  }
+  
+  var waitSeconds;
+  var alerted = false;
+  cssAPI.load = function(cssId, req, load, config, parse) {
+    
+    waitSeconds = waitSeconds || config.waitSeconds || 7;
+
+    var resourceId = cssId + (!parse ? '.css' : '.less');
+
+    // attach the load function to a buffer if there is one in registration
+    // if not, we do a full injection load
+    if (cssAPI.attachBuffer(resourceId, load))
+      return;
+
+    fileUrl = req.toUrl(resourceId);
+    
+    if (!alerted && testing) {
+      alert(hackLinks ? 'hacking links' : 'not hacking');
+      alerted = true;
+    }
+
+    if (!parse) {
+      cssAPI.linkLoad(fileUrl, load);
+    }
+    else {
+      loadCSS(fileUrl, function(css) {
+        // run parsing after normalization - since less is a CSS subset this works fine
+        if (parse)
+          css = parse(css, function(css) {
+            cssAPI.inject(css);
+            setTimeout(load, 7);
+          });
+      });
+    }
+  }
+
+  if (testing)
+    cssAPI.inspect = function() {
+      if (stylesheet.styleSheet)
+        return stylesheet.styleSheet.cssText;
+      else if (stylesheet.innerHTML)
+        return stylesheet.innerHTML;
+    }
+  
+  return cssAPI;
+});

+ 138 - 0
js/lib/require-css-0.0.6/normalize.js

@@ -0,0 +1,138 @@
+/*
+ * css.normalize.js
+ *
+ * CSS Normalization
+ *
+ * CSS paths are normalized based on an optional basePath and the RequireJS config
+ *
+ * Usage:
+ *   normalize(css, fromBasePath, toBasePath);
+ *
+ * css: the stylesheet content to normalize
+ * fromBasePath: the absolute base path of the css relative to any root (but without ../ backtracking)
+ * toBasePath: the absolute new base path of the css relative to the same root
+ * 
+ * Absolute dependencies are left untouched.
+ *
+ * Urls in the CSS are picked up by regular expressions.
+ * These will catch all statements of the form:
+ *
+ * url(*)
+ * url('*')
+ * url("*")
+ * 
+ * @import '*'
+ * @import "*"
+ *
+ * (and so also @import url(*) variations)
+ *
+ * For urls needing normalization
+ *
+ */
+
+define(['require', 'module'], function(require, module) {
+  
+  // regular expression for removing double slashes
+  // eg http://www.example.com//my///url/here -> http://www.example.com/my/url/here
+  var slashes = /([^:])\/+/g
+  var removeDoubleSlashes = function(uri) {
+    return uri.replace(slashes, '$1/');
+  }
+
+  // given a relative URI, and two absolute base URIs, convert it from one base to another
+  var protocolRegEx = /[^\:\/]*:\/\/([^\/])*/
+  function convertURIBase(uri, fromBase, toBase) {
+    if(uri.indexOf("data:") === 0)
+      return uri;
+    uri = removeDoubleSlashes(uri);
+    // absolute urls are left in tact
+    if (uri.match(/^\//) || uri.match(protocolRegEx))
+      return uri;
+    // if toBase specifies a protocol path, ensure this is the same protocol as fromBase, if not
+    // use absolute path at fromBase
+    var toBaseProtocol = toBase.match(protocolRegEx);
+    var fromBaseProtocol = fromBase.match(protocolRegEx);
+    if (fromBaseProtocol && (!toBaseProtocol || toBaseProtocol[1] != fromBaseProtocol[1] || toBaseProtocol[2] != fromBaseProtocol[2]))
+      return absoluteURI(uri, fromBase);
+    
+    else {
+      return relativeURI(absoluteURI(uri, fromBase), toBase);
+    }
+  };
+  
+  // given a relative URI, calculate the absolute URI
+  function absoluteURI(uri, base) {
+    if (uri.substr(0, 2) == './')
+      uri = uri.substr(2);    
+    
+    var baseParts = base.split('/');
+    var uriParts = uri.split('/');
+    
+    baseParts.pop();
+    
+    while (curPart = uriParts.shift())
+      if (curPart == '..')
+        baseParts.pop();
+      else
+        baseParts.push(curPart);
+    
+    return baseParts.join('/');
+  };
+
+
+  // given an absolute URI, calculate the relative URI
+  function relativeURI(uri, base) {
+    
+    // reduce base and uri strings to just their difference string
+    var baseParts = base.split('/');
+    baseParts.pop();
+    base = baseParts.join('/') + '/';
+    i = 0;
+    while (base.substr(i, 1) == uri.substr(i, 1))
+      i++;
+    while (base.substr(i, 1) != '/')
+      i--;
+    base = base.substr(i + 1);
+    uri = uri.substr(i + 1);
+
+    // each base folder difference is thus a backtrack
+    baseParts = base.split('/');
+    var uriParts = uri.split('/');
+    out = '';
+    while (baseParts.shift())
+      out += '../';
+    
+    // finally add uri parts
+    while (curPart = uriParts.shift())
+      out += curPart + '/';
+    
+    return out.substr(0, out.length - 1);
+  };
+  
+  var normalizeCSS = function(source, fromBase, toBase, cssBase) {
+
+    fromBase = removeDoubleSlashes(fromBase);
+    toBase = removeDoubleSlashes(toBase);
+
+    var urlRegEx = /@import\s*("([^"]*)"|'([^']*)')|url\s*\(\s*(\s*"([^"]*)"|'([^']*)'|[^\)]*\s*)\s*\)/ig;
+    var result, url, source;
+
+    while (result = urlRegEx.exec(source)) {
+      url = result[3] || result[2] || result[5] || result[6] || result[4];
+      var newUrl;
+      if (cssBase && url.substr(0, 1) == '/')
+        newUrl = cssBase + url;
+      else
+        newUrl = convertURIBase(url, fromBase, toBase);
+      var quoteLen = result[5] || result[6] ? 1 : 0;
+      source = source.substr(0, urlRegEx.lastIndex - url.length - quoteLen - 1) + newUrl + source.substr(urlRegEx.lastIndex - quoteLen - 1);
+      urlRegEx.lastIndex = urlRegEx.lastIndex + (newUrl.length - url.length);
+    }
+    
+    return source;
+  };
+  
+  normalizeCSS.convertURIBase = convertURIBase;
+  
+  return normalizeCSS;
+});

+ 5 - 0
js/lib/require-css-0.0.6/package.json

@@ -0,0 +1,5 @@
+{
+  "volo": {
+    "type": "directory"
+  }
+}

+ 36 - 0
js/lib/require.min.js

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