瀏覽代碼

AMBARI-8799. View: Files, cleanup and rendering optimization (alexantonenko)

Alex Antonenko 10 年之前
父節點
當前提交
2c33f87625
共有 42 個文件被更改,包括 4734 次插入244 次删除
  1. 12 18
      contrib/views/files/src/main/resources/ui/app/adapter.js
  2. 266 0
      contrib/views/files/src/main/resources/ui/app/assets/javascripts/ember-qunit.js
  3. 692 0
      contrib/views/files/src/main/resources/ui/app/assets/javascripts/jquery.mockjax.js
  4. 3 0
      contrib/views/files/src/main/resources/ui/app/assets/javascripts/modernizr-2.6.2.min.js
  5. 2495 0
      contrib/views/files/src/main/resources/ui/app/assets/javascripts/qunit.js
  6. 29 0
      contrib/views/files/src/main/resources/ui/app/assets/javascripts/tests.js
  7. 237 0
      contrib/views/files/src/main/resources/ui/app/assets/stylesheets/qunit.css
  8. 46 0
      contrib/views/files/src/main/resources/ui/app/assets/tests.html
  9. 1 1
      contrib/views/files/src/main/resources/ui/app/components/breadCrumbs.js
  10. 5 16
      contrib/views/files/src/main/resources/ui/app/components/bulkCheckbox.js
  11. 3 3
      contrib/views/files/src/main/resources/ui/app/components/confirmDelete.js
  12. 1 1
      contrib/views/files/src/main/resources/ui/app/components/contextMenu.js
  13. 2 4
      contrib/views/files/src/main/resources/ui/app/components/popoverDelete.js
  14. 11 21
      contrib/views/files/src/main/resources/ui/app/components/renameInput.js
  15. 4 9
      contrib/views/files/src/main/resources/ui/app/components/sortArrow.js
  16. 3 3
      contrib/views/files/src/main/resources/ui/app/components/toggleContext.js
  17. 5 5
      contrib/views/files/src/main/resources/ui/app/components/uploader.js
  18. 8 39
      contrib/views/files/src/main/resources/ui/app/controllers/chmodModal.js
  19. 2 2
      contrib/views/files/src/main/resources/ui/app/controllers/error.js
  20. 4 19
      contrib/views/files/src/main/resources/ui/app/controllers/file.js
  21. 28 6
      contrib/views/files/src/main/resources/ui/app/controllers/files.js
  22. 1 6
      contrib/views/files/src/main/resources/ui/app/controllers/filesAlert.js
  23. 3 2
      contrib/views/files/src/main/resources/ui/app/initialize.js
  24. 1 1
      contrib/views/files/src/main/resources/ui/app/models/file.js
  25. 29 6
      contrib/views/files/src/main/resources/ui/app/routes/file.js
  26. 7 1
      contrib/views/files/src/main/resources/ui/app/styles/application.less
  27. 1 1
      contrib/views/files/src/main/resources/ui/app/templates/components/contextMenu.hbs
  28. 1 1
      contrib/views/files/src/main/resources/ui/app/templates/components/mkdirInput.hbs
  29. 27 14
      contrib/views/files/src/main/resources/ui/app/templates/files.hbs
  30. 97 0
      contrib/views/files/src/main/resources/ui/app/templates/modal/chmod.hbs
  31. 0 2
      contrib/views/files/src/main/resources/ui/app/templates/util/errorRow.hbs
  32. 3 14
      contrib/views/files/src/main/resources/ui/app/templates/util/fileRow.hbs
  33. 7 27
      contrib/views/files/src/main/resources/ui/app/views/file.js
  34. 32 0
      contrib/views/files/src/main/resources/ui/app/views/files.js
  35. 50 0
      contrib/views/files/src/main/resources/ui/app/views/modalChmod.js
  36. 2 1
      contrib/views/files/src/main/resources/ui/config.coffee
  37. 8 4
      contrib/views/files/src/main/resources/ui/package.json
  38. 136 0
      contrib/views/files/src/main/resources/ui/runner.js
  39. 0 17
      contrib/views/files/src/main/resources/ui/test/spec.coffee
  40. 32 0
      contrib/views/files/src/main/resources/ui/test/unit/controllers/files_test.js
  41. 436 0
      contrib/views/files/src/main/resources/ui/vendor/js/ember-cloaking.js
  42. 4 0
      pom.xml

+ 12 - 18
contrib/views/files/src/main/resources/ui/app/adapter.js

