diff --git a/.gitignore b/.gitignore index 81baed62b59a..885bf06f2e05 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,18 @@ yarn-debug.log* # Ignore default target directory for the npm package 'ui5-schemas' .tmp + + +# Playground +packages/playground/_site/ +packages/playground/.sass-cache/ +packages/playground/assets/js/ui5-webcomponents/ + +packages/playground/docs/components +!packages/playground/docs/components/component.md + +packages/playground/docs/documentation +!packages/playground/docs/documentation/documentation.md + +packages/playground/docs/tutorials +!packages/playground/docs/tutorials/tutorials.md diff --git a/.travis.yml b/.travis.yml index 5ee218feff66..7b5ec5fc4c27 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,10 @@ before_install: - curl -o- -L https://yarnpkg.com/install.sh | bash - export PATH="$HOME/.yarn/bin:$PATH" + # Playground dependecies: + - gem install jekyll -v 3.8.6 + - gem install jekyll-seo-tag + script: - yarn build - yarn test diff --git a/deploy/deploy.sh b/deploy/deploy.sh index b9787d2b544c..9ac265d2876e 100644 --- a/deploy/deploy.sh +++ b/deploy/deploy.sh @@ -56,7 +56,7 @@ if [ "$TRAVIS_BRANCH" == "$TRAVIS_LATEST_RELEASE_WEBSITE_BRANCH" ]; then # Run the build again so rollup can generate the correct public path urls cd $TRAVIS_BUILD_DIR - DEPLOY_PUBLIC_PATH=https://sap.github.io/ui5-webcomponents/ yarn build + DEPLOY_PUBLIC_PATH=https://sap.github.io/ui5-webcomponents/assets/js/ui5-webcomponents/ yarn build:playground # Move master build folder to gh-pages folder cp -Rf $TRAVIS_BUILD_DIR/packages/playground/dist/* gh-pages @@ -85,7 +85,7 @@ if [ "$TRAVIS_BRANCH" == "$TRAVIS_LATEST_RELEASE_WEBSITE_BRANCH" ]; then # Run the build again so rollup can generate the correct public path urls cd $TRAVIS_BUILD_DIR - DEPLOY_PUBLIC_PATH=https://sap.github.io/ui5-webcomponents/master yarn build + DEPLOY_PUBLIC_PATH=https://sap.github.io/ui5-webcomponents/master/assets/js/ui5-webcomponents/ yarn build:playground # Move master build folder to gh-pages folder cp -Rf $TRAVIS_BUILD_DIR/packages/playground/dist/* gh-pages/master diff --git a/docs/Angular-tutorial.md b/docs/Angular-tutorial.md index ec059f3473f6..de7407640d3d 100644 --- a/docs/Angular-tutorial.md +++ b/docs/Angular-tutorial.md @@ -2,30 +2,36 @@ In this tutorial you will learn how to add UI5 Web Components to your application. The UI5 Web Components can be added both to new Angular applications, as well as already existing ones. -## Step 1: Install Angular CLI: -``` +## Step 1: Install Angular CLI + +```bash npm install -g @angular/cli ``` -## Step 2: Create New Angular Application: -``` +## Step 2: Create New Angular Application + +```bash ng new ui5-web-components-application cd ui5-web-components-application ``` -## Step 3: Add UI5 Web Components: -``` +## Step 3: Add UI5 Web Components + +```bash npm install @ui5/webcomponents --save ``` ## Step 4. Allow the Use of Custom Elements in Angular + Before using UI5 Web Components, you have to allow the use of custom elements in Angular. To do so, you have to import CUSTOM_ELEMENTS_SCHEMA in ```app.module.ts``` : + ```js import { ..., CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; ``` + After importing it, you have to add it to the schemas array: -``` +```js imports: [ ... ], @@ -34,35 +40,42 @@ schemas: [ ] ``` -## Step 5. Import the Components That You Are Going to Use: +## Step 5. Import the Components That You Are Going to Use + ```js import "@ui5/webcomponents/dist/Button"; ``` -## Step 6. Use the Imported Elements in Your Application: +## Step 6. Use the Imported Elements in Your Application + ```html Hello world! ``` -## Step 7. Launch the Application: -``` +## Step 7. Launch the Application + +```bash ng serve -o ``` -## Additional: +## Additional -### Two-Way Data Binding: +### Two-Way Data Binding You can use two-way data binding with the following components: CheckBox, RadioButton, Input, DatePicker, Switch, TextArea. In order to use it, you have to use a library called [Origami](https://github.com/hotforfeature/origami), that provides advanced support for two-way data binding of custom elements. Example: -1. Install Origami: -``` + +1. Install Origami: + +```bash npm install @codebakery/origami ``` + 2. Import the OrigamiFormsModule from Origami -``` + +```js import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { OrigamiFormsModule } from '@codebakery/origami/forms'; @@ -78,6 +91,7 @@ export class AppModule {} ``` 3. Use Origami in your template: + ```html ``` diff --git a/docs/Configuration.md b/docs/Configuration.md index f25f2667204f..067d77e37740 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -16,7 +16,7 @@ calendarType | Gregorian, Islamic, Buddhist, Japanese, Persian | Gregorian | [formatSettings](#formatSettings)| See the [Format settings](#formatSettings) section below | Empty object | Allows to override locale-specific configuration -###RTL +### RTL When the `rtl` setting is set to `true`, UI5 Web Components will adjust their styling accordingly. However, you should also set the HTML attribute `dir` to `rtl` on the `body` or `html` or any other relevant region of your application diff --git a/docs/HowToUse.md b/docs/How To Use.md similarity index 100% rename from docs/HowToUse.md rename to docs/How To Use.md diff --git a/docs/PublicModuleImports.md b/docs/Public Module Imports.md similarity index 100% rename from docs/PublicModuleImports.md rename to docs/Public Module Imports.md diff --git a/docs/React-tutorial.md b/docs/React-tutorial.md index 5630b34b4bac..20040e696538 100644 --- a/docs/React-tutorial.md +++ b/docs/React-tutorial.md @@ -2,36 +2,40 @@ In this tutorial you will learn how to add UI5 Web Components to your application. The UI5 Web Components can be added both to new React applications, as well as already existing ones. -## Step 1. Start New Application. For Example with create-react-app: -``` +## Step 1. Start New Application. For Example with create-react-app + +```bash npx create-react-app ui5-web-components-application cd ui5-web-components-application ``` -## Step 2. Add UI5 Web Components: -``` +## Step 2. Add UI5 Web Components + +```bash npm install @ui5/webcomponents --save ``` -## Step 3. Import the Components That You Are Going to Use: +## Step 3. Import the Components That You Are Going to Use + ```js import "@ui5/webcomponents/dist/Button"; ``` -## Step 4. Use the Imported Elements in Your Application: +## Step 4. Use the Imported Elements in Your Application + ```html Hello world! ``` -## Step 5. Launch the Application: -``` +## Step 5. Launch the Application + +```bash yarn start ``` +## Additional -## Additional: - -### Event Binding: +### Event Binding In order to use the events, provided by UI5 Web Components, currently you need to get a ref to the component, because React doesn't support custom events. Here is an example of what you need to do in order to use the events provided by UI5 Web Components: @@ -57,7 +61,7 @@ class Home extends Component { } ``` -### Bolean Properties Binding: +### Bolean Properties Binding For boolean properties like ```collapsed``` in ```ui5-panel```, instead of setting true or false, you have to take care of the presence of the property. Here is an example: @@ -65,4 +69,4 @@ For boolean properties like ```collapsed``` in ```ui5-panel```, instead of sett -``` \ No newline at end of file +``` diff --git a/docs/Vue-tutorial.md b/docs/Vue-tutorial.md index 5781b54fe5c6..b771c6232fa9 100644 --- a/docs/Vue-tutorial.md +++ b/docs/Vue-tutorial.md @@ -2,49 +2,57 @@ In this tutorial you will learn how to add UI5 Web Components to your application. The UI5 Web Components can be added both to new VueJS applications, as well as already existing ones. -## Step 1. Install Vue CLI: -``` +## Step 1. Install Vue CLI + +```bash npm install -g @vue/cli ``` -## Step 2. Init New App: -``` +## Step 2. Init New App + +```bash vue create ui5-web-components-application cd ui5-web-components-application ``` -## Step 3. Add UI5 Web Components: -``` +## Step 3. Add UI5 Web Components + +```bash npm install @ui5/webcomponents --save ``` ## Step 4. Add UI5 Web Components to Vue ignoredElement + Add the following line to your ```main.js``` file: ```js Vue.config.ignoredElements = [/^ui5-/]; ``` -## Step 5. Import the Components That You Are Going to Use: +## Step 5. Import the Components That You Are Going to Use + ```js import "@ui5/webcomponents/dist/Button"; ``` -## Step 6. Use the Imported Elements in Your Application: +## Step 6. Use the Imported Elements in Your Application + ```html Hello world! ``` -## Step 7: Launch the Application: -``` +## Step 7: Launch the Application + +```bash yarn serve ``` -## Additional: +## Additional -### Two-Way Data Binding: +### Two-Way Data Binding `v-model` binding doesn't work as expected for custom elements. In order to use two way data binding, you should bind and update the value yourself like this: + ```html { } catch (err) { } if (content) { - const fnRedirect = ` - - `; const APIReference = compiledHandlebars(entry).replace(/\[\]/g, " [0..n]"); const EntitySince = compiledSinceTemplate(entry).replace(/\[\]/g, " [0..n]"); - content = content.replace('', APIReference); content = content.replace(sinceMarker, EntitySince); content = content.replace(linkMatcher, match => { diff --git a/lib/documentation/templates/api-events-section.js b/lib/documentation/templates/api-events-section.js index 9b207791966d..03eba4556162 100644 --- a/lib/documentation/templates/api-events-section.js +++ b/lib/documentation/templates/api-events-section.js @@ -22,10 +22,10 @@ module.exports = { {{#each this.parameters}} - +
{{this.name}}
-
type: {{this.type}}
description: {{{this.description}}}
+
type: {{this.type}}
description: {{{this.description}}}
{{/each}} diff --git a/lib/documentation/templates/api-methods-section.js b/lib/documentation/templates/api-methods-section.js index c8545b338d92..3c7e79040c13 100644 --- a/lib/documentation/templates/api-methods-section.js +++ b/lib/documentation/templates/api-methods-section.js @@ -18,7 +18,7 @@ module.exports = { {{#each this.parameters}}
{{this.name}}
-
type: {{this.type}}
description: {{{this.description}}}
+
type: {{this.type}}
description: {{{this.description}}}
{{/each}} {{/each}} diff --git a/lib/documentation/templates/api-properties-section.js b/lib/documentation/templates/api-properties-section.js index dba2583dfb79..02b88c8ef18e 100644 --- a/lib/documentation/templates/api-properties-section.js +++ b/lib/documentation/templates/api-properties-section.js @@ -14,7 +14,16 @@ module.exports = { {{#each properties}}
-
{{this.name}} {{#if this.readonly}} (readonly) {{else}}
{{toKebabCase this.name}}{{/if}}
+
+ {{this.name}} + {{#if this.readonly}} + (readonly) + {{/if}} +
+ {{#if (toKebabCase this.name)}} + {{toKebabCase this.name}} + {{/if}} +
{{this.type}}
{{this.defaultValue}}
diff --git a/lib/documentation/templates/template.js b/lib/documentation/templates/template.js index ad110e158347..a2f9c3b59167 100644 --- a/lib/documentation/templates/template.js +++ b/lib/documentation/templates/template.js @@ -33,6 +33,6 @@ module.exports = { Privacy Policy Legal
- Sap Logo + Sap Logo ` }; diff --git a/package.json b/package.json index 8e01d4edd934..2968383ac7e3 100644 --- a/package.json +++ b/package.json @@ -9,11 +9,11 @@ "ui5" ], "scripts": { - "build": "npm-run-all --sequential build:core build:base build:main build:playground", + "build": "npm-run-all --sequential build:core build:base build:main", "build:core": "cd packages/core && yarn build", "build:base": "cd packages/base && yarn build", "build:main": "cd packages/main && yarn build", - "build:playground": "cd packages/playground && yarn build", + "build:playground": "yarn build:main && cd packages/playground && yarn build", "clean": "npm-run-all --sequential clean:core clean:base clean:main", "clean:core": "cd packages/core && yarn clean", "clean:base": "cd packages/base && yarn clean", @@ -21,6 +21,7 @@ "start": "npm-run-all --parallel start:base start:main", "start:base": "cd packages/base && yarn start", "start:main": "cd packages/main && yarn start", + "start:playground": "cross-env DEPLOY_PUBLIC_PATH=/assets/js/ui5-webcomponents/ yarn build:main && cd packages/playground && yarn start", "test": "cd packages/main && yarn test", "lint": "wsrun --exclude-missing lint", "link-all": "wsrun link", diff --git a/packages/main/jest-puppeteer.config.js b/packages/main/jest-puppeteer.config.js index 81929a63ce00..5e24a0875972 100644 --- a/packages/main/jest-puppeteer.config.js +++ b/packages/main/jest-puppeteer.config.js @@ -6,7 +6,7 @@ module.exports = { // headless: false }, server: { - command: 'cd ../playground && npx ui5 serve', + command: 'cd ./dist/ && serve -l 8080', port: 8080, launchTimeout: 10000, debug: true, diff --git a/packages/main/rollup.config.js b/packages/main/rollup.config.js index eaf01f1c7fd7..8d2f6f9499e0 100644 --- a/packages/main/rollup.config.js +++ b/packages/main/rollup.config.js @@ -10,10 +10,11 @@ import filesize from 'rollup-plugin-filesize'; import commonjs from 'rollup-plugin-commonjs'; const DIST = path.normalize("dist"); -const DIST_PLAYGROUND = path.normalize("dist/resources"); +const DIST_PLAYGROUND = path.normalize("dist/resources/"); const DEPLOY_PUBLIC_PATH = process.env.DEPLOY_PUBLIC_PATH || ""; +const IS_TRAVIS_DEPLOYMENT = process.env.IS_TRAVIS_DEPLOYMENT || false; function ui5DevImportCheckerPlugin() { return { @@ -36,6 +37,7 @@ function ui5DevImportCheckerPlugin() { const getPlugins = ({ transpile }) => { const plugins = []; + let publicPath = DEPLOY_PUBLIC_PATH || "/resources/"; plugins.push(filesize({ render : function (options, bundle, { minSize, gzipSize, brotliSize, bundleSize }){ @@ -44,7 +46,7 @@ const getPlugins = ({ transpile }) => { })); plugins.push(ui5DevImportCheckerPlugin()); - + plugins.push(url({ limit: 0, include: [ @@ -52,7 +54,7 @@ const getPlugins = ({ transpile }) => { ], emitFiles: true, fileName: "[name].[hash][extname]", - publicPath: DEPLOY_PUBLIC_PATH + "/resources/", + publicPath, })); diff --git a/packages/main/test/playground/css/72-Bold.ttf b/packages/main/test/playground/css/72-Bold.ttf deleted file mode 100644 index 76cac05462a8..000000000000 Binary files a/packages/main/test/playground/css/72-Bold.ttf and /dev/null differ diff --git a/packages/main/test/playground/css/Menlo-Regular.ttf b/packages/main/test/playground/css/Menlo-Regular.ttf deleted file mode 100644 index 033dc6d21241..000000000000 Binary files a/packages/main/test/playground/css/Menlo-Regular.ttf and /dev/null differ diff --git a/packages/main/test/playground/libs/google-code-prettify/lang-css.js b/packages/main/test/playground/libs/google-code-prettify/lang-css.js deleted file mode 100644 index 90d175da0ed2..000000000000 --- a/packages/main/test/playground/libs/google-code-prettify/lang-css.js +++ /dev/null @@ -1,18 +0,0 @@ -/* - - Copyright (C) 2009 Google Inc. - - Licensed 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. -*/ -PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[["str",/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],["str",/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']+)\)/i],["kwd",/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//], -["com",/^(?:\x3c!--|--\x3e)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#(?:[0-9a-f]{3}){1,2}\b/i],["pln",/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],["pun",/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^\)\"\']+/]]),["css-str"]); diff --git a/packages/main/test/playground/libs/google-code-prettify/prettify.css b/packages/main/test/playground/libs/google-code-prettify/prettify.css deleted file mode 100644 index e6fe342f227c..000000000000 --- a/packages/main/test/playground/libs/google-code-prettify/prettify.css +++ /dev/null @@ -1 +0,0 @@ -.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.clo,.opn,.pun{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.kwd,.tag,.typ{font-weight:700}.str{color:#060}.kwd{color:#006}.com{color:#600;font-style:italic}.typ{color:#404}.lit{color:#044}.clo,.opn,.pun{color:#440}.tag{color:#006}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} \ No newline at end of file diff --git a/packages/main/test/playground/libs/google-code-prettify/prettify.js b/packages/main/test/playground/libs/google-code-prettify/prettify.js deleted file mode 100644 index 477f03d550d5..000000000000 --- a/packages/main/test/playground/libs/google-code-prettify/prettify.js +++ /dev/null @@ -1,46 +0,0 @@ -!function(){/* - - Copyright (C) 2006 Google Inc. - - Licensed 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. -*/ -"undefined"!==typeof window&&(window.PR_SHOULD_USE_CONTINUATION=!0); -(function(){function T(a){function d(e){var a=e.charCodeAt(0);if(92!==a)return a;var c=e.charAt(1);return(a=w[c])?a:"0"<=c&&"7">=c?parseInt(e.substring(1),8):"u"===c||"x"===c?parseInt(e.substring(2),16):e.charCodeAt(1)}function f(e){if(32>e)return(16>e?"\\x0":"\\x")+e.toString(16);e=String.fromCharCode(e);return"\\"===e||"-"===e||"]"===e||"^"===e?"\\"+e:e}function c(e){var c=e.substring(1,e.length-1).match(RegExp("\\\\u[0-9A-Fa-f]{4}|\\\\x[0-9A-Fa-f]{2}|\\\\[0-3][0-7]{0,2}|\\\\[0-7]{1,2}|\\\\[\\s\\S]|-|[^-\\\\]","g")); -e=[];var a="^"===c[0],b=["["];a&&b.push("^");for(var a=a?1:0,g=c.length;ak||122k||90k||122h[0]&&(h[1]+1>h[0]&&b.push("-"),b.push(f(h[1])));b.push("]");return b.join("")}function m(e){for(var a=e.source.match(RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g")),b=a.length,d=[],g=0,h=0;g/,null])):d.push(["com",/^#[^\r\n]*/,null,"#"]));a.cStyleComments&&(f.push(["com",/^\/\/[^\r\n]*/,null]),f.push(["com",/^\/\*[\s\S]*?(?:\*\/|$)/,null]));if(c=a.regexLiterals){var m=(c=1|\\/=?|::?|<>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*("+ -("/(?=[^/*"+c+"])(?:[^/\\x5B\\x5C"+c+"]|\\x5C"+m+"|\\x5B(?:[^\\x5C\\x5D"+c+"]|\\x5C"+m+")*(?:\\x5D|$))+/")+")")])}(c=a.types)&&f.push(["typ",c]);c=(""+a.keywords).replace(/^ | $/g,"");c.length&&f.push(["kwd",new RegExp("^(?:"+c.replace(/[\s,]+/g,"|")+")\\b"),null]);d.push(["pln",/^\s+/,null," \r\n\t\u00a0"]);c="^.[^\\s\\w.$@'\"`/\\\\]*";a.regexLiterals&&(c+="(?!s*/)");f.push(["lit",/^@[a-z_$][a-z_$@0-9]*/i,null],["typ",/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],["pln",/^[a-z_$][a-z_$@0-9]*/i, -null],["lit",/^(?:0x[a-f0-9]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+\-]?\d+)?)[a-z]*/i,null,"0123456789"],["pln",/^\\[\s\S]?/,null],["pun",new RegExp(c),null]);return G(d,f)}function L(a,d,f){function c(a){var b=a.nodeType;if(1==b&&!t.test(a.className))if("br"===a.nodeName.toLowerCase())m(a),a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)c(a);else if((3==b||4==b)&&f){var e=a.nodeValue,d=e.match(q);d&&(b=e.substring(0,d.index),a.nodeValue=b,(e=e.substring(d.index+ -d[0].length))&&a.parentNode.insertBefore(l.createTextNode(e),a.nextSibling),m(a),b||a.parentNode.removeChild(a))}}function m(a){function c(a,b){var e=b?a.cloneNode(!1):a,k=a.parentNode;if(k){var k=c(k,1),d=a.nextSibling;k.appendChild(e);for(var f=d;f;f=d)d=f.nextSibling,k.appendChild(f)}return e}for(;!a.nextSibling;)if(a=a.parentNode,!a)return;a=c(a.nextSibling,0);for(var e;(e=a.parentNode)&&1===e.nodeType;)a=e;b.push(a)}for(var t=/(?:^|\s)nocode(?:\s|$)/,q=/\r\n?|\n/,l=a.ownerDocument,n=l.createElement("li");a.firstChild;)n.appendChild(a.firstChild); -for(var b=[n],p=0;p=+m[1],d=/\n/g,t=a.a,q=t.length,f=0,l=a.c,n=l.length,c=0,b=a.g,p=b.length,w=0;b[p]=q;var r,e;for(e=r=0;e=h&&(c+=2);f>=k&&(w+=2)}}finally{g&&(g.style.display=a)}}catch(y){D.console&&console.log(y&&y.stack||y)}}var D="undefined"!==typeof window? -window:{},B=["break,continue,do,else,for,if,return,while"],F=[[B,"auto,case,char,const,default,double,enum,extern,float,goto,inline,int,long,register,restrict,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],H=[F,"alignas,alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,delegate,dynamic_cast,explicit,export,friend,generic,late_check,mutable,namespace,noexcept,noreturn,nullptr,property,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"], -O=[F,"abstract,assert,boolean,byte,extends,finally,final,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],P=[F,"abstract,add,alias,as,ascending,async,await,base,bool,by,byte,checked,decimal,delegate,descending,dynamic,event,finally,fixed,foreach,from,get,global,group,implicit,in,interface,internal,into,is,join,let,lock,null,object,out,override,orderby,params,partial,readonly,ref,remove,sbyte,sealed,select,set,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,value,var,virtual,where,yield"], -F=[F,"abstract,async,await,constructor,debugger,enum,eval,export,from,function,get,import,implements,instanceof,interface,let,null,of,set,undefined,var,with,yield,Infinity,NaN"],Q=[B,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],R=[B,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"], -B=[B,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],S=/^(DIR|FILE|array|vector|(de|priority_)?queue|(forward_)?list|stack|(const_)?(reverse_)?iterator|(unordered_)?(multi)?(set|map)|bitset|u?(int|float)\d*)\b/,W=/\S/,X=x({keywords:[H,P,O,F,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",Q,R,B],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}), -I={};t(X,["default-code"]);t(G([],[["pln",/^[^]*(?:>|$)/],["com",/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),"default-markup htm html mxml xhtml xml xsl".split(" "));t(G([["pln",/^[\s]+/, -null," \t\r\n"],["atv",/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],["pun",/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]); -t(G([],[["atv",/^[\s\S]+/]]),["uq.val"]);t(x({keywords:H,hashComments:!0,cStyleComments:!0,types:S}),"c cc cpp cxx cyc m".split(" "));t(x({keywords:"null,true,false"}),["json"]);t(x({keywords:P,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:S}),["cs"]);t(x({keywords:O,cStyleComments:!0}),["java"]);t(x({keywords:B,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]);t(x({keywords:Q,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]);t(x({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END", -hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]);t(x({keywords:R,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]);t(x({keywords:F,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]);t(x({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,throw,true,try,unless,until,when,while,yes",hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0, -regexLiterals:!0}),["coffee"]);t(G([],[["str",/^[\s\S]+/]]),["regex"]);var Y=D.PR={createSimpleLexer:G,registerLangHandler:t,sourceDecorator:x,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ",prettyPrintOne:D.prettyPrintOne=function(a,d,f){f=f||!1;d=d||null;var c=document.createElement("div");c.innerHTML="
"+a+"
"; -c=c.firstChild;f&&L(c,f,!0);M({j:d,m:f,h:c,l:1,a:null,i:null,c:null,g:null});return c.innerHTML},prettyPrint:D.prettyPrint=function(a,d){function f(){for(var c=D.PR_SHOULD_USE_CONTINUATION?b.now()+250:Infinity;p=c?parseInt(e.substring(1),8):"u"===c||"x"===c?parseInt(e.substring(2),16):e.charCodeAt(1)}function f(e){if(32>e)return(16>e?"\\x0":"\\x")+e.toString(16);e=String.fromCharCode(e); - return"\\"===e||"-"===e||"]"===e||"^"===e?"\\"+e:e}function c(e){var c=e.substring(1,e.length-1).match(RegExp("\\\\u[0-9A-Fa-f]{4}|\\\\x[0-9A-Fa-f]{2}|\\\\[0-3][0-7]{0,2}|\\\\[0-7]{1,2}|\\\\[\\s\\S]|-|[^-\\\\]","g"));e=[];var a="^"===c[0],b=["["];a&&b.push("^");for(var a=a?1:0,h=c.length;ap||122p||90p||122m[0]&&(m[1]+1>m[0]&&b.push("-"),b.push(f(m[1])));b.push("]");return b.join("")}function g(e){for(var a=e.source.match(RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)", - "g")),b=a.length,d=[],h=0,m=0;h/,null])):d.push(["com",/^#[^\r\n]*/,null,"#"]));a.cStyleComments&&(f.push(["com",/^\/\/[^\r\n]*/,null]),f.push(["com",/^\/\*[\s\S]*?(?:\*\/|$)/, - null]));if(c=a.regexLiterals){var g=(c=1|\\/=?|::?|<>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*("+("/(?=[^/*"+c+"])(?:[^/\\x5B\\x5C"+c+"]|\\x5C"+g+"|\\x5B(?:[^\\x5C\\x5D"+c+"]|\\x5C"+g+")*(?:\\x5D|$))+/")+")")])}(c=a.types)&&f.push(["typ",c]);c=(""+a.keywords).replace(/^ | $/g,"");c.length&&f.push(["kwd", - new RegExp("^(?:"+c.replace(/[\s,]+/g,"|")+")\\b"),null]);d.push(["pln",/^\s+/,null," \r\n\t\u00a0"]);c="^.[^\\s\\w.$@'\"`/\\\\]*";a.regexLiterals&&(c+="(?!s*/)");f.push(["lit",/^@[a-z_$][a-z_$@0-9]*/i,null],["typ",/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],["pln",/^[a-z_$][a-z_$@0-9]*/i,null],["lit",/^(?:0x[a-f0-9]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+\-]?\d+)?)[a-z]*/i,null,"0123456789"],["pln",/^\\[\s\S]?/,null],["pun",new RegExp(c),null]);return E(d,f)}function B(a,d,f){function c(a){var b= - a.nodeType;if(1==b&&!r.test(a.className))if("br"===a.nodeName.toLowerCase())g(a),a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)c(a);else if((3==b||4==b)&&f){var e=a.nodeValue,d=e.match(n);d&&(b=e.substring(0,d.index),a.nodeValue=b,(e=e.substring(d.index+d[0].length))&&a.parentNode.insertBefore(q.createTextNode(e),a.nextSibling),g(a),b||a.parentNode.removeChild(a))}}function g(a){function c(a,b){var e=b?a.cloneNode(!1):a,p=a.parentNode;if(p){var p=c(p,1),d=a.nextSibling; - p.appendChild(e);for(var f=d;f;f=d)d=f.nextSibling,p.appendChild(f)}return e}for(;!a.nextSibling;)if(a=a.parentNode,!a)return;a=c(a.nextSibling,0);for(var e;(e=a.parentNode)&&1===e.nodeType;)a=e;b.push(a)}for(var r=/(?:^|\s)nocode(?:\s|$)/,n=/\r\n?|\n/,q=a.ownerDocument,k=q.createElement("li");a.firstChild;)k.appendChild(a.firstChild);for(var b=[k],t=0;t=+g[1],d=/\n/g,r=a.a,k=r.length,f=0,q=a.c,n=q.length,c=0,b=a.g,t=b.length,v=0;b[t]=k;var u,e;for(e=u=0;e=m&&(c+=2);f>=p&&(v+=2)}}finally{h&&(h.style.display=a)}}catch(y){Q.console&&console.log(y&&y.stack||y)}}var Q="undefined"!==typeof window?window:{},J=["break,continue,do,else,for,if,return,while"],K=[[J,"auto,case,char,const,default,double,enum,extern,float,goto,inline,int,long,register,restrict,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"], - "catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],R=[K,"alignas,alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,delegate,dynamic_cast,explicit,export,friend,generic,late_check,mutable,namespace,noexcept,noreturn,nullptr,property,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],L=[K,"abstract,assert,boolean,byte,extends,finally,final,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"], - M=[K,"abstract,add,alias,as,ascending,async,await,base,bool,by,byte,checked,decimal,delegate,descending,dynamic,event,finally,fixed,foreach,from,get,global,group,implicit,in,interface,internal,into,is,join,let,lock,null,object,out,override,orderby,params,partial,readonly,ref,remove,sbyte,sealed,select,set,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,value,var,virtual,where,yield"],K=[K,"abstract,async,await,constructor,debugger,enum,eval,export,from,function,get,import,implements,instanceof,interface,let,null,of,set,undefined,var,with,yield,Infinity,NaN"], - N=[J,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],O=[J,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],J=[J,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],P=/^(DIR|FILE|array|vector|(de|priority_)?queue|(forward_)?list|stack|(const_)?(reverse_)?iterator|(unordered_)?(multi)?(set|map)|bitset|u?(int|float)\d*)\b/, - S=/\S/,T=v({keywords:[R,M,L,K,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",N,O,J],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),V={};n(T,["default-code"]);n(E([],[["pln",/^[^]*(?:>|$)/],["com",/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-", - /^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),"default-markup htm html mxml xhtml xml xsl".split(" "));n(E([["pln",/^[\s]+/,null," \t\r\n"],["atv",/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/], - ["pun",/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);n(E([],[["atv",/^[\s\S]+/]]),["uq.val"]);n(v({keywords:R,hashComments:!0,cStyleComments:!0,types:P}),"c cc cpp cxx cyc m".split(" "));n(v({keywords:"null,true,false"}),["json"]);n(v({keywords:M,hashComments:!0,cStyleComments:!0, - verbatimStrings:!0,types:P}),["cs"]);n(v({keywords:L,cStyleComments:!0}),["java"]);n(v({keywords:J,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]);n(v({keywords:N,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]);n(v({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:2}), - ["perl","pl","pm"]);n(v({keywords:O,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]);n(v({keywords:K,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]);n(v({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,throw,true,try,unless,until,when,while,yes",hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);n(E([],[["str",/^[\s\S]+/]]), - ["regex"]);var U=Q.PR={createSimpleLexer:E,registerLangHandler:n,sourceDecorator:v,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ",prettyPrintOne:function(a,d,f){f=f||!1;d=d||null;var c=document.createElement("div");c.innerHTML="
"+a+"
";c=c.firstChild;f&&B(c,f,!0);H({j:d,m:f,h:c,l:1,a:null,i:null,c:null,g:null}); - return c.innerHTML},prettyPrint:g=function(a,d){function f(){for(var c=Q.PR_SHOULD_USE_CONTINUATION?b.now()+250:Infinity;tQUnit Page for ui5-checkbox - @@ -13,48 +12,39 @@ - - - - - - + + + + + + + diff --git a/packages/main/test/qunit/util/jquery.min.js b/packages/main/test/qunit/util/jquery.min.js new file mode 100644 index 000000000000..07c00cd227da --- /dev/null +++ b/packages/main/test/qunit/util/jquery.min.js @@ -0,0 +1,2 @@ +/*! jQuery v3.4.1 | (c) JS Foundation and other contributors | jquery.org/license */ +!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(C,e){"use strict";var t=[],E=C.document,r=Object.getPrototypeOf,s=t.slice,g=t.concat,u=t.push,i=t.indexOf,n={},o=n.toString,v=n.hasOwnProperty,a=v.toString,l=a.call(Object),y={},m=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},x=function(e){return null!=e&&e===e.window},c={type:!0,src:!0,nonce:!0,noModule:!0};function b(e,t,n){var r,i,o=(n=n||E).createElement("script");if(o.text=e,t)for(r in c)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function w(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[o.call(e)]||"object":typeof e}var f="3.4.1",k=function(e,t){return new k.fn.init(e,t)},p=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;function d(e){var t=!!e&&"length"in e&&e.length,n=w(e);return!m(e)&&!x(e)&&("array"===n||0===t||"number"==typeof t&&0+~]|"+M+")"+M+"*"),U=new RegExp(M+"|>"),X=new RegExp($),V=new RegExp("^"+I+"$"),G={ID:new RegExp("^#("+I+")"),CLASS:new RegExp("^\\.("+I+")"),TAG:new RegExp("^("+I+"|[*])"),ATTR:new RegExp("^"+W),PSEUDO:new RegExp("^"+$),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+R+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/HTML$/i,Q=/^(?:input|select|textarea|button)$/i,J=/^h\d$/i,K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ee=/[+~]/,te=new RegExp("\\\\([\\da-f]{1,6}"+M+"?|("+M+")|.)","ig"),ne=function(e,t,n){var r="0x"+t-65536;return r!=r||n?t:r<0?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,1023&r|56320)},re=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ie=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},oe=function(){T()},ae=be(function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()},{dir:"parentNode",next:"legend"});try{H.apply(t=O.call(m.childNodes),m.childNodes),t[m.childNodes.length].nodeType}catch(e){H={apply:t.length?function(e,t){L.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function se(t,e,n,r){var i,o,a,s,u,l,c,f=e&&e.ownerDocument,p=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==p&&9!==p&&11!==p)return n;if(!r&&((e?e.ownerDocument||e:m)!==C&&T(e),e=e||C,E)){if(11!==p&&(u=Z.exec(t)))if(i=u[1]){if(9===p){if(!(a=e.getElementById(i)))return n;if(a.id===i)return n.push(a),n}else if(f&&(a=f.getElementById(i))&&y(e,a)&&a.id===i)return n.push(a),n}else{if(u[2])return H.apply(n,e.getElementsByTagName(t)),n;if((i=u[3])&&d.getElementsByClassName&&e.getElementsByClassName)return H.apply(n,e.getElementsByClassName(i)),n}if(d.qsa&&!A[t+" "]&&(!v||!v.test(t))&&(1!==p||"object"!==e.nodeName.toLowerCase())){if(c=t,f=e,1===p&&U.test(t)){(s=e.getAttribute("id"))?s=s.replace(re,ie):e.setAttribute("id",s=k),o=(l=h(t)).length;while(o--)l[o]="#"+s+" "+xe(l[o]);c=l.join(","),f=ee.test(t)&&ye(e.parentNode)||e}try{return H.apply(n,f.querySelectorAll(c)),n}catch(e){A(t,!0)}finally{s===k&&e.removeAttribute("id")}}}return g(t.replace(B,"$1"),e,n,r)}function ue(){var r=[];return function e(t,n){return r.push(t+" ")>b.cacheLength&&delete e[r.shift()],e[t+" "]=n}}function le(e){return e[k]=!0,e}function ce(e){var t=C.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function fe(e,t){var n=e.split("|"),r=n.length;while(r--)b.attrHandle[n[r]]=t}function pe(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function de(t){return function(e){return"input"===e.nodeName.toLowerCase()&&e.type===t}}function he(n){return function(e){var t=e.nodeName.toLowerCase();return("input"===t||"button"===t)&&e.type===n}}function ge(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&ae(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function ve(a){return le(function(o){return o=+o,le(function(e,t){var n,r=a([],e.length,o),i=r.length;while(i--)e[n=r[i]]&&(e[n]=!(t[n]=e[n]))})})}function ye(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}for(e in d=se.support={},i=se.isXML=function(e){var t=e.namespaceURI,n=(e.ownerDocument||e).documentElement;return!Y.test(t||n&&n.nodeName||"HTML")},T=se.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:m;return r!==C&&9===r.nodeType&&r.documentElement&&(a=(C=r).documentElement,E=!i(C),m!==C&&(n=C.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",oe,!1):n.attachEvent&&n.attachEvent("onunload",oe)),d.attributes=ce(function(e){return e.className="i",!e.getAttribute("className")}),d.getElementsByTagName=ce(function(e){return e.appendChild(C.createComment("")),!e.getElementsByTagName("*").length}),d.getElementsByClassName=K.test(C.getElementsByClassName),d.getById=ce(function(e){return a.appendChild(e).id=k,!C.getElementsByName||!C.getElementsByName(k).length}),d.getById?(b.filter.ID=function(e){var t=e.replace(te,ne);return function(e){return e.getAttribute("id")===t}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n=t.getElementById(e);return n?[n]:[]}}):(b.filter.ID=function(e){var n=e.replace(te,ne);return function(e){var t="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return t&&t.value===n}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),b.find.TAG=d.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):d.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},b.find.CLASS=d.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&E)return t.getElementsByClassName(e)},s=[],v=[],(d.qsa=K.test(C.querySelectorAll))&&(ce(function(e){a.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&v.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||v.push("\\["+M+"*(?:value|"+R+")"),e.querySelectorAll("[id~="+k+"-]").length||v.push("~="),e.querySelectorAll(":checked").length||v.push(":checked"),e.querySelectorAll("a#"+k+"+*").length||v.push(".#.+[+~]")}),ce(function(e){e.innerHTML="";var t=C.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&v.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&v.push(":enabled",":disabled"),a.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&v.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),v.push(",.*:")})),(d.matchesSelector=K.test(c=a.matches||a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.msMatchesSelector))&&ce(function(e){d.disconnectedMatch=c.call(e,"*"),c.call(e,"[s!='']:x"),s.push("!=",$)}),v=v.length&&new RegExp(v.join("|")),s=s.length&&new RegExp(s.join("|")),t=K.test(a.compareDocumentPosition),y=t||K.test(a.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},D=t?function(e,t){if(e===t)return l=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!d.sortDetached&&t.compareDocumentPosition(e)===n?e===C||e.ownerDocument===m&&y(m,e)?-1:t===C||t.ownerDocument===m&&y(m,t)?1:u?P(u,e)-P(u,t):0:4&n?-1:1)}:function(e,t){if(e===t)return l=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e===C?-1:t===C?1:i?-1:o?1:u?P(u,e)-P(u,t):0;if(i===o)return pe(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?pe(a[r],s[r]):a[r]===m?-1:s[r]===m?1:0}),C},se.matches=function(e,t){return se(e,null,null,t)},se.matchesSelector=function(e,t){if((e.ownerDocument||e)!==C&&T(e),d.matchesSelector&&E&&!A[t+" "]&&(!s||!s.test(t))&&(!v||!v.test(t)))try{var n=c.call(e,t);if(n||d.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){A(t,!0)}return 0":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(te,ne),e[3]=(e[3]||e[4]||e[5]||"").replace(te,ne),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||se.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&se.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return G.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=h(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(te,ne).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=p[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&p(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(n,r,i){return function(e){var t=se.attr(e,n);return null==t?"!="===r:!r||(t+="","="===r?t===i:"!="===r?t!==i:"^="===r?i&&0===t.indexOf(i):"*="===r?i&&-1:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function j(e,n,r){return m(n)?k.grep(e,function(e,t){return!!n.call(e,t,e)!==r}):n.nodeType?k.grep(e,function(e){return e===n!==r}):"string"!=typeof n?k.grep(e,function(e){return-1)[^>]*|#([\w-]+))$/;(k.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||q,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:L.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof k?t[0]:t,k.merge(this,k.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:E,!0)),D.test(r[1])&&k.isPlainObject(t))for(r in t)m(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return(i=E.getElementById(r[2]))&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):m(e)?void 0!==n.ready?n.ready(e):e(k):k.makeArray(e,this)}).prototype=k.fn,q=k(E);var H=/^(?:parents|prev(?:Until|All))/,O={children:!0,contents:!0,next:!0,prev:!0};function P(e,t){while((e=e[t])&&1!==e.nodeType);return e}k.fn.extend({has:function(e){var t=k(e,this),n=t.length;return this.filter(function(){for(var e=0;e\x20\t\r\n\f]*)/i,he=/^$|^module$|\/(?:java|ecma)script/i,ge={option:[1,""],thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};function ve(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&A(e,t)?k.merge([e],n):n}function ye(e,t){for(var n=0,r=e.length;nx",y.noCloneChecked=!!me.cloneNode(!0).lastChild.defaultValue;var Te=/^key/,Ce=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,Ee=/^([^.]*)(?:\.(.+)|)/;function ke(){return!0}function Se(){return!1}function Ne(e,t){return e===function(){try{return E.activeElement}catch(e){}}()==("focus"===t)}function Ae(e,t,n,r,i,o){var a,s;if("object"==typeof t){for(s in"string"!=typeof n&&(r=r||n,n=void 0),t)Ae(e,s,n,r,t[s],o);return e}if(null==r&&null==i?(i=n,r=n=void 0):null==i&&("string"==typeof n?(i=r,r=void 0):(i=r,r=n,n=void 0)),!1===i)i=Se;else if(!i)return e;return 1===o&&(a=i,(i=function(e){return k().off(e),a.apply(this,arguments)}).guid=a.guid||(a.guid=k.guid++)),e.each(function(){k.event.add(this,t,i,r,n)})}function De(e,i,o){o?(Q.set(e,i,!1),k.event.add(e,i,{namespace:!1,handler:function(e){var t,n,r=Q.get(this,i);if(1&e.isTrigger&&this[i]){if(r.length)(k.event.special[i]||{}).delegateType&&e.stopPropagation();else if(r=s.call(arguments),Q.set(this,i,r),t=o(this,i),this[i](),r!==(n=Q.get(this,i))||t?Q.set(this,i,!1):n={},r!==n)return e.stopImmediatePropagation(),e.preventDefault(),n.value}else r.length&&(Q.set(this,i,{value:k.event.trigger(k.extend(r[0],k.Event.prototype),r.slice(1),this)}),e.stopImmediatePropagation())}})):void 0===Q.get(e,i)&&k.event.add(e,i,ke)}k.event={global:{},add:function(t,e,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,v=Q.get(t);if(v){n.handler&&(n=(o=n).handler,i=o.selector),i&&k.find.matchesSelector(ie,i),n.guid||(n.guid=k.guid++),(u=v.events)||(u=v.events={}),(a=v.handle)||(a=v.handle=function(e){return"undefined"!=typeof k&&k.event.triggered!==e.type?k.event.dispatch.apply(t,arguments):void 0}),l=(e=(e||"").match(R)||[""]).length;while(l--)d=g=(s=Ee.exec(e[l])||[])[1],h=(s[2]||"").split(".").sort(),d&&(f=k.event.special[d]||{},d=(i?f.delegateType:f.bindType)||d,f=k.event.special[d]||{},c=k.extend({type:d,origType:g,data:r,handler:n,guid:n.guid,selector:i,needsContext:i&&k.expr.match.needsContext.test(i),namespace:h.join(".")},o),(p=u[d])||((p=u[d]=[]).delegateCount=0,f.setup&&!1!==f.setup.call(t,r,h,a)||t.addEventListener&&t.addEventListener(d,a)),f.add&&(f.add.call(t,c),c.handler.guid||(c.handler.guid=n.guid)),i?p.splice(p.delegateCount++,0,c):p.push(c),k.event.global[d]=!0)}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,v=Q.hasData(e)&&Q.get(e);if(v&&(u=v.events)){l=(t=(t||"").match(R)||[""]).length;while(l--)if(d=g=(s=Ee.exec(t[l])||[])[1],h=(s[2]||"").split(".").sort(),d){f=k.event.special[d]||{},p=u[d=(r?f.delegateType:f.bindType)||d]||[],s=s[2]&&new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),a=o=p.length;while(o--)c=p[o],!i&&g!==c.origType||n&&n.guid!==c.guid||s&&!s.test(c.namespace)||r&&r!==c.selector&&("**"!==r||!c.selector)||(p.splice(o,1),c.selector&&p.delegateCount--,f.remove&&f.remove.call(e,c));a&&!p.length&&(f.teardown&&!1!==f.teardown.call(e,h,v.handle)||k.removeEvent(e,d,v.handle),delete u[d])}else for(d in u)k.event.remove(e,d+t[l],n,r,!0);k.isEmptyObject(u)&&Q.remove(e,"handle events")}},dispatch:function(e){var t,n,r,i,o,a,s=k.event.fix(e),u=new Array(arguments.length),l=(Q.get(this,"events")||{})[s.type]||[],c=k.event.special[s.type]||{};for(u[0]=s,t=1;t\x20\t\r\n\f]*)[^>]*)\/>/gi,qe=/\s*$/g;function Oe(e,t){return A(e,"table")&&A(11!==t.nodeType?t:t.firstChild,"tr")&&k(e).children("tbody")[0]||e}function Pe(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function Re(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Me(e,t){var n,r,i,o,a,s,u,l;if(1===t.nodeType){if(Q.hasData(e)&&(o=Q.access(e),a=Q.set(t,o),l=o.events))for(i in delete a.handle,a.events={},l)for(n=0,r=l[i].length;n")},clone:function(e,t,n){var r,i,o,a,s,u,l,c=e.cloneNode(!0),f=oe(e);if(!(y.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||k.isXMLDoc(e)))for(a=ve(c),r=0,i=(o=ve(e)).length;r").attr(n.scriptAttrs||{}).prop({charset:n.scriptCharset,src:n.url}).on("load error",i=function(e){r.remove(),i=null,e&&t("error"===e.type?404:200,e.type)}),E.head.appendChild(r[0])},abort:function(){i&&i()}}});var Vt,Gt=[],Yt=/(=)\?(?=&|$)|\?\?/;k.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Gt.pop()||k.expando+"_"+kt++;return this[e]=!0,e}}),k.ajaxPrefilter("json jsonp",function(e,t,n){var r,i,o,a=!1!==e.jsonp&&(Yt.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&Yt.test(e.data)&&"data");if(a||"jsonp"===e.dataTypes[0])return r=e.jsonpCallback=m(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,a?e[a]=e[a].replace(Yt,"$1"+r):!1!==e.jsonp&&(e.url+=(St.test(e.url)?"&":"?")+e.jsonp+"="+r),e.converters["script json"]=function(){return o||k.error(r+" was not called"),o[0]},e.dataTypes[0]="json",i=C[r],C[r]=function(){o=arguments},n.always(function(){void 0===i?k(C).removeProp(r):C[r]=i,e[r]&&(e.jsonpCallback=t.jsonpCallback,Gt.push(r)),o&&m(i)&&i(o[0]),o=i=void 0}),"script"}),y.createHTMLDocument=((Vt=E.implementation.createHTMLDocument("").body).innerHTML="
",2===Vt.childNodes.length),k.parseHTML=function(e,t,n){return"string"!=typeof e?[]:("boolean"==typeof t&&(n=t,t=!1),t||(y.createHTMLDocument?((r=(t=E.implementation.createHTMLDocument("")).createElement("base")).href=E.location.href,t.head.appendChild(r)):t=E),o=!n&&[],(i=D.exec(e))?[t.createElement(i[1])]:(i=we([e],t,o),o&&o.length&&k(o).remove(),k.merge([],i.childNodes)));var r,i,o},k.fn.load=function(e,t,n){var r,i,o,a=this,s=e.indexOf(" ");return-1").append(k.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},k.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){k.fn[t]=function(e){return this.on(t,e)}}),k.expr.pseudos.animated=function(t){return k.grep(k.timers,function(e){return t===e.elem}).length},k.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=k.css(e,"position"),c=k(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=k.css(e,"top"),u=k.css(e,"left"),("absolute"===l||"fixed"===l)&&-1<(o+u).indexOf("auto")?(a=(r=c.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),m(t)&&(t=t.call(e,n,k.extend({},s))),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):c.css(f)}},k.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){k.offset.setOffset(this,t,e)});var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===k.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===k.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=k(e).offset()).top+=k.css(e,"borderTopWidth",!0),i.left+=k.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-k.css(r,"marginTop",!0),left:t.left-i.left-k.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===k.css(e,"position"))e=e.offsetParent;return e||ie})}}),k.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,i){var o="pageYOffset"===i;k.fn[t]=function(e){return _(this,function(e,t,n){var r;if(x(e)?r=e:9===e.nodeType&&(r=e.defaultView),void 0===n)return r?r[i]:e[t];r?r.scrollTo(o?r.pageXOffset:n,o?n:r.pageYOffset):e[t]=n},t,e,arguments.length)}}),k.each(["top","left"],function(e,n){k.cssHooks[n]=ze(y.pixelPosition,function(e,t){if(t)return t=_e(e,n),$e.test(t)?k(e).position()[n]+"px":t})}),k.each({Height:"height",Width:"width"},function(a,s){k.each({padding:"inner"+a,content:s,"":"outer"+a},function(r,o){k.fn[o]=function(e,t){var n=arguments.length&&(r||"boolean"!=typeof e),i=r||(!0===e||!0===t?"margin":"border");return _(this,function(e,t,n){var r;return x(e)?0===o.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(r=e.documentElement,Math.max(e.body["scroll"+a],r["scroll"+a],e.body["offset"+a],r["offset"+a],r["client"+a])):void 0===n?k.css(e,t,i):k.style(e,t,n,i)},s,n?e:void 0,n)}})}),k.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,n){k.fn[n]=function(e,t){return 0 * { + box-sizing: border-box; + max-height: 2.8em; + display: block; + padding: 0.4em; +} + +#qunit-modulefilter-dropdown #qunit-modulefilter-actions > button { + float: right; + font: inherit; +} + +#qunit-modulefilter-dropdown #qunit-modulefilter-actions > :last-child { + /* insert padding to align with checkbox margins */ + padding-left: 3px; +} + +#qunit-modulefilter-dropdown-list { + max-height: 200px; + overflow-y: auto; + margin: 0; + border-top: 2px groove threedhighlight; + padding: 0.4em 0 0; + font: smaller/1.5em sans-serif; +} + +#qunit-modulefilter-dropdown-list li { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + +#qunit-modulefilter-dropdown-list .clickable { + display: block; + padding-left: 0.15em; +} + + +/** 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 > li { + display: none; +} + +#qunit-tests li.running, +#qunit-tests li.pass, +#qunit-tests li.fail, +#qunit-tests li.skipped, +#qunit-tests li.aborted { + display: list-item; +} + +#qunit-tests.hidepass { + position: relative; +} + +#qunit-tests.hidepass li.running, +#qunit-tests.hidepass li.pass:not(.todo) { + visibility: hidden; + position: absolute; + width: 0; + height: 0; + padding: 0; + border: 0; + margin: 0; +} + +#qunit-tests li strong { + cursor: pointer; +} + +#qunit-tests li.skipped strong { + cursor: default; +} + +#qunit-tests li a { + padding: 0.5em; + color: #C2CCD1; + text-decoration: none; +} + +#qunit-tests li p a { + padding: 0.25em; + color: #6B6464; +} +#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-source { + margin: 0.6em 0 0.3em; +} + +.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 { + color: #374E0C; + background-color: #E0F2BE; + text-decoration: none; +} + +#qunit-tests ins { + color: #500; + background-color: #FFCACA; + 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; } + + +/*** Aborted tests */ +#qunit-tests .aborted { color: #000; background-color: orange; } +/*** Skipped tests */ + +#qunit-tests .skipped { + background-color: #EBECE9; +} + +#qunit-tests .qunit-todo-label, +#qunit-tests .qunit-skipped-label { + background-color: #F4FF77; + display: inline-block; + font-style: normal; + color: #366097; + line-height: 1.8em; + padding: 0 0.5em; + margin: -0.4em 0.4em -0.4em 0; +} + +#qunit-tests .qunit-todo-label { + background-color: #EEE; +} + +/** Result */ + +#qunit-testresult { + color: #2B81AF; + background-color: #D2E0E6; + + border-bottom: 1px solid #FFF; +} +#qunit-testresult .clearfix { + height: 0; + clear: both; +} +#qunit-testresult .module-name { + font-weight: 700; +} +#qunit-testresult-display { + padding: 0.5em 1em 0.5em 1em; + width: 85%; + float:left; +} +#qunit-testresult-controls { + padding: 0.5em 1em 0.5em 1em; + width: 10%; + float:left; +} + +/** Fixture */ + +#qunit-fixture { + position: absolute; + top: -10000px; + left: -10000px; + width: 1000px; + height: 1000px; +} \ No newline at end of file diff --git a/packages/main/test/qunit/util/qunit-2.js b/packages/main/test/qunit/util/qunit-2.js new file mode 100644 index 000000000000..e20428b26dc0 --- /dev/null +++ b/packages/main/test/qunit/util/qunit-2.js @@ -0,0 +1,4920 @@ +/*! + * QUnit 2.3.2 + * https://qunitjs.com/ + * + * Copyright jQuery Foundation and other contributors + * Released under the MIT license + * https://jquery.org/license + * + * Date: 2017-04-18T02:19Z + */ +(function (global$1) { + 'use strict'; + + global$1 = 'default' in global$1 ? global$1['default'] : global$1; + + var window = global$1.window; + var console = global$1.console; + var setTimeout = global$1.setTimeout; + var clearTimeout = global$1.clearTimeout; + + var document = window && window.document; + var navigator = window && window.navigator; + + var localSessionStorage = function () { + var x = "qunit-test-string"; + try { + global$1.sessionStorage.setItem(x, x); + global$1.sessionStorage.removeItem(x); + return global$1.sessionStorage; + } catch (e) { + return undefined; + } + }(); + + var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { + return typeof obj; + } : function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + + + + + + + + + + + + var classCallCheck = function (instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + }; + + var createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + }(); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + var toConsumableArray = function (arr) { + if (Array.isArray(arr)) { + for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; + + return arr2; + } else { + return Array.from(arr); + } + }; + + var toString = Object.prototype.toString; + var hasOwn = Object.prototype.hasOwnProperty; + var now = Date.now || function () { + return new Date().getTime(); + }; + + var defined = { + document: window && window.document !== undefined, + setTimeout: setTimeout !== undefined + }; + + // 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; + } + + /** + * Determines whether an element exists in a given array or not. + * + * @method inArray + * @param {Any} elem + * @param {Array} array + * @return {Boolean} + */ + function inArray(elem, array) { + return array.indexOf(elem) !== -1; + } + + /** + * 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). + */ + function objectValues(obj) { + var key, + val, + vals = 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; + } + + function extend(a, b, undefOnly) { + for (var prop in b) { + if (hasOwn.call(b, prop)) { + if (b[prop] === undefined) { + delete a[prop]; + } else if (!(undefOnly && typeof a[prop] !== "undefined")) { + a[prop] = b[prop]; + } + } + } + + return a; + } + + function objectType(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 "Set": + case "Map": + case "Date": + case "RegExp": + case "Function": + case "Symbol": + return type.toLowerCase(); + } + + if ((typeof obj === "undefined" ? "undefined" : _typeof(obj)) === "object") { + return "object"; + } + } + + // Safe object type checking + function is(type, obj) { + return objectType(obj) === type; + } + + // Based on Java's String.hashCode, a simple but not + // rigorously collision resistant hashing function + function generateHash(module, testName) { + var str = module + "\x1C" + testName; + var hash = 0; + + for (var i = 0; i < str.length; i++) { + hash = (hash << 5) - hash + str.charCodeAt(i); + hash |= 0; + } + + // Convert the possibly negative integer hash code into an 8 character hex string, which isn't + // strictly necessary but increases user understanding that the id is a SHA-like hash + var hex = (0x100000000 + hash).toString(16); + if (hex.length < 8) { + hex = "0000000" + hex; + } + + return hex.slice(-8); + } + + // Test for equality any JavaScript type. + // Authors: Philippe Rathé , David Chan + var equiv = (function () { + + // Value pairs queued for comparison. Used for breadth-first processing order, recursion + // detection and avoiding repeated comparison (see below for details). + // Elements are { a: val, b: val }. + var pairs = []; + + var getProto = Object.getPrototypeOf || function (obj) { + return obj.__proto__; + }; + + function useStrictEquality(a, b) { + + // This only gets called if a and b are not strict equal, and is used to compare on + // the primitive values inside object wrappers. For example: + // `var i = 1;` + // `var j = new Number(1);` + // Neither a nor b can be null, as a !== b and they have the same type. + if ((typeof a === "undefined" ? "undefined" : _typeof(a)) === "object") { + a = a.valueOf(); + } + if ((typeof b === "undefined" ? "undefined" : _typeof(b)) === "object") { + b = b.valueOf(); + } + + return a === b; + } + + function compareConstructors(a, b) { + var protoA = getProto(a); + var protoB = getProto(b); + + // Comparing constructors is more strict than using `instanceof` + if (a.constructor === b.constructor) { + return true; + } + + // Ref #851 + // If the obj prototype descends from a null constructor, treat it + // as a null prototype. + if (protoA && protoA.constructor === null) { + protoA = null; + } + if (protoB && protoB.constructor === null) { + protoB = null; + } + + // Allow objects with no prototype to be equivalent to + // objects with Object as their constructor. + if (protoA === null && protoB === Object.prototype || protoB === null && protoA === Object.prototype) { + return true; + } + + return false; + } + + function getRegExpFlags(regexp) { + return "flags" in regexp ? regexp.flags : regexp.toString().match(/[gimuy]*$/)[0]; + } + + function isContainer(val) { + return ["object", "array", "map", "set"].indexOf(objectType(val)) !== -1; + } + + function breadthFirstCompareChild(a, b) { + + // If a is a container not reference-equal to b, postpone the comparison to the + // end of the pairs queue -- unless (a, b) has been seen before, in which case skip + // over the pair. + if (a === b) { + return true; + } + if (!isContainer(a)) { + return typeEquiv(a, b); + } + if (pairs.every(function (pair) { + return pair.a !== a || pair.b !== b; + })) { + + // Not yet started comparing this pair + pairs.push({ a: a, b: b }); + } + return true; + } + + var callbacks = { + "string": useStrictEquality, + "boolean": useStrictEquality, + "number": useStrictEquality, + "null": useStrictEquality, + "undefined": useStrictEquality, + "symbol": useStrictEquality, + "date": useStrictEquality, + + "nan": function nan() { + return true; + }, + + "regexp": function regexp(a, b) { + return a.source === b.source && + + // Include flags in the comparison + getRegExpFlags(a) === getRegExpFlags(b); + }, + + // abort (identical references / instance methods were skipped earlier) + "function": function _function() { + return false; + }, + + "array": function array(a, b) { + var i, len; + + len = a.length; + if (len !== b.length) { + + // Safe and faster + return false; + } + + for (i = 0; i < len; i++) { + + // Compare non-containers; queue non-reference-equal containers + if (!breadthFirstCompareChild(a[i], b[i])) { + return false; + } + } + return true; + }, + + // Define sets a and b to be equivalent if for each element aVal in a, there + // is some element bVal in b such that aVal and bVal are equivalent. Element + // repetitions are not counted, so these are equivalent: + // a = new Set( [ {}, [], [] ] ); + // b = new Set( [ {}, {}, [] ] ); + "set": function set$$1(a, b) { + var innerEq, + outerEq = true; + + if (a.size !== b.size) { + + // This optimization has certain quirks because of the lack of + // repetition counting. For instance, adding the same + // (reference-identical) element to two equivalent sets can + // make them non-equivalent. + return false; + } + + a.forEach(function (aVal) { + + // Short-circuit if the result is already known. (Using for...of + // with a break clause would be cleaner here, but it would cause + // a syntax error on older Javascript implementations even if + // Set is unused) + if (!outerEq) { + return; + } + + innerEq = false; + + b.forEach(function (bVal) { + var parentPairs; + + // Likewise, short-circuit if the result is already known + if (innerEq) { + return; + } + + // Swap out the global pairs list, as the nested call to + // innerEquiv will clobber its contents + parentPairs = pairs; + if (innerEquiv(bVal, aVal)) { + innerEq = true; + } + + // Replace the global pairs list + pairs = parentPairs; + }); + + if (!innerEq) { + outerEq = false; + } + }); + + return outerEq; + }, + + // Define maps a and b to be equivalent if for each key-value pair (aKey, aVal) + // in a, there is some key-value pair (bKey, bVal) in b such that + // [ aKey, aVal ] and [ bKey, bVal ] are equivalent. Key repetitions are not + // counted, so these are equivalent: + // a = new Map( [ [ {}, 1 ], [ {}, 1 ], [ [], 1 ] ] ); + // b = new Map( [ [ {}, 1 ], [ [], 1 ], [ [], 1 ] ] ); + "map": function map(a, b) { + var innerEq, + outerEq = true; + + if (a.size !== b.size) { + + // This optimization has certain quirks because of the lack of + // repetition counting. For instance, adding the same + // (reference-identical) key-value pair to two equivalent maps + // can make them non-equivalent. + return false; + } + + a.forEach(function (aVal, aKey) { + + // Short-circuit if the result is already known. (Using for...of + // with a break clause would be cleaner here, but it would cause + // a syntax error on older Javascript implementations even if + // Map is unused) + if (!outerEq) { + return; + } + + innerEq = false; + + b.forEach(function (bVal, bKey) { + var parentPairs; + + // Likewise, short-circuit if the result is already known + if (innerEq) { + return; + } + + // Swap out the global pairs list, as the nested call to + // innerEquiv will clobber its contents + parentPairs = pairs; + if (innerEquiv([bVal, bKey], [aVal, aKey])) { + innerEq = true; + } + + // Replace the global pairs list + pairs = parentPairs; + }); + + if (!innerEq) { + outerEq = false; + } + }); + + return outerEq; + }, + + "object": function object(a, b) { + var i, + aProperties = [], + bProperties = []; + + if (compareConstructors(a, b) === false) { + return false; + } + + // Be strict: don't ensure hasOwnProperty and go deep + for (i in a) { + + // Collect a's properties + aProperties.push(i); + + // Skip OOP methods that look the same + if (a.constructor !== Object && typeof a.constructor !== "undefined" && typeof a[i] === "function" && typeof b[i] === "function" && a[i].toString() === b[i].toString()) { + continue; + } + + // Compare non-containers; queue non-reference-equal containers + if (!breadthFirstCompareChild(a[i], b[i])) { + return false; + } + } + + for (i in b) { + + // Collect b's properties + bProperties.push(i); + } + + // Ensures identical properties name + return typeEquiv(aProperties.sort(), bProperties.sort()); + } + }; + + function typeEquiv(a, b) { + var type = objectType(a); + + // Callbacks for containers will append to the pairs queue to achieve breadth-first + // search order. The pairs queue is also used to avoid reprocessing any pair of + // containers that are reference-equal to a previously visited pair (a special case + // this being recursion detection). + // + // Because of this approach, once typeEquiv returns a false value, it should not be + // called again without clearing the pair queue else it may wrongly report a visited + // pair as being equivalent. + return objectType(b) === type && callbacks[type](a, b); + } + + function innerEquiv(a, b) { + var i, pair; + + // We're done when there's nothing more to compare + if (arguments.length < 2) { + return true; + } + + // Clear the global pair queue and add the top-level values being compared + pairs = [{ a: a, b: b }]; + + for (i = 0; i < pairs.length; i++) { + pair = pairs[i]; + + // Perform type-specific comparison on any pairs that are not strictly + // equal. For container types, that comparison will postpone comparison + // of any sub-container pair to the end of the pair queue. This gives + // breadth-first search order. It also avoids the reprocessing of + // reference-equal siblings, cousins etc, which can have a significant speed + // impact when comparing a container of small objects each of which has a + // reference to the same (singleton) large object. + if (pair.a !== pair.b && !typeEquiv(pair.a, pair.b)) { + return false; + } + } + + // ...across all consecutive argument pairs + return arguments.length === 2 || innerEquiv.apply(this, [].slice.call(arguments, 1)); + } + + return innerEquiv; + })(); + + /** + * Config object: Maintain internal state + * Later exposed as QUnit.config + * `config` initialized at top of scope + */ + var config = { + + // The queue of tests to run + queue: [], + + // Block until document ready + blocking: true, + + // 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, + + // HTML Reporter: collapse every test except the first failing test + // If false, all failing tests will be expanded + collapse: true, + + // By default, scroll to top of the page when suite is done + scrolltop: true, + + // Depth up-to which object will be dumped + maxDepth: 5, + + // When enabled, all tests must call expect() + requireExpects: false, + + // Placeholder for user-configurable form-exposed URL parameters + urlConfig: [], + + // Set of all modules. + modules: [], + + // The first unnamed module + currentModule: { + name: "", + tests: [], + childModules: [], + testsRun: 0, + unskippedTestsRun: 0 + }, + + callbacks: {}, + + // The storage module to use for reordering tests + storage: localSessionStorage + }; + + // take a predefined QUnit.config and extend the defaults + var globalConfig = window && window.QUnit && window.QUnit.config; + + // only extend the global config if there is no QUnit overload + if (window && window.QUnit && !window.QUnit.version) { + extend(config, globalConfig); + } + + // Push a loose unnamed module to the modules collection + config.modules.push(config.currentModule); + + // Based on jsDump by Ariel Flesler + // http://flesler.blogspot.com/2008/05/jsdump-pretty-dump-of-any-javascript.html + var dump = (function () { + function quote(str) { + return "\"" + str.toString().replace(/\\/g, "\\\\").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); + + if (dump.maxDepth && dump.depth > dump.maxDepth) { + return "[object Array]"; + } + + this.up(); + while (i--) { + ret[i] = this.parse(arr[i], undefined, stack); + } + this.down(); + return join("[", ret, "]"); + } + + function isArray(obj) { + return ( + + //Native Arrays + toString.call(obj) === "[object Array]" || + + // NodeList objects + typeof obj.length === "number" && obj.item !== undefined && (obj.length ? obj.item(0) === obj[0] : obj.item(0) === null && obj[0] === undefined) + ); + } + + var reName = /^function (\w+)/, + dump = { + + // The objType is used mostly internally, you can fix a (custom) type in advance + parse: function parse(obj, objType, stack) { + stack = stack || []; + var res, + parser, + parserType, + objIndex = stack.indexOf(obj); + + if (objIndex !== -1) { + return "recursion(" + (objIndex - stack.length) + ")"; + } + + objType = objType || this.typeOf(obj); + parser = this.parsers[objType]; + parserType = typeof parser === "undefined" ? "undefined" : _typeof(parser); + + if (parserType === "function") { + stack.push(obj); + res = parser.call(this, obj, stack); + stack.pop(); + return res; + } + return parserType === "string" ? parser : this.parsers.error; + }, + typeOf: function typeOf(obj) { + var type; + + if (obj === null) { + type = "null"; + } else if (typeof obj === "undefined") { + type = "undefined"; + } else if (is("regexp", obj)) { + type = "regexp"; + } else if (is("date", obj)) { + type = "date"; + } else if (is("function", obj)) { + type = "function"; + } else if (obj.setInterval !== undefined && obj.document !== undefined && obj.nodeType === undefined) { + type = "window"; + } else if (obj.nodeType === 9) { + type = "document"; + } else if (obj.nodeType) { + type = "node"; + } else if (isArray(obj)) { + type = "array"; + } else if (obj.constructor === Error.prototype.constructor) { + type = "error"; + } else { + type = typeof obj === "undefined" ? "undefined" : _typeof(obj); + } + return type; + }, + + separator: function separator() { + if (this.multiline) { + return this.HTML ? "
" : "\n"; + } else { + return this.HTML ? " " : " "; + } + }, + + // Extra can be a number, shortcut for increasing-calling-decreasing + indent: function indent(extra) { + if (!this.multiline) { + return ""; + } + var chr = this.indentChar; + if (this.HTML) { + chr = chr.replace(/\t/g, " ").replace(/ /g, " "); + } + return new Array(this.depth + (extra || 0)).join(chr); + }, + up: function up(a) { + this.depth += a || 1; + }, + down: function down(a) { + this.depth -= a || 1; + }, + setParser: function setParser(name, parser) { + this.parsers[name] = parser; + }, + + // The next 3 are exposed so you can use them + quote: quote, + literal: literal, + join: join, + depth: 1, + maxDepth: config.maxDepth, + + // This is the list of parsers, to modify them, use dump.setParser + parsers: { + window: "[Window]", + document: "[Document]", + error: function error(_error) { + return "Error(\"" + _error.message + "\")"; + }, + unknown: "[Unknown]", + "null": "null", + "undefined": "undefined", + "function": 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 object(map, stack) { + var keys, + key, + val, + i, + nonEnumerableProperties, + ret = []; + + if (dump.maxDepth && dump.depth > dump.maxDepth) { + return "[object Object]"; + } + + 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 && !inArray(key, 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(_node) { + var len, + i, + val, + open = dump.HTML ? "<" : "<", + close = dump.HTML ? ">" : ">", + 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 functionArgs(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 a html attribute value + attribute: quote, + string: quote, + date: quote, + regexp: literal, + number: literal, + "boolean": literal, + symbol: function symbol(sym) { + return sym.toString(); + } + }, + + // 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; + })(); + + var LISTENERS = Object.create(null); + var SUPPORTED_EVENTS = ["runStart", "suiteStart", "testStart", "assertion", "testEnd", "suiteEnd", "runEnd"]; + + /** + * Emits an event with the specified data to all currently registered listeners. + * Callbacks will fire in the order in which they are registered (FIFO). This + * function is not exposed publicly; it is used by QUnit internals to emit + * logging events. + * + * @private + * @method emit + * @param {String} eventName + * @param {Object} data + * @return {Void} + */ + function emit(eventName, data) { + if (objectType(eventName) !== "string") { + throw new TypeError("eventName must be a string when emitting an event"); + } + + // Clone the callbacks in case one of them registers a new callback + var originalCallbacks = LISTENERS[eventName]; + var callbacks = originalCallbacks ? [].concat(toConsumableArray(originalCallbacks)) : []; + + for (var i = 0; i < callbacks.length; i++) { + callbacks[i](data); + } + } + + /** + * Registers a callback as a listener to the specified event. + * + * @public + * @method on + * @param {String} eventName + * @param {Function} callback + * @return {Void} + */ + function on(eventName, callback) { + if (objectType(eventName) !== "string") { + throw new TypeError("eventName must be a string when registering a listener"); + } else if (!inArray(eventName, SUPPORTED_EVENTS)) { + var events = SUPPORTED_EVENTS.join(", "); + throw new Error("\"" + eventName + "\" is not a valid event; must be one of: " + events + "."); + } else if (objectType(callback) !== "function") { + throw new TypeError("callback must be a function when registering a listener"); + } + + if (!LISTENERS[eventName]) { + LISTENERS[eventName] = []; + } + + // Don't register the same callback more than once + if (!inArray(callback, LISTENERS[eventName])) { + LISTENERS[eventName].push(callback); + } + } + + // Register logging callbacks + function registerLoggingCallbacks(obj) { + var i, + l, + key, + callbackNames = ["begin", "done", "log", "testStart", "testDone", "moduleStart", "moduleDone"]; + + function registerLoggingCallback(key) { + var loggingCallback = function loggingCallback(callback) { + if (objectType(callback) !== "function") { + throw new Error("QUnit logging methods require a callback function as their first parameters."); + } + + config.callbacks[key].push(callback); + }; + + return loggingCallback; + } + + for (i = 0, l = callbackNames.length; i < l; i++) { + key = callbackNames[i]; + + // Initialize key collection of logging callback + if (objectType(config.callbacks[key]) === "undefined") { + config.callbacks[key] = []; + } + + obj[key] = registerLoggingCallback(key); + } + } + + function runLoggingCallbacks(key, args) { + var i, l, callbacks; + + callbacks = config.callbacks[key]; + for (i = 0, l = callbacks.length; i < l; i++) { + callbacks[i](args); + } + } + + // Doesn't support IE9, it will return undefined on these browsers + // See also https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error/Stack + var fileName = (sourceFromStacktrace(0) || "").replace(/(:\d+)+\)?/, "").replace(/.+\//, ""); + + function extractStacktrace(e, offset) { + offset = offset === undefined ? 4 : offset; + + var stack, include, i; + + if (e && e.stack) { + 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]; + } + } + + function sourceFromStacktrace(offset) { + var error = new Error(); + + // Support: Safari <=7 only, IE <=10 - 11 only + // Not all browsers generate the `stack` property for `new Error()`, see also #636 + if (!error.stack) { + try { + throw error; + } catch (err) { + error = err; + } + } + + return extractStacktrace(error, offset); + } + + var priorityCount = 0; + var unitSampler = void 0; + + /** + * Advances the ProcessingQueue to the next item if it is ready. + * @param {Boolean} last + */ + function advance() { + var start = now(); + config.depth = (config.depth || 0) + 1; + + while (config.queue.length && !config.blocking) { + var elapsedTime = now() - start; + + if (!defined.setTimeout || config.updateRate <= 0 || elapsedTime < config.updateRate) { + if (priorityCount > 0) { + priorityCount--; + } + + config.queue.shift()(); + } else { + setTimeout(advance, 13); + break; + } + } + + config.depth--; + + if (!config.blocking && !config.queue.length && config.depth === 0) { + done(); + } + } + + function addToQueueImmediate(callback) { + if (objectType(callback) === "array") { + while (callback.length) { + addToQueueImmediate(callback.pop()); + } + + return; + } + + config.queue.unshift(callback); + priorityCount++; + } + + /** + * Adds a function to the ProcessingQueue for execution. + * @param {Function|Array} callback + * @param {Boolean} priority + * @param {String} seed + */ + function addToQueue(callback, prioritize, seed) { + if (prioritize) { + config.queue.splice(priorityCount++, 0, callback); + } else if (seed) { + if (!unitSampler) { + unitSampler = unitSamplerGenerator(seed); + } + + // Insert into a random position after all prioritized items + var index = Math.floor(unitSampler() * (config.queue.length - priorityCount + 1)); + config.queue.splice(priorityCount + index, 0, callback); + } else { + config.queue.push(callback); + } + } + + /** + * Creates a seeded "sample" generator which is used for randomizing tests. + */ + function unitSamplerGenerator(seed) { + + // 32-bit xorshift, requires only a nonzero seed + // http://excamera.com/sphinx/article-xorshift.html + var sample = parseInt(generateHash(seed), 16) || -1; + return function () { + sample ^= sample << 13; + sample ^= sample >>> 17; + sample ^= sample << 5; + + // ECMAScript has no unsigned number type + if (sample < 0) { + sample += 0x100000000; + } + + return sample / 0x100000000; + }; + } + + /** + * This function is called when the ProcessingQueue is done processing all + * items. It handles emitting the final run events. + */ + function done() { + var storage = config.storage; + + ProcessingQueue.finished = true; + + var runtime = now() - config.started; + var passed = config.stats.all - config.stats.bad; + + emit("runEnd", globalSuite.end(true)); + runLoggingCallbacks("done", { + passed: passed, + failed: config.stats.bad, + total: config.stats.all, + runtime: runtime + }); + + // Clear own storage items if all tests passed + if (storage && config.stats.bad === 0) { + for (var i = storage.length - 1; i >= 0; i--) { + var key = storage.key(i); + + if (key.indexOf("qunit-test-") === 0) { + storage.removeItem(key); + } + } + } + } + + var ProcessingQueue = { + finished: false, + add: addToQueue, + addImmediate: addToQueueImmediate, + advance: advance + }; + + var TestReport = function () { + function TestReport(name, suite, options) { + classCallCheck(this, TestReport); + + this.name = name; + this.suiteName = suite.name; + this.fullName = suite.fullName.concat(name); + this.runtime = 0; + this.assertions = []; + + this.skipped = !!options.skip; + this.todo = !!options.todo; + + this.valid = options.valid; + + this._startTime = 0; + this._endTime = 0; + + suite.pushTest(this); + } + + createClass(TestReport, [{ + key: "start", + value: function start(recordTime) { + if (recordTime) { + this._startTime = Date.now(); + } + + return { + name: this.name, + suiteName: this.suiteName, + fullName: this.fullName.slice() + }; + } + }, { + key: "end", + value: function end(recordTime) { + if (recordTime) { + this._endTime = Date.now(); + } + + return extend(this.start(), { + runtime: this.getRuntime(), + status: this.getStatus(), + errors: this.getFailedAssertions(), + assertions: this.getAssertions() + }); + } + }, { + key: "pushAssertion", + value: function pushAssertion(assertion) { + this.assertions.push(assertion); + } + }, { + key: "getRuntime", + value: function getRuntime() { + return this._endTime - this._startTime; + } + }, { + key: "getStatus", + value: function getStatus() { + if (this.skipped) { + return "skipped"; + } + + var testPassed = this.getFailedAssertions().length > 0 ? this.todo : !this.todo; + + if (!testPassed) { + return "failed"; + } else if (this.todo) { + return "todo"; + } else { + return "passed"; + } + } + }, { + key: "getFailedAssertions", + value: function getFailedAssertions() { + return this.assertions.filter(function (assertion) { + return !assertion.passed; + }); + } + }, { + key: "getAssertions", + value: function getAssertions() { + return this.assertions.slice(); + } + + // Remove actual and expected values from assertions. This is to prevent + // leaking memory throughout a test suite. + + }, { + key: "slimAssertions", + value: function slimAssertions() { + this.assertions = this.assertions.map(function (assertion) { + delete assertion.actual; + delete assertion.expected; + return assertion; + }); + } + }]); + return TestReport; + }(); + + var focused = false; + + function Test(settings) { + var i, l; + + ++Test.count; + + this.expected = null; + extend(this, settings); + this.assertions = []; + this.semaphore = 0; + this.module = config.currentModule; + this.stack = sourceFromStacktrace(3); + this.steps = []; + + this.testReport = new TestReport(settings.testName, this.module.suiteReport, { + todo: settings.todo, + skip: settings.skip, + valid: this.valid() + }); + + // Register unique strings + for (i = 0, l = this.module.tests; i < l.length; i++) { + if (this.module.tests[i].name === this.testName) { + this.testName += " "; + } + } + + this.testId = generateHash(this.module.name, this.testName); + + this.module.tests.push({ + name: this.testName, + testId: this.testId, + skip: !!settings.skip + }); + + if (settings.skip) { + + // Skipped tests will fully ignore any sent callback + this.callback = function () {}; + this.async = false; + this.expected = 0; + } else { + this.assert = new Assert(this); + } + } + + Test.count = 0; + + function getNotStartedModules(startModule) { + var module = startModule, + modules = []; + + while (module && module.testsRun === 0) { + modules.push(module); + module = module.parentModule; + } + + return modules; + } + + Test.prototype = { + before: function before() { + var i, + startModule, + module = this.module, + notStartedModules = getNotStartedModules(module); + + for (i = notStartedModules.length - 1; i >= 0; i--) { + startModule = notStartedModules[i]; + startModule.stats = { all: 0, bad: 0, started: now() }; + emit("suiteStart", startModule.suiteReport.start(true)); + runLoggingCallbacks("moduleStart", { + name: startModule.name, + tests: startModule.tests + }); + } + + config.current = this; + + this.testEnvironment = extend({}, module.testEnvironment); + + this.started = now(); + emit("testStart", this.testReport.start(true)); + runLoggingCallbacks("testStart", { + name: this.testName, + module: module.name, + testId: this.testId, + previousFailure: this.previousFailure + }); + + if (!config.pollution) { + saveGlobal(); + } + }, + + run: function run() { + var promise; + + config.current = this; + + this.callbackStarted = now(); + + if (config.notrycatch) { + runTest(this); + return; + } + + try { + runTest(this); + } catch (e) { + 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) { + internalRecover(this); + } + } + + function runTest(test) { + promise = test.callback.call(test.testEnvironment, test.assert); + test.resolvePromise(promise); + } + }, + + after: function after() { + checkPollution(); + }, + + queueHook: function queueHook(hook, hookName, hookOwner) { + var promise, + test = this; + return function runHook() { + if (hookName === "before") { + if (hookOwner.unskippedTestsRun !== 0) { + return; + } + + test.preserveEnvironment = true; + } + + if (hookName === "after" && hookOwner.unskippedTestsRun !== numberOfUnskippedTests(hookOwner) - 1 && config.queue.length > 2) { + return; + } + + config.current = test; + if (config.notrycatch) { + callHook(); + return; + } + try { + callHook(); + } catch (error) { + test.pushFailure(hookName + " failed on " + test.testName + ": " + (error.message || error), extractStacktrace(error, 0)); + } + + function callHook() { + promise = hook.call(test.testEnvironment, test.assert); + test.resolvePromise(promise, hookName); + } + }; + }, + + // Currently only used for module level hooks, can be used to add global level ones + hooks: function hooks(handler) { + var hooks = []; + + function processHooks(test, module) { + if (module.parentModule) { + processHooks(test, module.parentModule); + } + if (module.hooks && objectType(module.hooks[handler]) === "function") { + hooks.push(test.queueHook(module.hooks[handler], handler, module)); + } + } + + // Hooks are ignored on skipped tests + if (!this.skip) { + processHooks(this, this.module); + } + return hooks; + }, + + finish: function finish() { + 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, + module = this.module, + moduleName = module.name, + testName = this.testName, + skipped = !!this.skip, + todo = !!this.todo, + bad = 0, + storage = config.storage; + + this.runtime = now() - this.started; + + config.stats.all += this.assertions.length; + module.stats.all += this.assertions.length; + + for (i = 0; i < this.assertions.length; i++) { + if (!this.assertions[i].result) { + bad++; + config.stats.bad++; + module.stats.bad++; + } + } + + notifyTestsRan(module, skipped); + + // Store result when possible + if (storage) { + if (bad) { + storage.setItem("qunit-test-" + moduleName + "-" + testName, bad); + } else { + storage.removeItem("qunit-test-" + moduleName + "-" + testName); + } + } + + // After emitting the js-reporters event we cleanup the assertion data to + // avoid leaking it. It is not used by the legacy testDone callbacks. + emit("testEnd", this.testReport.end(true)); + this.testReport.slimAssertions(); + + runLoggingCallbacks("testDone", { + name: testName, + module: moduleName, + skipped: skipped, + todo: todo, + failed: bad, + passed: this.assertions.length - bad, + total: this.assertions.length, + runtime: skipped ? 0 : this.runtime, + + // HTML Reporter use + assertions: this.assertions, + testId: this.testId, + + // Source of Test + source: this.stack + }); + + if (module.testsRun === numberOfTests(module)) { + logSuiteEnd(module); + + // Check if the parent modules, iteratively, are done. If that the case, + // we emit the `suiteEnd` event and trigger `moduleDone` callback. + var parent = module.parentModule; + while (parent && parent.testsRun === numberOfTests(parent)) { + logSuiteEnd(parent); + parent = parent.parentModule; + } + } + + config.current = undefined; + + function logSuiteEnd(module) { + emit("suiteEnd", module.suiteReport.end(true)); + runLoggingCallbacks("moduleDone", { + name: module.name, + tests: module.tests, + failed: module.stats.bad, + passed: module.stats.all - module.stats.bad, + total: module.stats.all, + runtime: now() - module.stats.started + }); + } + }, + + preserveTestEnvironment: function preserveTestEnvironment() { + if (this.preserveEnvironment) { + this.module.testEnvironment = this.testEnvironment; + this.testEnvironment = extend({}, this.module.testEnvironment); + } + }, + + queue: function queue() { + var test = this; + + if (!this.valid()) { + return; + } + + function runTest() { + + // Each of these can by async + ProcessingQueue.addImmediate([function () { + test.before(); + }, test.hooks("before"), function () { + test.preserveTestEnvironment(); + }, test.hooks("beforeEach"), function () { + test.run(); + }, test.hooks("afterEach").reverse(), test.hooks("after").reverse(), function () { + test.after(); + }, function () { + test.finish(); + }]); + } + + var previousFailCount = config.storage && +config.storage.getItem("qunit-test-" + this.module.name + "-" + this.testName); + + // Prioritize previously failed tests, detected from storage + var prioritize = config.reorder && !!previousFailCount; + + this.previousFailure = !!previousFailCount; + + ProcessingQueue.add(runTest, prioritize, config.seed); + + // If the queue has already finished, we manually process the new test + if (ProcessingQueue.finished) { + ProcessingQueue.advance(); + } + }, + + + pushResult: function pushResult(resultInfo) { + if (this !== config.current) { + throw new Error("Assertion occured after test had finished."); + } + + // Destructure of resultInfo = { result, actual, expected, message, negative } + var source, + details = { + module: this.module.name, + name: this.testName, + result: resultInfo.result, + message: resultInfo.message, + actual: resultInfo.actual, + expected: resultInfo.expected, + testId: this.testId, + negative: resultInfo.negative || false, + runtime: now() - this.started, + todo: !!this.todo + }; + + if (!resultInfo.result) { + source = resultInfo.source || sourceFromStacktrace(); + + if (source) { + details.source = source; + } + } + + this.logAssertion(details); + + this.assertions.push({ + result: !!resultInfo.result, + message: resultInfo.message + }); + }, + + pushFailure: function pushFailure(message, source, actual) { + if (!(this instanceof Test)) { + throw new Error("pushFailure() assertion outside test context, was " + sourceFromStacktrace(2)); + } + + this.pushResult({ + result: false, + message: message || "error", + actual: actual || null, + expected: null, + source: source + }); + }, + + /** + * Log assertion details using both the old QUnit.log interface and + * QUnit.on( "assertion" ) interface. + * + * @private + */ + logAssertion: function logAssertion(details) { + runLoggingCallbacks("log", details); + + var assertion = { + passed: details.result, + actual: details.actual, + expected: details.expected, + message: details.message, + stack: details.source, + todo: details.todo + }; + this.testReport.pushAssertion(assertion); + emit("assertion", assertion); + }, + + + resolvePromise: function resolvePromise(promise, phase) { + var then, + resume, + message, + test = this; + if (promise != null) { + then = promise.then; + if (objectType(then) === "function") { + resume = internalStop(test); + then.call(promise, function () { + resume(); + }, function (error) { + message = "Promise rejected " + (!phase ? "during" : phase.replace(/Each$/, "")) + " \"" + test.testName + "\": " + (error && error.message || error); + test.pushFailure(message, extractStacktrace(error, 0)); + + // Else next test will carry the responsibility + saveGlobal(); + + // Unblock + resume(); + }); + } + } + }, + + valid: function valid() { + var filter = config.filter, + regexFilter = /^(!?)\/([\w\W]*)\/(i?$)/.exec(filter), + module = config.module && config.module.toLowerCase(), + fullName = this.module.name + ": " + this.testName; + + function moduleChainNameMatch(testModule) { + var testModuleName = testModule.name ? testModule.name.toLowerCase() : null; + if (testModuleName === module) { + return true; + } else if (testModule.parentModule) { + return moduleChainNameMatch(testModule.parentModule); + } else { + return false; + } + } + + function moduleChainIdMatch(testModule) { + return inArray(testModule.moduleId, config.moduleId) || testModule.parentModule && moduleChainIdMatch(testModule.parentModule); + } + + // Internally-generated tests are always valid + if (this.callback && this.callback.validTest) { + return true; + } + + if (config.moduleId && config.moduleId.length > 0 && !moduleChainIdMatch(this.module)) { + + return false; + } + + if (config.testId && config.testId.length > 0 && !inArray(this.testId, config.testId)) { + + return false; + } + + if (module && !moduleChainNameMatch(this.module)) { + return false; + } + + if (!filter) { + return true; + } + + return regexFilter ? this.regexFilter(!!regexFilter[1], regexFilter[2], regexFilter[3], fullName) : this.stringFilter(filter, fullName); + }, + + regexFilter: function regexFilter(exclude, pattern, flags, fullName) { + var regex = new RegExp(pattern, flags); + var match = regex.test(fullName); + + return match !== exclude; + }, + + stringFilter: function stringFilter(filter, fullName) { + filter = filter.toLowerCase(); + fullName = fullName.toLowerCase(); + + var 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; + } + }; + + function pushFailure() { + if (!config.current) { + throw new Error("pushFailure() assertion outside test context, in " + sourceFromStacktrace(2)); + } + + // Gets current test obj + var currentTest = config.current; + + return currentTest.pushFailure.apply(currentTest, arguments); + } + + function saveGlobal() { + config.pollution = []; + + if (config.noglobals) { + for (var key in global$1) { + if (hasOwn.call(global$1, 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) { + pushFailure("Introduced global variable(s): " + newGlobals.join(", ")); + } + + deletedGlobals = diff(old, config.pollution); + if (deletedGlobals.length > 0) { + pushFailure("Deleted global variable(s): " + deletedGlobals.join(", ")); + } + } + + // Will be exposed as QUnit.test + function test(testName, callback) { + if (focused) { + return; + } + + var newTest = new Test({ + testName: testName, + callback: callback + }); + + newTest.queue(); + } + + function todo(testName, callback) { + if (focused) { + return; + } + + var newTest = new Test({ + testName: testName, + callback: callback, + todo: true + }); + + newTest.queue(); + } + + // Will be exposed as QUnit.skip + function skip(testName) { + if (focused) { + return; + } + + var test = new Test({ + testName: testName, + skip: true + }); + + test.queue(); + } + + // Will be exposed as QUnit.only + function only(testName, callback) { + if (focused) { + return; + } + + config.queue.length = 0; + focused = true; + + var newTest = new Test({ + testName: testName, + callback: callback + }); + + newTest.queue(); + } + + // Put a hold on processing and return a function that will release it. + function internalStop(test) { + var released = false; + + test.semaphore += 1; + config.blocking = true; + + // Set a recovery timeout, if so configured. + if (config.testTimeout && defined.setTimeout) { + clearTimeout(config.timeout); + config.timeout = setTimeout(function () { + pushFailure("Test timed out", sourceFromStacktrace(2)); + internalRecover(test); + }, config.testTimeout); + } + + return function resume() { + if (released) { + return; + } + + released = true; + test.semaphore -= 1; + internalStart(test); + }; + } + + // Forcefully release all processing holds. + function internalRecover(test) { + test.semaphore = 0; + internalStart(test); + } + + // Release a processing hold, scheduling a resumption attempt if no holds remain. + function internalStart(test) { + + // If semaphore is non-numeric, throw error + if (isNaN(test.semaphore)) { + test.semaphore = 0; + + pushFailure("Invalid value on test.semaphore", sourceFromStacktrace(2)); + return; + } + + // Don't start until equal number of stop-calls + if (test.semaphore > 0) { + return; + } + + // Throw an Error if start is called more often than stop + if (test.semaphore < 0) { + test.semaphore = 0; + + pushFailure("Tried to restart test while already started (test's semaphore was 0 already)", sourceFromStacktrace(2)); + return; + } + + // Add a slight delay to allow more assertions etc. + if (defined.setTimeout) { + if (config.timeout) { + clearTimeout(config.timeout); + } + config.timeout = setTimeout(function () { + if (test.semaphore > 0) { + return; + } + + if (config.timeout) { + clearTimeout(config.timeout); + } + + begin(); + }, 13); + } else { + begin(); + } + } + + function collectTests(module) { + var tests = [].concat(module.tests); + var modules = [].concat(toConsumableArray(module.childModules)); + + // Do a breadth-first traversal of the child modules + while (modules.length) { + var nextModule = modules.shift(); + tests.push.apply(tests, nextModule.tests); + modules.push.apply(modules, toConsumableArray(nextModule.childModules)); + } + + return tests; + } + + function numberOfTests(module) { + return collectTests(module).length; + } + + function numberOfUnskippedTests(module) { + return collectTests(module).filter(function (test) { + return !test.skip; + }).length; + } + + function notifyTestsRan(module, skipped) { + module.testsRun++; + if (!skipped) { + module.unskippedTestsRun++; + } + while (module = module.parentModule) { + module.testsRun++; + if (!skipped) { + module.unskippedTestsRun++; + } + } + } + + /** + * Returns a function that proxies to the given method name on the globals + * console object. The proxy will also detect if the console doesn't exist and + * will appropriately no-op. This allows support for IE9, which doesn't have a + * console if the developer tools are not open. + */ + function consoleProxy(method) { + return function () { + if (console) { + console[method].apply(console, arguments); + } + }; + } + + var Logger = { + warn: consoleProxy("warn") + }; + + var Assert = function () { + function Assert(testContext) { + classCallCheck(this, Assert); + + this.test = testContext; + } + + // Assert helpers + + // Documents a "step", which is a string value, in a test as a passing assertion + + + createClass(Assert, [{ + key: "step", + value: function step(message) { + var result = !!message; + + this.test.steps.push(message); + + return this.pushResult({ + result: result, + message: message || "You must provide a message to assert.step" + }); + } + + // Verifies the steps in a test match a given array of string values + + }, { + key: "verifySteps", + value: function verifySteps(steps, message) { + this.deepEqual(this.test.steps, steps, message); + } + + // Specify the number of expected assertions to guarantee that failed test + // (no assertions are run at all) don't slip through. + + }, { + key: "expect", + value: function expect(asserts) { + if (arguments.length === 1) { + this.test.expected = asserts; + } else { + return this.test.expected; + } + } + + // Put a hold on processing and return a function that will release it a maximum of once. + + }, { + key: "async", + value: function async(count) { + var test$$1 = this.test; + + var popped = false, + acceptCallCount = count; + + if (typeof acceptCallCount === "undefined") { + acceptCallCount = 1; + } + + var resume = internalStop(test$$1); + + return function done() { + if (config.current !== test$$1) { + throw Error("assert.async callback called after test finished."); + } + + if (popped) { + test$$1.pushFailure("Too many calls to the `assert.async` callback", sourceFromStacktrace(2)); + return; + } + + acceptCallCount -= 1; + if (acceptCallCount > 0) { + return; + } + + popped = true; + resume(); + }; + } + + // Exports test.push() to the user API + // Alias of pushResult. + + }, { + key: "push", + value: function push(result, actual, expected, message, negative) { + Logger.warn("assert.push is deprecated and will be removed in QUnit 3.0." + " Please use assert.pushResult instead (http://api.qunitjs.com/pushResult/)."); + + var currentAssert = this instanceof Assert ? this : config.current.assert; + return currentAssert.pushResult({ + result: result, + actual: actual, + expected: expected, + message: message, + negative: negative + }); + } + }, { + key: "pushResult", + value: function pushResult(resultInfo) { + + // Destructure of resultInfo = { result, actual, expected, message, negative } + var assert = this; + var currentTest = assert instanceof Assert && assert.test || config.current; + + // 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 (!currentTest) { + throw new Error("assertion outside test context, in " + sourceFromStacktrace(2)); + } + + if (!(assert instanceof Assert)) { + assert = currentTest.assert; + } + + return assert.test.pushResult(resultInfo); + } + }, { + key: "ok", + value: function ok(result, message) { + if (!message) { + message = result ? "okay" : "failed, expected argument to be truthy, was: " + dump.parse(result); + } + + this.pushResult({ + result: !!result, + actual: result, + expected: true, + message: message + }); + } + }, { + key: "notOk", + value: function notOk(result, message) { + if (!message) { + message = !result ? "okay" : "failed, expected argument to be falsy, was: " + dump.parse(result); + } + + this.pushResult({ + result: !result, + actual: result, + expected: false, + message: message + }); + } + }, { + key: "equal", + value: function equal(actual, expected, message) { + + // eslint-disable-next-line eqeqeq + var result = expected == actual; + + this.pushResult({ + result: result, + actual: actual, + expected: expected, + message: message + }); + } + }, { + key: "notEqual", + value: function notEqual(actual, expected, message) { + + // eslint-disable-next-line eqeqeq + var result = expected != actual; + + this.pushResult({ + result: result, + actual: actual, + expected: expected, + message: message, + negative: true + }); + } + }, { + key: "propEqual", + value: function propEqual(actual, expected, message) { + actual = objectValues(actual); + expected = objectValues(expected); + + this.pushResult({ + result: equiv(actual, expected), + actual: actual, + expected: expected, + message: message + }); + } + }, { + key: "notPropEqual", + value: function notPropEqual(actual, expected, message) { + actual = objectValues(actual); + expected = objectValues(expected); + + this.pushResult({ + result: !equiv(actual, expected), + actual: actual, + expected: expected, + message: message, + negative: true + }); + } + }, { + key: "deepEqual", + value: function deepEqual(actual, expected, message) { + this.pushResult({ + result: equiv(actual, expected), + actual: actual, + expected: expected, + message: message + }); + } + }, { + key: "notDeepEqual", + value: function notDeepEqual(actual, expected, message) { + this.pushResult({ + result: !equiv(actual, expected), + actual: actual, + expected: expected, + message: message, + negative: true + }); + } + }, { + key: "strictEqual", + value: function strictEqual(actual, expected, message) { + this.pushResult({ + result: expected === actual, + actual: actual, + expected: expected, + message: message + }); + } + }, { + key: "notStrictEqual", + value: function notStrictEqual(actual, expected, message) { + this.pushResult({ + result: expected !== actual, + actual: actual, + expected: expected, + message: message, + negative: true + }); + } + }, { + key: "throws", + value: function throws(block, expected, message) { + var actual = void 0, + result = false; + + var currentTest = this instanceof Assert && this.test || config.current; + + // 'expected' is optional unless doing string comparison + if (objectType(expected) === "string") { + if (message == null) { + message = expected; + expected = null; + } else { + throw new Error("throws/raises does not accept a string value for the expected argument.\n" + "Use a non-string object value (e.g. regExp) instead if it's necessary."); + } + } + + currentTest.ignoreGlobalErrors = true; + try { + block.call(currentTest.testEnvironment); + } catch (e) { + actual = e; + } + currentTest.ignoreGlobalErrors = false; + + if (actual) { + var expectedType = objectType(expected); + + // We don't want to validate thrown error + if (!expected) { + result = true; + expected = null; + + // Expected is a regexp + } else if (expectedType === "regexp") { + result = expected.test(errorString(actual)); + + // Expected is a constructor, maybe an Error constructor + } else if (expectedType === "function" && actual instanceof expected) { + result = true; + + // Expected is an Error object + } else if (expectedType === "object") { + result = 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) { + expected = null; + result = true; + } + } + + currentTest.assert.pushResult({ + result: result, + actual: actual, + expected: expected, + message: message + }); + } + }]); + return Assert; + }(); + + // Provide an alternative to assert.throws(), for environments that consider throws a reserved word + // Known to us are: Closure Compiler, Narwhal + // eslint-disable-next-line dot-notation + + + Assert.prototype.raises = Assert.prototype["throws"]; + + /** + * Converts an error into a simple string for comparisons. + * + * @param {Error} error + * @return {String} + */ + function errorString(error) { + var resultErrorString = error.toString(); + + if (resultErrorString.substring(0, 7) === "[object") { + var name = error.name ? error.name.toString() : "Error"; + var 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 resultErrorString; + } + } + + /* global module, exports, define */ + function exportQUnit(QUnit) { + + if (defined.document) { + + // QUnit may be defined when it is preconfigured but then only QUnit and QUnit.config may be defined. + if (window.QUnit && window.QUnit.version) { + throw new Error("QUnit has already been defined."); + } + + window.QUnit = QUnit; + } + + // For nodejs + if (typeof module !== "undefined" && module && module.exports) { + module.exports = QUnit; + + // For consistency with CommonJS environments' exports + module.exports.QUnit = QUnit; + } + + // For CommonJS with exports, but without module.exports, like Rhino + if (typeof exports !== "undefined" && exports) { + exports.QUnit = QUnit; + } + + if (typeof define === "function" && define.amd) { + define(function () { + return QUnit; + }); + QUnit.config.autostart = false; + } + } + + var SuiteReport = function () { + function SuiteReport(name, parentSuite) { + classCallCheck(this, SuiteReport); + + this.name = name; + this.fullName = parentSuite ? parentSuite.fullName.concat(name) : []; + + this.tests = []; + this.childSuites = []; + + if (parentSuite) { + parentSuite.pushChildSuite(this); + } + } + + createClass(SuiteReport, [{ + key: "start", + value: function start(recordTime) { + if (recordTime) { + this._startTime = Date.now(); + } + + return { + name: this.name, + fullName: this.fullName.slice(), + tests: this.tests.map(function (test) { + return test.start(); + }), + childSuites: this.childSuites.map(function (suite) { + return suite.start(); + }), + testCounts: { + total: this.getTestCounts().total + } + }; + } + }, { + key: "end", + value: function end(recordTime) { + if (recordTime) { + this._endTime = Date.now(); + } + + return { + name: this.name, + fullName: this.fullName.slice(), + tests: this.tests.map(function (test) { + return test.end(); + }), + childSuites: this.childSuites.map(function (suite) { + return suite.end(); + }), + testCounts: this.getTestCounts(), + runtime: this.getRuntime(), + status: this.getStatus() + }; + } + }, { + key: "pushChildSuite", + value: function pushChildSuite(suite) { + this.childSuites.push(suite); + } + }, { + key: "pushTest", + value: function pushTest(test) { + this.tests.push(test); + } + }, { + key: "getRuntime", + value: function getRuntime() { + return this._endTime - this._startTime; + } + }, { + key: "getTestCounts", + value: function getTestCounts() { + var counts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { passed: 0, failed: 0, skipped: 0, todo: 0, total: 0 }; + + counts = this.tests.reduce(function (counts, test) { + if (test.valid) { + counts[test.getStatus()]++; + counts.total++; + } + + return counts; + }, counts); + + return this.childSuites.reduce(function (counts, suite) { + return suite.getTestCounts(counts); + }, counts); + } + }, { + key: "getStatus", + value: function getStatus() { + var _getTestCounts = this.getTestCounts(), + total = _getTestCounts.total, + failed = _getTestCounts.failed, + skipped = _getTestCounts.skipped, + todo = _getTestCounts.todo; + + if (failed) { + return "failed"; + } else { + if (skipped === total) { + return "skipped"; + } else if (todo === total) { + return "todo"; + } else { + return "passed"; + } + } + } + }]); + return SuiteReport; + }(); + + // Handle an unhandled exception. By convention, returns true if further + // error handling should be suppressed and false otherwise. + // In this case, we will only suppress further error handling if the + // "ignoreGlobalErrors" configuration option is enabled. + function onError(error) { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + if (config.current) { + if (config.current.ignoreGlobalErrors) { + return true; + } + pushFailure.apply(undefined, [error.message, error.fileName + ":" + error.lineNumber].concat(args)); + } else { + test("global failure", extend(function () { + pushFailure.apply(undefined, [error.message, error.fileName + ":" + error.lineNumber].concat(args)); + }, { validTest: true })); + } + + return false; + } + + var QUnit = {}; + var globalSuite = new SuiteReport(); + + // The initial "currentModule" represents the global (or top-level) module that + // is not explicitly defined by the user, therefore we add the "globalSuite" to + // it since each module has a suiteReport associated with it. + config.currentModule.suiteReport = globalSuite; + + var moduleStack = []; + var globalStartCalled = false; + var runStarted = false; + + // Figure out if we're running the tests from a server or not + QUnit.isLocal = !(defined.document && window.location.protocol !== "file:"); + + // Expose the current QUnit version + QUnit.version = "2.3.2"; + + function createModule(name, testEnvironment) { + var parentModule = moduleStack.length ? moduleStack.slice(-1)[0] : null; + var moduleName = parentModule !== null ? [parentModule.name, name].join(" > ") : name; + var parentSuite = parentModule ? parentModule.suiteReport : globalSuite; + + var module = { + name: moduleName, + parentModule: parentModule, + tests: [], + moduleId: generateHash(moduleName), + testsRun: 0, + unskippedTestsRun: 0, + childModules: [], + suiteReport: new SuiteReport(name, parentSuite) + }; + + var env = {}; + if (parentModule) { + parentModule.childModules.push(module); + extend(env, parentModule.testEnvironment); + } + extend(env, testEnvironment); + module.testEnvironment = env; + + config.modules.push(module); + return module; + } + + extend(QUnit, { + on: on, + + // Call on start of module test to prepend name to all tests + module: function module(name, testEnvironment, executeNow) { + if (arguments.length === 2) { + if (objectType(testEnvironment) === "function") { + executeNow = testEnvironment; + testEnvironment = undefined; + } + } + + var module = createModule(name, testEnvironment); + + // Move any hooks to a 'hooks' object + if (module.testEnvironment) { + module.hooks = { + before: module.testEnvironment.before, + beforeEach: module.testEnvironment.beforeEach, + afterEach: module.testEnvironment.afterEach, + after: module.testEnvironment.after + }; + + delete module.testEnvironment.before; + delete module.testEnvironment.beforeEach; + delete module.testEnvironment.afterEach; + delete module.testEnvironment.after; + } + + var moduleFns = { + before: setHook(module, "before"), + beforeEach: setHook(module, "beforeEach"), + afterEach: setHook(module, "afterEach"), + after: setHook(module, "after") + }; + + var currentModule = config.currentModule; + if (objectType(executeNow) === "function") { + moduleStack.push(module); + config.currentModule = module; + executeNow.call(module.testEnvironment, moduleFns); + moduleStack.pop(); + module = module.parentModule || currentModule; + } + + config.currentModule = module; + }, + + test: test, + + todo: todo, + + skip: skip, + + only: only, + + start: function start(count) { + var globalStartAlreadyCalled = globalStartCalled; + + if (!config.current) { + globalStartCalled = true; + + if (runStarted) { + throw new Error("Called start() while test already started running"); + } else if (globalStartAlreadyCalled || count > 1) { + throw new Error("Called start() outside of a test context too many times"); + } else if (config.autostart) { + throw new Error("Called start() outside of a test context when " + "QUnit.config.autostart was true"); + } else if (!config.pageLoaded) { + + // The page isn't completely loaded yet, so we set autostart and then + // load if we're in Node or wait for the browser's load event. + config.autostart = true; + + // Starts from Node even if .load was not previously called. We still return + // early otherwise we'll wind up "beginning" twice. + if (!defined.document) { + QUnit.load(); + } + + return; + } + } else { + throw new Error("QUnit.start cannot be called inside a test context."); + } + + scheduleBegin(); + }, + + config: config, + + is: is, + + objectType: objectType, + + extend: extend, + + load: function load() { + config.pageLoaded = true; + + // Initialize the configuration options + extend(config, { + stats: { all: 0, bad: 0 }, + started: 0, + updateRate: 1000, + autostart: true, + filter: "" + }, true); + + if (!runStarted) { + config.blocking = false; + + if (config.autostart) { + scheduleBegin(); + } + } + }, + + stack: function stack(offset) { + offset = (offset || 0) + 2; + return sourceFromStacktrace(offset); + }, + + onError: onError + }); + + QUnit.pushFailure = pushFailure; + QUnit.assert = Assert.prototype; + QUnit.equiv = equiv; + QUnit.dump = dump; + + registerLoggingCallbacks(QUnit); + + function scheduleBegin() { + + runStarted = true; + + // Add a slight delay to allow definition of more modules and tests. + if (defined.setTimeout) { + setTimeout(function () { + begin(); + }, 13); + } else { + begin(); + } + } + + function begin() { + var i, + l, + modulesLog = []; + + // If the test run hasn't officially begun yet + if (!config.started) { + + // Record the time of the test run's beginning + config.started = now(); + + // Delete the loose unnamed module if unused. + if (config.modules[0].name === "" && config.modules[0].tests.length === 0) { + config.modules.shift(); + } + + // Avoid unnecessary information by not logging modules' test environments + for (i = 0, l = config.modules.length; i < l; i++) { + modulesLog.push({ + name: config.modules[i].name, + tests: config.modules[i].tests + }); + } + + // The test run is officially beginning now + emit("runStart", globalSuite.start(true)); + runLoggingCallbacks("begin", { + totalTests: Test.count, + modules: modulesLog + }); + } + + config.blocking = false; + ProcessingQueue.advance(); + } + + function setHook(module, hookName) { + if (!module.hooks) { + module.hooks = {}; + } + + return function (callback) { + module.hooks[hookName] = callback; + }; + } + + exportQUnit(QUnit); + + (function () { + + if (typeof window === "undefined" || typeof document === "undefined") { + return; + } + + var config = QUnit.config, + hasOwn = Object.prototype.hasOwnProperty; + + // Stores fixture HTML for resetting later + function storeFixture() { + + // Avoid overwriting user-defined values + if (hasOwn.call(config, "fixture")) { + return; + } + + var fixture = document.getElementById("qunit-fixture"); + if (fixture) { + config.fixture = fixture.innerHTML; + } + } + + QUnit.begin(storeFixture); + + // Resets the fixture DOM element if available. + function resetFixture() { + if (config.fixture == null) { + return; + } + + var fixture = document.getElementById("qunit-fixture"); + if (fixture) { + fixture.innerHTML = config.fixture; + } + } + + QUnit.testStart(resetFixture); + })(); + + (function () { + + // Only interact with URLs via window.location + var location = typeof window !== "undefined" && window.location; + if (!location) { + return; + } + + var urlParams = getUrlParams(); + + QUnit.urlParams = urlParams; + + // Match module/test by inclusion in an array + QUnit.config.moduleId = [].concat(urlParams.moduleId || []); + QUnit.config.testId = [].concat(urlParams.testId || []); + + // Exact case-insensitive match of the module name + QUnit.config.module = urlParams.module; + + // Regular expression or case-insenstive substring match against "moduleName: testName" + QUnit.config.filter = urlParams.filter; + + // Test order randomization + if (urlParams.seed === true) { + + // Generate a random seed if the option is specified without a value + QUnit.config.seed = Math.random().toString(36).slice(2); + } else if (urlParams.seed) { + QUnit.config.seed = urlParams.seed; + } + + // Add URL-parameter-mapped config values with UI form rendering data + QUnit.config.urlConfig.push({ + id: "hidepassed", + label: "Hide passed tests", + tooltip: "Only show tests and assertions that fail. Stored as query-strings." + }, { + id: "noglobals", + label: "Check for Globals", + tooltip: "Enabling this will test if any test introduces new properties on the " + "global object (`window` in Browsers). 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." + }); + + QUnit.begin(function () { + var i, + option, + urlConfig = QUnit.config.urlConfig; + + for (i = 0; i < urlConfig.length; i++) { + + // Options can be either strings or objects with nonempty "id" properties + option = QUnit.config.urlConfig[i]; + if (typeof option !== "string") { + option = option.id; + } + + if (QUnit.config[option] === undefined) { + QUnit.config[option] = urlParams[option]; + } + } + }); + + function getUrlParams() { + var i, param, name, value; + var urlParams = Object.create(null); + var params = location.search.slice(1).split("&"); + var length = params.length; + + for (i = 0; i < length; i++) { + if (params[i]) { + param = params[i].split("="); + name = decodeQueryParam(param[0]); + + // Allow just a key to turn on a flag, e.g., test.html?noglobals + value = param.length === 1 || decodeQueryParam(param.slice(1).join("=")); + if (name in urlParams) { + urlParams[name] = [].concat(urlParams[name], value); + } else { + urlParams[name] = value; + } + } + } + + return urlParams; + } + + function decodeQueryParam(param) { + return decodeURIComponent(param.replace(/\+/g, "%20")); + } + })(); + + var stats = { + passedTests: 0, + failedTests: 0, + skippedTests: 0, + todoTests: 0 + }; + + // 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 "'"; + case "\"": + return """; + case "<": + return "<"; + case ">": + return ">"; + case "&": + return "&"; + } + }); + } + + (function () { + + // Don't load the HTML Reporter on non-browser environments + if (typeof window === "undefined" || !window.document) { + return; + } + + var config = QUnit.config, + document$$1 = window.document, + collapseNext = false, + hasOwn = Object.prototype.hasOwnProperty, + unfilteredUrl = setUrl({ filter: undefined, module: undefined, + moduleId: undefined, testId: undefined }), + modulesList = []; + + function addEvent(elem, type, fn) { + elem.addEventListener(type, fn, false); + } + + function removeEvent(elem, type, fn) { + elem.removeEventListener(type, fn, false); + } + + 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, force) { + if (force || typeof force === "undefined" && !hasClass(elem, name)) { + addClass(elem, name); + } else { + removeClass(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 document$$1.getElementById && document$$1.getElementById(name); + } + + function abortTests() { + var abortButton = id("qunit-abort-tests-button"); + if (abortButton) { + abortButton.disabled = true; + abortButton.innerHTML = "Aborting..."; + } + QUnit.config.queue.length = 0; + return false; + } + + function interceptNavigation(ev) { + applyUrlParams(); + + if (ev && ev.preventDefault) { + ev.preventDefault(); + } + + return false; + } + + function getUrlConfigHtml() { + var i, + j, + val, + escaped, + escapedTooltip, + selection = false, + urlConfig = config.urlConfig, + urlConfigHtml = ""; + + for (i = 0; i < urlConfig.length; i++) { + + // Options can be either strings or objects with nonempty "id" properties + val = config.urlConfig[i]; + if (typeof val === "string") { + val = { + id: val, + label: val + }; + } + + escaped = escapeText(val.id); + escapedTooltip = escapeText(val.tooltip); + + if (!val.value || typeof val.value === "string") { + urlConfigHtml += ""; + } else { + urlConfigHtml += ""; + } + } + + return urlConfigHtml; + } + + // Handle "click" events on toolbar checkboxes and "change" for select menus. + // Updates the URL with the new state of `config.urlConfig` values. + function toolbarChanged() { + var updatedUrl, + value, + tests, + field = this, + params = {}; + + // Detect if field is a select menu or a checkbox + if ("selectedIndex" in field) { + value = field.options[field.selectedIndex].value || undefined; + } else { + value = field.checked ? field.defaultValue || true : undefined; + } + + params[field.name] = value; + updatedUrl = setUrl(params); + + // Check if we can apply the change without a page refresh + if ("hidepassed" === field.name && "replaceState" in window.history) { + QUnit.urlParams[field.name] = value; + config[field.name] = value || false; + tests = id("qunit-tests"); + if (tests) { + toggleClass(tests, "hidepass", value || false); + } + window.history.replaceState(null, "", updatedUrl); + } else { + window.location = updatedUrl; + } + } + + function setUrl(params) { + var key, + arrValue, + i, + querystring = "?", + location = window.location; + + params = QUnit.extend(QUnit.extend({}, QUnit.urlParams), params); + + for (key in params) { + + // Skip inherited or undefined properties + if (hasOwn.call(params, key) && params[key] !== undefined) { + + // Output a parameter for each value of this key (but usually just one) + arrValue = [].concat(params[key]); + for (i = 0; i < arrValue.length; i++) { + querystring += encodeURIComponent(key); + if (arrValue[i] !== true) { + querystring += "=" + encodeURIComponent(arrValue[i]); + } + querystring += "&"; + } + } + } + return location.protocol + "//" + location.host + location.pathname + querystring.slice(0, -1); + } + + function applyUrlParams() { + var i, + selectedModules = [], + modulesList = id("qunit-modulefilter-dropdown-list").getElementsByTagName("input"), + filter = id("qunit-filter-input").value; + + for (i = 0; i < modulesList.length; i++) { + if (modulesList[i].checked) { + selectedModules.push(modulesList[i].value); + } + } + + window.location = setUrl({ + filter: filter === "" ? undefined : filter, + moduleId: selectedModules.length === 0 ? undefined : selectedModules, + + // Remove module and testId filter + module: undefined, + testId: undefined + }); + } + + function toolbarUrlConfigContainer() { + var urlConfigContainer = document$$1.createElement("span"); + + urlConfigContainer.innerHTML = getUrlConfigHtml(); + addClass(urlConfigContainer, "qunit-url-config"); + + addEvents(urlConfigContainer.getElementsByTagName("input"), "change", toolbarChanged); + addEvents(urlConfigContainer.getElementsByTagName("select"), "change", toolbarChanged); + + return urlConfigContainer; + } + + function abortTestsButton() { + var button = document$$1.createElement("button"); + button.id = "qunit-abort-tests-button"; + button.innerHTML = "Abort"; + addEvent(button, "click", abortTests); + return button; + } + + function toolbarLooseFilter() { + var filter = document$$1.createElement("form"), + label = document$$1.createElement("label"), + input = document$$1.createElement("input"), + button = document$$1.createElement("button"); + + addClass(filter, "qunit-filter"); + + label.innerHTML = "Filter: "; + + input.type = "text"; + input.value = config.filter || ""; + input.name = "filter"; + input.id = "qunit-filter-input"; + + button.innerHTML = "Go"; + + label.appendChild(input); + + filter.appendChild(label); + filter.appendChild(document$$1.createTextNode(" ")); + filter.appendChild(button); + addEvent(filter, "submit", interceptNavigation); + + return filter; + } + + function moduleListHtml() { + var i, + checked, + html = ""; + + for (i = 0; i < config.modules.length; i++) { + if (config.modules[i].name !== "") { + checked = config.moduleId.indexOf(config.modules[i].moduleId) > -1; + html += "
  • "; + } + } + + return html; + } + + function toolbarModuleFilter() { + var allCheckbox, + commit, + reset, + moduleFilter = document$$1.createElement("form"), + label = document$$1.createElement("label"), + moduleSearch = document$$1.createElement("input"), + dropDown = document$$1.createElement("div"), + actions = document$$1.createElement("span"), + dropDownList = document$$1.createElement("ul"), + dirty = false; + + moduleSearch.id = "qunit-modulefilter-search"; + addEvent(moduleSearch, "input", searchInput); + addEvent(moduleSearch, "input", searchFocus); + addEvent(moduleSearch, "focus", searchFocus); + addEvent(moduleSearch, "click", searchFocus); + + label.id = "qunit-modulefilter-search-container"; + label.innerHTML = "Module: "; + label.appendChild(moduleSearch); + + actions.id = "qunit-modulefilter-actions"; + actions.innerHTML = "" + "" + ""; + allCheckbox = actions.lastChild.firstChild; + commit = actions.firstChild; + reset = commit.nextSibling; + addEvent(commit, "click", applyUrlParams); + + dropDownList.id = "qunit-modulefilter-dropdown-list"; + dropDownList.innerHTML = moduleListHtml(); + + dropDown.id = "qunit-modulefilter-dropdown"; + dropDown.style.display = "none"; + dropDown.appendChild(actions); + dropDown.appendChild(dropDownList); + addEvent(dropDown, "change", selectionChange); + selectionChange(); + + moduleFilter.id = "qunit-modulefilter"; + moduleFilter.appendChild(label); + moduleFilter.appendChild(dropDown); + addEvent(moduleFilter, "submit", interceptNavigation); + addEvent(moduleFilter, "reset", function () { + + // Let the reset happen, then update styles + window.setTimeout(selectionChange); + }); + + // Enables show/hide for the dropdown + function searchFocus() { + if (dropDown.style.display !== "none") { + return; + } + + dropDown.style.display = "block"; + addEvent(document$$1, "click", hideHandler); + addEvent(document$$1, "keydown", hideHandler); + + // Hide on Escape keydown or outside-container click + function hideHandler(e) { + var inContainer = moduleFilter.contains(e.target); + + if (e.keyCode === 27 || !inContainer) { + if (e.keyCode === 27 && inContainer) { + moduleSearch.focus(); + } + dropDown.style.display = "none"; + removeEvent(document$$1, "click", hideHandler); + removeEvent(document$$1, "keydown", hideHandler); + moduleSearch.value = ""; + searchInput(); + } + } + } + + // Processes module search box input + function searchInput() { + var i, + item, + searchText = moduleSearch.value.toLowerCase(), + listItems = dropDownList.children; + + for (i = 0; i < listItems.length; i++) { + item = listItems[i]; + if (!searchText || item.textContent.toLowerCase().indexOf(searchText) > -1) { + item.style.display = ""; + } else { + item.style.display = "none"; + } + } + } + + // Processes selection changes + function selectionChange(evt) { + var i, + item, + checkbox = evt && evt.target || allCheckbox, + modulesList = dropDownList.getElementsByTagName("input"), + selectedNames = []; + + toggleClass(checkbox.parentNode, "checked", checkbox.checked); + + dirty = false; + if (checkbox.checked && checkbox !== allCheckbox) { + allCheckbox.checked = false; + removeClass(allCheckbox.parentNode, "checked"); + } + for (i = 0; i < modulesList.length; i++) { + item = modulesList[i]; + if (!evt) { + toggleClass(item.parentNode, "checked", item.checked); + } else if (checkbox === allCheckbox && checkbox.checked) { + item.checked = false; + removeClass(item.parentNode, "checked"); + } + dirty = dirty || item.checked !== item.defaultChecked; + if (item.checked) { + selectedNames.push(item.parentNode.textContent); + } + } + + commit.style.display = reset.style.display = dirty ? "" : "none"; + moduleSearch.placeholder = selectedNames.join(", ") || allCheckbox.parentNode.textContent; + moduleSearch.title = "Type to filter list. Current selection:\n" + (selectedNames.join("\n") || allCheckbox.parentNode.textContent); + } + + return moduleFilter; + } + + function appendToolbar() { + var toolbar = id("qunit-testrunner-toolbar"); + + if (toolbar) { + toolbar.appendChild(toolbarUrlConfigContainer()); + toolbar.appendChild(toolbarModuleFilter()); + toolbar.appendChild(toolbarLooseFilter()); + toolbar.appendChild(document$$1.createElement("div")).className = "clearfix"; + } + } + + function appendHeader() { + var header = id("qunit-header"); + + if (header) { + header.innerHTML = "" + header.innerHTML + " "; + } + } + + function appendBanner() { + var banner = id("qunit-banner"); + + if (banner) { + banner.className = ""; + } + } + + function appendTestResults() { + var tests = id("qunit-tests"), + result = id("qunit-testresult"), + controls; + + if (result) { + result.parentNode.removeChild(result); + } + + if (tests) { + tests.innerHTML = ""; + result = document$$1.createElement("p"); + result.id = "qunit-testresult"; + result.className = "result"; + tests.parentNode.insertBefore(result, tests); + result.innerHTML = "
    Running...
     
    " + "
    " + "
    "; + controls = id("qunit-testresult-controls"); + } + + if (controls) { + controls.appendChild(abortTestsButton()); + } + } + + function appendFilteredTest() { + var testId = QUnit.config.testId; + if (!testId || testId.length <= 0) { + return ""; + } + return "
    Rerunning selected tests: " + escapeText(testId.join(", ")) + " Run all tests
    "; + } + + function appendUserAgent() { + var userAgent = id("qunit-userAgent"); + + if (userAgent) { + userAgent.innerHTML = ""; + userAgent.appendChild(document$$1.createTextNode("QUnit " + QUnit.version + "; " + navigator.userAgent)); + } + } + + function appendInterface() { + var qunit = id("qunit"); + + if (qunit) { + qunit.innerHTML = "

    " + escapeText(document$$1.title) + "

    " + "

    " + "
    " + appendFilteredTest() + "

    " + "
      "; + } + + appendHeader(); + appendBanner(); + appendTestResults(); + appendUserAgent(); + appendToolbar(); + } + + function appendTestsList(modules) { + var i, l, x, z, test, moduleObj; + + for (i = 0, l = modules.length; i < l; i++) { + moduleObj = modules[i]; + + for (x = 0, z = moduleObj.tests.length; x < z; x++) { + test = moduleObj.tests[x]; + + appendTest(test.name, test.testId, moduleObj.name); + } + } + } + + function appendTest(name, testId, moduleName) { + var title, + rerunTrigger, + testBlock, + assertList, + tests = id("qunit-tests"); + + if (!tests) { + return; + } + + title = document$$1.createElement("strong"); + title.innerHTML = getNameHtml(name, moduleName); + + rerunTrigger = document$$1.createElement("a"); + rerunTrigger.innerHTML = "Rerun"; + rerunTrigger.href = setUrl({ testId: testId }); + + testBlock = document$$1.createElement("li"); + testBlock.appendChild(title); + testBlock.appendChild(rerunTrigger); + testBlock.id = "qunit-test-output-" + testId; + + assertList = document$$1.createElement("ol"); + assertList.className = "qunit-assert-list"; + + testBlock.appendChild(assertList); + + tests.appendChild(testBlock); + } + + // HTML Reporter initialization and load + QUnit.begin(function (details) { + var i, moduleObj, tests; + + // Sort modules by name for the picker + for (i = 0; i < details.modules.length; i++) { + moduleObj = details.modules[i]; + if (moduleObj.name) { + modulesList.push(moduleObj.name); + } + } + modulesList.sort(function (a, b) { + return a.localeCompare(b); + }); + + // Initialize QUnit elements + appendInterface(); + appendTestsList(details.modules); + tests = id("qunit-tests"); + if (tests && config.hidepassed) { + addClass(tests, "hidepass"); + } + }); + + QUnit.done(function (details) { + var banner = id("qunit-banner"), + tests = id("qunit-tests"), + abortButton = id("qunit-abort-tests-button"), + totalTests = stats.passedTests + stats.skippedTests + stats.todoTests + stats.failedTests, + html = [totalTests, " tests completed in ", details.runtime, " milliseconds, with ", stats.failedTests, " failed, ", stats.skippedTests, " skipped, and ", stats.todoTests, " todo.
      ", "", details.passed, " assertions of ", details.total, " passed, ", details.failed, " failed."].join(""), + test, + assertLi, + assertList; + + // Update remaing tests to aborted + if (abortButton && abortButton.disabled) { + html = "Tests aborted after " + details.runtime + " milliseconds."; + + for (var i = 0; i < tests.children.length; i++) { + test = tests.children[i]; + if (test.className === "" || test.className === "running") { + test.className = "aborted"; + assertList = test.getElementsByTagName("ol")[0]; + assertLi = document$$1.createElement("li"); + assertLi.className = "fail"; + assertLi.innerHTML = "Test aborted."; + assertList.appendChild(assertLi); + } + } + } + + if (banner && (!abortButton || abortButton.disabled === false)) { + banner.className = stats.failedTests ? "qunit-fail" : "qunit-pass"; + } + + if (abortButton) { + abortButton.parentNode.removeChild(abortButton); + } + + if (tests) { + id("qunit-testresult-display").innerHTML = html; + } + + if (config.altertitle && document$$1.title) { + + // Show ✖ for good, ✔ for bad suite result in title + // use escape sequences in case file gets loaded with non-utf-8-charset + document$$1.title = [stats.failedTests ? "\u2716" : "\u2714", document$$1.title.replace(/^[\u2714\u2716] /i, "")].join(" "); + } + + // 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 = "" + escapeText(module) + ": "; + } + + nameHtml += "" + escapeText(name) + ""; + + return nameHtml; + } + + QUnit.testStart(function (details) { + var running, testBlock, bad; + + testBlock = id("qunit-test-output-" + details.testId); + if (testBlock) { + testBlock.className = "running"; + } else { + + // Report later registered tests + appendTest(details.name, details.testId, details.module); + } + + running = id("qunit-testresult-display"); + if (running) { + bad = QUnit.config.reorder && details.previousFailure; + + running.innerHTML = (bad ? "Rerunning previously failed test:
      " : "Running:
      ") + getNameHtml(details.name, details.module); + } + }); + + function stripHtml(string) { + + // Strip tags, html entity and whitespaces + return string.replace(/<\/?[^>]+(>|$)/g, "").replace(/\"/g, "").replace(/\s+/g, ""); + } + + QUnit.log(function (details) { + var assertList, + assertLi, + message, + expected, + actual, + diff, + showDiff = false, + testItem = id("qunit-test-output-" + details.testId); + + if (!testItem) { + return; + } + + message = escapeText(details.message) || (details.result ? "okay" : "failed"); + message = "" + message + ""; + message += "@ " + details.runtime + " ms"; + + // The 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")) { + if (details.negative) { + expected = "NOT " + QUnit.dump.parse(details.expected); + } else { + expected = QUnit.dump.parse(details.expected); + } + + actual = QUnit.dump.parse(details.actual); + message += ""; + + if (actual !== expected) { + + message += ""; + + if (typeof details.actual === "number" && typeof details.expected === "number") { + if (!isNaN(details.actual) && !isNaN(details.expected)) { + showDiff = true; + diff = details.actual - details.expected; + diff = (diff > 0 ? "+" : "") + diff; + } + } else if (typeof details.actual !== "boolean" && typeof details.expected !== "boolean") { + diff = QUnit.diff(expected, actual); + + // don't show diff if there is zero overlap + showDiff = stripHtml(diff).length !== stripHtml(expected).length + stripHtml(actual).length; + } + + if (showDiff) { + message += ""; + } + } else if (expected.indexOf("[object Array]") !== -1 || expected.indexOf("[object Object]") !== -1) { + message += ""; + } else { + message += ""; + } + + if (details.source) { + message += ""; + } + + message += "
      Expected:
      " + escapeText(expected) + "
      Result:
      " + escapeText(actual) + "
      Diff:
      " + diff + "
      Message: " + "Diff suppressed as the depth of object is more than current max depth (" + QUnit.config.maxDepth + ").

      Hint: Use QUnit.dump.maxDepth to " + " run with a higher max depth or " + "Rerun without max depth.

      Message: " + "Diff suppressed as the expected and actual results have an equivalent" + " serialization
      Source:
      " + escapeText(details.source) + "
      "; + + // This occurs when pushFailure is set and we have an extracted stack trace + } else if (!details.result && details.source) { + message += "" + "" + "
      Source:
      " + escapeText(details.source) + "
      "; + } + + assertList = testItem.getElementsByTagName("ol")[0]; + + assertLi = document$$1.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, + skipped, + sourceName, + tests = id("qunit-tests"); + + if (!tests) { + return; + } + + testItem = id("qunit-test-output-" + details.testId); + + assertList = testItem.getElementsByTagName("ol")[0]; + + good = details.passed; + bad = details.failed; + + // This test passed if it has no unexpected failed assertions + var testPassed = details.failed > 0 ? details.todo : !details.todo; + + if (testPassed) { + + // Collapse the passing tests + addClass(assertList, "qunit-collapsed"); + } else if (config.collapse) { + if (!collapseNext) { + + // Skip collapsing the first failing test + collapseNext = true; + } else { + + // Collapse remaining tests + addClass(assertList, "qunit-collapsed"); + } + } + + // The testItem.firstChild is the test name + testTitle = testItem.firstChild; + + testCounts = bad ? "" + bad + ", " + "" + good + ", " : ""; + + testTitle.innerHTML += " (" + testCounts + details.assertions.length + ")"; + + if (details.skipped) { + stats.skippedTests++; + + testItem.className = "skipped"; + skipped = document$$1.createElement("em"); + skipped.className = "qunit-skipped-label"; + skipped.innerHTML = "skipped"; + testItem.insertBefore(skipped, testTitle); + } else { + addEvent(testTitle, "click", function () { + toggleClass(assertList, "qunit-collapsed"); + }); + + testItem.className = testPassed ? "pass" : "fail"; + + if (details.todo) { + var todoLabel = document$$1.createElement("em"); + todoLabel.className = "qunit-todo-label"; + todoLabel.innerHTML = "todo"; + testItem.className += " todo"; + testItem.insertBefore(todoLabel, testTitle); + } + + time = document$$1.createElement("span"); + time.className = "runtime"; + time.innerHTML = details.runtime + " ms"; + testItem.insertBefore(time, assertList); + + if (!testPassed) { + stats.failedTests++; + } else if (details.todo) { + stats.todoTests++; + } else { + stats.passedTests++; + } + } + + // Show the source of the test when showing assertions + if (details.source) { + sourceName = document$$1.createElement("p"); + sourceName.innerHTML = "Source: " + details.source; + addClass(sourceName, "qunit-source"); + if (testPassed) { + addClass(sourceName, "qunit-collapsed"); + } + addEvent(testTitle, "click", function () { + toggleClass(sourceName, "qunit-collapsed"); + }); + testItem.appendChild(sourceName); + } + }); + + // Avoid readyState issue with phantomjs + // Ref: #818 + var notPhantom = function (p) { + return !(p && p.version && p.version.major > 0); + }(window.phantom); + + if (notPhantom && document$$1.readyState === "complete") { + QUnit.load(); + } else { + addEvent(window, "load", QUnit.load); + } + + // Wrap window.onerror. We will call the original window.onerror to see if + // the existing handler fully handles the error; if not, we will call the + // QUnit.onError function. + var originalWindowOnError = window.onerror; + + // Cover uncaught exceptions + // Returning true will suppress the default browser handler, + // returning false will let it run. + window.onerror = function (message, fileName, lineNumber) { + var ret = false; + if (originalWindowOnError) { + for (var _len = arguments.length, args = Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) { + args[_key - 3] = arguments[_key]; + } + + ret = originalWindowOnError.call.apply(originalWindowOnError, [this, message, fileName, lineNumber].concat(args)); + } + + // Treat return value as window.onerror itself does, + // Only do our handling if not suppressed. + if (ret !== true) { + var error = { + message: message, + fileName: fileName, + lineNumber: lineNumber + }; + + ret = QUnit.onError(error); + } + + return ret; + }; + })(); + + /* + * This file is a modified version of google-diff-match-patch's JavaScript implementation + * (https://code.google.com/p/google-diff-match-patch/source/browse/trunk/javascript/diff_match_patch_uncompressed.js), + * modifications are licensed as more fully set forth in LICENSE.txt. + * + * The original source of google-diff-match-patch is attributable and licensed as follows: + * + * Copyright 2006 Google Inc. + * https://code.google.com/p/google-diff-match-patch/ + * + * Licensed 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 + * + * https://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. + * + * More Info: + * https://code.google.com/p/google-diff-match-patch/ + * + * Usage: QUnit.diff(expected, actual) + * + */ + QUnit.diff = function () { + function DiffMatchPatch() {} + + // DIFF FUNCTIONS + + /** + * The data structure representing a diff is an array of tuples: + * [[DIFF_DELETE, 'Hello'], [DIFF_INSERT, 'Goodbye'], [DIFF_EQUAL, ' world.']] + * which means: delete 'Hello', add 'Goodbye' and keep ' world.' + */ + var DIFF_DELETE = -1, + DIFF_INSERT = 1, + DIFF_EQUAL = 0; + + /** + * Find the differences between two texts. Simplifies the problem by stripping + * any common prefix or suffix off the texts before diffing. + * @param {string} text1 Old string to be diffed. + * @param {string} text2 New string to be diffed. + * @param {boolean=} optChecklines Optional speedup flag. If present and false, + * then don't run a line-level diff first to identify the changed areas. + * Defaults to true, which does a faster, slightly less optimal diff. + * @return {!Array.} Array of diff tuples. + */ + DiffMatchPatch.prototype.DiffMain = function (text1, text2, optChecklines) { + var deadline, checklines, commonlength, commonprefix, commonsuffix, diffs; + + // The diff must be complete in up to 1 second. + deadline = new Date().getTime() + 1000; + + // Check for null inputs. + if (text1 === null || text2 === null) { + throw new Error("Null input. (DiffMain)"); + } + + // Check for equality (speedup). + if (text1 === text2) { + if (text1) { + return [[DIFF_EQUAL, text1]]; + } + return []; + } + + if (typeof optChecklines === "undefined") { + optChecklines = true; + } + + checklines = optChecklines; + + // Trim off common prefix (speedup). + commonlength = this.diffCommonPrefix(text1, text2); + commonprefix = text1.substring(0, commonlength); + text1 = text1.substring(commonlength); + text2 = text2.substring(commonlength); + + // Trim off common suffix (speedup). + commonlength = this.diffCommonSuffix(text1, text2); + commonsuffix = text1.substring(text1.length - commonlength); + text1 = text1.substring(0, text1.length - commonlength); + text2 = text2.substring(0, text2.length - commonlength); + + // Compute the diff on the middle block. + diffs = this.diffCompute(text1, text2, checklines, deadline); + + // Restore the prefix and suffix. + if (commonprefix) { + diffs.unshift([DIFF_EQUAL, commonprefix]); + } + if (commonsuffix) { + diffs.push([DIFF_EQUAL, commonsuffix]); + } + this.diffCleanupMerge(diffs); + return diffs; + }; + + /** + * Reduce the number of edits by eliminating operationally trivial equalities. + * @param {!Array.} diffs Array of diff tuples. + */ + DiffMatchPatch.prototype.diffCleanupEfficiency = function (diffs) { + var changes, equalities, equalitiesLength, lastequality, pointer, preIns, preDel, postIns, postDel; + changes = false; + equalities = []; // Stack of indices where equalities are found. + equalitiesLength = 0; // Keeping our own length var is faster in JS. + /** @type {?string} */ + lastequality = null; + + // Always equal to diffs[equalities[equalitiesLength - 1]][1] + pointer = 0; // Index of current position. + + // Is there an insertion operation before the last equality. + preIns = false; + + // Is there a deletion operation before the last equality. + preDel = false; + + // Is there an insertion operation after the last equality. + postIns = false; + + // Is there a deletion operation after the last equality. + postDel = false; + while (pointer < diffs.length) { + + // Equality found. + if (diffs[pointer][0] === DIFF_EQUAL) { + if (diffs[pointer][1].length < 4 && (postIns || postDel)) { + + // Candidate found. + equalities[equalitiesLength++] = pointer; + preIns = postIns; + preDel = postDel; + lastequality = diffs[pointer][1]; + } else { + + // Not a candidate, and can never become one. + equalitiesLength = 0; + lastequality = null; + } + postIns = postDel = false; + + // An insertion or deletion. + } else { + + if (diffs[pointer][0] === DIFF_DELETE) { + postDel = true; + } else { + postIns = true; + } + + /* + * Five types to be split: + * ABXYCD + * AXCD + * ABXC + * AXCD + * ABXC + */ + if (lastequality && (preIns && preDel && postIns && postDel || lastequality.length < 2 && preIns + preDel + postIns + postDel === 3)) { + + // Duplicate record. + diffs.splice(equalities[equalitiesLength - 1], 0, [DIFF_DELETE, lastequality]); + + // Change second copy to insert. + diffs[equalities[equalitiesLength - 1] + 1][0] = DIFF_INSERT; + equalitiesLength--; // Throw away the equality we just deleted; + lastequality = null; + if (preIns && preDel) { + + // No changes made which could affect previous entry, keep going. + postIns = postDel = true; + equalitiesLength = 0; + } else { + equalitiesLength--; // Throw away the previous equality. + pointer = equalitiesLength > 0 ? equalities[equalitiesLength - 1] : -1; + postIns = postDel = false; + } + changes = true; + } + } + pointer++; + } + + if (changes) { + this.diffCleanupMerge(diffs); + } + }; + + /** + * Convert a diff array into a pretty HTML report. + * @param {!Array.} diffs Array of diff tuples. + * @param {integer} string to be beautified. + * @return {string} HTML representation. + */ + DiffMatchPatch.prototype.diffPrettyHtml = function (diffs) { + var op, + data, + x, + html = []; + for (x = 0; x < diffs.length; x++) { + op = diffs[x][0]; // Operation (insert, delete, equal) + data = diffs[x][1]; // Text of change. + switch (op) { + case DIFF_INSERT: + html[x] = "" + escapeText(data) + ""; + break; + case DIFF_DELETE: + html[x] = "" + escapeText(data) + ""; + break; + case DIFF_EQUAL: + html[x] = "" + escapeText(data) + ""; + break; + } + } + return html.join(""); + }; + + /** + * Determine the common prefix of two strings. + * @param {string} text1 First string. + * @param {string} text2 Second string. + * @return {number} The number of characters common to the start of each + * string. + */ + DiffMatchPatch.prototype.diffCommonPrefix = function (text1, text2) { + var pointermid, pointermax, pointermin, pointerstart; + + // Quick check for common null cases. + if (!text1 || !text2 || text1.charAt(0) !== text2.charAt(0)) { + return 0; + } + + // Binary search. + // Performance analysis: https://neil.fraser.name/news/2007/10/09/ + pointermin = 0; + pointermax = Math.min(text1.length, text2.length); + pointermid = pointermax; + pointerstart = 0; + while (pointermin < pointermid) { + if (text1.substring(pointerstart, pointermid) === text2.substring(pointerstart, pointermid)) { + pointermin = pointermid; + pointerstart = pointermin; + } else { + pointermax = pointermid; + } + pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin); + } + return pointermid; + }; + + /** + * Determine the common suffix of two strings. + * @param {string} text1 First string. + * @param {string} text2 Second string. + * @return {number} The number of characters common to the end of each string. + */ + DiffMatchPatch.prototype.diffCommonSuffix = function (text1, text2) { + var pointermid, pointermax, pointermin, pointerend; + + // Quick check for common null cases. + if (!text1 || !text2 || text1.charAt(text1.length - 1) !== text2.charAt(text2.length - 1)) { + return 0; + } + + // Binary search. + // Performance analysis: https://neil.fraser.name/news/2007/10/09/ + pointermin = 0; + pointermax = Math.min(text1.length, text2.length); + pointermid = pointermax; + pointerend = 0; + while (pointermin < pointermid) { + if (text1.substring(text1.length - pointermid, text1.length - pointerend) === text2.substring(text2.length - pointermid, text2.length - pointerend)) { + pointermin = pointermid; + pointerend = pointermin; + } else { + pointermax = pointermid; + } + pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin); + } + return pointermid; + }; + + /** + * Find the differences between two texts. Assumes that the texts do not + * have any common prefix or suffix. + * @param {string} text1 Old string to be diffed. + * @param {string} text2 New string to be diffed. + * @param {boolean} checklines Speedup flag. If false, then don't run a + * line-level diff first to identify the changed areas. + * If true, then run a faster, slightly less optimal diff. + * @param {number} deadline Time when the diff should be complete by. + * @return {!Array.} Array of diff tuples. + * @private + */ + DiffMatchPatch.prototype.diffCompute = function (text1, text2, checklines, deadline) { + var diffs, longtext, shorttext, i, hm, text1A, text2A, text1B, text2B, midCommon, diffsA, diffsB; + + if (!text1) { + + // Just add some text (speedup). + return [[DIFF_INSERT, text2]]; + } + + if (!text2) { + + // Just delete some text (speedup). + return [[DIFF_DELETE, text1]]; + } + + longtext = text1.length > text2.length ? text1 : text2; + shorttext = text1.length > text2.length ? text2 : text1; + i = longtext.indexOf(shorttext); + if (i !== -1) { + + // Shorter text is inside the longer text (speedup). + diffs = [[DIFF_INSERT, longtext.substring(0, i)], [DIFF_EQUAL, shorttext], [DIFF_INSERT, longtext.substring(i + shorttext.length)]]; + + // Swap insertions for deletions if diff is reversed. + if (text1.length > text2.length) { + diffs[0][0] = diffs[2][0] = DIFF_DELETE; + } + return diffs; + } + + if (shorttext.length === 1) { + + // Single character string. + // After the previous speedup, the character can't be an equality. + return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]]; + } + + // Check to see if the problem can be split in two. + hm = this.diffHalfMatch(text1, text2); + if (hm) { + + // A half-match was found, sort out the return data. + text1A = hm[0]; + text1B = hm[1]; + text2A = hm[2]; + text2B = hm[3]; + midCommon = hm[4]; + + // Send both pairs off for separate processing. + diffsA = this.DiffMain(text1A, text2A, checklines, deadline); + diffsB = this.DiffMain(text1B, text2B, checklines, deadline); + + // Merge the results. + return diffsA.concat([[DIFF_EQUAL, midCommon]], diffsB); + } + + if (checklines && text1.length > 100 && text2.length > 100) { + return this.diffLineMode(text1, text2, deadline); + } + + return this.diffBisect(text1, text2, deadline); + }; + + /** + * Do the two texts share a substring which is at least half the length of the + * longer text? + * This speedup can produce non-minimal diffs. + * @param {string} text1 First string. + * @param {string} text2 Second string. + * @return {Array.} Five element Array, containing the prefix of + * text1, the suffix of text1, the prefix of text2, the suffix of + * text2 and the common middle. Or null if there was no match. + * @private + */ + DiffMatchPatch.prototype.diffHalfMatch = function (text1, text2) { + var longtext, shorttext, dmp, text1A, text2B, text2A, text1B, midCommon, hm1, hm2, hm; + + longtext = text1.length > text2.length ? text1 : text2; + shorttext = text1.length > text2.length ? text2 : text1; + if (longtext.length < 4 || shorttext.length * 2 < longtext.length) { + return null; // Pointless. + } + dmp = this; // 'this' becomes 'window' in a closure. + + /** + * Does a substring of shorttext exist within longtext such that the substring + * is at least half the length of longtext? + * Closure, but does not reference any external variables. + * @param {string} longtext Longer string. + * @param {string} shorttext Shorter string. + * @param {number} i Start index of quarter length substring within longtext. + * @return {Array.} Five element Array, containing the prefix of + * longtext, the suffix of longtext, the prefix of shorttext, the suffix + * of shorttext and the common middle. Or null if there was no match. + * @private + */ + function diffHalfMatchI(longtext, shorttext, i) { + var seed, j, bestCommon, prefixLength, suffixLength, bestLongtextA, bestLongtextB, bestShorttextA, bestShorttextB; + + // Start with a 1/4 length substring at position i as a seed. + seed = longtext.substring(i, i + Math.floor(longtext.length / 4)); + j = -1; + bestCommon = ""; + while ((j = shorttext.indexOf(seed, j + 1)) !== -1) { + prefixLength = dmp.diffCommonPrefix(longtext.substring(i), shorttext.substring(j)); + suffixLength = dmp.diffCommonSuffix(longtext.substring(0, i), shorttext.substring(0, j)); + if (bestCommon.length < suffixLength + prefixLength) { + bestCommon = shorttext.substring(j - suffixLength, j) + shorttext.substring(j, j + prefixLength); + bestLongtextA = longtext.substring(0, i - suffixLength); + bestLongtextB = longtext.substring(i + prefixLength); + bestShorttextA = shorttext.substring(0, j - suffixLength); + bestShorttextB = shorttext.substring(j + prefixLength); + } + } + if (bestCommon.length * 2 >= longtext.length) { + return [bestLongtextA, bestLongtextB, bestShorttextA, bestShorttextB, bestCommon]; + } else { + return null; + } + } + + // First check if the second quarter is the seed for a half-match. + hm1 = diffHalfMatchI(longtext, shorttext, Math.ceil(longtext.length / 4)); + + // Check again based on the third quarter. + hm2 = diffHalfMatchI(longtext, shorttext, Math.ceil(longtext.length / 2)); + if (!hm1 && !hm2) { + return null; + } else if (!hm2) { + hm = hm1; + } else if (!hm1) { + hm = hm2; + } else { + + // Both matched. Select the longest. + hm = hm1[4].length > hm2[4].length ? hm1 : hm2; + } + + // A half-match was found, sort out the return data. + if (text1.length > text2.length) { + text1A = hm[0]; + text1B = hm[1]; + text2A = hm[2]; + text2B = hm[3]; + } else { + text2A = hm[0]; + text2B = hm[1]; + text1A = hm[2]; + text1B = hm[3]; + } + midCommon = hm[4]; + return [text1A, text1B, text2A, text2B, midCommon]; + }; + + /** + * Do a quick line-level diff on both strings, then rediff the parts for + * greater accuracy. + * This speedup can produce non-minimal diffs. + * @param {string} text1 Old string to be diffed. + * @param {string} text2 New string to be diffed. + * @param {number} deadline Time when the diff should be complete by. + * @return {!Array.} Array of diff tuples. + * @private + */ + DiffMatchPatch.prototype.diffLineMode = function (text1, text2, deadline) { + var a, diffs, linearray, pointer, countInsert, countDelete, textInsert, textDelete, j; + + // Scan the text on a line-by-line basis first. + a = this.diffLinesToChars(text1, text2); + text1 = a.chars1; + text2 = a.chars2; + linearray = a.lineArray; + + diffs = this.DiffMain(text1, text2, false, deadline); + + // Convert the diff back to original text. + this.diffCharsToLines(diffs, linearray); + + // Eliminate freak matches (e.g. blank lines) + this.diffCleanupSemantic(diffs); + + // Rediff any replacement blocks, this time character-by-character. + // Add a dummy entry at the end. + diffs.push([DIFF_EQUAL, ""]); + pointer = 0; + countDelete = 0; + countInsert = 0; + textDelete = ""; + textInsert = ""; + while (pointer < diffs.length) { + switch (diffs[pointer][0]) { + case DIFF_INSERT: + countInsert++; + textInsert += diffs[pointer][1]; + break; + case DIFF_DELETE: + countDelete++; + textDelete += diffs[pointer][1]; + break; + case DIFF_EQUAL: + + // Upon reaching an equality, check for prior redundancies. + if (countDelete >= 1 && countInsert >= 1) { + + // Delete the offending records and add the merged ones. + diffs.splice(pointer - countDelete - countInsert, countDelete + countInsert); + pointer = pointer - countDelete - countInsert; + a = this.DiffMain(textDelete, textInsert, false, deadline); + for (j = a.length - 1; j >= 0; j--) { + diffs.splice(pointer, 0, a[j]); + } + pointer = pointer + a.length; + } + countInsert = 0; + countDelete = 0; + textDelete = ""; + textInsert = ""; + break; + } + pointer++; + } + diffs.pop(); // Remove the dummy entry at the end. + + return diffs; + }; + + /** + * Find the 'middle snake' of a diff, split the problem in two + * and return the recursively constructed diff. + * See Myers 1986 paper: An O(ND) Difference Algorithm and Its Variations. + * @param {string} text1 Old string to be diffed. + * @param {string} text2 New string to be diffed. + * @param {number} deadline Time at which to bail if not yet complete. + * @return {!Array.} Array of diff tuples. + * @private + */ + DiffMatchPatch.prototype.diffBisect = function (text1, text2, deadline) { + var text1Length, text2Length, maxD, vOffset, vLength, v1, v2, x, delta, front, k1start, k1end, k2start, k2end, k2Offset, k1Offset, x1, x2, y1, y2, d, k1, k2; + + // Cache the text lengths to prevent multiple calls. + text1Length = text1.length; + text2Length = text2.length; + maxD = Math.ceil((text1Length + text2Length) / 2); + vOffset = maxD; + vLength = 2 * maxD; + v1 = new Array(vLength); + v2 = new Array(vLength); + + // Setting all elements to -1 is faster in Chrome & Firefox than mixing + // integers and undefined. + for (x = 0; x < vLength; x++) { + v1[x] = -1; + v2[x] = -1; + } + v1[vOffset + 1] = 0; + v2[vOffset + 1] = 0; + delta = text1Length - text2Length; + + // If the total number of characters is odd, then the front path will collide + // with the reverse path. + front = delta % 2 !== 0; + + // Offsets for start and end of k loop. + // Prevents mapping of space beyond the grid. + k1start = 0; + k1end = 0; + k2start = 0; + k2end = 0; + for (d = 0; d < maxD; d++) { + + // Bail out if deadline is reached. + if (new Date().getTime() > deadline) { + break; + } + + // Walk the front path one step. + for (k1 = -d + k1start; k1 <= d - k1end; k1 += 2) { + k1Offset = vOffset + k1; + if (k1 === -d || k1 !== d && v1[k1Offset - 1] < v1[k1Offset + 1]) { + x1 = v1[k1Offset + 1]; + } else { + x1 = v1[k1Offset - 1] + 1; + } + y1 = x1 - k1; + while (x1 < text1Length && y1 < text2Length && text1.charAt(x1) === text2.charAt(y1)) { + x1++; + y1++; + } + v1[k1Offset] = x1; + if (x1 > text1Length) { + + // Ran off the right of the graph. + k1end += 2; + } else if (y1 > text2Length) { + + // Ran off the bottom of the graph. + k1start += 2; + } else if (front) { + k2Offset = vOffset + delta - k1; + if (k2Offset >= 0 && k2Offset < vLength && v2[k2Offset] !== -1) { + + // Mirror x2 onto top-left coordinate system. + x2 = text1Length - v2[k2Offset]; + if (x1 >= x2) { + + // Overlap detected. + return this.diffBisectSplit(text1, text2, x1, y1, deadline); + } + } + } + } + + // Walk the reverse path one step. + for (k2 = -d + k2start; k2 <= d - k2end; k2 += 2) { + k2Offset = vOffset + k2; + if (k2 === -d || k2 !== d && v2[k2Offset - 1] < v2[k2Offset + 1]) { + x2 = v2[k2Offset + 1]; + } else { + x2 = v2[k2Offset - 1] + 1; + } + y2 = x2 - k2; + while (x2 < text1Length && y2 < text2Length && text1.charAt(text1Length - x2 - 1) === text2.charAt(text2Length - y2 - 1)) { + x2++; + y2++; + } + v2[k2Offset] = x2; + if (x2 > text1Length) { + + // Ran off the left of the graph. + k2end += 2; + } else if (y2 > text2Length) { + + // Ran off the top of the graph. + k2start += 2; + } else if (!front) { + k1Offset = vOffset + delta - k2; + if (k1Offset >= 0 && k1Offset < vLength && v1[k1Offset] !== -1) { + x1 = v1[k1Offset]; + y1 = vOffset + x1 - k1Offset; + + // Mirror x2 onto top-left coordinate system. + x2 = text1Length - x2; + if (x1 >= x2) { + + // Overlap detected. + return this.diffBisectSplit(text1, text2, x1, y1, deadline); + } + } + } + } + } + + // Diff took too long and hit the deadline or + // number of diffs equals number of characters, no commonality at all. + return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]]; + }; + + /** + * Given the location of the 'middle snake', split the diff in two parts + * and recurse. + * @param {string} text1 Old string to be diffed. + * @param {string} text2 New string to be diffed. + * @param {number} x Index of split point in text1. + * @param {number} y Index of split point in text2. + * @param {number} deadline Time at which to bail if not yet complete. + * @return {!Array.} Array of diff tuples. + * @private + */ + DiffMatchPatch.prototype.diffBisectSplit = function (text1, text2, x, y, deadline) { + var text1a, text1b, text2a, text2b, diffs, diffsb; + text1a = text1.substring(0, x); + text2a = text2.substring(0, y); + text1b = text1.substring(x); + text2b = text2.substring(y); + + // Compute both diffs serially. + diffs = this.DiffMain(text1a, text2a, false, deadline); + diffsb = this.DiffMain(text1b, text2b, false, deadline); + + return diffs.concat(diffsb); + }; + + /** + * Reduce the number of edits by eliminating semantically trivial equalities. + * @param {!Array.} diffs Array of diff tuples. + */ + DiffMatchPatch.prototype.diffCleanupSemantic = function (diffs) { + var changes, equalities, equalitiesLength, lastequality, pointer, lengthInsertions2, lengthDeletions2, lengthInsertions1, lengthDeletions1, deletion, insertion, overlapLength1, overlapLength2; + changes = false; + equalities = []; // Stack of indices where equalities are found. + equalitiesLength = 0; // Keeping our own length var is faster in JS. + /** @type {?string} */ + lastequality = null; + + // Always equal to diffs[equalities[equalitiesLength - 1]][1] + pointer = 0; // Index of current position. + + // Number of characters that changed prior to the equality. + lengthInsertions1 = 0; + lengthDeletions1 = 0; + + // Number of characters that changed after the equality. + lengthInsertions2 = 0; + lengthDeletions2 = 0; + while (pointer < diffs.length) { + if (diffs[pointer][0] === DIFF_EQUAL) { + // Equality found. + equalities[equalitiesLength++] = pointer; + lengthInsertions1 = lengthInsertions2; + lengthDeletions1 = lengthDeletions2; + lengthInsertions2 = 0; + lengthDeletions2 = 0; + lastequality = diffs[pointer][1]; + } else { + // An insertion or deletion. + if (diffs[pointer][0] === DIFF_INSERT) { + lengthInsertions2 += diffs[pointer][1].length; + } else { + lengthDeletions2 += diffs[pointer][1].length; + } + + // Eliminate an equality that is smaller or equal to the edits on both + // sides of it. + if (lastequality && lastequality.length <= Math.max(lengthInsertions1, lengthDeletions1) && lastequality.length <= Math.max(lengthInsertions2, lengthDeletions2)) { + + // Duplicate record. + diffs.splice(equalities[equalitiesLength - 1], 0, [DIFF_DELETE, lastequality]); + + // Change second copy to insert. + diffs[equalities[equalitiesLength - 1] + 1][0] = DIFF_INSERT; + + // Throw away the equality we just deleted. + equalitiesLength--; + + // Throw away the previous equality (it needs to be reevaluated). + equalitiesLength--; + pointer = equalitiesLength > 0 ? equalities[equalitiesLength - 1] : -1; + + // Reset the counters. + lengthInsertions1 = 0; + lengthDeletions1 = 0; + lengthInsertions2 = 0; + lengthDeletions2 = 0; + lastequality = null; + changes = true; + } + } + pointer++; + } + + // Normalize the diff. + if (changes) { + this.diffCleanupMerge(diffs); + } + + // Find any overlaps between deletions and insertions. + // e.g: abcxxxxxxdef + // -> abcxxxdef + // e.g: xxxabcdefxxx + // -> defxxxabc + // Only extract an overlap if it is as big as the edit ahead or behind it. + pointer = 1; + while (pointer < diffs.length) { + if (diffs[pointer - 1][0] === DIFF_DELETE && diffs[pointer][0] === DIFF_INSERT) { + deletion = diffs[pointer - 1][1]; + insertion = diffs[pointer][1]; + overlapLength1 = this.diffCommonOverlap(deletion, insertion); + overlapLength2 = this.diffCommonOverlap(insertion, deletion); + if (overlapLength1 >= overlapLength2) { + if (overlapLength1 >= deletion.length / 2 || overlapLength1 >= insertion.length / 2) { + + // Overlap found. Insert an equality and trim the surrounding edits. + diffs.splice(pointer, 0, [DIFF_EQUAL, insertion.substring(0, overlapLength1)]); + diffs[pointer - 1][1] = deletion.substring(0, deletion.length - overlapLength1); + diffs[pointer + 1][1] = insertion.substring(overlapLength1); + pointer++; + } + } else { + if (overlapLength2 >= deletion.length / 2 || overlapLength2 >= insertion.length / 2) { + + // Reverse overlap found. + // Insert an equality and swap and trim the surrounding edits. + diffs.splice(pointer, 0, [DIFF_EQUAL, deletion.substring(0, overlapLength2)]); + + diffs[pointer - 1][0] = DIFF_INSERT; + diffs[pointer - 1][1] = insertion.substring(0, insertion.length - overlapLength2); + diffs[pointer + 1][0] = DIFF_DELETE; + diffs[pointer + 1][1] = deletion.substring(overlapLength2); + pointer++; + } + } + pointer++; + } + pointer++; + } + }; + + /** + * Determine if the suffix of one string is the prefix of another. + * @param {string} text1 First string. + * @param {string} text2 Second string. + * @return {number} The number of characters common to the end of the first + * string and the start of the second string. + * @private + */ + DiffMatchPatch.prototype.diffCommonOverlap = function (text1, text2) { + var text1Length, text2Length, textLength, best, length, pattern, found; + + // Cache the text lengths to prevent multiple calls. + text1Length = text1.length; + text2Length = text2.length; + + // Eliminate the null case. + if (text1Length === 0 || text2Length === 0) { + return 0; + } + + // Truncate the longer string. + if (text1Length > text2Length) { + text1 = text1.substring(text1Length - text2Length); + } else if (text1Length < text2Length) { + text2 = text2.substring(0, text1Length); + } + textLength = Math.min(text1Length, text2Length); + + // Quick check for the worst case. + if (text1 === text2) { + return textLength; + } + + // Start by looking for a single character match + // and increase length until no match is found. + // Performance analysis: https://neil.fraser.name/news/2010/11/04/ + best = 0; + length = 1; + while (true) { + pattern = text1.substring(textLength - length); + found = text2.indexOf(pattern); + if (found === -1) { + return best; + } + length += found; + if (found === 0 || text1.substring(textLength - length) === text2.substring(0, length)) { + best = length; + length++; + } + } + }; + + /** + * Split two texts into an array of strings. Reduce the texts to a string of + * hashes where each Unicode character represents one line. + * @param {string} text1 First string. + * @param {string} text2 Second string. + * @return {{chars1: string, chars2: string, lineArray: !Array.}} + * An object containing the encoded text1, the encoded text2 and + * the array of unique strings. + * The zeroth element of the array of unique strings is intentionally blank. + * @private + */ + DiffMatchPatch.prototype.diffLinesToChars = function (text1, text2) { + var lineArray, lineHash, chars1, chars2; + lineArray = []; // E.g. lineArray[4] === 'Hello\n' + lineHash = {}; // E.g. lineHash['Hello\n'] === 4 + + // '\x00' is a valid character, but various debuggers don't like it. + // So we'll insert a junk entry to avoid generating a null character. + lineArray[0] = ""; + + /** + * Split a text into an array of strings. Reduce the texts to a string of + * hashes where each Unicode character represents one line. + * Modifies linearray and linehash through being a closure. + * @param {string} text String to encode. + * @return {string} Encoded string. + * @private + */ + function diffLinesToCharsMunge(text) { + var chars, lineStart, lineEnd, lineArrayLength, line; + chars = ""; + + // Walk the text, pulling out a substring for each line. + // text.split('\n') would would temporarily double our memory footprint. + // Modifying text would create many large strings to garbage collect. + lineStart = 0; + lineEnd = -1; + + // Keeping our own length variable is faster than looking it up. + lineArrayLength = lineArray.length; + while (lineEnd < text.length - 1) { + lineEnd = text.indexOf("\n", lineStart); + if (lineEnd === -1) { + lineEnd = text.length - 1; + } + line = text.substring(lineStart, lineEnd + 1); + lineStart = lineEnd + 1; + + if (lineHash.hasOwnProperty ? lineHash.hasOwnProperty(line) : lineHash[line] !== undefined) { + chars += String.fromCharCode(lineHash[line]); + } else { + chars += String.fromCharCode(lineArrayLength); + lineHash[line] = lineArrayLength; + lineArray[lineArrayLength++] = line; + } + } + return chars; + } + + chars1 = diffLinesToCharsMunge(text1); + chars2 = diffLinesToCharsMunge(text2); + return { + chars1: chars1, + chars2: chars2, + lineArray: lineArray + }; + }; + + /** + * Rehydrate the text in a diff from a string of line hashes to real lines of + * text. + * @param {!Array.} diffs Array of diff tuples. + * @param {!Array.} lineArray Array of unique strings. + * @private + */ + DiffMatchPatch.prototype.diffCharsToLines = function (diffs, lineArray) { + var x, chars, text, y; + for (x = 0; x < diffs.length; x++) { + chars = diffs[x][1]; + text = []; + for (y = 0; y < chars.length; y++) { + text[y] = lineArray[chars.charCodeAt(y)]; + } + diffs[x][1] = text.join(""); + } + }; + + /** + * Reorder and merge like edit sections. Merge equalities. + * Any edit section can move as long as it doesn't cross an equality. + * @param {!Array.} diffs Array of diff tuples. + */ + DiffMatchPatch.prototype.diffCleanupMerge = function (diffs) { + var pointer, countDelete, countInsert, textInsert, textDelete, commonlength, changes, diffPointer, position; + diffs.push([DIFF_EQUAL, ""]); // Add a dummy entry at the end. + pointer = 0; + countDelete = 0; + countInsert = 0; + textDelete = ""; + textInsert = ""; + + while (pointer < diffs.length) { + switch (diffs[pointer][0]) { + case DIFF_INSERT: + countInsert++; + textInsert += diffs[pointer][1]; + pointer++; + break; + case DIFF_DELETE: + countDelete++; + textDelete += diffs[pointer][1]; + pointer++; + break; + case DIFF_EQUAL: + + // Upon reaching an equality, check for prior redundancies. + if (countDelete + countInsert > 1) { + if (countDelete !== 0 && countInsert !== 0) { + + // Factor out any common prefixes. + commonlength = this.diffCommonPrefix(textInsert, textDelete); + if (commonlength !== 0) { + if (pointer - countDelete - countInsert > 0 && diffs[pointer - countDelete - countInsert - 1][0] === DIFF_EQUAL) { + diffs[pointer - countDelete - countInsert - 1][1] += textInsert.substring(0, commonlength); + } else { + diffs.splice(0, 0, [DIFF_EQUAL, textInsert.substring(0, commonlength)]); + pointer++; + } + textInsert = textInsert.substring(commonlength); + textDelete = textDelete.substring(commonlength); + } + + // Factor out any common suffixies. + commonlength = this.diffCommonSuffix(textInsert, textDelete); + if (commonlength !== 0) { + diffs[pointer][1] = textInsert.substring(textInsert.length - commonlength) + diffs[pointer][1]; + textInsert = textInsert.substring(0, textInsert.length - commonlength); + textDelete = textDelete.substring(0, textDelete.length - commonlength); + } + } + + // Delete the offending records and add the merged ones. + if (countDelete === 0) { + diffs.splice(pointer - countInsert, countDelete + countInsert, [DIFF_INSERT, textInsert]); + } else if (countInsert === 0) { + diffs.splice(pointer - countDelete, countDelete + countInsert, [DIFF_DELETE, textDelete]); + } else { + diffs.splice(pointer - countDelete - countInsert, countDelete + countInsert, [DIFF_DELETE, textDelete], [DIFF_INSERT, textInsert]); + } + pointer = pointer - countDelete - countInsert + (countDelete ? 1 : 0) + (countInsert ? 1 : 0) + 1; + } else if (pointer !== 0 && diffs[pointer - 1][0] === DIFF_EQUAL) { + + // Merge this equality with the previous one. + diffs[pointer - 1][1] += diffs[pointer][1]; + diffs.splice(pointer, 1); + } else { + pointer++; + } + countInsert = 0; + countDelete = 0; + textDelete = ""; + textInsert = ""; + break; + } + } + if (diffs[diffs.length - 1][1] === "") { + diffs.pop(); // Remove the dummy entry at the end. + } + + // Second pass: look for single edits surrounded on both sides by equalities + // which can be shifted sideways to eliminate an equality. + // e.g: ABAC -> ABAC + changes = false; + pointer = 1; + + // Intentionally ignore the first and last element (don't need checking). + while (pointer < diffs.length - 1) { + if (diffs[pointer - 1][0] === DIFF_EQUAL && diffs[pointer + 1][0] === DIFF_EQUAL) { + + diffPointer = diffs[pointer][1]; + position = diffPointer.substring(diffPointer.length - diffs[pointer - 1][1].length); + + // This is a single edit surrounded by equalities. + if (position === diffs[pointer - 1][1]) { + + // Shift the edit over the previous equality. + diffs[pointer][1] = diffs[pointer - 1][1] + diffs[pointer][1].substring(0, diffs[pointer][1].length - diffs[pointer - 1][1].length); + diffs[pointer + 1][1] = diffs[pointer - 1][1] + diffs[pointer + 1][1]; + diffs.splice(pointer - 1, 1); + changes = true; + } else if (diffPointer.substring(0, diffs[pointer + 1][1].length) === diffs[pointer + 1][1]) { + + // Shift the edit over the next equality. + diffs[pointer - 1][1] += diffs[pointer + 1][1]; + diffs[pointer][1] = diffs[pointer][1].substring(diffs[pointer + 1][1].length) + diffs[pointer + 1][1]; + diffs.splice(pointer + 1, 1); + changes = true; + } + } + pointer++; + } + + // If shifts were made, the diff needs reordering and another shift sweep. + if (changes) { + this.diffCleanupMerge(diffs); + } + }; + + return function (o, n) { + var diff, output, text; + diff = new DiffMatchPatch(); + output = diff.DiffMain(o, n); + diff.diffCleanupEfficiency(output); + text = diff.diffPrettyHtml(output); + + return text; + }; + }(); + + }((function() { return this; }()))); \ No newline at end of file diff --git a/packages/main/test/qunit/util/qunit-coverage.js b/packages/main/test/qunit/util/qunit-coverage.js new file mode 100644 index 000000000000..0f8dfe8348ed --- /dev/null +++ b/packages/main/test/qunit/util/qunit-coverage.js @@ -0,0 +1,142 @@ +/*! + * OpenUI5 + * (c) Copyright 2009-2019 SAP SE or an SAP affiliate company. + * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + */ + +/*global jQuery, QUnit, URI, XMLHttpRequest, blanket, sap */// declare unusual global vars for JSLint/SAPUI5 validation +(function() { + "use strict"; + + if (typeof QUnit === "undefined") { + throw new Error("qunit-coverage.js: QUnit is not loaded yet!"); + } + + // set a hook for client-side coverage on window object + window["sap-ui-qunit-coverage"] = "client"; + + // client-side instrument filter options (data-attributes of qunit-coverage script tag) + var sFilterAttr, sAntiFilterAttr; + + // extract base URL from script to attach the qunit-coverage script + var aScripts = document.getElementsByTagName("script"), + sBaseUrl = null; + + for (var i = 0; i < aScripts.length; i++) { + var oScript = aScripts[i]; + var sSrc = oScript.getAttribute("src"); + if (sSrc) { + var aBaseUrl = sSrc.match(/(.*)qunit\/qunit-coverage\.js$/i); + if (aBaseUrl && aBaseUrl.length > 1) { + sBaseUrl = aBaseUrl[1]; + + // Set custom client-side instrument filter (from script attributes) + if (oScript.hasAttribute("data-sap-ui-cover-only")) { + sFilterAttr = oScript.getAttribute("data-sap-ui-cover-only"); + } + if (oScript.hasAttribute("data-sap-ui-cover-never")) { + sAntiFilterAttr = oScript.getAttribute("data-sap-ui-cover-never"); + } + + break; + } + } + } + + // check for coverage being active or not + if (QUnit.urlParams.coverage) { + + var translate = function(sScript, sModuleName) { + + // avoid duplicate instrumentation on server and client-side + if (sScript.indexOf("window['sap-ui-qunit-coverage'] = 'server';") === 0) { + return sScript; + } + + // manage includes and excludes with blanket utils + // check for blanket option (set via JS) and fall back to attribute of qunit-coverage script tag + var sFilter = blanket.options("sap-ui-cover-only") || sFilterAttr; + var sAntiFilter = blanket.options("sap-ui-cover-never") || sAntiFilterAttr; + + if (typeof sAntiFilter !== "undefined" && blanket.utils.matchPatternAttribute(sModuleName, sAntiFilter)) { + // NEVER INSTRUMENT (excluded) + } else if (typeof sFilter === "undefined" || blanket.utils.matchPatternAttribute(sModuleName, sFilter)) { + // INSTRUMENT (included) + + blanket.instrument({ + inputFile: sScript, + inputFileName: sModuleName, + instrumentCache: false + }, function(sInstrumentedScript) { + sScript = sInstrumentedScript; + }); + + } else { + // DONT INSTRUMENT (not explicitly excluded / included) + } + + return sScript; + }; + + // load and execute blanket script synchronously via XHR + if ( typeof blanket === 'undefined' ) { + var sDocumentLocation = document.location.href.replace(/\?.*|#.*/g, ""), + sFullUrl = null; + + if (sBaseUrl === null) { + if ( typeof sap === 'object' && sap.ui && sap.ui.require && sap.ui.require.toUrl ) { + sFullUrl = sap.ui.require.toUrl("sap/ui/thirdparty/blanket.js"); + } else if (jQuery && jQuery.sap && jQuery.sap.getResourcePath) { + sFullUrl = jQuery.sap.getResourcePath("sap/ui/thirdparty/blanket", ".js"); + } else { + throw new Error("qunit-coverage.js: The script tag seems to be malformed!"); + } + } else { + sFullUrl = sBaseUrl + "thirdparty/blanket.js"; + } + + var req = new XMLHttpRequest(); + req.open('GET', sFullUrl, false); + req.onreadystatechange = function() { + if (req.readyState == 4) { + + // execute the loaded script + var sScript = req.responseText; + if (typeof URI !== "undefined") { + sScript += "\n//# sourceURL=" + URI(sFullUrl).absoluteTo(sDocumentLocation); + } + window.eval(sScript); + } + }; + req.send(null); + } + + // reset QUnit config => will be set by QUnitUtils! + QUnit.config.autostart = true; + + // prevent QUnit.start() call in blanket + blanket.options("existingRequireJS", true); + + if ( typeof sap === 'object' && sap.ui && sap.ui.loader && sap.ui.loader._ ) { + sap.ui.loader._.translate = translate; + } else if (jQuery && jQuery.sap) { + jQuery.sap.require._hook = translate; + } else { + throw new Error("qunit-coverage.js: jQuery.sap.global is not loaded - require hook cannot be set!"); + } + + + } else { + + // add a QUnit configuration option in the Toolbar to enable/disable + // client-side instrumentation via blanket (done manually because in + // this case blanket will not be loaded and executed) + QUnit.config.urlConfig.push({ + id: "coverage", + label: "Enable coverage", + tooltip: "Enable code coverage." + }); + + } + +})(); \ No newline at end of file diff --git a/packages/main/test/qunit/util/qunit.css b/packages/main/test/qunit/util/qunit.css new file mode 100644 index 000000000000..08b46514b9c3 --- /dev/null +++ b/packages/main/test/qunit/util/qunit.css @@ -0,0 +1,297 @@ +/*! + * QUnit 1.18.0 + * http://qunitjs.com/ + * + * Copyright jQuery Foundation and other contributors + * Released under the MIT license + * http://jquery.org/license + * + * Date: 2015-04-03T10:23Z + */ + +/** 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; + padding: 0.2em; +} + +.qunit-url-config { + display: inline-block; + padding: 0.1em; +} + +.qunit-filter { + display: block; + float: right; + margin-left: 1em; +} + +/** 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 > li { + display: none; +} + +#qunit-tests li.running, +#qunit-tests li.pass, +#qunit-tests li.fail, +#qunit-tests li.skipped { + display: list-item; +} + +/* MODIFIED BY SAP */ +#qunit-tests.hidepass { + position: relative; +} +/* END MODIFIED BY SAP */ + +#qunit-tests.hidepass li.running, +#qunit-tests.hidepass li.pass { + visibility: hidden; + position: absolute; + width: 0px; + height: 0px; + padding: 0; + border: 0; + margin: 0; +} + +#qunit-tests li strong { + cursor: pointer; +} + +#qunit-tests li.skipped strong { + cursor: default; +} + +#qunit-tests li a { + padding: 0.5em; + color: #C2CCD1; + text-decoration: none; +} + +#qunit-tests li p a { + padding: 0.25em; + color: #6B6464; +} +#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; } + +/*** Skipped tests */ + +#qunit-tests .skipped { + background-color: #EBECE9; +} + +#qunit-tests .qunit-skipped-label { + background-color: #F4FF77; + display: inline-block; + font-style: normal; + color: #366097; + line-height: 1.8em; + padding: 0 0.5em; + margin: -0.4em 0.4em -0.4em 0; +} + +/** 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; +} \ No newline at end of file diff --git a/packages/main/test/qunit/util/qunit.js b/packages/main/test/qunit/util/qunit.js new file mode 100644 index 000000000000..644ddb1fa658 --- /dev/null +++ b/packages/main/test/qunit/util/qunit.js @@ -0,0 +1,3847 @@ +/*! + * QUnit 1.18.0 + * http://qunitjs.com/ + * + * Copyright jQuery Foundation and other contributors + * Released under the MIT license + * http://jquery.org/license + * + * Date: 2015-04-03T10:23Z + */ + +(function( window ) { + + var QUnit, + config, + onErrorFnPrev, + loggingCallbacks = {}, + 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(); + }, + globalStartCalled = false, + runStarted = false, + setTimeout = window.setTimeout, + clearTimeout = window.clearTimeout, + defined = { + document: window.document !== undefined, + setTimeout: 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; + }; + + QUnit = {}; + + /** + * 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, + + // 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, + + // depth up-to which object will be dumped + maxDepth: 5, + + // add checkboxes that are persisted in the query-string + // when enabled, the id is set to `true` as a `QUnit.config` property + urlConfig: [ + { + id: "hidepassed", + label: "Hide passed tests", + tooltip: "Only show tests and assertions that fail. Stored as query-strings." + }, + { + 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: [], + + // The first unnamed module + currentModule: { + name: "", + tests: [] + }, + + callbacks: {} + }; + + //### BEGIN MODIFIED BY SAP + // downport of fix for https://github.com/qunitjs/qunit/issues/1059 + // take a predefined QUnit.config and extend the defaults + var globalConfig = window && window.QUnit && window.QUnit.config; + + // only extend the global config if there is no QUnit overload + if (window && window.QUnit && !window.QUnit.version) { + extend(config, globalConfig); + } + //### END MODIFIED BY SAP + + // Push a loose unnamed module to the modules collection + config.modules.push( config.currentModule ); + + // 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 ]; + } + } + } + + if ( urlParams.filter === true ) { + delete urlParams.filter; + } + + QUnit.urlParams = urlParams; + + // String search anywhere in moduleName+testName + config.filter = urlParams.filter; + + if ( urlParams.maxDepth ) { + config.maxDepth = parseInt( urlParams.maxDepth, 10 ) === -1 ? + Number.POSITIVE_INFINITY : + urlParams.maxDepth; + } + + config.testId = []; + if ( urlParams.testId ) { + + // Ensure that urlParams.testId is an array + urlParams.testId = decodeURIComponent( urlParams.testId ).split( "," ); + for ( i = 0; i < urlParams.testId.length; i++ ) { + config.testId.push( urlParams.testId[ i ] ); + } + } + + // Figure out if we're running the tests from a server or not + QUnit.isLocal = location.protocol === "file:"; + + // Expose the current QUnit version + QUnit.version = "1.18.0"; + }()); + + // Root QUnit object. + // `QUnit` initialized at top of scope + extend( QUnit, { + + // call on start of module test to prepend name to all tests + module: function( name, testEnvironment ) { + var currentModule = { + name: name, + testEnvironment: testEnvironment, + tests: [] + }; + + // DEPRECATED: handles setup/teardown functions, + // beforeEach and afterEach should be used instead + if ( testEnvironment && testEnvironment.setup ) { + testEnvironment.beforeEach = testEnvironment.setup; + delete testEnvironment.setup; + } + if ( testEnvironment && testEnvironment.teardown ) { + testEnvironment.afterEach = testEnvironment.teardown; + delete testEnvironment.teardown; + } + + config.modules.push( currentModule ); + config.currentModule = currentModule; + }, + + // DEPRECATED: QUnit.asyncTest() will be removed in QUnit 2.0. + 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 + }); + + test.queue(); + }, + + skip: function( testName ) { + var test = new Test({ + testName: testName, + skip: true + }); + + test.queue(); + }, + + // DEPRECATED: The functionality of QUnit.start() will be altered in QUnit 2.0. + // In QUnit 2.0, invoking it will ONLY affect the `QUnit.config.autostart` blocking behavior. + start: function( count ) { + var globalStartAlreadyCalled = globalStartCalled; + + if ( !config.current ) { + globalStartCalled = true; + + if ( runStarted ) { + throw new Error( "Called start() outside of a test context while already started" ); + } else if ( globalStartAlreadyCalled || count > 1 ) { + throw new Error( "Called start() outside of a test context too many times" ); + } else if ( config.autostart ) { + throw new Error( "Called start() outside of a test context when " + + "QUnit.config.autostart was true" ); + } else if ( !config.pageLoaded ) { + + // The page isn't completely loaded yet, so bail out and let `QUnit.load` handle it + config.autostart = true; + return; + } + } else { + + // If a test is running, adjust its semaphore + config.current.semaphore -= count || 1; + + // Don't start until equal number of stop-calls + if ( config.current.semaphore > 0 ) { + return; + } + + // throw an Error if start is called more often than stop + if ( config.current.semaphore < 0 ) { + config.current.semaphore = 0; + + QUnit.pushFailure( + "Called start() while already started (test's semaphore was 0 already)", + sourceFromStacktrace( 2 ) + ); + return; + } + } + + resumeProcessing(); + }, + + // DEPRECATED: QUnit.stop() will be removed in QUnit 2.0. + stop: function( count ) { + + // If there isn't a test running, don't allow QUnit.stop() to be called + if ( !config.current ) { + throw new Error( "Called stop() outside of a test context" ); + } + + // If a test is running, adjust its semaphore + config.current.semaphore += count || 1; + + pauseProcessing(); + }, + + 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; + }, + + extend: extend, + + load: function() { + config.pageLoaded = true; + + // Initialize the configuration options + extend( config, { + stats: { all: 0, bad: 0 }, + moduleStats: { all: 0, bad: 0 }, + started: 0, + updateRate: 1000, + autostart: true, + filter: "" + }, true ); + + config.blocking = false; + + if ( config.autostart ) { + resumeProcessing(); + } + } + }); + + // Register logging callbacks + (function() { + var i, l, key, + callbacks = [ "begin", "done", "log", "testStart", "testDone", + "moduleStart", "moduleDone" ]; + + function registerLoggingCallback( key ) { + var loggingCallback = function( callback ) { + if ( QUnit.objectType( callback ) !== "function" ) { + throw new Error( + "QUnit logging methods require a callback function as their first parameters." + ); + } + + config.callbacks[ key ].push( callback ); + }; + + // DEPRECATED: This will be removed on QUnit 2.0.0+ + // Stores the registered functions allowing restoring + // at verifyLoggingCallbacks() if modified + loggingCallbacks[ key ] = loggingCallback; + + return loggingCallback; + } + + for ( i = 0, l = callbacks.length; i < l; i++ ) { + key = callbacks[ i ]; + + // Initialize key collection of logging callback + if ( QUnit.objectType( config.callbacks[ key ] ) === "undefined" ) { + config.callbacks[ key ] = []; + } + + QUnit[ key ] = registerLoggingCallback( key ); + } + })(); + + // `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: true } ) ); + } + return false; + } + + return ret; + }; + + function done() { + var runtime, passed; + + config.autorun = true; + + // Log the last module results + if ( config.previousModule ) { + runLoggingCallbacks( "moduleDone", { + name: config.previousModule.name, + tests: config.previousModule.tests, + failed: config.moduleStats.bad, + passed: config.moduleStats.all - config.moduleStats.bad, + total: config.moduleStats.all, + runtime: now() - config.moduleStats.started + }); + } + delete config.previousModule; + + 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 + }); + } + + // Doesn't support IE6 to IE9, it will return undefined on these browsers + // 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.stack ) { + 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 ]; + + // Support: Safari <=6 only + } else if ( e.sourceURL ) { + + // 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 ) { + var error = new Error(); + + // Support: Safari <=7 only, IE <=10 - 11 only + // Not all browsers generate the `stack` property for `new Error()`, see also #636 + if ( !error.stack ) { + try { + throw error; + } catch ( err ) { + error = err; + } + } + + return extractStacktrace( error, offset ); + } + + function synchronize( callback, last ) { + if ( QUnit.objectType( callback ) === "array" ) { + while ( callback.length ) { + synchronize( callback.shift() ); + } + return; + } + 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 || 0 ) + 1; + + while ( config.queue.length && !config.blocking ) { + if ( !defined.setTimeout || config.updateRate <= 0 || + ( ( now() - start ) < config.updateRate ) ) { + if ( config.current ) { + + // Reset async tracking for each phase of the Test lifecycle + config.current.usedAsync = false; + } + config.queue.shift()(); + } else { + setTimeout( next, 13 ); + break; + } + } + config.depth--; + if ( last && !config.blocking && !config.queue.length && config.depth === 0 ) { + done(); + } + } + + function begin() { + var i, l, + modulesLog = []; + + // If the test run hasn't officially begun yet + if ( !config.started ) { + + // Record the time of the test run's beginning + config.started = now(); + + verifyLoggingCallbacks(); + + // Delete the loose unnamed module if unused. + if ( config.modules[ 0 ].name === "" && config.modules[ 0 ].tests.length === 0 ) { + config.modules.shift(); + } + + // Avoid unnecessary information by not logging modules' test environments + for ( i = 0, l = config.modules.length; i < l; i++ ) { + modulesLog.push({ + name: config.modules[ i ].name, + tests: config.modules[ i ].tests + }); + } + + // The test run is officially beginning now + runLoggingCallbacks( "begin", { + totalTests: Test.count, + modules: modulesLog + }); + } + + config.blocking = false; + process( true ); + } + + function resumeProcessing() { + runStarted = true; + + // A slight delay to allow this iteration of the event loop to finish (more assertions, etc.) + if ( defined.setTimeout ) { + setTimeout(function() { + if ( config.current && config.current.semaphore > 0 ) { + return; + } + if ( config.timeout ) { + clearTimeout( config.timeout ); + } + + begin(); + }, 13 ); + } else { + begin(); + } + } + + function pauseProcessing() { + config.blocking = true; + + if ( config.testTimeout && defined.setTimeout ) { + clearTimeout( config.timeout ); + config.timeout = setTimeout(function() { + if ( config.current ) { + config.current.semaphore = 0; + QUnit.pushFailure( "Test timed out", sourceFromStacktrace( 2 ) ); + } else { + throw new Error( "Test timed out" ); + } + resumeProcessing(); + }, config.testTimeout ); + } + } + + 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 runLoggingCallbacks( key, args ) { + var i, l, callbacks; + + callbacks = config.callbacks[ key ]; + for ( i = 0, l = callbacks.length; i < l; i++ ) { + callbacks[ i ]( args ); + } + } + + // DEPRECATED: This will be removed on 2.0.0+ + // This function verifies if the loggingCallbacks were modified by the user + // If so, it will restore it, assign the given callback and print a console warning + function verifyLoggingCallbacks() { + var loggingCallback, userCallback; + + for ( loggingCallback in loggingCallbacks ) { + if ( QUnit[ loggingCallback ] !== loggingCallbacks[ loggingCallback ] ) { + + userCallback = QUnit[ loggingCallback ]; + + // Restore the callback function + QUnit[ loggingCallback ] = loggingCallbacks[ loggingCallback ]; + + // Assign the deprecated given callback + QUnit[ loggingCallback ]( userCallback ); + + if ( window.console && window.console.warn ) { + window.console.warn( + "QUnit." + loggingCallback + " was replaced with a new value.\n" + + "Please, check out the documentation on how to apply logging callbacks.\n" + + "Reference: http://api.qunitjs.com/category/callbacks/" + ); + } + } + } + } + + // 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 ) { + var i, l; + + ++Test.count; + + extend( this, settings ); + this.assertions = []; + this.semaphore = 0; + this.usedAsync = false; + this.module = config.currentModule; + this.stack = sourceFromStacktrace( 3 ); + + // Register unique strings + for ( i = 0, l = this.module.tests; i < l.length; i++ ) { + if ( this.module.tests[ i ].name === this.testName ) { + this.testName += " "; + } + } + + this.testId = generateHash( this.module.name, this.testName ); + + this.module.tests.push({ + name: this.testName, + testId: this.testId + }); + + if ( settings.skip ) { + + // Skipped tests will fully ignore any sent callback + this.callback = function() {}; + this.async = false; + this.expected = 0; + } else { + this.assert = new Assert( this ); + } + } + + Test.count = 0; + + Test.prototype = { + before: 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.name, + tests: config.previousModule.tests, + failed: config.moduleStats.bad, + passed: config.moduleStats.all - config.moduleStats.bad, + total: config.moduleStats.all, + runtime: now() - config.moduleStats.started + }); + } + config.previousModule = this.module; + config.moduleStats = { all: 0, bad: 0, started: now() }; + runLoggingCallbacks( "moduleStart", { + name: this.module.name, + tests: this.module.tests + }); + } + + config.current = this; + + this.testEnvironment = extend( {}, this.module.testEnvironment ); + delete this.testEnvironment.beforeEach; + delete this.testEnvironment.afterEach; + + this.started = now(); + runLoggingCallbacks( "testStart", { + name: this.testName, + module: this.module.name, + testId: this.testId + }); + + if ( !config.pollution ) { + saveGlobal(); + } + }, + + run: function() { + var promise; + + config.current = this; + + if ( this.async ) { + QUnit.stop(); + } + + this.callbackStarted = now(); + + if ( config.notrycatch ) { + promise = this.callback.call( this.testEnvironment, this.assert ); + this.resolvePromise( promise ); + return; + } + + try { + promise = this.callback.call( this.testEnvironment, this.assert ); + this.resolvePromise( promise ); + } catch ( e ) { + 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(); + } + } + }, + + after: function() { + checkPollution(); + }, + + queueHook: function( hook, hookName ) { + var promise, + test = this; + return function runHook() { + config.current = test; + if ( config.notrycatch ) { + promise = hook.call( test.testEnvironment, test.assert ); + test.resolvePromise( promise, hookName ); + return; + } + try { + promise = hook.call( test.testEnvironment, test.assert ); + test.resolvePromise( promise, hookName ); + } catch ( error ) { + test.pushFailure( hookName + " failed on " + test.testName + ": " + + ( error.message || error ), extractStacktrace( error, 0 ) ); + } + }; + }, + + // Currently only used for module level hooks, can be used to add global level ones + hooks: function( handler ) { + var hooks = []; + + // Hooks are ignored on skipped tests + if ( this.skip ) { + return hooks; + } + + if ( this.module.testEnvironment && + QUnit.objectType( this.module.testEnvironment[ handler ] ) === "function" ) { + hooks.push( this.queueHook( this.module.testEnvironment[ handler ], handler ) ); + } + + return hooks; + }, + + 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.name, + skipped: !!this.skip, + failed: bad, + passed: this.assertions.length - bad, + total: this.assertions.length, + runtime: this.runtime, + + // HTML Reporter use + assertions: this.assertions, + testId: this.testId, + + // DEPRECATED: this property will be removed in 2.0.0, use runtime instead + duration: this.runtime + }); + + // 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(); + + config.current = undefined; + }, + + queue: function() { + var bad, + test = this; + + if ( !this.valid() ) { + return; + } + + function run() { + + // each of these can by async + synchronize([ + function() { + test.before(); + }, + + test.hooks( "beforeEach" ), + + function() { + test.run(); + }, + + test.hooks( "afterEach" ).reverse(), + + function() { + test.after(); + }, + 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.name + "-" + this.testName ); + + if ( bad ) { + run(); + } else { + synchronize( run, true ); + } + }, + + push: function( result, actual, expected, message ) { + var source, + details = { + module: this.module.name, + name: this.testName, + result: result, + message: message, + actual: actual, + expected: expected, + testId: this.testId, + runtime: now() - this.started + }; + + 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, + name: this.testName, + result: false, + message: message || "error", + actual: actual || null, + testId: this.testId, + runtime: now() - this.started + }; + + if ( source ) { + details.source = source; + } + + runLoggingCallbacks( "log", details ); + + this.assertions.push({ + result: false, + message: message + }); + }, + + resolvePromise: function( promise, phase ) { + var then, message, + test = this; + if ( promise != null ) { + then = promise.then; + if ( QUnit.objectType( then ) === "function" ) { + QUnit.stop(); + then.call( + promise, + QUnit.start, + function( error ) { + message = "Promise rejected " + + ( !phase ? "during" : phase.replace( /Each$/, "" ) ) + + " " + test.testName + ": " + ( error.message || error ); + test.pushFailure( message, extractStacktrace( error, 0 ) ); + + // else next test will carry the responsibility + saveGlobal(); + + // Unblock + QUnit.start(); + } + ); + } + } + }, + + valid: function() { + var include, + filter = config.filter && config.filter.toLowerCase(), + module = QUnit.urlParams.module && QUnit.urlParams.module.toLowerCase(), + fullName = ( this.module.name + ": " + this.testName ).toLowerCase(); + + // Internally-generated tests are always valid + if ( this.callback && this.callback.validTest ) { + return true; + } + + if ( config.testId.length > 0 && inArray( this.testId, config.testId ) < 0 ) { + return false; + } + + if ( module && ( !this.module.name || this.module.name.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; + } + + }; + + // 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 = defined.document && document.getElementById && + document.getElementById( "qunit-fixture" ); + + if ( fixture ) { + fixture.innerHTML = config.fixture; + } + }; + + 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; + + return currentTest.pushFailure.apply( currentTest, arguments ); + }; + + // Based on Java's String.hashCode, a simple but not + // rigorously collision resistant hashing function + function generateHash( module, testName ) { + var hex, + i = 0, + hash = 0, + str = module + "\x1C" + testName, + len = str.length; + + for ( ; i < len; i++ ) { + hash = ( ( hash << 5 ) - hash ) + str.charCodeAt( i ); + hash |= 0; + } + + // Convert the possibly negative integer hash code into an 8 character hex string, which isn't + // strictly necessary but increases user understanding that the id is a SHA-like hash + hex = ( 0x100000000 + hash ).toString( 16 ); + if ( hex.length < 8 ) { + hex = "0000000" + hex; + } + + return hex.slice( -8 ); + } + + 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; + } + }, + + // Increment this Test's semaphore counter, then return a single-use function that + // decrements that counter a maximum of once. + async: function() { + var test = this.test, + popped = false; + + test.semaphore += 1; + test.usedAsync = true; + pauseProcessing(); + + return function done() { + if ( !popped ) { + test.semaphore -= 1; + popped = true; + resumeProcessing(); + } else { + test.pushFailure( "Called the callback returned from `assert.async` more than once", + sourceFromStacktrace( 2 ) ); + } + }; + }, + + // Exports test.push() to the user API + push: function( /* result, actual, expected, message */ ) { + var assert = this, + currentTest = ( assert instanceof Assert && assert.test ) || QUnit.config.current; + + // 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 ( !currentTest ) { + throw new Error( "assertion outside test context, in " + sourceFromStacktrace( 2 ) ); + } + + if ( currentTest.usedAsync === true && currentTest.semaphore === 0 ) { + currentTest.pushFailure( "Assertion after the final `assert.async` was resolved", + sourceFromStacktrace( 2 ) ); + + // Allow this assertion to continue running anyway... + } + + if ( !( assert instanceof Assert ) ) { + assert = currentTest.assert; + } + return assert.test.push.apply( assert.test, arguments ); + }, + + ok: function( result, message ) { + message = message || ( result ? "okay" : "failed, expected argument to be truthy, was: " + + QUnit.dump.parse( result ) ); + this.push( !!result, result, true, message ); + }, + + notOk: function( result, message ) { + message = message || ( !result ? "okay" : "failed, expected argument to be falsy, was: " + + QUnit.dump.parse( result ) ); + this.push( !result, result, false, message ); + }, + + equal: function( actual, expected, message ) { + /*jshint eqeqeq:false */ + this.push( expected == actual, actual, expected, message ); + }, + + notEqual: function( actual, expected, message ) { + /*jshint eqeqeq:false */ + this.push( expected != actual, actual, expected, message ); + }, + + propEqual: function( actual, expected, message ) { + actual = objectValues( actual ); + expected = objectValues( expected ); + this.push( QUnit.equiv( actual, expected ), actual, expected, message ); + }, + + notPropEqual: function( actual, expected, message ) { + actual = objectValues( actual ); + expected = objectValues( expected ); + this.push( !QUnit.equiv( actual, expected ), actual, expected, message ); + }, + + deepEqual: function( actual, expected, message ) { + this.push( QUnit.equiv( actual, expected ), actual, expected, message ); + }, + + notDeepEqual: function( actual, expected, message ) { + this.push( !QUnit.equiv( actual, expected ), actual, expected, message ); + }, + + strictEqual: function( actual, expected, message ) { + this.push( expected === actual, actual, expected, message ); + }, + + notStrictEqual: function( actual, expected, message ) { + this.push( expected !== actual, actual, expected, message ); + }, + + "throws": function( block, expected, message ) { + var actual, expectedType, + expectedOutput = expected, + ok = false, + currentTest = ( this instanceof Assert && this.test ) || QUnit.config.current; + + // 'expected' is optional unless doing string comparison + if ( message == null && typeof expected === "string" ) { + message = expected; + expected = null; + } + + currentTest.ignoreGlobalErrors = true; + try { + block.call( currentTest.testEnvironment ); + } catch (e) { + actual = e; + } + currentTest.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; + } + } + + currentTest.assert.push( ok, actual, expectedOutput, message ); + } + }; + + // Provide an alternative to assert.throws(), for enviroments that consider throws a reserved word + // Known to us are: Closure Compiler, Narwhal + (function() { + /*jshint sub:true */ + Assert.prototype.raises = Assert.prototype[ "throws" ]; + }()); + + // Test for equality any JavaScript type. + // Author: Philippe Rathé + 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 ); + + if ( dump.maxDepth && dump.depth > dump.maxDepth ) { + return "[object Array]"; + } + + this.up(); + while ( i-- ) { + ret[ i ] = this.parse( arr[ i ], undefined, stack ); + } + this.down(); + return join( "[", ret, "]" ); + } + + var reName = /^function (\w+)/, + dump = { + + // objType is used mostly internally, you can fix a (custom) type in advance + parse: function( obj, objType, stack ) { + stack = stack || []; + var res, parser, parserType, + inStack = inArray( obj, stack ); + + if ( inStack !== -1 ) { + return "recursion(" + ( inStack - stack.length ) + ")"; + } + + objType = objType || this.typeOf( obj ); + parser = this.parsers[ objType ]; + parserType = typeof parser; + + if ( parserType === "function" ) { + stack.push( obj ); + res = parser.call( this, obj, stack ); + stack.pop(); + return res; + } + return ( parserType === "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 ( obj.setInterval !== undefined && + obj.document !== undefined && + 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" && obj.item !== undefined && + ( obj.length ? obj.item( 0 ) === obj[ 0 ] : ( obj.item( 0 ) === null && + 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 ? "
      " : "\n" : this.HTML ? " " : " "; + }, + // 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, " " ); + } + 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, + maxDepth: QUnit.config.maxDepth, + + // 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 ) { + var keys, key, val, i, nonEnumerableProperties, + ret = []; + + if ( dump.maxDepth && dump.depth > dump.maxDepth ) { + return "[object Object]"; + } + + 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 && inArray( key, keys ) < 0 ) { + 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 ? "<" : "<", + close = dump.HTML ? ">" : ">", + 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", + "notOk", + "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 nodejs + if ( typeof module !== "undefined" && module && module.exports ) { + module.exports = QUnit; + + // For consistency with CommonJS environments' exports + module.exports.QUnit = QUnit; + } + + // For CommonJS with exports, but without module.exports, like Rhino + if ( typeof exports !== "undefined" && exports ) { + exports.QUnit = QUnit; + } + + //### BEGIN MODIFIED BY SAP + // In most of our test cases, QUnit is loaded via a script tag. If requireJS has been loaded before, + // (e.g. after chart library has been loaded), it rejects to define QUnit without a module name and throws an error. + // Furthermore, preventing the autorun in that case also causes problems, as tests are not prepared to handle this + // (they don't call QUnit.start). + // Drawback of this patch: this module can't be loaded via requireJS (not used within UI5) + // + //if ( typeof define === "function" && define.amd ) { + // define( function() { + // return QUnit; + // } ); + // QUnit.config.autostart = false; + //} + //### END MODIFIED BY SAP + + // Get a reference to the global object, like window in browsers + }( (function() { + return this; + })() )); + + /*istanbul ignore next */ + // jscs:disable maximumLineLength + /* + * This file is a modified version of google-diff-match-patch's JavaScript implementation + * (https://code.google.com/p/google-diff-match-patch/source/browse/trunk/javascript/diff_match_patch_uncompressed.js), + * modifications are licensed as more fully set forth in LICENSE.txt. + * + * The original source of google-diff-match-patch is attributable and licensed as follows: + * + * Copyright 2006 Google Inc. + * http://code.google.com/p/google-diff-match-patch/ + * + * Licensed 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. + * + * More Info: + * https://code.google.com/p/google-diff-match-patch/ + * + * Usage: QUnit.diff(expected, actual) + * + * QUnit.diff( "the quick brown fox jumped over", "the quick fox jumps over" ) === "the quick brown fox jumpsed} Array of diff tuples. + */ + DiffMatchPatch.prototype.DiffMain = function( text1, text2, optChecklines, optDeadline ) { + var deadline, checklines, commonlength, + commonprefix, commonsuffix, diffs; + // Set a deadline by which time the diff must be complete. + if ( typeof optDeadline === "undefined" ) { + if ( this.DiffTimeout <= 0 ) { + optDeadline = Number.MAX_VALUE; + } else { + optDeadline = ( new Date() ).getTime() + this.DiffTimeout * 1000; + } + } + deadline = optDeadline; + + // Check for null inputs. + if ( text1 === null || text2 === null ) { + throw new Error( "Null input. (DiffMain)" ); + } + + // Check for equality (speedup). + if ( text1 === text2 ) { + if ( text1 ) { + return [ + [ DIFF_EQUAL, text1 ] + ]; + } + return []; + } + + if ( typeof optChecklines === "undefined" ) { + optChecklines = true; + } + + checklines = optChecklines; + + // Trim off common prefix (speedup). + commonlength = this.diffCommonPrefix( text1, text2 ); + commonprefix = text1.substring( 0, commonlength ); + text1 = text1.substring( commonlength ); + text2 = text2.substring( commonlength ); + + // Trim off common suffix (speedup). + ///////// + commonlength = this.diffCommonSuffix( text1, text2 ); + commonsuffix = text1.substring( text1.length - commonlength ); + text1 = text1.substring( 0, text1.length - commonlength ); + text2 = text2.substring( 0, text2.length - commonlength ); + + // Compute the diff on the middle block. + diffs = this.diffCompute( text1, text2, checklines, deadline ); + + // Restore the prefix and suffix. + if ( commonprefix ) { + diffs.unshift( [ DIFF_EQUAL, commonprefix ] ); + } + if ( commonsuffix ) { + diffs.push( [ DIFF_EQUAL, commonsuffix ] ); + } + this.diffCleanupMerge( diffs ); + return diffs; + }; + + /** + * Reduce the number of edits by eliminating operationally trivial equalities. + * @param {!Array.} diffs Array of diff tuples. + */ + DiffMatchPatch.prototype.diffCleanupEfficiency = function( diffs ) { + var changes, equalities, equalitiesLength, lastequality, + pointer, preIns, preDel, postIns, postDel; + changes = false; + equalities = []; // Stack of indices where equalities are found. + equalitiesLength = 0; // Keeping our own length var is faster in JS. + /** @type {?string} */ + lastequality = null; + // Always equal to diffs[equalities[equalitiesLength - 1]][1] + pointer = 0; // Index of current position. + // Is there an insertion operation before the last equality. + preIns = false; + // Is there a deletion operation before the last equality. + preDel = false; + // Is there an insertion operation after the last equality. + postIns = false; + // Is there a deletion operation after the last equality. + postDel = false; + while ( pointer < diffs.length ) { + if ( diffs[ pointer ][ 0 ] === DIFF_EQUAL ) { // Equality found. + if ( diffs[ pointer ][ 1 ].length < this.DiffEditCost && ( postIns || postDel ) ) { + // Candidate found. + equalities[ equalitiesLength++ ] = pointer; + preIns = postIns; + preDel = postDel; + lastequality = diffs[ pointer ][ 1 ]; + } else { + // Not a candidate, and can never become one. + equalitiesLength = 0; + lastequality = null; + } + postIns = postDel = false; + } else { // An insertion or deletion. + if ( diffs[ pointer ][ 0 ] === DIFF_DELETE ) { + postDel = true; + } else { + postIns = true; + } + /* + * Five types to be split: + * ABXYCD + * AXCD + * ABXC + * AXCD + * ABXC + */ + if ( lastequality && ( ( preIns && preDel && postIns && postDel ) || + ( ( lastequality.length < this.DiffEditCost / 2 ) && + ( preIns + preDel + postIns + postDel ) === 3 ) ) ) { + // Duplicate record. + diffs.splice( equalities[equalitiesLength - 1], 0, [ DIFF_DELETE, lastequality ] ); + // Change second copy to insert. + diffs[ equalities[ equalitiesLength - 1 ] + 1 ][ 0 ] = DIFF_INSERT; + equalitiesLength--; // Throw away the equality we just deleted; + lastequality = null; + if (preIns && preDel) { + // No changes made which could affect previous entry, keep going. + postIns = postDel = true; + equalitiesLength = 0; + } else { + equalitiesLength--; // Throw away the previous equality. + pointer = equalitiesLength > 0 ? equalities[ equalitiesLength - 1 ] : -1; + postIns = postDel = false; + } + changes = true; + } + } + pointer++; + } + + if ( changes ) { + this.diffCleanupMerge( diffs ); + } + }; + + /** + * Convert a diff array into a pretty HTML report. + * @param {!Array.} diffs Array of diff tuples. + * @param {integer} string to be beautified. + * @return {string} HTML representation. + */ + DiffMatchPatch.prototype.diffPrettyHtml = function( diffs ) { + var op, data, x, html = []; + for ( x = 0; x < diffs.length; x++ ) { + op = diffs[x][0]; // Operation (insert, delete, equal) + data = diffs[x][1]; // Text of change. + switch ( op ) { + case DIFF_INSERT: + html[x] = "" + data + ""; + break; + case DIFF_DELETE: + html[x] = "" + data + ""; + break; + case DIFF_EQUAL: + html[x] = "" + data + ""; + break; + } + } + return html.join(""); + }; + + /** + * Determine the common prefix of two strings. + * @param {string} text1 First string. + * @param {string} text2 Second string. + * @return {number} The number of characters common to the start of each + * string. + */ + DiffMatchPatch.prototype.diffCommonPrefix = function( text1, text2 ) { + var pointermid, pointermax, pointermin, pointerstart; + // Quick check for common null cases. + if ( !text1 || !text2 || text1.charAt(0) !== text2.charAt(0) ) { + return 0; + } + // Binary search. + // Performance analysis: http://neil.fraser.name/news/2007/10/09/ + pointermin = 0; + pointermax = Math.min( text1.length, text2.length ); + pointermid = pointermax; + pointerstart = 0; + while ( pointermin < pointermid ) { + if ( text1.substring( pointerstart, pointermid ) === text2.substring( pointerstart, pointermid ) ) { + pointermin = pointermid; + pointerstart = pointermin; + } else { + pointermax = pointermid; + } + pointermid = Math.floor( ( pointermax - pointermin ) / 2 + pointermin ); + } + return pointermid; + }; + + /** + * Determine the common suffix of two strings. + * @param {string} text1 First string. + * @param {string} text2 Second string. + * @return {number} The number of characters common to the end of each string. + */ + DiffMatchPatch.prototype.diffCommonSuffix = function( text1, text2 ) { + var pointermid, pointermax, pointermin, pointerend; + // Quick check for common null cases. + if (!text1 || !text2 || text1.charAt(text1.length - 1) !== text2.charAt(text2.length - 1)) { + return 0; + } + // Binary search. + // Performance analysis: http://neil.fraser.name/news/2007/10/09/ + pointermin = 0; + pointermax = Math.min(text1.length, text2.length); + pointermid = pointermax; + pointerend = 0; + while ( pointermin < pointermid ) { + if (text1.substring( text1.length - pointermid, text1.length - pointerend ) === + text2.substring( text2.length - pointermid, text2.length - pointerend ) ) { + pointermin = pointermid; + pointerend = pointermin; + } else { + pointermax = pointermid; + } + pointermid = Math.floor( ( pointermax - pointermin ) / 2 + pointermin ); + } + return pointermid; + }; + + /** + * Find the differences between two texts. Assumes that the texts do not + * have any common prefix or suffix. + * @param {string} text1 Old string to be diffed. + * @param {string} text2 New string to be diffed. + * @param {boolean} checklines Speedup flag. If false, then don't run a + * line-level diff first to identify the changed areas. + * If true, then run a faster, slightly less optimal diff. + * @param {number} deadline Time when the diff should be complete by. + * @return {!Array.} Array of diff tuples. + * @private + */ + DiffMatchPatch.prototype.diffCompute = function( text1, text2, checklines, deadline ) { + var diffs, longtext, shorttext, i, hm, + text1A, text2A, text1B, text2B, + midCommon, diffsA, diffsB; + + if ( !text1 ) { + // Just add some text (speedup). + return [ + [ DIFF_INSERT, text2 ] + ]; + } + + if (!text2) { + // Just delete some text (speedup). + return [ + [ DIFF_DELETE, text1 ] + ]; + } + + longtext = text1.length > text2.length ? text1 : text2; + shorttext = text1.length > text2.length ? text2 : text1; + i = longtext.indexOf( shorttext ); + if ( i !== -1 ) { + // Shorter text is inside the longer text (speedup). + diffs = [ + [ DIFF_INSERT, longtext.substring( 0, i ) ], + [ DIFF_EQUAL, shorttext ], + [ DIFF_INSERT, longtext.substring( i + shorttext.length ) ] + ]; + // Swap insertions for deletions if diff is reversed. + if ( text1.length > text2.length ) { + diffs[0][0] = diffs[2][0] = DIFF_DELETE; + } + return diffs; + } + + if ( shorttext.length === 1 ) { + // Single character string. + // After the previous speedup, the character can't be an equality. + return [ + [ DIFF_DELETE, text1 ], + [ DIFF_INSERT, text2 ] + ]; + } + + // Check to see if the problem can be split in two. + hm = this.diffHalfMatch(text1, text2); + if (hm) { + // A half-match was found, sort out the return data. + text1A = hm[0]; + text1B = hm[1]; + text2A = hm[2]; + text2B = hm[3]; + midCommon = hm[4]; + // Send both pairs off for separate processing. + diffsA = this.DiffMain(text1A, text2A, checklines, deadline); + diffsB = this.DiffMain(text1B, text2B, checklines, deadline); + // Merge the results. + return diffsA.concat([ + [ DIFF_EQUAL, midCommon ] + ], diffsB); + } + + if (checklines && text1.length > 100 && text2.length > 100) { + return this.diffLineMode(text1, text2, deadline); + } + + return this.diffBisect(text1, text2, deadline); + }; + + /** + * Do the two texts share a substring which is at least half the length of the + * longer text? + * This speedup can produce non-minimal diffs. + * @param {string} text1 First string. + * @param {string} text2 Second string. + * @return {Array.} Five element Array, containing the prefix of + * text1, the suffix of text1, the prefix of text2, the suffix of + * text2 and the common middle. Or null if there was no match. + * @private + */ + DiffMatchPatch.prototype.diffHalfMatch = function(text1, text2) { + var longtext, shorttext, dmp, + text1A, text2B, text2A, text1B, midCommon, + hm1, hm2, hm; + if (this.DiffTimeout <= 0) { + // Don't risk returning a non-optimal diff if we have unlimited time. + return null; + } + longtext = text1.length > text2.length ? text1 : text2; + shorttext = text1.length > text2.length ? text2 : text1; + if (longtext.length < 4 || shorttext.length * 2 < longtext.length) { + return null; // Pointless. + } + dmp = this; // 'this' becomes 'window' in a closure. + + /** + * Does a substring of shorttext exist within longtext such that the substring + * is at least half the length of longtext? + * Closure, but does not reference any external variables. + * @param {string} longtext Longer string. + * @param {string} shorttext Shorter string. + * @param {number} i Start index of quarter length substring within longtext. + * @return {Array.} Five element Array, containing the prefix of + * longtext, the suffix of longtext, the prefix of shorttext, the suffix + * of shorttext and the common middle. Or null if there was no match. + * @private + */ + function diffHalfMatchI(longtext, shorttext, i) { + var seed, j, bestCommon, prefixLength, suffixLength, + bestLongtextA, bestLongtextB, bestShorttextA, bestShorttextB; + // Start with a 1/4 length substring at position i as a seed. + seed = longtext.substring(i, i + Math.floor(longtext.length / 4)); + j = -1; + bestCommon = ""; + while ((j = shorttext.indexOf(seed, j + 1)) !== -1) { + prefixLength = dmp.diffCommonPrefix(longtext.substring(i), + shorttext.substring(j)); + suffixLength = dmp.diffCommonSuffix(longtext.substring(0, i), + shorttext.substring(0, j)); + if (bestCommon.length < suffixLength + prefixLength) { + bestCommon = shorttext.substring(j - suffixLength, j) + + shorttext.substring(j, j + prefixLength); + bestLongtextA = longtext.substring(0, i - suffixLength); + bestLongtextB = longtext.substring(i + prefixLength); + bestShorttextA = shorttext.substring(0, j - suffixLength); + bestShorttextB = shorttext.substring(j + prefixLength); + } + } + if (bestCommon.length * 2 >= longtext.length) { + return [ bestLongtextA, bestLongtextB, + bestShorttextA, bestShorttextB, bestCommon + ]; + } else { + return null; + } + } + + // First check if the second quarter is the seed for a half-match. + hm1 = diffHalfMatchI(longtext, shorttext, + Math.ceil(longtext.length / 4)); + // Check again based on the third quarter. + hm2 = diffHalfMatchI(longtext, shorttext, + Math.ceil(longtext.length / 2)); + if (!hm1 && !hm2) { + return null; + } else if (!hm2) { + hm = hm1; + } else if (!hm1) { + hm = hm2; + } else { + // Both matched. Select the longest. + hm = hm1[4].length > hm2[4].length ? hm1 : hm2; + } + + // A half-match was found, sort out the return data. + text1A, text1B, text2A, text2B; + if (text1.length > text2.length) { + text1A = hm[0]; + text1B = hm[1]; + text2A = hm[2]; + text2B = hm[3]; + } else { + text2A = hm[0]; + text2B = hm[1]; + text1A = hm[2]; + text1B = hm[3]; + } + midCommon = hm[4]; + return [ text1A, text1B, text2A, text2B, midCommon ]; + }; + + /** + * Do a quick line-level diff on both strings, then rediff the parts for + * greater accuracy. + * This speedup can produce non-minimal diffs. + * @param {string} text1 Old string to be diffed. + * @param {string} text2 New string to be diffed. + * @param {number} deadline Time when the diff should be complete by. + * @return {!Array.} Array of diff tuples. + * @private + */ + DiffMatchPatch.prototype.diffLineMode = function(text1, text2, deadline) { + var a, diffs, linearray, pointer, countInsert, + countDelete, textInsert, textDelete, j; + // Scan the text on a line-by-line basis first. + a = this.diffLinesToChars(text1, text2); + text1 = a.chars1; + text2 = a.chars2; + linearray = a.lineArray; + + diffs = this.DiffMain(text1, text2, false, deadline); + + // Convert the diff back to original text. + this.diffCharsToLines(diffs, linearray); + // Eliminate freak matches (e.g. blank lines) + this.diffCleanupSemantic(diffs); + + // Rediff any replacement blocks, this time character-by-character. + // Add a dummy entry at the end. + diffs.push( [ DIFF_EQUAL, "" ] ); + pointer = 0; + countDelete = 0; + countInsert = 0; + textDelete = ""; + textInsert = ""; + while (pointer < diffs.length) { + switch ( diffs[pointer][0] ) { + case DIFF_INSERT: + countInsert++; + textInsert += diffs[pointer][1]; + break; + case DIFF_DELETE: + countDelete++; + textDelete += diffs[pointer][1]; + break; + case DIFF_EQUAL: + // Upon reaching an equality, check for prior redundancies. + if (countDelete >= 1 && countInsert >= 1) { + // Delete the offending records and add the merged ones. + diffs.splice(pointer - countDelete - countInsert, + countDelete + countInsert); + pointer = pointer - countDelete - countInsert; + a = this.DiffMain(textDelete, textInsert, false, deadline); + for (j = a.length - 1; j >= 0; j--) { + diffs.splice( pointer, 0, a[j] ); + } + pointer = pointer + a.length; + } + countInsert = 0; + countDelete = 0; + textDelete = ""; + textInsert = ""; + break; + } + pointer++; + } + diffs.pop(); // Remove the dummy entry at the end. + + return diffs; + }; + + /** + * Find the 'middle snake' of a diff, split the problem in two + * and return the recursively constructed diff. + * See Myers 1986 paper: An O(ND) Difference Algorithm and Its Variations. + * @param {string} text1 Old string to be diffed. + * @param {string} text2 New string to be diffed. + * @param {number} deadline Time at which to bail if not yet complete. + * @return {!Array.} Array of diff tuples. + * @private + */ + DiffMatchPatch.prototype.diffBisect = function(text1, text2, deadline) { + var text1Length, text2Length, maxD, vOffset, vLength, + v1, v2, x, delta, front, k1start, k1end, k2start, + k2end, k2Offset, k1Offset, x1, x2, y1, y2, d, k1, k2; + // Cache the text lengths to prevent multiple calls. + text1Length = text1.length; + text2Length = text2.length; + maxD = Math.ceil((text1Length + text2Length) / 2); + vOffset = maxD; + vLength = 2 * maxD; + v1 = new Array(vLength); + v2 = new Array(vLength); + // Setting all elements to -1 is faster in Chrome & Firefox than mixing + // integers and undefined. + for (x = 0; x < vLength; x++) { + v1[x] = -1; + v2[x] = -1; + } + v1[vOffset + 1] = 0; + v2[vOffset + 1] = 0; + delta = text1Length - text2Length; + // If the total number of characters is odd, then the front path will collide + // with the reverse path. + front = (delta % 2 !== 0); + // Offsets for start and end of k loop. + // Prevents mapping of space beyond the grid. + k1start = 0; + k1end = 0; + k2start = 0; + k2end = 0; + for (d = 0; d < maxD; d++) { + // Bail out if deadline is reached. + if ((new Date()).getTime() > deadline) { + break; + } + + // Walk the front path one step. + for (k1 = -d + k1start; k1 <= d - k1end; k1 += 2) { + k1Offset = vOffset + k1; + if ( k1 === -d || ( k1 !== d && v1[ k1Offset - 1 ] < v1[ k1Offset + 1 ] ) ) { + x1 = v1[k1Offset + 1]; + } else { + x1 = v1[k1Offset - 1] + 1; + } + y1 = x1 - k1; + while (x1 < text1Length && y1 < text2Length && + text1.charAt(x1) === text2.charAt(y1)) { + x1++; + y1++; + } + v1[k1Offset] = x1; + if (x1 > text1Length) { + // Ran off the right of the graph. + k1end += 2; + } else if (y1 > text2Length) { + // Ran off the bottom of the graph. + k1start += 2; + } else if (front) { + k2Offset = vOffset + delta - k1; + if (k2Offset >= 0 && k2Offset < vLength && v2[k2Offset] !== -1) { + // Mirror x2 onto top-left coordinate system. + x2 = text1Length - v2[k2Offset]; + if (x1 >= x2) { + // Overlap detected. + return this.diffBisectSplit(text1, text2, x1, y1, deadline); + } + } + } + } + + // Walk the reverse path one step. + for (k2 = -d + k2start; k2 <= d - k2end; k2 += 2) { + k2Offset = vOffset + k2; + if ( k2 === -d || (k2 !== d && v2[ k2Offset - 1 ] < v2[ k2Offset + 1 ] ) ) { + x2 = v2[k2Offset + 1]; + } else { + x2 = v2[k2Offset - 1] + 1; + } + y2 = x2 - k2; + while (x2 < text1Length && y2 < text2Length && + text1.charAt(text1Length - x2 - 1) === + text2.charAt(text2Length - y2 - 1)) { + x2++; + y2++; + } + v2[k2Offset] = x2; + if (x2 > text1Length) { + // Ran off the left of the graph. + k2end += 2; + } else if (y2 > text2Length) { + // Ran off the top of the graph. + k2start += 2; + } else if (!front) { + k1Offset = vOffset + delta - k2; + if (k1Offset >= 0 && k1Offset < vLength && v1[k1Offset] !== -1) { + x1 = v1[k1Offset]; + y1 = vOffset + x1 - k1Offset; + // Mirror x2 onto top-left coordinate system. + x2 = text1Length - x2; + if (x1 >= x2) { + // Overlap detected. + return this.diffBisectSplit(text1, text2, x1, y1, deadline); + } + } + } + } + } + // Diff took too long and hit the deadline or + // number of diffs equals number of characters, no commonality at all. + return [ + [ DIFF_DELETE, text1 ], + [ DIFF_INSERT, text2 ] + ]; + }; + + /** + * Given the location of the 'middle snake', split the diff in two parts + * and recurse. + * @param {string} text1 Old string to be diffed. + * @param {string} text2 New string to be diffed. + * @param {number} x Index of split point in text1. + * @param {number} y Index of split point in text2. + * @param {number} deadline Time at which to bail if not yet complete. + * @return {!Array.} Array of diff tuples. + * @private + */ + DiffMatchPatch.prototype.diffBisectSplit = function( text1, text2, x, y, deadline ) { + var text1a, text1b, text2a, text2b, diffs, diffsb; + text1a = text1.substring(0, x); + text2a = text2.substring(0, y); + text1b = text1.substring(x); + text2b = text2.substring(y); + + // Compute both diffs serially. + diffs = this.DiffMain(text1a, text2a, false, deadline); + diffsb = this.DiffMain(text1b, text2b, false, deadline); + + return diffs.concat(diffsb); + }; + + /** + * Reduce the number of edits by eliminating semantically trivial equalities. + * @param {!Array.} diffs Array of diff tuples. + */ + DiffMatchPatch.prototype.diffCleanupSemantic = function(diffs) { + var changes, equalities, equalitiesLength, lastequality, + pointer, lengthInsertions2, lengthDeletions2, lengthInsertions1, + lengthDeletions1, deletion, insertion, overlapLength1, overlapLength2; + changes = false; + equalities = []; // Stack of indices where equalities are found. + equalitiesLength = 0; // Keeping our own length var is faster in JS. + /** @type {?string} */ + lastequality = null; + // Always equal to diffs[equalities[equalitiesLength - 1]][1] + pointer = 0; // Index of current position. + // Number of characters that changed prior to the equality. + lengthInsertions1 = 0; + lengthDeletions1 = 0; + // Number of characters that changed after the equality. + lengthInsertions2 = 0; + lengthDeletions2 = 0; + while (pointer < diffs.length) { + if (diffs[pointer][0] === DIFF_EQUAL) { // Equality found. + equalities[equalitiesLength++] = pointer; + lengthInsertions1 = lengthInsertions2; + lengthDeletions1 = lengthDeletions2; + lengthInsertions2 = 0; + lengthDeletions2 = 0; + lastequality = diffs[pointer][1]; + } else { // An insertion or deletion. + if (diffs[pointer][0] === DIFF_INSERT) { + lengthInsertions2 += diffs[pointer][1].length; + } else { + lengthDeletions2 += diffs[pointer][1].length; + } + // Eliminate an equality that is smaller or equal to the edits on both + // sides of it. + if (lastequality && (lastequality.length <= + Math.max(lengthInsertions1, lengthDeletions1)) && + (lastequality.length <= Math.max(lengthInsertions2, + lengthDeletions2))) { + // Duplicate record. + diffs.splice( equalities[ equalitiesLength - 1 ], 0, [ DIFF_DELETE, lastequality ] ); + // Change second copy to insert. + diffs[equalities[equalitiesLength - 1] + 1][0] = DIFF_INSERT; + // Throw away the equality we just deleted. + equalitiesLength--; + // Throw away the previous equality (it needs to be reevaluated). + equalitiesLength--; + pointer = equalitiesLength > 0 ? equalities[equalitiesLength - 1] : -1; + lengthInsertions1 = 0; // Reset the counters. + lengthDeletions1 = 0; + lengthInsertions2 = 0; + lengthDeletions2 = 0; + lastequality = null; + changes = true; + } + } + pointer++; + } + + // Normalize the diff. + if (changes) { + this.diffCleanupMerge(diffs); + } + + // Find any overlaps between deletions and insertions. + // e.g: abcxxxxxxdef + // -> abcxxxdef + // e.g: xxxabcdefxxx + // -> defxxxabc + // Only extract an overlap if it is as big as the edit ahead or behind it. + pointer = 1; + while (pointer < diffs.length) { + if (diffs[pointer - 1][0] === DIFF_DELETE && + diffs[pointer][0] === DIFF_INSERT) { + deletion = diffs[pointer - 1][1]; + insertion = diffs[pointer][1]; + overlapLength1 = this.diffCommonOverlap(deletion, insertion); + overlapLength2 = this.diffCommonOverlap(insertion, deletion); + if (overlapLength1 >= overlapLength2) { + if (overlapLength1 >= deletion.length / 2 || + overlapLength1 >= insertion.length / 2) { + // Overlap found. Insert an equality and trim the surrounding edits. + diffs.splice( pointer, 0, [ DIFF_EQUAL, insertion.substring( 0, overlapLength1 ) ] ); + diffs[pointer - 1][1] = + deletion.substring(0, deletion.length - overlapLength1); + diffs[pointer + 1][1] = insertion.substring(overlapLength1); + pointer++; + } + } else { + if (overlapLength2 >= deletion.length / 2 || + overlapLength2 >= insertion.length / 2) { + // Reverse overlap found. + // Insert an equality and swap and trim the surrounding edits. + diffs.splice( pointer, 0, [ DIFF_EQUAL, deletion.substring( 0, overlapLength2 ) ] ); + diffs[pointer - 1][0] = DIFF_INSERT; + diffs[pointer - 1][1] = + insertion.substring(0, insertion.length - overlapLength2); + diffs[pointer + 1][0] = DIFF_DELETE; + diffs[pointer + 1][1] = + deletion.substring(overlapLength2); + pointer++; + } + } + pointer++; + } + pointer++; + } + }; + + /** + * Determine if the suffix of one string is the prefix of another. + * @param {string} text1 First string. + * @param {string} text2 Second string. + * @return {number} The number of characters common to the end of the first + * string and the start of the second string. + * @private + */ + DiffMatchPatch.prototype.diffCommonOverlap = function(text1, text2) { + var text1Length, text2Length, textLength, + best, length, pattern, found; + // Cache the text lengths to prevent multiple calls. + text1Length = text1.length; + text2Length = text2.length; + // Eliminate the null case. + if (text1Length === 0 || text2Length === 0) { + return 0; + } + // Truncate the longer string. + if (text1Length > text2Length) { + text1 = text1.substring(text1Length - text2Length); + } else if (text1Length < text2Length) { + text2 = text2.substring(0, text1Length); + } + textLength = Math.min(text1Length, text2Length); + // Quick check for the worst case. + if (text1 === text2) { + return textLength; + } + + // Start by looking for a single character match + // and increase length until no match is found. + // Performance analysis: http://neil.fraser.name/news/2010/11/04/ + best = 0; + length = 1; + while (true) { + pattern = text1.substring(textLength - length); + found = text2.indexOf(pattern); + if (found === -1) { + return best; + } + length += found; + if (found === 0 || text1.substring(textLength - length) === + text2.substring(0, length)) { + best = length; + length++; + } + } + }; + + /** + * Split two texts into an array of strings. Reduce the texts to a string of + * hashes where each Unicode character represents one line. + * @param {string} text1 First string. + * @param {string} text2 Second string. + * @return {{chars1: string, chars2: string, lineArray: !Array.}} + * An object containing the encoded text1, the encoded text2 and + * the array of unique strings. + * The zeroth element of the array of unique strings is intentionally blank. + * @private + */ + DiffMatchPatch.prototype.diffLinesToChars = function(text1, text2) { + var lineArray, lineHash, chars1, chars2; + lineArray = []; // e.g. lineArray[4] === 'Hello\n' + lineHash = {}; // e.g. lineHash['Hello\n'] === 4 + + // '\x00' is a valid character, but various debuggers don't like it. + // So we'll insert a junk entry to avoid generating a null character. + lineArray[0] = ""; + + /** + * Split a text into an array of strings. Reduce the texts to a string of + * hashes where each Unicode character represents one line. + * Modifies linearray and linehash through being a closure. + * @param {string} text String to encode. + * @return {string} Encoded string. + * @private + */ + function diffLinesToCharsMunge(text) { + var chars, lineStart, lineEnd, lineArrayLength, line; + chars = ""; + // Walk the text, pulling out a substring for each line. + // text.split('\n') would would temporarily double our memory footprint. + // Modifying text would create many large strings to garbage collect. + lineStart = 0; + lineEnd = -1; + // Keeping our own length variable is faster than looking it up. + lineArrayLength = lineArray.length; + while (lineEnd < text.length - 1) { + lineEnd = text.indexOf("\n", lineStart); + if (lineEnd === -1) { + lineEnd = text.length - 1; + } + line = text.substring(lineStart, lineEnd + 1); + lineStart = lineEnd + 1; + + if (lineHash.hasOwnProperty ? lineHash.hasOwnProperty(line) : + (lineHash[line] !== undefined)) { + chars += String.fromCharCode( lineHash[ line ] ); + } else { + chars += String.fromCharCode(lineArrayLength); + lineHash[line] = lineArrayLength; + lineArray[lineArrayLength++] = line; + } + } + return chars; + } + + chars1 = diffLinesToCharsMunge(text1); + chars2 = diffLinesToCharsMunge(text2); + return { + chars1: chars1, + chars2: chars2, + lineArray: lineArray + }; + }; + + /** + * Rehydrate the text in a diff from a string of line hashes to real lines of + * text. + * @param {!Array.} diffs Array of diff tuples. + * @param {!Array.} lineArray Array of unique strings. + * @private + */ + DiffMatchPatch.prototype.diffCharsToLines = function( diffs, lineArray ) { + var x, chars, text, y; + for ( x = 0; x < diffs.length; x++ ) { + chars = diffs[x][1]; + text = []; + for ( y = 0; y < chars.length; y++ ) { + text[y] = lineArray[chars.charCodeAt(y)]; + } + diffs[x][1] = text.join(""); + } + }; + + /** + * Reorder and merge like edit sections. Merge equalities. + * Any edit section can move as long as it doesn't cross an equality. + * @param {!Array.} diffs Array of diff tuples. + */ + DiffMatchPatch.prototype.diffCleanupMerge = function(diffs) { + var pointer, countDelete, countInsert, textInsert, textDelete, + commonlength, changes; + diffs.push( [ DIFF_EQUAL, "" ] ); // Add a dummy entry at the end. + pointer = 0; + countDelete = 0; + countInsert = 0; + textDelete = ""; + textInsert = ""; + commonlength; + while (pointer < diffs.length) { + switch ( diffs[ pointer ][ 0 ] ) { + case DIFF_INSERT: + countInsert++; + textInsert += diffs[pointer][1]; + pointer++; + break; + case DIFF_DELETE: + countDelete++; + textDelete += diffs[pointer][1]; + pointer++; + break; + case DIFF_EQUAL: + // Upon reaching an equality, check for prior redundancies. + if (countDelete + countInsert > 1) { + if (countDelete !== 0 && countInsert !== 0) { + // Factor out any common prefixies. + commonlength = this.diffCommonPrefix(textInsert, textDelete); + if (commonlength !== 0) { + if ((pointer - countDelete - countInsert) > 0 && + diffs[pointer - countDelete - countInsert - 1][0] === + DIFF_EQUAL) { + diffs[pointer - countDelete - countInsert - 1][1] += + textInsert.substring(0, commonlength); + } else { + diffs.splice( 0, 0, [ DIFF_EQUAL, + textInsert.substring( 0, commonlength ) + ] ); + pointer++; + } + textInsert = textInsert.substring(commonlength); + textDelete = textDelete.substring(commonlength); + } + // Factor out any common suffixies. + commonlength = this.diffCommonSuffix(textInsert, textDelete); + if (commonlength !== 0) { + diffs[pointer][1] = textInsert.substring(textInsert.length - + commonlength) + diffs[pointer][1]; + textInsert = textInsert.substring(0, textInsert.length - + commonlength); + textDelete = textDelete.substring(0, textDelete.length - + commonlength); + } + } + // Delete the offending records and add the merged ones. + if (countDelete === 0) { + diffs.splice( pointer - countInsert, + countDelete + countInsert, [ DIFF_INSERT, textInsert ] ); + } else if (countInsert === 0) { + diffs.splice( pointer - countDelete, + countDelete + countInsert, [ DIFF_DELETE, textDelete ] ); + } else { + diffs.splice( pointer - countDelete - countInsert, + countDelete + countInsert, [ DIFF_DELETE, textDelete ], [ DIFF_INSERT, textInsert ] ); + } + pointer = pointer - countDelete - countInsert + + (countDelete ? 1 : 0) + (countInsert ? 1 : 0) + 1; + } else if (pointer !== 0 && diffs[pointer - 1][0] === DIFF_EQUAL) { + // Merge this equality with the previous one. + diffs[pointer - 1][1] += diffs[pointer][1]; + diffs.splice(pointer, 1); + } else { + pointer++; + } + countInsert = 0; + countDelete = 0; + textDelete = ""; + textInsert = ""; + break; + } + } + if (diffs[diffs.length - 1][1] === "") { + diffs.pop(); // Remove the dummy entry at the end. + } + + // Second pass: look for single edits surrounded on both sides by equalities + // which can be shifted sideways to eliminate an equality. + // e.g: ABAC -> ABAC + changes = false; + pointer = 1; + // Intentionally ignore the first and last element (don't need checking). + while (pointer < diffs.length - 1) { + if (diffs[pointer - 1][0] === DIFF_EQUAL && + diffs[pointer + 1][0] === DIFF_EQUAL) { + // This is a single edit surrounded by equalities. + if ( diffs[ pointer ][ 1 ].substring( diffs[ pointer ][ 1 ].length - + diffs[ pointer - 1 ][ 1 ].length ) === diffs[ pointer - 1 ][ 1 ] ) { + // Shift the edit over the previous equality. + diffs[pointer][1] = diffs[pointer - 1][1] + + diffs[pointer][1].substring(0, diffs[pointer][1].length - + diffs[pointer - 1][1].length); + diffs[pointer + 1][1] = diffs[pointer - 1][1] + diffs[pointer + 1][1]; + diffs.splice(pointer - 1, 1); + changes = true; + } else if ( diffs[ pointer ][ 1 ].substring( 0, diffs[ pointer + 1 ][ 1 ].length ) === + diffs[ pointer + 1 ][ 1 ] ) { + // Shift the edit over the next equality. + diffs[pointer - 1][1] += diffs[pointer + 1][1]; + diffs[pointer][1] = + diffs[pointer][1].substring(diffs[pointer + 1][1].length) + + diffs[pointer + 1][1]; + diffs.splice(pointer + 1, 1); + changes = true; + } + } + pointer++; + } + // If shifts were made, the diff needs reordering and another shift sweep. + if (changes) { + this.diffCleanupMerge(diffs); + } + }; + + return function(o, n) { + var diff, output, text; + diff = new DiffMatchPatch(); + output = diff.DiffMain(o, n); + //console.log(output); + diff.diffCleanupEfficiency(output); + text = diff.diffPrettyHtml(output); + + return text; + }; + }()); + // jscs:enable + + (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 = []; + + // 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 = + "

      " + escapeText( document.title ) + "

      " + + "

      " + + "
      " + + "

      " + + "
        "; + } + + 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...
         "; + } + }; + + // 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: window.document !== undefined, + sessionStorage: (function() { + var x = "qunit-test-string"; + try { + sessionStorage.setItem( x, x ); + sessionStorage.removeItem( x ); + return true; + } catch ( e ) { + return false; + } + }()) + }, + modulesList = []; + + /** + * 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 "'"; + case "\"": + return """; + case "<": + return "<"; + case ">": + return ">"; + case "&": + return "&"; + } + }); + } + + /** + * @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, function() { + var event = window.event; + if ( !event.target ) { + event.target = event.srcElement || document; + } + + fn.call( elem, event ); + }); + } + } + + /** + * @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 ); + + if ( config[ val.id ] === undefined ) { + config[ val.id ] = QUnit.urlParams[ val.id ]; + } + + if ( !val.value || typeof val.value === "string" ) { + urlConfigHtml += ""; + } else { + urlConfigHtml += ""; + } + } + + return urlConfigHtml; + } + + // Handle "click" events on toolbar checkboxes and "change" for select menus. + // Updates the URL with the new state of `config.urlConfig` values. + function toolbarChanged() { + var updatedUrl, value, + field = this, + params = {}; + + // Detect if field is a select menu or a checkbox + if ( "selectedIndex" in field ) { + value = field.options[ field.selectedIndex ].value || undefined; + } else { + value = field.checked ? ( field.defaultValue || true ) : undefined; + } + + params[ field.name ] = value; + updatedUrl = setUrl( params ); + + if ( "hidepassed" === field.name && "replaceState" in window.history ) { + config[ field.name ] = value || false; + if ( value ) { + addClass( id( "qunit-tests" ), "hidepass" ); + } else { + removeClass( id( "qunit-tests" ), "hidepass" ); + } + + // It is not necessary to refresh the whole page + window.history.replaceState( null, "", updatedUrl ); + } else { + window.location = updatedUrl; + } + } + + function setUrl( params ) { + var key, + querystring = "?"; + + params = QUnit.extend( QUnit.extend( {}, QUnit.urlParams ), params ); + + for ( key in params ) { + if ( hasOwn.call( params, key ) ) { + if ( params[ key ] === undefined ) { + continue; + } + querystring += encodeURIComponent( key ); + if ( params[ key ] !== true ) { + querystring += "=" + encodeURIComponent( params[ key ] ); + } + querystring += "&"; + } + } + return location.protocol + "//" + location.host + + location.pathname + querystring.slice( 0, -1 ); + } + + function applyUrlParams() { + var selectedModule, + modulesList = id( "qunit-modulefilter" ), + filter = id( "qunit-filter-input" ).value; + + selectedModule = modulesList ? + decodeURIComponent( modulesList.options[ modulesList.selectedIndex ].value ) : + undefined; + + window.location = setUrl({ + module: ( selectedModule === "" ) ? undefined : selectedModule, + filter: ( filter === "" ) ? undefined : filter, + + // Remove testId filter + testId: undefined + }); + } + + function toolbarUrlConfigContainer() { + var urlConfigContainer = document.createElement( "span" ); + + urlConfigContainer.innerHTML = getUrlConfigHtml(); + addClass( urlConfigContainer, "qunit-url-config" ); + + // For oldIE support: + // * Add handlers to the individual elements instead of the container + // * Use "click" instead of "change" for checkboxes + addEvents( urlConfigContainer.getElementsByTagName( "input" ), "click", toolbarChanged ); + addEvents( urlConfigContainer.getElementsByTagName( "select" ), "change", toolbarChanged ); + + return urlConfigContainer; + } + + function toolbarLooseFilter() { + var filter = document.createElement( "form" ), + label = document.createElement( "label" ), + input = document.createElement( "input" ), + button = document.createElement( "button" ); + + addClass( filter, "qunit-filter" ); + + label.innerHTML = "Filter: "; + + input.type = "text"; + input.value = config.filter || ""; + input.name = "filter"; + input.id = "qunit-filter-input"; + + button.innerHTML = "Go"; + + label.appendChild( input ); + + filter.appendChild( label ); + filter.appendChild( button ); + addEvent( filter, "submit", function( ev ) { + applyUrlParams(); + + if ( ev && ev.preventDefault ) { + ev.preventDefault(); + } + + return false; + }); + + return filter; + } + + function toolbarModuleFilterHtml() { + var i, + moduleFilterHtml = ""; + + if ( !modulesList.length ) { + return false; + } + + modulesList.sort(function( a, b ) { + return a.localeCompare( b ); + }); + + moduleFilterHtml += "" + + ""; + + return moduleFilterHtml; + } + + function toolbarModuleFilter() { + var toolbar = id( "qunit-testrunner-toolbar" ), + moduleFilter = document.createElement( "span" ), + moduleFilterHtml = toolbarModuleFilterHtml(); + + if ( !toolbar || !moduleFilterHtml ) { + return false; + } + + moduleFilter.setAttribute( "id", "qunit-modulefilter-container" ); + moduleFilter.innerHTML = moduleFilterHtml; + + addEvent( moduleFilter.lastChild, "change", applyUrlParams ); + + toolbar.appendChild( moduleFilter ); + } + + function appendToolbar() { + var toolbar = id( "qunit-testrunner-toolbar" ); + + if ( toolbar ) { + toolbar.appendChild( toolbarUrlConfigContainer() ); + toolbar.appendChild( toolbarLooseFilter() ); + } + } + + function appendHeader() { + var header = id( "qunit-header" ); + + if ( header ) { + header.innerHTML = "" + header.innerHTML + " "; + } + } + + function appendBanner() { + var banner = id( "qunit-banner" ); + + if ( banner ) { + banner.className = ""; + } + } + + 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...
         "; + } + } + + function storeFixture() { + var fixture = id( "qunit-fixture" ); + if ( fixture ) { + config.fixture = fixture.innerHTML; + } + } + + function appendUserAgent() { + var userAgent = id( "qunit-userAgent" ); + + if ( userAgent ) { + userAgent.innerHTML = ""; + userAgent.appendChild( + document.createTextNode( + "QUnit " + QUnit.version + "; " + navigator.userAgent + ) + ); + } + } + + function appendTestsList( modules ) { + var i, l, x, z, test, moduleObj; + + for ( i = 0, l = modules.length; i < l; i++ ) { + moduleObj = modules[ i ]; + + if ( moduleObj.name ) { + modulesList.push( moduleObj.name ); + } + + for ( x = 0, z = moduleObj.tests.length; x < z; x++ ) { + test = moduleObj.tests[ x ]; + + appendTest( test.name, test.testId, moduleObj.name ); + } + } + } + + function appendTest( name, testId, moduleName ) { + var title, rerunTrigger, testBlock, assertList, + tests = id( "qunit-tests" ); + + if ( !tests ) { + return; + } + + title = document.createElement( "strong" ); + title.innerHTML = getNameHtml( name, moduleName ); + + rerunTrigger = document.createElement( "a" ); + rerunTrigger.innerHTML = "Rerun"; + rerunTrigger.href = setUrl({ testId: testId }); + + testBlock = document.createElement( "li" ); + testBlock.appendChild( title ); + testBlock.appendChild( rerunTrigger ); + testBlock.id = "qunit-test-output-" + testId; + + assertList = document.createElement( "ol" ); + assertList.className = "qunit-assert-list"; + + testBlock.appendChild( assertList ); + + tests.appendChild( testBlock ); + } + + // HTML Reporter initialization and load + QUnit.begin(function( details ) { + var qunit = id( "qunit" ); + + // Fixture is the only one necessary to run without the #qunit element + storeFixture(); + + if ( qunit ) { + qunit.innerHTML = + "

        " + escapeText( document.title ) + "

        " + + "

        " + + "
        " + + "

        " + + "
          "; + } + + appendHeader(); + appendBanner(); + appendTestResults(); + appendUserAgent(); + appendToolbar(); + appendTestsList( details.modules ); + toolbarModuleFilter(); + + if ( qunit && config.hidepassed ) { + addClass( qunit.lastChild, "hidepass" ); + } + }); + + QUnit.done(function( details ) { + var i, key, + banner = id( "qunit-banner" ), + tests = id( "qunit-tests" ), + html = [ + "Tests completed in ", + details.runtime, + " milliseconds.
          ", + "", + details.passed, + " assertions of ", + details.total, + " passed, ", + details.failed, + " 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 = "" + escapeText( module ) + ": "; + } + + nameHtml += "" + escapeText( name ) + ""; + + return nameHtml; + } + + QUnit.testStart(function( details ) { + var running, testBlock, bad; + + testBlock = id( "qunit-test-output-" + details.testId ); + if ( testBlock ) { + testBlock.className = "running"; + } else { + + // Report later registered tests + appendTest( details.name, details.testId, details.module ); + } + + running = id( "qunit-testresult" ); + if ( running ) { + bad = QUnit.config.reorder && defined.sessionStorage && + +sessionStorage.getItem( "qunit-test-" + details.module + "-" + details.name ); + + running.innerHTML = ( bad ? + "Rerunning previously failed test:
          " : + "Running:
          " ) + + getNameHtml( details.name, details.module ); + } + + }); + + QUnit.log(function( details ) { + var assertList, assertLi, + message, expected, actual, + testItem = id( "qunit-test-output-" + details.testId ); + + if ( !testItem ) { + return; + } + + message = escapeText( details.message ) || ( details.result ? "okay" : "failed" ); + message = "" + message + ""; + message += "@ " + details.runtime + " ms"; + + // 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 += ""; + + if ( actual !== expected ) { + message += "" + + ""; + } else { + if ( expected.indexOf( "[object Array]" ) !== -1 || + expected.indexOf( "[object Object]" ) !== -1 ) { + message += ""; + } + } + + if ( details.source ) { + message += ""; + } + + message += "
          Expected:
          " +
          +                expected +
          +                "
          Result:
          " +
          +                    actual + "
          Diff:
          " +
          +                    QUnit.diff( expected, actual ) + "
          Message: " + + "Diff suppressed as the depth of object is more than current max depth (" + + QUnit.config.maxDepth + ").

          Hint: Use QUnit.dump.maxDepth to " + + " run with a higher max depth or " + + "Rerun without max depth.

          Source:
          " +
          +                    escapeText( details.source ) + "
          "; + + // this occours when pushFailure is set and we have an extracted stack trace + } else if ( !details.result && details.source ) { + message += "" + + "" + + "
          Source:
          " +
          +                escapeText( details.source ) + "
          "; + } + + 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, skipped, + tests = id( "qunit-tests" ); + + if ( !tests ) { + return; + } + + testItem = id( "qunit-test-output-" + details.testId ); + + 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 ? + "" + bad + ", " + "" + good + ", " : + ""; + + testTitle.innerHTML += " (" + testCounts + + details.assertions.length + ")"; + + if ( details.skipped ) { + testItem.className = "skipped"; + skipped = document.createElement( "em" ); + skipped.className = "qunit-skipped-label"; + skipped.innerHTML = "skipped"; + testItem.insertBefore( skipped, testTitle ); + } else { + addEvent( testTitle, "click", function() { + toggleClass( assertList, "qunit-collapsed" ); + }); + + testItem.className = bad ? "fail" : "pass"; + + time = document.createElement( "span" ); + time.className = "runtime"; + time.innerHTML = details.runtime + " ms"; + testItem.insertBefore( time, assertList ); + } + }); + + if ( defined.document ) { + if ( document.readyState === "complete" ) { + QUnit.load(); + } else { + addEvent( window, "load", QUnit.load ); + } + } else { + config.pageLoaded = true; + config.autorun = true; + } + + })(); \ No newline at end of file diff --git a/packages/main/test/qunit/util/sinon-qunit.js b/packages/main/test/qunit/util/sinon-qunit.js new file mode 100644 index 000000000000..281df90c5c7a --- /dev/null +++ b/packages/main/test/qunit/util/sinon-qunit.js @@ -0,0 +1,80 @@ +/** + * sinon-qunit 2.0.0, 2014/05/29 + * + * @author Christian Johansen (christian@cjohansen.no) + * + * (The BSD License) + * + * Copyright (c) 2010-2011, Christian Johansen, christian@cjohansen.no + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of Christian Johansen nor the names of his contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/*global sinon, QUnit, test*/ +sinon.expectation.fail = sinon.assert.fail = function (msg) { + // ##### BEGIN: MODIFIED BY SAP + // use QUnit.assert.ok instead of QUnit.ok + // see https://github.com/cjohansen/sinon-qunit/pull/17 + QUnit.assert.ok(false, msg); + // ##### END: MODIFIED BY SAP +}; + +sinon.assert.pass = function (assertion) { + // ##### BEGIN: MODIFIED BY SAP + // use QUnit.assert.ok instead of QUnit.ok + QUnit.assert.ok(true, assertion); + // ##### END: MODIFIED BY SAP +}; + +sinon.config = { + injectIntoThis: true, + injectInto: null, + properties: ["spy", "stub", "mock", "clock", "sandbox"], + useFakeTimers: false, + useFakeServer: false +}; + +(function (global) { + var qTest = QUnit.test; + + // ##### BEGIN: MODIFIED BY SAP + // QUnit 2.x only supports only signature QUnit.test(message, callback); there are no more 'expected' and 'async' parameters + if ( qTest.length === 2 ) { + QUnit.test = function(testName, callback) { + return qTest(testName, sinon.test(callback)); + }; + } else { + // ##### END: MODIFIED BY SAP + QUnit.test = global.test = function (testName, expected, callback, async) { + if (arguments.length === 2) { + callback = expected; + expected = null; + } + + return qTest(testName, expected, sinon.test(callback), async); + }; + // ##### BEGIN: MODIFIED BY SAP + } + // ##### END: MODIFIED BY SAP +}(this)); \ No newline at end of file diff --git a/packages/main/test/qunit/util/sinon.js b/packages/main/test/qunit/util/sinon.js new file mode 100644 index 000000000000..f3e8cbf1c5dd --- /dev/null +++ b/packages/main/test/qunit/util/sinon.js @@ -0,0 +1,5984 @@ +/** + * Sinon.JS 1.14.1, 2015/03/16 + * + * @author Christian Johansen (christian@cjohansen.no) + * @author Contributors: https://github.com/cjohansen/Sinon.JS/blob/master/AUTHORS + * + * (The BSD License) + * + * Copyright (c) 2010-2014, Christian Johansen, christian@cjohansen.no + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of Christian Johansen nor the names of his contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +(function (root, factory) { + if (typeof define === 'function' && define.amd) { + define('sinon', [], function () { + return (root.sinon = factory()); + }); + } else if (typeof exports === 'object') { + module.exports = factory(); + } else { + root.sinon = factory(); + } + }(this, function () { + var samsam, formatio; + (function () { + function define(mod, deps, fn) { + if (mod == "samsam") { + samsam = deps(); + } else if (typeof deps === "function" && mod.length === 0) { + lolex = deps(); + } else if (typeof fn === "function") { + formatio = fn(samsam); + } + } + define.amd = {}; + ((typeof define === "function" && define.amd && function (m) { define("samsam", m); }) || + (typeof module === "object" && + function (m) { module.exports = m(); }) || // Node + function (m) { this.samsam = m(); } // Browser globals + )(function () { + var o = Object.prototype; + var div = typeof document !== "undefined" && document.createElement("div"); + + function isNaN(value) { + // Unlike global isNaN, this avoids type coercion + // typeof check avoids IE host object issues, hat tip to + // lodash + var val = value; // JsLint thinks value !== value is "weird" + return typeof value === "number" && value !== val; + } + + function getClass(value) { + // Returns the internal [[Class]] by calling Object.prototype.toString + // with the provided value as this. Return value is a string, naming the + // internal class, e.g. "Array" + return o.toString.call(value).split(/[ \]]/)[1]; + } + + /** + * @name samsam.isArguments + * @param Object object + * + * Returns ``true`` if ``object`` is an ``arguments`` object, + * ``false`` otherwise. + */ + function isArguments(object) { + if (getClass(object) === 'Arguments') { return true; } + if (typeof object !== "object" || typeof object.length !== "number" || + getClass(object) === "Array") { + return false; + } + if (typeof object.callee == "function") { return true; } + try { + object[object.length] = 6; + delete object[object.length]; + } catch (e) { + return true; + } + return false; + } + + /** + * @name samsam.isElement + * @param Object object + * + * Returns ``true`` if ``object`` is a DOM element node. Unlike + * Underscore.js/lodash, this function will return ``false`` if ``object`` + * is an *element-like* object, i.e. a regular object with a ``nodeType`` + * property that holds the value ``1``. + */ + function isElement(object) { + if (!object || object.nodeType !== 1 || !div) { return false; } + try { + object.appendChild(div); + object.removeChild(div); + } catch (e) { + return false; + } + return true; + } + + /** + * @name samsam.keys + * @param Object object + * + * Return an array of own property names. + */ + function keys(object) { + var ks = [], prop; + for (prop in object) { + if (o.hasOwnProperty.call(object, prop)) { ks.push(prop); } + } + return ks; + } + + /** + * @name samsam.isDate + * @param Object value + * + * Returns true if the object is a ``Date``, or *date-like*. Duck typing + * of date objects work by checking that the object has a ``getTime`` + * function whose return value equals the return value from the object's + * ``valueOf``. + */ + function isDate(value) { + return typeof value.getTime == "function" && + value.getTime() == value.valueOf(); + } + + /** + * @name samsam.isNegZero + * @param Object value + * + * Returns ``true`` if ``value`` is ``-0``. + */ + function isNegZero(value) { + return value === 0 && 1 / value === -Infinity; + } + + /** + * @name samsam.equal + * @param Object obj1 + * @param Object obj2 + * + * Returns ``true`` if two objects are strictly equal. Compared to + * ``===`` there are two exceptions: + * + * - NaN is considered equal to NaN + * - -0 and +0 are not considered equal + */ + function identical(obj1, obj2) { + if (obj1 === obj2 || (isNaN(obj1) && isNaN(obj2))) { + return obj1 !== 0 || isNegZero(obj1) === isNegZero(obj2); + } + } + + + /** + * @name samsam.deepEqual + * @param Object obj1 + * @param Object obj2 + * + * Deep equal comparison. Two values are "deep equal" if: + * + * - They are equal, according to samsam.identical + * - They are both date objects representing the same time + * - They are both arrays containing elements that are all deepEqual + * - They are objects with the same set of properties, and each property + * in ``obj1`` is deepEqual to the corresponding property in ``obj2`` + * + * Supports cyclic objects. + */ + function deepEqualCyclic(obj1, obj2) { + + // used for cyclic comparison + // contain already visited objects + var objects1 = [], + objects2 = [], + // contain pathes (position in the object structure) + // of the already visited objects + // indexes same as in objects arrays + paths1 = [], + paths2 = [], + // contains combinations of already compared objects + // in the manner: { "$1['ref']$2['ref']": true } + compared = {}; + + /** + * used to check, if the value of a property is an object + * (cyclic logic is only needed for objects) + * only needed for cyclic logic + */ + function isObject(value) { + + if (typeof value === 'object' && value !== null && + !(value instanceof Boolean) && + !(value instanceof Date) && + !(value instanceof Number) && + !(value instanceof RegExp) && + !(value instanceof String)) { + + return true; + } + + return false; + } + + /** + * returns the index of the given object in the + * given objects array, -1 if not contained + * only needed for cyclic logic + */ + function getIndex(objects, obj) { + + var i; + for (i = 0; i < objects.length; i++) { + if (objects[i] === obj) { + return i; + } + } + + return -1; + } + + // does the recursion for the deep equal check + return (function deepEqual(obj1, obj2, path1, path2) { + var type1 = typeof obj1; + var type2 = typeof obj2; + + // == null also matches undefined + if (obj1 === obj2 || + isNaN(obj1) || isNaN(obj2) || + obj1 == null || obj2 == null || + type1 !== "object" || type2 !== "object") { + + return identical(obj1, obj2); + } + + // Elements are only equal if identical(expected, actual) + if (isElement(obj1) || isElement(obj2)) { return false; } + + var isDate1 = isDate(obj1), isDate2 = isDate(obj2); + if (isDate1 || isDate2) { + if (!isDate1 || !isDate2 || obj1.getTime() !== obj2.getTime()) { + return false; + } + } + + if (obj1 instanceof RegExp && obj2 instanceof RegExp) { + if (obj1.toString() !== obj2.toString()) { return false; } + } + + var class1 = getClass(obj1); + var class2 = getClass(obj2); + var keys1 = keys(obj1); + var keys2 = keys(obj2); + + if (isArguments(obj1) || isArguments(obj2)) { + if (obj1.length !== obj2.length) { return false; } + } else { + if (type1 !== type2 || class1 !== class2 || + keys1.length !== keys2.length) { + return false; + } + } + + var key, i, l, + // following vars are used for the cyclic logic + value1, value2, + isObject1, isObject2, + index1, index2, + newPath1, newPath2; + + for (i = 0, l = keys1.length; i < l; i++) { + key = keys1[i]; + if (!o.hasOwnProperty.call(obj2, key)) { + return false; + } + + // Start of the cyclic logic + + value1 = obj1[key]; + value2 = obj2[key]; + + isObject1 = isObject(value1); + isObject2 = isObject(value2); + + // determine, if the objects were already visited + // (it's faster to check for isObject first, than to + // get -1 from getIndex for non objects) + index1 = isObject1 ? getIndex(objects1, value1) : -1; + index2 = isObject2 ? getIndex(objects2, value2) : -1; + + // determine the new pathes of the objects + // - for non cyclic objects the current path will be extended + // by current property name + // - for cyclic objects the stored path is taken + newPath1 = index1 !== -1 + ? paths1[index1] + : path1 + '[' + JSON.stringify(key) + ']'; + newPath2 = index2 !== -1 + ? paths2[index2] + : path2 + '[' + JSON.stringify(key) + ']'; + + // stop recursion if current objects are already compared + if (compared[newPath1 + newPath2]) { + return true; + } + + // remember the current objects and their pathes + if (index1 === -1 && isObject1) { + objects1.push(value1); + paths1.push(newPath1); + } + if (index2 === -1 && isObject2) { + objects2.push(value2); + paths2.push(newPath2); + } + + // remember that the current objects are already compared + if (isObject1 && isObject2) { + compared[newPath1 + newPath2] = true; + } + + // End of cyclic logic + + // neither value1 nor value2 is a cycle + // continue with next level + if (!deepEqual(value1, value2, newPath1, newPath2)) { + return false; + } + } + + return true; + + }(obj1, obj2, '$1', '$2')); + } + + var match; + + function arrayContains(array, subset) { + if (subset.length === 0) { return true; } + var i, l, j, k; + for (i = 0, l = array.length; i < l; ++i) { + if (match(array[i], subset[0])) { + for (j = 0, k = subset.length; j < k; ++j) { + if (!match(array[i + j], subset[j])) { return false; } + } + return true; + } + } + return false; + } + + /** + * @name samsam.match + * @param Object object + * @param Object matcher + * + * Compare arbitrary value ``object`` with matcher. + */ + match = function match(object, matcher) { + if (matcher && typeof matcher.test === "function") { + return matcher.test(object); + } + + if (typeof matcher === "function") { + return matcher(object) === true; + } + + if (typeof matcher === "string") { + matcher = matcher.toLowerCase(); + var notNull = typeof object === "string" || !!object; + return notNull && + (String(object)).toLowerCase().indexOf(matcher) >= 0; + } + + if (typeof matcher === "number") { + return matcher === object; + } + + if (typeof matcher === "boolean") { + return matcher === object; + } + + if (typeof(matcher) === "undefined") { + return typeof(object) === "undefined"; + } + + if (matcher === null) { + return object === null; + } + + if (getClass(object) === "Array" && getClass(matcher) === "Array") { + return arrayContains(object, matcher); + } + + if (matcher && typeof matcher === "object") { + if (matcher === object) { + return true; + } + var prop; + for (prop in matcher) { + var value = object[prop]; + if (typeof value === "undefined" && + typeof object.getAttribute === "function") { + value = object.getAttribute(prop); + } + if (matcher[prop] === null || typeof matcher[prop] === 'undefined') { + if (value !== matcher[prop]) { + return false; + } + } else if (typeof value === "undefined" || !match(value, matcher[prop])) { + return false; + } + } + return true; + } + + throw new Error("Matcher was not a string, a number, a " + + "function, a boolean or an object"); + }; + + return { + isArguments: isArguments, + isElement: isElement, + isDate: isDate, + isNegZero: isNegZero, + identical: identical, + deepEqual: deepEqualCyclic, + match: match, + keys: keys + }; + }); + ((typeof define === "function" && define.amd && function (m) { + define("formatio", ["samsam"], m); + }) || (typeof module === "object" && function (m) { + module.exports = m(require("samsam")); + }) || function (m) { this.formatio = m(this.samsam); } + )(function (samsam) { + + var formatio = { + excludeConstructors: ["Object", /^.$/], + quoteStrings: true, + limitChildrenCount: 0 + }; + + var hasOwn = Object.prototype.hasOwnProperty; + + var specialObjects = []; + if (typeof global !== "undefined") { + specialObjects.push({ object: global, value: "[object global]" }); + } + if (typeof document !== "undefined") { + specialObjects.push({ + object: document, + value: "[object HTMLDocument]" + }); + } + if (typeof window !== "undefined") { + specialObjects.push({ object: window, value: "[object Window]" }); + } + + function functionName(func) { + if (!func) { return ""; } + if (func.displayName) { return func.displayName; } + if (func.name) { return func.name; } + var matches = func.toString().match(/function\s+([^\(]+)/m); + return (matches && matches[1]) || ""; + } + + function constructorName(f, object) { + var name = functionName(object && object.constructor); + var excludes = f.excludeConstructors || + formatio.excludeConstructors || []; + + var i, l; + for (i = 0, l = excludes.length; i < l; ++i) { + if (typeof excludes[i] === "string" && excludes[i] === name) { + return ""; + } else if (excludes[i].test && excludes[i].test(name)) { + return ""; + } + } + + return name; + } + + function isCircular(object, objects) { + if (typeof object !== "object") { return false; } + var i, l; + for (i = 0, l = objects.length; i < l; ++i) { + if (objects[i] === object) { return true; } + } + return false; + } + + function ascii(f, object, processed, indent) { + if (typeof object === "string") { + var qs = f.quoteStrings; + var quote = typeof qs !== "boolean" || qs; + return processed || quote ? '"' + object + '"' : object; + } + + if (typeof object === "function" && !(object instanceof RegExp)) { + return ascii.func(object); + } + + processed = processed || []; + + if (isCircular(object, processed)) { return "[Circular]"; } + + if (Object.prototype.toString.call(object) === "[object Array]") { + return ascii.array.call(f, object, processed); + } + + if (!object) { return String((1/object) === -Infinity ? "-0" : object); } + if (samsam.isElement(object)) { return ascii.element(object); } + + if (typeof object.toString === "function" && + object.toString !== Object.prototype.toString) { + return object.toString(); + } + + var i, l; + for (i = 0, l = specialObjects.length; i < l; i++) { + if (object === specialObjects[i].object) { + return specialObjects[i].value; + } + } + + return ascii.object.call(f, object, processed, indent); + } + + ascii.func = function (func) { + return "function " + functionName(func) + "() {}"; + }; + + ascii.array = function (array, processed) { + processed = processed || []; + processed.push(array); + var pieces = []; + var i, l; + l = (this.limitChildrenCount > 0) ? + Math.min(this.limitChildrenCount, array.length) : array.length; + + for (i = 0; i < l; ++i) { + pieces.push(ascii(this, array[i], processed)); + } + + if(l < array.length) + pieces.push("[... " + (array.length - l) + " more elements]"); + + return "[" + pieces.join(", ") + "]"; + }; + + ascii.object = function (object, processed, indent) { + processed = processed || []; + processed.push(object); + indent = indent || 0; + var pieces = [], properties = samsam.keys(object).sort(); + var length = 3; + var prop, str, obj, i, k, l; + l = (this.limitChildrenCount > 0) ? + Math.min(this.limitChildrenCount, properties.length) : properties.length; + + for (i = 0; i < l; ++i) { + prop = properties[i]; + obj = object[prop]; + + if (isCircular(obj, processed)) { + str = "[Circular]"; + } else { + str = ascii(this, obj, processed, indent + 2); + } + + str = (/\s/.test(prop) ? '"' + prop + '"' : prop) + ": " + str; + length += str.length; + pieces.push(str); + } + + var cons = constructorName(this, object); + var prefix = cons ? "[" + cons + "] " : ""; + var is = ""; + for (i = 0, k = indent; i < k; ++i) { is += " "; } + + if(l < properties.length) + pieces.push("[... " + (properties.length - l) + " more elements]"); + + if (length + indent > 80) { + return prefix + "{\n " + is + pieces.join(",\n " + is) + "\n" + + is + "}"; + } + return prefix + "{ " + pieces.join(", ") + " }"; + }; + + ascii.element = function (element) { + var tagName = element.tagName.toLowerCase(); + var attrs = element.attributes, attr, pairs = [], attrName, i, l, val; + + for (i = 0, l = attrs.length; i < l; ++i) { + attr = attrs.item(i); + attrName = attr.nodeName.toLowerCase().replace("html:", ""); + val = attr.nodeValue; + if (attrName !== "contenteditable" || val !== "inherit") { + if (!!val) { pairs.push(attrName + "=\"" + val + "\""); } + } + } + + var formatted = "<" + tagName + (pairs.length > 0 ? " " : ""); + var content = element.innerHTML; + + if (content.length > 20) { + content = content.substr(0, 20) + "[...]"; + } + + var res = formatted + pairs.join(" ") + ">" + content + + ""; + + return res.replace(/ contentEditable="inherit"/, ""); + }; + + function Formatio(options) { + for (var opt in options) { + this[opt] = options[opt]; + } + } + + Formatio.prototype = { + functionName: functionName, + + configure: function (options) { + return new Formatio(options); + }, + + constructorName: function (object) { + return constructorName(this, object); + }, + + ascii: function (object, processed, indent) { + return ascii(this, object, processed, indent); + } + }; + + return Formatio.prototype; + }); + !function(e){if("object"==typeof exports&&"undefined"!=typeof module)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.lolex=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);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 3 || !/^(\d\d:){0,2}\d\d?$/.test(str)) { + throw new Error("tick only understands numbers and 'h:m:s'"); + } + + while (i--) { + parsed = parseInt(strings[i], 10); + + if (parsed >= 60) { + throw new Error("Invalid time " + str); + } + + ms += parsed * Math.pow(60, (l - i - 1)); + } + + return ms * 1000; + } + + /** + * Used to grok the `now` parameter to createClock. + */ + function getEpoch(epoch) { + if (!epoch) { return 0; } + if (typeof epoch.getTime === "function") { return epoch.getTime(); } + if (typeof epoch === "number") { return epoch; } + throw new TypeError("now should be milliseconds since UNIX epoch"); + } + + function inRange(from, to, timer) { + return timer && timer.callAt >= from && timer.callAt <= to; + } + + function mirrorDateProperties(target, source) { + if (source.now) { + target.now = function now() { + return target.clock.now; + }; + } else { + delete target.now; + } + + if (source.toSource) { + target.toSource = function toSource() { + return source.toSource(); + }; + } else { + delete target.toSource; + } + + target.toString = function toString() { + return source.toString(); + }; + + target.prototype = source.prototype; + target.parse = source.parse; + target.UTC = source.UTC; + target.prototype.toUTCString = source.prototype.toUTCString; + + for (var prop in source) { + if (source.hasOwnProperty(prop)) { + target[prop] = source[prop]; + } + } + + return target; + } + + function createDate() { + function ClockDate(year, month, date, hour, minute, second, ms) { + // Defensive and verbose to avoid potential harm in passing + // explicit undefined when user does not pass argument + switch (arguments.length) { + case 0: + return new NativeDate(ClockDate.clock.now); + case 1: + return new NativeDate(year); + case 2: + return new NativeDate(year, month); + case 3: + return new NativeDate(year, month, date); + case 4: + return new NativeDate(year, month, date, hour); + case 5: + return new NativeDate(year, month, date, hour, minute); + case 6: + return new NativeDate(year, month, date, hour, minute, second); + default: + return new NativeDate(year, month, date, hour, minute, second, ms); + } + } + + return mirrorDateProperties(ClockDate, NativeDate); + } + + function addTimer(clock, timer) { + if (typeof timer.func === "undefined") { + throw new Error("Callback must be provided to timer calls"); + } + + if (!clock.timers) { + clock.timers = {}; + } + + timer.id = id++; + timer.createdAt = clock.now; + timer.callAt = clock.now + (timer.delay || 0); + + clock.timers[timer.id] = timer; + + if (addTimerReturnsObject) { + return { + id: timer.id, + ref: function() {}, + unref: function() {} + }; + } + else { + return timer.id; + } + } + + function firstTimerInRange(clock, from, to) { + var timers = clock.timers, timer = null; + + for (var id in timers) { + if (!inRange(from, to, timers[id])) { + continue; + } + + if (!timer || ~compareTimers(timer, timers[id])) { + timer = timers[id]; + } + } + + return timer; + } + + function compareTimers(a, b) { + // Sort first by absolute timing + if (a.callAt < b.callAt) { + return -1; + } + if (a.callAt > b.callAt) { + return 1; + } + + // Sort next by immediate, immediate timers take precedence + if (a.immediate && !b.immediate) { + return -1; + } + if (!a.immediate && b.immediate) { + return 1; + } + + // Sort next by creation time, earlier-created timers take precedence + if (a.createdAt < b.createdAt) { + return -1; + } + if (a.createdAt > b.createdAt) { + return 1; + } + + // Sort next by id, lower-id timers take precedence + if (a.id < b.id) { + return -1; + } + if (a.id > b.id) { + return 1; + } + + // As timer ids are unique, no fallback `0` is necessary + } + + function callTimer(clock, timer) { + if (typeof timer.interval == "number") { + clock.timers[timer.id].callAt += timer.interval; + } else { + delete clock.timers[timer.id]; + } + + try { + if (typeof timer.func == "function") { + timer.func.apply(null, timer.args); + } else { + eval(timer.func); + } + } catch (e) { + var exception = e; + } + + if (!clock.timers[timer.id]) { + if (exception) { + throw exception; + } + return; + } + + if (exception) { + throw exception; + } + } + + function uninstall(clock, target) { + var method; + + for (var i = 0, l = clock.methods.length; i < l; i++) { + method = clock.methods[i]; + + if (target[method].hadOwnProperty) { + target[method] = clock["_" + method]; + } else { + try { + delete target[method]; + } catch (e) {} + } + } + + // Prevent multiple executions which will completely remove these props + clock.methods = []; + } + + function hijackMethod(target, method, clock) { + clock[method].hadOwnProperty = Object.prototype.hasOwnProperty.call(target, method); + clock["_" + method] = target[method]; + + if (method == "Date") { + var date = mirrorDateProperties(clock[method], target[method]); + target[method] = date; + } else { + target[method] = function () { + return clock[method].apply(clock, arguments); + }; + + for (var prop in clock[method]) { + if (clock[method].hasOwnProperty(prop)) { + target[method][prop] = clock[method][prop]; + } + } + } + + target[method].clock = clock; + } + + var timers = { + setTimeout: setTimeout, + clearTimeout: clearTimeout, + setImmediate: (typeof setImmediate !== "undefined" ? setImmediate : undefined), + clearImmediate: (typeof clearImmediate !== "undefined" ? clearImmediate: undefined), + setInterval: setInterval, + clearInterval: clearInterval, + Date: Date + }; + + var keys = Object.keys || function (obj) { + var ks = []; + for (var key in obj) { + ks.push(key); + } + return ks; + }; + + exports.timers = timers; + + var createClock = exports.createClock = function (now) { + var clock = { + now: getEpoch(now), + timeouts: {}, + Date: createDate() + }; + + clock.Date.clock = clock; + + clock.setTimeout = function setTimeout(func, timeout) { + return addTimer(clock, { + func: func, + args: Array.prototype.slice.call(arguments, 2), + delay: timeout + }); + }; + + clock.clearTimeout = function clearTimeout(timerId) { + if (!timerId) { + // null appears to be allowed in most browsers, and appears to be + // relied upon by some libraries, like Bootstrap carousel + return; + } + if (!clock.timers) { + clock.timers = []; + } + // in Node, timerId is an object with .ref()/.unref(), and + // its .id field is the actual timer id. + if (typeof timerId === "object") { + timerId = timerId.id + } + if (timerId in clock.timers) { + delete clock.timers[timerId]; + } + }; + + clock.setInterval = function setInterval(func, timeout) { + return addTimer(clock, { + func: func, + args: Array.prototype.slice.call(arguments, 2), + delay: timeout, + interval: timeout + }); + }; + + clock.clearInterval = function clearInterval(timerId) { + clock.clearTimeout(timerId); + }; + + clock.setImmediate = function setImmediate(func) { + return addTimer(clock, { + func: func, + args: Array.prototype.slice.call(arguments, 1), + immediate: true + }); + }; + + clock.clearImmediate = function clearImmediate(timerId) { + clock.clearTimeout(timerId); + }; + + clock.tick = function tick(ms) { + ms = typeof ms == "number" ? ms : parseTime(ms); + var tickFrom = clock.now, tickTo = clock.now + ms, previous = clock.now; + var timer = firstTimerInRange(clock, tickFrom, tickTo); + + var firstException; + while (timer && tickFrom <= tickTo) { + if (clock.timers[timer.id]) { + tickFrom = clock.now = timer.callAt; + try { + callTimer(clock, timer); + } catch (e) { + firstException = firstException || e; + } + } + + timer = firstTimerInRange(clock, previous, tickTo); + previous = tickFrom; + } + + clock.now = tickTo; + + if (firstException) { + throw firstException; + } + + return clock.now; + }; + + clock.reset = function reset() { + clock.timers = {}; + }; + + return clock; + }; + + exports.install = function install(target, now, toFake) { + if (typeof target === "number") { + toFake = now; + now = target; + target = null; + } + + if (!target) { + target = global; + } + + var clock = createClock(now); + + clock.uninstall = function () { + uninstall(clock, target); + }; + + clock.methods = toFake || []; + + if (clock.methods.length === 0) { + clock.methods = keys(timers); + } + + for (var i = 0, l = clock.methods.length; i < l; i++) { + hijackMethod(target, clock.methods[i], clock); + } + + return clock; + }; + + }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) + },{}]},{},[1])(1) + }); + })(); + var define; + /** + * Sinon core utilities. For internal use only. + * + * @author Christian Johansen (christian@cjohansen.no) + * @license BSD + * + * Copyright (c) 2010-2013 Christian Johansen + */ + + var sinon = (function () { + "use strict"; + + var sinon; + var isNode = typeof module !== "undefined" && module.exports && typeof require === "function"; + var isAMD = typeof define === "function" && typeof define.amd === "object" && define.amd; + + function loadDependencies(require, exports, module) { + sinon = module.exports = require("./sinon/util/core"); + require("./sinon/extend"); + require("./sinon/typeOf"); + require("./sinon/times_in_words"); + require("./sinon/spy"); + require("./sinon/call"); + require("./sinon/behavior"); + require("./sinon/stub"); + require("./sinon/mock"); + require("./sinon/collection"); + require("./sinon/assert"); + require("./sinon/sandbox"); + require("./sinon/test"); + require("./sinon/test_case"); + require("./sinon/match"); + require("./sinon/format"); + require("./sinon/log_error"); + } + + if (isAMD) { + define(loadDependencies); + } else if (isNode) { + loadDependencies(require, module.exports, module); + sinon = module.exports; + } else { + sinon = {}; + } + + return sinon; + }()); + + /** + * @depend ../../sinon.js + */ + /** + * Sinon core utilities. For internal use only. + * + * @author Christian Johansen (christian@cjohansen.no) + * @license BSD + * + * Copyright (c) 2010-2013 Christian Johansen + */ + + (function (sinon) { + var div = typeof document != "undefined" && document.createElement("div"); + var hasOwn = Object.prototype.hasOwnProperty; + + function isDOMNode(obj) { + var success = false; + + try { + obj.appendChild(div); + success = div.parentNode == obj; + } catch (e) { + return false; + } finally { + try { + obj.removeChild(div); + } catch (e) { + // Remove failed, not much we can do about that + } + } + + return success; + } + + function isElement(obj) { + return div && obj && obj.nodeType === 1 && isDOMNode(obj); + } + + function isFunction(obj) { + return typeof obj === "function" || !!(obj && obj.constructor && obj.call && obj.apply); + } + + function isReallyNaN(val) { + return typeof val === "number" && isNaN(val); + } + + function mirrorProperties(target, source) { + for (var prop in source) { + if (!hasOwn.call(target, prop)) { + target[prop] = source[prop]; + } + } + } + + function isRestorable(obj) { + return typeof obj === "function" && typeof obj.restore === "function" && obj.restore.sinon; + } + + // Cheap way to detect if we have ES5 support. + var hasES5Support = "keys" in Object; + + function makeApi(sinon) { + sinon.wrapMethod = function wrapMethod(object, property, method) { + if (!object) { + throw new TypeError("Should wrap property of object"); + } + + if (typeof method != "function" && typeof method != "object") { + throw new TypeError("Method wrapper should be a function or a property descriptor"); + } + + function checkWrappedMethod(wrappedMethod) { + if (!isFunction(wrappedMethod)) { + error = new TypeError("Attempted to wrap " + (typeof wrappedMethod) + " property " + + property + " as function"); + } else if (wrappedMethod.restore && wrappedMethod.restore.sinon) { + error = new TypeError("Attempted to wrap " + property + " which is already wrapped"); + } else if (wrappedMethod.calledBefore) { + var verb = !!wrappedMethod.returns ? "stubbed" : "spied on"; + error = new TypeError("Attempted to wrap " + property + " which is already " + verb); + } + + if (error) { + if (wrappedMethod && wrappedMethod.stackTrace) { + error.stack += "\n--------------\n" + wrappedMethod.stackTrace; + } + throw error; + } + } + + var error, wrappedMethod; + + // IE 8 does not support hasOwnProperty on the window object and Firefox has a problem + // when using hasOwn.call on objects from other frames. + var owned = object.hasOwnProperty ? object.hasOwnProperty(property) : hasOwn.call(object, property); + + if (hasES5Support) { + var methodDesc = (typeof method == "function") ? {value: method} : method, + wrappedMethodDesc = sinon.getPropertyDescriptor(object, property), + i; + + if (!wrappedMethodDesc) { + error = new TypeError("Attempted to wrap " + (typeof wrappedMethod) + " property " + + property + " as function"); + } else if (wrappedMethodDesc.restore && wrappedMethodDesc.restore.sinon) { + error = new TypeError("Attempted to wrap " + property + " which is already wrapped"); + } + if (error) { + if (wrappedMethodDesc && wrappedMethodDesc.stackTrace) { + error.stack += "\n--------------\n" + wrappedMethodDesc.stackTrace; + } + throw error; + } + + var types = sinon.objectKeys(methodDesc); + for (i = 0; i < types.length; i++) { + wrappedMethod = wrappedMethodDesc[types[i]]; + checkWrappedMethod(wrappedMethod); + } + + mirrorProperties(methodDesc, wrappedMethodDesc); + for (i = 0; i < types.length; i++) { + mirrorProperties(methodDesc[types[i]], wrappedMethodDesc[types[i]]); + } + Object.defineProperty(object, property, methodDesc); + } else { + wrappedMethod = object[property]; + checkWrappedMethod(wrappedMethod); + object[property] = method; + method.displayName = property; + } + + method.displayName = property; + + // Set up a stack trace which can be used later to find what line of + // code the original method was created on. + method.stackTrace = (new Error("Stack Trace for original")).stack; + + method.restore = function () { + // For prototype properties try to reset by delete first. + // If this fails (ex: localStorage on mobile safari) then force a reset + // via direct assignment. + if (!owned) { + try { + delete object[property]; + } catch (e) {} + // For native code functions `delete` fails without throwing an error + // on Chrome < 43, PhantomJS, etc. + // Use strict equality comparison to check failures then force a reset + // via direct assignment. + if (object[property] === method) { + object[property] = wrappedMethod; + } + } else if (hasES5Support) { + Object.defineProperty(object, property, wrappedMethodDesc); + } + + if (!hasES5Support && object[property] === method) { + object[property] = wrappedMethod; + } + }; + + method.restore.sinon = true; + + if (!hasES5Support) { + mirrorProperties(method, wrappedMethod); + } + + return method; + }; + + sinon.create = function create(proto) { + var F = function () {}; + F.prototype = proto; + return new F(); + }; + + sinon.deepEqual = function deepEqual(a, b) { + if (sinon.match && sinon.match.isMatcher(a)) { + return a.test(b); + } + + if (typeof a != "object" || typeof b != "object") { + if (isReallyNaN(a) && isReallyNaN(b)) { + return true; + } else { + return a === b; + } + } + + if (isElement(a) || isElement(b)) { + return a === b; + } + + if (a === b) { + return true; + } + + if ((a === null && b !== null) || (a !== null && b === null)) { + return false; + } + + if (a instanceof RegExp && b instanceof RegExp) { + return (a.source === b.source) && (a.global === b.global) && + (a.ignoreCase === b.ignoreCase) && (a.multiline === b.multiline); + } + + var aString = Object.prototype.toString.call(a); + if (aString != Object.prototype.toString.call(b)) { + return false; + } + + if (aString == "[object Date]") { + return a.valueOf() === b.valueOf(); + } + + var prop, aLength = 0, bLength = 0; + + if (aString == "[object Array]" && a.length !== b.length) { + return false; + } + + for (prop in a) { + aLength += 1; + + if (!(prop in b)) { + return false; + } + + if (!deepEqual(a[prop], b[prop])) { + return false; + } + } + + for (prop in b) { + bLength += 1; + } + + return aLength == bLength; + }; + + sinon.functionName = function functionName(func) { + var name = func.displayName || func.name; + + // Use function decomposition as a last resort to get function + // name. Does not rely on function decomposition to work - if it + // doesn't debugging will be slightly less informative + // (i.e. toString will say 'spy' rather than 'myFunc'). + if (!name) { + var matches = func.toString().match(/function ([^\s\(]+)/); + name = matches && matches[1]; + } + + return name; + }; + + sinon.functionToString = function toString() { + if (this.getCall && this.callCount) { + var thisValue, prop, i = this.callCount; + + while (i--) { + thisValue = this.getCall(i).thisValue; + + for (prop in thisValue) { + if (thisValue[prop] === this) { + return prop; + } + } + } + } + + return this.displayName || "sinon fake"; + }; + + sinon.objectKeys = function objectKeys(obj) { + if (obj !== Object(obj)) { + throw new TypeError("sinon.objectKeys called on a non-object"); + } + + var keys = []; + var key; + for (key in obj) { + if (hasOwn.call(obj, key)) { + keys.push(key); + } + } + + return keys; + }; + + sinon.getPropertyDescriptor = function getPropertyDescriptor(object, property) { + var proto = object, descriptor; + while (proto && !(descriptor = Object.getOwnPropertyDescriptor(proto, property))) { + proto = Object.getPrototypeOf(proto); + } + return descriptor; + } + + sinon.getConfig = function (custom) { + var config = {}; + custom = custom || {}; + var defaults = sinon.defaultConfig; + + for (var prop in defaults) { + if (defaults.hasOwnProperty(prop)) { + config[prop] = custom.hasOwnProperty(prop) ? custom[prop] : defaults[prop]; + } + } + + return config; + }; + + sinon.defaultConfig = { + injectIntoThis: true, + injectInto: null, + properties: ["spy", "stub", "mock", "clock", "server", "requests"], + useFakeTimers: true, + useFakeServer: true + }; + + sinon.timesInWords = function timesInWords(count) { + return count == 1 && "once" || + count == 2 && "twice" || + count == 3 && "thrice" || + (count || 0) + " times"; + }; + + sinon.calledInOrder = function (spies) { + for (var i = 1, l = spies.length; i < l; i++) { + if (!spies[i - 1].calledBefore(spies[i]) || !spies[i].called) { + return false; + } + } + + return true; + }; + + sinon.orderByFirstCall = function (spies) { + return spies.sort(function (a, b) { + // uuid, won't ever be equal + var aCall = a.getCall(0); + var bCall = b.getCall(0); + var aId = aCall && aCall.callId || -1; + var bId = bCall && bCall.callId || -1; + + return aId < bId ? -1 : 1; + }); + }; + + sinon.createStubInstance = function (constructor) { + if (typeof constructor !== "function") { + throw new TypeError("The constructor should be a function."); + } + return sinon.stub(sinon.create(constructor.prototype)); + }; + + sinon.restore = function (object) { + if (object !== null && typeof object === "object") { + for (var prop in object) { + if (isRestorable(object[prop])) { + object[prop].restore(); + } + } + } else if (isRestorable(object)) { + object.restore(); + } + }; + + return sinon; + } + + var isNode = typeof module !== "undefined" && module.exports && typeof require == "function"; + var isAMD = typeof define === "function" && typeof define.amd === "object" && define.amd; + + function loadDependencies(require, exports) { + makeApi(exports); + } + + if (isAMD) { + define(loadDependencies); + } else if (isNode) { + loadDependencies(require, module.exports); + } else if (!sinon) { + return; + } else { + makeApi(sinon); + } + }(typeof sinon == "object" && sinon || null)); + + /** + * @depend util/core.js + */ + + (function (sinon) { + function makeApi(sinon) { + + // Adapted from https://developer.mozilla.org/en/docs/ECMAScript_DontEnum_attribute#JScript_DontEnum_Bug + var hasDontEnumBug = (function () { + var obj = { + constructor: function () { + return "0"; + }, + toString: function () { + return "1"; + }, + valueOf: function () { + return "2"; + }, + toLocaleString: function () { + return "3"; + }, + prototype: function () { + return "4"; + }, + isPrototypeOf: function () { + return "5"; + }, + propertyIsEnumerable: function () { + return "6"; + }, + hasOwnProperty: function () { + return "7"; + }, + length: function () { + return "8"; + }, + unique: function () { + return "9" + } + }; + + var result = []; + for (var prop in obj) { + result.push(obj[prop]()); + } + return result.join("") !== "0123456789"; + })(); + + /* Public: Extend target in place with all (own) properties from sources in-order. Thus, last source will + * override properties in previous sources. + * + * target - The Object to extend + * sources - Objects to copy properties from. + * + * Returns the extended target + */ + function extend(target /*, sources */) { + var sources = Array.prototype.slice.call(arguments, 1), + source, i, prop; + + for (i = 0; i < sources.length; i++) { + source = sources[i]; + + for (prop in source) { + if (source.hasOwnProperty(prop)) { + target[prop] = source[prop]; + } + } + + // Make sure we copy (own) toString method even when in JScript with DontEnum bug + // See https://developer.mozilla.org/en/docs/ECMAScript_DontEnum_attribute#JScript_DontEnum_Bug + if (hasDontEnumBug && source.hasOwnProperty("toString") && source.toString !== target.toString) { + target.toString = source.toString; + } + } + + return target; + }; + + sinon.extend = extend; + return sinon.extend; + } + + function loadDependencies(require, exports, module) { + var sinon = require("./util/core"); + module.exports = makeApi(sinon); + } + + var isNode = typeof module !== "undefined" && module.exports && typeof require == "function"; + var isAMD = typeof define === "function" && typeof define.amd === "object" && define.amd; + + if (isAMD) { + define(loadDependencies); + } else if (isNode) { + loadDependencies(require, module.exports, module); + } else if (!sinon) { + return; + } else { + makeApi(sinon); + } + }(typeof sinon == "object" && sinon || null)); + + /** + * @depend util/core.js + */ + + (function (sinon) { + function makeApi(sinon) { + + function timesInWords(count) { + switch (count) { + case 1: + return "once"; + case 2: + return "twice"; + case 3: + return "thrice"; + default: + return (count || 0) + " times"; + } + } + + sinon.timesInWords = timesInWords; + return sinon.timesInWords; + } + + function loadDependencies(require, exports, module) { + var sinon = require("./util/core"); + module.exports = makeApi(sinon); + } + + var isNode = typeof module !== "undefined" && module.exports && typeof require == "function"; + var isAMD = typeof define === "function" && typeof define.amd === "object" && define.amd; + + if (isAMD) { + define(loadDependencies); + } else if (isNode) { + loadDependencies(require, module.exports, module); + } else if (!sinon) { + return; + } else { + makeApi(sinon); + } + }(typeof sinon == "object" && sinon || null)); + + /** + * @depend util/core.js + */ + /** + * Format functions + * + * @author Christian Johansen (christian@cjohansen.no) + * @license BSD + * + * Copyright (c) 2010-2014 Christian Johansen + */ + + (function (sinon, formatio) { + function makeApi(sinon) { + function typeOf(value) { + if (value === null) { + return "null"; + } else if (value === undefined) { + return "undefined"; + } + var string = Object.prototype.toString.call(value); + return string.substring(8, string.length - 1).toLowerCase(); + }; + + sinon.typeOf = typeOf; + return sinon.typeOf; + } + + function loadDependencies(require, exports, module) { + var sinon = require("./util/core"); + module.exports = makeApi(sinon); + } + + var isNode = typeof module !== "undefined" && module.exports && typeof require == "function"; + var isAMD = typeof define === "function" && typeof define.amd === "object" && define.amd; + + if (isAMD) { + define(loadDependencies); + } else if (isNode) { + loadDependencies(require, module.exports, module); + } else if (!sinon) { + return; + } else { + makeApi(sinon); + } + }( + (typeof sinon == "object" && sinon || null), + (typeof formatio == "object" && formatio) + )); + + /** + * @depend util/core.js + * @depend typeOf.js + */ + /*jslint eqeqeq: false, onevar: false, plusplus: false*/ + /*global module, require, sinon*/ + /** + * Match functions + * + * @author Maximilian Antoni (mail@maxantoni.de) + * @license BSD + * + * Copyright (c) 2012 Maximilian Antoni + */ + + (function (sinon) { + function makeApi(sinon) { + function assertType(value, type, name) { + var actual = sinon.typeOf(value); + if (actual !== type) { + throw new TypeError("Expected type of " + name + " to be " + + type + ", but was " + actual); + } + } + + var matcher = { + toString: function () { + return this.message; + } + }; + + function isMatcher(object) { + return matcher.isPrototypeOf(object); + } + + function matchObject(expectation, actual) { + if (actual === null || actual === undefined) { + return false; + } + for (var key in expectation) { + if (expectation.hasOwnProperty(key)) { + var exp = expectation[key]; + var act = actual[key]; + if (match.isMatcher(exp)) { + if (!exp.test(act)) { + return false; + } + } else if (sinon.typeOf(exp) === "object") { + if (!matchObject(exp, act)) { + return false; + } + } else if (!sinon.deepEqual(exp, act)) { + return false; + } + } + } + return true; + } + + matcher.or = function (m2) { + if (!arguments.length) { + throw new TypeError("Matcher expected"); + } else if (!isMatcher(m2)) { + m2 = match(m2); + } + var m1 = this; + var or = sinon.create(matcher); + or.test = function (actual) { + return m1.test(actual) || m2.test(actual); + }; + or.message = m1.message + ".or(" + m2.message + ")"; + return or; + }; + + matcher.and = function (m2) { + if (!arguments.length) { + throw new TypeError("Matcher expected"); + } else if (!isMatcher(m2)) { + m2 = match(m2); + } + var m1 = this; + var and = sinon.create(matcher); + and.test = function (actual) { + return m1.test(actual) && m2.test(actual); + }; + and.message = m1.message + ".and(" + m2.message + ")"; + return and; + }; + + var match = function (expectation, message) { + var m = sinon.create(matcher); + var type = sinon.typeOf(expectation); + switch (type) { + case "object": + if (typeof expectation.test === "function") { + m.test = function (actual) { + return expectation.test(actual) === true; + }; + m.message = "match(" + sinon.functionName(expectation.test) + ")"; + return m; + } + var str = []; + for (var key in expectation) { + if (expectation.hasOwnProperty(key)) { + str.push(key + ": " + expectation[key]); + } + } + m.test = function (actual) { + return matchObject(expectation, actual); + }; + m.message = "match(" + str.join(", ") + ")"; + break; + case "number": + m.test = function (actual) { + return expectation == actual; + }; + break; + case "string": + m.test = function (actual) { + if (typeof actual !== "string") { + return false; + } + return actual.indexOf(expectation) !== -1; + }; + m.message = "match(\"" + expectation + "\")"; + break; + case "regexp": + m.test = function (actual) { + if (typeof actual !== "string") { + return false; + } + return expectation.test(actual); + }; + break; + case "function": + m.test = expectation; + if (message) { + m.message = message; + } else { + m.message = "match(" + sinon.functionName(expectation) + ")"; + } + break; + default: + m.test = function (actual) { + return sinon.deepEqual(expectation, actual); + }; + } + if (!m.message) { + m.message = "match(" + expectation + ")"; + } + return m; + }; + + match.isMatcher = isMatcher; + + match.any = match(function () { + return true; + }, "any"); + + match.defined = match(function (actual) { + return actual !== null && actual !== undefined; + }, "defined"); + + match.truthy = match(function (actual) { + return !!actual; + }, "truthy"); + + match.falsy = match(function (actual) { + return !actual; + }, "falsy"); + + match.same = function (expectation) { + return match(function (actual) { + return expectation === actual; + }, "same(" + expectation + ")"); + }; + + match.typeOf = function (type) { + assertType(type, "string", "type"); + return match(function (actual) { + return sinon.typeOf(actual) === type; + }, "typeOf(\"" + type + "\")"); + }; + + match.instanceOf = function (type) { + assertType(type, "function", "type"); + return match(function (actual) { + return actual instanceof type; + }, "instanceOf(" + sinon.functionName(type) + ")"); + }; + + function createPropertyMatcher(propertyTest, messagePrefix) { + return function (property, value) { + assertType(property, "string", "property"); + var onlyProperty = arguments.length === 1; + var message = messagePrefix + "(\"" + property + "\""; + if (!onlyProperty) { + message += ", " + value; + } + message += ")"; + return match(function (actual) { + if (actual === undefined || actual === null || + !propertyTest(actual, property)) { + return false; + } + return onlyProperty || sinon.deepEqual(value, actual[property]); + }, message); + }; + } + + match.has = createPropertyMatcher(function (actual, property) { + if (typeof actual === "object") { + return property in actual; + } + return actual[property] !== undefined; + }, "has"); + + match.hasOwn = createPropertyMatcher(function (actual, property) { + return actual.hasOwnProperty(property); + }, "hasOwn"); + + match.bool = match.typeOf("boolean"); + match.number = match.typeOf("number"); + match.string = match.typeOf("string"); + match.object = match.typeOf("object"); + match.func = match.typeOf("function"); + match.array = match.typeOf("array"); + match.regexp = match.typeOf("regexp"); + match.date = match.typeOf("date"); + + sinon.match = match; + return match; + } + + var isNode = typeof module !== "undefined" && module.exports && typeof require == "function"; + var isAMD = typeof define === "function" && typeof define.amd === "object" && define.amd; + + function loadDependencies(require, exports, module) { + var sinon = require("./util/core"); + require("./typeOf"); + module.exports = makeApi(sinon); + } + + if (isAMD) { + define(loadDependencies); + } else if (isNode) { + loadDependencies(require, module.exports, module); + } else if (!sinon) { + return; + } else { + makeApi(sinon); + } + }(typeof sinon == "object" && sinon || null)); + + /** + * @depend util/core.js + */ + /** + * Format functions + * + * @author Christian Johansen (christian@cjohansen.no) + * @license BSD + * + * Copyright (c) 2010-2014 Christian Johansen + */ + + (function (sinon, formatio) { + function makeApi(sinon) { + function valueFormatter(value) { + return "" + value; + } + + function getFormatioFormatter() { + var formatter = formatio.configure({ + quoteStrings: false, + limitChildrenCount: 250 + }); + + function format() { + return formatter.ascii.apply(formatter, arguments); + }; + + return format; + } + + function getNodeFormatter(value) { + function format(value) { + return typeof value == "object" && value.toString === Object.prototype.toString ? util.inspect(value) : value; + }; + + try { + var util = require("util"); + } catch (e) { + /* Node, but no util module - would be very old, but better safe than sorry */ + } + + return util ? format : valueFormatter; + } + + var isNode = typeof module !== "undefined" && module.exports && typeof require == "function", + formatter; + + if (isNode) { + try { + formatio = require("formatio"); + } catch (e) {} + } + + if (formatio) { + formatter = getFormatioFormatter() + } else if (isNode) { + formatter = getNodeFormatter(); + } else { + formatter = valueFormatter; + } + + sinon.format = formatter; + return sinon.format; + } + + function loadDependencies(require, exports, module) { + var sinon = require("./util/core"); + module.exports = makeApi(sinon); + } + + var isNode = typeof module !== "undefined" && module.exports && typeof require == "function"; + var isAMD = typeof define === "function" && typeof define.amd === "object" && define.amd; + + if (isAMD) { + define(loadDependencies); + } else if (isNode) { + loadDependencies(require, module.exports, module); + } else if (!sinon) { + return; + } else { + makeApi(sinon); + } + }( + (typeof sinon == "object" && sinon || null), + (typeof formatio == "object" && formatio) + )); + + /** + * @depend util/core.js + * @depend match.js + * @depend format.js + */ + /** + * Spy calls + * + * @author Christian Johansen (christian@cjohansen.no) + * @author Maximilian Antoni (mail@maxantoni.de) + * @license BSD + * + * Copyright (c) 2010-2013 Christian Johansen + * Copyright (c) 2013 Maximilian Antoni + */ + + (function (sinon) { + function makeApi(sinon) { + function throwYieldError(proxy, text, args) { + var msg = sinon.functionName(proxy) + text; + if (args.length) { + msg += " Received [" + slice.call(args).join(", ") + "]"; + } + throw new Error(msg); + } + + var slice = Array.prototype.slice; + + var callProto = { + calledOn: function calledOn(thisValue) { + if (sinon.match && sinon.match.isMatcher(thisValue)) { + return thisValue.test(this.thisValue); + } + return this.thisValue === thisValue; + }, + + calledWith: function calledWith() { + var l = arguments.length; + if (l > this.args.length) { + return false; + } + for (var i = 0; i < l; i += 1) { + if (!sinon.deepEqual(arguments[i], this.args[i])) { + return false; + } + } + + return true; + }, + + calledWithMatch: function calledWithMatch() { + var l = arguments.length; + if (l > this.args.length) { + return false; + } + for (var i = 0; i < l; i += 1) { + var actual = this.args[i]; + var expectation = arguments[i]; + if (!sinon.match || !sinon.match(expectation).test(actual)) { + return false; + } + } + return true; + }, + + calledWithExactly: function calledWithExactly() { + return arguments.length == this.args.length && + this.calledWith.apply(this, arguments); + }, + + notCalledWith: function notCalledWith() { + return !this.calledWith.apply(this, arguments); + }, + + notCalledWithMatch: function notCalledWithMatch() { + return !this.calledWithMatch.apply(this, arguments); + }, + + returned: function returned(value) { + return sinon.deepEqual(value, this.returnValue); + }, + + threw: function threw(error) { + if (typeof error === "undefined" || !this.exception) { + return !!this.exception; + } + + return this.exception === error || this.exception.name === error; + }, + + calledWithNew: function calledWithNew() { + return this.proxy.prototype && this.thisValue instanceof this.proxy; + }, + + calledBefore: function (other) { + return this.callId < other.callId; + }, + + calledAfter: function (other) { + return this.callId > other.callId; + }, + + callArg: function (pos) { + this.args[pos](); + }, + + callArgOn: function (pos, thisValue) { + this.args[pos].apply(thisValue); + }, + + callArgWith: function (pos) { + this.callArgOnWith.apply(this, [pos, null].concat(slice.call(arguments, 1))); + }, + + callArgOnWith: function (pos, thisValue) { + var args = slice.call(arguments, 2); + this.args[pos].apply(thisValue, args); + }, + + yield: function () { + this.yieldOn.apply(this, [null].concat(slice.call(arguments, 0))); + }, + + yieldOn: function (thisValue) { + var args = this.args; + for (var i = 0, l = args.length; i < l; ++i) { + if (typeof args[i] === "function") { + args[i].apply(thisValue, slice.call(arguments, 1)); + return; + } + } + throwYieldError(this.proxy, " cannot yield since no callback was passed.", args); + }, + + yieldTo: function (prop) { + this.yieldToOn.apply(this, [prop, null].concat(slice.call(arguments, 1))); + }, + + yieldToOn: function (prop, thisValue) { + var args = this.args; + for (var i = 0, l = args.length; i < l; ++i) { + if (args[i] && typeof args[i][prop] === "function") { + args[i][prop].apply(thisValue, slice.call(arguments, 2)); + return; + } + } + throwYieldError(this.proxy, " cannot yield to '" + prop + + "' since no callback was passed.", args); + }, + + toString: function () { + var callStr = this.proxy.toString() + "("; + var args = []; + + for (var i = 0, l = this.args.length; i < l; ++i) { + args.push(sinon.format(this.args[i])); + } + + callStr = callStr + args.join(", ") + ")"; + + if (typeof this.returnValue != "undefined") { + callStr += " => " + sinon.format(this.returnValue); + } + + if (this.exception) { + callStr += " !" + this.exception.name; + + if (this.exception.message) { + callStr += "(" + this.exception.message + ")"; + } + } + + return callStr; + } + }; + + callProto.invokeCallback = callProto.yield; + + function createSpyCall(spy, thisValue, args, returnValue, exception, id) { + if (typeof id !== "number") { + throw new TypeError("Call id is not a number"); + } + var proxyCall = sinon.create(callProto); + proxyCall.proxy = spy; + proxyCall.thisValue = thisValue; + proxyCall.args = args; + proxyCall.returnValue = returnValue; + proxyCall.exception = exception; + proxyCall.callId = id; + + return proxyCall; + } + createSpyCall.toString = callProto.toString; // used by mocks + + sinon.spyCall = createSpyCall; + return createSpyCall; + } + + var isNode = typeof module !== "undefined" && module.exports && typeof require == "function"; + var isAMD = typeof define === "function" && typeof define.amd === "object" && define.amd; + + function loadDependencies(require, exports, module) { + var sinon = require("./util/core"); + require("./match"); + require("./format"); + module.exports = makeApi(sinon); + } + + if (isAMD) { + define(loadDependencies); + } else if (isNode) { + loadDependencies(require, module.exports, module); + } else if (!sinon) { + return; + } else { + makeApi(sinon); + } + }(typeof sinon == "object" && sinon || null)); + + /** + * @depend times_in_words.js + * @depend util/core.js + * @depend extend.js + * @depend call.js + * @depend format.js + */ + /** + * Spy functions + * + * @author Christian Johansen (christian@cjohansen.no) + * @license BSD + * + * Copyright (c) 2010-2013 Christian Johansen + */ + + (function (sinon) { + + function makeApi(sinon) { + var push = Array.prototype.push; + var slice = Array.prototype.slice; + var callId = 0; + + function spy(object, property, types) { + if (!property && typeof object == "function") { + return spy.create(object); + } + + if (!object && !property) { + return spy.create(function () { }); + } + + if (types) { + var methodDesc = sinon.getPropertyDescriptor(object, property); + for (var i = 0; i < types.length; i++) { + methodDesc[types[i]] = spy.create(methodDesc[types[i]]); + } + return sinon.wrapMethod(object, property, methodDesc); + } else { + var method = object[property]; + return sinon.wrapMethod(object, property, spy.create(method)); + } + } + + function matchingFake(fakes, args, strict) { + if (!fakes) { + return; + } + + for (var i = 0, l = fakes.length; i < l; i++) { + if (fakes[i].matches(args, strict)) { + return fakes[i]; + } + } + } + + function incrementCallCount() { + this.called = true; + this.callCount += 1; + this.notCalled = false; + this.calledOnce = this.callCount == 1; + this.calledTwice = this.callCount == 2; + this.calledThrice = this.callCount == 3; + } + + function createCallProperties() { + this.firstCall = this.getCall(0); + this.secondCall = this.getCall(1); + this.thirdCall = this.getCall(2); + this.lastCall = this.getCall(this.callCount - 1); + } + + // ##### BEGIN OF MODIFICATION BY SAP + // var vars = "a,b,c,d,e,f,g,h,i,j,k,l"; + // ##### END OF MODIFICATION BY SAP + function createProxy(func, proxyLength) { + // Retain the function length: + var p; + if (proxyLength) { + // ##### BEGIN OF MODIFICATION BY SAP + // The following lines have been downported from Sinon 4.4.6 to avoid the use of eval() (for better CSP compliance) + + // Do not change this to use an eval. Projects that depend on sinon block the use of eval. + // ref: https://github.com/sinonjs/sinon/issues/710 + switch (proxyLength) { + /*eslint-disable no-unused-vars, max-len*/ + case 1: p = function proxy(a) { return p.invoke(func, this, slice.call(arguments)); }; break; + case 2: p = function proxy(a, b) { return p.invoke(func, this, slice.call(arguments)); }; break; + case 3: p = function proxy(a, b, c) { return p.invoke(func, this, slice.call(arguments)); }; break; + case 4: p = function proxy(a, b, c, d) { return p.invoke(func, this, slice.call(arguments)); }; break; + case 5: p = function proxy(a, b, c, d, e) { return p.invoke(func, this, slice.call(arguments)); }; break; + case 6: p = function proxy(a, b, c, d, e, f) { return p.invoke(func, this, slice.call(arguments)); }; break; + case 7: p = function proxy(a, b, c, d, e, f, g) { return p.invoke(func, this, slice.call(arguments)); }; break; + case 8: p = function proxy(a, b, c, d, e, f, g, h) { return p.invoke(func, this, slice.call(arguments)); }; break; + case 9: p = function proxy(a, b, c, d, e, f, g, h, i) { return p.invoke(func, this, slice.call(arguments)); }; break; + case 10: p = function proxy(a, b, c, d, e, f, g, h, i, j) { return p.invoke(func, this, slice.call(arguments)); }; break; + case 11: p = function proxy(a, b, c, d, e, f, g, h, i, j, k) { return p.invoke(func, this, slice.call(arguments)); }; break; + case 12: p = function proxy(a, b, c, d, e, f, g, h, i, j, k, l) { return p.invoke(func, this, slice.call(arguments)); }; break; + default: p = function proxy() { return p.invoke(func, this, slice.call(arguments)); }; break; + /*eslint-enable*/ + } + // + // eval("p = (function proxy(" + vars.substring(0, proxyLength * 2 - 1) + + // ") { return p.invoke(func, this, slice.call(arguments)); });"); + // + // ##### END OF MODIFICATION BY SAP + } else { + p = function proxy() { + return p.invoke(func, this, slice.call(arguments)); + }; + } + return p; + } + + var uuid = 0; + + // Public API + var spyApi = { + reset: function () { + if (this.invoking) { + var err = new Error("Cannot reset Sinon function while invoking it. " + + "Move the call to .reset outside of the callback."); + err.name = "InvalidResetException"; + throw err; + } + + this.called = false; + this.notCalled = true; + this.calledOnce = false; + this.calledTwice = false; + this.calledThrice = false; + this.callCount = 0; + this.firstCall = null; + this.secondCall = null; + this.thirdCall = null; + this.lastCall = null; + this.args = []; + this.returnValues = []; + this.thisValues = []; + this.exceptions = []; + this.callIds = []; + if (this.fakes) { + for (var i = 0; i < this.fakes.length; i++) { + this.fakes[i].reset(); + } + } + + return this; + }, + + create: function create(func, spyLength) { + var name; + + if (typeof func != "function") { + func = function () { }; + } else { + name = sinon.functionName(func); + } + + if (!spyLength) { + spyLength = func.length; + } + + var proxy = createProxy(func, spyLength); + + sinon.extend(proxy, spy); + delete proxy.create; + sinon.extend(proxy, func); + + proxy.reset(); + proxy.prototype = func.prototype; + proxy.displayName = name || "spy"; + proxy.toString = sinon.functionToString; + proxy.instantiateFake = sinon.spy.create; + proxy.id = "spy#" + uuid++; + + return proxy; + }, + + invoke: function invoke(func, thisValue, args) { + var matching = matchingFake(this.fakes, args); + var exception, returnValue; + + incrementCallCount.call(this); + push.call(this.thisValues, thisValue); + push.call(this.args, args); + push.call(this.callIds, callId++); + + // Make call properties available from within the spied function: + createCallProperties.call(this); + + try { + this.invoking = true; + + if (matching) { + returnValue = matching.invoke(func, thisValue, args); + } else { + returnValue = (this.func || func).apply(thisValue, args); + } + + var thisCall = this.getCall(this.callCount - 1); + if (thisCall.calledWithNew() && typeof returnValue !== "object") { + returnValue = thisValue; + } + } catch (e) { + exception = e; + } finally { + delete this.invoking; + } + + push.call(this.exceptions, exception); + push.call(this.returnValues, returnValue); + + // Make return value and exception available in the calls: + createCallProperties.call(this); + + if (exception !== undefined) { + throw exception; + } + + return returnValue; + }, + + named: function named(name) { + this.displayName = name; + return this; + }, + + getCall: function getCall(i) { + if (i < 0 || i >= this.callCount) { + return null; + } + + return sinon.spyCall(this, this.thisValues[i], this.args[i], + this.returnValues[i], this.exceptions[i], + this.callIds[i]); + }, + + getCalls: function () { + var calls = []; + var i; + + for (i = 0; i < this.callCount; i++) { + calls.push(this.getCall(i)); + } + + return calls; + }, + + calledBefore: function calledBefore(spyFn) { + if (!this.called) { + return false; + } + + if (!spyFn.called) { + return true; + } + + return this.callIds[0] < spyFn.callIds[spyFn.callIds.length - 1]; + }, + + calledAfter: function calledAfter(spyFn) { + if (!this.called || !spyFn.called) { + return false; + } + + return this.callIds[this.callCount - 1] > spyFn.callIds[spyFn.callCount - 1]; + }, + + withArgs: function () { + var args = slice.call(arguments); + + if (this.fakes) { + var match = matchingFake(this.fakes, args, true); + + if (match) { + return match; + } + } else { + this.fakes = []; + } + + var original = this; + var fake = this.instantiateFake(); + fake.matchingAguments = args; + fake.parent = this; + push.call(this.fakes, fake); + + fake.withArgs = function () { + return original.withArgs.apply(original, arguments); + }; + + for (var i = 0; i < this.args.length; i++) { + if (fake.matches(this.args[i])) { + incrementCallCount.call(fake); + push.call(fake.thisValues, this.thisValues[i]); + push.call(fake.args, this.args[i]); + push.call(fake.returnValues, this.returnValues[i]); + push.call(fake.exceptions, this.exceptions[i]); + push.call(fake.callIds, this.callIds[i]); + } + } + createCallProperties.call(fake); + + return fake; + }, + + matches: function (args, strict) { + var margs = this.matchingAguments; + + if (margs.length <= args.length && + sinon.deepEqual(margs, args.slice(0, margs.length))) { + return !strict || margs.length == args.length; + } + }, + + printf: function (format) { + var spy = this; + var args = slice.call(arguments, 1); + var formatter; + + return (format || "").replace(/%(.)/g, function (match, specifyer) { + formatter = spyApi.formatters[specifyer]; + + if (typeof formatter == "function") { + return formatter.call(null, spy, args); + } else if (!isNaN(parseInt(specifyer, 10))) { + return sinon.format(args[specifyer - 1]); + } + + return "%" + specifyer; + }); + } + }; + + function delegateToCalls(method, matchAny, actual, notCalled) { + spyApi[method] = function () { + if (!this.called) { + if (notCalled) { + return notCalled.apply(this, arguments); + } + return false; + } + + var currentCall; + var matches = 0; + + for (var i = 0, l = this.callCount; i < l; i += 1) { + currentCall = this.getCall(i); + + if (currentCall[actual || method].apply(currentCall, arguments)) { + matches += 1; + + if (matchAny) { + return true; + } + } + } + + return matches === this.callCount; + }; + } + + delegateToCalls("calledOn", true); + delegateToCalls("alwaysCalledOn", false, "calledOn"); + delegateToCalls("calledWith", true); + delegateToCalls("calledWithMatch", true); + delegateToCalls("alwaysCalledWith", false, "calledWith"); + delegateToCalls("alwaysCalledWithMatch", false, "calledWithMatch"); + delegateToCalls("calledWithExactly", true); + delegateToCalls("alwaysCalledWithExactly", false, "calledWithExactly"); + delegateToCalls("neverCalledWith", false, "notCalledWith", + function () { return true; }); + delegateToCalls("neverCalledWithMatch", false, "notCalledWithMatch", + function () { return true; }); + delegateToCalls("threw", true); + delegateToCalls("alwaysThrew", false, "threw"); + delegateToCalls("returned", true); + delegateToCalls("alwaysReturned", false, "returned"); + delegateToCalls("calledWithNew", true); + delegateToCalls("alwaysCalledWithNew", false, "calledWithNew"); + delegateToCalls("callArg", false, "callArgWith", function () { + throw new Error(this.toString() + " cannot call arg since it was not yet invoked."); + }); + spyApi.callArgWith = spyApi.callArg; + delegateToCalls("callArgOn", false, "callArgOnWith", function () { + throw new Error(this.toString() + " cannot call arg since it was not yet invoked."); + }); + spyApi.callArgOnWith = spyApi.callArgOn; + delegateToCalls("yield", false, "yield", function () { + throw new Error(this.toString() + " cannot yield since it was not yet invoked."); + }); + // "invokeCallback" is an alias for "yield" since "yield" is invalid in strict mode. + spyApi.invokeCallback = spyApi.yield; + delegateToCalls("yieldOn", false, "yieldOn", function () { + throw new Error(this.toString() + " cannot yield since it was not yet invoked."); + }); + delegateToCalls("yieldTo", false, "yieldTo", function (property) { + throw new Error(this.toString() + " cannot yield to '" + property + + "' since it was not yet invoked."); + }); + delegateToCalls("yieldToOn", false, "yieldToOn", function (property) { + throw new Error(this.toString() + " cannot yield to '" + property + + "' since it was not yet invoked."); + }); + + spyApi.formatters = { + c: function (spy) { + return sinon.timesInWords(spy.callCount); + }, + + n: function (spy) { + return spy.toString(); + }, + + C: function (spy) { + var calls = []; + + for (var i = 0, l = spy.callCount; i < l; ++i) { + var stringifiedCall = " " + spy.getCall(i).toString(); + if (/\n/.test(calls[i - 1])) { + stringifiedCall = "\n" + stringifiedCall; + } + push.call(calls, stringifiedCall); + } + + return calls.length > 0 ? "\n" + calls.join("\n") : ""; + }, + + t: function (spy) { + var objects = []; + + for (var i = 0, l = spy.callCount; i < l; ++i) { + push.call(objects, sinon.format(spy.thisValues[i])); + } + + return objects.join(", "); + }, + + "*": function (spy, args) { + var formatted = []; + + for (var i = 0, l = args.length; i < l; ++i) { + push.call(formatted, sinon.format(args[i])); + } + + return formatted.join(", "); + } + }; + + sinon.extend(spy, spyApi); + + spy.spyCall = sinon.spyCall; + sinon.spy = spy; + + return spy; + } + + var isNode = typeof module !== "undefined" && module.exports && typeof require == "function"; + var isAMD = typeof define === "function" && typeof define.amd === "object" && define.amd; + + function loadDependencies(require, exports, module) { + var sinon = require("./util/core"); + require("./call"); + require("./extend"); + require("./times_in_words"); + require("./format"); + module.exports = makeApi(sinon); + } + + if (isAMD) { + define(loadDependencies); + } else if (isNode) { + loadDependencies(require, module.exports, module); + } else if (!sinon) { + return; + } else { + makeApi(sinon); + } + }(typeof sinon == "object" && sinon || null)); + + /** + * @depend util/core.js + * @depend extend.js + */ + /** + * Stub behavior + * + * @author Christian Johansen (christian@cjohansen.no) + * @author Tim Fischbach (mail@timfischbach.de) + * @license BSD + * + * Copyright (c) 2010-2013 Christian Johansen + */ + + (function (sinon) { + var slice = Array.prototype.slice; + var join = Array.prototype.join; + var useLeftMostCallback = -1; + var useRightMostCallback = -2; + + var nextTick = (function () { + if (typeof process === "object" && typeof process.nextTick === "function") { + return process.nextTick; + } else if (typeof setImmediate === "function") { + return setImmediate; + } else { + return function (callback) { + setTimeout(callback, 0); + }; + } + })(); + + function throwsException(error, message) { + if (typeof error == "string") { + this.exception = new Error(message || ""); + this.exception.name = error; + } else if (!error) { + this.exception = new Error("Error"); + } else { + this.exception = error; + } + + return this; + } + + function getCallback(behavior, args) { + var callArgAt = behavior.callArgAt; + + if (callArgAt >= 0) { + return args[callArgAt]; + } + + var argumentList; + + if (callArgAt === useLeftMostCallback) { + argumentList = args; + } + + if (callArgAt === useRightMostCallback) { + argumentList = slice.call(args).reverse(); + } + + var callArgProp = behavior.callArgProp; + + for (var i = 0, l = argumentList.length; i < l; ++i) { + if (!callArgProp && typeof argumentList[i] == "function") { + return argumentList[i]; + } + + if (callArgProp && argumentList[i] && + typeof argumentList[i][callArgProp] == "function") { + return argumentList[i][callArgProp]; + } + } + + return null; + } + + function makeApi(sinon) { + function getCallbackError(behavior, func, args) { + if (behavior.callArgAt < 0) { + var msg; + + if (behavior.callArgProp) { + msg = sinon.functionName(behavior.stub) + + " expected to yield to '" + behavior.callArgProp + + "', but no object with such a property was passed."; + } else { + msg = sinon.functionName(behavior.stub) + + " expected to yield, but no callback was passed."; + } + + if (args.length > 0) { + msg += " Received [" + join.call(args, ", ") + "]"; + } + + return msg; + } + + return "argument at index " + behavior.callArgAt + " is not a function: " + func; + } + + function callCallback(behavior, args) { + if (typeof behavior.callArgAt == "number") { + var func = getCallback(behavior, args); + + if (typeof func != "function") { + throw new TypeError(getCallbackError(behavior, func, args)); + } + + if (behavior.callbackAsync) { + nextTick(function () { + func.apply(behavior.callbackContext, behavior.callbackArguments); + }); + } else { + func.apply(behavior.callbackContext, behavior.callbackArguments); + } + } + } + + var proto = { + create: function create(stub) { + var behavior = sinon.extend({}, sinon.behavior); + delete behavior.create; + behavior.stub = stub; + + return behavior; + }, + + isPresent: function isPresent() { + return (typeof this.callArgAt == "number" || + this.exception || + typeof this.returnArgAt == "number" || + this.returnThis || + this.returnValueDefined); + }, + + invoke: function invoke(context, args) { + callCallback(this, args); + + if (this.exception) { + throw this.exception; + } else if (typeof this.returnArgAt == "number") { + return args[this.returnArgAt]; + } else if (this.returnThis) { + return context; + } + + return this.returnValue; + }, + + onCall: function onCall(index) { + return this.stub.onCall(index); + }, + + onFirstCall: function onFirstCall() { + return this.stub.onFirstCall(); + }, + + onSecondCall: function onSecondCall() { + return this.stub.onSecondCall(); + }, + + onThirdCall: function onThirdCall() { + return this.stub.onThirdCall(); + }, + + withArgs: function withArgs(/* arguments */) { + throw new Error("Defining a stub by invoking \"stub.onCall(...).withArgs(...)\" is not supported. " + + "Use \"stub.withArgs(...).onCall(...)\" to define sequential behavior for calls with certain arguments."); + }, + + callsArg: function callsArg(pos) { + if (typeof pos != "number") { + throw new TypeError("argument index is not number"); + } + + this.callArgAt = pos; + this.callbackArguments = []; + this.callbackContext = undefined; + this.callArgProp = undefined; + this.callbackAsync = false; + + return this; + }, + + callsArgOn: function callsArgOn(pos, context) { + if (typeof pos != "number") { + throw new TypeError("argument index is not number"); + } + if (typeof context != "object") { + throw new TypeError("argument context is not an object"); + } + + this.callArgAt = pos; + this.callbackArguments = []; + this.callbackContext = context; + this.callArgProp = undefined; + this.callbackAsync = false; + + return this; + }, + + callsArgWith: function callsArgWith(pos) { + if (typeof pos != "number") { + throw new TypeError("argument index is not number"); + } + + this.callArgAt = pos; + this.callbackArguments = slice.call(arguments, 1); + this.callbackContext = undefined; + this.callArgProp = undefined; + this.callbackAsync = false; + + return this; + }, + + callsArgOnWith: function callsArgWith(pos, context) { + if (typeof pos != "number") { + throw new TypeError("argument index is not number"); + } + if (typeof context != "object") { + throw new TypeError("argument context is not an object"); + } + + this.callArgAt = pos; + this.callbackArguments = slice.call(arguments, 2); + this.callbackContext = context; + this.callArgProp = undefined; + this.callbackAsync = false; + + return this; + }, + + yields: function () { + this.callArgAt = useLeftMostCallback; + this.callbackArguments = slice.call(arguments, 0); + this.callbackContext = undefined; + this.callArgProp = undefined; + this.callbackAsync = false; + + return this; + }, + + yieldsRight: function () { + this.callArgAt = useRightMostCallback; + this.callbackArguments = slice.call(arguments, 0); + this.callbackContext = undefined; + this.callArgProp = undefined; + this.callbackAsync = false; + + return this; + }, + + yieldsOn: function (context) { + if (typeof context != "object") { + throw new TypeError("argument context is not an object"); + } + + this.callArgAt = useLeftMostCallback; + this.callbackArguments = slice.call(arguments, 1); + this.callbackContext = context; + this.callArgProp = undefined; + this.callbackAsync = false; + + return this; + }, + + yieldsTo: function (prop) { + this.callArgAt = useLeftMostCallback; + this.callbackArguments = slice.call(arguments, 1); + this.callbackContext = undefined; + this.callArgProp = prop; + this.callbackAsync = false; + + return this; + }, + + yieldsToOn: function (prop, context) { + if (typeof context != "object") { + throw new TypeError("argument context is not an object"); + } + + this.callArgAt = useLeftMostCallback; + this.callbackArguments = slice.call(arguments, 2); + this.callbackContext = context; + this.callArgProp = prop; + this.callbackAsync = false; + + return this; + }, + + throws: throwsException, + throwsException: throwsException, + + returns: function returns(value) { + this.returnValue = value; + this.returnValueDefined = true; + + return this; + }, + + returnsArg: function returnsArg(pos) { + if (typeof pos != "number") { + throw new TypeError("argument index is not number"); + } + + this.returnArgAt = pos; + + return this; + }, + + returnsThis: function returnsThis() { + this.returnThis = true; + + return this; + } + }; + + // create asynchronous versions of callsArg* and yields* methods + for (var method in proto) { + // need to avoid creating anotherasync versions of the newly added async methods + if (proto.hasOwnProperty(method) && + method.match(/^(callsArg|yields)/) && + !method.match(/Async/)) { + proto[method + "Async"] = (function (syncFnName) { + return function () { + var result = this[syncFnName].apply(this, arguments); + this.callbackAsync = true; + return result; + }; + })(method); + } + } + + sinon.behavior = proto; + return proto; + } + + var isNode = typeof module !== "undefined" && module.exports && typeof require == "function"; + var isAMD = typeof define === "function" && typeof define.amd === "object" && define.amd; + + function loadDependencies(require, exports, module) { + var sinon = require("./util/core"); + require("./extend"); + module.exports = makeApi(sinon); + } + + if (isAMD) { + define(loadDependencies); + } else if (isNode) { + loadDependencies(require, module.exports, module); + } else if (!sinon) { + return; + } else { + makeApi(sinon); + } + }(typeof sinon == "object" && sinon || null)); + + /** + * @depend util/core.js + * @depend extend.js + * @depend spy.js + * @depend behavior.js + */ + /** + * Stub functions + * + * @author Christian Johansen (christian@cjohansen.no) + * @license BSD + * + * Copyright (c) 2010-2013 Christian Johansen + */ + + (function (sinon) { + function makeApi(sinon) { + function stub(object, property, func) { + if (!!func && typeof func != "function" && typeof func != "object") { + throw new TypeError("Custom stub should be a function or a property descriptor"); + } + + var wrapper; + + if (func) { + if (typeof func == "function") { + wrapper = sinon.spy && sinon.spy.create ? sinon.spy.create(func) : func; + } else { + wrapper = func; + if (sinon.spy && sinon.spy.create) { + var types = sinon.objectKeys(wrapper); + for (var i = 0; i < types.length; i++) { + wrapper[types[i]] = sinon.spy.create(wrapper[types[i]]); + } + } + } + } else { + var stubLength = 0; + if (typeof object == "object" && typeof object[property] == "function") { + stubLength = object[property].length; + } + wrapper = stub.create(stubLength); + } + + if (!object && typeof property === "undefined") { + return sinon.stub.create(); + } + + if (typeof property === "undefined" && typeof object == "object") { + for (var prop in object) { + if (typeof object[prop] === "function") { + stub(object, prop); + } + } + + return object; + } + + return sinon.wrapMethod(object, property, wrapper); + } + + function getDefaultBehavior(stub) { + return stub.defaultBehavior || getParentBehaviour(stub) || sinon.behavior.create(stub); + } + + function getParentBehaviour(stub) { + return (stub.parent && getCurrentBehavior(stub.parent)); + } + + function getCurrentBehavior(stub) { + var behavior = stub.behaviors[stub.callCount - 1]; + return behavior && behavior.isPresent() ? behavior : getDefaultBehavior(stub); + } + + var uuid = 0; + + var proto = { + create: function create(stubLength) { + var functionStub = function () { + return getCurrentBehavior(functionStub).invoke(this, arguments); + }; + + functionStub.id = "stub#" + uuid++; + var orig = functionStub; + functionStub = sinon.spy.create(functionStub, stubLength); + functionStub.func = orig; + + sinon.extend(functionStub, stub); + functionStub.instantiateFake = sinon.stub.create; + functionStub.displayName = "stub"; + functionStub.toString = sinon.functionToString; + + functionStub.defaultBehavior = null; + functionStub.behaviors = []; + + return functionStub; + }, + + resetBehavior: function () { + var i; + + this.defaultBehavior = null; + this.behaviors = []; + + delete this.returnValue; + delete this.returnArgAt; + this.returnThis = false; + + if (this.fakes) { + for (i = 0; i < this.fakes.length; i++) { + this.fakes[i].resetBehavior(); + } + } + }, + + onCall: function onCall(index) { + if (!this.behaviors[index]) { + this.behaviors[index] = sinon.behavior.create(this); + } + + return this.behaviors[index]; + }, + + onFirstCall: function onFirstCall() { + return this.onCall(0); + }, + + onSecondCall: function onSecondCall() { + return this.onCall(1); + }, + + onThirdCall: function onThirdCall() { + return this.onCall(2); + } + }; + + for (var method in sinon.behavior) { + if (sinon.behavior.hasOwnProperty(method) && + !proto.hasOwnProperty(method) && + method != "create" && + method != "withArgs" && + method != "invoke") { + proto[method] = (function (behaviorMethod) { + return function () { + this.defaultBehavior = this.defaultBehavior || sinon.behavior.create(this); + this.defaultBehavior[behaviorMethod].apply(this.defaultBehavior, arguments); + return this; + }; + }(method)); + } + } + + sinon.extend(stub, proto); + sinon.stub = stub; + + return stub; + } + + var isNode = typeof module !== "undefined" && module.exports && typeof require == "function"; + var isAMD = typeof define === "function" && typeof define.amd === "object" && define.amd; + + function loadDependencies(require, exports, module) { + var sinon = require("./util/core"); + require("./behavior"); + require("./spy"); + require("./extend"); + module.exports = makeApi(sinon); + } + + if (isAMD) { + define(loadDependencies); + } else if (isNode) { + loadDependencies(require, module.exports, module); + } else if (!sinon) { + return; + } else { + makeApi(sinon); + } + }(typeof sinon == "object" && sinon || null)); + + /** + * @depend times_in_words.js + * @depend util/core.js + * @depend call.js + * @depend extend.js + * @depend match.js + * @depend spy.js + * @depend stub.js + * @depend format.js + */ + /** + * Mock functions. + * + * @author Christian Johansen (christian@cjohansen.no) + * @license BSD + * + * Copyright (c) 2010-2013 Christian Johansen + */ + + (function (sinon) { + function makeApi(sinon) { + var push = [].push; + var match = sinon.match; + + function mock(object) { + if (!object) { + return sinon.expectation.create("Anonymous mock"); + } + + return mock.create(object); + } + + function each(collection, callback) { + if (!collection) { + return; + } + + for (var i = 0, l = collection.length; i < l; i += 1) { + callback(collection[i]); + } + } + + sinon.extend(mock, { + create: function create(object) { + if (!object) { + throw new TypeError("object is null"); + } + + var mockObject = sinon.extend({}, mock); + mockObject.object = object; + delete mockObject.create; + + return mockObject; + }, + + expects: function expects(method) { + if (!method) { + throw new TypeError("method is falsy"); + } + + if (!this.expectations) { + this.expectations = {}; + this.proxies = []; + } + + if (!this.expectations[method]) { + this.expectations[method] = []; + var mockObject = this; + + sinon.wrapMethod(this.object, method, function () { + return mockObject.invokeMethod(method, this, arguments); + }); + + push.call(this.proxies, method); + } + + var expectation = sinon.expectation.create(method); + push.call(this.expectations[method], expectation); + + return expectation; + }, + + restore: function restore() { + var object = this.object; + + each(this.proxies, function (proxy) { + if (typeof object[proxy].restore == "function") { + object[proxy].restore(); + } + }); + }, + + verify: function verify() { + var expectations = this.expectations || {}; + var messages = [], met = []; + + each(this.proxies, function (proxy) { + each(expectations[proxy], function (expectation) { + if (!expectation.met()) { + push.call(messages, expectation.toString()); + } else { + push.call(met, expectation.toString()); + } + }); + }); + + this.restore(); + + if (messages.length > 0) { + sinon.expectation.fail(messages.concat(met).join("\n")); + } else if (met.length > 0) { + sinon.expectation.pass(messages.concat(met).join("\n")); + } + + return true; + }, + + invokeMethod: function invokeMethod(method, thisValue, args) { + var expectations = this.expectations && this.expectations[method]; + var length = expectations && expectations.length || 0, i; + + for (i = 0; i < length; i += 1) { + if (!expectations[i].met() && + expectations[i].allowsCall(thisValue, args)) { + return expectations[i].apply(thisValue, args); + } + } + + var messages = [], available, exhausted = 0; + + for (i = 0; i < length; i += 1) { + if (expectations[i].allowsCall(thisValue, args)) { + available = available || expectations[i]; + } else { + exhausted += 1; + } + push.call(messages, " " + expectations[i].toString()); + } + + if (exhausted === 0) { + return available.apply(thisValue, args); + } + + messages.unshift("Unexpected call: " + sinon.spyCall.toString.call({ + proxy: method, + args: args + })); + + sinon.expectation.fail(messages.join("\n")); + } + }); + + var times = sinon.timesInWords; + var slice = Array.prototype.slice; + + function callCountInWords(callCount) { + if (callCount == 0) { + return "never called"; + } else { + return "called " + times(callCount); + } + } + + function expectedCallCountInWords(expectation) { + var min = expectation.minCalls; + var max = expectation.maxCalls; + + if (typeof min == "number" && typeof max == "number") { + var str = times(min); + + if (min != max) { + str = "at least " + str + " and at most " + times(max); + } + + return str; + } + + if (typeof min == "number") { + return "at least " + times(min); + } + + return "at most " + times(max); + } + + function receivedMinCalls(expectation) { + var hasMinLimit = typeof expectation.minCalls == "number"; + return !hasMinLimit || expectation.callCount >= expectation.minCalls; + } + + function receivedMaxCalls(expectation) { + if (typeof expectation.maxCalls != "number") { + return false; + } + + return expectation.callCount == expectation.maxCalls; + } + + function verifyMatcher(possibleMatcher, arg) { + if (match && match.isMatcher(possibleMatcher)) { + return possibleMatcher.test(arg); + } else { + return true; + } + } + + sinon.expectation = { + minCalls: 1, + maxCalls: 1, + + create: function create(methodName) { + var expectation = sinon.extend(sinon.stub.create(), sinon.expectation); + delete expectation.create; + expectation.method = methodName; + + return expectation; + }, + + invoke: function invoke(func, thisValue, args) { + this.verifyCallAllowed(thisValue, args); + + return sinon.spy.invoke.apply(this, arguments); + }, + + atLeast: function atLeast(num) { + if (typeof num != "number") { + throw new TypeError("'" + num + "' is not number"); + } + + if (!this.limitsSet) { + this.maxCalls = null; + this.limitsSet = true; + } + + this.minCalls = num; + + return this; + }, + + atMost: function atMost(num) { + if (typeof num != "number") { + throw new TypeError("'" + num + "' is not number"); + } + + if (!this.limitsSet) { + this.minCalls = null; + this.limitsSet = true; + } + + this.maxCalls = num; + + return this; + }, + + never: function never() { + return this.exactly(0); + }, + + once: function once() { + return this.exactly(1); + }, + + twice: function twice() { + return this.exactly(2); + }, + + thrice: function thrice() { + return this.exactly(3); + }, + + exactly: function exactly(num) { + if (typeof num != "number") { + throw new TypeError("'" + num + "' is not a number"); + } + + this.atLeast(num); + return this.atMost(num); + }, + + met: function met() { + return !this.failed && receivedMinCalls(this); + }, + + verifyCallAllowed: function verifyCallAllowed(thisValue, args) { + if (receivedMaxCalls(this)) { + this.failed = true; + sinon.expectation.fail(this.method + " already called " + times(this.maxCalls)); + } + + if ("expectedThis" in this && this.expectedThis !== thisValue) { + sinon.expectation.fail(this.method + " called with " + thisValue + " as thisValue, expected " + + this.expectedThis); + } + + if (!("expectedArguments" in this)) { + return; + } + + if (!args) { + sinon.expectation.fail(this.method + " received no arguments, expected " + + sinon.format(this.expectedArguments)); + } + + if (args.length < this.expectedArguments.length) { + sinon.expectation.fail(this.method + " received too few arguments (" + sinon.format(args) + + "), expected " + sinon.format(this.expectedArguments)); + } + + if (this.expectsExactArgCount && + args.length != this.expectedArguments.length) { + sinon.expectation.fail(this.method + " received too many arguments (" + sinon.format(args) + + "), expected " + sinon.format(this.expectedArguments)); + } + + for (var i = 0, l = this.expectedArguments.length; i < l; i += 1) { + + if (!verifyMatcher(this.expectedArguments[i], args[i])) { + sinon.expectation.fail(this.method + " received wrong arguments " + sinon.format(args) + + ", didn't match " + this.expectedArguments.toString()); + } + + if (!sinon.deepEqual(this.expectedArguments[i], args[i])) { + sinon.expectation.fail(this.method + " received wrong arguments " + sinon.format(args) + + ", expected " + sinon.format(this.expectedArguments)); + } + } + }, + + allowsCall: function allowsCall(thisValue, args) { + if (this.met() && receivedMaxCalls(this)) { + return false; + } + + if ("expectedThis" in this && this.expectedThis !== thisValue) { + return false; + } + + if (!("expectedArguments" in this)) { + return true; + } + + args = args || []; + + if (args.length < this.expectedArguments.length) { + return false; + } + + if (this.expectsExactArgCount && + args.length != this.expectedArguments.length) { + return false; + } + + for (var i = 0, l = this.expectedArguments.length; i < l; i += 1) { + if (!verifyMatcher(this.expectedArguments[i], args[i])) { + return false; + } + + if (!sinon.deepEqual(this.expectedArguments[i], args[i])) { + return false; + } + } + + return true; + }, + + withArgs: function withArgs() { + this.expectedArguments = slice.call(arguments); + return this; + }, + + withExactArgs: function withExactArgs() { + this.withArgs.apply(this, arguments); + this.expectsExactArgCount = true; + return this; + }, + + on: function on(thisValue) { + this.expectedThis = thisValue; + return this; + }, + + toString: function () { + var args = (this.expectedArguments || []).slice(); + + if (!this.expectsExactArgCount) { + push.call(args, "[...]"); + } + + var callStr = sinon.spyCall.toString.call({ + proxy: this.method || "anonymous mock expectation", + args: args + }); + + var message = callStr.replace(", [...", "[, ...") + " " + + expectedCallCountInWords(this); + + if (this.met()) { + return "Expectation met: " + message; + } + + return "Expected " + message + " (" + + callCountInWords(this.callCount) + ")"; + }, + + verify: function verify() { + if (!this.met()) { + sinon.expectation.fail(this.toString()); + } else { + sinon.expectation.pass(this.toString()); + } + + return true; + }, + + pass: function pass(message) { + sinon.assert.pass(message); + }, + + fail: function fail(message) { + var exception = new Error(message); + exception.name = "ExpectationError"; + + throw exception; + } + }; + + sinon.mock = mock; + return mock; + } + + var isNode = typeof module !== "undefined" && module.exports && typeof require == "function"; + var isAMD = typeof define === "function" && typeof define.amd === "object" && define.amd; + + function loadDependencies(require, exports, module) { + var sinon = require("./util/core"); + require("./times_in_words"); + require("./call"); + require("./extend"); + require("./match"); + require("./spy"); + require("./stub"); + require("./format"); + + module.exports = makeApi(sinon); + } + + if (isAMD) { + define(loadDependencies); + } else if (isNode) { + loadDependencies(require, module.exports, module); + } else if (!sinon) { + return; + } else { + makeApi(sinon); + } + }(typeof sinon == "object" && sinon || null)); + + /** + * @depend util/core.js + * @depend spy.js + * @depend stub.js + * @depend mock.js + */ + /** + * Collections of stubs, spies and mocks. + * + * @author Christian Johansen (christian@cjohansen.no) + * @license BSD + * + * Copyright (c) 2010-2013 Christian Johansen + */ + + (function (sinon) { + var push = [].push; + var hasOwnProperty = Object.prototype.hasOwnProperty; + + function getFakes(fakeCollection) { + if (!fakeCollection.fakes) { + fakeCollection.fakes = []; + } + + return fakeCollection.fakes; + } + + function each(fakeCollection, method) { + var fakes = getFakes(fakeCollection); + + for (var i = 0, l = fakes.length; i < l; i += 1) { + if (typeof fakes[i][method] == "function") { + fakes[i][method](); + } + } + } + + function compact(fakeCollection) { + var fakes = getFakes(fakeCollection); + var i = 0; + while (i < fakes.length) { + fakes.splice(i, 1); + } + } + + function makeApi(sinon) { + var collection = { + verify: function resolve() { + each(this, "verify"); + }, + + restore: function restore() { + each(this, "restore"); + compact(this); + }, + + reset: function restore() { + each(this, "reset"); + }, + + verifyAndRestore: function verifyAndRestore() { + var exception; + + try { + this.verify(); + } catch (e) { + exception = e; + } + + this.restore(); + + if (exception) { + throw exception; + } + }, + + add: function add(fake) { + push.call(getFakes(this), fake); + return fake; + }, + + spy: function spy() { + return this.add(sinon.spy.apply(sinon, arguments)); + }, + + stub: function stub(object, property, value) { + if (property) { + var original = object[property]; + + if (typeof original != "function") { + if (!hasOwnProperty.call(object, property)) { + throw new TypeError("Cannot stub non-existent own property " + property); + } + + object[property] = value; + + return this.add({ + restore: function () { + object[property] = original; + } + }); + } + } + if (!property && !!object && typeof object == "object") { + var stubbedObj = sinon.stub.apply(sinon, arguments); + + for (var prop in stubbedObj) { + if (typeof stubbedObj[prop] === "function") { + this.add(stubbedObj[prop]); + } + } + + return stubbedObj; + } + + return this.add(sinon.stub.apply(sinon, arguments)); + }, + + mock: function mock() { + return this.add(sinon.mock.apply(sinon, arguments)); + }, + + inject: function inject(obj) { + var col = this; + + obj.spy = function () { + return col.spy.apply(col, arguments); + }; + + obj.stub = function () { + return col.stub.apply(col, arguments); + }; + + obj.mock = function () { + return col.mock.apply(col, arguments); + }; + + return obj; + } + }; + + sinon.collection = collection; + return collection; + } + + var isNode = typeof module !== "undefined" && module.exports && typeof require == "function"; + var isAMD = typeof define === "function" && typeof define.amd === "object" && define.amd; + + function loadDependencies(require, exports, module) { + var sinon = require("./util/core"); + require("./mock"); + require("./spy"); + require("./stub"); + module.exports = makeApi(sinon); + } + + if (isAMD) { + define(loadDependencies); + } else if (isNode) { + loadDependencies(require, module.exports, module); + } else if (!sinon) { + return; + } else { + makeApi(sinon); + } + }(typeof sinon == "object" && sinon || null)); + + /*global lolex */ + + /** + * Fake timer API + * setTimeout + * setInterval + * clearTimeout + * clearInterval + * tick + * reset + * Date + * + * Inspired by jsUnitMockTimeOut from JsUnit + * + * @author Christian Johansen (christian@cjohansen.no) + * @license BSD + * + * Copyright (c) 2010-2013 Christian Johansen + */ + + if (typeof sinon == "undefined") { + var sinon = {}; + } + + (function (global) { + function makeApi(sinon, lol) { + var llx = typeof lolex !== "undefined" ? lolex : lol; + + sinon.useFakeTimers = function () { + var now, methods = Array.prototype.slice.call(arguments); + + if (typeof methods[0] === "string") { + now = 0; + } else { + now = methods.shift(); + } + + var clock = llx.install(now || 0, methods); + clock.restore = clock.uninstall; + return clock; + }; + + sinon.clock = { + create: function (now) { + return llx.createClock(now); + } + }; + + sinon.timers = { + setTimeout: setTimeout, + clearTimeout: clearTimeout, + setImmediate: (typeof setImmediate !== "undefined" ? setImmediate : undefined), + clearImmediate: (typeof clearImmediate !== "undefined" ? clearImmediate : undefined), + setInterval: setInterval, + clearInterval: clearInterval, + Date: Date + }; + } + + var isNode = typeof module !== "undefined" && module.exports && typeof require == "function"; + var isAMD = typeof define === "function" && typeof define.amd === "object" && define.amd; + + function loadDependencies(require, epxorts, module, lolex) { + var sinon = require("./core"); + makeApi(sinon, lolex); + module.exports = sinon; + } + + if (isAMD) { + define(loadDependencies); + } else if (isNode) { + loadDependencies(require, module.exports, module, require("lolex")); + } else { + makeApi(sinon); + } + }(typeof global != "undefined" && typeof global !== "function" ? global : this)); + + /** + * Minimal Event interface implementation + * + * Original implementation by Sven Fuchs: https://gist.github.com/995028 + * Modifications and tests by Christian Johansen. + * + * @author Sven Fuchs (svenfuchs@artweb-design.de) + * @author Christian Johansen (christian@cjohansen.no) + * @license BSD + * + * Copyright (c) 2011 Sven Fuchs, Christian Johansen + */ + + if (typeof sinon == "undefined") { + this.sinon = {}; + } + + (function () { + var push = [].push; + + function makeApi(sinon) { + sinon.Event = function Event(type, bubbles, cancelable, target) { + this.initEvent(type, bubbles, cancelable, target); + }; + + sinon.Event.prototype = { + initEvent: function (type, bubbles, cancelable, target) { + this.type = type; + this.bubbles = bubbles; + this.cancelable = cancelable; + this.target = target; + }, + + stopPropagation: function () {}, + + preventDefault: function () { + this.defaultPrevented = true; + } + }; + + sinon.ProgressEvent = function ProgressEvent(type, progressEventRaw, target) { + this.initEvent(type, false, false, target); + this.loaded = progressEventRaw.loaded || null; + this.total = progressEventRaw.total || null; + this.lengthComputable = !!progressEventRaw.total; + }; + + sinon.ProgressEvent.prototype = new sinon.Event(); + + sinon.ProgressEvent.prototype.constructor = sinon.ProgressEvent; + + sinon.CustomEvent = function CustomEvent(type, customData, target) { + this.initEvent(type, false, false, target); + this.detail = customData.detail || null; + }; + + sinon.CustomEvent.prototype = new sinon.Event(); + + sinon.CustomEvent.prototype.constructor = sinon.CustomEvent; + + sinon.EventTarget = { + addEventListener: function addEventListener(event, listener) { + this.eventListeners = this.eventListeners || {}; + this.eventListeners[event] = this.eventListeners[event] || []; + push.call(this.eventListeners[event], listener); + }, + + removeEventListener: function removeEventListener(event, listener) { + var listeners = this.eventListeners && this.eventListeners[event] || []; + + for (var i = 0, l = listeners.length; i < l; ++i) { + if (listeners[i] == listener) { + return listeners.splice(i, 1); + } + } + }, + + dispatchEvent: function dispatchEvent(event) { + var type = event.type; + var listeners = this.eventListeners && this.eventListeners[type] || []; + + for (var i = 0; i < listeners.length; i++) { + if (typeof listeners[i] == "function") { + listeners[i].call(this, event); + } else { + listeners[i].handleEvent(event); + } + } + + return !!event.defaultPrevented; + } + }; + } + + var isNode = typeof module !== "undefined" && module.exports && typeof require == "function"; + var isAMD = typeof define === "function" && typeof define.amd === "object" && define.amd; + + function loadDependencies(require) { + var sinon = require("./core"); + makeApi(sinon); + } + + if (isAMD) { + define(loadDependencies); + } else if (isNode) { + loadDependencies(require); + } else { + makeApi(sinon); + } + }()); + + /** + * @depend util/core.js + */ + /** + * Logs errors + * + * @author Christian Johansen (christian@cjohansen.no) + * @license BSD + * + * Copyright (c) 2010-2014 Christian Johansen + */ + + (function (sinon) { + // cache a reference to setTimeout, so that our reference won't be stubbed out + // when using fake timers and errors will still get logged + // https://github.com/cjohansen/Sinon.JS/issues/381 + var realSetTimeout = setTimeout; + + function makeApi(sinon) { + + function log() {} + + function logError(label, err) { + var msg = label + " threw exception: "; + + sinon.log(msg + "[" + err.name + "] " + err.message); + + if (err.stack) { + sinon.log(err.stack); + } + + logError.setTimeout(function () { + err.message = msg + err.message; + throw err; + }, 0); + }; + + // wrap realSetTimeout with something we can stub in tests + logError.setTimeout = function (func, timeout) { + realSetTimeout(func, timeout); + } + + var exports = {}; + exports.log = sinon.log = log; + exports.logError = sinon.logError = logError; + + return exports; + } + + function loadDependencies(require, exports, module) { + var sinon = require("./util/core"); + module.exports = makeApi(sinon); + } + + var isNode = typeof module !== "undefined" && module.exports && typeof require == "function"; + var isAMD = typeof define === "function" && typeof define.amd === "object" && define.amd; + + if (isAMD) { + define(loadDependencies); + } else if (isNode) { + loadDependencies(require, module.exports, module); + } else if (!sinon) { + return; + } else { + makeApi(sinon); + } + }(typeof sinon == "object" && sinon || null)); + + /** + * @depend core.js + * @depend ../extend.js + * @depend event.js + * @depend ../log_error.js + */ + /** + * Fake XDomainRequest object + */ + + if (typeof sinon == "undefined") { + this.sinon = {}; + } + + // wrapper for global + (function (global) { + var xdr = { XDomainRequest: global.XDomainRequest }; + xdr.GlobalXDomainRequest = global.XDomainRequest; + xdr.supportsXDR = typeof xdr.GlobalXDomainRequest != "undefined"; + xdr.workingXDR = xdr.supportsXDR ? xdr.GlobalXDomainRequest : false; + + function makeApi(sinon) { + sinon.xdr = xdr; + + function FakeXDomainRequest() { + this.readyState = FakeXDomainRequest.UNSENT; + this.requestBody = null; + this.requestHeaders = {}; + this.status = 0; + this.timeout = null; + + if (typeof FakeXDomainRequest.onCreate == "function") { + FakeXDomainRequest.onCreate(this); + } + } + + function verifyState(xdr) { + if (xdr.readyState !== FakeXDomainRequest.OPENED) { + throw new Error("INVALID_STATE_ERR"); + } + + if (xdr.sendFlag) { + throw new Error("INVALID_STATE_ERR"); + } + } + + function verifyRequestSent(xdr) { + if (xdr.readyState == FakeXDomainRequest.UNSENT) { + throw new Error("Request not sent"); + } + if (xdr.readyState == FakeXDomainRequest.DONE) { + throw new Error("Request done"); + } + } + + function verifyResponseBodyType(body) { + if (typeof body != "string") { + var error = new Error("Attempted to respond to fake XDomainRequest with " + + body + ", which is not a string."); + error.name = "InvalidBodyException"; + throw error; + } + } + + sinon.extend(FakeXDomainRequest.prototype, sinon.EventTarget, { + open: function open(method, url) { + this.method = method; + this.url = url; + + this.responseText = null; + this.sendFlag = false; + + this.readyStateChange(FakeXDomainRequest.OPENED); + }, + + readyStateChange: function readyStateChange(state) { + this.readyState = state; + var eventName = ""; + switch (this.readyState) { + case FakeXDomainRequest.UNSENT: + break; + case FakeXDomainRequest.OPENED: + break; + case FakeXDomainRequest.LOADING: + if (this.sendFlag) { + //raise the progress event + eventName = "onprogress"; + } + break; + case FakeXDomainRequest.DONE: + if (this.isTimeout) { + eventName = "ontimeout" + } else if (this.errorFlag || (this.status < 200 || this.status > 299)) { + eventName = "onerror"; + } else { + eventName = "onload" + } + break; + } + + // raising event (if defined) + if (eventName) { + if (typeof this[eventName] == "function") { + try { + this[eventName](); + } catch (e) { + sinon.logError("Fake XHR " + eventName + " handler", e); + } + } + } + }, + + send: function send(data) { + verifyState(this); + + if (!/^(get|head)$/i.test(this.method)) { + this.requestBody = data; + } + this.requestHeaders["Content-Type"] = "text/plain;charset=utf-8"; + + this.errorFlag = false; + this.sendFlag = true; + this.readyStateChange(FakeXDomainRequest.OPENED); + + if (typeof this.onSend == "function") { + this.onSend(this); + } + }, + + abort: function abort() { + this.aborted = true; + this.responseText = null; + this.errorFlag = true; + + if (this.readyState > sinon.FakeXDomainRequest.UNSENT && this.sendFlag) { + this.readyStateChange(sinon.FakeXDomainRequest.DONE); + this.sendFlag = false; + } + }, + + setResponseBody: function setResponseBody(body) { + verifyRequestSent(this); + verifyResponseBodyType(body); + + var chunkSize = this.chunkSize || 10; + var index = 0; + this.responseText = ""; + + do { + this.readyStateChange(FakeXDomainRequest.LOADING); + this.responseText += body.substring(index, index + chunkSize); + index += chunkSize; + } while (index < body.length); + + this.readyStateChange(FakeXDomainRequest.DONE); + }, + + respond: function respond(status, contentType, body) { + // content-type ignored, since XDomainRequest does not carry this + // we keep the same syntax for respond(...) as for FakeXMLHttpRequest to ease + // test integration across browsers + this.status = typeof status == "number" ? status : 200; + this.setResponseBody(body || ""); + }, + + simulatetimeout: function simulatetimeout() { + this.status = 0; + this.isTimeout = true; + // Access to this should actually throw an error + this.responseText = undefined; + this.readyStateChange(FakeXDomainRequest.DONE); + } + }); + + sinon.extend(FakeXDomainRequest, { + UNSENT: 0, + OPENED: 1, + LOADING: 3, + DONE: 4 + }); + + sinon.useFakeXDomainRequest = function useFakeXDomainRequest() { + sinon.FakeXDomainRequest.restore = function restore(keepOnCreate) { + if (xdr.supportsXDR) { + global.XDomainRequest = xdr.GlobalXDomainRequest; + } + + delete sinon.FakeXDomainRequest.restore; + + if (keepOnCreate !== true) { + delete sinon.FakeXDomainRequest.onCreate; + } + }; + if (xdr.supportsXDR) { + global.XDomainRequest = sinon.FakeXDomainRequest; + } + return sinon.FakeXDomainRequest; + }; + + sinon.FakeXDomainRequest = FakeXDomainRequest; + } + + var isNode = typeof module !== "undefined" && module.exports && typeof require == "function"; + var isAMD = typeof define === "function" && typeof define.amd === "object" && define.amd; + + function loadDependencies(require, exports, module) { + var sinon = require("./core"); + require("../extend"); + require("./event"); + require("../log_error"); + makeApi(sinon); + module.exports = sinon; + } + + if (isAMD) { + define(loadDependencies); + } else if (isNode) { + loadDependencies(require, module.exports, module); + } else { + makeApi(sinon); + } + })(this); + + /** + * @depend core.js + * @depend ../extend.js + * @depend event.js + * @depend ../log_error.js + */ + /** + * Fake XMLHttpRequest object + * + * @author Christian Johansen (christian@cjohansen.no) + * @license BSD + * + * Copyright (c) 2010-2013 Christian Johansen + */ + + (function (global) { + + var supportsProgress = typeof ProgressEvent !== "undefined"; + var supportsCustomEvent = typeof CustomEvent !== "undefined"; + var sinonXhr = { XMLHttpRequest: global.XMLHttpRequest }; + sinonXhr.GlobalXMLHttpRequest = global.XMLHttpRequest; + sinonXhr.GlobalActiveXObject = global.ActiveXObject; + sinonXhr.supportsActiveX = typeof sinonXhr.GlobalActiveXObject != "undefined"; + sinonXhr.supportsXHR = typeof sinonXhr.GlobalXMLHttpRequest != "undefined"; + sinonXhr.workingXHR = sinonXhr.supportsXHR ? sinonXhr.GlobalXMLHttpRequest : sinonXhr.supportsActiveX + ? function () { return new sinonXhr.GlobalActiveXObject("MSXML2.XMLHTTP.3.0") } : false; + sinonXhr.supportsCORS = sinonXhr.supportsXHR && "withCredentials" in (new sinonXhr.GlobalXMLHttpRequest()); + + /*jsl:ignore*/ + var unsafeHeaders = { + "Accept-Charset": true, + "Accept-Encoding": true, + Connection: true, + "Content-Length": true, + Cookie: true, + Cookie2: true, + "Content-Transfer-Encoding": true, + Date: true, + Expect: true, + Host: true, + "Keep-Alive": true, + Referer: true, + TE: true, + Trailer: true, + "Transfer-Encoding": true, + Upgrade: true, + "User-Agent": true, + Via: true + }; + /*jsl:end*/ + + function FakeXMLHttpRequest() { + this.readyState = FakeXMLHttpRequest.UNSENT; + this.requestHeaders = {}; + this.requestBody = null; + this.status = 0; + this.statusText = ""; + this.upload = new UploadProgress(); + if (sinonXhr.supportsCORS) { + this.withCredentials = false; + } + + var xhr = this; + var events = ["loadstart", "load", "abort", "loadend"]; + + function addEventListener(eventName) { + xhr.addEventListener(eventName, function (event) { + var listener = xhr["on" + eventName]; + + if (listener && typeof listener == "function") { + listener.call(this, event); + } + }); + } + + for (var i = events.length - 1; i >= 0; i--) { + addEventListener(events[i]); + } + + if (typeof FakeXMLHttpRequest.onCreate == "function") { + FakeXMLHttpRequest.onCreate(this); + } + } + + // An upload object is created for each + // FakeXMLHttpRequest and allows upload + // events to be simulated using uploadProgress + // and uploadError. + function UploadProgress() { + this.eventListeners = { + progress: [], + load: [], + abort: [], + error: [] + } + } + + UploadProgress.prototype.addEventListener = function addEventListener(event, listener) { + this.eventListeners[event].push(listener); + }; + + UploadProgress.prototype.removeEventListener = function removeEventListener(event, listener) { + var listeners = this.eventListeners[event] || []; + + for (var i = 0, l = listeners.length; i < l; ++i) { + if (listeners[i] == listener) { + return listeners.splice(i, 1); + } + } + }; + + UploadProgress.prototype.dispatchEvent = function dispatchEvent(event) { + var listeners = this.eventListeners[event.type] || []; + + for (var i = 0, listener; (listener = listeners[i]) != null; i++) { + listener(event); + } + }; + + function verifyState(xhr) { + if (xhr.readyState !== FakeXMLHttpRequest.OPENED) { + throw new Error("INVALID_STATE_ERR"); + } + + if (xhr.sendFlag) { + throw new Error("INVALID_STATE_ERR"); + } + } + + function getHeader(headers, header) { + header = header.toLowerCase(); + + for (var h in headers) { + if (h.toLowerCase() == header) { + return h; + } + } + + return null; + } + + // filtering to enable a white-list version of Sinon FakeXhr, + // where whitelisted requests are passed through to real XHR + function each(collection, callback) { + if (!collection) { + return; + } + + for (var i = 0, l = collection.length; i < l; i += 1) { + callback(collection[i]); + } + } + function some(collection, callback) { + for (var index = 0; index < collection.length; index++) { + if (callback(collection[index]) === true) { + return true; + } + } + return false; + } + // largest arity in XHR is 5 - XHR#open + var apply = function (obj, method, args) { + switch (args.length) { + case 0: return obj[method](); + case 1: return obj[method](args[0]); + case 2: return obj[method](args[0], args[1]); + case 3: return obj[method](args[0], args[1], args[2]); + case 4: return obj[method](args[0], args[1], args[2], args[3]); + case 5: return obj[method](args[0], args[1], args[2], args[3], args[4]); + } + }; + + FakeXMLHttpRequest.filters = []; + FakeXMLHttpRequest.addFilter = function addFilter(fn) { + this.filters.push(fn) + }; + // ##### BEGIN OF MODIFICATION BY SAP + //var IE6Re = /MSIE 6/; + // Fix in SAP internally used Sinon.JS version: + // In the newest Sinon, errors are only suppressed for user agents matching /MSIE 6/, + // so IE7-IE9 throw an exception: a broader RegExp needs to be used for IE7-IE9 + var IE6to9Re = /MSIE [6-9]/; + // ##### END OF MODIFICATION BY SAP + FakeXMLHttpRequest.defake = function defake(fakeXhr, xhrArgs) { + var xhr = new sinonXhr.workingXHR(); + each([ + "open", + "setRequestHeader", + "send", + "abort", + "getResponseHeader", + "getAllResponseHeaders", + "addEventListener", + "overrideMimeType", + "removeEventListener" + ], function (method) { + fakeXhr[method] = function () { + return apply(xhr, method, arguments); + }; + }); + + var copyAttrs = function (args) { + each(args, function (attr) { + try { + fakeXhr[attr] = xhr[attr] + } catch (e) { + // ##### BEGIN OF MODIFICATION BY SAP + //if (!IE6Re.test(navigator.userAgent)) { + // Sinon.JS does not respect https://msdn.microsoft.com/en-us/library/ms753800(v=vs.85).aspx saying: + // In MSXML 3.0 and MSXML 6.0, reading the status property after loading has commenced but has not + // yet completed (for example, at the LOADED or INTERACTIVE state) returns the following error: + // "The data necessary to complete this operation is not yet available." + if (!IE6to9Re.test(navigator.userAgent) + && "The data necessary to complete this operation is not yet available.\r\n" !== e.message) { + // ##### END OF MODIFICATION BY SAP + throw e; + } + } + }); + }; + + var stateChange = function stateChange() { + fakeXhr.readyState = xhr.readyState; + if (xhr.readyState >= FakeXMLHttpRequest.HEADERS_RECEIVED) { + copyAttrs(["status", "statusText"]); + } + if (xhr.readyState >= FakeXMLHttpRequest.LOADING) { + copyAttrs(["responseText", "response"]); + } + if (xhr.readyState === FakeXMLHttpRequest.DONE) { + copyAttrs(["responseXML"]); + } + if (fakeXhr.onreadystatechange) { + fakeXhr.onreadystatechange.call(fakeXhr, { target: fakeXhr }); + } + }; + + if (xhr.addEventListener) { + for (var event in fakeXhr.eventListeners) { + if (fakeXhr.eventListeners.hasOwnProperty(event)) { + each(fakeXhr.eventListeners[event], function (handler) { + xhr.addEventListener(event, handler); + }); + } + } + xhr.addEventListener("readystatechange", stateChange); + } else { + xhr.onreadystatechange = stateChange; + } + apply(xhr, "open", xhrArgs); + }; + FakeXMLHttpRequest.useFilters = false; + + function verifyRequestOpened(xhr) { + if (xhr.readyState != FakeXMLHttpRequest.OPENED) { + throw new Error("INVALID_STATE_ERR - " + xhr.readyState); + } + } + + function verifyRequestSent(xhr) { + if (xhr.readyState == FakeXMLHttpRequest.DONE) { + throw new Error("Request done"); + } + } + + function verifyHeadersReceived(xhr) { + if (xhr.async && xhr.readyState != FakeXMLHttpRequest.HEADERS_RECEIVED) { + throw new Error("No headers received"); + } + } + + function verifyResponseBodyType(body) { + if (typeof body != "string") { + var error = new Error("Attempted to respond to fake XMLHttpRequest with " + + body + ", which is not a string."); + error.name = "InvalidBodyException"; + throw error; + } + } + + FakeXMLHttpRequest.parseXML = function parseXML(text) { + var xmlDoc; + + if (typeof DOMParser != "undefined") { + var parser = new DOMParser(); + xmlDoc = parser.parseFromString(text, "text/xml"); + } else { + xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); + xmlDoc.async = "false"; + xmlDoc.loadXML(text); + } + + return xmlDoc; + }; + + FakeXMLHttpRequest.statusCodes = { + 100: "Continue", + 101: "Switching Protocols", + 200: "OK", + 201: "Created", + 202: "Accepted", + 203: "Non-Authoritative Information", + 204: "No Content", + 205: "Reset Content", + 206: "Partial Content", + 207: "Multi-Status", + 300: "Multiple Choice", + 301: "Moved Permanently", + 302: "Found", + 303: "See Other", + 304: "Not Modified", + 305: "Use Proxy", + 307: "Temporary Redirect", + 400: "Bad Request", + 401: "Unauthorized", + 402: "Payment Required", + 403: "Forbidden", + 404: "Not Found", + 405: "Method Not Allowed", + 406: "Not Acceptable", + 407: "Proxy Authentication Required", + 408: "Request Timeout", + 409: "Conflict", + 410: "Gone", + 411: "Length Required", + 412: "Precondition Failed", + 413: "Request Entity Too Large", + 414: "Request-URI Too Long", + 415: "Unsupported Media Type", + 416: "Requested Range Not Satisfiable", + 417: "Expectation Failed", + 422: "Unprocessable Entity", + 500: "Internal Server Error", + 501: "Not Implemented", + 502: "Bad Gateway", + 503: "Service Unavailable", + 504: "Gateway Timeout", + 505: "HTTP Version Not Supported" + }; + + function makeApi(sinon) { + sinon.xhr = sinonXhr; + + sinon.extend(FakeXMLHttpRequest.prototype, sinon.EventTarget, { + async: true, + + open: function open(method, url, async, username, password) { + this.method = method; + this.url = url; + this.async = typeof async == "boolean" ? async : true; + this.username = username; + this.password = password; + this.responseText = null; + this.responseXML = null; + this.requestHeaders = {}; + this.sendFlag = false; + + if (FakeXMLHttpRequest.useFilters === true) { + var xhrArgs = arguments; + var defake = some(FakeXMLHttpRequest.filters, function (filter) { + return filter.apply(this, xhrArgs) + }); + if (defake) { + return FakeXMLHttpRequest.defake(this, arguments); + } + } + this.readyStateChange(FakeXMLHttpRequest.OPENED); + }, + + readyStateChange: function readyStateChange(state) { + this.readyState = state; + + if (typeof this.onreadystatechange == "function") { + try { + this.onreadystatechange(); + } catch (e) { + sinon.logError("Fake XHR onreadystatechange handler", e); + } + } + + this.dispatchEvent(new sinon.Event("readystatechange")); + + switch (this.readyState) { + case FakeXMLHttpRequest.DONE: + this.dispatchEvent(new sinon.Event("load", false, false, this)); + this.dispatchEvent(new sinon.Event("loadend", false, false, this)); + this.upload.dispatchEvent(new sinon.Event("load", false, false, this)); + if (supportsProgress) { + this.upload.dispatchEvent(new sinon.ProgressEvent("progress", {loaded: 100, total: 100})); + this.dispatchEvent(new sinon.ProgressEvent("progress", {loaded: 100, total: 100})); + } + break; + } + }, + + setRequestHeader: function setRequestHeader(header, value) { + verifyState(this); + + if (unsafeHeaders[header] || /^(Sec-|Proxy-)/.test(header)) { + throw new Error("Refused to set unsafe header \"" + header + "\""); + } + + if (this.requestHeaders[header]) { + this.requestHeaders[header] += "," + value; + } else { + this.requestHeaders[header] = value; + } + }, + + // Helps testing + setResponseHeaders: function setResponseHeaders(headers) { + verifyRequestOpened(this); + this.responseHeaders = {}; + + for (var header in headers) { + if (headers.hasOwnProperty(header)) { + this.responseHeaders[header] = headers[header]; + } + } + + if (this.async) { + this.readyStateChange(FakeXMLHttpRequest.HEADERS_RECEIVED); + } else { + this.readyState = FakeXMLHttpRequest.HEADERS_RECEIVED; + } + }, + + // Currently treats ALL data as a DOMString (i.e. no Document) + send: function send(data) { + verifyState(this); + + if (!/^(get|head)$/i.test(this.method)) { + var contentType = getHeader(this.requestHeaders, "Content-Type"); + if (this.requestHeaders[contentType]) { + var value = this.requestHeaders[contentType].split(";"); + this.requestHeaders[contentType] = value[0] + ";charset=utf-8"; + } else if (!(data instanceof FormData)) { + this.requestHeaders["Content-Type"] = "text/plain;charset=utf-8"; + } + + this.requestBody = data; + } + + this.errorFlag = false; + this.sendFlag = this.async; + this.readyStateChange(FakeXMLHttpRequest.OPENED); + + if (typeof this.onSend == "function") { + this.onSend(this); + } + + this.dispatchEvent(new sinon.Event("loadstart", false, false, this)); + }, + + abort: function abort() { + this.aborted = true; + this.responseText = null; + this.errorFlag = true; + this.requestHeaders = {}; + + if (this.readyState > FakeXMLHttpRequest.UNSENT && this.sendFlag) { + this.readyStateChange(FakeXMLHttpRequest.DONE); + this.sendFlag = false; + } + + this.readyState = FakeXMLHttpRequest.UNSENT; + + this.dispatchEvent(new sinon.Event("abort", false, false, this)); + + this.upload.dispatchEvent(new sinon.Event("abort", false, false, this)); + + if (typeof this.onerror === "function") { + this.onerror(); + } + }, + + getResponseHeader: function getResponseHeader(header) { + if (this.readyState < FakeXMLHttpRequest.HEADERS_RECEIVED) { + return null; + } + + if (/^Set-Cookie2?$/i.test(header)) { + return null; + } + + header = getHeader(this.responseHeaders, header); + + return this.responseHeaders[header] || null; + }, + + getAllResponseHeaders: function getAllResponseHeaders() { + if (this.readyState < FakeXMLHttpRequest.HEADERS_RECEIVED) { + return ""; + } + + var headers = ""; + + for (var header in this.responseHeaders) { + if (this.responseHeaders.hasOwnProperty(header) && + !/^Set-Cookie2?$/i.test(header)) { + headers += header + ": " + this.responseHeaders[header] + "\r\n"; + } + } + + return headers; + }, + + setResponseBody: function setResponseBody(body) { + verifyRequestSent(this); + verifyHeadersReceived(this); + verifyResponseBodyType(body); + + var chunkSize = this.chunkSize || 10; + var index = 0; + this.responseText = ""; + + do { + if (this.async) { + this.readyStateChange(FakeXMLHttpRequest.LOADING); + } + + this.responseText += body.substring(index, index + chunkSize); + index += chunkSize; + } while (index < body.length); + + var type = this.getResponseHeader("Content-Type"); + + if (this.responseText && + (!type || /(text\/xml)|(application\/xml)|(\+xml)/.test(type))) { + try { + this.responseXML = FakeXMLHttpRequest.parseXML(this.responseText); + } catch (e) { + // Unable to parse XML - no biggie + } + } + + this.readyStateChange(FakeXMLHttpRequest.DONE); + }, + + respond: function respond(status, headers, body) { + this.status = typeof status == "number" ? status : 200; + this.statusText = FakeXMLHttpRequest.statusCodes[this.status]; + this.setResponseHeaders(headers || {}); + this.setResponseBody(body || ""); + }, + + uploadProgress: function uploadProgress(progressEventRaw) { + if (supportsProgress) { + this.upload.dispatchEvent(new sinon.ProgressEvent("progress", progressEventRaw)); + } + }, + + downloadProgress: function downloadProgress(progressEventRaw) { + if (supportsProgress) { + this.dispatchEvent(new sinon.ProgressEvent("progress", progressEventRaw)); + } + }, + + uploadError: function uploadError(error) { + if (supportsCustomEvent) { + this.upload.dispatchEvent(new sinon.CustomEvent("error", {detail: error})); + } + } + }); + + sinon.extend(FakeXMLHttpRequest, { + UNSENT: 0, + OPENED: 1, + HEADERS_RECEIVED: 2, + LOADING: 3, + DONE: 4 + }); + + sinon.useFakeXMLHttpRequest = function () { + FakeXMLHttpRequest.restore = function restore(keepOnCreate) { + if (sinonXhr.supportsXHR) { + global.XMLHttpRequest = sinonXhr.GlobalXMLHttpRequest; + } + + if (sinonXhr.supportsActiveX) { + global.ActiveXObject = sinonXhr.GlobalActiveXObject; + } + + delete FakeXMLHttpRequest.restore; + + if (keepOnCreate !== true) { + delete FakeXMLHttpRequest.onCreate; + } + }; + if (sinonXhr.supportsXHR) { + global.XMLHttpRequest = FakeXMLHttpRequest; + } + + if (sinonXhr.supportsActiveX) { + global.ActiveXObject = function ActiveXObject(objId) { + if (objId == "Microsoft.XMLHTTP" || /^Msxml2\.XMLHTTP/i.test(objId)) { + + return new FakeXMLHttpRequest(); + } + + return new sinonXhr.GlobalActiveXObject(objId); + }; + } + + return FakeXMLHttpRequest; + }; + + sinon.FakeXMLHttpRequest = FakeXMLHttpRequest; + } + + var isNode = typeof module !== "undefined" && module.exports && typeof require == "function"; + var isAMD = typeof define === "function" && typeof define.amd === "object" && define.amd; + + function loadDependencies(require, exports, module) { + var sinon = require("./core"); + require("../extend"); + require("./event"); + require("../log_error"); + makeApi(sinon); + module.exports = sinon; + } + + if (isAMD) { + define(loadDependencies); + } else if (isNode) { + loadDependencies(require, module.exports, module); + } else if (typeof sinon === "undefined") { + return; + } else { + makeApi(sinon); + } + + })(typeof global !== "undefined" ? global : this); + + /** + * @depend fake_xdomain_request.js + * @depend fake_xml_http_request.js + * @depend ../format.js + * @depend ../log_error.js + */ + /** + * The Sinon "server" mimics a web server that receives requests from + * sinon.FakeXMLHttpRequest and provides an API to respond to those requests, + * both synchronously and asynchronously. To respond synchronuously, canned + * answers have to be provided upfront. + * + * @author Christian Johansen (christian@cjohansen.no) + * @license BSD + * + * Copyright (c) 2010-2013 Christian Johansen + */ + + if (typeof sinon == "undefined") { + var sinon = {}; + } + + (function () { + var push = [].push; + function F() {} + + function create(proto) { + F.prototype = proto; + return new F(); + } + + function responseArray(handler) { + var response = handler; + + if (Object.prototype.toString.call(handler) != "[object Array]") { + response = [200, {}, handler]; + } + + if (typeof response[2] != "string") { + throw new TypeError("Fake server response body should be string, but was " + + typeof response[2]); + } + + return response; + } + + var wloc = typeof window !== "undefined" ? window.location : {}; + var rCurrLoc = new RegExp("^" + wloc.protocol + "//" + wloc.host); + + function matchOne(response, reqMethod, reqUrl) { + var rmeth = response.method; + var matchMethod = !rmeth || rmeth.toLowerCase() == reqMethod.toLowerCase(); + var url = response.url; + var matchUrl = !url || url == reqUrl || (typeof url.test == "function" && url.test(reqUrl)); + + return matchMethod && matchUrl; + } + + function match(response, request) { + var requestUrl = request.url; + + if (!/^https?:\/\//.test(requestUrl) || rCurrLoc.test(requestUrl)) { + requestUrl = requestUrl.replace(rCurrLoc, ""); + } + + if (matchOne(response, this.getHTTPMethod(request), requestUrl)) { + if (typeof response.response == "function") { + var ru = response.url; + var args = [request].concat(ru && typeof ru.exec == "function" ? ru.exec(requestUrl).slice(1) : []); + return response.response.apply(response, args); + } + + return true; + } + + return false; + } + + function makeApi(sinon) { + sinon.fakeServer = { + create: function () { + var server = create(this); + if (!sinon.xhr.supportsCORS) { + this.xhr = sinon.useFakeXDomainRequest(); + } else { + this.xhr = sinon.useFakeXMLHttpRequest(); + } + server.requests = []; + + this.xhr.onCreate = function (xhrObj) { + server.addRequest(xhrObj); + }; + + return server; + }, + + addRequest: function addRequest(xhrObj) { + var server = this; + push.call(this.requests, xhrObj); + + xhrObj.onSend = function () { + server.handleRequest(this); + + if (server.respondImmediately) { + server.respond(); + } else if (server.autoRespond && !server.responding) { + setTimeout(function () { + server.responding = false; + server.respond(); + }, server.autoRespondAfter || 10); + + server.responding = true; + } + }; + }, + + getHTTPMethod: function getHTTPMethod(request) { + if (this.fakeHTTPMethods && /post/i.test(request.method)) { + var matches = (request.requestBody || "").match(/_method=([^\b;]+)/); + return !!matches ? matches[1] : request.method; + } + + return request.method; + }, + + handleRequest: function handleRequest(xhr) { + if (xhr.async) { + if (!this.queue) { + this.queue = []; + } + + push.call(this.queue, xhr); + } else { + this.processRequest(xhr); + } + }, + + log: function log(response, request) { + var str; + + str = "Request:\n" + sinon.format(request) + "\n\n"; + str += "Response:\n" + sinon.format(response) + "\n\n"; + + sinon.log(str); + }, + + respondWith: function respondWith(method, url, body) { + if (arguments.length == 1 && typeof method != "function") { + this.response = responseArray(method); + return; + } + + if (!this.responses) { this.responses = []; } + + if (arguments.length == 1) { + body = method; + url = method = null; + } + + if (arguments.length == 2) { + body = url; + url = method; + method = null; + } + + push.call(this.responses, { + method: method, + url: url, + response: typeof body == "function" ? body : responseArray(body) + }); + }, + + respond: function respond() { + if (arguments.length > 0) { + this.respondWith.apply(this, arguments); + } + + var queue = this.queue || []; + var requests = queue.splice(0, queue.length); + var request; + + while (request = requests.shift()) { + this.processRequest(request); + } + }, + + processRequest: function processRequest(request) { + try { + if (request.aborted) { + return; + } + + var response = this.response || [404, {}, ""]; + + if (this.responses) { + for (var l = this.responses.length, i = l - 1; i >= 0; i--) { + if (match.call(this, this.responses[i], request)) { + response = this.responses[i].response; + break; + } + } + } + + if (request.readyState != 4) { + this.log(response, request); + + request.respond(response[0], response[1], response[2]); + } + } catch (e) { + sinon.logError("Fake server request processing", e); + } + }, + + restore: function restore() { + return this.xhr.restore && this.xhr.restore.apply(this.xhr, arguments); + } + }; + } + + var isNode = typeof module !== "undefined" && module.exports && typeof require == "function"; + var isAMD = typeof define === "function" && typeof define.amd === "object" && define.amd; + + function loadDependencies(require, exports, module) { + var sinon = require("./core"); + require("./fake_xdomain_request"); + require("./fake_xml_http_request"); + require("../format"); + makeApi(sinon); + module.exports = sinon; + } + + if (isAMD) { + define(loadDependencies); + } else if (isNode) { + loadDependencies(require, module.exports, module); + } else { + makeApi(sinon); + } + }()); + + /** + * @depend fake_server.js + * @depend fake_timers.js + */ + /** + * Add-on for sinon.fakeServer that automatically handles a fake timer along with + * the FakeXMLHttpRequest. The direct inspiration for this add-on is jQuery + * 1.3.x, which does not use xhr object's onreadystatehandler at all - instead, + * it polls the object for completion with setInterval. Dispite the direct + * motivation, there is nothing jQuery-specific in this file, so it can be used + * in any environment where the ajax implementation depends on setInterval or + * setTimeout. + * + * @author Christian Johansen (christian@cjohansen.no) + * @license BSD + * + * Copyright (c) 2010-2013 Christian Johansen + */ + + (function () { + function makeApi(sinon) { + function Server() {} + Server.prototype = sinon.fakeServer; + + sinon.fakeServerWithClock = new Server(); + + sinon.fakeServerWithClock.addRequest = function addRequest(xhr) { + if (xhr.async) { + if (typeof setTimeout.clock == "object") { + this.clock = setTimeout.clock; + } else { + this.clock = sinon.useFakeTimers(); + this.resetClock = true; + } + + if (!this.longestTimeout) { + var clockSetTimeout = this.clock.setTimeout; + var clockSetInterval = this.clock.setInterval; + var server = this; + + this.clock.setTimeout = function (fn, timeout) { + server.longestTimeout = Math.max(timeout, server.longestTimeout || 0); + + return clockSetTimeout.apply(this, arguments); + }; + + this.clock.setInterval = function (fn, timeout) { + server.longestTimeout = Math.max(timeout, server.longestTimeout || 0); + + return clockSetInterval.apply(this, arguments); + }; + } + } + + return sinon.fakeServer.addRequest.call(this, xhr); + }; + + sinon.fakeServerWithClock.respond = function respond() { + var returnVal = sinon.fakeServer.respond.apply(this, arguments); + + if (this.clock) { + this.clock.tick(this.longestTimeout || 0); + this.longestTimeout = 0; + + if (this.resetClock) { + this.clock.restore(); + this.resetClock = false; + } + } + + return returnVal; + }; + + sinon.fakeServerWithClock.restore = function restore() { + if (this.clock) { + this.clock.restore(); + } + + return sinon.fakeServer.restore.apply(this, arguments); + }; + } + + var isNode = typeof module !== "undefined" && module.exports && typeof require == "function"; + var isAMD = typeof define === "function" && typeof define.amd === "object" && define.amd; + + function loadDependencies(require) { + var sinon = require("./core"); + require("./fake_server"); + require("./fake_timers"); + makeApi(sinon); + } + + if (isAMD) { + define(loadDependencies); + } else if (isNode) { + loadDependencies(require); + } else { + makeApi(sinon); + } + }()); + + /** + * @depend util/core.js + * @depend extend.js + * @depend collection.js + * @depend util/fake_timers.js + * @depend util/fake_server_with_clock.js + */ + /** + * Manages fake collections as well as fake utilities such as Sinon's + * timers and fake XHR implementation in one convenient object. + * + * @author Christian Johansen (christian@cjohansen.no) + * @license BSD + * + * Copyright (c) 2010-2013 Christian Johansen + */ + + (function () { + function makeApi(sinon) { + var push = [].push; + + function exposeValue(sandbox, config, key, value) { + if (!value) { + return; + } + + if (config.injectInto && !(key in config.injectInto)) { + config.injectInto[key] = value; + sandbox.injectedKeys.push(key); + } else { + push.call(sandbox.args, value); + } + } + + function prepareSandboxFromConfig(config) { + var sandbox = sinon.create(sinon.sandbox); + + if (config.useFakeServer) { + if (typeof config.useFakeServer == "object") { + sandbox.serverPrototype = config.useFakeServer; + } + + sandbox.useFakeServer(); + } + + if (config.useFakeTimers) { + if (typeof config.useFakeTimers == "object") { + sandbox.useFakeTimers.apply(sandbox, config.useFakeTimers); + } else { + sandbox.useFakeTimers(); + } + } + + return sandbox; + } + + sinon.sandbox = sinon.extend(sinon.create(sinon.collection), { + useFakeTimers: function useFakeTimers() { + this.clock = sinon.useFakeTimers.apply(sinon, arguments); + + return this.add(this.clock); + }, + + serverPrototype: sinon.fakeServer, + + useFakeServer: function useFakeServer() { + var proto = this.serverPrototype || sinon.fakeServer; + + if (!proto || !proto.create) { + return null; + } + + this.server = proto.create(); + return this.add(this.server); + }, + + inject: function (obj) { + sinon.collection.inject.call(this, obj); + + if (this.clock) { + obj.clock = this.clock; + } + + if (this.server) { + obj.server = this.server; + obj.requests = this.server.requests; + } + + obj.match = sinon.match; + + return obj; + }, + + restore: function () { + sinon.collection.restore.apply(this, arguments); + this.restoreContext(); + }, + + restoreContext: function () { + if (this.injectedKeys) { + for (var i = 0, j = this.injectedKeys.length; i < j; i++) { + delete this.injectInto[this.injectedKeys[i]]; + } + this.injectedKeys = []; + } + }, + + create: function (config) { + if (!config) { + return sinon.create(sinon.sandbox); + } + + var sandbox = prepareSandboxFromConfig(config); + sandbox.args = sandbox.args || []; + sandbox.injectedKeys = []; + sandbox.injectInto = config.injectInto; + var prop, value, exposed = sandbox.inject({}); + + if (config.properties) { + for (var i = 0, l = config.properties.length; i < l; i++) { + prop = config.properties[i]; + value = exposed[prop] || prop == "sandbox" && sandbox; + exposeValue(sandbox, config, prop, value); + } + } else { + exposeValue(sandbox, config, "sandbox", value); + } + + return sandbox; + }, + + match: sinon.match + }); + + sinon.sandbox.useFakeXMLHttpRequest = sinon.sandbox.useFakeServer; + + return sinon.sandbox; + } + + var isNode = typeof module !== "undefined" && module.exports && typeof require == "function"; + var isAMD = typeof define === "function" && typeof define.amd === "object" && define.amd; + + function loadDependencies(require, exports, module) { + var sinon = require("./util/core"); + require("./extend"); + require("./util/fake_server_with_clock"); + require("./util/fake_timers"); + require("./collection"); + module.exports = makeApi(sinon); + } + + if (isAMD) { + define(loadDependencies); + } else if (isNode) { + loadDependencies(require, module.exports, module); + } else if (!sinon) { + return; + } else { + makeApi(sinon); + } + }()); + + /** + * @depend util/core.js + * @depend sandbox.js + */ + /** + * Test function, sandboxes fakes + * + * @author Christian Johansen (christian@cjohansen.no) + * @license BSD + * + * Copyright (c) 2010-2013 Christian Johansen + */ + + (function (sinon) { + function makeApi(sinon) { + var slice = Array.prototype.slice; + + function test(callback) { + var type = typeof callback; + + if (type != "function") { + throw new TypeError("sinon.test needs to wrap a test function, got " + type); + } + + function sinonSandboxedTest() { + var config = sinon.getConfig(sinon.config); + config.injectInto = config.injectIntoThis && this || config.injectInto; + var sandbox = sinon.sandbox.create(config); + var args = slice.call(arguments); + var oldDone = args.length && args[args.length - 1]; + var exception, result; + + if (typeof oldDone == "function") { + args[args.length - 1] = function sinonDone(result) { + if (result) { + sandbox.restore(); + throw exception; + } else { + sandbox.verifyAndRestore(); + } + oldDone(result); + }; + } + + try { + result = callback.apply(this, args.concat(sandbox.args)); + } catch (e) { + exception = e; + } + + if (typeof oldDone != "function") { + // ##### BEGIN OF MODIFICATION BY SAP + // @see https://github.com/sinonjs/sinon-test/issues/6 + if (result && typeof result.then === "function") { + return result.then(function (result) { + sandbox.verifyAndRestore(); + return result; + }, function (exception) { + sandbox.restore(); + throw exception; + }); + } + // ##### END OF MODIFICATION BY SAP + if (typeof exception !== "undefined") { + sandbox.restore(); + throw exception; + } else { + sandbox.verifyAndRestore(); + } + } + + return result; + } + + if (callback.length) { + return function sinonAsyncSandboxedTest(callback) { + return sinonSandboxedTest.apply(this, arguments); + }; + } + + return sinonSandboxedTest; + } + + test.config = { + injectIntoThis: true, + injectInto: null, + properties: ["spy", "stub", "mock", "clock", "server", "requests"], + useFakeTimers: true, + useFakeServer: true + }; + + sinon.test = test; + return test; + } + + var isNode = typeof module !== "undefined" && module.exports && typeof require == "function"; + var isAMD = typeof define === "function" && typeof define.amd === "object" && define.amd; + + function loadDependencies(require, exports, module) { + var sinon = require("./util/core"); + require("./sandbox"); + module.exports = makeApi(sinon); + } + + if (isAMD) { + define(loadDependencies); + } else if (isNode) { + loadDependencies(require, module.exports, module); + } else if (sinon) { + makeApi(sinon); + } + }(typeof sinon == "object" && sinon || null)); + + /** + * @depend util/core.js + * @depend test.js + */ + /** + * Test case, sandboxes all test functions + * + * @author Christian Johansen (christian@cjohansen.no) + * @license BSD + * + * Copyright (c) 2010-2013 Christian Johansen + */ + + (function (sinon) { + function createTest(property, setUp, tearDown) { + return function () { + if (setUp) { + setUp.apply(this, arguments); + } + + var exception, result; + + try { + result = property.apply(this, arguments); + } catch (e) { + exception = e; + } + + if (tearDown) { + tearDown.apply(this, arguments); + } + + if (exception) { + throw exception; + } + + return result; + }; + } + + function makeApi(sinon) { + function testCase(tests, prefix) { + /*jsl:ignore*/ + if (!tests || typeof tests != "object") { + throw new TypeError("sinon.testCase needs an object with test functions"); + } + /*jsl:end*/ + + prefix = prefix || "test"; + var rPrefix = new RegExp("^" + prefix); + var methods = {}, testName, property, method; + var setUp = tests.setUp; + var tearDown = tests.tearDown; + + for (testName in tests) { + if (tests.hasOwnProperty(testName)) { + property = tests[testName]; + + if (/^(setUp|tearDown)$/.test(testName)) { + continue; + } + + if (typeof property == "function" && rPrefix.test(testName)) { + method = property; + + if (setUp || tearDown) { + method = createTest(property, setUp, tearDown); + } + + methods[testName] = sinon.test(method); + } else { + methods[testName] = tests[testName]; + } + } + } + + return methods; + } + + sinon.testCase = testCase; + return testCase; + } + + var isNode = typeof module !== "undefined" && module.exports && typeof require == "function"; + var isAMD = typeof define === "function" && typeof define.amd === "object" && define.amd; + + function loadDependencies(require, exports, module) { + var sinon = require("./util/core"); + require("./test"); + module.exports = makeApi(sinon); + } + + if (isAMD) { + define(loadDependencies); + } else if (isNode) { + loadDependencies(require, module.exports, module); + } else if (!sinon) { + return; + } else { + makeApi(sinon); + } + }(typeof sinon == "object" && sinon || null)); + + /** + * @depend times_in_words.js + * @depend util/core.js + * @depend match.js + * @depend format.js + */ + /** + * Assertions matching the test spy retrieval interface. + * + * @author Christian Johansen (christian@cjohansen.no) + * @license BSD + * + * Copyright (c) 2010-2013 Christian Johansen + */ + + (function (sinon, global) { + var slice = Array.prototype.slice; + + function makeApi(sinon) { + var assert; + + function verifyIsStub() { + var method; + + for (var i = 0, l = arguments.length; i < l; ++i) { + method = arguments[i]; + + if (!method) { + assert.fail("fake is not a spy"); + } + + if (method.proxy) { + verifyIsStub(method.proxy); + } else { + if (typeof method != "function") { + assert.fail(method + " is not a function"); + } + + if (typeof method.getCall != "function") { + assert.fail(method + " is not stubbed"); + } + } + + } + } + + function failAssertion(object, msg) { + object = object || global; + var failMethod = object.fail || assert.fail; + failMethod.call(object, msg); + } + + function mirrorPropAsAssertion(name, method, message) { + if (arguments.length == 2) { + message = method; + method = name; + } + + assert[name] = function (fake) { + verifyIsStub(fake); + + var args = slice.call(arguments, 1); + var failed = false; + + if (typeof method == "function") { + failed = !method(fake); + } else { + failed = typeof fake[method] == "function" ? + !fake[method].apply(fake, args) : !fake[method]; + } + + if (failed) { + failAssertion(this, (fake.printf || fake.proxy.printf).apply(fake, [message].concat(args))); + } else { + assert.pass(name); + } + }; + } + + function exposedName(prefix, prop) { + return !prefix || /^fail/.test(prop) ? prop : + prefix + prop.slice(0, 1).toUpperCase() + prop.slice(1); + } + + assert = { + failException: "AssertError", + + fail: function fail(message) { + var error = new Error(message); + error.name = this.failException || assert.failException; + + throw error; + }, + + pass: function pass(assertion) {}, + + callOrder: function assertCallOrder() { + verifyIsStub.apply(null, arguments); + var expected = "", actual = ""; + + if (!sinon.calledInOrder(arguments)) { + try { + expected = [].join.call(arguments, ", "); + var calls = slice.call(arguments); + var i = calls.length; + while (i) { + if (!calls[--i].called) { + calls.splice(i, 1); + } + } + actual = sinon.orderByFirstCall(calls).join(", "); + } catch (e) { + // If this fails, we'll just fall back to the blank string + } + + failAssertion(this, "expected " + expected + " to be " + + "called in order but were called as " + actual); + } else { + assert.pass("callOrder"); + } + }, + + callCount: function assertCallCount(method, count) { + verifyIsStub(method); + + if (method.callCount != count) { + var msg = "expected %n to be called " + sinon.timesInWords(count) + + " but was called %c%C"; + failAssertion(this, method.printf(msg)); + } else { + assert.pass("callCount"); + } + }, + + expose: function expose(target, options) { + if (!target) { + throw new TypeError("target is null or undefined"); + } + + var o = options || {}; + var prefix = typeof o.prefix == "undefined" && "assert" || o.prefix; + var includeFail = typeof o.includeFail == "undefined" || !!o.includeFail; + + for (var method in this) { + if (method != "expose" && (includeFail || !/^(fail)/.test(method))) { + target[exposedName(prefix, method)] = this[method]; + } + } + + return target; + }, + + match: function match(actual, expectation) { + var matcher = sinon.match(expectation); + if (matcher.test(actual)) { + assert.pass("match"); + } else { + var formatted = [ + "expected value to match", + " expected = " + sinon.format(expectation), + " actual = " + sinon.format(actual) + ] + failAssertion(this, formatted.join("\n")); + } + } + }; + + mirrorPropAsAssertion("called", "expected %n to have been called at least once but was never called"); + mirrorPropAsAssertion("notCalled", function (spy) { return !spy.called; }, + "expected %n to not have been called but was called %c%C"); + mirrorPropAsAssertion("calledOnce", "expected %n to be called once but was called %c%C"); + mirrorPropAsAssertion("calledTwice", "expected %n to be called twice but was called %c%C"); + mirrorPropAsAssertion("calledThrice", "expected %n to be called thrice but was called %c%C"); + mirrorPropAsAssertion("calledOn", "expected %n to be called with %1 as this but was called with %t"); + mirrorPropAsAssertion("alwaysCalledOn", "expected %n to always be called with %1 as this but was called with %t"); + mirrorPropAsAssertion("calledWithNew", "expected %n to be called with new"); + mirrorPropAsAssertion("alwaysCalledWithNew", "expected %n to always be called with new"); + mirrorPropAsAssertion("calledWith", "expected %n to be called with arguments %*%C"); + mirrorPropAsAssertion("calledWithMatch", "expected %n to be called with match %*%C"); + mirrorPropAsAssertion("alwaysCalledWith", "expected %n to always be called with arguments %*%C"); + mirrorPropAsAssertion("alwaysCalledWithMatch", "expected %n to always be called with match %*%C"); + mirrorPropAsAssertion("calledWithExactly", "expected %n to be called with exact arguments %*%C"); + mirrorPropAsAssertion("alwaysCalledWithExactly", "expected %n to always be called with exact arguments %*%C"); + mirrorPropAsAssertion("neverCalledWith", "expected %n to never be called with arguments %*%C"); + mirrorPropAsAssertion("neverCalledWithMatch", "expected %n to never be called with match %*%C"); + mirrorPropAsAssertion("threw", "%n did not throw exception%C"); + mirrorPropAsAssertion("alwaysThrew", "%n did not always throw exception%C"); + + sinon.assert = assert; + return assert; + } + + var isNode = typeof module !== "undefined" && module.exports && typeof require == "function"; + var isAMD = typeof define === "function" && typeof define.amd === "object" && define.amd; + + function loadDependencies(require, exports, module) { + var sinon = require("./util/core"); + require("./match"); + require("./format"); + module.exports = makeApi(sinon); + } + + if (isAMD) { + define(loadDependencies); + } else if (isNode) { + loadDependencies(require, module.exports, module); + } else if (!sinon) { + return; + } else { + makeApi(sinon); + } + + }(typeof sinon == "object" && sinon || null, typeof window != "undefined" ? window : (typeof self != "undefined") ? self : global)); + + return sinon; + })); \ No newline at end of file diff --git a/packages/main/test/samples/Badge.sample.html b/packages/main/test/samples/Badge.sample.html index 4ca04ebe48bb..b99cb2e79ead 100644 --- a/packages/main/test/samples/Badge.sample.html +++ b/packages/main/test/samples/Badge.sample.html @@ -1,62 +1,28 @@ - - +
          +

          Badge

          +
          + +
          +
          - - <ui5-badge> - - - +
          <ui5-badge>
          - - - - - - - - - - - - - - - - - -
          -

          Badge

          -
          - -
          -
          - -
          <ui5-badge>
          - -
          -

          Basic Badge

          -
          - available 1 - required 2 - 3K - bug 4 - in process 5 - in warehouse 6 - 7$ - solution provided 8 - pending release 9 - customer action 10 - This would truncate as it is too long -
          -
          
          +<section>
          +	<h3>Basic Badge</h3>
          +	<div class="snippet">
          +		<ui5-badge color-scheme="1">available 1</ui5-badge>
          +		<ui5-badge color-scheme="2">required 2</ui5-badge>
          +		<ui5-badge color-scheme="3">3K</ui5-badge>
          +		<ui5-badge color-scheme="4">bug 4</ui5-badge>
          +		<ui5-badge color-scheme="5">in process 5</ui5-badge>
          +		<ui5-badge color-scheme="6">in warehouse 6</ui5-badge>
          +		<ui5-badge color-scheme="7">7$</ui5-badge>
          +		<ui5-badge color-scheme="8">solution provided 8</ui5-badge>
          +		<ui5-badge color-scheme="9">pending release 9</ui5-badge>
          +		<ui5-badge color-scheme="10">customer action 10</ui5-badge>
          +		<ui5-badge style="width:200px;">This would truncate as it is too long</ui5-badge>
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-badge color-scheme="1">available 1</ui5-badge>
           <ui5-badge color-scheme="2">required 2</ui5-badge>
           <ui5-badge color-scheme="3">3</ui5-badge>
          @@ -68,38 +34,38 @@ <h3>Basic Badge</h3>
           <ui5-badge color-scheme="9">pending release 9</ui5-badge>
           <ui5-badge color-scheme="10">customer action 10</ui5-badge>
           <ui5-badge style="width:200px;">This would truncate as it is too long</ui5-badge>
          -		
          -
          + + -
          -

          Badge with Icon

          -
          - - done - - - - - - in process - - - - - - - - - pending - - - - - - - -
          -
          
          +<section>
          +	<h3>Badge with Icon</h3>
          +	<div class="snippet">
          +		<ui5-badge color-scheme="1">
          +				<ui5-icon src="sap-icon://accept" slot="icon"></ui5-icon>done
          +		</ui5-badge>
          +		<ui5-badge color-scheme="2">
          +				<ui5-icon src="sap-icon://sap-ui5" slot="icon"></ui5-icon>
          +		</ui5-badge>
          +		<ui5-badge color-scheme="3">
          +				<ui5-icon src="sap-icon://add-equipment" slot="icon"></ui5-icon>in process
          +		</ui5-badge>
          +		<ui5-badge color-scheme="4">
          +				<ui5-icon src="sap-icon://lab" slot="icon"></ui5-icon>
          +		</ui5-badge>
          +		<ui5-badge color-scheme="5">
          +				<ui5-icon src="sap-icon://email-read" slot="icon"></ui5-icon>
          +		</ui5-badge>
          +		<ui5-badge color-scheme="6">
          +				<ui5-icon src="sap-icon://pending" slot="icon"></ui5-icon>pending
          +		</ui5-badge>
          +		<ui5-badge color-scheme="7">
          +				<ui5-icon src="sap-icon://lightbulb" slot="icon"></ui5-icon>
          +		</ui5-badge>
          +		<ui5-badge color-scheme="8">
          +				<ui5-icon src="sap-icon://locked" slot="icon"></ui5-icon>
          +		</ui5-badge>
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-badge color-scheme="1">
           	<ui5-icon src="sap-icon://accept" slot="icon"></ui5-icon>done
           </ui5-badge>
          @@ -124,14 +90,6 @@ <h3>Badge with Icon</h3>
           <ui5-badge color-scheme="8">
           	<ui5-icon src="sap-icon://locked" slot="icon"></ui5-icon>
           </ui5-badge>
          -		
          -
          - - - - - - - + + + diff --git a/packages/main/test/samples/BusyIndicator.sample.html b/packages/main/test/samples/BusyIndicator.sample.html index d2a8059d0522..466f214728f6 100644 --- a/packages/main/test/samples/BusyIndicator.sample.html +++ b/packages/main/test/samples/BusyIndicator.sample.html @@ -1,96 +1,59 @@ - - - - - <ui5-busyindicator> - - - - - - - - - - - - - - - - - - - - - - - - - -
          -

          BusyIndicator

          -
          - + + +
          +

          BusyIndicator

          +
          + +
          +
          + +
          +

          Busy Indicator with different size

          +
          + + +
          -
          - -
          -

          Busy Indicator with different size

          -
          - - - -
          -
          
          +	<pre class="prettyprint lang-html"><xmp>
           <div>
           	<ui5-busyindicator active size="Small"></ui5-busyindicator>
           	<ui5-busyindicator active size="Medium"></ui5-busyindicator>
           	<ui5-busyindicator active size="Large"></ui5-busyindicator>
           </div>
          -		
          -
          + + -
          -

          Busy Indicator wrapping other elements

          -
          - Fetch List Data +
          +

          Busy Indicator wrapping other elements

          +
          + Fetch List Data - - - + + + -
          -
          
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-button id="fetch-btn" style="width: 120px;">Fetch List Data</ui5-button>
           
           <ui5-busyindicator id="busy-container" size="Medium">
          @@ -117,11 +80,10 @@ <h3>Busy Indicator wrapping other elements</h3>
           		}, 2000);
           	});
           </script>
          -		
          -
          + +
          - + diff --git a/packages/main/test/samples/Button.sample.html b/packages/main/test/samples/Button.sample.html index 2e4027c2519e..39e130aa3f5d 100644 --- a/packages/main/test/samples/Button.sample.html +++ b/packages/main/test/samples/Button.sample.html @@ -1,108 +1,72 @@ - - - - - <ui5-button> - - - - - - - - - - - - - - - - - - - - - - -
          -
          Button
          -
          <ui5-button>
          -
          - -
          -

          Basic Button

          -
          - Enabled - Disabled - Cancel - Approve - Decline - Subscribe -
          -
          
          +<header>
          +	<div class="control-header">Button</div>
          +	<div style="margin-bottom: 2rem; font-weight: 300; font-size: 1.1rem; color: #666666;">&lt;ui5-button&gt;</div>
          +</header>
          +
          +<section>
          +	<h3>Basic Button</h3>
          +	<div class="snippet">
          +		<ui5-button class="samples-margin" design="Default">Enabled</ui5-button>
          +		<ui5-button class="samples-margin" disabled>Disabled</ui5-button>
          +		<ui5-button class="samples-margin" design="Transparent">Cancel</ui5-button>
          +		<ui5-button class="samples-margin" design="Positive">Approve</ui5-button>
          +		<ui5-button class="samples-margin" design="Negative">Decline</ui5-button>
          +		<ui5-button class="samples-margin" design="Emphasized">Subscribe</ui5-button>
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-button design="Default">Enabled</ui5-button>
           <ui5-button disabled>Disabled</ui5-button>
           <ui5-button design="Transparent">Cancel</ui5-button>
          -<ui5-button design="Positive" icon-end>Approve</ui5-button>
          +<ui5-button design="Positive">Approve</ui5-button>
           <ui5-button design="Negative">Decline</ui5-button>
           <ui5-button design="Emphasized">Subscribe</ui5-button>
          -		
          -
          - -
          -

          Button with Icon

          -
          - Add - Download - Add - Remove - Accept -
          -
          
          +	
          +
          + +
          +

          Button with Icon

          +
          + Add + Download + Add + Remove + Accept +
          +
          
           <ui5-button icon="sap-icon://employee">Add</ui5-button>
           <ui5-button icon="sap-icon://download" icon-end>Download</ui5-button>
           <ui5-button design="Positive" icon="sap-icon://add">Add</ui5-button>
           <ui5-button design="Negative" icon="sap-icon://delete">Remove</ui5-button>
           <ui5-button design="Transparent" icon="sap-icon://accept">Transparent</ui5-button>
          -		
          -
          - -
          -

          Icon Only Button

          -
          - - - - - - - - - - - - - - - - - - - - - -
          -
          
          +	
          +
          + +
          +

          Icon Only Button

          +
          + + + + + + + + + + + + + + + + + + + + + +
          +
          
           <ui5-button icon="sap-icon://away" aria-labelledby="lblAway"></ui5-button>
           <ui5-button icon="sap-icon://action-settings" aria-labelledby="lblSettings" ></ui5-button>
           <ui5-button icon="sap-icon://add" aria-labelledby="lblAdd"></ui5-button>
          @@ -114,30 +78,25 @@ <h3>Icon Only Button</h3>
           <ui5-button icon="sap-icon://camera" design="Transparent" aria-labelledby="lblCamera"></ui5-button>
           <ui5-button icon="sap-icon://cart" design="Transparent" aria-labelledby="lblCart"></ui5-button>
           <ui5-label style="display:none" id="lblAdd" aria-hidden="true">Add</ui5-label>
          -		
          -
          - -
          -

          Button with Design

          -
          - Submit - Agree - Decline - Disabled - Transparent -
          -
          
          +	
          +
          + +
          +

          Button with Design

          +
          + Submit + Agree + Decline + Disabled + Transparent +
          +
          
           <ui5-button design="Emphasized">Submit</ui5-button>
           <ui5-button design="Positive">Agree</ui5-button>
           <ui5-button design="Negative">Decline</ui5-button>
           <ui5-button disabled>Disabled</ui5-button>
           <ui5-button design="Transparent">Transparent</ui5-button>
          -		
          -
          - - - + + - + diff --git a/packages/main/test/samples/Card.sample.html b/packages/main/test/samples/Card.sample.html index dbeda02fe7e9..522b3ce20328 100644 --- a/packages/main/test/samples/Card.sample.html +++ b/packages/main/test/samples/Card.sample.html @@ -1,131 +1,93 @@ - - - - - <ui5-card> - - - - - - - - - - - - - - - - - - - - - - -
          -

          Card

          -
          <ui5-card>
          -
          - -
          -

          Card with List

          -
          - -
          - - Alain Chevalier - Monique Legrand - Michael Adams - + -
          -
          - -
          - - Richard Wilson - Elena Petrova - John Miller - -
          -
          -
          +
          +

          Card

          +
          <ui5-card>
          +
          + +
          +

          Card with List

          +
          + +
          + + Alain Chevalier + Monique Legrand + Michael Adams + + +
          +
          + +
          + + Richard Wilson + Elena Petrova + John Miller + +
          +
          +
          -
          -
          +	<pre class="prettyprint lang-html"><xmp>
           <style>
           .card-content {
           	display: flex;
          @@ -137,9 +99,9 @@ <h3>Card with List</h3>
           <ui5-card avatar="sap-icon://group" heading="Team Space" subtitle="Direct Reports" status="3 of 10" class="medium">
           	<div class="card-content">
           		<ui5-list separators="None" class="card-content-child" style="width: 100%">
          -			<ui5-li image="../../www/samples/images/man_avatar_1.png" description="User Researcher">Alain Chevalier</ui5-li>
          -			<ui5-li image="../../www/samples/images/woman_avatar_1.png" description="Artist">Monique Legrand</ui5-li>
          -			<ui5-li image="../../www/samples/images/woman_avatar_2.png" description="UX Specialist">Michael Adams</ui5-li>
          +			<ui5-li image="../../assets/images/avatars/man_avatar_1.png" description="User Researcher">Alain Chevalier</ui5-li>
          +			<ui5-li image="../../assets/images/avatars/woman_avatar_1.png" description="Artist">Monique Legrand</ui5-li>
          +			<ui5-li image="../../assets/images/avatars/woman_avatar_2.png" description="UX Specialist">Michael Adams</ui5-li>
           		</ui5-list>
           
           	</div>
          @@ -147,88 +109,86 @@ <h3>Card with List</h3>
           <ui5-card avatar="sap-icon://group" heading="This header is interactive" header-interactive subtitle="Click, press Enter or Space" status="3 of 6" class="medium">
           	<div class="card-content">
           		<ui5-list separators="None" class="card-content-child" style="width: 100%">
          -			<ui5-li image="../../www/samples/images/man_avatar_2.png" description="Software Architect">Richard Wilson</ui5-li>
          -			<ui5-li image="../../www/samples/images/woman_avatar_3.png" description="Visual Designer">Elena Petrova</ui5-li>
          -			<ui5-li image="../../www/samples/images/man_avatar_3.png" description="Quality Specialist">John Miller</ui5-li>
          +			<ui5-li image="../../assets/images/avatars/man_avatar_2.png" description="Software Architect">Richard Wilson</ui5-li>
          +			<ui5-li image="../../assets/images/avatars/woman_avatar_3.png" description="Visual Designer">Elena Petrova</ui5-li>
          +			<ui5-li image="../../assets/images/avatars/man_avatar_3.png" description="Quality Specialist">John Miller</ui5-li>
           		</ui5-list>
           	</div>
           </ui5-card>
          -
          -		
          -
          - -
          -

          Card with Table

          -
          - - - - - Sales Order - - - - Customer - - - - Net Amount - - - - Status - - - - - 5000010050 - - - Entertainment Argentinia - - - 6k USD - - - Aproved - - - - - - 5000010051 - - - Brazil Techologies - - - 2k USD - - - Rejected - - - - - - 5000010052 - - - Robert Brown Ent. - - - 17k USD - - - Pending - - - - -
          + +
          + +
          +

          Card with Table

          +
          + + + + + Sales Order + + + + Customer + + + + Net Amount + + + + Status + + + + + 5000010050 + + + Entertainment Argentinia + + + 6k USD + + + Aproved + + + + + + 5000010051 + + + Brazil Techologies + + + 2k USD + + + Rejected + + + + + + 5000010052 + + + Robert Brown Ent. + + + 17k USD + + + Pending + + + + +
          -
          -
          +	<pre class="prettyprint lang-html"><xmp>
           <style>
           .status-error {color: #b00;}
           .status-warning {color: #e9730c;}
          @@ -271,28 +231,26 @@ <h3>Card with Table</h3>
           		...
           	</ui5-table>
           </ui5-card>
          -
          -		
          -
          - -
          -

          Card with Timeline

          -
          - - - - - MR SOF02 2.43 - - - Online meeting - - - -
          + +
          + +
          +

          Card with Timeline

          +
          + + + + + MR SOF02 2.43 + + + Online meeting + + + +
          -
          -
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-card
           	heading="Upcoming Activities"
           	subtitle="For Today"
          @@ -307,90 +265,88 @@ <h3>Card with Timeline</h3>
           		</ui5-timeline-item>
           	</ui5-timeline>
           </ui5-card>
          -
          -		
          -
          - -
          -

          More Cards

          -
          - - - Personal Development - Finance - Communications Skills - - - - - - -
          -
          - Avantel - ID234522566-D44 -
          -
          - 27.25K EUR -
          + +
          + +
          +

          More Cards

          +
          + + + Personal Development + Finance + Communications Skills + + + + + + +
          +
          + Avantel + ID234522566-D44
          - - - -
          -
          - Telecomunicaciones Star - ID7125852785-A51 -
          -
          - 22.89K EUR -
          +
          + 27.25K EUR
          - - - -
          -
          - Talpa - ID123555587-I05 -
          -
          - 7.85K EUR -
          -
          -
          - - - - -
          - Contact details - -
          - Company Name - Company A
          + -
          - Address - 481 West Street, Anytown 45066, USA + +
          +
          + Telecomunicaciones Star + ID7125852785-A51 +
          +
          + 22.89K EUR +
          +
          -
          - Website - www.company_a.example.com + +
          +
          + Talpa + ID123555587-I05 +
          +
          + 7.85K EUR +
          +
          + + + + +
          + Contact details + +
          + Company Name + Company A
          - -
          -
          -
          -<ui5-card avatar="../../www/samples/images/man_avatar_1.png" heading="David Willams" subtitle="Sales Manager" class="small">
          +				<div class="content-group">
          +					<ui5-label>Address</ui5-label>
          +					<ui5-title level="H6">481 West Street, Anytown 45066, USA</ui5-title>
          +				</div>
          +
          +				<div class="content-group">
          +					<ui5-label>Website</ui5-label>
          +					<ui5-link target="_blank">www.company_a.example.com</ui5-link>
          +				</div>
          +			</div>
          +		</ui5-card>
          +	</div>
          +
          +	<pre class="prettyprint lang-html"><xmp>
          +<ui5-card avatar="../../assets/images/avatars/man_avatar_1.png" heading="David Willams" subtitle="Sales Manager" class="small">
           	<ui5-list separators="Inner" class="content-padding">
           		<ui5-li icon="sap-icon://competitor" icon-end>Personal Development</ui5-li>
           		<ui5-li icon="sap-icon://wallet" icon-end>Finance</ui5-li>
          @@ -434,7 +390,7 @@ <h3>More Cards</h3>
           	</ui5-list>
           </ui5-card>
           
          -<ui5-card avatar="../../www/samples/images/woman_avatar_1.png" heading="Dona Maria Moore" subtitle="Senior Sales Executive" class="small">
          +<ui5-card avatar="../../assets/images/avatars/woman_avatar_1.png" heading="Dona Maria Moore" subtitle="Senior Sales Executive" class="small">
           	<div class="content content-padding">
           		<ui5-title level="H5" style="padding-bottom: 1rem;">Contact details</ui5-title>
           
          @@ -452,15 +408,7 @@ <h3>More Cards</h3>
           		</div>
           	</div>
           </ui5-card>
          -
          -		
          -
          - - - - - + +
          - + diff --git a/packages/main/test/samples/CheckBox.sample.html b/packages/main/test/samples/CheckBox.sample.html index fd7210d1efbc..aa794d9061ac 100644 --- a/packages/main/test/samples/CheckBox.sample.html +++ b/packages/main/test/samples/CheckBox.sample.html @@ -1,71 +1,37 @@ - - - - - <ui5-checkbox> - - - - - - - - - - - - - - - - - - - - -
          -

          CheckBox

          -
          <ui5-checkbox>
          -
          - -
          -

          Basic CheckBox

          -
          - - - - -
          -
          
          +<header>
          +	<h2 class="control-header">CheckBox</h2>
          +	<div style="margin-bottom: 2rem; font-weight: 300; font-size: 1.1rem; color: #666666;">&lt;ui5-checkbox&gt;</div>
          +</header>
          +
          +<section>
          +	<h3>Basic CheckBox</h3>
          +	<div class="snippet">
          +		<ui5-checkbox text="Chocolate" checked></ui5-checkbox>
          +		<ui5-checkbox text="Strawberry" checked></ui5-checkbox>
          +		<ui5-checkbox text="Waffles" checked value-state="Error"></ui5-checkbox>
          +		<ui5-checkbox text="Cake" checked value-state="Warning"></ui5-checkbox>
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-checkbox text="Chocolate" checked></ui5-checkbox>
           <ui5-checkbox text="Strawberry" checked></ui5-checkbox>
           <ui5-checkbox text="Waffles" checked value-state="Error"></ui5-checkbox>
           <ui5-checkbox text="Cake" checked value-state="Warning"></ui5-checkbox>
          -		
          -
          - -
          -

          CheckBox states

          -
          - - - - - - - - -
          -
          
          +	
          +
          + +
          +

          CheckBox states

          +
          + + + + + + + + +
          +
          
           <ui5-checkbox text="Error" value-state="Error"></ui5-checkbox>
           <ui5-checkbox text="Warning" value-state="Warning"></ui5-checkbox>
           <ui5-checkbox text="Disabled" disabled checked></ui5-checkbox>
          @@ -74,26 +40,19 @@ <h3>CheckBox states</h3>
           <ui5-checkbox text="Warning disabled " disabled value-state="Warning" checked></ui5-checkbox>
           <ui5-checkbox text="Error readonly" readonly value-state="Error" checked></ui5-checkbox>
           <ui5-checkbox text="Warning readonly" readonly value-state="Warning" checked></ui5-checkbox>
          -		
          -
          - -
          -

          CheckBox with Text Wrapping

          -
          - - -
          -
          
          +	
          +
          + +
          +

          CheckBox with Text Wrapping

          +
          + + +
          +
          
           <ui5-checkbox text="ui5-checkbox with 'wrap' set and some long text." wrap ></ui5-checkbox>
           <ui5-checkbox text="Another ui5-checkbox with very long text here" wrap style="width:200px"></ui5-checkbox>
          -		
          -
          - - - - - + + - + diff --git a/packages/main/test/samples/DatePicker.sample.html b/packages/main/test/samples/DatePicker.sample.html index 575710cecf4a..8b7bc4a62c0c 100644 --- a/packages/main/test/samples/DatePicker.sample.html +++ b/packages/main/test/samples/DatePicker.sample.html @@ -1,55 +1,28 @@ - - - - - <ui5-datepicker> - - - - - - - - - - - - - - - - - - -
          -

          DatePicker

          -
          <ui5-datepicker>
          -
          - -
          -

          Basic DatePicker

          -
          -
          - -
          +
          +

          DatePicker

          +
          <ui5-datepicker>
          +
          + +
          +

          Basic DatePicker

          +
          +
          +
          -
          
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-datepicker id="myDatepicker1"></ui5-datepicker>
          -	
          -
          - -
          -

          DatePicker with Placeholder, Tooltip, Events, and ValueState

          -
          -
          - -
          + +
          + +
          +

          DatePicker with Placeholder, Tooltip, Events, and ValueState

          +
          +
          +
          -
          
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-datepicker id="myDatepicker2" placeholder='Delivery Date...' title='Delivery Date!'></ui5-datepicker>
           <script>
           	const dp = document.getElementById('myDatepicker2');
          @@ -60,7 +33,7 @@ <h3>DatePicker with Placeholder, Tooltip, Events, and ValueState</h3>
           	dp.addEventListener('input', (e) => console.log('input: ', e.detail));
           </script>
           	
          -
          +

          DatePicker with shortcuts: type "today" or "yesterday" and press "Enter"

          @@ -81,10 +54,11 @@

          DatePicker with format-pattern='short'

          -
          
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-datepicker format-pattern='short'></ui5-datepicker>
           	
          - +

          DatePicker with format-pattern='long'

          @@ -96,19 +70,19 @@

          DatePicker with format-pattern='long'

          
           <ui5-datepicker format-pattern='long'></ui5-datepicker>
           	
          -
          + -
          -

          DatePicker with format-pattern='QQQ yyyy, MMM dd', value='Q4 2018, Feb 14'

          -
          -
          - -
          +
          +

          DatePicker with format-pattern='QQQ yyyy, MMM dd', value='Q4 2018, Feb 14'

          +
          +
          +
          -
          
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-datepicker format-pattern='QQQ yyyy, MMM dd' value='Q4 2018, Feb 14'></ui5-datepicker>
           	
          -
          +

          DatePicker with format-pattern='EEE, M/d/yyyy'

          @@ -120,7 +94,7 @@

          DatePicker with format-pattern='EEE, M/d/yyyy'

          
           <ui5-datepicker format-pattern='EEE, M/d/yyyy'></ui5-datepicker>
           	
          -
          +

          Disabled DatePicker

          @@ -132,7 +106,7 @@

          Disabled DatePicker

          
           <ui5-datepicker disabled></ui5-datepicker>
           	
          -
          +

          readonly DatePicker

          @@ -144,7 +118,7 @@

          readonly DatePicker

          
           <ui5-datepicker readonly></ui5-datepicker>
           	
          -
          +

          DatePicker with Japanese Calendar Type

          @@ -156,7 +130,7 @@

          DatePicker with Japanese Calendar Type

          
           <ui5-datepicker primary-calendar-type='Japanese'></ui5-datepicker>
           	
          -
          +

          DatePicker with Islamic Calendar Type

          @@ -168,7 +142,7 @@

          DatePicker with Islamic Calendar Type

          
           <ui5-datepicker primary-calendar-type='Islamic'></ui5-datepicker>
           	
          -
          +

          DatePicker with Buddhist Calendar Type

          @@ -180,20 +154,15 @@

          DatePicker with Buddhist Calendar Type

          
           <ui5-datepicker primary-calendar-type='Buddhist'></ui5-datepicker>
           	
          -
          - - - - - + - + diff --git a/packages/main/test/samples/Dialog.sample.html b/packages/main/test/samples/Dialog.sample.html index 5060550dda88..a2b37fe63716 100644 --- a/packages/main/test/samples/Dialog.sample.html +++ b/packages/main/test/samples/Dialog.sample.html @@ -1,91 +1,57 @@ - - - - - <ui5-dialog> - - - - - - - - - - - - - - - - - - - - -
          -

          Dialog

          -
          <ui5-dialog>
          -
          - -
          -

          Basic Dialog

          -
          - Open Dialog - - - - -
          -
          - Register +
          +

          Dialog

          +
          <ui5-dialog>
          +
          + +
          +

          Basic Dialog

          +
          + Open Dialog + + +
          -
          
          +				<div>
          +					<ui5-label for="address">Address: </ui5-label>
          +					<ui5-input id="address"></ui5-input>
          +				</div>
          +			</section>
          +
          +			<div slot="footer" style="display: flex; align-items: center;padding: .5rem">
          +				<div style="flex: 1;"></div>
          +				<ui5-button id="closeDialogButton" design="Emphasized">Register</ui5-button>
          +			</div>
          +		</ui5-dialog>
          +
          +		<script>
          +			var dialogOpener = document.getElementById("openDialogButton");
          +			var dialog = document.getElementById("hello-dialog");
          +			var dialogCloser = document.getElementById("closeDialogButton");
          +
          +			dialogOpener.addEventListener("click", function() {
          +				dialog.open();
          +			});
          +
          +			dialogCloser.addEventListener("click", function() {
          +				dialog.close();
          +			});
          +		</script>
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-button id="openDialogButton" design="Emphasized">Open Dialog</ui5-button>
           
           <ui5-dialog id="hello-dialog" header-text="Register Form">
          @@ -130,14 +96,7 @@ <h3>Basic Dialog</h3>
           		dialog.close();
           	});
           </script>
          -		
          -
          - - - - - + +
          - + \ No newline at end of file diff --git a/packages/main/test/samples/Icon.sample.html b/packages/main/test/samples/Icon.sample.html index f693c2db3c12..65de8c2a3db5 100644 --- a/packages/main/test/samples/Icon.sample.html +++ b/packages/main/test/samples/Icon.sample.html @@ -1,77 +1,36 @@ - - - - - <ui5-icon> - - - - - - - - - - - - - - - - - - - - -
          -

          Icon

          -
          <ui5-icon>
          -
          - -
          -

          Basic Icons

          -
          - - - - - -
          -
          
          +<header>
          +	<h2 class="control-header">Icon</h2>
          +	<div style="margin-bottom: 2rem; font-weight: 300; font-size: 1.1rem; color: #666666;">&lt;ui5-icon&gt;</div>
          +</header>
          +
          +<section>
          +	<h3>Basic Icons</h3>
          +	<div class="snippet">
          +		<ui5-icon class="samples-margin" src="sap-icon://activate"></ui5-icon>
          +		<ui5-icon class="samples-margin" src="sap-icon://activities"></ui5-icon>
          +		<ui5-icon class="samples-margin" src="sap-icon://add-equipment"></ui5-icon>
          +		<ui5-icon class="samples-margin" src="sap-icon://add-document"></ui5-icon>
          +		<ui5-icon class="samples-margin" src="sap-icon://add-employee"></ui5-icon>
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-icon src="sap-icon://activate"></ui5-icon>
           <ui5-icon src="sap-icon://activities"></ui5-icon>
           <ui5-icon src="sap-icon://add-equipment"></ui5-icon>
           <ui5-icon src="sap-icon://add-document"></ui5-icon>
           <ui5-icon src="sap-icon://add-employee"></ui5-icon>
          -		
          -
          - -
          -

          Customized Icons

          -
          - - -
          -
          
          +	
          +
          + +
          +

          Customized Icons

          +
          + + +
          +
          
           <ui5-icon class="samples-margin" src="sap-icon://employee" style="width:3rem;height:3rem;font-size:1.5rem;color:crimson;background-color:#fafafa" ></ui5-icon>
           <ui5-icon class="samples-margin" src="sap-icon://menu" style="width:3rem;height:3rem;font-size:1.5rem;color:crimson;background-color:#fafafa"></ui5-icon>
          -		
          -
          - - - - - + + - + diff --git a/packages/main/test/samples/Input.sample.html b/packages/main/test/samples/Input.sample.html index f3fbd906bea4..813b0fe66193 100644 --- a/packages/main/test/samples/Input.sample.html +++ b/packages/main/test/samples/Input.sample.html @@ -1,111 +1,78 @@ - - - - - <ui5-input> - - - - - - - - - - + - .inputIcon { - background: #fafafa; - color: #0a6ed1; - cursor: pointer; - } - .inputIcon:hover{ - background: rgba(224,224,224,0.5) - } - - - - -
          -

          Input

          -
          <ui5-input>
          -
          - -
          -

          Basic Input

          -
          - - - -
          -
          
          +<header>
          +	<h2 class="control-header">Input</h2>
          +	<div style="margin-bottom: 2rem; font-weight: 300; font-size: 1.1rem; color: #666666;">&lt;ui5-input&gt;</div>
          +</header>
          +
          +<section>
          +	<h3>Basic Input</h3>
          +	<div class="snippet">
          +		<ui5-input class="samples-margin samples-responsive-margin-bottom input-width" value="Input"></ui5-input>
          +		<ui5-input class="samples-margin samples-responsive-margin-bottom input-width" readonly value="readonly Input"></ui5-input>
          +		<ui5-input class="samples-margin samples-responsive-margin-bottom input-width" disabled value="Disabled Input"></ui5-input>
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-input value="Input"></ui5-input>
           <ui5-input readonly value="readonly Input"></ui5-input>
           <ui5-input disabled value="Disabled Input"></ui5-input>
          -		
          -
          + + -
          -

          Input With Suggestions (Note: the usage depends on the framework you are using)

          -
          - - - - -
          -
          
          +
          +				suggestionItems.forEach(function(item) {
          +					var li = document.createElement("ui5-li");
          +					li.icon = "sap-icon://world";
          +					li.id = item;
          +					li.textContent = item;
          +					oInput.appendChild(li);
          +				});
          +			});
          +		</script>
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-input id="suggestions-input" show-suggestions placeholder="Start typing country name"></ui5-input>
           
           <script>
          @@ -140,33 +107,33 @@ <h3>Input With Suggestions (Note: the usage depends on the framework you are usi
           		});
           	});
           </script>
          -		
          -
          - -
          -

          Input with Value State

          -
          - - - -
          -
          
          +	
          +
          + +
          +

          Input with Value State

          +
          + + + +
          +
          
           <ui5-input value="Success" value-state="Success"></ui5-input>
           <ui5-input value="Warning" value-state="Warning"></ui5-input>
           <ui5-input value="Error" value-state="Error"></ui5-input>
          -		
          -
          - -
          -

          Input as Search Field

          -
          -
          - - - -
          + +
          + +
          +

          Input as Search Field

          +
          +
          + + +
          -
          
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <style>
           	.inputIcon {
           		background: #fafafa;
          @@ -191,39 +158,35 @@ <h3>Input as Search Field</h3>
           		searchCriteria = e.target.value;
           	});
           </script>
          -		
          -
          - -
          -

          Input with Label

          -
          -
          - Name - -
          -
          - Secret Code - -
          + +
          + +
          +

          Input with Label

          +
          +
          + Name + +
          +
          + Secret Code +
          -
          
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-label class="samples-big-margin-right" for="myInput" required>Name</ui5-label>
           <ui5-input class="input-width" id="myInput" placeholder="Enter your Name" required></ui5-input>
          -		
          -
          + + - - - - + - + diff --git a/packages/main/test/samples/Label.sample.html b/packages/main/test/samples/Label.sample.html index e1c3d640b736..1f991a287f76 100644 --- a/packages/main/test/samples/Label.sample.html +++ b/packages/main/test/samples/Label.sample.html @@ -1,110 +1,75 @@ - - - - - <ui5-label> - - - - - - - - - - - - - - - - - - - - -
          -

          Label

          -
          <ui5-label>
          -
          - -
          -

          Basic Label

          -
          - The quick brown fox jumps over the lazy dog. -
          -
          
          -<ui5-label>The quick brown fox jumps over the lazy dog.</ui5-label>
          -		
          -
          - -
          -

          Required Label

          -
          - Required Label -
          -
          
          +<header>
          +	<h2 class="control-header">Label</h2>
          +	<div style="margin-bottom: 2rem; font-weight: 300; font-size: 1.1rem; color: #666666;">&lt;ui5-label&gt;</div>
          +</header>
          +
          +<section>
          +	<h3>Basic Label</h3>
          +	<div class="snippet">
          +		<ui5-label>The quick brown fox jumps over the lazy dog.</ui5-label>
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
          +<ui5-label>Simple Label</ui5-label>
          +	
          +
          + +
          +

          Required Label

          +
          + Required Label +
          +
          
           <ui5-label required>Required Label</ui5-label>
          -		
          -
          - -
          -

          Truncated Label

          -
          - Long labels are truncated by default. -
          -
          
          +	
          +
          + +
          +

          Truncated Label

          +
          + Long labels are truncated by default. +
          +
          
           <ui5-label style="width:200px">Long labels are truncated by default.</ui5-label>
          -		
          -
          - -
          -

          Wrapped Label

          -
          - Long labels can wrap if the 'wrap' property is set. -
          -
          
          +	
          +
          + +
          +

          Wrapped Label

          +
          + Long labels can wrap if the 'wrap' property is set. +
          +
          
           <ui5-label style="width:200px" wrap>Long labels can wrap if the 'wrap' property is set.</ui5-label>
          -		
          -
          - -
          -

          Label 'for'

          -
          - First name - -
          - Date of birth - -
          - Job - - Manager - Sales - Developer - -
          - Description label test - -
          -
          - Gender - - -
          -
          - Accept terms of use - -
          + +
          + +
          +

          Label 'for'

          +
          + First name + +
          + Date of birth + +
          + Job + + Manager + Sales + Developer + +
          + Description label test + +
          +
          + Gender + + +
          +
          + Accept terms of use +
          
           <ui5-label id="myLabel" for="myInput" required>First name</ui5-label>
          @@ -125,13 +90,6 @@ <h3>Label 'for'</h3>
           <ui5-label for="myCB" required>Accept terms of use</ui5-label>
           	<ui5-checkbox id="myCB"></ui5-checkbox>
           		
          -
          - - - - - + - + diff --git a/packages/main/test/samples/Link.sample.html b/packages/main/test/samples/Link.sample.html index 761ffdb1d9cf..442806b2173d 100644 --- a/packages/main/test/samples/Link.sample.html +++ b/packages/main/test/samples/Link.sample.html @@ -1,63 +1,22 @@ - - - - - <ui5-link> - - - - - - - - - - - - - - - - - - - - -
          -

          Link

          -
          <ui5-link>
          -
          - -
          -

          Different Link Designs

          -
          - Standard Link - Subtle link - Disabled - Emphasized -
          -
          
          +<header>
          +	<h2 class="control-header">Link</h2>
          +	<div style="margin-bottom: 2rem; font-weight: 300; font-size: 1.1rem; color: #666666;">&lt;ui5-link&gt;</div>
          +</header>
          +
          +<section>
          +	<h3>Different Link Designs</h3>
          +	<div class="snippet">
          +		<ui5-link class="samples-big-margin-right" href="https://www.sap.com" target="_blank">Standard Link</ui5-link>
          +		<ui5-link class="samples-big-margin-right" href="https://www.sap.com" target="_blank" design="Subtle">Subtle link</ui5-link>
          +		<ui5-link class="samples-big-margin-right" href="https://www.sap.com" target="_blank" disabled>Disabled</ui5-link>
          +		<ui5-link class="samples-big-margin-right" href="https://www.sap.com" target="_blank" design="Emphasized">Emphasized</ui5-link>
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-link href="https://www.sap.com" target="_blank">Standard Link</ui5-link>
           <ui5-link href="https://www.sap.com" target="_blank" design="Subtle">Subtle link</ui5-link>
           <ui5-link href="https://www.sap.com" target="_blank" disabled>Disabled</ui5-link>
           <ui5-link href="https://www.sap.com" target="_blank" design="Emphasized">Emphasized</ui5-link>
          -		
          -
          - - - - - + + - + diff --git a/packages/main/test/samples/List.sample.html b/packages/main/test/samples/List.sample.html index 1c0f41789689..5d0ab915ebfd 100644 --- a/packages/main/test/samples/List.sample.html +++ b/packages/main/test/samples/List.sample.html @@ -1,81 +1,47 @@ - - - - - <ui5-list> - - - - - - - - - - - - - - - - - - - - -
          -

          List

          -
          <ui5-list>
          -
          - -
          -

          Basic List

          -
          - - Pineapple - Orange - Banana - Mango - -
          -
          
          +<header>
          +	<h2 class="control-header">List</h2>
          +	<div style="margin-bottom: 2rem; font-weight: 300; font-size: 1.1rem; color: #666666;">&lt;ui5-list&gt;</div>
          +</header>
          +
          +<section>
          +	<h3>Basic List</h3>
          +	<div class="snippet">
          +		<ui5-list id="myList" class="full-width">
          +			<ui5-li icon="sap-icon://nutrition-activity" description="Tropical plant with an edible fruit" info="In-stock" info-state="Success">Pineapple</ui5-li>
          +			<ui5-li icon="sap-icon://nutrition-activity" description="Occurs between red and yellow" info="Expires" info-state="Warning">Orange</ui5-li>
          +			<ui5-li icon="sap-icon://nutrition-activity" description="The yellow lengthy fruit" info="Re-stock" info-state="Error">Banana</ui5-li>
          +			<ui5-li icon="sap-icon://nutrition-activity" description="The tropical stone fruit" info="Re-stock" info-state="Error">Mango</ui5-li>
          +		</ui5-list>
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-list id="myList" class="full-width">
           	<ui5-li icon="sap-icon://nutrition-activity" description="Tropical plant with an edible fruit" info="In-stock" info-state="Success">Pineapple</ui5-li>
           	<ui5-li icon="sap-icon://nutrition-activity" description="Occurs between red and yellow" info="Expires" info-state="Warning">Orange</ui5-li>
           	<ui5-li icon="sap-icon://nutrition-activity" description="The yellow lengthy fruit" info="Re-stock" info-state="Error">Banana</ui5-li>
           	<ui5-li icon="sap-icon://nutrition-activity" description="The tropical stone fruit" info="Re-stock" info-state="Error">Mango</ui5-li>
           </ui5-list>
          -		
          -
          - -
          -

          List in Single-selection Mode

          -
          - - Argentina - Bulgaria - China - Denmark (ui5-li type='Inactive') - - - -
          -
          
          +	
          +
          + +
          +

          List in Single-selection Mode

          +
          + + Argentina + Bulgaria + China + Denmark (ui5-li type='Inactive') + + + +
          +
          
           <ui5-list id="country-selector" mode="SingleSelect" header-text="Select a country:">
           	<ui5-li selected icon="sap-icon://map" icon-end>Argentina</ui5-li>
           	<ui5-li icon="sap-icon://map" icon-end>Bulgaria</ui5-li>
          @@ -90,119 +56,115 @@ <h3>List in Single-selection Mode</h3>
           		alert("The selected item:  " + selectedItems[0].textContent);
           	});
           </script>
          -		
          -
          - - -
          -

          List in Multi-selection Mode

          -
          - - Pineapple - Orange - Banana - Mango - - -
          -			
          +	
          +
          + + +
          +

          List in Multi-selection Mode

          +
          + + Pineapple + Orange + Banana + Mango + +
          +
          
           <ui5-list id="myList1" mode='MultiSelect' header-text="Multiple selection is possible">
           	<ui5-li>Pineapple</ui5-li>
           	<ui5-li selected>Orange</ui5-li>
           	<ui5-li>Banana</ui5-li>
           	<ui5-li>Mango</ui5-li>
           </ui5-list>
          -			
          -		
          -
          + + -
          -

          List With GroupHeaders

          -
          - - Front End Developers - Jennifer - Lora - Carlotta - - Back End Developers - Clark - Ellen - Adam - - FullStack Developers - Susan - David - Natalie - - -
          -				
          +<section>
          +	<h3>List With GroupHeaders</h3>
          +	<div class="snippet">
          +		<ui5-list header-text="Community" mode="MultiSelect">
          +			<ui5-li-groupheader>Front End Developers</ui5-li-groupheader>
          +			<ui5-li image="../../assets/images/avatars/woman_avatar_3.png" icon="sap-icon://navigation-right-arrow" icon-end>Jennifer</ui5-li>
          +			<ui5-li image="../../assets/images/avatars/woman_avatar_4.png" icon="sap-icon://navigation-right-arrow" icon-end>Lora</ui5-li>
          +			<ui5-li image="../../assets/images/avatars/woman_avatar_5.png" icon="sap-icon://navigation-right-arrow" icon-end>Carlotta</ui5-li>
          +
          +			<ui5-li-groupheader>Back End Developers</ui5-li-groupheader>
          +			<ui5-li image="../../assets/images/avatars/man_avatar_1.png"  icon="sap-icon://navigation-right-arrow" icon-end>Clark</ui5-li>
          +			<ui5-li image="../../assets/images/avatars/woman_avatar_1.png" icon="sap-icon://navigation-right-arrow" icon-end>Ellen</ui5-li>
          +			<ui5-li image="../../assets/images/avatars/man_avatar_2.png" icon="sap-icon://navigation-right-arrow" icon-end>Adam</ui5-li>
          +
          +			<ui5-li-groupheader>FullStack Developers</ui5-li-groupheader>
          +			<ui5-li image="../../assets/images/avatars/woman_avatar_2.png" icon="sap-icon://navigation-right-arrow" icon-end>Susan</ui5-li>
          +			<ui5-li image="../../assets/images/avatars/man_avatar_3.png" icon="sap-icon://navigation-right-arrow" icon-end>David</ui5-li>
          +			<ui5-li image="../../assets/images/avatars/woman_avatar_3.png" icon="sap-icon://navigation-right-arrow" icon-end>Natalie</ui5-li>
          +		</ui5-list>
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-list header-text="Team Members" mode="MultiSelect">
           	<ui5-li-groupheader>Front End Developers</ui5-li-groupheader>
          -	<ui5-li image="../../www/samples/images/woman_avatar_3.png" icon="sap-icon://navigation-right-arrow" icon-end>Jennifer</ui5-li>
          -	<ui5-li image="../../www/samples/images/woman_avatar_4.png" icon="sap-icon://navigation-right-arrow" icon-end>Lora</ui5-li>
          -	<ui5-li image="../../www/samples/images/woman_avatar_5.png" icon="sap-icon://navigation-right-arrow" icon-end>Carlotta</ui5-li>
          +	<ui5-li image="../../assets/images/avatars/woman_avatar_3.png" icon="sap-icon://navigation-right-arrow" icon-end>Jennifer</ui5-li>
          +	<ui5-li image="../../assets/images/avatars/woman_avatar_4.png" icon="sap-icon://navigation-right-arrow" icon-end>Lora</ui5-li>
          +	<ui5-li image="../../assets/images/avatars/woman_avatar_5.png" icon="sap-icon://navigation-right-arrow" icon-end>Carlotta</ui5-li>
           
           	<ui5-li-groupheader>Back End Developers</ui5-li-groupheader>
          -	<ui5-li image="../../www/samples/images/man_avatar_1.png"  icon="sap-icon://navigation-right-arrow" icon-end>Clark</ui5-li>
          -	<ui5-li image="../../www/samples/images/woman_avatar_1.png" icon="sap-icon://navigation-right-arrow" icon-end>Ellen</ui5-li>
          -	<ui5-li image="../../www/samples/images/man_avatar_2.png" icon="sap-icon://navigation-right-arrow" icon-end>Adam</ui5-li>
          +	<ui5-li image="../../assets/images/avatars/man_avatar_1.png"  icon="sap-icon://navigation-right-arrow" icon-end>Clark</ui5-li>
          +	<ui5-li image="../../assets/images/avatars/woman_avatar_1.png" icon="sap-icon://navigation-right-arrow" icon-end>Ellen</ui5-li>
          +	<ui5-li image="../../assets/images/avatars/man_avatar_2.png" icon="sap-icon://navigation-right-arrow" icon-end>Adam</ui5-li>
           
           	<ui5-li-groupheader>FullStack Developers</ui5-li-groupheader>
          -	<ui5-li image="../../www/samples/images/woman_avatar_2.png" icon="sap-icon://navigation-right-arrow" icon-end>Susan</ui5-li>
          -	<ui5-li image="../../www/samples/images/man_avatar_3.png" icon="sap-icon://navigation-right-arrow" icon-end>David</ui5-li>
          -	<ui5-li image="../../www/samples/images/woman_avatar_3.png" icon="sap-icon://navigation-right-arrow" icon-end>Natalie</ui5-li>
          +	<ui5-li image="../../assets/images/avatars/woman_avatar_2.png" icon="sap-icon://navigation-right-arrow" icon-end>Susan</ui5-li>
          +	<ui5-li image="../../assets/images/avatars/man_avatar_3.png" icon="sap-icon://navigation-right-arrow" icon-end>David</ui5-li>
          +	<ui5-li image="../../assets/images/avatars/woman_avatar_3.png" icon="sap-icon://navigation-right-arrow" icon-end>Natalie</ui5-li>
           </ui5-list>
          -				
          -			
          -
          - - -
          -

          List in Delete Mode

          -
          - - Argentina - Bulgaria - China - -
          -
          
          +	
          +
          + + +
          +

          List in Delete Mode

          +
          + + Argentina + Bulgaria + China + +
          +
          
           <ui5-list id="myList5" mode="Delete" header-text="Note: The list items removal is up to application developers">
           	<ui5-li>Argentina</ui5-li>
           	<ui5-li>Bulgaria</ui5-li>
           	<ui5-li>China</ui5-li>
           </ui5-list>
          -		
          -
          - -
          -

          List with No Data

          -
          - -
          -
          
          +	
          +
          + +
          +

          List with No Data

          +
          + +
          +
          
           <ui5-list class="full-width" header-text="Products" no-data-text="No Data Available separators="None"></ui5-list>
          -		
          -
          - -
          -

          List Item Separation Types

          -
          - - Item #1 - Item #2 - Item #3 - - - Devilered - Pending - Declined - -
          -
          
          +	
          +
          + +
          +

          List Item Separation Types

          +
          + + Item #1 + Item #2 + Item #3 + + + Devilered + Pending + Declined + +
          +
          
           <ui5-list header-text="No separators" separators="None" class="full-width">
           	<ui5-li icon="sap-icon://product">Item #1</ui5-li>
           	<ui5-li icon="sap-icon://product">Item #2</ui5-li>
          @@ -213,14 +175,7 @@ <h3>List Item Separation Types</h3>
           	<ui5-li icon="sap-icon://shipping-status">Pending</ui5-li>
           	<ui5-li icon="sap-icon://shipping-status">Declined</ui5-li>
           </ui5-list>
          -		
          -
          + + - - - - - - + diff --git a/packages/main/test/samples/MessageStrip.sample.html b/packages/main/test/samples/MessageStrip.sample.html index c9718dadce2a..17acf9d4baa8 100644 --- a/packages/main/test/samples/MessageStrip.sample.html +++ b/packages/main/test/samples/MessageStrip.sample.html @@ -1,56 +1,20 @@ - - - - - <ui5-messagestrip> - - - - - - - - - - - - - - - - - - - - - - -
          -
          MessageStrip
          -
          - -
          -
          -
          <ui5-messagestrip>
          - -
          -

          MessageStrip

          -
          - Information MessageStrip - Positive MessageStrip - Negative MessageStrip - Warning MessageStrip -
          -
          
          +<header class="component-heading">
          +	<div class="control-header">MessageStrip</div>
          +	<div class="component-heading-since">
          +		<span><!--since_tag_marker--></span>
          +	</div>
          +</header>
          +<div style="margin-bottom: 2rem; font-weight: 300; font-size: 1.1rem; color: #666666;">&lt;ui5-messagestrip&gt;</div>
          +
          +<section>
          +	<h3>MessageStrip</h3>
          +	<div class="snippet">
          +		<ui5-messagestrip class="samples-margin-bottom" type="Information">Information MessageStrip</ui5-messagestrip>
          +		<ui5-messagestrip class="samples-margin-bottom" type="Positive">Positive MessageStrip</ui5-messagestrip>
          +		<ui5-messagestrip class="samples-margin-bottom" type="Negative">Negative MessageStrip</ui5-messagestrip>
          +		<ui5-messagestrip class="samples-margin-bottom" type="Warning">Warning MessageStrip</ui5-messagestrip>
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-messagestrip type="Information">Information MessageStrip</ui5-messagestrip>
           <ui5-messagestrip type="Positive">Positive MessageStrip</ui5-messagestrip>
           <ui5-messagestrip type="Negative">Negative MessageStrip</ui5-messagestrip>
          @@ -62,34 +26,34 @@ <h3>MessageStrip</h3>
           		});
           	});
           </script>
          -		
          -
          - -
          -

          MessageStrip With No Close Button

          -
          - Information MessageStrip With No Close Button - Positive MessageStrip With No Close Button - Negative MessageStrip With No Close Button - Warning MessageStrip With No Close Button -
          -
          
          +	
          +
          + +
          +

          MessageStrip With No Close Button

          +
          + Information MessageStrip With No Close Button + Positive MessageStrip With No Close Button + Negative MessageStrip With No Close Button + Warning MessageStrip With No Close Button +
          +
          
           <ui5-messagestrip type="Information" no-close-button>Information MessageStrip With No Close Button</ui5-messagestrip>
           <ui5-messagestrip type="Positive" no-close-button>Positive MessageStrip With No Close Button</ui5-messagestrip>
           <ui5-messagestrip type="Negative" no-close-button>Negative MessageStrip With No Close Button</ui5-messagestrip>
           <ui5-messagestrip type="Warning" no-close-button>Warning MessageStrip With No Close Button</ui5-messagestrip>
          -		
          -
          - -
          -

          MessageStrip With No Icon

          -
          - Information MessageStrip With No Icon - Positive MessageStrip With No Icon - Negative MessageStrip With No Icon - Warning MessageStrip With No Icon -
          -
          
          +	
          +
          + +
          +

          MessageStrip With No Icon

          +
          + Information MessageStrip With No Icon + Positive MessageStrip With No Icon + Negative MessageStrip With No Icon + Warning MessageStrip With No Icon +
          +
          
           <ui5-messagestrip type="Information" no-icon>Information MessageStrip With No Icon</ui5-messagestrip>
           <ui5-messagestrip type="Positive" no-icon>Positive MessageStrip With No Icon</ui5-messagestrip>
           <ui5-messagestrip type="Negative" no-icon>Negative MessageStrip With No Icon</ui5-messagestrip>
          @@ -101,18 +65,18 @@ <h3>MessageStrip With No Icon</h3>
           		});
           	});
           </script>
          -		
          -
          - -
          -

          Custom MessageStrip

          -
          - You have new message. - Successfull login! - Access denied! - Update is required. -
          -
          
          +	
          +
          + +
          +

          Custom MessageStrip

          +
          + You have new message. + Successfull login! + Access denied! + Update is required. +
          +
          
           <ui5-messagestrip type="Information" style="width: 200px;" no-icon no-close-button>You have new message.</ui5-messagestrip>
           <ui5-messagestrip type="Positive" style="width: 200px;" no-close-button>Successfull login!</ui5-messagestrip>
           <ui5-messagestrip type="Negative" style="width: 200px;" no-icon>Access denied!</ui5-messagestrip>
          @@ -124,18 +88,15 @@ <h3>Custom MessageStrip</h3>
           		});
           	});
           </script>
          -		
          -
          + + - - + diff --git a/packages/main/test/samples/MultiComboBox.sample.html b/packages/main/test/samples/MultiComboBox.sample.html index 221e320e5116..dbe9c9f0c8bb 100644 --- a/packages/main/test/samples/MultiComboBox.sample.html +++ b/packages/main/test/samples/MultiComboBox.sample.html @@ -1,72 +1,38 @@ - - - - - <ui5-multi-combobox> - - - - - - - - - - - - - - - - - - - - -
          -

          MultiComboBox

          -
          - -
          -
          - -
          <ui5-multi-combobox>
          - -
          -

          Basic MultiComboBox

          -
          - - UI5 - - - UI5 - - - UI5 - -
          -
          
          +<style>
          +	.snippet ui5-multi-combobox {
          +		flex: 1;
          +		min-width: 240px;
          +		margin: 0 8px 8px 0;
          +	}
          +
          +	ui5-multi-combobox:not(:defined) {
          +		display: none;
          +	}
          +</style>
          +
          +<header class="component-heading">
          +	<h2 class="control-header">MultiComboBox</h2>
          +	<div class="component-heading-since">
          +		<span><!--since_tag_marker--></span>
          +	</div>
          +</header>
          +
          +<div style="margin-bottom: 2rem; font-weight: 300; font-size: 1.1rem; color: #666666;">&lt;ui5-multi-combobox&gt;</div>
          +
          +<section>
          +	<h3>Basic MultiComboBox</h3>
          +	<div class="snippet" style="display: flex; flex-wrap: wrap;">
          +		<ui5-multi-combobox placeholder="Type your value">
          +			<ui5-li selected>UI5</ui5-li>
          +		</ui5-multi-combobox>
          +		<ui5-multi-combobox readonly value="Readonly combo">
          +			<ui5-li selected>UI5</ui5-li>
          +		</ui5-multi-combobox>
          +		<ui5-multi-combobox disabled value="Disabled combo">
          +			<ui5-li selected>UI5</ui5-li>
          +		</ui5-multi-combobox>
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-multi-combobox placeholder="Type your value">
           	<ui5-li selected>UI5</ui5-li>
           </ui5-multi-combobox>
          @@ -78,26 +44,26 @@ <h3>Basic MultiComboBox</h3>
           <ui5-multi-combobox disabled value="Disabled combo">
           	<ui5-li selected>UI5</ui5-li>
           </ui5-multi-combobox>
          -		
          -
          + + -
          -

          MultiComboBox with items

          -
          - - Argentina - Bulgaria - Denmark - England - Albania - Morocco - Portugal - Germany - Philippines - Paraguay - -
          -
          
          +<section>
          +	<h3>MultiComboBox with items</h3>
          +	<div class="snippet">
          +		<ui5-multi-combobox style="width: 100%" placeholder="Choose your countries">
          +			<ui5-li selected>Argentina</ui5-li>
          +			<ui5-li>Bulgaria</ui5-li>
          +			<ui5-li>Denmark</ui5-li>
          +			<ui5-li>England</ui5-li>
          +			<ui5-li>Albania</ui5-li>
          +			<ui5-li>Morocco</ui5-li>
          +			<ui5-li>Portugal</ui5-li>
          +			<ui5-li>Germany</ui5-li>
          +			<ui5-li>Philippines</ui5-li>
          +			<ui5-li>Paraguay</ui5-li>
          +		</ui5-multi-combobox>
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-multi-combobox placeholder="Choose your countries">
           	<ui5-li selected>Argentina</ui5-li>
           	<ui5-li>Bulgaria</ui5-li>
          @@ -110,27 +76,26 @@ <h3>MultiComboBox with items</h3>
           	<ui5-li>Philippines</ui5-li>
           	<ui5-li>Paraguay</ui5-li>
           </ui5-multi-combobox>
          -		
          -
          + + -
          -

          MultiComboBox with free text input

          -
          - - Argentina - Bulgaria - Denmark - England - Albania - Morocco - Portugal - Germany - Philippines - Paraguay - -
          +
          +

          MultiComboBox with free text input

          -
          
          +		<ui5-multi-combobox style="width: 100%" placeholder="Choose your countries" allow-custom-values>
          +			<ui5-li>Argentina</ui5-li>
          +			<ui5-li selected>Bulgaria</ui5-li>
          +			<ui5-li>Denmark</ui5-li>
          +			<ui5-li selected>England</ui5-li>
          +			<ui5-li>Albania</ui5-li>
          +			<ui5-li>Morocco</ui5-li>
          +			<ui5-li>Portugal</ui5-li>
          +			<ui5-li selected>Germany</ui5-li>
          +			<ui5-li>Philippines</ui5-li>
          +			<ui5-li>Paraguay</ui5-li>
          +		</ui5-multi-combobox>
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-multi-combobox placeholder="Choose your countries">
           	<ui5-li>Argentina</ui5-li>
           	<ui5-li selected>Bulgaria</ui5-li>
          @@ -143,31 +108,31 @@ <h3>MultiComboBox with free text input</h3>
           	<ui5-li>Philippines</ui5-li>
           	<ui5-li>Paraguay</ui5-li>
           </ui5-multi-combobox>
          -		
          -
          - -
          -

          MultiComboBox with Value State

          -
          - - Fortune - Luck - Success - - - - Attention - Caution - Warning - - - - Fault - Error - Mistake - -
          -
          
          +	
          +
          + +
          +

          MultiComboBox with Value State

          +
          + + Fortune + Luck + Success + + + + Attention + Caution + Warning + + + + Fault + Error + Mistake + +
          +
          
           <ui5-multi-combobox value-state="Success">
           	<ui5-li>Fortune</ui5-li>
           	<ui5-li>Luck</ui5-li>
          @@ -185,15 +150,7 @@ <h3>MultiComboBox with Value State</h3>
           	<ui5-li selected>Error</ui5-li>
           	<ui5-li>Mistake</ui5-li>
           </ui5-multi-combobox>
          -			
          -
          - - - - - - + +
          - + diff --git a/packages/main/test/samples/Panel.sample.html b/packages/main/test/samples/Panel.sample.html index 417d1c807781..3e1d041b1168 100644 --- a/packages/main/test/samples/Panel.sample.html +++ b/packages/main/test/samples/Panel.sample.html @@ -1,71 +1,35 @@ - - - - - <ui5-panel> - - - - - - - - - - - - - - - - - - - - - - -
          -

          Panel

          -
          <ui5-panel>
          -
          - -
          -

          Basic Panel

          -
          - -

          I am a native heading!

          - Short text. -
          - Another text. -

          - Aute ullamco officia fugiat culpa do tempor tempor aute excepteur magna. Quis velit adipisicing excepteur do eu duis elit. Sunt ea pariatur nulla est laborum proident sunt labore commodo Lorem laboris nisi Lorem. -

          -
          -
          -
          
          +<style>
          +	.header {
          +		display: flex;
          +		align-items: center;
          +		justify-content: space-between;
          +		width: 100%;
          +	}
           
          +	.hcb .content-color {
          +		color: #fff;
          +	}
          +</style>
          +<header>
          +	<h2 class="control-header">Panel</h2>
          +	<div style="margin-bottom: 2rem; font-weight: 300; font-size: 1.1rem; color: #666666;">&lt;ui5-panel&gt;</div>
          +</header>
          +
          +<section>
          +	<h3>Basic Panel</h3>
          +	<div class="snippet">
          +		<ui5-panel width="100%" accessible-role="Complementary"
          +			header-text="Both expandable and expanded" class="full-width">
          +			<h1 class="content-color">I am a native heading!</h1>
          +			<ui5-label wrap>Short text.</ui5-label>
          +			<br>
          +			<ui5-label wrap>Another text.</ui5-label>
          +			<p class="content-color">
          +				Aute ullamco officia fugiat culpa do tempor tempor aute excepteur magna. Quis velit adipisicing excepteur do eu duis elit. Sunt ea pariatur nulla est laborum proident sunt labore commodo Lorem laboris nisi Lorem.
          +			</p>
          +		</ui5-panel>
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-panel width="100%" accessible-role="Complementary"
           	header-text="Both expandable and expanded" class="full-width">
           	<h1 class="content-color">I am a native heading!</h1>
          @@ -76,27 +40,27 @@ <h1 class="content-color">I am a native heading!</h1>
           		Aute ullamco officia fugiat culpa do tempor tempor aute excepteur magna. Quis velit adipisicing excepteur do eu duis elit. Sunt ea pariatur nulla est laborum proident sunt labore commodo Lorem laboris nisi Lorem.
           	</p>
           </ui5-panel>
          -		
          -
          - -
          -

          Panel with List

          -
          - - - Argentina - Bulgaria - China - Germany - Hungary - England - USA - Canada - - -
          -
          
          +	
          +
          + +
          +

          Panel with List

          +
          + + + Argentina + Bulgaria + China + Germany + Hungary + England + USA + Canada + + +
          +
          
           <ui5-panel accessible-role="Complementary"
           	header-text="Select your country" class="full-width">
           	<ui5-list id="myList1" mode="MultiSelect">
          @@ -110,22 +74,22 @@ <h3>Panel with List</h3>
           		<ui5-li key="country8">Canada</ui5-li>
           	</ui5-list>
           </ui5-panel>
          -		
          -
          - -
          -

          Fixed Panel (Can't be Collapsed/Expanded)

          -
          - - - Argentina - Bulgaria - China - Germany - - -
          -
          
          +	
          +
          + +
          +

          Fixed Panel (Can't be Collapsed/Expanded)

          +
          + + + Argentina + Bulgaria + China + Germany + + +
          +
          
           <ui5-panel
           	fixed accessible-role="Complementary"
           	header-text="Country Of Birth"
          @@ -137,34 +101,34 @@ <h3>Fixed Panel (Can't be Collapsed/Expanded)</h3>
           		<ui5-li key="country4">Germany</ui5-li>
           	</ui5-list>
           </ui5-panel>
          -		
          -
          - -
          -

          Panel with Custom Header

          -
          - - - -
          - Countries -
          - Edit - Add - Remove -
          + +
          + +
          +

          Panel with Custom Header

          +
          + + + +
          + Countries +
          + Edit + Add + Remove
          - - - Argentina - Bulgaria - China - - -
          -
          
          +			</div>
          +
          +			<ui5-list id="myList1" mode="MultiSelect">
          +				<ui5-li key="country1">Argentina</ui5-li>
          +				<ui5-li key="country2">Bulgaria</ui5-li>
          +				<ui5-li key="country3">China</ui5-li>
          +			</ui5-list>
          +		</ui5-panel>
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <style>
           	.header {
           		display: flex;
          @@ -194,14 +158,7 @@ <h3>Panel with Custom Header</h3>
           		<ui5-li key="country3">China</ui5-li>
           	</ui5-list>
           </ui5-panel>
          -		
          -
          - - - - - + + - + diff --git a/packages/main/test/samples/Popover.sample.html b/packages/main/test/samples/Popover.sample.html index bf6790ea3b03..97b1262d6f64 100644 --- a/packages/main/test/samples/Popover.sample.html +++ b/packages/main/test/samples/Popover.sample.html @@ -1,75 +1,41 @@ - - - - - <ui5-popover> - - - - - - - - - - - - - - - - - - - - -
          -

          Popover

          -
          <ui5-popover>
          -
          - -
          -

          Basic Popover

          -
          - Open Popover - - -
          -
          - Email: - -
          -
          -
          - + diff --git a/packages/main/test/samples/RadioButton.sample.html b/packages/main/test/samples/RadioButton.sample.html index 069b1fbb4e51..03023106b734 100644 --- a/packages/main/test/samples/RadioButton.sample.html +++ b/packages/main/test/samples/RadioButton.sample.html @@ -1,78 +1,45 @@ - - - - - <ui5-radiobutton> - - - - - - - - - - - - - - - - - - - - -
          -

          RadioButton

          -
          <ui5-radiobutton>
          -
          - -
          -

          Basic RadioButton Types

          -
          - - - - - -
          -
          
          +<header>
          +	<h2 class="control-header">RadioButton</h2>
          +	<div style="margin-bottom: 2rem; font-weight: 300; font-size: 1.1rem; color: #666666;">&lt;ui5-radiobutton&gt;</div>
          +</header>
          +
          +<section>
          +	<h3>Basic RadioButton Types</h3>
          +	<div class="snippet">
          +		<ui5-radiobutton text="Option A" selected name="GroupA"></ui5-radiobutton>
          +		<ui5-radiobutton text="Option B" value-state="None" name="GroupA"></ui5-radiobutton>
          +		<ui5-radiobutton text="Option C" value-state="Warning" name="GroupA"></ui5-radiobutton>
          +		<ui5-radiobutton text="Option D" value-state="Error" name="GroupA"></ui5-radiobutton>
          +		<ui5-radiobutton text="Option E" disabled name="GroupA"></ui5-radiobutton>
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-radiobutton text="Option A" selected name="GroupA"></ui5-radiobutton>
           <ui5-radiobutton text="Option B" value-state="None" name="GroupA"></ui5-radiobutton>
           <ui5-radiobutton text="Option C" value-state="Warning" name="GroupA"></ui5-radiobutton>
           <ui5-radiobutton text="Option D" value-state="Error" name="GroupA"></ui5-radiobutton>
           <ui5-radiobutton text="Option E" disabled name="GroupA"></ui5-radiobutton>
          -		
          -
          + + +

          RadioButton in group - navigate via [UP/Right] and [DOWN/Left] arrow keys

          -
          -
          - Group of states - Selected radio: None - - - -
          -
          - Group of options - Selected radio: Option A - - - -
          +
          +
          + Group of states + Selected radio: None + + +
          -
          
          +		<div id="radioGroup2" class="radio-button-group">
          +			<ui5-title>Group of options</ui5-title>
          +			<ui5-label id="lblRadioGroup2">Selected radio: Option A</ui5-label>
          +			<ui5-radiobutton text="Option A" selected name="GroupC"></ui5-radiobutton>
          +			<ui5-radiobutton text="Option B" value-state="None" name="GroupC"></ui5-radiobutton>
          +			<ui5-radiobutton text="Option C" value-state="None" name="GroupC"></ui5-radiobutton>
          +		</div>
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <script>
           radioGroup.addEventListener("select", function(e) {
           	lblRadioGroup.innerHTML = e.target.text;
          @@ -93,24 +60,17 @@ <h3>RadioButton in group - navigate via [UP/Right] and [DOWN/Left] arrow keys</h
           	<ui5-radiobutton text="Option B" value-state="None" name="GroupC"></ui5-radiobutton>
           	<ui5-radiobutton text="Option C" value-state="None" name="GroupC"></ui5-radiobutton>
           </div>
          -		
          -
          - - + + - + - + radioGroup2.addEventListener("select", function(e) { + lblRadioGroup2.innerHTML = e.target.text; + }); + - + diff --git a/packages/main/test/samples/Select.sample.html b/packages/main/test/samples/Select.sample.html index dc0db93e51f3..38adff2c008d 100644 --- a/packages/main/test/samples/Select.sample.html +++ b/packages/main/test/samples/Select.sample.html @@ -1,75 +1,41 @@ - - + - - + } + -
          -

          Select

          -
          - -
          -
          +
          +

          Select

          +
          + +
          +
          -
          <ui5-select>
          -
          -

          Basic Select

          -
          - - Phone +
          <ui5-select>
          +
          +

          Basic Select

          +
          + + Phone + Tablet + Desktop + + + Phone Tablet - Desktop - - - Phone - Tablet - Desktop - -
          -
          
          +				<ui5-option icon="sap-icon://laptop">Desktop</ui5-option>
          +		</ui5-select>
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-select class="select">
           	<ui5-option icon="sap-icon://iphone">Phone</ui5-option>
           	<ui5-option icon="sap-icon://ipad">Tablet</ui5-option>
          @@ -80,29 +46,29 @@ <h3>Basic Select</h3>
           	<ui5-option icon="sap-icon://ipad">Tablet</ui5-option>
           	<ui5-option icon="sap-icon://laptop">Desktop</ui5-option>
           </ui5-select>
          -		
          -
          + +
          -
          -

          Select with Value State

          -
          - - Apple - Avocado - Mango - - - Orange - Pumpkin - Carrot - - - Strawberry - Tomato - Red Chili Pepper - -
          -
          
          +<section>
          +	<h3>Select with Value State</h3>
          +	<div class="snippet">
          +		<ui5-select value-state="Success" class="select">
          +				<ui5-option icon="sap-icon://meal" selected>Apple</ui5-option>
          +				<ui5-option icon="sap-icon://meal">Avocado</ui5-option>
          +				<ui5-option icon="sap-icon://meal">Mango</ui5-option>
          +		</ui5-select>
          +		<ui5-select value-state="Warning" class="select">
          +				<ui5-option icon="sap-icon://meal">Orange</ui5-option>
          +				<ui5-option icon="sap-icon://meal" selected>Pumpkin</ui5-option>
          +				<ui5-option icon="sap-icon://meal">Carrot</ui5-option>
          +		</ui5-select>
          +		<ui5-select value-state="Error" class="select">
          +				<ui5-option icon="sap-icon://meal">Strawberry</ui5-option>
          +				<ui5-option icon="sap-icon://meal">Tomato</ui5-option>
          +				<ui5-option icon="sap-icon://meal" selected>Red Chili Pepper</ui5-option>
          +		</ui5-select>
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-select value-state="Success" class="select">
           	<ui5-option icon="sap-icon://meal" selected>Apple</ui5-option>
           	<ui5-option icon="sap-icon://meal">Avocado</ui5-option>
          @@ -118,14 +84,7 @@ <h3>Select with Value State</h3>
           	<ui5-option icon="sap-icon://meal">Tomato</ui5-option>
           	<ui5-option icon="sap-icon://meal" selected>Red Chili Pepper</ui5-option>
           </ui5-select>
          -		
          -
          - - - - - + + - + diff --git a/packages/main/test/samples/ShellBar.sample.html b/packages/main/test/samples/ShellBar.sample.html index 50c95d8ee2b6..df523e6a69e6 100644 --- a/packages/main/test/samples/ShellBar.sample.html +++ b/packages/main/test/samples/ShellBar.sample.html @@ -1,112 +1,71 @@ - - - - - <ui5-shellbar> - - - - - - - - +
          +

          ShellBar

          +
          + +
          +
          - +
          <ui5-shellbar>
          - - - - - - - - - - - -
          -

          ShellBar

          -
          - -
          -
          - -
          <ui5-shellbar>
          - -
          -

          ShellBar

          -
          - + - + + - - + - + Application 1 + Application 2 + Application 3 + Application 4 + Application 5 + - Application 1 - Application 2 - Application 3 - Application 4 - Application 5 - + +
          + An Kimura +
          - -
          - An Kimura -
          +
          + + App Finder + Settings + Edit Home Page + Help + Sign out + +
          +
          -
          - - App Finder - Settings - Edit Home Page - Help - Sign out - +
          -
          - - -
          - -
          -		
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-shellbar
           	id="shellbar"
           	primary-title="Corporate Portal"
           	secondary-title="secondary title"
          -	logo="../../images/sap-logo-svg.svg"
          -	profile="../../www/samples/images/woman_avatar_5.png"
          +	logo="../../assets/images/sap-logo-svg.svg"
          +	profile="../../assets/images/avatars/woman_avatar_5.png"
           	notification-count="99+"
           	show-notifications
           	show-product-switch
          @@ -148,59 +107,57 @@ <h3>ShellBar</h3>
           	shellbar.addEventListener("profileClick", function(event) {
           		popover.openBy(event.detail.targetRef);
           	});
          -
           </script>
          -		
          -				
          -
          - - -
          -

          Basic ShellBar

          -
          - - -
          + +
          + + +
          +

          Basic ShellBar

          +
          + + + + + +
          -
          -
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-shellbar
          -	profile="../../www/samples/images/woman_avatar_5.png"
          +	profile="../../assets/images/avatars/woman_avatar_5.png"
           	primary-title="Corporate Portal"
           	secondary-title="secondary title"
          -	logo="../../images/sap-logo-svg.svg"
          +	logo="../../assets/images/sap-logo-svg.svg"
           >
           </ui5-shellbar>
          -
          -		
          -
          - - -
          -

          ShellBar with search and notifications

          -
          - - - - -
          + +
          + + +
          +

          ShellBar with search and notifications

          +
          + + + + +
          -
          -	
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-shellbar
          -	profile="../../www/samples/images/woman_avatar_5.png"
          +	profile="../../assets/images/avatars/woman_avatar_5.png"
           	primary-title="Corporate Portal"
           	secondary-title="secondary title"
           	logo="../../images/sap-logo-svg.svg"
          @@ -210,35 +167,33 @@ <h3>ShellBar with search and notifications</h3>
           
           	<ui5-input slot="searchField" placeholer="Enter service..."></ui5-input>
           </ui5-shellbar>
          -	
          -			
          -
          - - -
          -

          ShellBar with product switch and CoPilot

          -
          - - - -
          + +
          + + +
          +

          ShellBar with product switch and CoPilot

          +
          + + + +
          -
          -	
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-shellbar
          -profile="../../www/samples/images/woman_avatar_5.png"
          +profile="../../assets/images/avatars/woman_avatar_5.png"
           primary-title="Corporate Portal"
           secondary-title="secondary title"
          -logo="../../images/sap-logo-svg.svg"
          +logo="../../assets/images/sap-logo-svg.svg"
           show-co-pilot
           show-product-switch
           show-notifications
          @@ -246,14 +201,7 @@ <h3>ShellBar with product switch and CoPilot</h3>
           >
           
           </ui5-shellbar>
          -	
          -			
          -
          - - + + - - - + diff --git a/packages/main/test/samples/Switch.sample.html b/packages/main/test/samples/Switch.sample.html index 6d1e5618f805..b76f0aec46b8 100644 --- a/packages/main/test/samples/Switch.sample.html +++ b/packages/main/test/samples/Switch.sample.html @@ -1,94 +1,53 @@ - - - - - <ui5-switch> - - - - - - - - - - - - - - - - - - - - - - -
          -

          Switch

          -
          - -
          -
          -
          <ui5-switch>
          - - -
          -

          Basic Switch

          -
          - - - - - - -
          -
          
          +<style>
          +	ui5-switch {
          +		margin: 8px;
          +	}
          +</style>
          +
          +<header class="component-heading">
          +	<h2 class="control-header">Switch</h2>
          +	<div class="component-heading-since">
          +		<span><!--since_tag_marker--></span>
          +	</div>
          +</header>
          +<div style="margin-bottom: 2rem; font-weight: 300; font-size: 1.1rem; color: #666666;">&lt;ui5-switch&gt;</div>
          +
          +<!-- Basic Switch -->
          +<section>
          +	<h3>Basic Switch</h3>
          +	<div class="snippet">
          +		<ui5-switch text-on="On" text-off="Off"></ui5-switch>
          +		<ui5-switch text-on="On" text-off="Off" checked></ui5-switch>
          +		<ui5-switch></ui5-switch>
          +		<ui5-switch checked></ui5-switch>
          +		<ui5-switch text-on="Yes" text-off="No" disabled></ui5-switch>
          +		<ui5-switch text-on="Yes" text-off="No" checked disabled ></ui5-switch>
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-switch text-on="On" text-off="Off"></ui5-switch>
           <ui5-switch text-on="On" text-off="Off" checked></ui5-switch>
           <ui5-switch></ui5-switch>
           <ui5-switch checked></ui5-switch>
           <ui5-switch text-on="Yes" text-off="No" disabled></ui5-switch>
           <ui5-switch text-on="Yes" text-off="No" checked disabled ></ui5-switch>
          -		
          -
          + + - -
          + +

          Graphical Switch

          -
          - - - - -
          -
          
          +	<div class="snippet">
          +		<ui5-switch graphical></ui5-switch>
          +		<ui5-switch graphical checked></ui5-switch>
          +		<ui5-switch graphical disabled></ui5-switch>
          +		<ui5-switch graphical checked disabled></ui5-switch>
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-switch graphical></ui5-switch>
           <ui5-switch graphical checked></ui5-switch>
           <ui5-switch graphical disabled></ui5-switch>
           <ui5-switch graphical checked disabled></ui5-switch>
          -		
          -
          - - - - - + +
          - + diff --git a/packages/main/test/samples/TabContainer.sample.html b/packages/main/test/samples/TabContainer.sample.html index addffd27c2e5..8c0efebe8800 100644 --- a/packages/main/test/samples/TabContainer.sample.html +++ b/packages/main/test/samples/TabContainer.sample.html @@ -1,65 +1,31 @@ - - +
          +

          TabContainer

          +
          <ui5-tabcontainer>
          +
          - - <ui5-tabcontainer> - - - - - - - - - - - - - - - - - - - - -
          -

          TabContainer

          -
          <ui5-tabcontainer>
          -
          - -
          -

          Basic TabContainer

          -
          - - - Quibusdam, veniam! Architecto debitis iusto ad et, asperiores quisquam perferendis reprehenderit ipsa voluptate minus minima, perspiciatis cum. Totam harum necessitatibus numquam voluptatum. - - - Lorem ipsum dolor sit amet consectetur adipisicing elit. Fuga magni facere error dicta beatae optio repudiandae vero, quidem voluptatibus perferendis eum maiores rem tempore voluptates aperiam eos enim delectus unde. - - - Dignissimos debitis architecto temporibus doloribus reiciendis libero rem nemo, nobis quidem dolor praesentium, beatae voluptatum iste eveniet, nam voluptatem obcaecati ducimus dolore. - - - Possimus ipsa eos impedit aut nisi repellendus recusandae, temporibus ducimus, necessitatibus tenetur facere, minima vero fugit rem reiciendis natus ratione quia numquam? - - - - Explicabo laboriosam ab consequuntur, qui dignissimos inventore sapiente ullam quaerat ratione libero vero, beatae laudantium! Aperiam numquam tempore, laudantium perferendis recusandae autem. - - -
          -
          
          +<section>
          +	<h3>Basic TabContainer</h3>
          +	<div class="snippet">
          +		<ui5-tabcontainer class="full-width" show-overflow>
          +			<ui5-tab icon="sap-icon://menu" text="Tab 1">
          +				<ui5-label>Quibusdam, veniam! Architecto debitis iusto ad et, asperiores quisquam perferendis reprehenderit ipsa voluptate minus minima, perspiciatis cum. Totam harum necessitatibus numquam voluptatum.</ui5-label>
          +			</ui5-tab>
          +			<ui5-tab icon="sap-icon://activities" text="Tab 2" selected>
          +				<ui5-label>Lorem ipsum dolor sit amet consectetur adipisicing elit. Fuga magni facere error dicta beatae optio repudiandae vero, quidem voluptatibus perferendis eum maiores rem tempore voluptates aperiam eos enim delectus unde.</ui5-label>
          +			</ui5-tab>
          +			<ui5-tab icon="sap-icon://add" text="Tab 3">
          +				<ui5-label>Dignissimos debitis architecto temporibus doloribus reiciendis libero rem nemo, nobis quidem dolor praesentium, beatae voluptatum iste eveniet, nam voluptatem obcaecati ducimus dolore.</ui5-label>
          +			</ui5-tab>
          +			<ui5-tab icon="sap-icon://calendar" text="Tab 4">
          +				<ui5-label>Possimus ipsa eos impedit aut nisi repellendus recusandae, temporibus ducimus, necessitatibus tenetur facere, minima vero fugit rem reiciendis natus ratione quia numquam?</ui5-label>
          +			</ui5-tab>
          +			<ui5-tab-separator></ui5-tab-separator>
          +			<ui5-tab icon="sap-icon://action-settings" text="Tab 5">
          +				<ui5-label>Explicabo laboriosam ab consequuntur, qui dignissimos inventore sapiente ullam quaerat ratione libero vero, beatae laudantium! Aperiam numquam tempore, laudantium perferendis recusandae autem.</ui5-label>
          +			</ui5-tab>
          +		</ui5-tabcontainer>
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-tabcontainer class="full-width" show-overflow>
           	<ui5-tab text="Tab 1">
           		<ui5-label>Quibusdam, veniam! Architecto debitis iusto ad et, asperiores quisquam perferendis reprehenderit ipsa voluptate minus minima, perspiciatis cum. Totam harum necessitatibus numquam voluptatum.</ui5-label>
          @@ -78,21 +44,21 @@ <h3>Basic TabContainer</h3>
           		<ui5-label>Explicabo laboriosam ab consequuntur, qui dignissimos inventore sapiente ullam quaerat ratione libero vero, beatae laudantium! Aperiam numquam tempore, laudantium perferendis recusandae autem.</ui5-label>
           	</ui5-tab>
           </ui5-tabcontainer>
          -		
          -
          + + -
          -

          Text Only TabContainer

          -
          - - - - - - - -
          -
          
          +<section>
          +	<h3>Text Only TabContainer</h3>
          +	<div class="snippet">
          +		<ui5-tabcontainer class="full-width" collapsed fixed show-overflow>
          +			<ui5-tab text="Home"></ui5-tab>
          +			<ui5-tab text="What's new" selected></ui5-tab>
          +			<ui5-tab text="Who are we"></ui5-tab>
          +			<ui5-tab text="About"></ui5-tab>
          +			<ui5-tab text="Contacts"></ui5-tab>
          +		</ui5-tabcontainer>
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-tabcontainer class="full-width" collapsed fixed show-overflow>
           	<ui5-tab text="Home"></ui5-tab>
           	<ui5-tab text="What's new" selected></ui5-tab>
          @@ -100,14 +66,7 @@ <h3>Text Only TabContainer</h3>
           	<ui5-tab text="About"></ui5-tab>
           <ui5-tab text="Contacts"></ui5-tab>
           </ui5-tabcontainer>
          -		
          -
          - - - - - + + - + diff --git a/packages/main/test/samples/Table.sample.html b/packages/main/test/samples/Table.sample.html index 87a258b3011e..e4a6b38e86d9 100644 --- a/packages/main/test/samples/Table.sample.html +++ b/packages/main/test/samples/Table.sample.html @@ -1,92 +1,91 @@ - - - - - <ui5-table> - - - - - - - - - - - - - - - - - - - - - - -
          -

          Table

          -
          <ui5-table>
          -
          - -
          -

          Basic Table

          -
          + +s +
          +

          Table

          +
          <ui5-table>
          +
          + +
          +

          Basic Table

          +
          + + +
          + Products table - resize your browser to make some columns pop-in + Toggle Sticky Column Header +
          - -
          - Products table - resize your browser to make some columns pop-in - Toggle Sticky Column Header -
          + + + + Product + - - - - Product - + + Supplier + - - Supplier - + + Dimensions + - - Dimensions - + + Weight + - - Weight - + + Price + - - Price - + - +
          -
          -
          
          +		<ui5-table class="demo-table" id="tbl">
          +			<!-- Columns -->
          +			<ui5-table-column slot="columns" width="12em">
          +				<span style="line-height: 1.4rem">Product</span>
          +			</ui5-table-column>
          +
          +			<ui5-table-column slot="columns" min-width="800" popin-text="Supplier">
          +				<span style="line-height: 1.4rem">Supplier</span>
          +			</ui5-table-column>
          +
          +			<ui5-table-column slot="columns" min-width="600" popin-text="Dimensions" demand-popin>
          +				<span style="line-height: 1.4rem">Dimensions</span>
          +			</ui5-table-column>
          +
          +			<ui5-table-column slot="columns" min-width="600" popin-text="Weight" demand-popin>
          +				<span style="line-height: 1.4rem">Weight</span>
          +			</ui5-table-column>
          +
          +			<ui5-table-column slot="columns" >
          +				<span style="line-height: 1.4rem">Price</span>
          +			</ui5-table-column>
          +
          +		</ui5-table>
          +
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <!-- Header -->
           <div class="header">
           	<span>Products table - resize your browser to make some columns pop-in</span>
          @@ -168,300 +167,295 @@ <h3>Table with No Data</h3>
           		<span style="line-height: 1.4rem">Price</span>
           	</ui5-table-column>
           </ui5-table>
          -		
          -
          - - - - - - - + + + + + + diff --git a/packages/main/test/samples/TextArea.sample.html b/packages/main/test/samples/TextArea.sample.html index 3d2a13fbd962..b777efdf8102 100644 --- a/packages/main/test/samples/TextArea.sample.html +++ b/packages/main/test/samples/TextArea.sample.html @@ -1,67 +1,26 @@ - - - - - <ui5-textarea> - - - - - - - - - - - - - - - - - - - - -
          -

          TextArea

          -
          <ui5-textarea>
          -
          - -
          -

          Basic TextArea

          -
          - -
          -
          
          +<header>
          +	<h2 class="control-header">TextArea</h2>
          +	<div style="margin-bottom: 2rem; font-weight: 300; font-size: 1.1rem; color: #666666;">&lt;ui5-textarea&gt;</div>
          +</header>
          +
          +<section>
          +	<h3>Basic TextArea</h3>
          +	<div class="snippet">
          +		<ui5-textarea class="textarea-width" placeholder="Type as much text as you wish"></ui5-textarea>
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-textarea placeholder="Type as much text as you wish"></ui5-textarea>
          -		
          -
          - -
          -

          TextArea with Maximum Length

          -
          - -
          -
          
          +	
          +
          + +
          +

          TextArea with Maximum Length

          +
          + +
          +
          
           <ui5-textarea placeholder="Type some text" max-length="10" show-exceeded-text></ui5-textarea>
          -		
          -
          - - - - - + + - + diff --git a/packages/main/test/samples/Timeline.sample.html b/packages/main/test/samples/Timeline.sample.html index 14869d2fe921..0f3ca6ee899a 100644 --- a/packages/main/test/samples/Timeline.sample.html +++ b/packages/main/test/samples/Timeline.sample.html @@ -1,68 +1,32 @@ - - - - - <ui5-timeline> - - - - - - - - - - - - - - - - - - - - - - - - -
          -

          Timeline

          -
          - -
          -
          - -
          <ui5-timeline>
          - -
          -

          Basic Timeline

          -
          - - - -
          MR SOF02 2.43
          -
          - -
          Online meeting
          -
          -
          -
          -
          
          +<style>
          +	ui5-card {
          +		width: 300px;
          +	}
          +</style>
          +
          +<header class="component-heading">
          +	<h2 class="control-header">Timeline</h2>
          +	<div class="component-heading-since">
          +		<span><!--since_tag_marker--></span>
          +	</div>
          +</header>
          +
          +<div style="margin-bottom: 2rem; font-weight: 300; font-size: 1.1rem; color: #666666;">&lt;ui5-timeline&gt;</div>
          +
          +<section>
          +	<h3>Basic Timeline</h3>
          +	<div class="snippet">
          +		<ui5-timeline>
          +			<ui5-timeline-item id="test-item" title-text="called" subtitle-text="20.02.2017 11:30" icon="sap-icon://phone" item-name="John Smith" item-name-clickable></ui5-timeline-item>
          +			<ui5-timeline-item title-text="Weekly Sync - CP Design" subtitle-text="27.07.2017 (11:00 - 12:30)" icon="sap-icon://calendar">
          +				<div>MR SOF02 2.43</div>
          +			</ui5-timeline-item>
          +			<ui5-timeline-item title-text="Video Converence Call - UI5" subtitle-text="31.01.2018 (12:00 - 13:00)" icon="sap-icon://calendar">
          +				<div>Online meeting</div>
          +			</ui5-timeline-item>
          +		</ui5-timeline>
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-timeline>
           	<ui5-timeline-item id="test-item" title-text="called" subtitle-text="20.02.2017 11:30" icon="sap-icon://phone" item-name="John Smith" item-name-clickable></ui5-timeline-item>
           	<ui5-timeline-item title-text="Weekly Sync - CP Design" subtitle-text="27.07.2017 (11:00 - 12:30)" icon="sap-icon://calendar">
          @@ -72,12 +36,7 @@ <h3>Basic Timeline</h3>
           		<div>Online meeting</div>
           	</ui5-timeline-item>
           </ui5-timeline>
          -		
          -
          - - - + + - + diff --git a/packages/main/test/samples/Title.sample.html b/packages/main/test/samples/Title.sample.html index 454d1331322c..f089731326e3 100644 --- a/packages/main/test/samples/Title.sample.html +++ b/packages/main/test/samples/Title.sample.html @@ -1,67 +1,26 @@ - - - - - <ui5-title> - - - - - - - - - - - - - - - - - - - - -
          -

          Title

          -
          <ui5-title>
          -
          - -
          -

          Title in All Available Levels

          -
          - Title level 1 - Title level 2 - Title level 3 - Title level 4 - Title level 5 - Title level 6 -
          -
          
          +<header>
          +	<h2 class="control-header">Title</h2>
          +	<div style="margin-bottom: 2rem; font-weight: 300; font-size: 1.1rem; color: #666666;">&lt;ui5-title&gt;</div>
          +</header>
          +
          +<section>
          +	<h3>Title in All Available Levels</h3>
          +	<div class="snippet flex-column">
          +		<ui5-title level="H1">Title level 1</ui5-title>
          +		<ui5-title level="H2">Title level 2</ui5-title>
          +		<ui5-title level="H3">Title level 3</ui5-title>
          +		<ui5-title level="H4">Title level 4</ui5-title>
          +		<ui5-title level="H5">Title level 5</ui5-title>
          +		<ui5-title level="H6">Title level 6</ui5-title>
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-title level="H1">Title level 1</ui5-title>
           <ui5-title level="H2">Title level 2</ui5-title>
           <ui5-title level="H3">Title level 3</ui5-title>
           <ui5-title level="H4">Title level 4</ui5-title>
           <ui5-title level="H5">Title level 5</ui5-title>
           <ui5-title level="H6">Title level 6</ui5-title>
          -		
          -
          - - - - - + + - + diff --git a/packages/main/test/samples/ToggleButton.sample.html b/packages/main/test/samples/ToggleButton.sample.html index 9dbe71f6d335..392f9062cc65 100644 --- a/packages/main/test/samples/ToggleButton.sample.html +++ b/packages/main/test/samples/ToggleButton.sample.html @@ -1,57 +1,23 @@ - - +
          +

          ToggleButton

          +
          <ui5-togglebutton>
          +
          - - <ui5-togglebutton> - - - - - - - - - - - - - - - - - - - - -
          -

          ToggleButton

          -
          <ui5-togglebutton>
          -
          - -
          -

          ToggleButton States

          -
          - ToggleButton - Pressed ToggleButton - Disabled ToggleButton - Disabled ToggleButton - Accept ToggleButton - Accept ToggleButton - Reject ToggleButton - Reject ToggleButton - Transparent ToggleButton - Transparent ToggleButton -
          -
          
          +<section>
          +	<h3>ToggleButton States</h3>
          +	<div class="snippet">
          +		<ui5-togglebutton class="samples-margin">ToggleButton</ui5-togglebutton>
          +		<ui5-togglebutton class="samples-margin" pressed>Pressed ToggleButton</ui5-togglebutton>
          +		<ui5-togglebutton class="samples-margin" disabled>Disabled ToggleButton</ui5-togglebutton>
          +		<ui5-togglebutton class="samples-margin" disabled pressed>Disabled ToggleButton</ui5-togglebutton>
          +		<ui5-togglebutton class="samples-margin" design="Positive">Accept ToggleButton</ui5-togglebutton>
          +		<ui5-togglebutton class="samples-margin" design="Positive" pressed>Accept ToggleButton</ui5-togglebutton>
          +		<ui5-togglebutton class="samples-margin" design="Negative">Reject ToggleButton</ui5-togglebutton>
          +		<ui5-togglebutton class="samples-margin" design="Negative" pressed>Reject ToggleButton</ui5-togglebutton>
          +		<ui5-togglebutton class="samples-margin" design="Transparent">Transparent ToggleButton</ui5-togglebutton>
          +		<ui5-togglebutton class="samples-margin" design="Transparent" pressed>Transparent ToggleButton</ui5-togglebutton>
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-togglebutton>ToggleButton</ui5-togglebutton>
           <ui5-togglebutton pressed>Pressed ToggleButton</ui5-togglebutton>
           <ui5-togglebutton disabled>Disabled ToggleButton</ui5-togglebutton>
          @@ -62,42 +28,42 @@ <h3>ToggleButton States</h3>
           <ui5-togglebutton design="Negative" pressed>Reject ToggleButton</ui5-togglebutton>
           <ui5-togglebutton design="Transparent">Transparent ToggleButton</ui5-togglebutton>
           <ui5-togglebutton design="Transparent" pressed>Transparent ToggleButton</ui5-togglebutton>
          -		
          -
          + + -
          -

          ToggleButton with Icon

          -
          - Menu - Add - Back - Accept - Deny -
          -
          
          +<section>
          +	<h3>ToggleButton with Icon</h3>
          +	<div class="snippet">
          +		<ui5-togglebutton class="samples-margin" icon="sap-icon://menu">Menu</ui5-togglebutton>
          +		<ui5-togglebutton class="samples-margin" design="Emphasized" icon="sap-icon://add">Add</ui5-togglebutton>
          +		<ui5-togglebutton class="samples-margin" design="Default" icon="sap-icon://nav-back">Back</ui5-togglebutton>
          +		<ui5-togglebutton class="samples-margin" design="Positive" icon="sap-icon://accept">Accept</ui5-togglebutton>
          +		<ui5-togglebutton class="samples-margin" design="Negative" icon="sap-icon://sys-cancel">Deny</ui5-togglebutton>
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-togglebutton icon="sap-icon://menu">Menu</ui5-togglebutton>
           <ui5-togglebutton design="Emphasized" icon="sap-icon://add">Add</ui5-togglebutton>
           <ui5-togglebutton design="Default" icon="sap-icon://nav-back">Back</ui5-togglebutton>
           <ui5-togglebutton design="Positive" icon="sap-icon://accept">Accept</ui5-togglebutton>
           <ui5-togglebutton design="Negative" icon="sap-icon://sys-cancel">Deny</ui5-togglebutton>
          -		
          -
          + + -
          -

          ToggleButton with Icon Only

          -
          - - - - - - - - - - -
          -
          
          +<section>
          +	<h3>ToggleButton with Icon Only</h3>
          +	<div class="snippet">
          +			<ui5-togglebutton class="samples-margin" icon="sap-icon://away"></ui5-togglebutton>
          +			<ui5-togglebutton class="samples-margin" icon="sap-icon://action-settings" pressed></ui5-togglebutton>
          +			<ui5-togglebutton class="samples-margin" icon="sap-icon://add"></ui5-togglebutton>
          +			<ui5-togglebutton class="samples-margin" icon="sap-icon://alert" pressed></ui5-togglebutton>
          +			<ui5-togglebutton class="samples-margin" icon="sap-icon://accept" design="Positive"></ui5-togglebutton>
          +			<ui5-togglebutton class="samples-margin" icon="sap-icon://bookmark" design="Positive" pressed></ui5-togglebutton>
          +			<ui5-togglebutton class="samples-margin" icon="sap-icon://cancel" design="Negative"></ui5-togglebutton>
          +			<ui5-togglebutton class="samples-margin" icon="sap-icon://call" design="Negative" pressed></ui5-togglebutton>
          +			<ui5-togglebutton class="samples-margin" icon="sap-icon://camera" design="Transparent"></ui5-togglebutton>
          +			<ui5-togglebutton class="samples-margin" icon="sap-icon://cart" design="Transparent" pressed></ui5-togglebutton>
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-togglebutton icon="sap-icon://accept"></ui5-togglebutton>
           <ui5-togglebutton icon="sap-icon://action-settings" pressed></ui5-togglebutton>
           <ui5-togglebutton icon="sap-icon://add"></ui5-togglebutton>
          @@ -108,24 +74,24 @@ <h3>ToggleButton with Icon Only</h3>
           <ui5-togglebutton icon="sap-icon://call" design="Negative" pressed></ui5-togglebutton>
           <ui5-togglebutton icon="sap-icon://camera" design="Transparent"></ui5-togglebutton>
           <ui5-togglebutton icon="sap-icon://cart" design="Transparent" pressed></ui5-togglebutton>
          -		
          -
          + + -
          -

          ToggleButton

          -
          - Yes/No - Yes/No - Toggle Button - Toggle Button pressed - On/Off - On/Off - Menu - Menu - Transparent - Transparent -
          -
          
          +<section>
          +	<h3>ToggleButton</h3>
          +	<div class="snippet">
          +			<ui5-togglebutton class="samples-margin">Yes/No</ui5-togglebutton>
          +			<ui5-togglebutton class="samples-margin" pressed>Yes/No</ui5-togglebutton>
          +			<ui5-togglebutton class="samples-margin">Toggle Button</ui5-togglebutton>
          +			<ui5-togglebutton class="samples-margin" pressed>Toggle Button pressed</ui5-togglebutton>
          +			<ui5-togglebutton class="samples-margin" design="Positive">On/Off</ui5-togglebutton>
          +			<ui5-togglebutton class="samples-margin" design="Positive" pressed>On/Off</ui5-togglebutton>
          +			<ui5-togglebutton class="samples-margin" design="Negative">Menu</ui5-togglebutton>
          +			<ui5-togglebutton class="samples-margin" design="Negative" pressed>Menu</ui5-togglebutton>
          +			<ui5-togglebutton class="samples-margin" design="Negative">Transparent</ui5-togglebutton>
          +			<ui5-togglebutton class="samples-margin" design="Negative" pressed>Transparent</ui5-togglebutton>
          +	</div>
          +	<pre class="prettyprint lang-html"><xmp>
           <ui5-togglebutton>Yes/No</ui5-togglebutton>
           <ui5-togglebutton pressed>Yes/No</ui5-togglebutton>
           <ui5-togglebutton>Toggle Button</ui5-togglebutton>
          @@ -136,14 +102,7 @@ <h3>ToggleButton</h3>
           <ui5-togglebutton design="Negative" pressed>Menu</ui5-togglebutton>
           <ui5-togglebutton design="Transparent">Transparent</ui5-togglebutton>
           <ui5-togglebutton design="Transparent" pressed>Transparent</ui5-togglebutton>
          -		
          -
          - - - - - + + - + diff --git a/packages/playground/404.html b/packages/playground/404.html new file mode 100644 index 000000000000..56efce4a39e6 --- /dev/null +++ b/packages/playground/404.html @@ -0,0 +1,11 @@ +--- +layout: default +title: Page not found +permalink: /404 +nav_exclude: true +search_exclude: true +--- + +

          Page not found

          + +

          The page you requested could not be found. Try using the navigation {% if site.search_enabled %}or search {% endif %}to find what you're looking for or go to this site's home page.

          diff --git a/packages/playground/Gemfile b/packages/playground/Gemfile new file mode 100644 index 000000000000..3be9c3cd812e --- /dev/null +++ b/packages/playground/Gemfile @@ -0,0 +1,2 @@ +source "https://rubygems.org" +gemspec diff --git a/packages/playground/Gemfile.lock b/packages/playground/Gemfile.lock new file mode 100644 index 000000000000..3dc90acc21fe --- /dev/null +++ b/packages/playground/Gemfile.lock @@ -0,0 +1,78 @@ +PATH + remote: . + specs: + UI5-Web-Components-Playground (1.0.0.pre.rc.4) + jekyll (~> 3.8.5) + jekyll-seo-tag (~> 2.0) + rake (~> 12.3.1) + +GEM + remote: https://rubygems.org/ + specs: + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) + colorator (1.1.0) + concurrent-ruby (1.1.5) + em-websocket (0.5.1) + eventmachine (>= 0.12.9) + http_parser.rb (~> 0.6.0) + eventmachine (1.2.7) + eventmachine (1.2.7-x64-mingw32) + ffi (1.11.1) + ffi (1.11.1-x64-mingw32) + forwardable-extended (2.6.0) + http_parser.rb (0.6.0) + i18n (0.9.5) + concurrent-ruby (~> 1.0) + jekyll (3.8.6) + addressable (~> 2.4) + colorator (~> 1.0) + em-websocket (~> 0.5) + i18n (~> 0.7) + jekyll-sass-converter (~> 1.0) + jekyll-watch (~> 2.0) + kramdown (~> 1.14) + liquid (~> 4.0) + mercenary (~> 0.3.3) + pathutil (~> 0.9) + rouge (>= 1.7, < 4) + safe_yaml (~> 1.0) + jekyll-sass-converter (1.5.2) + sass (~> 3.4) + jekyll-seo-tag (2.6.1) + jekyll (>= 3.3, < 5.0) + jekyll-watch (2.2.1) + listen (~> 3.0) + kramdown (1.17.0) + liquid (4.0.3) + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) + mercenary (0.3.6) + pathutil (0.16.2) + forwardable-extended (~> 2.6) + public_suffix (4.0.1) + rake (12.3.3) + rb-fsevent (0.10.3) + rb-inotify (0.10.0) + ffi (~> 1.0) + rouge (3.11.0) + ruby_dep (1.5.0) + safe_yaml (1.0.5) + sass (3.7.4) + sass-listen (~> 4.0.0) + sass-listen (4.0.0) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + +PLATFORMS + ruby + x64-mingw32 + +DEPENDENCIES + UI5-Web-Components-Playground! + bundler (~> 2.0.1) + +BUNDLED WITH + 2.0.2 diff --git a/packages/playground/Rakefile b/packages/playground/Rakefile new file mode 100644 index 000000000000..b8b42c4ba849 --- /dev/null +++ b/packages/playground/Rakefile @@ -0,0 +1 @@ +Dir.glob('lib/tasks/*.rake').each {|r| import r} diff --git a/packages/playground/_config.yml b/packages/playground/_config.yml new file mode 100644 index 000000000000..4a55333ae1e7 --- /dev/null +++ b/packages/playground/_config.yml @@ -0,0 +1,35 @@ +# Welcome to Jekyll! +# +# This config file is meant for settings that affect your whole site, values +# which you are expected to set up once and rarely edit after that. If you find +# yourself editing these this file very often, consider using Jekyll's data files +# feature for the data you need to update frequently. +# +# For technical reasons, this file is *NOT* reloaded automatically when you use +# 'jekyll serve'. If you change this file, please restart the server process. + +# Site settings +# These are used to personalize your new site. If you look in the HTML files, +# you will see them accessed via {{ site.title }}, {{ site.github_repo }}, and so on. +# You can create any custom variable you would like, and they will be accessible +# in the templates via {{ site.myvariable }}. +title: UI5 Web Components +description: Enterprise-flavored sugar on top of native APIs! +# baseurl: "" # the subpath of your site, e.g. /blog +url: "https://sap.github.io/ui5-webcomponents" # the base hostname & protocol for your site, e.g. http://example.com + +# permalink: /playground +exclude: ["node_modules/", "*.gemspec", "*.gem", "Gemfile", "Gemfile.lock", "package.json", "package-lock.json", "script/", "LICENSE.txt", "lib/", "bin/", "README.md", "Rakefile"] + +# Enable or disable the site search +search_enabled: true + +# Color scheme currently only supports "dark" or nil (default) +color_scheme: nil + +# Google Analytics Tracking (optional) +# e.g, UA-1234567-89 +#ga_tracking: + +plugins: + - jekyll-seo-tag \ No newline at end of file diff --git a/packages/playground/_includes/head.html b/packages/playground/_includes/head.html new file mode 100644 index 000000000000..4b2a62f59a79 --- /dev/null +++ b/packages/playground/_includes/head.html @@ -0,0 +1,33 @@ + + + + + + {% if site.plugins.jekyll-seo == nil %} + {{ page.title }} - {{ site.title }} + + {% if page.description %} + + {% endif %} + {% endif %} + + + + + + + + + + + + +{% seo %} + diff --git a/packages/playground/_includes/nav.html b/packages/playground/_includes/nav.html new file mode 100644 index 000000000000..6e540104bc17 --- /dev/null +++ b/packages/playground/_includes/nav.html @@ -0,0 +1,49 @@ + diff --git a/packages/playground/_layouts/default.html b/packages/playground/_layouts/default.html new file mode 100644 index 000000000000..240b5d36a20b --- /dev/null +++ b/packages/playground/_layouts/default.html @@ -0,0 +1,67 @@ + + + +{% include head.html %} + + +
          + + +
          +
          + {% unless page.url == "/" %} + {% if page.parent %} + + {% endif %} + {% endunless %} +
          + {{ content }} + + {% if page.has_children == true and page.has_toc != false %} +
          +

          Table of contents

          + {% assign children_list = site.pages | sort:"nav_order" %} +
            + {% for child in children_list %} + {% if child.parent == page.title and child.title != page.title %} +
          • + {{ child.title }} +
          • + {% endif %} + {% endfor %} +
          + {% endif %} +
          +
          +
          +
          + + + diff --git a/packages/playground/_layouts/docs.html b/packages/playground/_layouts/docs.html new file mode 100644 index 000000000000..e4917a033faa --- /dev/null +++ b/packages/playground/_layouts/docs.html @@ -0,0 +1,52 @@ +--- +layout: default +--- + +{{ content }} + + + + \ No newline at end of file diff --git a/packages/playground/_layouts/sample.html b/packages/playground/_layouts/sample.html new file mode 100644 index 000000000000..587184c65422 --- /dev/null +++ b/packages/playground/_layouts/sample.html @@ -0,0 +1,72 @@ +--- +layout: default +--- + +{{ content }} + +
          + + + +
          + +
          +
          +
          + Theme: + + Fiori 3 + Belize + High Contrast Black + +
          +
          + Content Density: + + Cozy + Compact + +
          +
          + Text Direction: + + LTR + RTL + +
          +
          +
          +
          + Apply + Cancel +
          +
          + + + + + + + + + \ No newline at end of file diff --git a/packages/playground/_sass/base.scss b/packages/playground/_sass/base.scss new file mode 100644 index 000000000000..a3eddcc99cc1 --- /dev/null +++ b/packages/playground/_sass/base.scss @@ -0,0 +1,107 @@ +// +// Base element style overrides +// +// stylelint-disable selector-no-type, selector-max-type + + +::selection { + color: $white; + background: $link-color; +} + +html { + @include fs-4; +} + +body { + font-family: $body-font-family; + font-size: inherit; + line-height: $body-line-height; + color: $body-text-color; + background-color: $body-background-color; +} + +p:not(.style-scope), +h1:not(.style-scope), +h2:not(.style-scope), +h3:not(.style-scope), +h4:not(.style-scope), +h5:not(.style-scope), +h6:not(.style-scope), +ol:not(.style-scope), +ul:not(.style-scope), +pre:not(.style-scope), +address:not(.style-scope), +blockquote:not(.style-scope), +dl:not(.style-scope), +div:not(.style-scope), +fieldset:not(.style-scope), +form:not(.style-scope), +hr:not(.style-scope), +noscript:not(.style-scope), +table:not(.style-scope) { + margin-top: 0; +} + +h1:not(.style-scope), +h2:not(.style-scope), +h3:not(.style-scope), +h4:not(.style-scope), +h5:not(.style-scope), +h6:not(.style-scope) { + margin-top: 1.2em; + margin-bottom: 0.8em; + font-weight: 500; + line-height: $body-heading-line-height; + color: $body-heading-color; +} + +p:not(.style-scope) { + margin-bottom: 1em; +} + +a { + color: #4A90E2; + text-decoration: none; +} + +a:not([class]):not(.style-scope) { + text-decoration: none; + background-image: linear-gradient($border-color 0%, $border-color 100%); + background-repeat: repeat-x; + background-position: 0 100%; + background-size: 1px 1px; + + &:hover { + background-image: linear-gradient(rgba($link-color, 0.45) 0%, rgba($link-color, 0.45) 100%); + background-size: 1px 1px; + + } +} + +code:not(.style-scope) { + font-family: $mono-font-family; + font-size: 14px; + line-height: $body-line-height; +} + +figure:not(.style-scope) { + margin: 0; +} + +li:not(.style-scope) { + margin: 0.25em 0; +} + +img:not(.style-scope) { + max-width: 100%; + height: auto; +} + +hr:not(.style-scope) { + height: 1px; + padding: 0; + margin: $sp-6 0; + background-color: $border-color; + border: 0; +} diff --git a/packages/playground/_sass/code.scss b/packages/playground/_sass/code.scss new file mode 100644 index 000000000000..e8989f31dc03 --- /dev/null +++ b/packages/playground/_sass/code.scss @@ -0,0 +1,122 @@ +// +// Code and syntax highlighting +// +// stylelint-disable selector-no-qualifying-type, declaration-block-semicolon-newline-after,declaration-block-single-line-max-declarations, selector-no-type, selector-max-type + +code { + padding: 0.2em 0.15em; + font-weight: 400; + background-color: $code-background-color; + border: $border $border-color; + border-radius: $border-radius; +} + +pre.highlight { + padding: $sp-3; + margin-bottom: 0; + -webkit-overflow-scrolling: touch; + background-color: $code-background-color; + + code { + padding: 0; + border: 0; + } +} + +.highlighter-rouge { + margin-bottom: $sp-3; + overflow: hidden; + border-radius: $border-radius; +} + +.highlight .c { color: #586e75; } // comment // +.highlight .err { color: #93a1a1; } // error // +.highlight .g { color: #93a1a1; } // generic // +.highlight .k { color: #859900; } // keyword // +.highlight .l { color: #93a1a1; } // literal // +.highlight .n { color: #93a1a1; } // name // +.highlight .o { color: #859900; } // operator // +.highlight .x { color: #cb4b16; } // other // +.highlight .p { color: #93a1a1; } // punctuation // +.highlight .cm { color: #586e75; } // comment.multiline // +.highlight .cp { color: #859900; } // comment.preproc // +.highlight .c1 { color: #586e75; } // comment.single // +.highlight .cs { color: #859900; } // comment.special // +.highlight .gd { color: #2aa198; } // generic.deleted // +.highlight .ge { font-style: italic; color: #93a1a1; } // generic.emph // +.highlight .gr { color: #dc322f; } // generic.error // +.highlight .gh { color: #cb4b16; } // generic.heading // +.highlight .gi { color: #859900; } // generic.inserted // +.highlight .go { color: #93a1a1; } // generic.output // +.highlight .gp { color: #93a1a1; } // generic.prompt // +.highlight .gs { font-weight: bold; color: #93a1a1; } // generic.strong // +.highlight .gu { color: #cb4b16; } // generic.subheading // +.highlight .gt { color: #93a1a1; } // generic.traceback // +.highlight .kc { color: #cb4b16; } // keyword.constant // +.highlight .kd { color: #268bd2; } // keyword.declaration // +.highlight .kn { color: #859900; } // keyword.namespace // +.highlight .kp { color: #859900; } // keyword.pseudo // +.highlight .kr { color: #268bd2; } // keyword.reserved // +.highlight .kt { color: #dc322f; } // keyword.type // +.highlight .ld { color: #93a1a1; } // literal.date // +.highlight .m { color: #2aa198; } // literal.number // +.highlight .s { color: #2aa198; } // literal.string // +.highlight .na { color: #93a1a1; } // name.attribute // +.highlight .nb { color: #b58900; } // name.builtin // +.highlight .nc { color: #268bd2; } // name.class // +.highlight .no { color: #cb4b16; } // name.constant // +.highlight .nd { color: #268bd2; } // name.decorator // +.highlight .ni { color: #cb4b16; } // name.entity // +.highlight .ne { color: #cb4b16; } // name.exception // +.highlight .nf { color: #268bd2; } // name.function // +.highlight .nl { color: #93a1a1; } // name.label // +.highlight .nn { color: #93a1a1; } // name.namespace // +.highlight .nx { color: #555; } // name.other // +.highlight .py { color: #93a1a1; } // name.property // +.highlight .nt { color: #268bd2; } // name.tag // +.highlight .nv { color: #268bd2; } // name.variable // +.highlight .ow { color: #859900; } // operator.word // +.highlight .w { color: #93a1a1; } // text.whitespace // +.highlight .mf { color: #2aa198; } // literal.number.float // +.highlight .mh { color: #2aa198; } // literal.number.hex // +.highlight .mi { color: #2aa198; } // literal.number.integer // +.highlight .mo { color: #2aa198; } // literal.number.oct // +.highlight .sb { color: #586e75; } // literal.string.backtick // +.highlight .sc { color: #2aa198; } // literal.string.char // +.highlight .sd { color: #93a1a1; } // literal.string.doc // +.highlight .s2 { color: #2aa198; } // literal.string.double // +.highlight .se { color: #cb4b16; } // literal.string.escape // +.highlight .sh { color: #93a1a1; } // literal.string.heredoc // +.highlight .si { color: #2aa198; } // literal.string.interpol // +.highlight .sx { color: #2aa198; } // literal.string.other // +.highlight .sr { color: #dc322f; } // literal.string.regex // +.highlight .s1 { color: #2aa198; } // literal.string.single // +.highlight .ss { color: #2aa198; } // literal.string.symbol // +.highlight .bp { color: #268bd2; } // name.builtin.pseudo // +.highlight .vc { color: #268bd2; } // name.variable.class // +.highlight .vg { color: #268bd2; } // name.variable.global // +.highlight .vi { color: #268bd2; } // name.variable.instance // +.highlight .il { color: #2aa198; } // literal.number.integer.long // + +// +// Code examples (rendered) +// + +.code-example { + padding: $sp-3; + margin-bottom: $sp-3; + overflow: auto; + border: 1px solid $border-color; + border-radius: $border-radius; + + + .highlighter-rouge, + + figure.highlight { + position: relative; + margin-top: -$sp-4; + border-right: 1px solid $border-color; + border-bottom: 1px solid $border-color; + border-left: 1px solid $border-color; + border-top-left-radius: 0; + border-top-right-radius: 0; + } +} diff --git a/packages/playground/_sass/layout.scss b/packages/playground/_sass/layout.scss new file mode 100644 index 000000000000..bbe8f2683f7d --- /dev/null +++ b/packages/playground/_sass/layout.scss @@ -0,0 +1,233 @@ +// +// The basic two column layout +// + +.page-wrap { + @include mq(md) { + position: absolute; + top: 0; + left: 0; + display: flex; + width: 100%; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; + } +} + +.side-bar { + z-index: 100; + height: calc(100% - 3rem); + top: 3rem; + display: flex; + flex-wrap: wrap; + padding-top: $gutter-spacing-sm; + padding-bottom: $gutter-spacing-sm; + background-color: #fff; + width: 250px; + + @include mq(md) { + flex-wrap: nowrap; + position: absolute; + // width: $nav-width + 16px; + height: 100%; + padding-top: 0; + flex-direction: column; + border-right: $border $border-color; + align-items: flex-end; + + // IE spesific css + position: fixed; + top: 3rem; + left: 0; + } + + @include mq(lg) { + // width: calc((100% - #{$nav-width + $content-width}) / 2 + #{$nav-width}); + min-width: $nav-width; + + // IE spesific css + position: fixed; + top: 3rem; + left: 0; + } +} + +.main-content-wrap { + @include mq(md) { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + min-height: 600px; + -webkit-overflow-scrolling: touch; + overflow-x: hidden; + overflow-y: scroll; + } +} + +.main-content { + padding-top: $gutter-spacing-sm; + font-family: "72-Regular"; + @include container; + + @include mq(md) { + position: relative; + margin: 48px 0 0 250px; + padding-top: 2rem; + } + + @include mq(lg) { + margin: 48px 0 0 250px; + padding-top: 2rem; + } +} + +.js-main-content:focus { + outline: none; +} + +.page-header { + width: 100%; + height: 3rem; + display: flex; + justify-content: space-between; + align-items: center; + background-color: #000; + z-index: 100; + + .main-content, .main-content-header { + padding-top: 0; + + @include mq(md) { + display: flex; + justify-content: flex-end; + } + } +} + +.logo-wrapper { + height: 100%; + display: flex; + align-items: center; + z-index: 1; +} + +.logo { + width: 2.4rem; + height: 2.4rem; + margin: 0 .5rem; +} + +.heading { + color: #fff; +} + +.settings { + width: 2rem; + height: 2.3rem; + display: flex; + justify-content: center; + align-items: center; + position: fixed; + top: 20%; + right: 0; + background-color: #000; + border-top-left-radius: 10px; + border-bottom-left-radius: 10px; + cursor: pointer; +} + +.hcb .settings { + -webkit-box-shadow: -10px 0px 10px 0px rgba(255,255,255,0.75); + -moz-box-shadow: -10px 0px 10px 0px rgba(255,255,255,0.75); + box-shadow: -1px 1px 10px 0px rgba(255,255,255,0.75); +} + +.settings > svg { + fill: #fff; +} + +.settings > svg:hover { + fill: #cacaca; +} + +.settings-icon { + width: 70%; + height: 70%; +} + +#mobile-button { + margin-right: .5rem; + background: none; + color: #fff; + border: 1px solid #fff; + border-radius: 5px; +} + +@media only screen and (min-width: 740px) { + #mobile-button { + visibility: hidden; + } +} + +@media only screen and (max-width: 740px) { + .heading { + display: none; + } + + .side-bar { + padding: 0; + width: 100%; + } +} + +.navigation, +.site-footer { + box-sizing: border-box; + padding-left: 2rem; + padding-right: 2rem; + + width: 100% !important; + + @include mq(lg) { + width: $nav-width + 32px; + } +} + +.navigation { + @include mq(md) { + padding-top: 1rem; + overflow-y: auto; + flex: 1 1 auto; + } +} + +// stylelint-disable selector-max-type + +body { + position: relative; + padding-bottom: $sp-10; + + @include mq(md) { + position: static; + padding-bottom: 0; + } +} + +// stylelint-enable selector-max-type + +.site-footer { + position: absolute; + bottom: 0; + padding-top: $sp-4; + padding-bottom: $sp-4; + + @include mq(md) { + position: static; + align-self: flex-end; + justify-self: end; + background-color: $sidebar-color; + } +} diff --git a/packages/playground/_sass/navigation.scss b/packages/playground/_sass/navigation.scss new file mode 100644 index 000000000000..6a99b0411d41 --- /dev/null +++ b/packages/playground/_sass/navigation.scss @@ -0,0 +1,180 @@ +// +// Main nav, breadcrumb, etc... +// + +@font-face { + font-family: "72-Bold"; + src: url(../fonts/72-Bold.woff2) format("woff2"), + url(../fonts/72-Bold.woff) format("woff"); +} + +@font-face { + font-family: "72-Regular"; + src: url(../fonts/72-Regular.woff2) format("woff2"), + url(../fonts/72-Regular.woff) format("woff"); +} + +.navigation-list { + padding: 0; + margin-top: $sp-4; + margin-bottom: 0; + list-style: none; + + @include mq(md) { + margin-top: 0; + } +} + +.navigation-list > .navigation-list-item > .navigation-list-link { + position: relative; + font-family: "72-Bold"; + font-size: 1rem; +} + +.navigation-list-child-list { + padding-left: $sp-3; + list-style: none; + + .navigation-list-item { + font-family: "72-Regular" !important; + position: relative; + + &.active { + &::before { + color: $body-text-color; + } + } + } +} + +.visible { + display: block !important; + padding-bottom: 3rem; +} + +.navigation-list-item { + position: relative; + @include fs-4; + margin: 0; + + @include mq(md) { + @include fs-3; + } + + .navigation-list-child-list { + display: none; + } + + &.active { + .navigation-list-child-list { + display: block; + } + } +} + +.navigation-list-link.active::after{ + content: ""; + width: .9rem; + height: 3px; + position: absolute; + left: -1.2rem; + top: .75rem; + border-radius: 1rem; + background-color: #FF6216; +} + +.navigation-list > .navigation-list-item > a.navigation-list-link::after { + top: .8rem; +} + +@media only screen and (max-width: 740px) { + .navigation-list-item { + text-align: center; + &::after { + display: none; + } + } +} + +.navigation-list-link { + display: flex; + justify-content: space-between; + padding-top: $sp-1; + padding-bottom: $sp-1; + color: #2b2b2b; + font-family: "72-Regular"; +} + +.new-tag { + display: flex; + align-items: center; + color: #4A90E2; + font-size: 12px; +} + +// Small screen nav + +.main-nav, +.aux-nav { + display: none; + + &.nav-open { + display: block; + } + @include mq(md) { + display: block; + } +} + +// Breadcrumb nav +.breadcrumb-nav { + @include mq(md) { + margin-top: -$sp-4; + } +} + +.breadcrumb-nav-list { + padding-left: 0; + margin-bottom: $sp-3; + list-style: none; +} + +.breadcrumb-nav-list-item { + display: table-cell; + @include fs-2; + + &::before { + display: none; + } + + &::after { + display: inline-block; + margin-right: $sp-2; + margin-left: $sp-2; + color: $grey-dk-000; + content: "/"; + } + + &:last-child { + &::after { + content: ""; + } + } +} + +@media(max-width: 740px) { + .navigation-list-link { + display: flex; + justify-content: center; + } + + .navigation-list-link, .component-name { + width: 100%; + } + + .new-tag { + position: absolute; + line-height: 1.5rem; + right: 0rem; + } +} \ No newline at end of file diff --git a/packages/playground/_sass/search.scss b/packages/playground/_sass/search.scss new file mode 100644 index 000000000000..935ba0d494f6 --- /dev/null +++ b/packages/playground/_sass/search.scss @@ -0,0 +1,138 @@ +// +// Search input and autocomplete +// + +.search { + width: 320px; + position: relative; + z-index: 99; + display: none; + padding: $sp-2; + border-radius: 3px; + box-shadow: 0 1px 2px rgba(0, 0, 0, 0.07), 0 3px 10px rgba(0, 0, 0, 0.05); + + @include mq(md) { + display: block; + padding-top: $sp-1; + padding-right: 0; + padding-bottom: 0; + padding-left: 0; + margin-bottom: 0; + background-color: transparent; + box-shadow: none; + } + + &.nav-open { + display: block; + } +} + +@media only screen and (max-width: 740px) { + .heading { + display: none; + } + + .search { + display: block; + width: 200px; + } +} + +.search-results-wrap { + display: none; + + &.active { + position: absolute; + top: $sp-1; + z-index: 100; + display: block; + width: 300px; + margin-top: $gutter-spacing; + background: lighten($body-background-color, 1%); + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.07), 0 4px 14px rgba(0, 0, 0, 0.05); + } +} + +.search-input-wrap { + display: flex; + padding: 0 0.4rem; + background-color: #000; + border: 1px solid #fff; + border-radius: 4px; +} + + +.search-input { + width: 100%; + padding-top: $sp-1; + padding-bottom: $sp-1; + background-color: #000; + color: #fff; + border-top: 0; + border-right: 0; + border-bottom: 0; + border-left: 0; + order: 2; + + &:focus { + outline: 0; + box-shadow: none; + + + .search-icon { + fill: #fff; + } + } + + &:focus::-webkit-input-placeholder { /* Edge */ + color: #fff + } + + &:focus::placeholder { + color: #fff + } + + @include fs-5; + + @include mq(sm) { + @include fs-3; + } + + @include mq(md) { + @include fs-2; + } +} + +.search-icon { + align-self: center; + margin-right: $sp-2; + fill: $grey-dk-000; + order: 1; +} + +.search-results-list { + padding-left: 0; + margin-top: $sp-1; + margin-bottom: $sp-1; + list-style: none; + @include fs-3; +} + +.search-results-list-item { + padding: 0; + margin: 0; +} + +.search-results-link { + display: flex; + flex-direction: column; + padding-top: $sp-1; + padding-right: $sp-3; + padding-bottom: $sp-1; + padding-left: $sp-3; + color: $body-heading-color; + + &:hover { + color: #4A90E2; + background-color: darken($body-background-color, 2%); + } +} diff --git a/packages/playground/_sass/support/_functions.scss b/packages/playground/_sass/support/_functions.scss new file mode 100644 index 000000000000..e9885f625faa --- /dev/null +++ b/packages/playground/_sass/support/_functions.scss @@ -0,0 +1,10 @@ +@function rem($size, $unit:"") { + $remSize: $size / $root-font-size; + + @if ($unit == false) { + @return #{$remSize}; + } + @else { + @return #{$remSize}rem; + } +} diff --git a/packages/playground/_sass/support/_variables.scss b/packages/playground/_sass/support/_variables.scss new file mode 100644 index 000000000000..7de75b1481f7 --- /dev/null +++ b/packages/playground/_sass/support/_variables.scss @@ -0,0 +1,130 @@ +// +// Typography +// + +$body-font-family: -apple-system, BlinkMacSystemFont, "helvetica neue", helvetica, roboto, noto, "segoe ui", arial, sans-serif !default; +$mono-font-family: "SFMono-Regular", Menlo, Consolas, Monospace !default; +$root-font-size: 16px !default; // Base font-size for rems +$body-line-height: 1.4 !default; +$body-heading-line-height: 1.15 !default !default; + +// +// Colors +// + +$white: #fff !default; + +$grey-dk-000: #959396 !default; +$grey-dk-100: #5c5962 !default; +$grey-dk-200: #44434d !default; +$grey-dk-250: #302d36 !default; +$grey-dk-300: #27262b !default; + +$grey-lt-000: #f5f6fa !default; +$grey-lt-100: #eeebee !default; +$grey-lt-200: #ecebed !default; +$grey-lt-300: #e6e1e8 !default; + +$purple-000: #7253ed !default; +$purple-100: #5e41d0 !default; +$purple-200: #4e26af !default; +$purple-300: #381885 !default; + +$blue-000: #2c84fa !default; +$blue-100: #2869e6 !default; +$blue-200: #264caf !default; +$blue-300: #183385 !default; + +$green-000: #41d693 !default; +$green-100: #11b584 !default; +$green-200: #009c7b !default; +$green-300: #026e57 !default; + +$yellow-000: #ffeb82 !default; +$yellow-100: #fadf50 !default; +$yellow-200: #f7d12e !default; +$yellow-300: #e7af06 !default; + +$red-000: #f77e7e !default; +$red-100: #f96e65 !default; +$red-200: #e94c4c !default; +$red-300: #dd2e2e !default; + +$body-background-color: $white !default; +$sidebar-color: $grey-lt-000 !default; +$code-background-color: $grey-lt-000 !default; + +$body-text-color: $grey-dk-100 !default; +$body-heading-color: $grey-dk-300 !default; +$nav-child-link-color: #4A90E2; +$link-color: #4A90E2; +$btn-primary-color: $purple-100 !default; +$base-button-color: #f7f7f7 !default; + +// +// Media queries in pixels +// + +$media-queries: ( + xs: 320px, + sm: 500px, + md: 740px, + lg: 1120px, + xl: 1400px +) !default; + +// +// Spacing +// + +$spacing-unit: 1rem; // 1rem == 16px + +$spacers: ( + sp-0: 0, + sp-1: $spacing-unit * 0.25, + sp-2: $spacing-unit * 0.5, + sp-3: $spacing-unit * 0.75, + sp-4: $spacing-unit, + sp-5: $spacing-unit * 1.5, + sp-6: $spacing-unit * 2, + sp-7: $spacing-unit * 2.5, + sp-8: $spacing-unit * 3, + sp-9: $spacing-unit * 3.5, + sp-10: $spacing-unit * 4 +) !default; + +$sp-1: map-get($spacers, sp-1) !default; // 0.25 rem == 4px +$sp-2: map-get($spacers, sp-2) !default; // 0.5 rem == 8px +$sp-3: map-get($spacers, sp-3) !default; // 0.75 rem == 12px +$sp-4: map-get($spacers, sp-4) !default; // 1 rem == 16px +$sp-5: map-get($spacers, sp-5) !default; // 1.5 rem == 24px +$sp-6: map-get($spacers, sp-6) !default; // 2 rem == 32px +$sp-7: map-get($spacers, sp-7) !default; // 2.5 rem == 40px +$sp-8: map-get($spacers, sp-8) !default; // 3 rem == 48px +$sp-9: map-get($spacers, sp-9) !default; // 4 rem == 48px +$sp-10: map-get($spacers, sp-10) !default; // 4.5 rem == 48px + +// +// Borders +// + +$border: 1px solid !default; +$border-radius: 4px !default; +$border-color: $grey-lt-100 !default; + +// +// Grid system +// + +$gutter-spacing: $sp-6 !default; +$gutter-spacing-sm: $sp-4 !default; +$nav-width: 232px !default; +$content-width: 800px !default; + +$media-queries: ( + xs: 320px, + sm: 500px, + md: 740px, + lg: 800px, + xl: 1316px +) !default; diff --git a/packages/playground/_sass/support/mixins/_buttons.scss b/packages/playground/_sass/support/mixins/_buttons.scss new file mode 100644 index 000000000000..e3e6c4fbcafd --- /dev/null +++ b/packages/playground/_sass/support/mixins/_buttons.scss @@ -0,0 +1,27 @@ +// Colored button + +@mixin btn-color($fg, $bg) { + color: $fg; + background-color: darken($bg, 2%); + background-image: linear-gradient(lighten($bg, 5%), darken($bg, 2%)); + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25), 0 4px 10px rgba(0, 0, 0, 0.12); + + &:hover, + &.zeroclipboard-is-hover { + color: $fg; + background-color: darken($bg, 4%); + background-image: linear-gradient((lighten($bg, 2%), darken($bg, 4%))); + } + + &:active, + &.selected, + &.zeroclipboard-is-active { + background-color: darken($bg, 5%); + background-image: none; + box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15); + } + + &.selected:hover { + background-color: darken($bg, 10%); + } +} diff --git a/packages/playground/_sass/support/mixins/_layout.scss b/packages/playground/_sass/support/mixins/_layout.scss new file mode 100644 index 000000000000..7e7967e4cb42 --- /dev/null +++ b/packages/playground/_sass/support/mixins/_layout.scss @@ -0,0 +1,36 @@ +// Media query + +// Media query mixin +// Usage: +// @include mq(md) { +// ..medium and up styles +// } +@mixin mq($name) { + // Retrieves the value from the key + $value: map-get($media-queries, $name); + + // If the key exists in the map + @if $value != null { + // Prints a media query based on the value + @media (min-width: rem($value)) { + @content; + } + } + + @else { + @warn "No value could be retrieved from `#{$media-query}`. " + + "Please make sure it is defined in `$media-queries` map."; + } +} + +// Responsive container + +@mixin container { + padding-right: $gutter-spacing-sm; + padding-left: $gutter-spacing-sm; + + @include mq(md) { + padding-right: $gutter-spacing; + padding-left: $gutter-spacing; + } +} diff --git a/packages/playground/_sass/support/mixins/_typography.scss b/packages/playground/_sass/support/mixins/_typography.scss new file mode 100644 index 000000000000..e6d85beaa710 --- /dev/null +++ b/packages/playground/_sass/support/mixins/_typography.scss @@ -0,0 +1,81 @@ +// Font size + +@mixin fs-1 { + font-size: 9px !important; + + @include mq(sm) { + font-size: 10px !important; + } +} + +@mixin fs-2 { + font-size: 11px !important; + + @include mq(sm) { + font-size: 12px !important; + } +} + +@mixin fs-3 { + font-size: 12px !important; + + @include mq(sm) { + font-size: 14px !important; + } +} + +@mixin fs-4 { + font-size: 14px !important; + + @include mq(sm) { + font-size: 16px !important; + } +} + +@mixin fs-5 { + font-size: 16px !important; + + @include mq(sm) { + font-size: 18px !important; + } +} + +@mixin fs-6 { + font-size: 18px !important; + + @include mq(sm) { + font-size: 24px !important; + } +} + +@mixin fs-7 { + font-size: 24px !important; + + @include mq(sm) { + font-size: 32px !important; + } +} + +@mixin fs-8 { + font-size: 32px !important; + + @include mq(sm) { + font-size: 36px !important; + } +} + +@mixin fs-9 { + font-size: 36px !important; + + @include mq(sm) { + font-size: 42px !important; + } +} + +@mixin fs-10 { + font-size: 42px !important; + + @include mq(sm) { + font-size: 48px !important; + } +} diff --git a/packages/playground/_sass/support/mixins/mixins.scss b/packages/playground/_sass/support/mixins/mixins.scss new file mode 100644 index 000000000000..0506fbf5ff41 --- /dev/null +++ b/packages/playground/_sass/support/mixins/mixins.scss @@ -0,0 +1,3 @@ +@import "./layout"; +@import "./buttons"; +@import "./typography"; diff --git a/packages/playground/_sass/support/support.scss b/packages/playground/_sass/support/support.scss new file mode 100644 index 000000000000..8131a3201a04 --- /dev/null +++ b/packages/playground/_sass/support/support.scss @@ -0,0 +1,3 @@ +@import "./variables"; +@import "./functions"; +@import "./mixins/mixins"; diff --git a/packages/playground/_sass/tables.scss b/packages/playground/_sass/tables.scss new file mode 100644 index 000000000000..39bc0dc38e9d --- /dev/null +++ b/packages/playground/_sass/tables.scss @@ -0,0 +1,78 @@ +// +// Tables +// +// stylelint-disable max-nesting-depth, selector-no-type, selector-max-type + +table { + display: block; + width: 100%; + max-width: 100%; + margin-bottom: $sp-5; + overflow-x: auto; + border-collapse: separate; + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.07), 0 4px 14px rgba(0, 0, 0, 0.05); + + @include mq(sm) { + display: table; + } +} + +th, +td { + @include fs-3; + min-width: 120px; + padding-top: $sp-2; + padding-right: $sp-3; + padding-bottom: $sp-2; + padding-left: $sp-3; + background-color: lighten($body-background-color, 2%); + border-bottom: $border rgba($border-color, 0.5); + border-left: $border $border-color; + + &:first-of-type { + border-left: 0; + } +} + +thead, +tbody:first-child { + tr { + &:first-of-type { + th, + td { + &:first-of-type { + border-top-left-radius: $border-radius; + } + + &:last-of-type { + border-top-right-radius: $border-radius; + } + } + } + } +} + +tbody { + tr { + &:last-of-type { + th, + td { + border-bottom: 0; + + &:first-of-type { + border-bottom-left-radius: $border-radius; + } + + &:last-of-type { + border-bottom-right-radius: $border-radius; + } + } + } + } +} + +thead { + th { + border-bottom: 1px solid $border-color; + } +} diff --git a/packages/playground/_sass/vendor/normalize.scss/normalize.scss b/packages/playground/_sass/vendor/normalize.scss/normalize.scss new file mode 100644 index 000000000000..ce38a4fab48e --- /dev/null +++ b/packages/playground/_sass/vendor/normalize.scss/normalize.scss @@ -0,0 +1,427 @@ +/*! normalize.scss v0.1.0 | MIT License | based on git.io/normalize */ + +/** + * 1. Set default font family to sans-serif. + * 2. Prevent iOS text size adjust after orientation change, without disabling + * user zoom. + */ + +html { + font-family: sans-serif; /* 1 */ + -ms-text-size-adjust: 100%; /* 2 */ + -webkit-text-size-adjust: 100%; /* 2 */ +} + +/** + * Remove default margin. + */ + +body { + margin: 0; +} + +/* HTML5 display definitions + ========================================================================== */ + +/** + * Correct `block` display not defined for any HTML5 element in IE 8/9. + * Correct `block` display not defined for `details` or `summary` in IE 10/11 + * and Firefox. + * Correct `block` display not defined for `main` in IE 11. + */ + +article, +aside, +details, +figcaption, +figure, +footer, +header, +hgroup, +main, +menu, +nav, +section, +summary { + display: block; +} + +/** + * 1. Correct `inline-block` display not defined in IE 8/9. + * 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera. + */ + +audio, +canvas, +progress, +video { + display: inline-block; /* 1 */ + vertical-align: baseline; /* 2 */ +} + +/** + * Prevent modern browsers from displaying `audio` without controls. + * Remove excess height in iOS 5 devices. + */ + +audio:not([controls]) { + display: none; + height: 0; +} + +/** + * Address `[hidden]` styling not present in IE 8/9/10. + * Hide the `template` element in IE 8/9/11, Safari, and Firefox < 22. + */ + +[hidden], +template { + display: none; +} + +/* Links + ========================================================================== */ + +/** + * Remove the gray background color from active links in IE 10. + */ + +a { + background-color: transparent; +} + +/** + * Improve readability when focused and also mouse hovered in all browsers. + */ + +a:active, +a:hover { + outline: 0; +} + +/* Text-level semantics + ========================================================================== */ + +/** + * Address styling not present in IE 8/9/10/11, Safari, and Chrome. + */ + +abbr[title] { + border-bottom: 1px dotted; +} + +/** + * Address style set to `bolder` in Firefox 4+, Safari, and Chrome. + */ + +b, +strong { + font-weight: bold; +} + +/** + * Address styling not present in Safari and Chrome. + */ + +dfn { + font-style: italic; +} + +/** + * Address variable `h1` font-size and margin within `section` and `article` + * contexts in Firefox 4+, Safari, and Chrome. + */ + +h1 { + font-size: 2em; + margin: 0.67em 0; +} + +/** + * Address styling not present in IE 8/9. + */ + +mark { + background: #ff0; + color: #000; +} + +/** + * Address inconsistent and variable font size in all browsers. + */ + +small { + font-size: 80%; +} + +/** + * Prevent `sub` and `sup` affecting `line-height` in all browsers. + */ + +sub, +sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; +} + +sup { + top: -0.5em; +} + +sub { + bottom: -0.25em; +} + +/* Embedded content + ========================================================================== */ + +/** + * Remove border when inside `a` element in IE 8/9/10. + */ + +img { + border: 0; +} + +/** + * Correct overflow not hidden in IE 9/10/11. + */ + +svg:not(:root) { + overflow: hidden; +} + +/* Grouping content + ========================================================================== */ + +/** + * Address margin not present in IE 8/9 and Safari. + */ + +figure { + margin: 1em 40px; +} + +/** + * Address differences between Firefox and other browsers. + */ + +hr { + -moz-box-sizing: content-box; + box-sizing: content-box; + height: 0; +} + +/** + * Contain overflow in all browsers. + */ + +pre { + overflow: auto; +} + +/** + * Address odd `em`-unit font size rendering in all browsers. + */ + +code, +kbd, +pre, +samp { + font-family: monospace, monospace; + font-size: 1em; +} + +/* Forms + ========================================================================== */ + +/** + * Known limitation: by default, Chrome and Safari on OS X allow very limited + * styling of `select`, unless a `border` property is set. + */ + +/** + * 1. Correct color not being inherited. + * Known issue: affects color of disabled elements. + * 2. Correct font properties not being inherited. + * 3. Address margins set differently in Firefox 4+, Safari, and Chrome. + */ + +button, +input, +optgroup, +select, +textarea { + color: inherit; /* 1 */ + font: inherit; /* 2 */ + margin: 0; /* 3 */ +} + +/** + * Address `overflow` set to `hidden` in IE 8/9/10/11. + */ + +button { + overflow: visible; +} + +/** + * Address inconsistent `text-transform` inheritance for `button` and `select`. + * All other form control elements do not inherit `text-transform` values. + * Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera. + * Correct `select` style inheritance in Firefox. + */ + +button, +select { + text-transform: none; +} + +/** + * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` + * and `video` controls. + * 2. Correct inability to style clickable `input` types in iOS. + * 3. Improve usability and consistency of cursor style between image-type + * `input` and others. + */ + +button, +html input[type="button"], /* 1 */ +input[type="reset"], +input[type="submit"] { + -webkit-appearance: button; /* 2 */ + cursor: pointer; /* 3 */ +} + +/** + * Re-set default cursor for disabled elements. + */ + +button[disabled], +html input[disabled] { + cursor: default; +} + +/** + * Remove inner padding and border in Firefox 4+. + */ + +button::-moz-focus-inner, +input::-moz-focus-inner { + border: 0; + padding: 0; +} + +/** + * Address Firefox 4+ setting `line-height` on `input` using `!important` in + * the UA stylesheet. + */ + +input { + line-height: normal; +} + +/** + * It's recommended that you don't attempt to style these elements. + * Firefox's implementation doesn't respect box-sizing, padding, or width. + * + * 1. Address box sizing set to `content-box` in IE 8/9/10. + * 2. Remove excess padding in IE 8/9/10. + */ + +input[type="checkbox"], +input[type="radio"] { + box-sizing: border-box; /* 1 */ + padding: 0; /* 2 */ +} + +/** + * Fix the cursor style for Chrome's increment/decrement buttons. For certain + * `font-size` values of the `input`, it causes the cursor style of the + * decrement button to change from `default` to `text`. + */ + +input[type="number"]::-webkit-inner-spin-button, +input[type="number"]::-webkit-outer-spin-button { + height: auto; +} + +/** + * 1. Address `appearance` set to `searchfield` in Safari and Chrome. + * 2. Address `box-sizing` set to `border-box` in Safari and Chrome + * (include `-moz` to future-proof). + */ + +input[type="search"] { + -webkit-appearance: textfield; /* 1 */ + -moz-box-sizing: content-box; + -webkit-box-sizing: content-box; /* 2 */ + box-sizing: content-box; +} + +/** + * Remove inner padding and search cancel button in Safari and Chrome on OS X. + * Safari (but not Chrome) clips the cancel button when the search input has + * padding (and `textfield` appearance). + */ + +input[type="search"]::-webkit-search-cancel-button, +input[type="search"]::-webkit-search-decoration { + -webkit-appearance: none; +} + +/** + * Define consistent border, margin, and padding. + */ + +fieldset { + border: 1px solid #c0c0c0; + margin: 0 2px; + padding: 0.35em 0.625em 0.75em; +} + +/** + * 1. Correct `color` not being inherited in IE 8/9/10/11. + * 2. Remove padding so people aren't caught out if they zero out fieldsets. + */ + +legend { + border: 0; /* 1 */ + padding: 0; /* 2 */ +} + +/** + * Remove default vertical scrollbar in IE 8/9/10/11. + */ + +textarea { + overflow: auto; +} + +/** + * Don't inherit the `font-weight` (applied by a rule above). + * NOTE: the default cannot safely be changed in Chrome and Safari on OS X. + */ + +optgroup { + font-weight: bold; +} + +/* Tables + ========================================================================== */ + +/** + * Remove most spacing between table cells. + */ + +table { + border-collapse: collapse; + border-spacing: 0; +} + +td, +th { + padding: 0; +} diff --git a/packages/main/test/playground/css/api.css b/packages/playground/assets/css/api.css similarity index 83% rename from packages/main/test/playground/css/api.css rename to packages/playground/assets/css/api.css index 0d23cc495075..fa2c530d438b 100644 --- a/packages/main/test/playground/css/api.css +++ b/packages/playground/assets/css/api.css @@ -1,19 +1,6 @@ -@font-face { - font-family: "72-Bold"; - src: url(../../../www/home/fonts/72-Bold.woff2) format("woff2"), - url(../../../www/home/fonts/72-Bold.woff) format("woff"); -} - -@font-face { - font-family: "72-Regular"; - src: url(../../../www/home/fonts/72-Regular.woff2) format("woff2"), - url(../../../www/home/fonts/72-Regular.woff) format("woff"); -} - body { font-family: "72-Regular", Arial, Helvetica, sans-serif; box-sizing: border-box; - padding: 0.625rem 1.25rem; } .component-heading { @@ -26,10 +13,6 @@ body { align-items: center; } -.example-wrapper { - padding: 1rem 3rem 8rem 3rem; -} - .control-header { font-family: "72-Bold", "72-Regular"; font-size: 3rem; @@ -51,25 +34,6 @@ body { flex-wrap: wrap; } -pre.prettyprint { - box-sizing: border-box; - margin: 0 0 3rem 0; - width: 100%; - padding: 1rem; - overflow: auto; - border-top: none; - border-radius: 0 0 0.375rem 0.375rem; - border: 0.0625rem solid #C1C1C1; - background-color: #394958; -} - -pre.prettyprint > xmp { - margin: 0; - font-family: Menlo, "Lucida Console", Monaco, "Courier New", monospace !important; - font-size: 14px !important; - line-height: 1.3rem !important; -} - .samples-margin { margin: 0 8px 8px 0; } @@ -190,6 +154,11 @@ pre.prettyprint > xmp { /* margin: 0; */ } +.component-api { + font-family: "72-Regular"; + font-size: 14px; +} + .space-top { margin-top: 72px; } @@ -198,10 +167,6 @@ pre.prettyprint > xmp { margin-top: 16px; } -pre.prettyprint>xmp { - padding-left: 24px; -} - .api-table-header-roll { background: #F0F0F0; box-shadow: inset 0 -1px 0 0 rgba(0, 0, 0, 0.20); @@ -327,26 +292,9 @@ pre.prettyprint>xmp { width: 100%; } -.hcb-background .api-table { - border: 1px solid #fff; -} - -.hcb-background .api-container.appended-doc { - color: #fff; -} - -.hcb-background .api-table-header-roll { - background-color: #222; -} - -.hcb-background .api-table-roll-even { - background: #000; - box-shadow: inset 0 -1px 0 0 rgba(255,255,255,0.10); -} - -.hcb-background .api-table-roll-odd { - background: #222; - box-shadow: inset 0 -1px 0 0 rgba(255,255,255,0.10); +/* HCB styles */ +.hcb .snippet { + background-color: #000; } .bold { @@ -417,6 +365,7 @@ pre.prettyprint>xmp { flex-wrap: wrap; align-items: center; justify-content: flex-start; + font-family: "72-Regular"; } .footer-links > a { @@ -435,6 +384,21 @@ pre.prettyprint>xmp { text-decoration: none; } +.settings-form { + width: 250px; + margin: 2rem; +} + +.closing-buttons { + padding: .25rem .5rem .25rem 0; + display: flex; + justify-content: flex-end; +} + +.padding-end{ + margin-right: .5rem; +} + @media(max-width: 600px) { .login-form { margin: 3rem 1rem; @@ -447,10 +411,6 @@ pre.prettyprint>xmp { .samples-responsive-padding-bottom { padding-bottom: 8px; } - - .example-wrapper { - padding: 0.625rem 1.25rem; - } } @media(max-width: 920px) { diff --git a/packages/playground/webapp/css/index.css b/packages/playground/assets/css/landing-page.css similarity index 94% rename from packages/playground/webapp/css/index.css rename to packages/playground/assets/css/landing-page.css index fd1192d4a450..27693b05eac3 100644 --- a/packages/playground/webapp/css/index.css +++ b/packages/playground/assets/css/landing-page.css @@ -1,19 +1,19 @@ @font-face { font-family: "72-Bold"; - src: url(../www/home/fonts/72-Bold.woff2) format("woff2"), - url(../www/home/fonts/72-Bold.woff) format("woff"); + src: url(../fonts/72-Bold.woff2) format("woff2"), + url(../fonts/72-Bold.woff) format("woff"); } @font-face { font-family: "72-Regular"; - src: url(../www/home/fonts/72-Regular.woff2) format("woff2"), - url(../www/home/fonts/72-Regular.woff) format("woff"); + src: url(../fonts/72-Regular.woff2) format("woff2"), + url(../fonts/72-Regular.woff) format("woff"); } @font-face { font-family: "72-Light"; - src: url(../www/home/fonts/72-Light.woff2) format("woff2"), - url(../www/home/fonts/72-Light.woff) format("woff"); + src: url(../fonts/72-Light.woff2) format("woff2"), + url(../fonts/72-Light.woff) format("woff"); } body { @@ -216,7 +216,7 @@ body { height: 4rem; } -.example-wrapper { +.datepicker-example-wrapper { width: 100%; height: 10.75rem; background: #FAFAFA; @@ -270,7 +270,7 @@ body { .card { width: 18.94rem; - /* height: 20.25rem; */ + height: 18rem; margin-bottom: 1rem; border-radius: 6px; } @@ -399,7 +399,7 @@ body { box-shadow: 0 0 2px 0 rgba(0,0,0,0.15); } -.footer-wrapper { +.landing-footer-wrapper { display: flex; justify-content: space-between; align-items: flex-start; @@ -545,12 +545,12 @@ body { width: 100%; } - .footer-wrapper { + .landing-footer-wrapper { flex-direction: column; align-items: center; } - .footer-wrapper div, .footer-wrapper h2, .footer-wrapper a { + .landing-footer-wrapper div, .landing-footer-wrapper h2, .landing-footer-wrapper a { width: 100%; text-align: center; } diff --git a/packages/playground/assets/css/main.scss b/packages/playground/assets/css/main.scss new file mode 100644 index 000000000000..d927501f445f --- /dev/null +++ b/packages/playground/assets/css/main.scss @@ -0,0 +1,21 @@ +--- +# this ensures Jekyll reads the file to be transformed into CSS later +# only Main files contain this front matter, not partials. +--- + +// +// Import external dependencies +// + +@import "./vendor/normalize.scss/normalize.scss"; + +// Support +@import "./support/support"; + +// Modules +@import "./base"; +@import "./layout"; +@import "./navigation"; +@import "./search"; +@import "./tables"; +@import "./code"; diff --git a/packages/playground/webapp/www/home/fonts/72-Bold.woff b/packages/playground/assets/fonts/72-Bold.woff similarity index 100% rename from packages/playground/webapp/www/home/fonts/72-Bold.woff rename to packages/playground/assets/fonts/72-Bold.woff diff --git a/packages/playground/webapp/www/home/fonts/72-Bold.woff2 b/packages/playground/assets/fonts/72-Bold.woff2 similarity index 100% rename from packages/playground/webapp/www/home/fonts/72-Bold.woff2 rename to packages/playground/assets/fonts/72-Bold.woff2 diff --git a/packages/playground/webapp/www/home/fonts/72-Light.woff b/packages/playground/assets/fonts/72-Light.woff similarity index 100% rename from packages/playground/webapp/www/home/fonts/72-Light.woff rename to packages/playground/assets/fonts/72-Light.woff diff --git a/packages/playground/webapp/www/home/fonts/72-Light.woff2 b/packages/playground/assets/fonts/72-Light.woff2 similarity index 100% rename from packages/playground/webapp/www/home/fonts/72-Light.woff2 rename to packages/playground/assets/fonts/72-Light.woff2 diff --git a/packages/playground/webapp/www/home/fonts/72-Regular.woff b/packages/playground/assets/fonts/72-Regular.woff similarity index 100% rename from packages/playground/webapp/www/home/fonts/72-Regular.woff rename to packages/playground/assets/fonts/72-Regular.woff diff --git a/packages/playground/webapp/www/home/fonts/72-Regular.woff2 b/packages/playground/assets/fonts/72-Regular.woff2 similarity index 100% rename from packages/playground/webapp/www/home/fonts/72-Regular.woff2 rename to packages/playground/assets/fonts/72-Regular.woff2 diff --git a/packages/playground/webapp/images/angular.svg b/packages/playground/assets/images/angular.svg similarity index 100% rename from packages/playground/webapp/images/angular.svg rename to packages/playground/assets/images/angular.svg diff --git a/packages/playground/webapp/www/samples/images/man_avatar_1.png b/packages/playground/assets/images/avatars/man_avatar_1.png similarity index 100% rename from packages/playground/webapp/www/samples/images/man_avatar_1.png rename to packages/playground/assets/images/avatars/man_avatar_1.png diff --git a/packages/playground/webapp/www/samples/images/man_avatar_2.png b/packages/playground/assets/images/avatars/man_avatar_2.png similarity index 100% rename from packages/playground/webapp/www/samples/images/man_avatar_2.png rename to packages/playground/assets/images/avatars/man_avatar_2.png diff --git a/packages/playground/webapp/www/samples/images/man_avatar_3.png b/packages/playground/assets/images/avatars/man_avatar_3.png similarity index 100% rename from packages/playground/webapp/www/samples/images/man_avatar_3.png rename to packages/playground/assets/images/avatars/man_avatar_3.png diff --git a/packages/playground/webapp/www/samples/images/man_avatar_4.png b/packages/playground/assets/images/avatars/man_avatar_4.png similarity index 100% rename from packages/playground/webapp/www/samples/images/man_avatar_4.png rename to packages/playground/assets/images/avatars/man_avatar_4.png diff --git a/packages/playground/webapp/www/samples/images/man_avatar_5.png b/packages/playground/assets/images/avatars/man_avatar_5.png similarity index 100% rename from packages/playground/webapp/www/samples/images/man_avatar_5.png rename to packages/playground/assets/images/avatars/man_avatar_5.png diff --git a/packages/playground/webapp/www/samples/images/woman_avatar_1.png b/packages/playground/assets/images/avatars/woman_avatar_1.png similarity index 100% rename from packages/playground/webapp/www/samples/images/woman_avatar_1.png rename to packages/playground/assets/images/avatars/woman_avatar_1.png diff --git a/packages/playground/webapp/www/samples/images/woman_avatar_2.png b/packages/playground/assets/images/avatars/woman_avatar_2.png similarity index 100% rename from packages/playground/webapp/www/samples/images/woman_avatar_2.png rename to packages/playground/assets/images/avatars/woman_avatar_2.png diff --git a/packages/playground/webapp/www/samples/images/woman_avatar_3.png b/packages/playground/assets/images/avatars/woman_avatar_3.png similarity index 100% rename from packages/playground/webapp/www/samples/images/woman_avatar_3.png rename to packages/playground/assets/images/avatars/woman_avatar_3.png diff --git a/packages/playground/webapp/www/samples/images/woman_avatar_4.png b/packages/playground/assets/images/avatars/woman_avatar_4.png similarity index 100% rename from packages/playground/webapp/www/samples/images/woman_avatar_4.png rename to packages/playground/assets/images/avatars/woman_avatar_4.png diff --git a/packages/playground/webapp/www/samples/images/woman_avatar_5.png b/packages/playground/assets/images/avatars/woman_avatar_5.png similarity index 100% rename from packages/playground/webapp/www/samples/images/woman_avatar_5.png rename to packages/playground/assets/images/avatars/woman_avatar_5.png diff --git a/packages/playground/webapp/images/bg.svg b/packages/playground/assets/images/bg.svg similarity index 100% rename from packages/playground/webapp/images/bg.svg rename to packages/playground/assets/images/bg.svg diff --git a/packages/playground/webapp/images/building.svg b/packages/playground/assets/images/building.svg similarity index 100% rename from packages/playground/webapp/images/building.svg rename to packages/playground/assets/images/building.svg diff --git a/packages/playground/webapp/images/bulb.svg b/packages/playground/assets/images/bulb.svg similarity index 100% rename from packages/playground/webapp/images/bulb.svg rename to packages/playground/assets/images/bulb.svg diff --git a/packages/playground/webapp/images/chrome.svg b/packages/playground/assets/images/chrome.svg similarity index 100% rename from packages/playground/webapp/images/chrome.svg rename to packages/playground/assets/images/chrome.svg diff --git a/packages/playground/webapp/images/edge.svg b/packages/playground/assets/images/edge.svg similarity index 100% rename from packages/playground/webapp/images/edge.svg rename to packages/playground/assets/images/edge.svg diff --git a/packages/playground/webapp/images/favicon-sap.ico b/packages/playground/assets/images/favicon-sap.ico similarity index 100% rename from packages/playground/webapp/images/favicon-sap.ico rename to packages/playground/assets/images/favicon-sap.ico diff --git a/packages/playground/webapp/images/favicon.ico b/packages/playground/assets/images/favicon.ico similarity index 100% rename from packages/playground/webapp/images/favicon.ico rename to packages/playground/assets/images/favicon.ico diff --git a/packages/playground/webapp/images/firefox.svg b/packages/playground/assets/images/firefox.svg similarity index 100% rename from packages/playground/webapp/images/firefox.svg rename to packages/playground/assets/images/firefox.svg diff --git a/packages/playground/webapp/images/ie.svg b/packages/playground/assets/images/ie.svg similarity index 100% rename from packages/playground/webapp/images/ie.svg rename to packages/playground/assets/images/ie.svg diff --git a/packages/playground/webapp/images/ui5.png b/packages/playground/assets/images/logo.png similarity index 100% rename from packages/playground/webapp/images/ui5.png rename to packages/playground/assets/images/logo.png diff --git a/packages/playground/webapp/images/odometer.svg b/packages/playground/assets/images/odometer.svg similarity index 100% rename from packages/playground/webapp/images/odometer.svg rename to packages/playground/assets/images/odometer.svg diff --git a/packages/playground/webapp/images/react.svg b/packages/playground/assets/images/react.svg similarity index 100% rename from packages/playground/webapp/images/react.svg rename to packages/playground/assets/images/react.svg diff --git a/packages/playground/webapp/images/safari.svg b/packages/playground/assets/images/safari.svg similarity index 100% rename from packages/playground/webapp/images/safari.svg rename to packages/playground/assets/images/safari.svg diff --git a/packages/playground/webapp/images/sap-logo-svg.svg b/packages/playground/assets/images/sap-logo-svg.svg similarity index 100% rename from packages/playground/webapp/images/sap-logo-svg.svg rename to packages/playground/assets/images/sap-logo-svg.svg diff --git a/packages/playground/assets/images/search.svg b/packages/playground/assets/images/search.svg new file mode 100644 index 000000000000..421ca4df01aa --- /dev/null +++ b/packages/playground/assets/images/search.svg @@ -0,0 +1 @@ +Search diff --git a/packages/playground/assets/images/settings-icon.svg b/packages/playground/assets/images/settings-icon.svg new file mode 100644 index 000000000000..4aeb5529895b --- /dev/null +++ b/packages/playground/assets/images/settings-icon.svg @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/playground/assets/images/ui5.png b/packages/playground/assets/images/ui5.png new file mode 100644 index 000000000000..da5a54aceb2b Binary files /dev/null and b/packages/playground/assets/images/ui5.png differ diff --git a/packages/playground/webapp/images/ui5logo.png b/packages/playground/assets/images/ui5logo.png similarity index 100% rename from packages/playground/webapp/images/ui5logo.png rename to packages/playground/assets/images/ui5logo.png diff --git a/packages/playground/webapp/images/vue.svg b/packages/playground/assets/images/vue.svg similarity index 100% rename from packages/playground/webapp/images/vue.svg rename to packages/playground/assets/images/vue.svg diff --git a/packages/playground/assets/js/playground.js b/packages/playground/assets/js/playground.js new file mode 100644 index 000000000000..102c6b9fd283 --- /dev/null +++ b/packages/playground/assets/js/playground.js @@ -0,0 +1,245 @@ +document.addEventListener("DOMContentLoaded", function() { + toggleNav(); + pageFocus(); + if (typeof lunr !== "undefined") { + initSearch(); + } + toggleSettings(); + setTheme(); + scrollSelectedMenuItemIntoView(); +}); + +function toggleSettings() { + var settingsButton = document.getElementById("settings-button"), + dialog = document.getElementById("settings-dialog"), + cancelButton = document.getElementById("cancelButton"), + applyButton = document.getElementById("applyButton"), + themeSwitch = document.getElementById("themeSwitch"), + contentDensitySwitch = document.getElementById("contentDensitySwitch"), + textDirectionSwitch = document.getElementById("textDirectionSwitch"); + + if (settingsButton) { + settingsButton.addEventListener("click", function(event) { + var urlParameters = getParams(window.location.href); + + // Casts to array because of IE11 + + // Set selected option of contentDensitySwitch + Array.prototype.slice.call(themeSwitch.querySelectorAll("ui5-option")).forEach(function(option) { + option.selected = option.value === urlParameters["sap-ui-theme"]; + }); + + // Set selected option of themeSwitch + Array.prototype.slice.call(contentDensitySwitch.querySelectorAll("ui5-option")).forEach(function(option) { + if (urlParameters["sap-ui-compactSize"] === "true") { + option.selected = option.textContent === "Compact"; + } else { + option.selected = option.textContent === "Cozy"; + } + }); + + // Set selected option of themeSwitch + Array.prototype.slice.call(textDirectionSwitch.querySelectorAll("ui5-option")).forEach(function(option) { + if (urlParameters["sap-ui-rtl"] === "true") { + option.selected = option.textContent === "RTL"; + } else { + option.selected = option.textContent === "LTR"; + } + }); + + dialog.open(); + }); + + cancelButton.addEventListener("click", function(event) { + dialog.close(); + }); + + applyButton.addEventListener("click", function(event) { + var theme = themeSwitch.selectedOption.value, + contentDensity = contentDensitySwitch.selectedOption.textContent, + textDirection = textDirectionSwitch.selectedOption.textContent; + + // Not implemented with string literals, beacause of IE11 + var newLocation = location.origin + location.pathname + "?sap-ui-theme="; + newLocation += theme; + newLocation += "&sap-ui-compactSize="; + newLocation += contentDensity === "Compact"; + newLocation += "&sap-ui-rtl="; + newLocation += textDirection === "RTL"; + + window.location = newLocation; + + dialog.close(); + }); + } +} + +function setTheme() { + var currentTheme = getParams(window.location.href)["sap-ui-theme"]; + if (currentTheme === "sap_belize_hcb") { + document.body.classList.add("hcb"); + } else { + document.body.classList.remove("hcb"); + } +} + +function getParams(url) { + var params = {}; + var parser = document.createElement("a"); + parser.href = url; + var query = parser.search.substring(1); + var vars = query.split("&"); + for (var i = 0; i < vars.length; i++) { + var pair = vars[i].split("="); + params[pair[0]] = decodeURIComponent(pair[1]); + } + return params; +} + +// Site search +function initSearch() { + var index = lunr(function () { + this.ref("id"); + this.field("title", { boost: 20 }); + this.field("content", { boost: 10 }); + this.field("url"); + }); + + // Get the generated search_data.json file so lunr.js can search it locally. + + var sc = document.getElementsByTagName("script"), + source = ""; + + for(var idx = 0; idx < sc.length; idx++) + { + var s = sc.item(idx); + + if(s.src && s.src.match(/playground\.js$/)) + { source = s.src; } + } + + var jsPath = source.replace("playground.js", ""); + + var jsonPath = jsPath + "search-data.json"; + + var request = new XMLHttpRequest(); + request.open("GET", jsonPath, true); + + request.onload = function() { + if (request.status >= 200 && request.status < 400) { + // Success! + var data = JSON.parse(request.responseText); + var keys = Object.keys(data); + + for(var i in data) { + index.add({ + id: data[i].id, + title: data[i].title, + content: data[i].content, + url: data[i].url + }); + } + searchResults(data); + } else { + // We reached our target server, but it returned an error + console.log("Error loading ajax request. Request status:" + request.status); + } + }; + + request.onerror = function() { + // There was a connection error of some sort + console.log("There was a connection error"); + }; + + request.send(); + + function searchResults(dataStore) { + var searchInput = document.querySelector(".js-search-input"); + var searchResults = document.querySelector(".js-search-results"); + var store = dataStore; + + function hideResults() { + searchResults.innerHTML = ""; + searchResults.classList.remove("active"); + } + + searchInput.addEventListener("keyup", function(e){ + var query = this.value; + + searchResults.innerHTML = ""; + searchResults.classList.remove("active"); + + if (query === "") { + hideResults(); + } else { + var results = index.search(query); + + if (results.length > 0) { + searchResults.classList.add("active"); + var resultsList = document.createElement("ul"); + searchResults.appendChild(resultsList); + + for (var i in results) { + var resultsListItem = document.createElement("li"); + var resultsLink = document.createElement("a"); + var resultsUrlDesc = document.createElement("span"); + var resultsUrl = store[results[i].ref].url; + var resultsRelUrl = store[results[i].ref].relUrl; + var resultsTitle = store[results[i].ref].title; + + resultsLink.setAttribute("href", resultsUrl); + resultsLink.innerText = resultsTitle; + resultsUrlDesc.innerText = resultsRelUrl; + + resultsList.classList.add("search-results-list"); + resultsListItem.classList.add("search-results-list-item"); + resultsLink.classList.add("search-results-link"); + resultsUrlDesc.classList.add("fs-2","text-grey-dk-000","d-block"); + + resultsList.appendChild(resultsListItem); + resultsListItem.appendChild(resultsLink); + resultsLink.appendChild(resultsUrlDesc); + } + } + + // When esc key is pressed, hide the results and clear the field + if (e.keyCode == 27) { + hideResults(); + searchInput.value = ""; + } + } + }); + + searchInput.addEventListener("blur", function(){ + setTimeout(function(){ hideResults() }, 300); + }); + } +} + +function pageFocus() { + var mainContent = document.querySelector(".js-main-content"); + mainContent.focus(); +} + +// Show/hide mobile menu +function toggleNav() { + var nav = document.querySelector(".js-main-nav"); + var navTrigger = document.querySelector(".js-main-nav-trigger"); + + navTrigger.addEventListener("click", function(event) { + nav.classList.toggle("nav-open"); + navTrigger.classList.toggle("nav-open"); + }) +} + +function scrollSelectedMenuItemIntoView() { + const selectedElement = document.querySelector(".navigation-list-link.active"); + const selectedElementBounding = selectedElement.getBoundingClientRect(); + if (selectedElementBounding.bottom >= (window.innerHeight || document.documentElement.clientHeight)) { + setTimeout(function() { + selectedElement.scrollIntoView({ + behavior: "smooth", + }); + }, 500); + } +} \ No newline at end of file diff --git a/packages/playground/assets/js/search-data.json b/packages/playground/assets/js/search-data.json new file mode 100644 index 000000000000..49cbc9dcbc2e --- /dev/null +++ b/packages/playground/assets/js/search-data.json @@ -0,0 +1,12 @@ +--- +--- +{ + {% for page in site.html_pages %}{% if page.search_exclude != true %}"{{ forloop.index0 }}": { + "id": "{{ forloop.index0 }}", + "title": "{{ page.title | replace: '&', '&' }}", + "content": "{{ page.content | markdownify | strip_html | escape_once | remove: 'Table of contents' | remove: '```' | remove: '---' | replace: '\', ' ' | normalize_whitespace }}", + "url": "{{ page.url | absolute_url }}", + "relUrl": "{{ page.url }}" + }{% unless forloop.last %},{% endunless %} + {% endif %}{% endfor %} +} diff --git a/packages/playground/assets/js/vendor/lunr.min.js b/packages/playground/assets/js/vendor/lunr.min.js new file mode 100644 index 000000000000..9960ccd23f6f --- /dev/null +++ b/packages/playground/assets/js/vendor/lunr.min.js @@ -0,0 +1,6 @@ +/** + * lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - 1.0.0 + * Copyright (C) 2017 Oliver Nightingale + * @license MIT + */ +!function(){var t=function(e){var n=new t.Index;return n.pipeline.add(t.trimmer,t.stopWordFilter,t.stemmer),e&&e.call(n,n),n};t.version="1.0.0",t.utils={},t.utils.warn=function(t){return function(e){t.console&&console.warn&&console.warn(e)}}(this),t.utils.asString=function(t){return void 0===t||null===t?"":t.toString()},t.EventEmitter=function(){this.events={}},t.EventEmitter.prototype.addListener=function(){var t=Array.prototype.slice.call(arguments),e=t.pop(),n=t;if("function"!=typeof e)throw new TypeError("last argument must be a function");n.forEach(function(t){this.hasHandler(t)||(this.events[t]=[]),this.events[t].push(e)},this)},t.EventEmitter.prototype.removeListener=function(t,e){if(this.hasHandler(t)){var n=this.events[t].indexOf(e);this.events[t].splice(n,1),this.events[t].length||delete this.events[t]}},t.EventEmitter.prototype.emit=function(t){if(this.hasHandler(t)){var e=Array.prototype.slice.call(arguments,1);this.events[t].forEach(function(t){t.apply(void 0,e)})}},t.EventEmitter.prototype.hasHandler=function(t){return t in this.events},t.tokenizer=function(e){return arguments.length&&null!=e&&void 0!=e?Array.isArray(e)?e.map(function(e){return t.utils.asString(e).toLowerCase()}):e.toString().trim().toLowerCase().split(t.tokenizer.separator):[]},t.tokenizer.separator=/[\s\-]+/,t.tokenizer.load=function(t){var e=this.registeredFunctions[t];if(!e)throw new Error("Cannot load un-registered function: "+t);return e},t.tokenizer.label="default",t.tokenizer.registeredFunctions={"default":t.tokenizer},t.tokenizer.registerFunction=function(e,n){n in this.registeredFunctions&&t.utils.warn("Overwriting existing tokenizer: "+n),e.label=n,this.registeredFunctions[n]=e},t.Pipeline=function(){this._stack=[]},t.Pipeline.registeredFunctions={},t.Pipeline.registerFunction=function(e,n){n in this.registeredFunctions&&t.utils.warn("Overwriting existing registered function: "+n),e.label=n,t.Pipeline.registeredFunctions[e.label]=e},t.Pipeline.warnIfFunctionNotRegistered=function(e){var n=e.label&&e.label in this.registeredFunctions;n||t.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},t.Pipeline.load=function(e){var n=new t.Pipeline;return e.forEach(function(e){var i=t.Pipeline.registeredFunctions[e];if(!i)throw new Error("Cannot load un-registered function: "+e);n.add(i)}),n},t.Pipeline.prototype.add=function(){var e=Array.prototype.slice.call(arguments);e.forEach(function(e){t.Pipeline.warnIfFunctionNotRegistered(e),this._stack.push(e)},this)},t.Pipeline.prototype.after=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var i=this._stack.indexOf(e);if(-1==i)throw new Error("Cannot find existingFn");i+=1,this._stack.splice(i,0,n)},t.Pipeline.prototype.before=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var i=this._stack.indexOf(e);if(-1==i)throw new Error("Cannot find existingFn");this._stack.splice(i,0,n)},t.Pipeline.prototype.remove=function(t){var e=this._stack.indexOf(t);-1!=e&&this._stack.splice(e,1)},t.Pipeline.prototype.run=function(t){for(var e=[],n=t.length,i=this._stack.length,r=0;n>r;r++){for(var o=t[r],s=0;i>s&&(o=this._stack[s](o,r,t),void 0!==o&&""!==o);s++);void 0!==o&&""!==o&&e.push(o)}return e},t.Pipeline.prototype.reset=function(){this._stack=[]},t.Pipeline.prototype.toJSON=function(){return this._stack.map(function(e){return t.Pipeline.warnIfFunctionNotRegistered(e),e.label})},t.Vector=function(){this._magnitude=null,this.list=void 0,this.length=0},t.Vector.Node=function(t,e,n){this.idx=t,this.val=e,this.next=n},t.Vector.prototype.insert=function(e,n){this._magnitude=void 0;var i=this.list;if(!i)return this.list=new t.Vector.Node(e,n,i),this.length++;if(en.idx?n=n.next:(i+=e.val*n.val,e=e.next,n=n.next);return i},t.Vector.prototype.similarity=function(t){return this.dot(t)/(this.magnitude()*t.magnitude())},t.SortedSet=function(){this.length=0,this.elements=[]},t.SortedSet.load=function(t){var e=new this;return e.elements=t,e.length=t.length,e},t.SortedSet.prototype.add=function(){var t,e;for(t=0;t1;){if(o===t)return r;t>o&&(e=r),o>t&&(n=r),i=n-e,r=e+Math.floor(i/2),o=this.elements[r]}return o===t?r:-1},t.SortedSet.prototype.locationFor=function(t){for(var e=0,n=this.elements.length,i=n-e,r=e+Math.floor(i/2),o=this.elements[r];i>1;)t>o&&(e=r),o>t&&(n=r),i=n-e,r=e+Math.floor(i/2),o=this.elements[r];return o>t?r:t>o?r+1:void 0},t.SortedSet.prototype.intersect=function(e){for(var n=new t.SortedSet,i=0,r=0,o=this.length,s=e.length,a=this.elements,h=e.elements;;){if(i>o-1||r>s-1)break;a[i]!==h[r]?a[i]h[r]&&r++:(n.add(a[i]),i++,r++)}return n},t.SortedSet.prototype.clone=function(){var e=new t.SortedSet;return e.elements=this.toArray(),e.length=e.elements.length,e},t.SortedSet.prototype.union=function(t){var e,n,i;this.length>=t.length?(e=this,n=t):(e=t,n=this),i=e.clone();for(var r=0,o=n.toArray();rp;p++)c[p]===a&&d++;h+=d/f*l.boost}}this.tokenStore.add(a,{ref:o,tf:h})}n&&this.eventEmitter.emit("add",e,this)},t.Index.prototype.remove=function(t,e){var n=t[this._ref],e=void 0===e?!0:e;if(this.documentStore.has(n)){var i=this.documentStore.get(n);this.documentStore.remove(n),i.forEach(function(t){this.tokenStore.remove(t,n)},this),e&&this.eventEmitter.emit("remove",t,this)}},t.Index.prototype.update=function(t,e){var e=void 0===e?!0:e;this.remove(t,!1),this.add(t,!1),e&&this.eventEmitter.emit("update",t,this)},t.Index.prototype.idf=function(t){var e="@"+t;if(Object.prototype.hasOwnProperty.call(this._idfCache,e))return this._idfCache[e];var n=this.tokenStore.count(t),i=1;return n>0&&(i=1+Math.log(this.documentStore.length/n)),this._idfCache[e]=i},t.Index.prototype.search=function(e){var n=this.pipeline.run(this.tokenizerFn(e)),i=new t.Vector,r=[],o=this._fields.reduce(function(t,e){return t+e.boost},0),s=n.some(function(t){return this.tokenStore.has(t)},this);if(!s)return[];n.forEach(function(e,n,s){var a=1/s.length*this._fields.length*o,h=this,u=this.tokenStore.expand(e).reduce(function(n,r){var o=h.corpusTokens.indexOf(r),s=h.idf(r),u=1,l=new t.SortedSet;if(r!==e){var c=Math.max(3,r.length-e.length);u=1/Math.log(c)}o>-1&&i.insert(o,a*s*u);for(var f=h.tokenStore.get(r),d=Object.keys(f),p=d.length,v=0;p>v;v++)l.add(f[d[v]].ref);return n.union(l)},new t.SortedSet);r.push(u)},this);var a=r.reduce(function(t,e){return t.intersect(e)});return a.map(function(t){return{ref:t,score:i.similarity(this.documentVector(t))}},this).sort(function(t,e){return e.score-t.score})},t.Index.prototype.documentVector=function(e){for(var n=this.documentStore.get(e),i=n.length,r=new t.Vector,o=0;i>o;o++){var s=n.elements[o],a=this.tokenStore.get(s)[e].tf,h=this.idf(s);r.insert(this.corpusTokens.indexOf(s),a*h)}return r},t.Index.prototype.toJSON=function(){return{version:t.version,fields:this._fields,ref:this._ref,tokenizer:this.tokenizerFn.label,documentStore:this.documentStore.toJSON(),tokenStore:this.tokenStore.toJSON(),corpusTokens:this.corpusTokens.toJSON(),pipeline:this.pipeline.toJSON()}},t.Index.prototype.use=function(t){var e=Array.prototype.slice.call(arguments,1);e.unshift(this),t.apply(this,e)},t.Store=function(){this.store={},this.length=0},t.Store.load=function(e){var n=new this;return n.length=e.length,n.store=Object.keys(e.store).reduce(function(n,i){return n[i]=t.SortedSet.load(e.store[i]),n},{}),n},t.Store.prototype.set=function(t,e){this.has(t)||this.length++,this.store[t]=e},t.Store.prototype.get=function(t){return this.store[t]},t.Store.prototype.has=function(t){return t in this.store},t.Store.prototype.remove=function(t){this.has(t)&&(delete this.store[t],this.length--)},t.Store.prototype.toJSON=function(){return{store:this.store,length:this.length}},t.stemmer=function(){var t={ational:"ate",tional:"tion",enci:"ence",anci:"ance",izer:"ize",bli:"ble",alli:"al",entli:"ent",eli:"e",ousli:"ous",ization:"ize",ation:"ate",ator:"ate",alism:"al",iveness:"ive",fulness:"ful",ousness:"ous",aliti:"al",iviti:"ive",biliti:"ble",logi:"log"},e={icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:""},n="[^aeiou]",i="[aeiouy]",r=n+"[^aeiouy]*",o=i+"[aeiou]*",s="^("+r+")?"+o+r,a="^("+r+")?"+o+r+"("+o+")?$",h="^("+r+")?"+o+r+o+r,u="^("+r+")?"+i,l=new RegExp(s),c=new RegExp(h),f=new RegExp(a),d=new RegExp(u),p=/^(.+?)(ss|i)es$/,v=/^(.+?)([^s])s$/,g=/^(.+?)eed$/,m=/^(.+?)(ed|ing)$/,y=/.$/,S=/(at|bl|iz)$/,w=new RegExp("([^aeiouylsz])\\1$"),k=new RegExp("^"+r+i+"[^aeiouwxy]$"),x=/^(.+?[^aeiou])y$/,b=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,E=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,F=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,_=/^(.+?)(s|t)(ion)$/,z=/^(.+?)e$/,O=/ll$/,P=new RegExp("^"+r+i+"[^aeiouwxy]$"),T=function(n){var i,r,o,s,a,h,u;if(n.length<3)return n;if(o=n.substr(0,1),"y"==o&&(n=o.toUpperCase()+n.substr(1)),s=p,a=v,s.test(n)?n=n.replace(s,"$1$2"):a.test(n)&&(n=n.replace(a,"$1$2")),s=g,a=m,s.test(n)){var T=s.exec(n);s=l,s.test(T[1])&&(s=y,n=n.replace(s,""))}else if(a.test(n)){var T=a.exec(n);i=T[1],a=d,a.test(i)&&(n=i,a=S,h=w,u=k,a.test(n)?n+="e":h.test(n)?(s=y,n=n.replace(s,"")):u.test(n)&&(n+="e"))}if(s=x,s.test(n)){var T=s.exec(n);i=T[1],n=i+"i"}if(s=b,s.test(n)){var T=s.exec(n);i=T[1],r=T[2],s=l,s.test(i)&&(n=i+t[r])}if(s=E,s.test(n)){var T=s.exec(n);i=T[1],r=T[2],s=l,s.test(i)&&(n=i+e[r])}if(s=F,a=_,s.test(n)){var T=s.exec(n);i=T[1],s=c,s.test(i)&&(n=i)}else if(a.test(n)){var T=a.exec(n);i=T[1]+T[2],a=c,a.test(i)&&(n=i)}if(s=z,s.test(n)){var T=s.exec(n);i=T[1],s=c,a=f,h=P,(s.test(i)||a.test(i)&&!h.test(i))&&(n=i)}return s=O,a=c,s.test(n)&&a.test(n)&&(s=y,n=n.replace(s,"")),"y"==o&&(n=o.toLowerCase()+n.substr(1)),n};return T}(),t.Pipeline.registerFunction(t.stemmer,"stemmer"),t.generateStopWordFilter=function(t){var e=t.reduce(function(t,e){return t[e]=e,t},{});return function(t){return t&&e[t]!==t?t:void 0}},t.stopWordFilter=t.generateStopWordFilter(["a","able","about","across","after","all","almost","also","am","among","an","and","any","are","as","at","be","because","been","but","by","can","cannot","could","dear","did","do","does","either","else","ever","every","for","from","get","got","had","has","have","he","her","hers","him","his","how","however","i","if","in","into","is","it","its","just","least","let","like","likely","may","me","might","most","must","my","neither","no","nor","not","of","off","often","on","only","or","other","our","own","rather","said","say","says","she","should","since","so","some","than","that","the","their","them","then","there","these","they","this","tis","to","too","twas","us","wants","was","we","were","what","when","where","which","while","who","whom","why","will","with","would","yet","you","your"]),t.Pipeline.registerFunction(t.stopWordFilter,"stopWordFilter"),t.trimmer=function(t){return t.replace(/^\W+/,"").replace(/\W+$/,"")},t.Pipeline.registerFunction(t.trimmer,"trimmer"),t.TokenStore=function(){this.root={docs:{}},this.length=0},t.TokenStore.load=function(t){var e=new this;return e.root=t.root,e.length=t.length,e},t.TokenStore.prototype.add=function(t,e,n){var n=n||this.root,i=t.charAt(0),r=t.slice(1);return i in n||(n[i]={docs:{}}),0===r.length?(n[i].docs[e.ref]=e,void(this.length+=1)):this.add(r,e,n[i])},t.TokenStore.prototype.has=function(t){if(!t)return!1;for(var e=this.root,n=0;n elements before custom elements + if (window.HTMLTemplateElement && HTMLTemplateElement.bootstrap) { + HTMLTemplateElement.bootstrap(window.document); + } + polyfillsLoaded = true; + runWhenLoadedFns().then(fireEvent); + } + + function runWhenLoadedFns() { + allowUpgrades = false; + var fnsMap = whenLoadedFns.map(function(fn) { + return fn instanceof Function ? fn() : fn; + }); + whenLoadedFns = []; + return Promise.all(fnsMap).then(function() { + allowUpgrades = true; + flushFn && flushFn(); + }).catch(function(err) { + console.error(err); + }); + } + + window.WebComponents = window.WebComponents || {}; + window.WebComponents.ready = window.WebComponents.ready || false; + window.WebComponents.waitFor = window.WebComponents.waitFor || function(waitFn) { + if (!waitFn) { + return; + } + whenLoadedFns.push(waitFn); + if (polyfillsLoaded) { + runWhenLoadedFns(); + } + }; + window.WebComponents._batchCustomElements = batchCustomElements; + + var name = 'webcomponents-loader.js'; + // Feature detect which polyfill needs to be imported. + var polyfills = []; + if (!('attachShadow' in Element.prototype && 'getRootNode' in Element.prototype) || + (window.ShadyDOM && window.ShadyDOM.force)) { + polyfills.push('sd'); + } + if (!window.customElements || window.customElements.forcePolyfill) { + polyfills.push('ce'); + } + + var needsTemplate = (function() { + // no real "},set:function(a){if(this.parentNode){T.body.innerHTML=a;for(a=this.ownerDocument.createDocumentFragment();T.body.firstChild;)m.call(a, +T.body.firstChild);n.call(this.parentNode,a,this)}else throw Error("Failed to set the 'outerHTML' property on 'Element': This element has no parent node.");},configurable:!0})};l(a.prototype);y(a.prototype);a.a=function(c){c=b(c,"template");for(var d=0,e=c.length,f;d]/g,La=function(a){switch(a){case "&":return"&";case "<":return"<";case ">":return">";case '"':return""";case "\u00a0":return" "}};q=function(a){for(var b={},c=0;c";break a;case Node.TEXT_NODE:h=h.data;h=k&&Ma[k.localName]?h:h.replace(Cb,La);break a; +case Node.COMMENT_NODE:h="\x3c!--"+h.data+"--\x3e";break a;default:throw window.console.error(h),Error("not implemented");}}c+=h}return c}}if(c||Bb){a.b=function(a,b){var c=f.call(a,!1);this.P&&this.P(c);b&&(m.call(c.content,f.call(a.content,!0)),Na(c.content,a.content));return c};var Na=function(c,d){if(d.querySelectorAll&&(d=b(d,"template"),0!==d.length)){c=b(c,"template");for(var e=0,f=c.length,g,h;e]/g;function Ib(a){switch(a){case "&":return"&";case "<":return"<";case ">":return">";case '"':return""";case "\u00a0":return" "}}function Jb(a){for(var b={},c=0;c";break a;case Node.TEXT_NODE:h=h.data;h=k&&Lb[k.localName]?h:h.replace(Hb,Ib);break a;case Node.COMMENT_NODE:h="\x3c!--"+h.data+"--\x3e";break a;default:throw window.console.error(h), +Error("not implemented");}}c+=h}return c};var Nb=B.D,Ob={querySelector:function(a){return this.__shady_native_querySelector(a)},querySelectorAll:function(a){return this.__shady_native_querySelectorAll(a)}},Pb={};function Qb(a){Pb[a]=function(b){return b["__shady_native_"+a]}}function Rb(a,b){D(a,b,"__shady_native_");for(var c in b)Qb(c)}function F(a,b){b=void 0===b?[]:b;for(var c=0;ce.assignedNodes.length&&(e.ba=!0)}e.ba&&(e.ba=!1,td(this,c))}c=this.a;b=[];for(e=0;eb.indexOf(d))||b.push(d);for(c=0;c "+b}))}a=a.replace(gg,function(a,b,c){return'[dir="'+c+'"] '+b+", "+b+'[dir="'+c+'"]'});return{value:a,Ha:b,stop:f}} +function eg(a,b){a=a.split(/(\[.+?\])/);for(var c=[],d=0;d+~]+)((?:\[.+?\]|[^\s>+~=[])+)/g,ig=/[[.:#*]/,ag=/^(::slotted)/,hg=/(:host)(?:\(((?:\([^)(]*\)|[^)(]*)+?)\))/,fg=/(?:::slotted)(?:\(((?:\([^)(]*\)|[^)(]*)+?)\))/,gg=/(.*):dir\((?:(ltr|rtl))\)/,Zf=/:(?:matches|any|-(?:webkit|moz)-any)/,S=new Mf;function kg(a,b,c,d,e){this.L=a||null;this.b=b||null;this.na=c||[];this.G=null;this.cssBuild=e||"";this.W=d||"";this.a=this.H=this.K=null}function U(a){return a?a.__styleInfo:null}function lg(a,b){return a.__styleInfo=b}kg.prototype.c=function(){return this.L};kg.prototype._getStyleRules=kg.prototype.c;function mg(a){var b=this.matches||this.matchesSelector||this.mozMatchesSelector||this.msMatchesSelector||this.oMatchesSelector||this.webkitMatchesSelector;return b&&b.call(this,a)}var ng=navigator.userAgent.match("Trident");function og(){}function pg(a){var b={},c=[],d=0;xf(a,function(a){qg(a);a.index=d++;a=a.A.cssText;for(var c;c=rf.exec(a);){var e=c[1];":"!==c[2]&&(b[e]=!0)}},function(a){c.push(a)});a.b=c;a=[];for(var e in b)a.push(e);return a} +function qg(a){if(!a.A){var b={},c={};rg(a,c)&&(b.J=c,a.rules=null);b.cssText=a.parsedCssText.replace(uf,"").replace(pf,"");a.A=b}}function rg(a,b){var c=a.A;if(c){if(c.J)return Object.assign(b,c.J),!0}else{c=a.parsedCssText;for(var d;a=pf.exec(c);){d=(a[2]||a[3]).trim();if("inherit"!==d||"unset"!==d)b[a[1].trim()]=d;d=!0}return d}} +function sg(a,b,c){b&&(b=0<=b.indexOf(";")?tg(a,b,c):Ff(b,function(b,e,f,g){if(!e)return b+g;(e=sg(a,c[e],c))&&"initial"!==e?"apply-shim-inherit"===e&&(e="inherit"):e=sg(a,c[f]||f,c)||f;return b+(e||"")+g}));return b&&b.trim()||""} +function tg(a,b,c){b=b.split(";");for(var d=0,e,f;d *"===f||"html"===f,h=0===f.indexOf(":host")&&!g;"shady"===c&&(g=f===e+" > *."+e||-1!==f.indexOf("html"),h=!g&&0===f.indexOf(e));if(g||h)c=e,h&&(b.C||(b.C=Vf(S,b,S.b,a?"."+a:"",e)),c=b.C||e),d({pa:c,Oa:h,ab:g})}}function wg(a,b,c){var d={},e={};xf(b,function(b){vg(a,b,c,function(c){mg.call(a._element||a,c.pa)&&(c.Oa?rg(b,d):rg(b,e))})},null,!0);return{Ta:e,Ma:d}} +function xg(a,b,c,d){var e=If(b),f=Uf(e.is,e.W),g=new RegExp("(?:^|[^.#[:])"+(b.extends?"\\"+f.slice(0,-1)+"\\]":f)+"($|[.:[\\s>+~])"),h=U(b);e=h.L;h=h.cssBuild;var k=yg(e,d);return Sf(b,e,function(b){var e="";b.A||qg(b);b.A.cssText&&(e=tg(a,b.A.cssText,c));b.cssText=e;if(!P&&!zf(b)&&b.cssText){var h=e=b.cssText;null==b.ta&&(b.ta=sf.test(e));if(b.ta)if(null==b.da){b.da=[];for(var m in k)h=k[m],h=h(e),e!==h&&(e=h,b.da.push(m))}else{for(m=0;m=m._useCount&&m.parentNode&&m.parentNode.removeChild(m));P?k.a?(k.a.textContent=h,g=k.a):h&&(g=Af(h,f,a.shadowRoot,k.b)):g?g.parentNode||(ng&&-1b&&-1==[34,35,60,62,63,96].indexOf(b)?a:encodeURIComponent(a)}function d(a){var b=a.charCodeAt(0);return 32b&&-1==[34,35,60,62,96].indexOf(b)?a:encodeURIComponent(a)}function e(a,e,g){function h(a){X.push(a)}var k=e||"scheme start",x=0,q="",u=!1,Q=!1,X=[];a:for(;(void 0!=a[x-1]||0==x)&&!this.i;){var l=a[x];switch(k){case "scheme start":if(l&&p.test(l))q+=l.toLowerCase(), +k="scheme";else if(e){h("Invalid scheme.");break a}else{q="";k="no scheme";continue}break;case "scheme":if(l&&G.test(l))q+=l.toLowerCase();else if(":"==l){this.h=q;q="";if(e)break a;void 0!==m[this.h]&&(this.B=!0);k="file"==this.h?"relative":this.B&&g&&g.h==this.h?"relative or authority":this.B?"authority first slash":"scheme data"}else if(e){void 0!=l&&h("Code point not allowed in scheme: "+l);break a}else{q="";x=0;k="no scheme";continue}break;case "scheme data":"?"==l?(this.o="?",k="query"):"#"== +l?(this.v="#",k="fragment"):void 0!=l&&"\t"!=l&&"\n"!=l&&"\r"!=l&&(this.la+=c(l));break;case "no scheme":if(g&&void 0!==m[g.h]){k="relative";continue}else h("Missing scheme."),f.call(this),this.i=!0;break;case "relative or authority":if("/"==l&&"/"==a[x+1])k="authority ignore slashes";else{h("Expected /, got: "+l);k="relative";continue}break;case "relative":this.B=!0;"file"!=this.h&&(this.h=g.h);if(void 0==l){this.j=g.j;this.m=g.m;this.l=g.l.slice();this.o=g.o;this.s=g.s;this.g=g.g;break a}else if("/"== +l||"\\"==l)"\\"==l&&h("\\ is an invalid code point."),k="relative slash";else if("?"==l)this.j=g.j,this.m=g.m,this.l=g.l.slice(),this.o="?",this.s=g.s,this.g=g.g,k="query";else if("#"==l)this.j=g.j,this.m=g.m,this.l=g.l.slice(),this.o=g.o,this.v="#",this.s=g.s,this.g=g.g,k="fragment";else{k=a[x+1];var y=a[x+2];if("file"!=this.h||!p.test(l)||":"!=k&&"|"!=k||void 0!=y&&"/"!=y&&"\\"!=y&&"?"!=y&&"#"!=y)this.j=g.j,this.m=g.m,this.s=g.s,this.g=g.g,this.l=g.l.slice(),this.l.pop();k="relative path";continue}break; +case "relative slash":if("/"==l||"\\"==l)"\\"==l&&h("\\ is an invalid code point."),k="file"==this.h?"file host":"authority ignore slashes";else{"file"!=this.h&&(this.j=g.j,this.m=g.m,this.s=g.s,this.g=g.g);k="relative path";continue}break;case "authority first slash":if("/"==l)k="authority second slash";else{h("Expected '/', got: "+l);k="authority ignore slashes";continue}break;case "authority second slash":k="authority ignore slashes";if("/"!=l){h("Expected '/', got: "+l);continue}break;case "authority ignore slashes":if("/"!= +l&&"\\"!=l){k="authority";continue}else h("Expected authority, got: "+l);break;case "authority":if("@"==l){u&&(h("@ already seen."),q+="%40");u=!0;for(l=0;l {\n const prop = Object.getOwnPropertyDescriptor(obj, name);\n return prop && prop.enumerable;\n });\n};\n\n// implement iterators for IE 11\nconst iterator = window.Symbol.iterator;\n\nif (!String.prototype[iterator] || !String.prototype.codePointAt) {\n /** @this {String} */\n String.prototype[iterator] = function*() {\n for (let i = 0; i < this.length; i++) {\n yield this[i];\n }\n }\n}\n\nif (!Set.prototype[iterator]) {\n /** @this {Set} */\n Set.prototype[iterator] = function*() {\n const temp = [];\n this.forEach((value) => {\n temp.push(value);\n });\n for (let i = 0; i < temp.length; i++) {\n yield temp[i];\n }\n };\n}\n\nif (!Map.prototype[iterator]) {\n /** @this {Map} */\n Map.prototype[iterator] = function*() {\n const entries = [];\n this.forEach((value, key) => {\n entries.push([key, value]);\n });\n for(let i = 0; i < entries.length; i++) {\n yield entries[i];\n }\n };\n}\n","/**\n * @license\n * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n */\n\n// minimal template polyfill\n(function() {\n 'use strict';\n\n var needsTemplate = (typeof HTMLTemplateElement === 'undefined');\n var brokenDocFragment = !(document.createDocumentFragment().cloneNode() instanceof DocumentFragment);\n var needsDocFrag = false;\n\n // NOTE: Replace DocumentFragment to work around IE11 bug that\n // causes children of a document fragment modified while\n // there is a mutation observer to not have a parentNode, or\n // have a broken parentNode (!?!)\n if (/Trident/.test(navigator.userAgent)) {\n (function() {\n\n needsDocFrag = true;\n\n var origCloneNode = Node.prototype.cloneNode;\n Node.prototype.cloneNode = function cloneNode(deep) {\n var newDom = origCloneNode.call(this, deep);\n if (this instanceof DocumentFragment) {\n newDom.__proto__ = DocumentFragment.prototype;\n }\n return newDom;\n };\n\n // IE's DocumentFragment querySelector code doesn't work when\n // called on an element instance\n DocumentFragment.prototype.querySelectorAll = HTMLElement.prototype.querySelectorAll;\n DocumentFragment.prototype.querySelector = HTMLElement.prototype.querySelector;\n\n Object.defineProperties(DocumentFragment.prototype, {\n 'nodeType': {\n get: function () {\n return Node.DOCUMENT_FRAGMENT_NODE;\n },\n configurable: true\n },\n\n 'localName': {\n get: function () {\n return undefined;\n },\n configurable: true\n },\n\n 'nodeName': {\n get: function () {\n return '#document-fragment';\n },\n configurable: true\n }\n });\n\n var origInsertBefore = Node.prototype.insertBefore;\n function insertBefore(newNode, refNode) {\n if (newNode instanceof DocumentFragment) {\n var child;\n while ((child = newNode.firstChild)) {\n origInsertBefore.call(this, child, refNode);\n }\n } else {\n origInsertBefore.call(this, newNode, refNode);\n }\n return newNode;\n }\n Node.prototype.insertBefore = insertBefore;\n\n var origAppendChild = Node.prototype.appendChild;\n Node.prototype.appendChild = function appendChild(child) {\n if (child instanceof DocumentFragment) {\n insertBefore.call(this, child, null);\n } else {\n origAppendChild.call(this, child);\n }\n return child;\n };\n\n var origRemoveChild = Node.prototype.removeChild;\n var origReplaceChild = Node.prototype.replaceChild;\n Node.prototype.replaceChild = function replaceChild(newChild, oldChild) {\n if (newChild instanceof DocumentFragment) {\n insertBefore.call(this, newChild, oldChild);\n origRemoveChild.call(this, oldChild);\n } else {\n origReplaceChild.call(this, newChild, oldChild);\n }\n return oldChild;\n };\n\n Document.prototype.createDocumentFragment = function createDocumentFragment() {\n var frag = this.createElement('df');\n frag.__proto__ = DocumentFragment.prototype;\n return frag;\n };\n\n var origImportNode = Document.prototype.importNode;\n Document.prototype.importNode = function importNode(impNode, deep) {\n deep = deep || false;\n var newNode = origImportNode.call(this, impNode, deep);\n if (impNode instanceof DocumentFragment) {\n newNode.__proto__ = DocumentFragment.prototype;\n }\n return newNode;\n };\n })();\n }\n\n // NOTE: we rely on this cloneNode not causing element upgrade.\n // This means this polyfill must load before the CE polyfill and\n // this would need to be re-worked if a browser supports native CE\n // but not