nexus site path corrected
[portal.git] / ecomp-portal-FE / client / bower_components / lodash / test / asset / test-ui.js
1 ;(function(window) {
2   'use strict';
3
4   /** The base path of the lodash builds. */
5   var basePath = '../';
6
7   /** The lodash build to load. */
8   var build = (build = /build=([^&]+)/.exec(location.search)) && decodeURIComponent(build[1]);
9
10   /** The module loader to use. */
11   var loader = (loader = /loader=([^&]+)/.exec(location.search)) && decodeURIComponent(loader[1]);
12
13   /** The `ui` object. */
14   var ui = {};
15
16   /*--------------------------------------------------------------------------*/
17
18   /**
19    * Registers an event listener on an element.
20    *
21    * @private
22    * @param {Element} element The element.
23    * @param {string} eventName The name of the event.
24    * @param {Function} handler The event handler.
25    * @returns {Element} The element.
26    */
27   function addListener(element, eventName, handler) {
28     if (typeof element.addEventListener != 'undefined') {
29       element.addEventListener(eventName, handler, false);
30     } else if (typeof element.attachEvent != 'undefined') {
31       element.attachEvent('on' + eventName, handler);
32     }
33   }
34
35   /*--------------------------------------------------------------------------*/
36
37   // Initialize controls.
38   addListener(window, 'load', function() {
39     function eventHandler(event) {
40       var buildIndex = buildList.selectedIndex,
41           loaderIndex = loaderList.selectedIndex,
42           search = location.search.replace(/^\?|&?(?:build|loader)=[^&]*&?/g, '');
43
44       if (event.stopPropagation) {
45         event.stopPropagation();
46       } else {
47         event.cancelBubble = true;
48       }
49       location.href =
50         location.href.split('?')[0] + '?' +
51         (search ? search + '&' : '') +
52         'build=' + (buildIndex < 0 ? build : buildList[buildIndex].value) + '&' +
53         'loader=' + (loaderIndex < 0 ? loader : loaderList[loaderIndex].value);
54     }
55
56     function init() {
57       var toolbar = document.getElementById('qunit-testrunner-toolbar');
58       if (!toolbar) {
59         setTimeout(init, 15);
60         return;
61       }
62       toolbar.appendChild(span1);
63       toolbar.appendChild(span2);
64
65       buildList.selectedIndex = (function() {
66         switch (build) {
67           case 'lodash':            return 1;
68           case 'lodash-core-dev':   return 2;
69           case 'lodash-core':       return 3;
70           case 'lodash-dev':
71           case null:                return 0;
72         }
73         return -1;
74       }());
75
76       loaderList.selectedIndex = (function() {
77         switch (loader) {
78           case 'curl':      return 1;
79           case 'dojo':      return 2;
80           case 'requirejs': return 3;
81           case 'none':
82           case null:        return 0;
83         }
84         return -1;
85       }());
86
87       addListener(buildList, 'change', eventHandler);
88       addListener(loaderList, 'change', eventHandler);
89     }
90
91     var span1 = document.createElement('span');
92     span1.style.cssText = 'float:right';
93     span1.innerHTML =
94       '<label for="qunit-build">Build: </label>' +
95       '<select id="qunit-build">' +
96       '<option value="lodash-dev">lodash (development)</option>' +
97       '<option value="lodash">lodash (production)</option>' +
98       '<option value="lodash-core-dev">lodash-core (development)</option>' +
99       '<option value="lodash-core">lodash-core (production)</option>' +
100       '</select>';
101
102     var span2 = document.createElement('span');
103     span2.style.cssText = 'float:right';
104     span2.innerHTML =
105       '<label for="qunit-loader">Loader: </label>' +
106       '<select id="qunit-loader">' +
107       '<option value="none">None</option>' +
108       '<option value="curl">Curl</option>' +
109       '<option value="dojo">Dojo</option>' +
110       '<option value="requirejs">RequireJS</option>' +
111       '</select>';
112
113     var buildList = span1.lastChild,
114         loaderList = span2.lastChild;
115
116     setTimeout(function() {
117       ui.timing.loadEventEnd = +new Date;
118     }, 1);
119
120     init();
121   });
122
123   // The lodash build file path.
124   ui.buildPath = (function() {
125     var result;
126     switch (build) {
127       case 'lodash':            result = 'dist/lodash.min.js'; break;
128       case 'lodash-core-dev':   result = 'dist/lodash.core.js'; break;
129       case 'lodash-core':       result = 'dist/lodash.core.min.js'; break;
130       case null:                build  = 'lodash-dev';
131       case 'lodash-dev':        result = 'lodash.js'; break;
132       default:                  return build;
133     }
134     return basePath + result;
135   }());
136
137   // The module loader file path.
138   ui.loaderPath = (function() {
139     var result;
140     switch (loader) {
141       case 'curl':      result = 'node_modules/curl-amd/dist/curl-kitchen-sink/curl.js'; break;
142       case 'dojo':      result = 'node_modules/dojo/dojo.js'; break;
143       case 'requirejs': result = 'node_modules/requirejs/require.js'; break;
144       case null:        loader = 'none'; return '';
145       default:          return loader;
146     }
147     return basePath + result;
148   }());
149
150   // Used to indicate testing a core build.
151   ui.isCore = /\bcore(\.min)?\.js\b/.test(ui.buildPath);
152
153   // Used to indicate testing a foreign file.
154   ui.isForeign = RegExp('^(\\w+:)?//').test(build);
155
156   // Used to indicate testing a modularized build.
157   ui.isModularize = /\b(?:amd|commonjs|es|node|npm|(index|main)\.js)\b/.test([location.pathname, location.search]);
158
159   // Used to indicate testing in Sauce Labs' automated test cloud.
160   ui.isSauceLabs = location.port == '9001';
161
162   // Used to indicate that lodash is in strict mode.
163   ui.isStrict = /\bes\b/.test([location.pathname, location.search]);
164
165   ui.urlParams = { 'build': build, 'loader': loader };
166   ui.timing = { 'loadEventEnd': 0 };
167
168   window.ui = ui;
169
170 }(this));