@@ -200,12 +200,7 @@ App.ApplicationStore = DS.Store.extend({
     return promiseArray(_listdir(adapter, this, type, query, array));
   },
   move:function (record, path) {
-    var oldpath;
-    if (typeof record === 'string') {
-      oldpath = record;
-    } else {
-      oldpath = record.get('id');
-    }
+    var oldpath = (typeof record === 'string')?record:record.get('id');
     var query = {
       "src":oldpath,
       "dst":path
@@ -243,7 +238,7 @@ App.ApplicationStore = DS.Store.extend({
     var promiseLabel = "DS: Model#remove " + this;
     var resolver = Ember.RSVP.defer(promiseLabel);
     var adapter = this.adapterFor(type);
-    
+
     record.deleteRecord();
     resolver.resolve(_remove(adapter, this, record, query, toTrash));
 
@@ -253,15 +248,14 @@ App.ApplicationStore = DS.Store.extend({
    * get dowload link
    * @param  {Array} files     records for download
    * @param  {String} option            browse, zip or concat
-   * @param  {Boolean} download
+   * @param  {Boolean} downloadArg
    * @return {Promise}
    */
-  linkFor:function (files, option, download) {
-    var resolver = Ember.RSVP.defer('promiseLabel'),
-    adapter = this.adapterFor(this.modelFor('file')),
-    query = {},
-    download = download || true;
-    option = option || "browse";
+  linkFor:function (files, option, downloadArg) {
+    var resolver = Ember.RSVP.defer('promiseLabel');
+    var query, adapter = this.adapterFor(this.modelFor('file')),
+        download = downloadArg || true;
+        option = option || "browse";
 
     if (option == 'browse') {
       query = { "path": files.get('firstObject.path'), "download": download };
@@ -313,7 +307,7 @@ App.Uploader = Ember.Uploader.create({
     var self = this;
 
     this.set('isUploading', true);
-    
+
     return this.ajax(url, data, type)
       .then(Em.run.bind(this,this.uploadSuccess),Em.run.bind(this,this.uploadFailed));
   },
@@ -351,7 +345,7 @@ App.Uploader = Ember.Uploader.create({
   }
 });
 
-App.IsodateTransform = DS.Transform.extend({  
+App.IsodateTransform = DS.Transform.extend({
   deserialize: function (serialized) {
     if (serialized) {
       return moment.utc(serialized).toDate();
@@ -367,11 +361,11 @@ App.IsodateTransform = DS.Transform.extend({
 });
 
 Ember.Handlebars.registerBoundHelper('showDate', function(date,format) {
-  return moment(date).format(format)
+  return moment(date).format(format);
 });
 
 Ember.Handlebars.registerBoundHelper('showDateUnix', function(date,format) {
-  return moment.unix(date).format(format)
+  return moment.unix(date).format(format);
 });
 
 Ember.Handlebars.registerBoundHelper('capitalize', function(string) {

+ 266 - 0
contrib/views/files/src/main/resources/ui/app/assets/javascripts/ember-qunit.js

@@ -0,0 +1,266 @@
+!function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.emq=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
+"use strict";
+var testResolver = _dereq_("./test-resolver")["default"] || _dereq_("./test-resolver");
+var Ember = window.Ember["default"] || window.Ember;
+
+exports["default"] = function isolatedContainer(fullNames) {
+  var resolver = testResolver.get();
+  var container = new Ember.Container();
+  container.optionsForType('component', { singleton: false });
+  container.optionsForType('view', { singleton: false });
+  container.optionsForType('template', { instantiate: false });
+  container.optionsForType('helper', { instantiate: false });
+  container.register('component-lookup:main', Ember.ComponentLookup);
+  for (var i = fullNames.length; i > 0; i--) {
+    var fullName = fullNames[i - 1];
+    container.register(fullName, resolver.resolve(fullName));
+  }
+  return container;
+}
+},{"./test-resolver":7}],2:[function(_dereq_,module,exports){
+"use strict";
+var Ember = window.Ember["default"] || window.Ember;
+var isolatedContainer = _dereq_("./isolated-container")["default"] || _dereq_("./isolated-container");
+var moduleFor = _dereq_("./module-for")["default"] || _dereq_("./module-for");
+var moduleForComponent = _dereq_("./module-for-component")["default"] || _dereq_("./module-for-component");
+var moduleForModel = _dereq_("./module-for-model")["default"] || _dereq_("./module-for-model");
+var test = _dereq_("./test")["default"] || _dereq_("./test");
+var testResolver = _dereq_("./test-resolver")["default"] || _dereq_("./test-resolver");
+
+Ember.testing = true;
+
+function setResolver(resolver) {
+  testResolver.set(resolver);
+}
+
+function globalize() {
+  window.moduleFor = moduleFor;
+  window.moduleForComponent = moduleForComponent;
+  window.moduleForModel = moduleForModel;
+  window.test = test;
+  window.setResolver = setResolver;
+}
+
+exports.globalize = globalize;
+exports.moduleFor = moduleFor;
+exports.moduleForComponent = moduleForComponent;
+exports.moduleForModel = moduleForModel;
+exports.test = test;
+exports.setResolver = setResolver;
+},{"./isolated-container":1,"./module-for":5,"./module-for-component":3,"./module-for-model":4,"./test":8,"./test-resolver":7}],3:[function(_dereq_,module,exports){
+"use strict";
+var testResolver = _dereq_("./test-resolver")["default"] || _dereq_("./test-resolver");
+var moduleFor = _dereq_("./module-for")["default"] || _dereq_("./module-for");
+var Ember = window.Ember["default"] || window.Ember;
+
+exports["default"] = function moduleForComponent(name, description, callbacks) {
+  var resolver = testResolver.get();
+
+  moduleFor('component:' + name, description, callbacks, function(container, context, defaultSubject) {
+    var layoutName = 'template:components/' + name;
+
+    var layout = resolver.resolve(layoutName);
+
+    if (layout) {
+      container.register(layoutName, layout);
+      container.injection('component:' + name, 'layout', layoutName);
+    }
+
+    context.dispatcher = Ember.EventDispatcher.create();
+    context.dispatcher.setup({}, '#ember-testing');
+
+    context.__setup_properties__.append = function(selector) {
+      var containerView = Ember.ContainerView.create({container: container});
+      var view = Ember.run(function(){
+        var subject = context.subject();
+        containerView.pushObject(subject);
+        // TODO: destory this somewhere
+        containerView.appendTo('#ember-testing');
+        return subject;
+      });
+
+      return view.$();
+    };
+    context.__setup_properties__.$ = context.__setup_properties__.append;
+  });
+}
+},{"./module-for":5,"./test-resolver":7}],4:[function(_dereq_,module,exports){
+"use strict";
+var moduleFor = _dereq_("./module-for")["default"] || _dereq_("./module-for");
+var Ember = window.Ember["default"] || window.Ember;
+
+exports["default"] = function moduleForModel(name, description, callbacks) {
+  moduleFor('model:' + name, description, callbacks, function(container, context, defaultSubject) {
+    if (DS._setupContainer) {
+      DS._setupContainer(container);
+    } else {
+      container.register('store:main', DS.Store);
+    }
+
+    var adapterFactory = container.lookupFactory('adapter:application');
+    if (!adapterFactory) {
+      container.register('adapter:application', DS.FixtureAdapter);
+    }
+
+    context.__setup_properties__.store = function(){
+      return container.lookup('store:main');
+    };
+
+    if (context.__setup_properties__.subject === defaultSubject) {
+      context.__setup_properties__.subject = function(options) {
+        return Ember.run(function() {
+          return container.lookup('store:main').createRecord(name, options);
+        });
+      };
+    }
+  });
+}
+},{"./module-for":5}],5:[function(_dereq_,module,exports){
+"use strict";
+var Ember = window.Ember["default"] || window.Ember;
+//import QUnit from 'qunit'; // Assumed global in runner
+var testContext = _dereq_("./test-context")["default"] || _dereq_("./test-context");
+var isolatedContainer = _dereq_("./isolated-container")["default"] || _dereq_("./isolated-container");
+
+exports["default"] = function moduleFor(fullName, description, callbacks, delegate) {
+  var container;
+  var context;
+
+  var _callbacks = {
+    setup: function(){
+      callbacks = callbacks || { };
+
+      var needs = [fullName].concat(callbacks.needs || []);
+      container = isolatedContainer(needs);
+
+      callbacks.subject   = callbacks.subject || defaultSubject;
+
+      callbacks.setup     = callbacks.setup    || function() { };
+      callbacks.teardown  = callbacks.teardown || function() { };
+
+      function factory() {
+        return container.lookupFactory(fullName);
+      }
+
+      testContext.set({
+        container:            container,
+        factory:              factory,
+        dispatcher:           null,
+        __setup_properties__: callbacks
+      });
+
+      context = testContext.get();
+
+      if (delegate) {
+        delegate(container, context, defaultSubject);
+      }
+
+      if (Ember.$('#ember-testing').length === 0) {
+        Ember.$('<div id="ember-testing"/>').appendTo(document.body);
+      }
+
+      buildContextVariables(context);
+      callbacks.setup.call(context, container);
+    },
+
+    teardown: function(){
+      Ember.run(function(){
+        container.destroy();
+
+        if (context.dispatcher) {
+          context.dispatcher.destroy();
+        }
+      });
+
+      callbacks.teardown(container);
+      Ember.$('#ember-testing').empty();
+    }
+  };
+
+  QUnit.module(description || fullName, _callbacks);
+}
+
+function defaultSubject(options, factory) {
+  return factory.create(options);
+}
+
+// allow arbitrary named factories, like rspec let
+function buildContextVariables(context) {
+  var cache     = { };
+  var callbacks = context.__setup_properties__;
+  var container = context.container;
+  var factory   = context.factory;
+
+  Ember.keys(callbacks).filter(function(key){
+    // ignore the default setup/teardown keys
+    return key !== 'setup' && key !== 'teardown';
+  }).forEach(function(key){
+    context[key] = function(options) {
+      if (cache[key]) { return cache[key]; }
+
+      var result = callbacks[key](options, factory(), container);
+      cache[key] = result;
+      return result;
+    };
+  });
+}
+},{"./isolated-container":1,"./test-context":6}],6:[function(_dereq_,module,exports){
+"use strict";
+var __test_context__;
+
+function set(context) {
+  __test_context__ = context;
+}
+
+exports.set = set;function get() {
+  return __test_context__;
+}
+
+exports.get = get;
+},{}],7:[function(_dereq_,module,exports){
+"use strict";
+var __resolver__;
+
+function set(resolver) {
+  __resolver__ = resolver;
+}
+
+exports.set = set;function get() {
+  if (__resolver__ == null) throw new Error('you must set a resolver with `testResolver.set(resolver)`');
+  return __resolver__;
+}
+
+exports.get = get;
+},{}],8:[function(_dereq_,module,exports){
+"use strict";
+var Ember = window.Ember["default"] || window.Ember;
+//import QUnit from 'qunit'; // Assumed global in runner
+var testContext = _dereq_("./test-context")["default"] || _dereq_("./test-context");
+
+function resetViews() {
+  Ember.View.views = {};
+}
+
+exports["default"] = function test(testName, callback) {
+
+  function wrapper() {
+    var context = testContext.get();
+
+    resetViews();
+    var result = callback.call(context);
+
+    function failTestOnPromiseRejection(reason) {
+      ok(false, reason);
+    }
+
+    Ember.run(function(){
+      stop();
+      Ember.RSVP.Promise.cast(result)['catch'](failTestOnPromiseRejection)['finally'](start);
+    });
+  }
+
+  QUnit.test(testName, wrapper);
+}
+},{"./test-context":6}]},{},[2])
+(2)
+});

+ 692 - 0
contrib/views/files/src/main/resources/ui/app/assets/javascripts/jquery.mockjax.js

@@ -0,0 +1,692 @@
+/*!
+ * MockJax - jQuery Plugin to Mock Ajax requests
+ *
+ * Version:  1.6.0
+ * Released:
+ * Home:   https://github.com/jakerella/jquery-mockjax
+ * Author:   Jonathan Sharp (http://jdsharp.com)
+ * License:  MIT,GPL
+ *
+ * Copyright (c) 2014 appendTo, Jordan Kasper
+ * NOTE: This repository was taken over by Jordan Kasper (@jakerella) October, 2014
+ *
+ * Dual licensed under the MIT or GPL licenses.
+ * http://opensource.org/licenses/MIT OR http://www.gnu.org/licenses/gpl-2.0.html
+ */
+(function($) {
+  var _ajax = $.ajax,
+    mockHandlers = [],
+    mockedAjaxCalls = [],
+    unmockedAjaxCalls = [],
+    CALLBACK_REGEX = /=\?(&|$)/,
+    jsc = (new Date()).getTime();
+
+
+  // Parse the given XML string.
+  function parseXML(xml) {
+    if ( window.DOMParser == undefined && window.ActiveXObject ) {
+      DOMParser = function() { };
+      DOMParser.prototype.parseFromString = function( xmlString ) {
+        var doc = new ActiveXObject('Microsoft.XMLDOM');
+        doc.async = 'false';
+        doc.loadXML( xmlString );
+        return doc;
+      };
+    }
+
+    try {
+      var xmlDoc = ( new DOMParser() ).parseFromString( xml, 'text/xml' );
+      if ( $.isXMLDoc( xmlDoc ) ) {
+        var err = $('parsererror', xmlDoc);
+        if ( err.length == 1 ) {
+          throw new Error('Error: ' + $(xmlDoc).text() );
+        }
+      } else {
+        throw new Error('Unable to parse XML');
+      }
+      return xmlDoc;
+    } catch( e ) {
+      var msg = ( e.name == undefined ? e : e.name + ': ' + e.message );
+      $(document).trigger('xmlParseError', [ msg ]);
+      return undefined;
+    }
+  }
+
+  // Check if the data field on the mock handler and the request match. This
+  // can be used to restrict a mock handler to being used only when a certain
+  // set of data is passed to it.
+  function isMockDataEqual( mock, live ) {
+    var identical = true;
+    // Test for situations where the data is a querystring (not an object)
+    if (typeof live === 'string') {
+      // Querystring may be a regex
+      return $.isFunction( mock.test ) ? mock.test(live) : mock == live;
+    }
+    $.each(mock, function(k) {
+      if ( live[k] === undefined ) {
+        identical = false;
+        return identical;
+      } else {
+        if ( typeof live[k] === 'object' && live[k] !== null ) {
+          if ( identical && $.isArray( live[k] ) ) {
+            identical = $.isArray( mock[k] ) && live[k].length === mock[k].length;
+          }
+          identical = identical && isMockDataEqual(mock[k], live[k]);
+        } else {
+          if ( mock[k] && $.isFunction( mock[k].test ) ) {
+            identical = identical && mock[k].test(live[k]);
+          } else {
+            identical = identical && ( mock[k] == live[k] );
+          }
+        }
+      }
+    });
+
+    return identical;
+  }
+
+  // See if a mock handler property matches the default settings
+  function isDefaultSetting(handler, property) {
+    return handler[property] === $.mockjaxSettings[property];
+  }
+
+  // Check the given handler should mock the given request
+  function getMockForRequest( handler, requestSettings ) {
+    // If the mock was registered with a function, let the function decide if we
+    // want to mock this request
+    if ( $.isFunction(handler) ) {
+      return handler( requestSettings );
+    }
+
+    // Inspect the URL of the request and check if the mock handler's url
+    // matches the url for this ajax request
+    if ( $.isFunction(handler.url.test) ) {
+      // The user provided a regex for the url, test it
+      if ( !handler.url.test( requestSettings.url ) ) {
+        return null;
+      }
+    } else {
+      // Look for a simple wildcard '*' or a direct URL match
+      var star = handler.url.indexOf('*');
+      if (handler.url !== requestSettings.url && star === -1 ||
+        !new RegExp(handler.url.replace(/[-[\]{}()+?.,\\^$|#\s]/g, "\\$&").replace(/\*/g, '.+')).test(requestSettings.url)) {
+        return null;
+      }
+    }
+
+    // Inspect the data submitted in the request (either POST body or GET query string)
+    if ( handler.data ) {
+      if ( ! requestSettings.data || !isMockDataEqual(handler.data, requestSettings.data) ) {
+        // They're not identical, do not mock this request
+        return null;
+      }
+    }
+    // Inspect the request type
+    if ( handler && handler.type &&
+      handler.type.toLowerCase() != requestSettings.type.toLowerCase() ) {
+      // The request type doesn't match (GET vs. POST)
+      return null;
+    }
+
+    return handler;
+  }
+
+  function parseResponseTimeOpt(responseTime) {
+    if ($.isArray(responseTime)) {
+      var min = responseTime[0];
+      var max = responseTime[1];
+      return (typeof min === 'number' && typeof max === 'number') ? Math.floor(Math.random() * (max - min)) + min : null;
+    } else {
+      return (typeof responseTime === 'number') ? responseTime: null;
+    }
+  }
+
+  // Process the xhr objects send operation
+  function _xhrSend(mockHandler, requestSettings, origSettings) {
+
+    // This is a substitute for < 1.4 which lacks $.proxy
+    var process = (function(that) {
+      return function() {
+        return (function() {
+          // The request has returned
+          this.status     = mockHandler.status;
+          this.statusText = mockHandler.statusText;
+          this.readyState	= 1;
+
+          var finishRequest = function () {
+            this.readyState	= 4;
+
+            var onReady;
+            // Copy over our mock to our xhr object before passing control back to
+            // jQuery's onreadystatechange callback
+            if ( requestSettings.dataType == 'json' && ( typeof mockHandler.responseText == 'object' ) ) {
+              this.responseText = JSON.stringify(mockHandler.responseText);
+            } else if ( requestSettings.dataType == 'xml' ) {
+              if ( typeof mockHandler.responseXML == 'string' ) {
+                this.responseXML = parseXML(mockHandler.responseXML);
+                //in jQuery 1.9.1+, responseXML is processed differently and relies on responseText
+                this.responseText = mockHandler.responseXML;
+              } else {
+                this.responseXML = mockHandler.responseXML;
+              }
+            } else if (typeof mockHandler.responseText === 'object' && mockHandler.responseText !== null) {
+              // since jQuery 1.9 responseText type has to match contentType
+              mockHandler.contentType = 'application/json';
+              this.responseText = JSON.stringify(mockHandler.responseText);
+            } else {
+              this.responseText = mockHandler.responseText;
+            }
+            if( typeof mockHandler.status == 'number' || typeof mockHandler.status == 'string' ) {
+              this.status = mockHandler.status;
+            }
+            if( typeof mockHandler.statusText === "string") {
+              this.statusText = mockHandler.statusText;
+            }
+            // jQuery 2.0 renamed onreadystatechange to onload
+            onReady = this.onreadystatechange || this.onload;
+
+            // jQuery < 1.4 doesn't have onreadystate change for xhr
+            if ( $.isFunction( onReady ) ) {
+              if( mockHandler.isTimeout) {
+                this.status = -1;
+              }
+              onReady.call( this, mockHandler.isTimeout ? 'timeout' : undefined );
+            } else if ( mockHandler.isTimeout ) {
+              // Fix for 1.3.2 timeout to keep success from firing.
+              this.status = -1;
+            }
+          };
+
+          // We have an executable function, call it to give
+          // the mock handler a chance to update it's data
+          if ( $.isFunction(mockHandler.response) ) {
+            // Wait for it to finish
+            if ( mockHandler.response.length === 2 ) {
+              mockHandler.response(origSettings, function () {
+                finishRequest.call(that);
+              });
+              return;
+            } else {
+              mockHandler.response(origSettings);
+            }
+          }
+
+          finishRequest.call(that);
+        }).apply(that);
+      };
+    })(this);
+
+    if ( mockHandler.proxy ) {
+      // We're proxying this request and loading in an external file instead
+      _ajax({
+        global: false,
+        url: mockHandler.proxy,
+        type: mockHandler.proxyType,
+        data: mockHandler.data,
+        dataType: requestSettings.dataType === "script" ? "text/plain" : requestSettings.dataType,
+        complete: function(xhr) {
+          mockHandler.responseXML = xhr.responseXML;
+          mockHandler.responseText = xhr.responseText;
+          // Don't override the handler status/statusText if it's specified by the config
+          if (isDefaultSetting(mockHandler, 'status')) {
+            mockHandler.status = xhr.status;
+          }
+          if (isDefaultSetting(mockHandler, 'statusText')) {
+            mockHandler.statusText = xhr.statusText;
+          }
+          this.responseTimer = setTimeout(process, parseResponseTimeOpt(mockHandler.responseTime) || 0);
+        }
+      });
+    } else {
+      // type == 'POST' || 'GET' || 'DELETE'
+      if ( requestSettings.async === false ) {
+        // TODO: Blocking delay
+        process();
+      } else {
+        this.responseTimer = setTimeout(process, parseResponseTimeOpt(mockHandler.responseTime) || 50);
+      }
+    }
+  }
+
+  // Construct a mocked XHR Object
+  function xhr(mockHandler, requestSettings, origSettings, origHandler) {
+    // Extend with our default mockjax settings
+    mockHandler = $.extend(true, {}, $.mockjaxSettings, mockHandler);
+
+    if (typeof mockHandler.headers === 'undefined') {
+      mockHandler.headers = {};
+    }
+    if (typeof requestSettings.headers === 'undefined') {
+      requestSettings.headers = {};
+    }
+    if ( mockHandler.contentType ) {
+      mockHandler.headers['content-type'] = mockHandler.contentType;
+    }
+
+    return {
+      status: mockHandler.status,
+      statusText: mockHandler.statusText,
+      readyState: 1,
+      open: function() { },
+      send: function() {
+        origHandler.fired = true;
+        _xhrSend.call(this, mockHandler, requestSettings, origSettings);
+      },
+      abort: function() {
+        clearTimeout(this.responseTimer);
+      },
+      setRequestHeader: function(header, value) {
+        requestSettings.headers[header] = value;
+      },
+      getResponseHeader: function(header) {
+        // 'Last-modified', 'Etag', 'content-type' are all checked by jQuery
+        if ( mockHandler.headers && mockHandler.headers[header] ) {
+          // Return arbitrary headers
+          return mockHandler.headers[header];
+        } else if ( header.toLowerCase() == 'last-modified' ) {
+          return mockHandler.lastModified || (new Date()).toString();
+        } else if ( header.toLowerCase() == 'etag' ) {
+          return mockHandler.etag || '';
+        } else if ( header.toLowerCase() == 'content-type' ) {
+          return mockHandler.contentType || 'text/plain';
+        }
+      },
+      getAllResponseHeaders: function() {
+        var headers = '';
+        // since jQuery 1.9 responseText type has to match contentType
+        if (mockHandler.contentType) {
+          mockHandler.headers['Content-Type'] = mockHandler.contentType;
+        }
+        $.each(mockHandler.headers, function(k, v) {
+          headers += k + ': ' + v + "\n";
+        });
+        return headers;
+      }
+    };
+  }
+
+  // Process a JSONP mock request.
+  function processJsonpMock( requestSettings, mockHandler, origSettings ) {
+    // Handle JSONP Parameter Callbacks, we need to replicate some of the jQuery core here
+    // because there isn't an easy hook for the cross domain script tag of jsonp
+
+    processJsonpUrl( requestSettings );
+
+    requestSettings.dataType = "json";
+    if(requestSettings.data && CALLBACK_REGEX.test(requestSettings.data) || CALLBACK_REGEX.test(requestSettings.url)) {
+      createJsonpCallback(requestSettings, mockHandler, origSettings);
+
+      // We need to make sure
+      // that a JSONP style response is executed properly
+
+      var rurl = /^(\w+:)?\/\/([^\/?#]+)/,
+        parts = rurl.exec( requestSettings.url ),
+        remote = parts && (parts[1] && parts[1] !== location.protocol || parts[2] !== location.host);
+
+      requestSettings.dataType = "script";
+      if(requestSettings.type.toUpperCase() === "GET" && remote ) {
+        var newMockReturn = processJsonpRequest( requestSettings, mockHandler, origSettings );
+
+        // Check if we are supposed to return a Deferred back to the mock call, or just
+        // signal success
+        if(newMockReturn) {
+          return newMockReturn;
+        } else {
+          return true;
+        }
+      }
+    }
+    return null;
+  }
+
+  // Append the required callback parameter to the end of the request URL, for a JSONP request
+  function processJsonpUrl( requestSettings ) {
+    if ( requestSettings.type.toUpperCase() === "GET" ) {
+      if ( !CALLBACK_REGEX.test( requestSettings.url ) ) {
+        requestSettings.url += (/\?/.test( requestSettings.url ) ? "&" : "?") +
+          (requestSettings.jsonp || "callback") + "=?";
+      }
+    } else if ( !requestSettings.data || !CALLBACK_REGEX.test(requestSettings.data) ) {
+      requestSettings.data = (requestSettings.data ? requestSettings.data + "&" : "") + (requestSettings.jsonp || "callback") + "=?";
+    }
+  }
+
+  // Process a JSONP request by evaluating the mocked response text
+  function processJsonpRequest( requestSettings, mockHandler, origSettings ) {
+    // Synthesize the mock request for adding a script tag
+    var callbackContext = origSettings && origSettings.context || requestSettings,
+      newMock = null;
+
+
+    // If the response handler on the moock is a function, call it
+    if ( mockHandler.response && $.isFunction(mockHandler.response) ) {
+      mockHandler.response(origSettings);
+    } else {
+
+      // Evaluate the responseText javascript in a global context
+      if( typeof mockHandler.responseText === 'object' ) {
+        $.globalEval( '(' + JSON.stringify( mockHandler.responseText ) + ')');
+      } else {
+        $.globalEval( '(' + mockHandler.responseText + ')');
+      }
+    }
+
+    // Successful response
+    setTimeout(function() {
+      jsonpSuccess( requestSettings, callbackContext, mockHandler );
+      jsonpComplete( requestSettings, callbackContext, mockHandler );
+    }, parseResponseTimeOpt(mockHandler.responseTime) || 0);
+
+    // If we are running under jQuery 1.5+, return a deferred object
+    if($.Deferred){
+      newMock = new $.Deferred();
+      if(typeof mockHandler.responseText == "object"){
+        newMock.resolveWith( callbackContext, [mockHandler.responseText] );
+      }
+      else{
+        newMock.resolveWith( callbackContext, [$.parseJSON( mockHandler.responseText )] );
+      }
+    }
+    return newMock;
+  }
+
+
+  // Create the required JSONP callback function for the request
+  function createJsonpCallback( requestSettings, mockHandler, origSettings ) {
+    var callbackContext = origSettings && origSettings.context || requestSettings;
+    var jsonp = requestSettings.jsonpCallback || ("jsonp" + jsc++);
+
+    // Replace the =? sequence both in the query string and the data
+    if ( requestSettings.data ) {
+      requestSettings.data = (requestSettings.data + "").replace(CALLBACK_REGEX, "=" + jsonp + "$1");
+    }
+
+    requestSettings.url = requestSettings.url.replace(CALLBACK_REGEX, "=" + jsonp + "$1");
+
+
+    // Handle JSONP-style loading
+    window[ jsonp ] = window[ jsonp ] || function( tmp ) {
+      data = tmp;
+      jsonpSuccess( requestSettings, callbackContext, mockHandler );
+      jsonpComplete( requestSettings, callbackContext, mockHandler );
+      // Garbage collect
+      window[ jsonp ] = undefined;
+
+      try {
+        delete window[ jsonp ];
+      } catch(e) {}
+
+      if ( head ) {
+        head.removeChild( script );
+      }
+    };
+  }
+
+  // The JSONP request was successful
+  function jsonpSuccess(requestSettings, callbackContext, mockHandler) {
+    // If a local callback was specified, fire it and pass it the data
+    if ( requestSettings.success ) {
+      requestSettings.success.call( callbackContext, mockHandler.responseText || "", status, {} );
+    }
+
+    // Fire the global callback
+    if ( requestSettings.global ) {
+      (requestSettings.context ? $(requestSettings.context) : $.event).trigger("ajaxSuccess", [{}, requestSettings]);
+    }
+  }
+
+  // The JSONP request was completed
+  function jsonpComplete(requestSettings, callbackContext) {
+    // Process result
+    if ( requestSettings.complete ) {
+      requestSettings.complete.call( callbackContext, {} , status );
+    }
+
+    // The request was completed
+    if ( requestSettings.global ) {
+      (requestSettings.context ? $(requestSettings.context) : $.event).trigger("ajaxComplete", [{}, requestSettings]);
+    }
+
+    // Handle the global AJAX counter
+    if ( requestSettings.global && ! --$.active ) {
+      $.event.trigger( "ajaxStop" );
+    }
+  }
+
+
+  // The core $.ajax replacement.
+  function handleAjax( url, origSettings ) {
+    var mockRequest, requestSettings, mockHandler, overrideCallback;
+
+    // If url is an object, simulate pre-1.5 signature
+    if ( typeof url === "object" ) {
+      origSettings = url;
+      url = undefined;
+    } else {
+      // work around to support 1.5 signature
+      origSettings = origSettings || {};
+      origSettings.url = url;
+    }
+
+    // Extend the original settings for the request
+    requestSettings = $.extend(true, {}, $.ajaxSettings, origSettings);
+
+    // Generic function to override callback methods for use with
+    // callback options (onAfterSuccess, onAfterError, onAfterComplete)
+    overrideCallback = function(action, mockHandler) {
+      var origHandler = origSettings[action.toLowerCase()];
+      return function() {
+        if ( $.isFunction(origHandler) ) {
+          origHandler.apply(this, [].slice.call(arguments));
+        }
+        mockHandler['onAfter' + action]();
+      };
+    };
+
+    // Iterate over our mock handlers (in registration order) until we find
+    // one that is willing to intercept the request
+    for(var k = 0; k < mockHandlers.length; k++) {
+      if ( !mockHandlers[k] ) {
+        continue;
+      }
+
+      mockHandler = getMockForRequest( mockHandlers[k], requestSettings );
+      if(!mockHandler) {
+        // No valid mock found for this request
+        continue;
+      }
+
+      mockedAjaxCalls.push(requestSettings);
+
+      // If logging is enabled, log the mock to the console
+      $.mockjaxSettings.log( mockHandler, requestSettings );
+
+
+      if ( requestSettings.dataType && requestSettings.dataType.toUpperCase() === 'JSONP' ) {
+        if ((mockRequest = processJsonpMock( requestSettings, mockHandler, origSettings ))) {
+          // This mock will handle the JSONP request
+          return mockRequest;
+        }
+      }
+
+
+      // Removed to fix #54 - keep the mocking data object intact
+      //mockHandler.data = requestSettings.data;
+
+      mockHandler.cache = requestSettings.cache;
+      mockHandler.timeout = requestSettings.timeout;
+      mockHandler.global = requestSettings.global;
+
+      // In the case of a timeout, we just need to ensure
+      // an actual jQuery timeout (That is, our reponse won't)
+      // return faster than the timeout setting.
+      if ( mockHandler.isTimeout ) {
+        if ( mockHandler.responseTime > 1 ) {
+          origSettings.timeout = mockHandler.responseTime - 1;
+        } else {
+          mockHandler.responseTime = 2;
+          origSettings.timeout = 1;
+        }
+        mockHandler.isTimeout = false;
+      }
+
+      // Set up onAfter[X] callback functions
+      if ( $.isFunction( mockHandler.onAfterSuccess ) ) {
+        origSettings.success = overrideCallback('Success', mockHandler);
+      }
+      if ( $.isFunction( mockHandler.onAfterError ) ) {
+        origSettings.error = overrideCallback('Error', mockHandler);
+      }
+      if ( $.isFunction( mockHandler.onAfterComplete ) ) {
+        origSettings.complete = overrideCallback('Complete', mockHandler);
+      }
+
+      copyUrlParameters(mockHandler, origSettings);
+
+      (function(mockHandler, requestSettings, origSettings, origHandler) {
+
+        mockRequest = _ajax.call($, $.extend(true, {}, origSettings, {
+          // Mock the XHR object
+          xhr: function() { return xhr( mockHandler, requestSettings, origSettings, origHandler ); }
+        }));
+      })(mockHandler, requestSettings, origSettings, mockHandlers[k]);
+
+      return mockRequest;
+    }
+
+    // We don't have a mock request
+    unmockedAjaxCalls.push(origSettings);
+    if($.mockjaxSettings.throwUnmocked === true) {
+      throw new Error('AJAX not mocked: ' + origSettings.url);
+    }
+    else { // trigger a normal request
+      return _ajax.apply($, [origSettings]);
+    }
+  }
+
+  /**
+   * Copies URL parameter values if they were captured by a regular expression
+   * @param {Object} mockHandler
+   * @param {Object} origSettings
+   */
+  function copyUrlParameters(mockHandler, origSettings) {
+    //parameters aren't captured if the URL isn't a RegExp
+    if (!(mockHandler.url instanceof RegExp)) {
+      return;
+    }
+    //if no URL params were defined on the handler, don't attempt a capture
+    if (!mockHandler.hasOwnProperty('urlParams')) {
+      return;
+    }
+    var captures = mockHandler.url.exec(origSettings.url);
+    //the whole RegExp match is always the first value in the capture results
+    if (captures.length === 1) {
+      return;
+    }
+    captures.shift();
+    //use handler params as keys and capture resuts as values
+    var i = 0,
+      capturesLength = captures.length,
+      paramsLength = mockHandler.urlParams.length,
+    //in case the number of params specified is less than actual captures
+      maxIterations = Math.min(capturesLength, paramsLength),
+      paramValues = {};
+    for (i; i < maxIterations; i++) {
+      var key = mockHandler.urlParams[i];
+      paramValues[key] = captures[i];
+    }
+    origSettings.urlParams = paramValues;
+  }
+
+
+  // Public
+
+  $.extend({
+    ajax: handleAjax
+  });
+
+  $.mockjaxSettings = {
+    //url:        null,
+    //type:       'GET',
+    log:          function( mockHandler, requestSettings ) {
+      if ( mockHandler.logging === false ||
+        ( typeof mockHandler.logging === 'undefined' && $.mockjaxSettings.logging === false ) ) {
+        return;
+      }
+      if ( window.console && console.log ) {
+        var message = 'MOCK ' + requestSettings.type.toUpperCase() + ': ' + requestSettings.url;
+        var request = $.extend({}, requestSettings);
+
+        if (typeof console.log === 'function') {
+          console.log(message, request);
+        } else {
+          try {
+            console.log( message + ' ' + JSON.stringify(request) );
+          } catch (e) {
+            console.log(message);
+          }
+        }
+      }
+    },
+    logging:       true,
+    status:        200,
+    statusText:    "OK",
+    responseTime:  500,
+    isTimeout:     false,
+    throwUnmocked: false,
+    contentType:   'text/plain',
+    response:      '',
+    responseText:  '',
+    responseXML:   '',
+    proxy:         '',
+    proxyType:     'GET',
+
+    lastModified:  null,
+    etag:          '',
+    headers: {
+      etag: 'IJF@H#@923uf8023hFO@I#H#',
+      'content-type' : 'text/plain'
+    }
+  };
+
+  $.mockjax = function(settings) {
+    var i = mockHandlers.length;
+    mockHandlers[i] = settings;
+    return i;
+  };
+  $.mockjax.clear = function(i) {
+    if ( arguments.length == 1 ) {
+      mockHandlers[i] = null;
+    } else {
+      mockHandlers = [];
+    }
+    mockedAjaxCalls = [];
+    unmockedAjaxCalls = [];
+  };
+  // support older, deprecated version
+  $.mockjaxClear = function(i) {
+    window.console && window.console.warn && window.console.warn( 'DEPRECATED: The $.mockjaxClear() method has been deprecated in 1.6.0. Please use $.mockjax.clear() as the older function will be removed soon!' );
+    $.mockjax.clear();
+  };
+  $.mockjax.handler = function(i) {
+    if ( arguments.length == 1 ) {
+      return mockHandlers[i];
+    }
+  };
+  $.mockjax.mockedAjaxCalls = function() {
+    return mockedAjaxCalls;
+  };
+  $.mockjax.unfiredHandlers = function() {
+    var results = [];
+    for (var i=0, len=mockHandlers.length; i<len; i++) {
+      var handler = mockHandlers[i];
+      if (handler !== null && !handler.fired) {
+        results.push(handler);
+      }
+    }
+    return results;
+  };
+  $.mockjax.unmockedAjaxCalls = function() {
+    return unmockedAjaxCalls;
+  };
+})(jQuery);

文件差異過大導致無法顯示
+ 3 - 0
contrib/views/files/src/main/resources/ui/app/assets/javascripts/modernizr-2.6.2.min.js


+ 2495 - 0
contrib/views/files/src/main/resources/ui/app/assets/javascripts/qunit.js

@@ -0,0 +1,2495 @@
+/*!
+ * QUnit 1.15.0
+ * http://qunitjs.com/
+ *
+ * Copyright 2014 jQuery Foundation and other contributors
+ * Released under the MIT license
+ * http://jquery.org/license
+ *
+ * Date: 2014-08-08T16:00Z
+ */
+
+(function( window ) {
+
+var QUnit,
+	config,
+	onErrorFnPrev,
+	fileName = ( sourceFromStacktrace( 0 ) || "" ).replace( /(:\d+)+\)?/, "" ).replace( /.+\//, "" ),
+	toString = Object.prototype.toString,
+	hasOwn = Object.prototype.hasOwnProperty,
+	// Keep a local reference to Date (GH-283)
+	Date = window.Date,
+	now = Date.now || function() {
+		return new Date().getTime();
+	},
+	setTimeout = window.setTimeout,
+	clearTimeout = window.clearTimeout,
+	defined = {
+		document: typeof window.document !== "undefined",
+		setTimeout: typeof window.setTimeout !== "undefined",
+		sessionStorage: (function() {
+			var x = "qunit-test-string";
+			try {
+				sessionStorage.setItem( x, x );
+				sessionStorage.removeItem( x );
+				return true;
+			} catch ( e ) {
+				return false;
+			}
+		}())
+	},
+	/**
+	 * Provides a normalized error string, correcting an issue
+	 * with IE 7 (and prior) where Error.prototype.toString is
+	 * not properly implemented
+	 *
+	 * Based on http://es5.github.com/#x15.11.4.4
+	 *
+	 * @param {String|Error} error
+	 * @return {String} error message
+	 */
+	errorString = function( error ) {
+		var name, message,
+			errorString = error.toString();
+		if ( errorString.substring( 0, 7 ) === "[object" ) {
+			name = error.name ? error.name.toString() : "Error";
+			message = error.message ? error.message.toString() : "";
+			if ( name && message ) {
+				return name + ": " + message;
+			} else if ( name ) {
+				return name;
+			} else if ( message ) {
+				return message;
+			} else {
+				return "Error";
+			}
+		} else {
+			return errorString;
+		}
+	},
+	/**
+	 * Makes a clone of an object using only Array or Object as base,
+	 * and copies over the own enumerable properties.
+	 *
+	 * @param {Object} obj
+	 * @return {Object} New object with only the own properties (recursively).
+	 */
+	objectValues = function( obj ) {
+		var key, val,
+			vals = QUnit.is( "array", obj ) ? [] : {};
+		for ( key in obj ) {
+			if ( hasOwn.call( obj, key ) ) {
+				val = obj[ key ];
+				vals[ key ] = val === Object( val ) ? objectValues( val ) : val;
+			}
+		}
+		return vals;
+	};
+
+// Root QUnit object.
+// `QUnit` initialized at top of scope
+QUnit = {
+
+	// call on start of module test to prepend name to all tests
+	module: function( name, testEnvironment ) {
+		config.currentModule = name;
+		config.currentModuleTestEnvironment = testEnvironment;
+		config.modules[ name ] = true;
+	},
+
+	asyncTest: function( testName, expected, callback ) {
+		if ( arguments.length === 2 ) {
+			callback = expected;
+			expected = null;
+		}
+
+		QUnit.test( testName, expected, callback, true );
+	},
+
+	test: function( testName, expected, callback, async ) {
+		var test;
+
+		if ( arguments.length === 2 ) {
+			callback = expected;
+			expected = null;
+		}
+
+		test = new Test({
+			testName: testName,
+			expected: expected,
+			async: async,
+			callback: callback,
+			module: config.currentModule,
+			moduleTestEnvironment: config.currentModuleTestEnvironment,
+			stack: sourceFromStacktrace( 2 )
+		});
+
+		if ( !validTest( test ) ) {
+			return;
+		}
+
+		test.queue();
+	},
+
+	start: function( count ) {
+		var message;
+
+		// QUnit hasn't been initialized yet.
+		// Note: RequireJS (et al) may delay onLoad
+		if ( config.semaphore === undefined ) {
+			QUnit.begin(function() {
+				// This is triggered at the top of QUnit.load, push start() to the event loop, to allow QUnit.load to finish first
+				setTimeout(function() {
+					QUnit.start( count );
+				});
+			});
+			return;
+		}
+
+		config.semaphore -= count || 1;
+		// don't start until equal number of stop-calls
+		if ( config.semaphore > 0 ) {
+			return;
+		}
+
+		// Set the starting time when the first test is run
+		QUnit.config.started = QUnit.config.started || now();
+		// ignore if start is called more often then stop
+		if ( config.semaphore < 0 ) {
+			config.semaphore = 0;
+
+			message = "Called start() while already started (QUnit.config.semaphore was 0 already)";
+
+			if ( config.current ) {
+				QUnit.pushFailure( message, sourceFromStacktrace( 2 ) );
+			} else {
+				throw new Error( message );
+			}
+
+			return;
+		}
+		// A slight delay, to avoid any current callbacks
+		if ( defined.setTimeout ) {
+			setTimeout(function() {
+				if ( config.semaphore > 0 ) {
+					return;
+				}
+				if ( config.timeout ) {
+					clearTimeout( config.timeout );
+				}
+
+				config.blocking = false;
+				process( true );
+			}, 13 );
+		} else {
+			config.blocking = false;
+			process( true );
+		}
+	},
+
+	stop: function( count ) {
+		config.semaphore += count || 1;
+		config.blocking = true;
+
+		if ( config.testTimeout && defined.setTimeout ) {
+			clearTimeout( config.timeout );
+			config.timeout = setTimeout(function() {
+				QUnit.ok( false, "Test timed out" );
+				config.semaphore = 1;
+				QUnit.start();
+			}, config.testTimeout );
+		}
+	}
+};
+
+// We use the prototype to distinguish between properties that should
+// be exposed as globals (and in exports) and those that shouldn't
+(function() {
+	function F() {}
+	F.prototype = QUnit;
+	QUnit = new F();
+
+	// Make F QUnit's constructor so that we can add to the prototype later
+	QUnit.constructor = F;
+}());
+
+/**
+ * Config object: Maintain internal state
+ * Later exposed as QUnit.config
+ * `config` initialized at top of scope
+ */
+config = {
+	// The queue of tests to run
+	queue: [],
+
+	// block until document ready
+	blocking: true,
+
+	// when enabled, show only failing tests
+	// gets persisted through sessionStorage and can be changed in UI via checkbox
+	hidepassed: false,
+
+	// by default, run previously failed tests first
+	// very useful in combination with "Hide passed tests" checked
+	reorder: true,
+
+	// by default, modify document.title when suite is done
+	altertitle: true,
+
+	// by default, scroll to top of the page when suite is done
+	scrolltop: true,
+
+	// when enabled, all tests must call expect()
+	requireExpects: false,
+
+	// add checkboxes that are persisted in the query-string
+	// when enabled, the id is set to `true` as a `QUnit.config` property
+	urlConfig: [
+		{
+			id: "noglobals",
+			label: "Check for Globals",
+			tooltip: "Enabling this will test if any test introduces new properties on the `window` object. Stored as query-strings."
+		},
+		{
+			id: "notrycatch",
+			label: "No try-catch",
+			tooltip: "Enabling this will run tests outside of a try-catch block. Makes debugging exceptions in IE reasonable. Stored as query-strings."
+		}
+	],
+
+	// Set of all modules.
+	modules: {},
+
+	callbacks: {}
+};
+
+// Initialize more QUnit.config and QUnit.urlParams
+(function() {
+	var i, current,
+		location = window.location || { search: "", protocol: "file:" },
+		params = location.search.slice( 1 ).split( "&" ),
+		length = params.length,
+		urlParams = {};
+
+	if ( params[ 0 ] ) {
+		for ( i = 0; i < length; i++ ) {
+			current = params[ i ].split( "=" );
+			current[ 0 ] = decodeURIComponent( current[ 0 ] );
+
+			// allow just a key to turn on a flag, e.g., test.html?noglobals
+			current[ 1 ] = current[ 1 ] ? decodeURIComponent( current[ 1 ] ) : true;
+			if ( urlParams[ current[ 0 ] ] ) {
+				urlParams[ current[ 0 ] ] = [].concat( urlParams[ current[ 0 ] ], current[ 1 ] );
+			} else {
+				urlParams[ current[ 0 ] ] = current[ 1 ];
+			}
+		}
+	}
+
+	QUnit.urlParams = urlParams;
+
+	// String search anywhere in moduleName+testName
+	config.filter = urlParams.filter;
+
+	// Exact match of the module name
+	config.module = urlParams.module;
+
+	config.testNumber = [];
+	if ( urlParams.testNumber ) {
+
+		// Ensure that urlParams.testNumber is an array
+		urlParams.testNumber = [].concat( urlParams.testNumber );
+		for ( i = 0; i < urlParams.testNumber.length; i++ ) {
+			current = urlParams.testNumber[ i ];
+			config.testNumber.push( parseInt( current, 10 ) );
+		}
+	}
+
+	// Figure out if we're running the tests from a server or not
+	QUnit.isLocal = location.protocol === "file:";
+}());
+
+extend( QUnit, {
+
+	config: config,
+
+	// Safe object type checking
+	is: function( type, obj ) {
+		return QUnit.objectType( obj ) === type;
+	},
+
+	objectType: function( obj ) {
+		if ( typeof obj === "undefined" ) {
+			return "undefined";
+		}
+
+		// Consider: typeof null === object
+		if ( obj === null ) {
+			return "null";
+		}
+
+		var match = toString.call( obj ).match( /^\[object\s(.*)\]$/ ),
+			type = match && match[ 1 ] || "";
+
+		switch ( type ) {
+			case "Number":
+				if ( isNaN( obj ) ) {
+					return "nan";
+				}
+				return "number";
+			case "String":
+			case "Boolean":
+			case "Array":
+			case "Date":
+			case "RegExp":
+			case "Function":
+				return type.toLowerCase();
+		}
+		if ( typeof obj === "object" ) {
+			return "object";
+		}
+		return undefined;
+	},
+
+	url: function( params ) {
+		params = extend( extend( {}, QUnit.urlParams ), params );
+		var key,
+			querystring = "?";
+
+		for ( key in params ) {
+			if ( hasOwn.call( params, key ) ) {
+				querystring += encodeURIComponent( key ) + "=" +
+					encodeURIComponent( params[ key ] ) + "&";
+			}
+		}
+		return window.location.protocol + "//" + window.location.host +
+			window.location.pathname + querystring.slice( 0, -1 );
+	},
+
+	extend: extend
+});
+
+/**
+ * @deprecated: Created for backwards compatibility with test runner that set the hook function
+ * into QUnit.{hook}, instead of invoking it and passing the hook function.
+ * QUnit.constructor is set to the empty F() above so that we can add to it's prototype here.
+ * Doing this allows us to tell if the following methods have been overwritten on the actual
+ * QUnit object.
+ */
+extend( QUnit.constructor.prototype, {
+
+	// Logging callbacks; all receive a single argument with the listed properties
+	// run test/logs.html for any related changes
+	begin: registerLoggingCallback( "begin" ),
+
+	// done: { failed, passed, total, runtime }
+	done: registerLoggingCallback( "done" ),
+
+	// log: { result, actual, expected, message }
+	log: registerLoggingCallback( "log" ),
+
+	// testStart: { name }
+	testStart: registerLoggingCallback( "testStart" ),
+
+	// testDone: { name, failed, passed, total, runtime }
+	testDone: registerLoggingCallback( "testDone" ),
+
+	// moduleStart: { name }
+	moduleStart: registerLoggingCallback( "moduleStart" ),
+
+	// moduleDone: { name, failed, passed, total }
+	moduleDone: registerLoggingCallback( "moduleDone" )
+});
+
+QUnit.load = function() {
+	runLoggingCallbacks( "begin", {
+		totalTests: Test.count
+	});
+
+	// Initialize the configuration options
+	extend( config, {
+		stats: { all: 0, bad: 0 },
+		moduleStats: { all: 0, bad: 0 },
+		started: 0,
+		updateRate: 1000,
+		autostart: true,
+		filter: "",
+		semaphore: 1
+	}, true );
+
+	config.blocking = false;
+
+	if ( config.autostart ) {
+		QUnit.start();
+	}
+};
+
+// `onErrorFnPrev` initialized at top of scope
+// Preserve other handlers
+onErrorFnPrev = window.onerror;
+
+// Cover uncaught exceptions
+// Returning true will suppress the default browser handler,
+// returning false will let it run.
+window.onerror = function( error, filePath, linerNr ) {
+	var ret = false;
+	if ( onErrorFnPrev ) {
+		ret = onErrorFnPrev( error, filePath, linerNr );
+	}
+
+	// Treat return value as window.onerror itself does,
+	// Only do our handling if not suppressed.
+	if ( ret !== true ) {
+		if ( QUnit.config.current ) {
+			if ( QUnit.config.current.ignoreGlobalErrors ) {
+				return true;
+			}
+			QUnit.pushFailure( error, filePath + ":" + linerNr );
+		} else {
+			QUnit.test( "global failure", extend(function() {
+				QUnit.pushFailure( error, filePath + ":" + linerNr );
+			}, { validTest: validTest } ) );
+		}
+		return false;
+	}
+
+	return ret;
+};
+
+function done() {
+	config.autorun = true;
+
+	// Log the last module results
+	if ( config.previousModule ) {
+		runLoggingCallbacks( "moduleDone", {
+			name: config.previousModule,
+			failed: config.moduleStats.bad,
+			passed: config.moduleStats.all - config.moduleStats.bad,
+			total: config.moduleStats.all
+		});
+	}
+	delete config.previousModule;
+
+	var runtime = now() - config.started,
+		passed = config.stats.all - config.stats.bad;
+
+	runLoggingCallbacks( "done", {
+		failed: config.stats.bad,
+		passed: passed,
+		total: config.stats.all,
+		runtime: runtime
+	});
+}
+
+/** @return Boolean: true if this test should be ran */
+function validTest( test ) {
+	var include,
+		filter = config.filter && config.filter.toLowerCase(),
+		module = config.module && config.module.toLowerCase(),
+		fullName = ( test.module + ": " + test.testName ).toLowerCase();
+
+	// Internally-generated tests are always valid
+	if ( test.callback && test.callback.validTest === validTest ) {
+		delete test.callback.validTest;
+		return true;
+	}
+
+	if ( config.testNumber.length > 0 ) {
+		if ( inArray( test.testNumber, config.testNumber ) < 0 ) {
+			return false;
+		}
+	}
+
+	if ( module && ( !test.module || test.module.toLowerCase() !== module ) ) {
+		return false;
+	}
+
+	if ( !filter ) {
+		return true;
+	}
+
+	include = filter.charAt( 0 ) !== "!";
+	if ( !include ) {
+		filter = filter.slice( 1 );
+	}
+
+	// If the filter matches, we need to honour include
+	if ( fullName.indexOf( filter ) !== -1 ) {
+		return include;
+	}
+
+	// Otherwise, do the opposite
+	return !include;
+}
+
+// Doesn't support IE6 to IE9
+// See also https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error/Stack
+function extractStacktrace( e, offset ) {
+	offset = offset === undefined ? 4 : offset;
+
+	var stack, include, i;
+
+	if ( e.stacktrace ) {
+
+		// Opera 12.x
+		return e.stacktrace.split( "\n" )[ offset + 3 ];
+	} else if ( e.stack ) {
+
+		// Firefox, Chrome, Safari 6+, IE10+, PhantomJS and Node
+		stack = e.stack.split( "\n" );
+		if ( /^error$/i.test( stack[ 0 ] ) ) {
+			stack.shift();
+		}
+		if ( fileName ) {
+			include = [];
+			for ( i = offset; i < stack.length; i++ ) {
+				if ( stack[ i ].indexOf( fileName ) !== -1 ) {
+					break;
+				}
+				include.push( stack[ i ] );
+			}
+			if ( include.length ) {
+				return include.join( "\n" );
+			}
+		}
+		return stack[ offset ];
+	} else if ( e.sourceURL ) {
+
+		// Safari < 6
+		// exclude useless self-reference for generated Error objects
+		if ( /qunit.js$/.test( e.sourceURL ) ) {
+			return;
+		}
+
+		// for actual exceptions, this is useful
+		return e.sourceURL + ":" + e.line;
+	}
+}
+function sourceFromStacktrace( offset ) {
+	try {
+		throw new Error();
+	} catch ( e ) {
+		return extractStacktrace( e, offset );
+	}
+}
+
+function synchronize( callback, last ) {
+	config.queue.push( callback );
+
+	if ( config.autorun && !config.blocking ) {
+		process( last );
+	}
+}
+
+function process( last ) {
+	function next() {
+		process( last );
+	}
+	var start = now();
+	config.depth = config.depth ? config.depth + 1 : 1;
+
+	while ( config.queue.length && !config.blocking ) {
+		if ( !defined.setTimeout || config.updateRate <= 0 || ( ( now() - start ) < config.updateRate ) ) {
+			config.queue.shift()();
+		} else {
+			setTimeout( next, 13 );
+			break;
+		}
+	}
+	config.depth--;
+	if ( last && !config.blocking && !config.queue.length && config.depth === 0 ) {
+		done();
+	}
+}
+
+function saveGlobal() {
+	config.pollution = [];
+
+	if ( config.noglobals ) {
+		for ( var key in window ) {
+			if ( hasOwn.call( window, key ) ) {
+				// in Opera sometimes DOM element ids show up here, ignore them
+				if ( /^qunit-test-output/.test( key ) ) {
+					continue;
+				}
+				config.pollution.push( key );
+			}
+		}
+	}
+}
+
+function checkPollution() {
+	var newGlobals,
+		deletedGlobals,
+		old = config.pollution;
+
+	saveGlobal();
+
+	newGlobals = diff( config.pollution, old );
+	if ( newGlobals.length > 0 ) {
+		QUnit.pushFailure( "Introduced global variable(s): " + newGlobals.join( ", " ) );
+	}
+
+	deletedGlobals = diff( old, config.pollution );
+	if ( deletedGlobals.length > 0 ) {
+		QUnit.pushFailure( "Deleted global variable(s): " + deletedGlobals.join( ", " ) );
+	}
+}
+
+// returns a new Array with the elements that are in a but not in b
+function diff( a, b ) {
+	var i, j,
+		result = a.slice();
+
+	for ( i = 0; i < result.length; i++ ) {
+		for ( j = 0; j < b.length; j++ ) {
+			if ( result[ i ] === b[ j ] ) {
+				result.splice( i, 1 );
+				i--;
+				break;
+			}
+		}
+	}
+	return result;
+}
+
+function extend( a, b, undefOnly ) {
+	for ( var prop in b ) {
+		if ( hasOwn.call( b, prop ) ) {
+
+			// Avoid "Member not found" error in IE8 caused by messing with window.constructor
+			if ( !( prop === "constructor" && a === window ) ) {
+				if ( b[ prop ] === undefined ) {
+					delete a[ prop ];
+				} else if ( !( undefOnly && typeof a[ prop ] !== "undefined" ) ) {
+					a[ prop ] = b[ prop ];
+				}
+			}
+		}
+	}
+
+	return a;
+}
+
+function registerLoggingCallback( key ) {
+
+	// Initialize key collection of logging callback
+	if ( QUnit.objectType( config.callbacks[ key ] ) === "undefined" ) {
+		config.callbacks[ key ] = [];
+	}
+
+	return function( callback ) {
+		config.callbacks[ key ].push( callback );
+	};
+}
+
+function runLoggingCallbacks( key, args ) {
+	var i, l, callbacks;
+
+	callbacks = config.callbacks[ key ];
+	for ( i = 0, l = callbacks.length; i < l; i++ ) {
+		callbacks[ i ]( args );
+	}
+}
+
+// from jquery.js
+function inArray( elem, array ) {
+	if ( array.indexOf ) {
+		return array.indexOf( elem );
+	}
+
+	for ( var i = 0, length = array.length; i < length; i++ ) {
+		if ( array[ i ] === elem ) {
+			return i;
+		}
+	}
+
+	return -1;
+}
+
+function Test( settings ) {
+	extend( this, settings );
+	this.assert = new Assert( this );
+	this.assertions = [];
+	this.testNumber = ++Test.count;
+}
+
+Test.count = 0;
+
+Test.prototype = {
+	setup: function() {
+		if (
+
+			// Emit moduleStart when we're switching from one module to another
+			this.module !== config.previousModule ||
+
+				// They could be equal (both undefined) but if the previousModule property doesn't
+				// yet exist it means this is the first test in a suite that isn't wrapped in a
+				// module, in which case we'll just emit a moduleStart event for 'undefined'.
+				// Without this, reporters can get testStart before moduleStart  which is a problem.
+				!hasOwn.call( config, "previousModule" )
+		) {
+			if ( hasOwn.call( config, "previousModule" ) ) {
+				runLoggingCallbacks( "moduleDone", {
+					name: config.previousModule,
+					failed: config.moduleStats.bad,
+					passed: config.moduleStats.all - config.moduleStats.bad,
+					total: config.moduleStats.all
+				});
+			}
+			config.previousModule = this.module;
+			config.moduleStats = { all: 0, bad: 0 };
+			runLoggingCallbacks( "moduleStart", {
+				name: this.module
+			});
+		}
+
+		config.current = this;
+
+		this.testEnvironment = extend({
+			setup: function() {},
+			teardown: function() {}
+		}, this.moduleTestEnvironment );
+
+		this.started = now();
+		runLoggingCallbacks( "testStart", {
+			name: this.testName,
+			module: this.module,
+			testNumber: this.testNumber
+		});
+
+		if ( !config.pollution ) {
+			saveGlobal();
+		}
+		if ( config.notrycatch ) {
+			this.testEnvironment.setup.call( this.testEnvironment, this.assert );
+			return;
+		}
+		try {
+			this.testEnvironment.setup.call( this.testEnvironment, this.assert );
+		} catch ( e ) {
+			this.pushFailure( "Setup failed on " + this.testName + ": " + ( e.message || e ), extractStacktrace( e, 0 ) );
+		}
+	},
+	run: function() {
+		config.current = this;
+
+		if ( this.async ) {
+			QUnit.stop();
+		}
+
+		this.callbackStarted = now();
+
+		if ( config.notrycatch ) {
+			this.callback.call( this.testEnvironment, this.assert );
+			this.callbackRuntime = now() - this.callbackStarted;
+			return;
+		}
+
+		try {
+			this.callback.call( this.testEnvironment, this.assert );
+			this.callbackRuntime = now() - this.callbackStarted;
+		} catch ( e ) {
+			this.callbackRuntime = now() - this.callbackStarted;
+
+			this.pushFailure( "Died on test #" + ( this.assertions.length + 1 ) + " " + this.stack + ": " + ( e.message || e ), extractStacktrace( e, 0 ) );
+
+			// else next test will carry the responsibility
+			saveGlobal();
+
+			// Restart the tests if they're blocking
+			if ( config.blocking ) {
+				QUnit.start();
+			}
+		}
+	},
+	teardown: function() {
+		config.current = this;
+		if ( config.notrycatch ) {
+			if ( typeof this.callbackRuntime === "undefined" ) {
+				this.callbackRuntime = now() - this.callbackStarted;
+			}
+			this.testEnvironment.teardown.call( this.testEnvironment, this.assert );
+			return;
+		} else {
+			try {
+				this.testEnvironment.teardown.call( this.testEnvironment, this.assert );
+			} catch ( e ) {
+				this.pushFailure( "Teardown failed on " + this.testName + ": " + ( e.message || e ), extractStacktrace( e, 0 ) );
+			}
+		}
+		checkPollution();
+	},
+	finish: function() {
+		config.current = this;
+		if ( config.requireExpects && this.expected === null ) {
+			this.pushFailure( "Expected number of assertions to be defined, but expect() was not called.", this.stack );
+		} else if ( this.expected !== null && this.expected !== this.assertions.length ) {
+			this.pushFailure( "Expected " + this.expected + " assertions, but " + this.assertions.length + " were run", this.stack );
+		} else if ( this.expected === null && !this.assertions.length ) {
+			this.pushFailure( "Expected at least one assertion, but none were run - call expect(0) to accept zero assertions.", this.stack );
+		}
+
+		var i,
+			bad = 0;
+
+		this.runtime = now() - this.started;
+		config.stats.all += this.assertions.length;
+		config.moduleStats.all += this.assertions.length;
+
+		for ( i = 0; i < this.assertions.length; i++ ) {
+			if ( !this.assertions[ i ].result ) {
+				bad++;
+				config.stats.bad++;
+				config.moduleStats.bad++;
+			}
+		}
+
+		runLoggingCallbacks( "testDone", {
+			name: this.testName,
+			module: this.module,
+			failed: bad,
+			passed: this.assertions.length - bad,
+			total: this.assertions.length,
+			runtime: this.runtime,
+
+			// HTML Reporter use
+			assertions: this.assertions,
+			testNumber: this.testNumber,
+
+			// DEPRECATED: this property will be removed in 2.0.0, use runtime instead
+			duration: this.runtime
+		});
+
+		config.current = undefined;
+	},
+
+	queue: function() {
+		var bad,
+			test = this;
+
+		function run() {
+			// each of these can by async
+			synchronize(function() {
+				test.setup();
+			});
+			synchronize(function() {
+				test.run();
+			});
+			synchronize(function() {
+				test.teardown();
+			});
+			synchronize(function() {
+				test.finish();
+			});
+		}
+
+		// `bad` initialized at top of scope
+		// defer when previous test run passed, if storage is available
+		bad = QUnit.config.reorder && defined.sessionStorage &&
+				+sessionStorage.getItem( "qunit-test-" + this.module + "-" + this.testName );
+
+		if ( bad ) {
+			run();
+		} else {
+			synchronize( run, true );
+		}
+	},
+
+	push: function( result, actual, expected, message ) {
+		var source,
+			details = {
+				module: this.module,
+				name: this.testName,
+				result: result,
+				message: message,
+				actual: actual,
+				expected: expected,
+				testNumber: this.testNumber
+			};
+
+		if ( !result ) {
+			source = sourceFromStacktrace();
+
+			if ( source ) {
+				details.source = source;
+			}
+		}
+
+		runLoggingCallbacks( "log", details );
+
+		this.assertions.push({
+			result: !!result,
+			message: message
+		});
+	},
+
+	pushFailure: function( message, source, actual ) {
+		if ( !this instanceof Test ) {
+			throw new Error( "pushFailure() assertion outside test context, was " + sourceFromStacktrace( 2 ) );
+		}
+
+		var details = {
+				module: this.module,
+				name: this.testName,
+				result: false,
+				message: message || "error",
+				actual: actual || null,
+				testNumber: this.testNumber
+			};
+
+		if ( source ) {
+			details.source = source;
+		}
+
+		runLoggingCallbacks( "log", details );
+
+		this.assertions.push({
+			result: false,
+			message: message
+		});
+	}
+};
+
+QUnit.pushFailure = function() {
+	if ( !QUnit.config.current ) {
+		throw new Error( "pushFailure() assertion outside test context, in " + sourceFromStacktrace( 2 ) );
+	}
+
+	// Gets current test obj
+	var currentTest = QUnit.config.current.assert.test;
+
+	return currentTest.pushFailure.apply( currentTest, arguments );
+};
+
+function Assert( testContext ) {
+	this.test = testContext;
+}
+
+// Assert helpers
+QUnit.assert = Assert.prototype = {
+
+	// Specify the number of expected assertions to guarantee that failed test (no assertions are run at all) don't slip through.
+	expect: function( asserts ) {
+		if ( arguments.length === 1 ) {
+			this.test.expected = asserts;
+		} else {
+			return this.test.expected;
+		}
+	},
+
+	// Exports test.push() to the user API
+	push: function() {
+		var assert = this;
+
+		// Backwards compatibility fix.
+		// Allows the direct use of global exported assertions and QUnit.assert.*
+		// Although, it's use is not recommended as it can leak assertions
+		// to other tests from async tests, because we only get a reference to the current test,
+		// not exactly the test where assertion were intended to be called.
+		if ( !QUnit.config.current ) {
+			throw new Error( "assertion outside test context, in " + sourceFromStacktrace( 2 ) );
+		}
+		if ( !( assert instanceof Assert ) ) {
+			assert = QUnit.config.current.assert;
+		}
+		return assert.test.push.apply( assert.test, arguments );
+	},
+
+	/**
+	 * Asserts rough true-ish result.
+	 * @name ok
+	 * @function
+	 * @example ok( "asdfasdf".length > 5, "There must be at least 5 chars" );
+	 */
+	ok: function( result, message ) {
+		message = message || ( result ? "okay" : "failed, expected argument to be truthy, was: " +
+			QUnit.dump.parse( result ) );
+		if ( !!result ) {
+			this.push( true, result, true, message );
+		} else {
+			this.test.pushFailure( message, null, result );
+		}
+	},
+
+	/**
+	 * Assert that the first two arguments are equal, with an optional message.
+	 * Prints out both actual and expected values.
+	 * @name equal
+	 * @function
+	 * @example equal( format( "Received {0} bytes.", 2), "Received 2 bytes.", "format() replaces {0} with next argument" );
+	 */
+	equal: function( actual, expected, message ) {
+		/*jshint eqeqeq:false */
+		this.push( expected == actual, actual, expected, message );
+	},
+
+	/**
+	 * @name notEqual
+	 * @function
+	 */
+	notEqual: function( actual, expected, message ) {
+		/*jshint eqeqeq:false */
+		this.push( expected != actual, actual, expected, message );
+	},
+
+	/**
+	 * @name propEqual
+	 * @function
+	 */
+	propEqual: function( actual, expected, message ) {
+		actual = objectValues( actual );
+		expected = objectValues( expected );
+		this.push( QUnit.equiv( actual, expected ), actual, expected, message );
+	},
+
+	/**
+	 * @name notPropEqual
+	 * @function
+	 */
+	notPropEqual: function( actual, expected, message ) {
+		actual = objectValues( actual );
+		expected = objectValues( expected );
+		this.push( !QUnit.equiv( actual, expected ), actual, expected, message );
+	},
+
+	/**
+	 * @name deepEqual
+	 * @function
+	 */
+	deepEqual: function( actual, expected, message ) {
+		this.push( QUnit.equiv( actual, expected ), actual, expected, message );
+	},
+
+	/**
+	 * @name notDeepEqual
+	 * @function
+	 */
+	notDeepEqual: function( actual, expected, message ) {
+		this.push( !QUnit.equiv( actual, expected ), actual, expected, message );
+	},
+
+	/**
+	 * @name strictEqual
+	 * @function
+	 */
+	strictEqual: function( actual, expected, message ) {
+		this.push( expected === actual, actual, expected, message );
+	},
+
+	/**
+	 * @name notStrictEqual
+	 * @function
+	 */
+	notStrictEqual: function( actual, expected, message ) {
+		this.push( expected !== actual, actual, expected, message );
+	},
+
+	"throws": function( block, expected, message ) {
+		var actual, expectedType,
+			expectedOutput = expected,
+			ok = false;
+
+		// 'expected' is optional unless doing string comparison
+		if ( message == null && typeof expected === "string" ) {
+			message = expected;
+			expected = null;
+		}
+
+		this.test.ignoreGlobalErrors = true;
+		try {
+			block.call( this.test.testEnvironment );
+		} catch (e) {
+			actual = e;
+		}
+		this.test.ignoreGlobalErrors = false;
+
+		if ( actual ) {
+			expectedType = QUnit.objectType( expected );
+
+			// we don't want to validate thrown error
+			if ( !expected ) {
+				ok = true;
+				expectedOutput = null;
+
+			// expected is a regexp
+			} else if ( expectedType === "regexp" ) {
+				ok = expected.test( errorString( actual ) );
+
+			// expected is a string
+			} else if ( expectedType === "string" ) {
+				ok = expected === errorString( actual );
+
+			// expected is a constructor, maybe an Error constructor
+			} else if ( expectedType === "function" && actual instanceof expected ) {
+				ok = true;
+
+			// expected is an Error object
+			} else if ( expectedType === "object" ) {
+				ok = actual instanceof expected.constructor &&
+					actual.name === expected.name &&
+					actual.message === expected.message;
+
+			// expected is a validation function which returns true if validation passed
+			} else if ( expectedType === "function" && expected.call( {}, actual ) === true ) {
+				expectedOutput = null;
+				ok = true;
+			}
+
+			this.push( ok, actual, expectedOutput, message );
+		} else {
+			this.test.pushFailure( message, null, "No exception was thrown." );
+		}
+	}
+};
+
+// Test for equality any JavaScript type.
+// Author: Philippe Rathé <prathe@gmail.com>
+QUnit.equiv = (function() {
+
+	// Call the o related callback with the given arguments.
+	function bindCallbacks( o, callbacks, args ) {
+		var prop = QUnit.objectType( o );
+		if ( prop ) {
+			if ( QUnit.objectType( callbacks[ prop ] ) === "function" ) {
+				return callbacks[ prop ].apply( callbacks, args );
+			} else {
+				return callbacks[ prop ]; // or undefined
+			}
+		}
+	}
+
+	// the real equiv function
+	var innerEquiv,
+
+		// stack to decide between skip/abort functions
+		callers = [],
+
+		// stack to avoiding loops from circular referencing
+		parents = [],
+		parentsB = [],
+
+		getProto = Object.getPrototypeOf || function( obj ) {
+			/* jshint camelcase: false, proto: true */
+			return obj.__proto__;
+		},
+		callbacks = (function() {
+
+			// for string, boolean, number and null
+			function useStrictEquality( b, a ) {
+
+				/*jshint eqeqeq:false */
+				if ( b instanceof a.constructor || a instanceof b.constructor ) {
+
+					// to catch short annotation VS 'new' annotation of a
+					// declaration
+					// e.g. var i = 1;
+					// var j = new Number(1);
+					return a == b;
+				} else {
+					return a === b;
+				}
+			}
+
+			return {
+				"string": useStrictEquality,
+				"boolean": useStrictEquality,
+				"number": useStrictEquality,
+				"null": useStrictEquality,
+				"undefined": useStrictEquality,
+
+				"nan": function( b ) {
+					return isNaN( b );
+				},
+
+				"date": function( b, a ) {
+					return QUnit.objectType( b ) === "date" && a.valueOf() === b.valueOf();
+				},
+
+				"regexp": function( b, a ) {
+					return QUnit.objectType( b ) === "regexp" &&
+
+						// the regex itself
+						a.source === b.source &&
+
+						// and its modifiers
+						a.global === b.global &&
+
+						// (gmi) ...
+						a.ignoreCase === b.ignoreCase &&
+						a.multiline === b.multiline &&
+						a.sticky === b.sticky;
+				},
+
+				// - skip when the property is a method of an instance (OOP)
+				// - abort otherwise,
+				// initial === would have catch identical references anyway
+				"function": function() {
+					var caller = callers[ callers.length - 1 ];
+					return caller !== Object && typeof caller !== "undefined";
+				},
+
+				"array": function( b, a ) {
+					var i, j, len, loop, aCircular, bCircular;
+
+					// b could be an object literal here
+					if ( QUnit.objectType( b ) !== "array" ) {
+						return false;
+					}
+
+					len = a.length;
+					if ( len !== b.length ) {
+						// safe and faster
+						return false;
+					}
+
+					// track reference to avoid circular references
+					parents.push( a );
+					parentsB.push( b );
+					for ( i = 0; i < len; i++ ) {
+						loop = false;
+						for ( j = 0; j < parents.length; j++ ) {
+							aCircular = parents[ j ] === a[ i ];
+							bCircular = parentsB[ j ] === b[ i ];
+							if ( aCircular || bCircular ) {
+								if ( a[ i ] === b[ i ] || aCircular && bCircular ) {
+									loop = true;
+								} else {
+									parents.pop();
+									parentsB.pop();
+									return false;
+								}
+							}
+						}
+						if ( !loop && !innerEquiv( a[ i ], b[ i ] ) ) {
+							parents.pop();
+							parentsB.pop();
+							return false;
+						}
+					}
+					parents.pop();
+					parentsB.pop();
+					return true;
+				},
+
+				"object": function( b, a ) {
+
+					/*jshint forin:false */
+					var i, j, loop, aCircular, bCircular,
+						// Default to true
+						eq = true,
+						aProperties = [],
+						bProperties = [];
+
+					// comparing constructors is more strict than using
+					// instanceof
+					if ( a.constructor !== b.constructor ) {
+
+						// Allow objects with no prototype to be equivalent to
+						// objects with Object as their constructor.
+						if ( !( ( getProto( a ) === null && getProto( b ) === Object.prototype ) ||
+							( getProto( b ) === null && getProto( a ) === Object.prototype ) ) ) {
+							return false;
+						}
+					}
+
+					// stack constructor before traversing properties
+					callers.push( a.constructor );
+
+					// track reference to avoid circular references
+					parents.push( a );
+					parentsB.push( b );
+
+					// be strict: don't ensure hasOwnProperty and go deep
+					for ( i in a ) {
+						loop = false;
+						for ( j = 0; j < parents.length; j++ ) {
+							aCircular = parents[ j ] === a[ i ];
+							bCircular = parentsB[ j ] === b[ i ];
+							if ( aCircular || bCircular ) {
+								if ( a[ i ] === b[ i ] || aCircular && bCircular ) {
+									loop = true;
+								} else {
+									eq = false;
+									break;
+								}
+							}
+						}
+						aProperties.push( i );
+						if ( !loop && !innerEquiv( a[ i ], b[ i ] ) ) {
+							eq = false;
+							break;
+						}
+					}
+
+					parents.pop();
+					parentsB.pop();
+					callers.pop(); // unstack, we are done
+
+					for ( i in b ) {
+						bProperties.push( i ); // collect b's properties
+					}
+
+					// Ensures identical properties name
+					return eq && innerEquiv( aProperties.sort(), bProperties.sort() );
+				}
+			};
+		}());
+
+	innerEquiv = function() { // can take multiple arguments
+		var args = [].slice.apply( arguments );
+		if ( args.length < 2 ) {
+			return true; // end transition
+		}
+
+		return ( (function( a, b ) {
+			if ( a === b ) {
+				return true; // catch the most you can
+			} else if ( a === null || b === null || typeof a === "undefined" ||
+					typeof b === "undefined" ||
+					QUnit.objectType( a ) !== QUnit.objectType( b ) ) {
+
+				// don't lose time with error prone cases
+				return false;
+			} else {
+				return bindCallbacks( a, callbacks, [ b, a ] );
+			}
+
+			// apply transition with (1..n) arguments
+		}( args[ 0 ], args[ 1 ] ) ) && innerEquiv.apply( this, args.splice( 1, args.length - 1 ) ) );
+	};
+
+	return innerEquiv;
+}());
+
+// Based on jsDump by Ariel Flesler
+// http://flesler.blogspot.com/2008/05/jsdump-pretty-dump-of-any-javascript.html
+QUnit.dump = (function() {
+	function quote( str ) {
+		return "\"" + str.toString().replace( /"/g, "\\\"" ) + "\"";
+	}
+	function literal( o ) {
+		return o + "";
+	}
+	function join( pre, arr, post ) {
+		var s = dump.separator(),
+			base = dump.indent(),
+			inner = dump.indent( 1 );
+		if ( arr.join ) {
+			arr = arr.join( "," + s + inner );
+		}
+		if ( !arr ) {
+			return pre + post;
+		}
+		return [ pre, inner + arr, base + post ].join( s );
+	}
+	function array( arr, stack ) {
+		var i = arr.length,
+			ret = new Array( i );
+		this.up();
+		while ( i-- ) {
+			ret[ i ] = this.parse( arr[ i ], undefined, stack );
+		}
+		this.down();
+		return join( "[", ret, "]" );
+	}
+
+	var reName = /^function (\w+)/,
+		dump = {
+			// type is used mostly internally, you can fix a (custom)type in advance
+			parse: function( obj, type, stack ) {
+				stack = stack || [];
+				var inStack, res,
+					parser = this.parsers[ type || this.typeOf( obj ) ];
+
+				type = typeof parser;
+				inStack = inArray( obj, stack );
+
+				if ( inStack !== -1 ) {
+					return "recursion(" + ( inStack - stack.length ) + ")";
+				}
+				if ( type === "function" ) {
+					stack.push( obj );
+					res = parser.call( this, obj, stack );
+					stack.pop();
+					return res;
+				}
+				return ( type === "string" ) ? parser : this.parsers.error;
+			},
+			typeOf: function( obj ) {
+				var type;
+				if ( obj === null ) {
+					type = "null";
+				} else if ( typeof obj === "undefined" ) {
+					type = "undefined";
+				} else if ( QUnit.is( "regexp", obj ) ) {
+					type = "regexp";
+				} else if ( QUnit.is( "date", obj ) ) {
+					type = "date";
+				} else if ( QUnit.is( "function", obj ) ) {
+					type = "function";
+				} else if ( typeof obj.setInterval !== undefined && typeof obj.document !== "undefined" && typeof obj.nodeType === "undefined" ) {
+					type = "window";
+				} else if ( obj.nodeType === 9 ) {
+					type = "document";
+				} else if ( obj.nodeType ) {
+					type = "node";
+				} else if (
+
+					// native arrays
+					toString.call( obj ) === "[object Array]" ||
+
+					// NodeList objects
+					( typeof obj.length === "number" && typeof obj.item !== "undefined" && ( obj.length ? obj.item( 0 ) === obj[ 0 ] : ( obj.item( 0 ) === null && typeof obj[ 0 ] === "undefined" ) ) )
+				) {
+					type = "array";
+				} else if ( obj.constructor === Error.prototype.constructor ) {
+					type = "error";
+				} else {
+					type = typeof obj;
+				}
+				return type;
+			},
+			separator: function() {
+				return this.multiline ? this.HTML ? "<br />" : "\n" : this.HTML ? "&nbsp;" : " ";
+			},
+			// extra can be a number, shortcut for increasing-calling-decreasing
+			indent: function( extra ) {
+				if ( !this.multiline ) {
+					return "";
+				}
+				var chr = this.indentChar;
+				if ( this.HTML ) {
+					chr = chr.replace( /\t/g, "   " ).replace( / /g, "&nbsp;" );
+				}
+				return new Array( this.depth + ( extra || 0 ) ).join( chr );
+			},
+			up: function( a ) {
+				this.depth += a || 1;
+			},
+			down: function( a ) {
+				this.depth -= a || 1;
+			},
+			setParser: function( name, parser ) {
+				this.parsers[ name ] = parser;
+			},
+			// The next 3 are exposed so you can use them
+			quote: quote,
+			literal: literal,
+			join: join,
+			//
+			depth: 1,
+			// This is the list of parsers, to modify them, use dump.setParser
+			parsers: {
+				window: "[Window]",
+				document: "[Document]",
+				error: function( error ) {
+					return "Error(\"" + error.message + "\")";
+				},
+				unknown: "[Unknown]",
+				"null": "null",
+				"undefined": "undefined",
+				"function": function( fn ) {
+					var ret = "function",
+						// functions never have name in IE
+						name = "name" in fn ? fn.name : ( reName.exec( fn ) || [] )[ 1 ];
+
+					if ( name ) {
+						ret += " " + name;
+					}
+					ret += "( ";
+
+					ret = [ ret, dump.parse( fn, "functionArgs" ), "){" ].join( "" );
+					return join( ret, dump.parse( fn, "functionCode" ), "}" );
+				},
+				array: array,
+				nodelist: array,
+				"arguments": array,
+				object: function( map, stack ) {
+					/*jshint forin:false */
+					var ret = [], keys, key, val, i, nonEnumerableProperties;
+					dump.up();
+					keys = [];
+					for ( key in map ) {
+						keys.push( key );
+					}
+
+					// Some properties are not always enumerable on Error objects.
+					nonEnumerableProperties = [ "message", "name" ];
+					for ( i in nonEnumerableProperties ) {
+						key = nonEnumerableProperties[ i ];
+						if ( key in map && !( key in keys ) ) {
+							keys.push( key );
+						}
+					}
+					keys.sort();
+					for ( i = 0; i < keys.length; i++ ) {
+						key = keys[ i ];
+						val = map[ key ];
+						ret.push( dump.parse( key, "key" ) + ": " + dump.parse( val, undefined, stack ) );
+					}
+					dump.down();
+					return join( "{", ret, "}" );
+				},
+				node: function( node ) {
+					var len, i, val,
+						open = dump.HTML ? "&lt;" : "<",
+						close = dump.HTML ? "&gt;" : ">",
+						tag = node.nodeName.toLowerCase(),
+						ret = open + tag,
+						attrs = node.attributes;
+
+					if ( attrs ) {
+						for ( i = 0, len = attrs.length; i < len; i++ ) {
+							val = attrs[ i ].nodeValue;
+
+							// IE6 includes all attributes in .attributes, even ones not explicitly set.
+							// Those have values like undefined, null, 0, false, "" or "inherit".
+							if ( val && val !== "inherit" ) {
+								ret += " " + attrs[ i ].nodeName + "=" + dump.parse( val, "attribute" );
+							}
+						}
+					}
+					ret += close;
+
+					// Show content of TextNode or CDATASection
+					if ( node.nodeType === 3 || node.nodeType === 4 ) {
+						ret += node.nodeValue;
+					}
+
+					return ret + open + "/" + tag + close;
+				},
+
+				// function calls it internally, it's the arguments part of the function
+				functionArgs: function( fn ) {
+					var args,
+						l = fn.length;
+
+					if ( !l ) {
+						return "";
+					}
+
+					args = new Array( l );
+					while ( l-- ) {
+
+						// 97 is 'a'
+						args[ l ] = String.fromCharCode( 97 + l );
+					}
+					return " " + args.join( ", " ) + " ";
+				},
+				// object calls it internally, the key part of an item in a map
+				key: quote,
+				// function calls it internally, it's the content of the function
+				functionCode: "[code]",
+				// node calls it internally, it's an html attribute value
+				attribute: quote,
+				string: quote,
+				date: quote,
+				regexp: literal,
+				number: literal,
+				"boolean": literal
+			},
+			// if true, entities are escaped ( <, >, \t, space and \n )
+			HTML: false,
+			// indentation unit
+			indentChar: "  ",
+			// if true, items in a collection, are separated by a \n, else just a space.
+			multiline: true
+		};
+
+	return dump;
+}());
+
+// back compat
+QUnit.jsDump = QUnit.dump;
+
+// For browser, export only select globals
+if ( typeof window !== "undefined" ) {
+
+	// Deprecated
+	// Extend assert methods to QUnit and Global scope through Backwards compatibility
+	(function() {
+		var i,
+			assertions = Assert.prototype;
+
+		function applyCurrent( current ) {
+			return function() {
+				var assert = new Assert( QUnit.config.current );
+				current.apply( assert, arguments );
+			};
+		}
+
+		for ( i in assertions ) {
+			QUnit[ i ] = applyCurrent( assertions[ i ] );
+		}
+	})();
+
+	(function() {
+		var i, l,
+			keys = [
+				"test",
+				"module",
+				"expect",
+				"asyncTest",
+				"start",
+				"stop",
+				"ok",
+				"equal",
+				"notEqual",
+				"propEqual",
+				"notPropEqual",
+				"deepEqual",
+				"notDeepEqual",
+				"strictEqual",
+				"notStrictEqual",
+				"throws"
+			];
+
+		for ( i = 0, l = keys.length; i < l; i++ ) {
+			window[ keys[ i ] ] = QUnit[ keys[ i ] ];
+		}
+	})();
+
+	window.QUnit = QUnit;
+}
+
+// For CommonJS environments, export everything
+if ( typeof module !== "undefined" && module.exports ) {
+	module.exports = QUnit;
+}
+
+// Get a reference to the global object, like window in browsers
+}( (function() {
+	return this;
+})() ));
+
+/*istanbul ignore next */
+/*
+ * Javascript Diff Algorithm
+ *  By John Resig (http://ejohn.org/)
+ *  Modified by Chu Alan "sprite"
+ *
+ * Released under the MIT license.
+ *
+ * More Info:
+ *  http://ejohn.org/projects/javascript-diff-algorithm/
+ *
+ * Usage: QUnit.diff(expected, actual)
+ *
+ * QUnit.diff( "the quick brown fox jumped over", "the quick fox jumps over" ) == "the  quick <del>brown </del> fox <del>jumped </del><ins>jumps </ins> over"
+ */
+QUnit.diff = (function() {
+	var hasOwn = Object.prototype.hasOwnProperty;
+
+	/*jshint eqeqeq:false, eqnull:true */
+	function diff( o, n ) {
+		var i,
+			ns = {},
+			os = {};
+
+		for ( i = 0; i < n.length; i++ ) {
+			if ( !hasOwn.call( ns, n[ i ] ) ) {
+				ns[ n[ i ] ] = {
+					rows: [],
+					o: null
+				};
+			}
+			ns[ n[ i ] ].rows.push( i );
+		}
+
+		for ( i = 0; i < o.length; i++ ) {
+			if ( !hasOwn.call( os, o[ i ] ) ) {
+				os[ o[ i ] ] = {
+					rows: [],
+					n: null
+				};
+			}
+			os[ o[ i ] ].rows.push( i );
+		}
+
+		for ( i in ns ) {
+			if ( hasOwn.call( ns, i ) ) {
+				if ( ns[ i ].rows.length === 1 && hasOwn.call( os, i ) && os[ i ].rows.length === 1 ) {
+					n[ ns[ i ].rows[ 0 ] ] = {
+						text: n[ ns[ i ].rows[ 0 ] ],
+						row: os[ i ].rows[ 0 ]
+					};
+					o[ os[ i ].rows[ 0 ] ] = {
+						text: o[ os[ i ].rows[ 0 ] ],
+						row: ns[ i ].rows[ 0 ]
+					};
+				}
+			}
+		}
+
+		for ( i = 0; i < n.length - 1; i++ ) {
+			if ( n[ i ].text != null && n[ i + 1 ].text == null && n[ i ].row + 1 < o.length && o[ n[ i ].row + 1 ].text == null &&
+				n[ i + 1 ] == o[ n[ i ].row + 1 ] ) {
+
+				n[ i + 1 ] = {
+					text: n[ i + 1 ],
+					row: n[ i ].row + 1
+				};
+				o[ n[ i ].row + 1 ] = {
+					text: o[ n[ i ].row + 1 ],
+					row: i + 1
+				};
+			}
+		}
+
+		for ( i = n.length - 1; i > 0; i-- ) {
+			if ( n[ i ].text != null && n[ i - 1 ].text == null && n[ i ].row > 0 && o[ n[ i ].row - 1 ].text == null &&
+				n[ i - 1 ] == o[ n[ i ].row - 1 ] ) {
+
+				n[ i - 1 ] = {
+					text: n[ i - 1 ],
+					row: n[ i ].row - 1
+				};
+				o[ n[ i ].row - 1 ] = {
+					text: o[ n[ i ].row - 1 ],
+					row: i - 1
+				};
+			}
+		}
+
+		return {
+			o: o,
+			n: n
+		};
+	}
+
+	return function( o, n ) {
+		o = o.replace( /\s+$/, "" );
+		n = n.replace( /\s+$/, "" );
+
+		var i, pre,
+			str = "",
+			out = diff( o === "" ? [] : o.split( /\s+/ ), n === "" ? [] : n.split( /\s+/ ) ),
+			oSpace = o.match( /\s+/g ),
+			nSpace = n.match( /\s+/g );
+
+		if ( oSpace == null ) {
+			oSpace = [ " " ];
+		} else {
+			oSpace.push( " " );
+		}
+
+		if ( nSpace == null ) {
+			nSpace = [ " " ];
+		} else {
+			nSpace.push( " " );
+		}
+
+		if ( out.n.length === 0 ) {
+			for ( i = 0; i < out.o.length; i++ ) {
+				str += "<del>" + out.o[ i ] + oSpace[ i ] + "</del>";
+			}
+		} else {
+			if ( out.n[ 0 ].text == null ) {
+				for ( n = 0; n < out.o.length && out.o[ n ].text == null; n++ ) {
+					str += "<del>" + out.o[ n ] + oSpace[ n ] + "</del>";
+				}
+			}
+
+			for ( i = 0; i < out.n.length; i++ ) {
+				if ( out.n[ i ].text == null ) {
+					str += "<ins>" + out.n[ i ] + nSpace[ i ] + "</ins>";
+				} else {
+
+					// `pre` initialized at top of scope
+					pre = "";
+
+					for ( n = out.n[ i ].row + 1; n < out.o.length && out.o[ n ].text == null; n++ ) {
+						pre += "<del>" + out.o[ n ] + oSpace[ n ] + "</del>";
+					}
+					str += " " + out.n[ i ].text + nSpace[ i ] + pre;
+				}
+			}
+		}
+
+		return str;
+	};
+}());
+
+(function() {
+
+// Deprecated QUnit.init - Ref #530
+// Re-initialize the configuration options
+QUnit.init = function() {
+	var tests, banner, result, qunit,
+		config = QUnit.config;
+
+	config.stats = { all: 0, bad: 0 };
+	config.moduleStats = { all: 0, bad: 0 };
+	config.started = 0;
+	config.updateRate = 1000;
+	config.blocking = false;
+	config.autostart = true;
+	config.autorun = false;
+	config.filter = "";
+	config.queue = [];
+	config.semaphore = 1;
+
+	// Return on non-browser environments
+	// This is necessary to not break on node tests
+	if ( typeof window === "undefined" ) {
+		return;
+	}
+
+	qunit = id( "qunit" );
+	if ( qunit ) {
+		qunit.innerHTML =
+			"<h1 id='qunit-header'>" + escapeText( document.title ) + "</h1>" +
+			"<h2 id='qunit-banner'></h2>" +
+			"<div id='qunit-testrunner-toolbar'></div>" +
+			"<h2 id='qunit-userAgent'></h2>" +
+			"<ol id='qunit-tests'></ol>";
+	}
+
+	tests = id( "qunit-tests" );
+	banner = id( "qunit-banner" );
+	result = id( "qunit-testresult" );
+
+	if ( tests ) {
+		tests.innerHTML = "";
+	}
+
+	if ( banner ) {
+		banner.className = "";
+	}
+
+	if ( result ) {
+		result.parentNode.removeChild( result );
+	}
+
+	if ( tests ) {
+		result = document.createElement( "p" );
+		result.id = "qunit-testresult";
+		result.className = "result";
+		tests.parentNode.insertBefore( result, tests );
+		result.innerHTML = "Running...<br/>&nbsp;";
+	}
+};
+
+// Resets the test setup. Useful for tests that modify the DOM.
+/*
+DEPRECATED: Use multiple tests instead of resetting inside a test.
+Use testStart or testDone for custom cleanup.
+This method will throw an error in 2.0, and will be removed in 2.1
+*/
+QUnit.reset = function() {
+
+	// Return on non-browser environments
+	// This is necessary to not break on node tests
+	if ( typeof window === "undefined" ) {
+		return;
+	}
+
+	var fixture = id( "qunit-fixture" );
+	if ( fixture ) {
+		fixture.innerHTML = config.fixture;
+	}
+};
+
+// Don't load the HTML Reporter on non-Browser environments
+if ( typeof window === "undefined" ) {
+	return;
+}
+
+var config = QUnit.config,
+	hasOwn = Object.prototype.hasOwnProperty,
+	defined = {
+		document: typeof window.document !== "undefined",
+		sessionStorage: (function() {
+			var x = "qunit-test-string";
+			try {
+				sessionStorage.setItem( x, x );
+				sessionStorage.removeItem( x );
+				return true;
+			} catch ( e ) {
+				return false;
+			}
+		}())
+	};
+
+/**
+* Escape text for attribute or text content.
+*/
+function escapeText( s ) {
+	if ( !s ) {
+		return "";
+	}
+	s = s + "";
+
+	// Both single quotes and double quotes (for attributes)
+	return s.replace( /['"<>&]/g, function( s ) {
+		switch ( s ) {
+		case "'":
+			return "&#039;";
+		case "\"":
+			return "&quot;";
+		case "<":
+			return "&lt;";
+		case ">":
+			return "&gt;";
+		case "&":
+			return "&amp;";
+		}
+	});
+}
+
+/**
+ * @param {HTMLElement} elem
+ * @param {string} type
+ * @param {Function} fn
+ */
+function addEvent( elem, type, fn ) {
+	if ( elem.addEventListener ) {
+
+		// Standards-based browsers
+		elem.addEventListener( type, fn, false );
+	} else if ( elem.attachEvent ) {
+
+		// support: IE <9
+		elem.attachEvent( "on" + type, fn );
+	}
+}
+
+/**
+ * @param {Array|NodeList} elems
+ * @param {string} type
+ * @param {Function} fn
+ */
+function addEvents( elems, type, fn ) {
+	var i = elems.length;
+	while ( i-- ) {
+		addEvent( elems[ i ], type, fn );
+	}
+}
+
+function hasClass( elem, name ) {
+	return ( " " + elem.className + " " ).indexOf( " " + name + " " ) >= 0;
+}
+
+function addClass( elem, name ) {
+	if ( !hasClass( elem, name ) ) {
+		elem.className += ( elem.className ? " " : "" ) + name;
+	}
+}
+
+function toggleClass( elem, name ) {
+	if ( hasClass( elem, name ) ) {
+		removeClass( elem, name );
+	} else {
+		addClass( elem, name );
+	}
+}
+
+function removeClass( elem, name ) {
+	var set = " " + elem.className + " ";
+
+	// Class name may appear multiple times
+	while ( set.indexOf( " " + name + " " ) >= 0 ) {
+		set = set.replace( " " + name + " ", " " );
+	}
+
+	// trim for prettiness
+	elem.className = typeof set.trim === "function" ? set.trim() : set.replace( /^\s+|\s+$/g, "" );
+}
+
+function id( name ) {
+	return defined.document && document.getElementById && document.getElementById( name );
+}
+
+function getUrlConfigHtml() {
+	var i, j, val,
+		escaped, escapedTooltip,
+		selection = false,
+		len = config.urlConfig.length,
+		urlConfigHtml = "";
+
+	for ( i = 0; i < len; i++ ) {
+		val = config.urlConfig[ i ];
+		if ( typeof val === "string" ) {
+			val = {
+				id: val,
+				label: val
+			};
+		}
+
+		escaped = escapeText( val.id );
+		escapedTooltip = escapeText( val.tooltip );
+
+		config[ val.id ] = QUnit.urlParams[ val.id ];
+		if ( !val.value || typeof val.value === "string" ) {
+			urlConfigHtml += "<input id='qunit-urlconfig-" + escaped +
+				"' name='" + escaped + "' type='checkbox'" +
+				( val.value ? " value='" + escapeText( val.value ) + "'" : "" ) +
+				( config[ val.id ] ? " checked='checked'" : "" ) +
+				" title='" + escapedTooltip + "'><label for='qunit-urlconfig-" + escaped +
+				"' title='" + escapedTooltip + "'>" + val.label + "</label>";
+		} else {
+			urlConfigHtml += "<label for='qunit-urlconfig-" + escaped +
+				"' title='" + escapedTooltip + "'>" + val.label +
+				": </label><select id='qunit-urlconfig-" + escaped +
+				"' name='" + escaped + "' title='" + escapedTooltip + "'><option></option>";
+
+			if ( QUnit.is( "array", val.value ) ) {
+				for ( j = 0; j < val.value.length; j++ ) {
+					escaped = escapeText( val.value[ j ] );
+					urlConfigHtml += "<option value='" + escaped + "'" +
+						( config[ val.id ] === val.value[ j ] ?
+							( selection = true ) && " selected='selected'" : "" ) +
+						">" + escaped + "</option>";
+				}
+			} else {
+				for ( j in val.value ) {
+					if ( hasOwn.call( val.value, j ) ) {
+						urlConfigHtml += "<option value='" + escapeText( j ) + "'" +
+							( config[ val.id ] === j ?
+								( selection = true ) && " selected='selected'" : "" ) +
+							">" + escapeText( val.value[ j ] ) + "</option>";
+					}
+				}
+			}
+			if ( config[ val.id ] && !selection ) {
+				escaped = escapeText( config[ val.id ] );
+				urlConfigHtml += "<option value='" + escaped +
+					"' selected='selected' disabled='disabled'>" + escaped + "</option>";
+			}
+			urlConfigHtml += "</select>";
+		}
+	}
+
+	return urlConfigHtml;
+}
+
+function toolbarUrlConfigContainer() {
+	var urlConfigContainer = document.createElement( "span" );
+
+	urlConfigContainer.innerHTML = getUrlConfigHtml();
+
+	// For oldIE support:
+	// * Add handlers to the individual elements instead of the container
+	// * Use "click" instead of "change" for checkboxes
+	// * Fallback from event.target to event.srcElement
+	addEvents( urlConfigContainer.getElementsByTagName( "input" ), "click", function( event ) {
+		var params = {},
+			target = event.target || event.srcElement;
+		params[ target.name ] = target.checked ?
+			target.defaultValue || true :
+			undefined;
+		window.location = QUnit.url( params );
+	});
+	addEvents( urlConfigContainer.getElementsByTagName( "select" ), "change", function( event ) {
+		var params = {},
+			target = event.target || event.srcElement;
+		params[ target.name ] = target.options[ target.selectedIndex ].value || undefined;
+		window.location = QUnit.url( params );
+	});
+
+	return urlConfigContainer;
+}
+
+function getModuleNames() {
+	var i,
+		moduleNames = [];
+
+	for ( i in config.modules ) {
+		if ( config.modules.hasOwnProperty( i ) ) {
+			moduleNames.push( i );
+		}
+	}
+
+	moduleNames.sort(function( a, b ) {
+		return a.localeCompare( b );
+	});
+
+	return moduleNames;
+}
+
+function toolbarModuleFilterHtml() {
+	var i,
+		moduleFilterHtml = "",
+		moduleNames = getModuleNames();
+
+	if ( moduleNames.length <= 1 ) {
+		return false;
+	}
+
+	moduleFilterHtml += "<label for='qunit-modulefilter'>Module: </label>" +
+		"<select id='qunit-modulefilter' name='modulefilter'><option value='' " +
+		( config.module === undefined ? "selected='selected'" : "" ) +
+		">< All Modules ></option>";
+
+	for ( i = 0; i < moduleNames.length; i++ ) {
+		moduleFilterHtml += "<option value='" +
+			escapeText( encodeURIComponent( moduleNames[ i ] ) ) + "' " +
+			( config.module === moduleNames[ i ] ? "selected='selected'" : "" ) +
+			">" + escapeText( moduleNames[ i ] ) + "</option>";
+	}
+	moduleFilterHtml += "</select>";
+
+	return moduleFilterHtml;
+}
+
+function toolbarModuleFilter() {
+	var moduleFilter = document.createElement( "span" ),
+		moduleFilterHtml = toolbarModuleFilterHtml();
+
+	if ( !moduleFilterHtml ) {
+		return false;
+	}
+
+	moduleFilter.setAttribute( "id", "qunit-modulefilter-container" );
+	moduleFilter.innerHTML = moduleFilterHtml;
+
+	addEvent( moduleFilter.lastChild, "change", function() {
+		var selectBox = moduleFilter.getElementsByTagName( "select" )[ 0 ],
+			selectedModule = decodeURIComponent( selectBox.options[ selectBox.selectedIndex ].value );
+
+		window.location = QUnit.url({
+			module: ( selectedModule === "" ) ? undefined : selectedModule,
+
+			// Remove any existing filters
+			filter: undefined,
+			testNumber: undefined
+		});
+	});
+
+	return moduleFilter;
+}
+
+function toolbarFilter() {
+	var testList = id( "qunit-tests" ),
+		filter = document.createElement( "input" );
+
+	filter.type = "checkbox";
+	filter.id = "qunit-filter-pass";
+
+	addEvent( filter, "click", function() {
+		if ( filter.checked ) {
+			addClass( testList, "hidepass" );
+			if ( defined.sessionStorage ) {
+				sessionStorage.setItem( "qunit-filter-passed-tests", "true" );
+			}
+		} else {
+			removeClass( testList, "hidepass" );
+			if ( defined.sessionStorage ) {
+				sessionStorage.removeItem( "qunit-filter-passed-tests" );
+			}
+		}
+	});
+
+	if ( config.hidepassed || defined.sessionStorage &&
+			sessionStorage.getItem( "qunit-filter-passed-tests" ) ) {
+		filter.checked = true;
+
+		addClass( testList, "hidepass" );
+	}
+
+	return filter;
+}
+
+function toolbarLabel() {
+	var label = document.createElement( "label" );
+	label.setAttribute( "for", "qunit-filter-pass" );
+	label.setAttribute( "title", "Only show tests and assertions that fail. Stored in sessionStorage." );
+	label.innerHTML = "Hide passed tests";
+
+	return label;
+}
+
+function appendToolbar() {
+	var moduleFilter,
+		toolbar = id( "qunit-testrunner-toolbar" );
+
+	if ( toolbar ) {
+		toolbar.appendChild( toolbarFilter() );
+		toolbar.appendChild( toolbarLabel() );
+		toolbar.appendChild( toolbarUrlConfigContainer() );
+
+		moduleFilter = toolbarModuleFilter();
+		if ( moduleFilter ) {
+			toolbar.appendChild( moduleFilter );
+		}
+	}
+}
+
+function appendBanner() {
+	var banner = id( "qunit-banner" );
+
+	if ( banner ) {
+		banner.className = "";
+		banner.innerHTML = "<a href='" +
+			QUnit.url({ filter: undefined, module: undefined, testNumber: undefined }) +
+			"'>" + banner.innerHTML + "</a> ";
+	}
+}
+
+function appendTestResults() {
+	var tests = id( "qunit-tests" ),
+		result = id( "qunit-testresult" );
+
+	if ( result ) {
+		result.parentNode.removeChild( result );
+	}
+
+	if ( tests ) {
+		tests.innerHTML = "";
+		result = document.createElement( "p" );
+		result.id = "qunit-testresult";
+		result.className = "result";
+		tests.parentNode.insertBefore( result, tests );
+		result.innerHTML = "Running...<br>&nbsp;";
+	}
+}
+
+function storeFixture() {
+	var fixture = id( "qunit-fixture" );
+	if ( fixture ) {
+		config.fixture = fixture.innerHTML;
+	}
+}
+
+function appendUserAgent() {
+	var userAgent = id( "qunit-userAgent" );
+	if ( userAgent ) {
+		userAgent.innerHTML = navigator.userAgent;
+	}
+}
+
+// HTML Reporter initialization and load
+QUnit.begin(function() {
+	var qunit = id( "qunit" );
+
+	if ( qunit ) {
+		qunit.innerHTML =
+		"<h1 id='qunit-header'>" + escapeText( document.title ) + "</h1>" +
+		"<h2 id='qunit-banner'></h2>" +
+		"<div id='qunit-testrunner-toolbar'></div>" +
+		"<h2 id='qunit-userAgent'></h2>" +
+		"<ol id='qunit-tests'></ol>";
+	}
+
+	appendBanner();
+	appendTestResults();
+	appendUserAgent();
+	appendToolbar();
+	storeFixture();
+});
+
+QUnit.done(function( details ) {
+	var i, key,
+		banner = id( "qunit-banner" ),
+		tests = id( "qunit-tests" ),
+		html = [
+			"Tests completed in ",
+			details.runtime,
+			" milliseconds.<br>",
+			"<span class='passed'>",
+			details.passed,
+			"</span> assertions of <span class='total'>",
+			details.total,
+			"</span> passed, <span class='failed'>",
+			details.failed,
+			"</span> failed."
+		].join( "" );
+
+	if ( banner ) {
+		banner.className = details.failed ? "qunit-fail" : "qunit-pass";
+	}
+
+	if ( tests ) {
+		id( "qunit-testresult" ).innerHTML = html;
+	}
+
+	if ( config.altertitle && defined.document && document.title ) {
+
+		// show ✖ for good, ✔ for bad suite result in title
+		// use escape sequences in case file gets loaded with non-utf-8-charset
+		document.title = [
+			( details.failed ? "\u2716" : "\u2714" ),
+			document.title.replace( /^[\u2714\u2716] /i, "" )
+		].join( " " );
+	}
+
+	// clear own sessionStorage items if all tests passed
+	if ( config.reorder && defined.sessionStorage && details.failed === 0 ) {
+		for ( i = 0; i < sessionStorage.length; i++ ) {
+			key = sessionStorage.key( i++ );
+			if ( key.indexOf( "qunit-test-" ) === 0 ) {
+				sessionStorage.removeItem( key );
+			}
+		}
+	}
+
+	// scroll back to top to show results
+	if ( config.scrolltop && window.scrollTo ) {
+		window.scrollTo( 0, 0 );
+	}
+});
+
+function getNameHtml( name, module ) {
+	var nameHtml = "";
+
+	if ( module ) {
+		nameHtml = "<span class='module-name'>" + escapeText( module ) + "</span>: ";
+	}
+
+	nameHtml += "<span class='test-name'>" + escapeText( name ) + "</span>";
+
+	return nameHtml;
+}
+
+QUnit.testStart(function( details ) {
+	var a, b, li, running, assertList,
+		name = getNameHtml( details.name, details.module ),
+		tests = id( "qunit-tests" );
+
+	if ( tests ) {
+		b = document.createElement( "strong" );
+		b.innerHTML = name;
+
+		a = document.createElement( "a" );
+		a.innerHTML = "Rerun";
+		a.href = QUnit.url({ testNumber: details.testNumber });
+
+		li = document.createElement( "li" );
+		li.appendChild( b );
+		li.appendChild( a );
+		li.className = "running";
+		li.id = "qunit-test-output" + details.testNumber;
+
+		assertList = document.createElement( "ol" );
+		assertList.className = "qunit-assert-list";
+
+		li.appendChild( assertList );
+
+		tests.appendChild( li );
+	}
+
+	running = id( "qunit-testresult" );
+	if ( running ) {
+		running.innerHTML = "Running: <br>" + name;
+	}
+
+});
+
+QUnit.log(function( details ) {
+	var assertList, assertLi,
+		message, expected, actual,
+		testItem = id( "qunit-test-output" + details.testNumber );
+
+	if ( !testItem ) {
+		return;
+	}
+
+	message = escapeText( details.message ) || ( details.result ? "okay" : "failed" );
+	message = "<span class='test-message'>" + message + "</span>";
+
+	// pushFailure doesn't provide details.expected
+	// when it calls, it's implicit to also not show expected and diff stuff
+	// Also, we need to check details.expected existence, as it can exist and be undefined
+	if ( !details.result && hasOwn.call( details, "expected" ) ) {
+		expected = escapeText( QUnit.dump.parse( details.expected ) );
+		actual = escapeText( QUnit.dump.parse( details.actual ) );
+		message += "<table><tr class='test-expected'><th>Expected: </th><td><pre>" +
+			expected +
+			"</pre></td></tr>";
+
+		if ( actual !== expected ) {
+			message += "<tr class='test-actual'><th>Result: </th><td><pre>" +
+				actual + "</pre></td></tr>" +
+				"<tr class='test-diff'><th>Diff: </th><td><pre>" +
+				QUnit.diff( expected, actual ) + "</pre></td></tr>";
+		}
+
+		if ( details.source ) {
+			message += "<tr class='test-source'><th>Source: </th><td><pre>" +
+				escapeText( details.source ) + "</pre></td></tr>";
+		}
+
+		message += "</table>";
+
+	// this occours when pushFailure is set and we have an extracted stack trace
+	} else if ( !details.result && details.source ) {
+		message += "<table>" +
+			"<tr class='test-source'><th>Source: </th><td><pre>" +
+			escapeText( details.source ) + "</pre></td></tr>" +
+			"</table>";
+	}
+
+	assertList = testItem.getElementsByTagName( "ol" )[ 0 ];
+
+	assertLi = document.createElement( "li" );
+	assertLi.className = details.result ? "pass" : "fail";
+	assertLi.innerHTML = message;
+	assertList.appendChild( assertLi );
+});
+
+QUnit.testDone(function( details ) {
+	var testTitle, time, testItem, assertList,
+		good, bad, testCounts,
+		tests = id( "qunit-tests" );
+
+	// QUnit.reset() is deprecated and will be replaced for a new
+	// fixture reset function on QUnit 2.0/2.1.
+	// It's still called here for backwards compatibility handling
+	QUnit.reset();
+
+	if ( !tests ) {
+		return;
+	}
+
+	testItem = id( "qunit-test-output" + details.testNumber );
+	assertList = testItem.getElementsByTagName( "ol" )[ 0 ];
+
+	good = details.passed;
+	bad = details.failed;
+
+	// store result when possible
+	if ( config.reorder && defined.sessionStorage ) {
+		if ( bad ) {
+			sessionStorage.setItem( "qunit-test-" + details.module + "-" + details.name, bad );
+		} else {
+			sessionStorage.removeItem( "qunit-test-" + details.module + "-" + details.name );
+		}
+	}
+
+	if ( bad === 0 ) {
+		addClass( assertList, "qunit-collapsed" );
+	}
+
+	// testItem.firstChild is the test name
+	testTitle = testItem.firstChild;
+
+	testCounts = bad ?
+		"<b class='failed'>" + bad + "</b>, " + "<b class='passed'>" + good + "</b>, " :
+		"";
+
+	testTitle.innerHTML += " <b class='counts'>(" + testCounts +
+		details.assertions.length + ")</b>";
+
+	addEvent( testTitle, "click", function() {
+		toggleClass( assertList, "qunit-collapsed" );
+	});
+
+	time = document.createElement( "span" );
+	time.className = "runtime";
+	time.innerHTML = details.runtime + " ms";
+
+	testItem.className = bad ? "fail" : "pass";
+
+	testItem.insertBefore( time, assertList );
+});
+
+if ( !defined.document || document.readyState === "complete" ) {
+	config.autorun = true;
+}
+
+if ( defined.document ) {
+	addEvent( window, "load", QUnit.load );
+}
+
+})();

+ 29 - 0
contrib/views/files/src/main/resources/ui/app/assets/javascripts/tests.js

@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var folderOrder = [
+  'test'
+];
+
+folderOrder.forEach(function(folder) {
+  window.require.list().filter(function(module) {
+    return new RegExp('^' + folder + '/').test(module);
+  }).forEach(function(module) {
+      require(module);
+    });
+});

+ 237 - 0
contrib/views/files/src/main/resources/ui/app/assets/stylesheets/qunit.css

@@ -0,0 +1,237 @@
+/*!
+ * QUnit 1.15.0
+ * http://qunitjs.com/
+ *
+ * Copyright 2014 jQuery Foundation and other contributors
+ * Released under the MIT license
+ * http://jquery.org/license
+ *
+ * Date: 2014-08-08T16:00Z
+ */
+
+/** Font Family and Sizes */
+
+#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult {
+	font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif;
+}
+
+#qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
+#qunit-tests { font-size: smaller; }
+
+
+/** Resets */
+
+#qunit-tests, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult, #qunit-modulefilter {
+	margin: 0;
+	padding: 0;
+}
+
+
+/** Header */
+
+#qunit-header {
+	padding: 0.5em 0 0.5em 1em;
+
+	color: #8699A4;
+	background-color: #0D3349;
+
+	font-size: 1.5em;
+	line-height: 1em;
+	font-weight: 400;
+
+	border-radius: 5px 5px 0 0;
+}
+
+#qunit-header a {
+	text-decoration: none;
+	color: #C2CCD1;
+}
+
+#qunit-header a:hover,
+#qunit-header a:focus {
+	color: #FFF;
+}
+
+#qunit-testrunner-toolbar label {
+	display: inline-block;
+	padding: 0 0.5em 0 0.1em;
+}
+
+#qunit-banner {
+	height: 5px;
+}
+
+#qunit-testrunner-toolbar {
+	padding: 0.5em 1em 0.5em 1em;
+	color: #5E740B;
+	background-color: #EEE;
+	overflow: hidden;
+}
+
+#qunit-userAgent {
+	padding: 0.5em 1em 0.5em 1em;
+	background-color: #2B81AF;
+	color: #FFF;
+	text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
+}
+
+#qunit-modulefilter-container {
+	float: right;
+}
+
+/** Tests: Pass/Fail */
+
+#qunit-tests {
+	list-style-position: inside;
+}
+
+#qunit-tests li {
+	padding: 0.4em 1em 0.4em 1em;
+	border-bottom: 1px solid #FFF;
+	list-style-position: inside;
+}
+
+#qunit-tests.hidepass li.pass, #qunit-tests.hidepass li.running  {
+	display: none;
+}
+
+#qunit-tests li strong {
+	cursor: pointer;
+}
+
+#qunit-tests li a {
+	padding: 0.5em;
+	color: #C2CCD1;
+	text-decoration: none;
+}
+#qunit-tests li a:hover,
+#qunit-tests li a:focus {
+	color: #000;
+}
+
+#qunit-tests li .runtime {
+	float: right;
+	font-size: smaller;
+}
+
+.qunit-assert-list {
+	margin-top: 0.5em;
+	padding: 0.5em;
+
+	background-color: #FFF;
+
+	border-radius: 5px;
+}
+
+.qunit-collapsed {
+	display: none;
+}
+
+#qunit-tests table {
+	border-collapse: collapse;
+	margin-top: 0.2em;
+}
+
+#qunit-tests th {
+	text-align: right;
+	vertical-align: top;
+	padding: 0 0.5em 0 0;
+}
+
+#qunit-tests td {
+	vertical-align: top;
+}
+
+#qunit-tests pre {
+	margin: 0;
+	white-space: pre-wrap;
+	word-wrap: break-word;
+}
+
+#qunit-tests del {
+	background-color: #E0F2BE;
+	color: #374E0C;
+	text-decoration: none;
+}
+
+#qunit-tests ins {
+	background-color: #FFCACA;
+	color: #500;
+	text-decoration: none;
+}
+
+/*** Test Counts */
+
+#qunit-tests b.counts                       { color: #000; }
+#qunit-tests b.passed                       { color: #5E740B; }
+#qunit-tests b.failed                       { color: #710909; }
+
+#qunit-tests li li {
+	padding: 5px;
+	background-color: #FFF;
+	border-bottom: none;
+	list-style-position: inside;
+}
+
+/*** Passing Styles */
+
+#qunit-tests li li.pass {
+	color: #3C510C;
+	background-color: #FFF;
+	border-left: 10px solid #C6E746;
+}
+
+#qunit-tests .pass                          { color: #528CE0; background-color: #D2E0E6; }
+#qunit-tests .pass .test-name               { color: #366097; }
+
+#qunit-tests .pass .test-actual,
+#qunit-tests .pass .test-expected           { color: #999; }
+
+#qunit-banner.qunit-pass                    { background-color: #C6E746; }
+
+/*** Failing Styles */
+
+#qunit-tests li li.fail {
+	color: #710909;
+	background-color: #FFF;
+	border-left: 10px solid #EE5757;
+	white-space: pre;
+}
+
+#qunit-tests > li:last-child {
+	border-radius: 0 0 5px 5px;
+}
+
+#qunit-tests .fail                          { color: #000; background-color: #EE5757; }
+#qunit-tests .fail .test-name,
+#qunit-tests .fail .module-name             { color: #000; }
+
+#qunit-tests .fail .test-actual             { color: #EE5757; }
+#qunit-tests .fail .test-expected           { color: #008000; }
+
+#qunit-banner.qunit-fail                    { background-color: #EE5757; }
+
+
+/** Result */
+
+#qunit-testresult {
+	padding: 0.5em 1em 0.5em 1em;
+
+	color: #2B81AF;
+	background-color: #D2E0E6;
+
+	border-bottom: 1px solid #FFF;
+}
+#qunit-testresult .module-name {
+	font-weight: 700;
+}
+
+/** Fixture */
+
+#qunit-fixture {
+	position: absolute;
+	top: -10000px;
+	left: -10000px;
+	width: 1000px;
+	height: 1000px;
+}

+ 46 - 0
contrib/views/files/src/main/resources/ui/app/assets/tests.html

@@ -0,0 +1,46 @@
+<!--
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+  <meta charset="utf-8">
+  <title>Files tests</title>
+  <link rel="stylesheet" href="stylesheets/qunit.css">
+</head>
+<body>
+  <div id="qunit"></div>
+  <div id="qunit-fixture"></div>
+  <div id="ember-testing"></div>
+  <script src="javascripts/qunit.js"></script>
+  <script src="javascripts/vendor.js"></script>
+  <script src="javascripts/jquery.mockjax.js"></script>
+  <script src="javascripts/ember-qunit.js"></script>
+  <script src="javascripts/app.js"></script>
+  <script>
+    emq.globalize();
+    require('initialize');
+    App.setupForTesting();
+    App.injectTestHelpers();
+    setResolver(Em.DefaultResolver.create({ namespace: App }));
+    App.rootElement = '#ember-testing'
+  </script>
+  <script src="javascripts/test.js"></script>
+  <script src="javascripts/tests.js"></script>
+</body>
+</html>

+ 1 - 1
contrib/views/files/src/main/resources/ui/app/components/breadCrumbs.js

@@ -29,7 +29,7 @@ App.BreadCrumbsComponent = Ember.CollectionView.extend({
       return crumbs.push({name:cur,path:'/'+array.slice(0,i+1).join('/')});
     });
     crumbs.unshift({name:'/',path:'/'});
-    crumbs.get('lastObject').last = 'true';
+    crumbs.set('lastObject.last','true');
     return crumbs;
   }.property('path'),
   itemViewClass: Ember.View.extend({

+ 5 - 16
contrib/views/files/src/main/resources/ui/app/components/bulkCheckbox.js

@@ -19,22 +19,11 @@
 var App = require('app');
 
 App.BulkCheckboxComponent = Em.Checkbox.extend({
-  changeBinding:'selectAll',
-  checkedBinding:'selectedAll',
-  selectedAll:false,
+  selectedAll:Em.computed.alias('checked'),
   selectAll:function () {
-    var checked = this.get('checked');
-    var items = this.get('content');
-    return items.forEach(function (item) {
-      item.set('selected',checked);
-    });
-  },
+    this.get('content').setEach('selected',this.get('selectedAll'));
+  }.on('change'),
   selection:function () {
-    var selected = this.get('content').filterBy('selected',true);
-    if (selected.length == this.get('content.length') && selected.length > 0) {
-      this.set('selectedAll',true);
-    } else {
-      this.set('selectedAll',false);
-    }
-  }.observes('content.@each.selected'),
+    this.set('selectedAll', !!(this.get('content.length') && this.get('content').isEvery('selected',true)));
+  }.observes('content.@each.selected')
 });

+ 3 - 3
contrib/views/files/src/main/resources/ui/app/components/confirmDelete.js

@@ -27,7 +27,7 @@ App.DropdownWrapComponent = Em.Component.extend({
   }.on('resetConfirm'),
   didInsertElement:function(){
     this.$().on('hidden.bs.dropdown',Em.run.bind(this,this.onResetConfirm));
-  },
+  }
 });
 
 App.ConfirmDeleteComponent = Em.Component.extend({
@@ -41,13 +41,13 @@ App.ConfirmDeleteComponent = Em.Component.extend({
   click:function  (e) {
     if (!$(e.target).hasClass('delete')) {
       e.stopPropagation();
-    };
+    }
   },
   actions:{
     ask:function () {
       this.get('parentView').trigger('resetConfirm');
       this.set('isRemoving',true);
-      return false; 
+      return false;
     },
     cancel:function () {
       this.cancelRemoving();

+ 1 - 1
contrib/views/files/src/main/resources/ui/app/components/contextMenu.js

@@ -36,7 +36,7 @@ App.ContextMenuComponent = Em.Component.extend({
     },
     moveToTrash:function () {
       this.get('target').send('deleteFile');
-    },
+    }
   }
 
 });

+ 2 - 4
contrib/views/files/src/main/resources/ui/app/components/popoverDelete.js

@@ -37,14 +37,12 @@ App.PopoverDeleteComponent = Em.Component.extend({
     if (!this.$()) {
       return;
     }
-    if (!this.$().is(e.target)
-        && this.$().has(e.target).length === 0
-        && $('.popover').has(e.target).length === 0) {
+    if (!this.$().is(e.target) && this.$().has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
           this.set('popover.isVisible',false);
     }
   },
   willClearRender:function () {
     this.get('popover').$element.off('click');
     $('body').off('click.popover');
-  },
+  }
 });

+ 11 - 21
contrib/views/files/src/main/resources/ui/app/components/renameInput.js

@@ -31,16 +31,16 @@ App.RenameInputComponent = Ember.Component.extend({
         case 'cancel': this.set('isRenaming',false); break;
         case 'confirm':
           tmpName = this.get('tmpName');
-          if (tmpName.length==0) {
+          if (tmpName.length ===0) {
             break;
-          };
+          }
           this.sendAction('confirm',this.get('filePath'),tmpName);
           this.set('isRenaming',false);
           break;
 
         default: this.toggleProperty('isRenaming');
       }
-    },
+    }
   },
 
   /**
@@ -51,23 +51,13 @@ App.RenameInputComponent = Ember.Component.extend({
   isRenaming:false,
 
   fileName:function () {
-    var name, file = this.get('file');
-    if (file instanceof DS.Model) {
-      name = this.get('file.name');
-    } else {
-      name = file.substr(file.lastIndexOf('/')+1);
-    };
-    return name;
+    var file = this.get('file');
+    return (file instanceof DS.Model)?file.get('name'):file.substr(file.lastIndexOf('/')+1);
   }.property('file'),
 
   filePath:function () {
-    var path, file = this.get('file');
-    if (file instanceof DS.Model) {
-      path = this.get('file.path');
-    } else {
-      path = file;
-    };
-    return path;
+    var file = this.get('file');
+    return (file instanceof DS.Model)?file.get('path'):file;
   }.property('file'),
 
   setTmpName:function () {
@@ -75,7 +65,7 @@ App.RenameInputComponent = Ember.Component.extend({
       this.set('tmpName',this.get('fileName'));
     } else {
       this.set('tmpName','');
-    };
+    }
   }.observes('isRenaming'),
 
   onFileChange:function () {
@@ -86,17 +76,17 @@ App.RenameInputComponent = Ember.Component.extend({
     controller:null,
     didInsertElement:function () {
       var element = $(this.get('element'));
-      element.focus().val(this.value)
+      element.focus().val(this.value);
     },
     keyUp: function(e) {
       var target = this.get('targetObject');
       if (e.keyCode==13) {
         return target.send('rename', 'confirm');
-      };
+      }
 
       if (e.keyCode==27) {
         return target.send('rename', 'cancel');
-      };
+      }
     }
   })
 });

+ 4 - 9
contrib/views/files/src/main/resources/ui/app/components/sortArrow.js

@@ -19,7 +19,7 @@
 var App = require('app');
 
 App.SortArrowComponent = Em.Component.extend({
-  layout:Ember.Handlebars.compile('<i {{bind-attr class=":fa view.asc:fa-chevron-down:fa-chevron-up view.cur::fa-gr view.cur::fa-rotate-270" }} ></i>'),
+  layout:Ember.Handlebars.compile('<i {{bind-attr class=":fa asc:fa-chevron-down:fa-chevron-up cur::fa-gr view.cur::fa-rotate-270" }} ></i>'),
   classNames:['pull-right'],
   tagName:'span',
   sPs:[],
@@ -28,12 +28,7 @@ App.SortArrowComponent = Em.Component.extend({
   asc:true,
   cur:false,
   sorting:function () {
-    if (this.get('sPs.firstObject') == this.get('sP')) {
-      this.set('asc',this.get('sA'));
-      this.set('cur',true);
-    } else{
-      this.set('asc',true);
-      this.set('cur',false);
-    };
-  }.observes('sPs','sA').on('init'),
+    var isSp = this.get('sPs.firstObject') == this.get('sP');
+    this.setProperties({'asc':(isSp)?this.get('sA'):true,'cur':isSp});
+  }.observes('sPs','sA').on('didInsertElement')
 });

+ 3 - 3
contrib/views/files/src/main/resources/ui/app/components/toggleContext.js

@@ -20,7 +20,7 @@ var App = require('app');
 
 App.ToggleContextComponent = Em.Component.extend({
   didInsertElement:function () {
-    var fileRow = this.$().parents('.file-row'),
+    var fileRow = this.$().parents('tr'),
         beforeHandler = Ember.run.bind(this, this.setContext),
         itemHandler = Ember.run.bind(this, this.itemHandler);
 
@@ -35,14 +35,14 @@ App.ToggleContextComponent = Em.Component.extend({
   setContext:function(e) {
     if (this.get('targetObject.isMoving')) {
       return false;
-    };
+    }
     this.set('targetObject.parentController.targetContextMenu',this.get('targetObject'));
     return true;
   },
   itemHandler:function (t,e) {
     if (e.target.dataset.disabled) {
       return false;
-    };
+    }
   },
   openOnClick:function (e) {
     if($(e.target).is('td') || $(e.target).hasClass('allow-open')){

+ 5 - 5
contrib/views/files/src/main/resources/ui/app/components/uploader.js

@@ -40,8 +40,8 @@ App.FileUploaderComponent = Ember.Component.extend({
         var label = this.get('value').replace(/\\/g, '/').replace(/.*\//, '');
         var log = numFiles > 1 ? numFiles + ' files selected' : label;
 
-        this.set('parentView.controlInput.value',log)
-        this.set('parentView.files',files)
+        this.set('parentView.controlInput.value',log);
+        this.set('parentView.files',files);
 
       }.observes('files')
     });
@@ -61,10 +61,10 @@ App.FileUploaderComponent = Ember.Component.extend({
           uploadBtn.start();
           uploader.on('progress',function (e) {
             uploadBtn.setProgress(e.percent/100);
-          })
+          });
           uploader.upload(file,{path:path}).finally(Em.run.bind(this,reset));
         }
-      };
+      }
     },
     clear:function () {
       this.set('fileInput.files',null);
@@ -99,7 +99,7 @@ App.FileUploaderComponent = Ember.Component.extend({
       if (!Ember.isEmpty(input.files)) {
         this.set('files', input.files);
       }
-    },
+    }
   }),
   controlInput:Ember.TextField.create({
     readonly:true,

+ 8 - 39
contrib/views/files/src/main/resources/ui/app/components/chmodInput.js → contrib/views/files/src/main/resources/ui/app/controllers/chmodModal.js

@@ -23,16 +23,15 @@ var _permissionsProp = function(n, l) {
     if (arguments.length > 1) {
       this.set('permissions', this.replaceAt(n,(val)?l:'-'));
       return val;
-    };
+    }
     return this.get('permissions')[n]===l;
-  }
-}
+  };
+};
 
-App.ChmodInputComponent = Em.Component.extend({
-  layoutName:'components/chmodInput',
-  tagName:'tr',
-  classNames:"chmod-row",
-  file:null,
+App.ChmodModalController = Em.ObjectController.extend({
+  needs:['files'],
+  classNames:'chmod-row',
+  file:Em.computed.alias('content'),
   permissions:Em.computed.alias('file.permission'),
   usrR:_permissionsProp(1, 'r').property('permissions'),
   usrW:_permissionsProp(2, 'w').property('permissions'),
@@ -44,36 +43,6 @@ App.ChmodInputComponent = Em.Component.extend({
   otrW:_permissionsProp(8, 'w').property('permissions'),
   otrE:_permissionsProp(9, 'x').property('permissions'),
   replaceAt:function (index,p) {
-    var perm = this.get('permissions');
-    var newPerm = perm.substr(0, index) + p + perm.substr(index + p.length);
-    return newPerm;
-  },
-  markActive:function () {
-    if (this.get('isVisible')) {
-      this.$('.btn-chmod').each(function () {
-        if ($(this).children('input').is(':checked')) {
-          $(this).addClass('active');
-        } else {
-          $(this).removeClass('active');
-        }
-      });
-    }
-  }.observes('chVisible'),
-  showModal:function () {
-    this.$('.chmodal').modal('toggle');
-  }.observes('chVisible'),
-  actions:{
-    confirm:function (r) {
-      this.sendAction('confirm',r);
-      this.set('chVisible',false);
-    },
-    close:function () {
-      var file = this.get('file');
-      var diff = file.changedAttributes();
-      if (diff.permission) {
-        file.set('permission',diff.permission[0]);
-      };
-      this.set('chVisible',false);
-    }
+    return this.get('permissions').substr(0, index) + p + perm.substr(index + p.length);;
   }
 });

+ 2 - 2
contrib/views/files/src/main/resources/ui/app/controllers/error.js

@@ -21,7 +21,7 @@ App.ErrorController = Ember.ObjectController.extend({
     toggleStackTrace:function () {
       var value = this.get('isExpanded');
       this.set('isExpanded', !value);
-    },
+    }
   },
 
   isExpanded: false,
@@ -45,5 +45,5 @@ App.ErrorController = Ember.ObjectController.extend({
       trace = json.trace;
     }
     return trace;
-  }.property('content'),
+  }.property('content')
 });

+ 4 - 19
contrib/views/files/src/main/resources/ui/app/controllers/file.js

@@ -19,10 +19,6 @@
 var App = require('app');
 
 App.FileController = Ember.ObjectController.extend({
-  init:function () {
-    this.set('content.selected', false);
-    this._super();
-  },
   actions:{
     download:function (option) {
       if (this.get('content.readAccess')) {
@@ -32,7 +28,7 @@ App.FileController = Ember.ObjectController.extend({
       }
     },
     showChmod:function () {
-      this.toggleProperty('chmodVisible',true);
+      this.send('showChmodModal',this.get('content'));
     },
     rename:function (opt,name) {
       var file = this.get('content'),
@@ -51,12 +47,6 @@ App.FileController = Ember.ObjectController.extend({
     editName:function () {
       this.set('isRenaming',true);
     },
-    chmod:function (r) {
-      var record = this.get('content');
-      this.store
-        .chmod(record)
-        .then(null,Em.run.bind(this,this.chmodErrorCallback,record));
-    },
     open:function (file) {
       if (!this.get('content.readAccess')) {
         return false;
@@ -88,9 +78,9 @@ App.FileController = Ember.ObjectController.extend({
     var thisFile = this.get('content.id');
     return movingFile === thisFile;
   }.property('parentController.movingFile'),
-  
+
   setSelected:function (controller,observer) {
-    this.set('selected',this.get(observer))
+    this.set('selected',this.get(observer));
   }.observes('content.selected'),
 
   renameSuccessCallback:function (record,error) {
@@ -98,13 +88,8 @@ App.FileController = Ember.ObjectController.extend({
     this.sendAlert(error);
   },
 
-  chmodErrorCallback:function (record,error) {
-    record.rollback();
-    this.sendAlert({message:'Permissions change failed'});
-  },
-
   deleteErrorCallback:function (record,error) {
-    this.parentController.model.pushRecord(record);
+    this.get('parentController.model').pushRecord(record);
     this.send('showAlert',error);
   },
 

+ 28 - 6
contrib/views/files/src/main/resources/ui/app/controllers/files.js

@@ -21,10 +21,11 @@ var bind = Ember.run.bind;
 
 App.FilesController = Ember.ArrayController.extend({
   actions:{
-    moveFile:function (opt,file) {
-      var src,
+    moveFile:function (opt,fileArg) {
+      var src, title,
+          file = fileArg || this.get('selectedFiles.firstObject'),
           moving = this.get('movingFile');
-      file = file || this.get('selectedFiles.firstObject');
+
       if (opt == 'cut') {
         src = file.toJSON({includeId: true});
         src = Em.merge(src,{name:file.get('name'),path:file.get('path')});
@@ -45,7 +46,7 @@ App.FilesController = Ember.ArrayController.extend({
     },
     renameDir:function (path,newName) {
       var _this = this,
-          basedir = path.substring(0,path.lastIndexOf('/')+1),
+          basedir = path.substring(0,path.lastIndexOf('/')+1);
           newPath = basedir + newName;
 
       if (path === newPath) {
@@ -108,11 +109,19 @@ App.FilesController = Ember.ArrayController.extend({
         this.set('sortAscending',true);
       }
     },
+    confirmChmod:function (file) {
+      this.store
+        .chmod(file)
+        .then(null,Em.run.bind(this,this.chmodErrorCallback,file));
+    },
     clearSearchField:function () {
       this.set('searchString','');
     }
   },
   init:function () {
+    if (App.testing) {
+      return this._super();
+    }
     var controller = this;
     var adapter = controller.store.adapterFor('file');
     var url = adapter.buildURL('upload');
@@ -148,7 +157,7 @@ App.FilesController = Ember.ArrayController.extend({
     return this.get('content').filterBy('selected', true);
   }.property('content.@each.selected'),
   canConcat:function () {
-    return this.get('selectedFiles').filterProperty('isDirectory').get('length')==0;
+    return this.get('selectedFiles').filterProperty('isDirectory').get('length')===0;
   }.property('selectedFiles.length'),
 
   searchString:'',
@@ -173,11 +182,24 @@ App.FilesController = Ember.ArrayController.extend({
 
   deleteErrorCallback:function (record,error) {
     this.model.pushRecord(record);
-    this.send('showAlert',error);
+    this.throwAlert(error);
+  },
+
+  chmodErrorCallback:function (record,error) {
+    record.rollback();
+    this.throwAlert({message:'Permissions change failed'});
   },
 
   throwAlert:function (error) {
     this.send('showAlert',error);
+  },
+
+  showSpinner:function () {
+    this.set('isLoadingFiles',true);
+  },
+
+  hideSpinner:function () {
+    this.set('isLoadingFiles',false);
   }
 });
 

+ 1 - 6
contrib/views/files/src/main/resources/ui/app/controllers/filesAlert.js

@@ -20,11 +20,6 @@ App.FilesAlertController = App.ErrorController.extend({
   content:null,
   output:function () {
     var error = this.get('content'),output;
-    if (error instanceof Em.Error) {
-      output = error;
-    } else {
-      output = {status:error.status, message:error.statusText||error.message};
-    };
-    return output;
+    return (error instanceof Em.Error)?error:{status:error.status, message:error.statusText||error.message};
   }.property('content')
 });

+ 3 - 2
contrib/views/files/src/main/resources/ui/app/initialize.js

@@ -30,6 +30,7 @@ require('templates/application');
 require('templates/index');
 require('templates/files');
 require('templates/error');
+require('templates/modal/chmod');
 require('templates/util/errorRow');
 require('templates/util/fileRow');
 
@@ -39,7 +40,6 @@ require('templates/components/deletePopover');
 require('templates/components/mkdirInput');
 require('templates/components/contextMenu');
 require('templates/components/deleteBulk');
-require('templates/components/chmodInput');
 
 //////////////////////////////////
 // Models
@@ -55,6 +55,7 @@ require('controllers/files');
 require('controllers/file');
 require('controllers/error');
 require('controllers/filesAlert');
+require('controllers/chmodModal');
 
 /////////////////////////////////
 // Components
@@ -71,7 +72,6 @@ require('components/popoverDelete');
 require('components/bulkCheckbox');
 require('components/mkdirInput');
 require('components/toggleContext');
-require('components/chmodInput');
 
 /////////////////////////////////
 // Views
@@ -79,6 +79,7 @@ require('components/chmodInput');
 
 require('views/file');
 require('views/filesAlert');
+require('views/modalChmod');
 
 /////////////////////////////////
 // Routes

+ 1 - 1
contrib/views/files/src/main/resources/ui/app/models/file.js

@@ -45,7 +45,7 @@ App.File = DS.Model.extend({
     return splitpath.get(splitpath.length-1);
   }.property('path'),
   date:function () {
-    return parseInt(moment(this.get('modificationTime')).format('X'))
+    return parseInt(moment(this.get('modificationTime')).format('X'));
   }.property('modificationTime'),
   size: Em.computed.alias('len')
 });

+ 29 - 6
contrib/views/files/src/main/resources/ui/app/routes/file.js

@@ -28,12 +28,17 @@ App.FilesRoute = Em.Route.extend({
     refreshDir:function () {
       this.refresh();
     },
+    loading:function  (argument) {
+      var target = this.controllerFor('files');
+      target.showSpinner();
+      this.router.one('didTransition', target, 'hideSpinner');
+    },
     error:function (error,transition,e) {
       if (this.router._lookupActiveView('files')) {
         this.send('showAlert',error);
       } else {
         return true;
-      };
+      }
     },
     dirUp: function () {
       var currentPath = this.controllerFor('files').get('path');
@@ -42,7 +47,27 @@ App.FilesRoute = Em.Route.extend({
       return this.transitionTo('files',{queryParams: {path: target}});
     },
     willTransition:function (argument) {
-      this.send('removeAlert');
+      var hasModal = this.router._lookupActiveView('modal.chmod'),
+          hasAlert = this.router._lookupActiveView('files.alert');
+
+      Em.run.next(function(){
+        if (hasAlert) this.send('removeAlert');
+        if (hasModal) this.send('removeChmodModal');
+      }.bind(this));
+    },
+    showChmodModal:function (content) {
+      this.controllerFor('chmodModal').set('content',content);
+      this.render('modal.chmod',{
+        into:'files',
+        outlet:'modal',
+        controller:'chmodModal'
+      });
+    },
+    removeChmodModal:function () {
+      this.disconnectOutlet({
+        outlet: 'modal',
+        parentView: 'files'
+      });
     },
     showAlert:function (error) {
       this.controllerFor('filesAlert').set('content',error);
@@ -64,16 +89,14 @@ App.FilesRoute = Em.Route.extend({
     return this.store.listdir(path);
   },
   afterModel:function (model) {
-    var self = this;
-    var model = model;
     this.store.filter('file',function(file) {
       if (!model.contains(file)) {
         return true;
-      };
+      }
     }).then(function (files) {
       files.forEach(function (file) {
         file.store.unloadRecord(file);
-      })
+      });
     });
   }
 });

+ 7 - 1
contrib/views/files/src/main/resources/ui/app/styles/application.less

@@ -155,6 +155,12 @@
           }
         }
       }
+      .fa-spin {
+        -webkit-animation: spin 0.7s infinite linear;
+        -moz-animation: spin 2s infinite linear;
+        -o-animation: spin 2s infinite linear;
+        animation: spin 2s infinite linear;
+      }
       .chmod-row {
         &:hover > td {
           background-color: #fff;
@@ -224,7 +230,7 @@
         }
       }
     }
-  } 
+  }
 
 }
 

+ 1 - 1
contrib/views/files/src/main/resources/ui/app/templates/components/contextMenu.hbs

@@ -19,7 +19,7 @@
 {{#dropdown-wrap}}
 <div id="context-menu">
   <ul class="dropdown-menu dropdown-context compressed-context" role="menu">
-    {{#if view.target.content.isDirectory}} 
+    {{#if view.target.content.isDirectory}}
       <li {{bind-attr class="view.target.content.readAccess::disabled"}}><a tabindex="-1" href="#" {{action 'open'}}>Open folder</a></li>
     {{else}}
       <li {{bind-attr class="view.target.content.readAccess::disabled"}}><a tabindex="-1" href="#" {{action 'download'}}>Download</a></li>

+ 1 - 1
contrib/views/files/src/main/resources/ui/app/templates/components/mkdirInput.hbs

@@ -16,7 +16,7 @@
    limitations under the License.
 }}
 
-{{#unless isMkdir}} 
+{{#unless isMkdir}}
   <button type="button" {{action 'edit'}} {{bind-attr class=":btn :btn-default :btn-sm :pull-right :mkdirwrap"}}>
     <i class="fa fa-plus"></i> New directory
   </button>

+ 27 - 14
contrib/views/files/src/main/resources/ui/app/templates/files.hbs

@@ -18,11 +18,11 @@
 
 <div class="panel-default panel-files">
   <div class="panel-heading">
-    {{!-- BREADCRUMBS --}}  
+    {{!-- BREADCRUMBS --}}
     {{bread-crumbs path=path}}
-      
+
     <div class="um-section">
-    {{!-- UPLOADER --}}  
+    {{!-- UPLOADER --}}
     <div {{bind-attr class="isUploading::hide :pull-right" }}>
       <button {{action 'upload' 'close'}} type="button" class="close" aria-hidden="true">&times;</button>
       {{file-uploader path=path uploader=uploader class=" upload-area pull-right" alert='showAlert'}}
@@ -34,7 +34,7 @@
       </button>
     </div>
 
-    {{!-- MKDIR --}} 
+    {{!-- MKDIR --}}
     {{mkdir-input create="mkdir" path=path}}
 
     </div>
@@ -88,7 +88,7 @@
             </ul>
           </div>
         </th>
-        <th class="check"> 
+        <th class="check">
         {{#dropdown-wrap}}
           <div id="bulkDropdown" class="btn-group">
             <span class="input-group-addon">
@@ -167,7 +167,7 @@
           <td >
             <ul class="list-inline file-actions text-right">
               <li>
-                <a href="#" {{action 'moveFile' 'move'}} data-toggle="tooltip" data-placement="bottom" title="Paste"><i class="fa fa-clipboard fa-lg"></i></a>  
+                <a href="#" {{action 'moveFile' 'move'}} data-toggle="tooltip" data-placement="bottom" title="Paste"><i class="fa fa-clipboard fa-lg"></i></a>
               </li>
             </ul>
           </td>
@@ -177,17 +177,30 @@
         </tr>
       {{/if}}
       {{/unless}}
-      {{#each fileList itemController="file"}}
-        {{partial 'util/fileRow'}}
-      {{/each}}
+    </tbody>
+    {{#unless isLoadingFiles}}
+      {{cloaked-collection
+          cloakView="file"
+          content=fileList
+          itemController="file"
+          loadingHTML='<td colspan="8" class="text-center"><i class="fa fa-refresh"></i></td>'
+          tagName='tbody'
+          defaultHeight='47'}}
+    {{else}}
+      <tbody>
+        <td colspan="8" class="text-center"><i class="fa fa-refresh fa-spin"></i></td>
+      </tbody>
+    {{/unless}}
+    <tbody>
       {{#unless fileList}}
-      <tr>
-        <td colspan="8">
-          No files
-        </td>
-      </tr>
+        <tr {{bind-attr class="isLoadingFiles:hide"}} >
+          <td colspan="8">
+            No files
+          </td>
+        </tr>
       {{/unless}}
     </tbody>
   </table>
   {{context-menu target=targetContextMenu}}
+  {{outlet modal}}
 </div>

+ 97 - 0
contrib/views/files/src/main/resources/ui/app/templates/modal/chmod.hbs

@@ -0,0 +1,97 @@
+{{!
+   Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+}}
+
+
+<div class="modal chmodal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static">
+  <div class="modal-dialog modal-sm">
+    <div class="modal-content">
+      <div class="modal-header">
+        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
+        <h4 class="modal-title">Edit permission</h4>
+      </div>
+      <div class="modal-body">
+
+        <form class="form-horizontal" role="form">
+          <div class="form-group">
+            <label class="col-sm-2 control-label">User</label>
+            <div class="col-sm-10">
+              <div class="btn-group" data-toggle="buttons">
+                <label {{bind-attr class=":btn :btn-sm usrR:btn-primary:btn-default :btn-chmod" }} >
+                  {{input type="checkbox" checked=usrR}} <span>Read</span>
+                </label>
+                <label {{bind-attr class=":btn :btn-sm usrW:btn-primary:btn-default :btn-chmod" }} >
+                  {{input type="checkbox" checked=usrW}} <span>Write</span>
+                </label>
+                <label {{bind-attr class=":btn :btn-sm usrE:btn-primary:btn-default :btn-chmod" }} >
+                  {{input type="checkbox" checked=usrE}} <span>Execute</span>
+                </label>
+              </div>
+            </div>
+          </div>
+          <div class="form-group">
+            <label class="col-sm-2 control-label">Group</label>
+            <div class="col-sm-10">
+              <div class="btn-group" data-toggle="buttons">
+                <label {{bind-attr class=":btn :btn-sm grpR:btn-primary:btn-default :btn-chmod" }} >
+                  {{input type="checkbox" checked=grpR}} <span>Read</span>
+                </label>
+                <label {{bind-attr class=":btn :btn-sm grpW:btn-primary:btn-default :btn-chmod" }} >
+                  {{input type="checkbox" checked=grpW}} <span>Write</span>
+                </label>
+                <label {{bind-attr class=":btn :btn-sm grpE:btn-primary:btn-default :btn-chmod" }} >
+                  {{input type="checkbox" checked=grpE}} <span>Execute</span>
+                </label>
+              </div>
+            </div>
+          </div>
+          <div class="form-group">
+            <label class="col-sm-2 control-label">Other</label>
+            <div class="col-sm-10">
+              <div class="btn-group" data-toggle="buttons">
+                <label {{bind-attr class=":btn :btn-sm otrR:btn-primary:btn-default :btn-chmod" }} >
+                  {{input type="checkbox" checked=otrR}} <span>Read</span>
+                </label>
+                <label {{bind-attr class=":btn :btn-sm otrW:btn-primary:btn-default :btn-chmod" }} >
+                  {{input type="checkbox" checked=otrW}} <span>Write</span>
+                </label>
+                <label {{bind-attr class=":btn :btn-sm otrE:btn-primary:btn-default :btn-chmod" }} >
+                  {{input type="checkbox" checked=otrE}} <span>Execute</span>
+                </label>
+              </div>
+            </div>
+          </div>
+
+          <div class="form-group">
+            <div class="col-sm-offset-2 col-sm-10">
+              <div class="checkbox">
+                <label>
+                  {{input type="checkbox"}} <span> Modify recursively</span>
+                </label>
+              </div>
+            </div>
+          </div>
+        </form>
+
+      </div>
+      <div class="modal-footer">
+        <button type="button" class="btn btn-default" {{action 'close' target="view"}}>Close</button>
+        <button type="button" class="btn btn-primary" {{action 'confirm' target="view"}}>Save changes</button>
+      </div>
+    </div>
+  </div>
+</div>

+ 0 - 2
contrib/views/files/src/main/resources/ui/app/templates/util/errorRow.hbs

@@ -35,5 +35,3 @@
     {{/if}}
   {{/if}}
 </div>
-  
-

+ 3 - 14
contrib/views/files/src/main/resources/ui/app/templates/util/fileRow.hbs

@@ -28,17 +28,11 @@
     {{#rename-input fileBinding='content' confirm='rename' isRenaming=isRenaming}}
       <div class="file-name allow-open">
         <span>
-        {{#if content.readAccess}}
           <a {{action 'open'}}>
             <strong>
               {{content.name}}
             </strong>
           </a>
-          {{else}}
-            <strong>
-              {{content.name}}
-            </strong>
-          {{/if}}
         </span>
         <span class="help-block mod-time allow-open">
           <small class='allow-open'>
@@ -63,18 +57,15 @@
         <li>
         {{#if content.readAccess}}
           {{#if content.isDirectory}}
-            <a href="#" {{action 'download' 'zip'}} data-toggle="tooltip" data-placement="bottom" title="Download ZIP"><i class="fa fa-archive fa-fw fa-lg"></i></a>
+            <a href="#" {{action 'download' 'zip'}} data-toggle="tooltip" data-placement="bottom" title="Download zip"><i class="fa fa-archive fa-fw fa-lg"></i></a>
           {{else}}
-            <a href="#" {{action 'download' 'browse'}} data-toggle="tooltip" data-placement="bottom" title="Download File"><i class="fa fa-download fa-fw fa-lg"></i></a>
+            <a href="#" {{action 'download' 'browse'}} data-toggle="tooltip" data-placement="bottom" title="Download"><i class="fa fa-download fa-fw fa-lg"></i></a>
           {{/if}}
         {{/if}}
         </li>
         <li>
-          <a href="#" {{action 'moveFile' 'cut' this.content}} data-toggle="tooltip" data-placement="bottom" title="Move"><i class="fa fa-level-down fa-rotate-270 fa-fw fa-lg"></i></span></a>  
+          <a href="#" {{action 'moveFile' 'cut' this.content}} data-toggle="tooltip" data-placement="bottom" title="Move"><i class="fa fa-level-down fa-rotate-270 fa-fw fa-lg"></i></a>
         </li>
-        {{!-- <li>
-          <a {{action 'rename' 'edit'}} data-toggle="tooltip" data-placement="bottom" title="Rename"><i class="fa fa-edit fa-lg"></i></a>
-        </li> --}}
         <li>{{popover-delete confirm="deleteFile"}}</li>
       </ul>
     {{/unless}}
@@ -88,5 +79,3 @@
   {{toggle-context}}
   </td>
 </tr>
-{{chmod-input chVisible=chmodVisible file=content confirm="chmod"}}
-        

+ 7 - 27
contrib/views/files/src/main/resources/ui/app/views/file.js

@@ -18,32 +18,12 @@
 
 var App = require('app');
 
-App.FilesView = Em.View.extend({
-    templateName: 'files',
-    didInsertElement:function () {
-      this.scheduleRebind();
-    },
-    scheduleRebind:function () {
-      Em.run.scheduleOnce('render', this, this.get('reBindTooltips'));
-    },
-    reBindTooltips:function () {
-      this.$().tooltip({selector:'[data-toggle=tooltip]'});
-    },
-    renameInputView: Em.TextField.extend({
-      controller:null,
-      didInsertElement:function (argument) {
-        var element = $(this.get('element'));
-        element.focus().val(this.value)
-      },
-      keyUp: function(e) {
-        var target = this.get('targetObject');
-        if (e.keyCode==13) {
-          return target.send('rename', 'confirm');
-        };
+Em.CloakedView.reopen({
+  classNames:['file-row'],
+  classNameBindings:['_containedView.controller.isMoving:isMoving']
+});
 
-        if (e.keyCode==27) {
-          return target.send('rename', 'cancel');
-        };
-      }
-    })
+App.FileView = Em.View.extend({
+  templateName: 'util/fileRow',
+  tagName:'tr'
 });

+ 32 - 0
contrib/views/files/src/main/resources/ui/app/views/files.js

@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+
+App.FilesView = Em.View.extend({
+    templateName: 'files',
+    didInsertElement:function () {
+      this.scheduleRebind();
+    },
+    scheduleRebind:function () {
+      Em.run.scheduleOnce('render', this, this.get('reBindTooltips'));
+    },
+    reBindTooltips:function () {
+      this.$().tooltip({selector:'[data-toggle=tooltip]'});
+    }
+});

+ 50 - 0
contrib/views/files/src/main/resources/ui/app/views/modalChmod.js

@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+
+App.ModalChmodView = Em.View.extend({
+  actions:{
+    confirm:function (file) {
+      this.get('controller.controllers.files').send('confirmChmod',this.get('controller.file'));
+      this.$('.chmodal').modal('hide');
+    },
+    close:function () {
+      var file = this.get('controller.file');
+      var diff = file.changedAttributes();
+      if (diff.permission) {
+        file.set('permission',diff.permission[0]);
+      }
+      this.$('.chmodal').modal('hide');
+    }
+  },
+  didInsertElement:function (argument) {
+    this.$('.btn-chmod').each(function () {
+      $(this).toggleClass('active',$(this).children('input').is(':checked'));
+    });
+
+    this.$('.chmodal').modal();
+    this.$('.chmodal').on('hidden.bs.modal',function  () {
+      this.get('controller.controllers.files').send('removeChmodModal');
+    }.bind(this));
+  },
+  willClearRender:function  () {
+    this.$('.chmodal').off('hidden.bs.modal');
+    this.$('.chmodal').modal('hide');
+  }
+});

+ 2 - 1
contrib/views/files/src/main/resources/ui/config.coffee

@@ -27,7 +27,8 @@ exports.config =
       defaultExtension: 'js'
       joinTo: 
         'javascripts/app.js': /^app/
-        'javascripts/vendor.js': /^bower_components|vendor/
+        'javascripts/vendor.js': /^bower_components|vendor/,
+        'javascripts/test.js': /^test(\/|\\)(?!vendor)/
 
     stylesheets:
       defaultExtension: 'css'

+ 8 - 4
contrib/views/files/src/main/resources/ui/package.json

@@ -12,6 +12,7 @@
     "node": "~0.6.10 || 0.8 || 0.9"
   },
   "scripts": {
+    "test": "node_modules/phantomjs/bin/phantomjs runner.js public/tests.html",
     "start": "brunch watch --server",
     "preinstall": "chmod +x node/npm/bin/node-gyp-bin/node-gyp",
     "postinstall" : "bash node/with_new_path.sh node node_modules/.bin/bower --allow-root install"
@@ -27,12 +28,15 @@
     "ember-precompiler-brunch": ">= 1.5.0",
     "less-brunch": "^1.7.2"
   },
-  "devDependencies": {},
+ "devDependencies": {
+    "phantomjs": "^1.9.2",
+    "karma": "*",
+    "karma-qunit": "*",
+    "karma-phantomjs-launcher": "~0.1.2"
+  },
   "ignore": [
     "**/.*",
     "node_modules",
-    "bower_components",
-    "test",
-    "tests"
+    "bower_components"
   ]
 }

+ 136 - 0
contrib/views/files/src/main/resources/ui/runner.js

@@ -0,0 +1,136 @@
+/*
+ * PhantomJS Runner QUnit Plugin (List Tests) 1.2.0
+ *
+ * PhantomJS binaries: http://phantomjs.org/download.html
+ * Requires PhantomJS 1.6+ (1.7+ recommended)
+ *
+ * Run with:
+ *   phantomjs runner-list.js [url-of-your-qunit-testsuite]
+ *
+ * e.g.
+ *   phantomjs runner-list.js http://localhost/qunit/test/index.html
+ */
+
+/*global phantom:false, require:false, console:false, window:false, QUnit:false */
+
+(function() {
+  'use strict';
+
+  var url, page, timeout,
+    args = require('system').args;
+
+  // arg[0]: scriptName, args[1...]: arguments
+  if (args.length < 2 || args.length > 3) {
+    console.error('Usage:\n  phantomjs runner-list.js [url-of-your-qunit-testsuite] [timeout-in-seconds]');
+    phantom.exit(1);
+  }
+
+  url = args[1];
+  page = require('webpage').create();
+  if (args[2] !== undefined) {
+    timeout = parseInt(args[2], 10);
+  }
+
+  // Route `console.log()` calls from within the Page context to the main Phantom context (i.e. current `this`)
+  page.onConsoleMessage = function(msg) {
+    console.log(msg);
+  };
+
+  page.onInitialized = function() {
+    page.evaluate(addLogging);
+  };
+
+  page.onCallback = function(message) {
+    var result,
+      failed;
+
+    if (message) {
+      if (message.name === 'QUnit.done') {
+        result = message.data;
+        failed = !result || !result.total || result.failed;
+
+        if (!result.total) {
+          console.error('No tests were executed. Are you loading tests asynchronously?');
+        }
+
+        phantom.exit(failed ? 1 : 0);
+      }
+    }
+  };
+
+  page.open(url, function(status) {
+    if (status !== 'success') {
+      console.error('Unable to access network: ' + status);
+      phantom.exit(1);
+    } else {
+      // Cannot do this verification with the 'DOMContentLoaded' handler because it
+      // will be too late to attach it if a page does not have any script tags.
+      var qunitMissing = page.evaluate(function() { return (typeof QUnit === 'undefined' || !QUnit); });
+      if (qunitMissing) {
+        console.error('The `QUnit` object is not present on this page.');
+        phantom.exit(1);
+      }
+
+      // Set a timeout on the test running, otherwise tests with async problems will hang forever
+      if (typeof timeout === 'number') {
+        setTimeout(function() {
+          console.error('The specified timeout of ' + timeout + ' seconds has expired. Aborting...');
+          phantom.exit(1);
+        }, timeout * 1000);
+      }
+
+      // Do nothing... the callback mechanism will handle everything!
+    }
+  });
+
+  function addLogging() {
+    window.document.addEventListener('DOMContentLoaded', function() {
+      var currentTestAssertions = [];
+
+      QUnit.log(function(details) {
+        var response;
+
+        console.log((details.result ? "? ": "? ") + details.message);
+
+        if (!details.result) {
+          response = details.message || '';
+
+          if (typeof details.expected !== 'undefined') {
+            if (response) {
+              response += ', ';
+            }
+
+            response += 'expected: ' + details.expected + ', but was: ' + details.actual;
+          }
+
+          if (details.source) {
+            response += '\n' + details.source;
+          }
+
+          console.log('    Failed assertion: ' + response);
+        }
+      });
+
+      QUnit.moduleStart(function( details ) {
+        if (details.name) {
+          console.log('\n' + details.name);
+        }
+      });
+
+      QUnit.testStart(function(result) {
+        console.log('\n' + result.name);
+      });
+
+      QUnit.done(function(result) {
+        console.log('\n' + 'Took ' + result.runtime +  'ms to run ' + result.total + ' tests. ' + result.passed + ' passed, ' + result.failed + ' failed.');
+
+        if (typeof window.callPhantom === 'function') {
+          window.callPhantom({
+            'name': 'QUnit.done',
+            'data': result
+          });
+        }
+      });
+    }, false);
+  }
+})();

+ 0 - 17
contrib/views/files/src/main/resources/ui/test/spec.coffee

@@ -1,17 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Write your [mocha](http://visionmedia.github.com/mocha/) specs here.

+ 32 - 0
contrib/views/files/src/main/resources/ui/test/unit/controllers/files_test.js

@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+moduleFor('controller:files', 'App.FilesController', {
+  needs:['controller:file']
+});
+
+test('Property "isRootDir" is true when in root directory', function () {
+
+  var cntr = this.subject();
+  Ember.run(function() {
+    equal(cntr.get('path')==='/', cntr.get('isRootDir') , 'isRootDir is set right');
+  });
+
+
+});

+ 436 - 0
contrib/views/files/src/main/resources/ui/vendor/js/ember-cloaking.js

@@ -0,0 +1,436 @@
+(function () {
+
+  /**
+    Display a list of cloaked items
+
+    @class CloakedCollectionView
+    @extends Ember.CollectionView
+    @namespace Ember
+  **/
+  Ember.CloakedCollectionView = Ember.CollectionView.extend({
+    topVisible: null,
+    bottomVisible: null,
+    offsetFixedTopElement: null,
+    offsetFixedBottomElement: null,
+//
+
+
+    init: function() {
+      var cloakView = this.get('cloakView'),
+          idProperty = this.get('idProperty'),
+          uncloakDefault = !!this.get('uncloakDefault');
+
+      // Set the slack ratio differently to allow for more or less slack in preloading
+      var slackRatio = parseFloat(this.get('slackRatio'));
+      if (!slackRatio) { this.set('slackRatio', 1.0); }
+
+      this.set('itemViewClass', Ember.CloakedView.extend({
+        classNames: [cloakView + '-cloak'],
+        cloaks: cloakView,
+        preservesContext: this.get('preservesContext') === "true",
+        cloaksController: this.get('itemController'),
+        defaultHeight: this.get('defaultHeight'),
+
+        init: function() {
+          this._super();
+
+          if (idProperty) {
+            this.set('elementId', cloakView + '-cloak-' + this.get('content.' + idProperty));
+          }
+          if (uncloakDefault) {
+            this.uncloak();
+          } else {
+            this.cloak();
+          }
+        }
+      }));
+
+      this._super();
+      Ember.run.next(this, 'scrolled');
+    },
+
+
+    /**
+      If the topmost visible view changed, we will notify the controller if it has an appropriate hook.
+
+      @method _topVisibleChanged
+      @observes topVisible
+    **/
+    _topVisibleChanged: Ember.observer('topVisible', function() {
+      var controller = this.get('controller');
+      if (controller.topVisibleChanged) { controller.topVisibleChanged(this.get('topVisible')); }
+    }),
+
+    /**
+      If the bottommost visible view changed, we will notify the controller if it has an appropriate hook.
+
+      @method _bottomVisible
+      @observes bottomVisible
+    **/
+    _bottomVisible: Ember.observer('bottomVisible', function() {
+      var controller = this.get('controller');
+      if (controller.bottomVisibleChanged) { controller.bottomVisibleChanged(this.get('bottomVisible')); }
+    }),
+
+    /**
+      Binary search for finding the topmost view on screen.
+
+      @method findTopView
+      @param {Array} childViews the childViews to search through
+      @param {Number} windowTop The top of the viewport to search against
+      @param {Number} min The minimum index to search through of the child views
+      @param {Number} max The max index to search through of the child views
+      @returns {Number} the index into childViews of the topmost view
+    **/
+    findTopView: function(childViews, viewportTop, min, max) {
+      if (max < min) { return min; }
+
+      var wrapperTop = this.get('wrapperTop')>>0;
+
+      while(max>min){
+        var mid = Math.floor((min + max) / 2),
+            // in case of not full-window scrolling
+            $view = childViews[mid].$(),
+            viewBottom = $view.position().top + wrapperTop + $view.height();
+
+        if (viewBottom > viewportTop) {
+          max = mid-1;
+        } else {
+          min = mid+1;
+        }
+      }
+
+      return min;
+    },
+
+
+    /**
+      Determine what views are onscreen and cloak/uncloak them as necessary.
+
+      @method scrolled
+    **/
+    scrolled: function() {
+      if (!this.get('scrollingEnabled')) { return; }
+
+      var childViews = this.get('childViews');
+      if ((!childViews) || (childViews.length === 0)) { return; }
+
+      var self = this,
+          toUncloak = [],
+          onscreen = [],
+          onscreenCloaks = [],
+          // calculating viewport edges
+          $w = Ember.$(window),
+          windowHeight = this.get('wrapperHeight') || ( window.innerHeight ? window.innerHeight : $w.height() ),
+          windowTop = this.get('wrapperTop') || $w.scrollTop(),
+          slack = Math.round(windowHeight * this.get('slackRatio')),
+          viewportTop = windowTop - slack,
+          windowBottom = windowTop + windowHeight,
+          viewportBottom = windowBottom + slack,
+          topView = this.findTopView(childViews, viewportTop, 0, childViews.length-1),
+          bodyHeight = this.get('wrapperHeight') ? this.$().height() : Ember.$('body').height(),
+          bottomView = topView,
+          offsetFixedTopElement = this.get('offsetFixedTopElement'),
+          offsetFixedBottomElement = this.get('offsetFixedBottomElement');
+
+      if (windowBottom > bodyHeight) { windowBottom = bodyHeight; }
+      if (viewportBottom > bodyHeight) { viewportBottom = bodyHeight; }
+
+      if (offsetFixedTopElement) {
+        windowTop += (offsetFixedTopElement.outerHeight(true) || 0);
+      }
+
+      if (offsetFixedBottomElement) {
+        windowBottom -= (offsetFixedBottomElement.outerHeight(true) || 0);
+      }
+
+      // Find the bottom view and what's onscreen
+      while (bottomView < childViews.length) {
+        var view = childViews[bottomView],
+          $view = view.$(),
+          // in case of not full-window scrolling
+          scrollOffset = this.get('wrapperTop') || 0,
+          viewTop = $view.offset().top + scrollOffset,
+          viewBottom = viewTop + $view.height();
+
+        if (viewTop > viewportBottom) { break; }
+        toUncloak.push(view);
+
+        if (viewBottom > windowTop && viewTop <= windowBottom) {
+          onscreen.push(view.get('content'));
+          onscreenCloaks.push(view);
+        }
+
+        bottomView++;
+      }
+      if (bottomView >= childViews.length) { bottomView = childViews.length - 1; }
+
+      // If our controller has a `sawObjects` method, pass the on screen objects to it.
+      var controller = this.get('controller');
+      if (onscreen.length) {
+        this.setProperties({topVisible: onscreen[0], bottomVisible: onscreen[onscreen.length-1]});
+        if (controller && controller.sawObjects) {
+          Em.run.schedule('afterRender', function() {
+            controller.sawObjects(onscreen);
+          });
+        }
+      } else {
+        this.setProperties({topVisible: null, bottomVisible: null});
+      }
+
+      var toCloak = childViews.slice(0, topView).concat(childViews.slice(bottomView+1));
+
+      this._uncloak = toUncloak;
+      if(this._nextUncloak){
+        Em.run.cancel(this._nextUncloak);
+        this._nextUncloak = null;
+      }
+
+      Em.run.schedule('afterRender', this, function() {
+        onscreenCloaks.forEach(function (v) {
+          if(v && v.uncloak) {
+            v.uncloak();
+          }
+        });
+        toCloak.forEach(function (v) { v.cloak(); });
+        if (self._nextUncloak) { Em.run.cancel(self._nextUncloak); }
+        self._nextUncloak = Em.run.later(self, self.uncloakQueue,50);
+      });
+
+      for (var j=bottomView; j<childViews.length; j++) {
+        var checkView = childViews[j];
+        if (!checkView._containedView) {
+          if (!checkView.get('loading')) {
+            checkView.$().html(this.get('loadingHTML') || "Loading...");
+          }
+          return;
+        }
+      }
+
+    },
+
+    uncloakQueue: function(){
+      var maxPerRun = 3, delay = 50, processed = 0, self = this;
+
+      if(this._uncloak){
+        while(processed < maxPerRun && this._uncloak.length>0){
+          var view = this._uncloak.shift();
+          if(view && view.uncloak && !view._containedView){
+            Em.run.schedule('afterRender', view, view.uncloak);
+            processed++;
+          }
+        }
+        if(this._uncloak.length === 0){
+          this._uncloak = null;
+        } else {
+          Em.run.schedule('afterRender', self, function(){
+            if(self._nextUncloak){
+              Em.run.cancel(self._nextUncloak);
+            }
+            self._nextUncloak = Em.run.next(self, function(){
+              if(self._nextUncloak){
+                Em.run.cancel(self._nextUncloak);
+              }
+              self._nextUncloak = Em.run.later(self,self.uncloakQueue,delay);
+            });
+          });
+        }
+      }
+    },
+
+    scrollTriggered: function() {
+      Em.run.scheduleOnce('afterRender', this, 'scrolled');
+    },
+
+    _startEvents: Ember.on('didInsertElement', function() {
+      if (this.get('offsetFixed')) {
+        Em.warn("Cloaked-collection's `offsetFixed` is deprecated. Use `offsetFixedTop` instead.");
+      }
+
+      var self = this,
+          offsetFixedTop = this.get('offsetFixedTop') || this.get('offsetFixed'),
+          offsetFixedBottom = this.get('offsetFixedBottom'),
+          onScrollMethod = function() {
+            Ember.run.debounce(self, 'scrollTriggered', 10);
+          };
+
+      if (offsetFixedTop) {
+        this.set('offsetFixedTopElement', Ember.$(offsetFixedTop));
+      }
+
+      if (offsetFixedBottom) {
+        this.set('offsetFixedBottomElement', Ember.$(offsetFixedBottom));
+      }
+
+      Ember.$(document).bind('touchmove.ember-cloak', onScrollMethod);
+      Ember.$(window).bind('scroll.ember-cloak', onScrollMethod);
+      this.addObserver('wrapperTop', self, onScrollMethod);
+      this.addObserver('wrapperHeight', self, onScrollMethod);
+      this.addObserver('content.@each', self, onScrollMethod);
+      this.scrollTriggered();
+
+      this.set('scrollingEnabled', true);
+    }),
+
+    cleanUp: function() {
+      Ember.$(document).unbind('touchmove.ember-cloak');
+      Ember.$(window).unbind('scroll.ember-cloak');
+      this.set('scrollingEnabled', false);
+    },
+
+    _endEvents: Ember.on('willDestroyElement', function() {
+      this.cleanUp();
+    })
+  });
+
+
+  /**
+    A cloaked view is one that removes its content when scrolled off the screen
+
+    @class CloakedView
+    @extends Ember.View
+    @namespace Ember
+  **/
+  Ember.CloakedView = Ember.View.extend({
+    attributeBindings: ['style'],
+
+    /**
+      Triggers the set up for rendering a view that is cloaked.
+
+      @method uncloak
+    */
+    uncloak: function() {
+      var state = this._state || this.state;
+      if (state !== 'inDOM' && state !== 'preRender') { return; }
+
+      if (!this._containedView) {
+        var model = this.get('content'),
+            controller = null,
+            container = this.get('container');
+
+        // Wire up the itemController if necessary
+        var controllerName = this.get('cloaksController');
+        if (controllerName) {
+          var controllerFullName = 'controller:' + controllerName,
+              factory = container.lookupFactory(controllerFullName),
+              parentController = this.get('controller');
+
+          // let ember generate controller if needed
+          if (factory === undefined) {
+            factory = Ember.generateControllerFactory(container, controllerName, model);
+
+            // inform developer about typo
+            Ember.Logger.warn('ember-cloaking: can\'t lookup controller by name "' + controllerFullName + '".');
+            Ember.Logger.warn('ember-cloaking: using ' + factory.toString() + '.');
+          }
+
+          controller = factory.create({
+            model: model,
+            parentController: parentController,
+            target: parentController
+          });
+        }
+        var createArgs = {},
+            target = controller || model;
+
+        if (this.get('preservesContext')) {
+          createArgs.content = target;
+        } else {
+          createArgs.context = target;
+        }
+        if (controller) { createArgs.controller = controller; }
+        this.setProperties({
+          style: null,
+          loading: false
+        });
+
+        this._containedView = this.createChildView(this.get('cloaks'), createArgs);
+        this.rerender();
+      }
+    },
+
+    /**
+      Removes the view from the DOM and tears down all observers.
+
+      @method cloak
+    */
+    cloak: function() {
+      var self = this;
+
+      if (this._containedView && (this._state || this.state) === 'inDOM') {
+        var style = 'height: ' + this.$().height() + 'px;';
+        this.set('style', style);
+        this.$().prop('style', style);
+
+        // We need to remove the container after the height of the element has taken
+        // effect.
+        Ember.run.schedule('afterRender', function() {
+          if(self._containedView){
+            self._containedView.remove();
+            self._containedView = null;
+          }
+        });
+      }
+    },
+
+    _removeContainedView: Ember.on('willDestroyElement', function(){
+      if(this._containedView){
+        this._containedView.remove();
+        this._containedView = null;
+      }
+      this._super();
+    }),
+
+    _setHeights: Ember.on('didInsertElement', function(){
+      if (!this._containedView) {
+        // setting default height
+        // but do not touch if height already defined
+        if(!this.$().height()){
+          var defaultHeight = 100;
+          if(this.get('defaultHeight')) {
+            defaultHeight = this.get('defaultHeight');
+          }
+
+          this.$().css('height', defaultHeight);
+        }
+      }
+    }),
+
+    /**
+      Render the cloaked view if applicable.
+
+      @method render
+    */
+    render: function(buffer) {
+      var containedView = this._containedView, self = this;
+
+      if (containedView && (containedView._state || containedView.state) !== 'inDOM') {
+        containedView.triggerRecursively('willInsertElement');
+        containedView.renderToBuffer(buffer);
+        containedView._transitionTo('inDOM');
+        Em.run.schedule('afterRender', function() {
+          if(self._containedView) {
+            self._containedView.triggerRecursively('didInsertElement');
+          }
+        });
+      }
+    }
+
+  });
+
+
+
+  Ember.Handlebars.registerHelper('cloaked-collection', function(options) {
+    var hash = options.hash,
+        types = options.hashTypes;
+
+    for (var prop in hash) {
+      if (types[prop] === 'ID') {
+        hash[prop + 'Binding'] = hash[prop];
+        delete hash[prop];
+      }
+    }
+    return Ember.Handlebars.helpers.view.call(this, Ember.CloakedCollectionView, options);
+  });
+
+})();

+ 4 - 0
pom.xml

@@ -223,6 +223,10 @@
             <exclude>contrib/views/files/src/main/resources/ui/node/**</exclude>
             <exclude>contrib/views/files/src/main/resources/ui/node_modules/**</exclude>
             <exclude>contrib/views/files/src/main/resources/ui/public/**</exclude>
+            <exclude>contrib/views/files/src/main/resources/ui/vendor/**</exclude>
+            <exclude>contrib/views/files/src/main/resources/ui/runner.js</exclude>
+            <exclude>contrib/views/files/src/main/resources/ui/app/assets/stylesheets/**</exclude>
+            <exclude>contrib/views/files/src/main/resources/ui/app/assets/javascripts/**</exclude>
             <exclude>contrib/views/jobs/src/main/resources/ui/.tmp/**</exclude>
             <exclude>contrib/views/jobs/src/main/resources/ui/**/bower_components/**</exclude>
             <exclude>contrib/views/jobs/src/main/resources/ui/dist/**</exclude>

部分文件因文件數量過多而無法顯示