diff --git a/README.md b/README.md index acbb9827..ebcea010 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,11 @@ ## Quick start -Project contains a poetry dependency file for installation with `poetry install` -To run `poetry run python manage.py runserver` +You will need `npm` (for javascript dependencies) and poetry (for python dependencies). -## Configuration - -The following should be set using environment variables: - -- CATALOGUE_URL -- CATALOGUE_TOKEN +1. Run `npm install` and then `npm run sass` to compile the stylesheets. +2. Run `poetry install` to install python dependencies +3. Set environment variables CATALOGUE_URL and CATALOGUE_TOKEN (TODO: add dotenv support) +4. Run `poetry run python manage.py runserver` ## Current Endpoints diff --git a/node_modules/.bin/sass b/node_modules/.bin/sass new file mode 120000 index 00000000..4bda500d --- /dev/null +++ b/node_modules/.bin/sass @@ -0,0 +1 @@ +../sass/sass.js \ No newline at end of file diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json new file mode 100644 index 00000000..40ff9363 --- /dev/null +++ b/node_modules/.package-lock.json @@ -0,0 +1,244 @@ +{ + "name": "find-moj-data", + "lockfileVersion": 3, + "requires": true, + "packages": { + "node_modules/@ministryofjustice/frontend": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@ministryofjustice/frontend/-/frontend-2.0.1.tgz", + "integrity": "sha512-LqB+3B90VzSyTh7QM81hXpg2g3EzGDWNbWdUdEKu82DqyHf1n+h9rhSC+Vfdah3g1wgZyjpWVl9RCqyKzgK1Lg==", + "dependencies": { + "govuk-frontend": "^5.0.0", + "moment": "^2.27.0" + }, + "engines": { + "node": ">= 4.2.0" + }, + "peerDependencies": { + "jquery": "^3.6.0" + } + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", + "engines": { + "node": ">=8" + } + }, + "node_modules/braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dependencies": { + "fill-range": "^7.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/chokidar": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", + "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ], + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/govuk-frontend": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/govuk-frontend/-/govuk-frontend-5.0.0.tgz", + "integrity": "sha512-3WSfvQ+3kw/q/m8jrq/t8XnMUA8D2r0uhGyZaDbIh1gWTJBQzJBHbHiKYI9nc9ixIXdCFsc9RozkgEm57a795g==", + "engines": { + "node": ">= 4.2.0" + } + }, + "node_modules/immutable": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/immutable/-/immutable-4.3.4.tgz", + "integrity": "sha512-fsXeu4J4i6WNWSikpI88v/PcVflZz+6kMhUfIwc5SY+poQRPnaf5V7qds6SUyUN3cVxEzuCab7QIoLOQ+DQ1wA==" + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/jquery": { + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.7.1.tgz", + "integrity": "sha512-m4avr8yL8kmFN8psrbFFFmB/If14iN5o9nw/NgnnM+kybDJpRsAynV2BsfpTYrTRysYUdADVD7CkUUizgkpLfg==", + "peer": true + }, + "node_modules/moment": { + "version": "2.30.1", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.30.1.tgz", + "integrity": "sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==", + "engines": { + "node": "*" + } + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/sass": { + "version": "1.70.0", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.70.0.tgz", + "integrity": "sha512-uUxNQ3zAHeAx5nRFskBnrWzDUJrrvpCPD5FNAoRvTi0WwremlheES3tg+56PaVtCs5QDRX5CBLxxKMDJMEa1WQ==", + "dependencies": { + "chokidar": ">=3.0.0 <4.0.0", + "immutable": "^4.0.0", + "source-map-js": ">=0.6.2 <2.0.0" + }, + "bin": { + "sass": "sass.js" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/source-map-js": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", + "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + } + } +} diff --git a/node_modules/@ministryofjustice/frontend/README.md b/node_modules/@ministryofjustice/frontend/README.md new file mode 100755 index 00000000..c8f9eca8 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/README.md @@ -0,0 +1,63 @@ +[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) +[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) +![NPM License](https://img.shields.io/npm/l/@ministryofjustice/frontend) + +![GitHub Workflow Status](https://img.shields.io/github/workflow/status/ministryofjustice/moj-frontend/Build%20and%20deploy%20docs) +![NPM Downloads](https://img.shields.io/npm/v/@ministryofjustice/frontend) +![NPM Downloads](https://img.shields.io/npm/dw/@ministryofjustice/frontend) + +# Ministry of Justice Frontend + +MOJ Frontend contains the code you need to start building user interfaces for UK Ministry of Justice government services. + +See live examples of MOJ Frontend components, and guidance on when to use them in your service, in the [MOJ Pattern Library documentation](https://design-patterns.service.justice.gov.uk/). + +## Contribution Guidelines + +If you want to help us build MOJ Frontend, view our [contribution guidelines](CONTRIBUTING.md). This covers all areas from semvar commit messages to release process. + +## Contact the team + +MOJ Frontend is maintained by staff in the Ministry of Justice. If you need support, you can use [GitHub discussions](https://github.com/ministryofjustice/moj-frontend/discussions) or one of our Slack channels: +- [#moj-pattern-library-support](https://mojdt.slack.com/archives/CH5RUSB27) on Justice Digital Slack +- [#moj-design-system channel](https://ukgovernmentdigital.slack.com/archives/CJ6QDRDGC) on UK Government Digital Slack + +## Quick start + +We recommend [installing MOJ Frontend using node package manager (npm)](https://design-patterns.service.justice.gov.uk/get-started/installing-with-npm/). + +Once installed, you will be able to use the code from the examples in the [MOJ Pattern Library](https://design-patterns.service.justice.gov.uk/) in your service. + +## Browser support + +MOJ Frontend will allow you to build services that comply with the [guidance in the Service Manual][service-manual-browsers]. + +MOJ Frontend no longer supports Internet Explorer 8. If you need IE8 support, then [you must use an old version or provide your own support](docs/installation/supporting-internet-explorer-8.md). + +[service-manual-browsers]: https://www.gov.uk/service-manual/technology/designing-for-different-browsers-and-devices#browsers-to-test-in + +## Assistive technology support + +MOJ Frontend will allow you to build services that comply with the [guidance in the Service Manual][service-manual-assistive-technologies]. + +In addition, we test that all content is accessible with keyboard only. + +We aim to support [users who adjust or override the colours of websites they visit][how-users-change-colours-on-websites]. We test this by [changing colours in Firefox][changing-colours-in-firefox], by [enabling 'High Contrast' mode in Windows][enabling-high-contrast-mode-in-windows] and by using the [High Contrast plugin for Chrome][high-contrast-plugin-for-chrome]. + +[service-manual-assistive-technologies]: https://www.gov.uk/service-manual/technology/testing-with-assistive-technologies#what-to-test + +[changing-colours-in-firefox]: +https://support.mozilla.org/en-US/kb/change-fonts-and-colors-websites-use + +[enabling-high-contrast-mode-in-windows]: +https://support.microsoft.com/en-gb/help/13862/windows-use-high-contrast-mode + +[high-contrast-plugin-for-chrome]: https://chrome.google.com/webstore/detail/high-contrast/djcfdncoelnlbldjfhinnjlhdjlikmph?hl=en-US + +[how-users-change-colours-on-websites]: +https://accessibility.blog.gov.uk/2017/03/27/how-users-change-colours-on-websites/ + +### Further reading + +- [Component principles](https://github.com/alphagov/govuk_publishing_components/blob/master/docs/component_principles.md) +- [Component conventions](https://github.com/alphagov/govuk_publishing_components/blob/master/docs/component_conventions.md) diff --git a/node_modules/@ministryofjustice/frontend/govuk-prototype-kit.config.json b/node_modules/@ministryofjustice/frontend/govuk-prototype-kit.config.json new file mode 100755 index 00000000..e31b99c0 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/govuk-prototype-kit.config.json @@ -0,0 +1,96 @@ +{ + "meta": { + "description": "The MOJ Frontend contains the code you need to start building user interfaces for UK Ministry of Justice government services.", + "urls": { + "documentation": "https://design-patterns.service.justice.gov.uk/", + "releaseNotes": "https://github.com/ministryofjustice/moj-frontend/releases/tag/v{{version}}", + "versionHistory": "https://github.com/ministryofjustice/moj-frontend/releases" + } + }, + "nunjucksFilters": [ + "/moj/filters/prototype-kit-13-filters.js" + ], + "scripts": [ + "/moj/all.jquery.min.js", + "/moj/init.js" + ], + "assets": [ + "/moj/assets" + ], + "sass": [ + "/moj/all.scss" + ], + "nunjucksPaths": [ + "/" + ], + "nunjucksMacros": [ + { + "importFrom": "moj/components/side-navigation/macro.njk", + "macroName": "mojSideNavigation" + }, + { + "importFrom": "moj/components/organisation-switcher/macro.njk", + "macroName": "mojOrganisationSwitcher" + }, + { + "importFrom": "moj/components/primary-navigation/macro.njk", + "macroName": "mojPrimaryNavigation" + }, + { + "importFrom": "moj/components/identity-bar/macro.njk", + "macroName": "mojIdentityBar" + }, + { + "importFrom": "moj/components/sub-navigation/macro.njk", + "macroName": "mojSubNavigation" + }, + { + "importFrom": "moj/components/notification-badge/macro.njk", + "macroName": "mojNotificationBadge" + }, + { + "importFrom": "moj/components/ticket-panel/macro.njk", + "macroName": "mojTicketPanel" + }, + { + "importFrom": "moj/components/timeline/macro.njk", + "macroName": "mojTimeline" + }, + { + "importFrom": "moj/components/badge/macro.njk", + "macroName": "mojBadge" + }, + { + "importFrom": "moj/components/messages/macro.njk", + "macroName": "mojMessages" + }, + { + "importFrom": "moj/components/banner/macro.njk", + "macroName": "mojBanner" + }, + { + "importFrom": "moj/components/pagination/macro.njk", + "macroName": "mojPagination" + }, + { + "importFrom": "moj/components/filter/macro.njk", + "macroName": "mojFilter" + }, + { + "importFrom": "moj/components/button-menu/macro.njk", + "macroName": "mojButtonMenu" + }, + { + "importFrom": "moj/components/page-header-actions/macro.njk", + "macroName": "mojPageHeaderActions" + }, + { + "importFrom": "moj/components/search/macro.njk", + "macroName": "mojSearch" + }, + { + "importFrom": "moj/components/header/macro.njk", + "macroName": "mojHeader" + } + ] +} diff --git a/node_modules/@ministryofjustice/frontend/moj/all.jquery.min.js b/node_modules/@ministryofjustice/frontend/moj/all.jquery.min.js new file mode 100644 index 00000000..12ca883a --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/all.jquery.min.js @@ -0,0 +1 @@ +!function(e,t){"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?module.exports=t():e.MOJFrontend=t()}(this,function(){!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(e.document)return t(e);throw new Error("jQuery requires a window with a document")}:t(e)}("undefined"!=typeof window?window:this,function(w,F){"use strict";function v(e){return"function"==typeof e&&"number"!=typeof e.nodeType&&"function"!=typeof e.item}function m(e){return null!=e&&e===e.window}var t=[],H=Object.getPrototypeOf,s=t.slice,R=t.flat?function(e){return t.flat.call(e)}:function(e){return t.concat.apply([],e)},I=t.push,O=t.indexOf,P={},W=P.toString,$=P.hasOwnProperty,z=$.toString,U=z.call(Object),g={},T=w.document,V={type:!0,src:!0,nonce:!0,noModule:!0};function X(e,t,n){var o,r,i=(n=n||T).createElement("script");if(i.text=e,t)for(o in V)(r=t[o]||t.getAttribute&&t.getAttribute(o))&&i.setAttribute(o,r);n.head.appendChild(i).parentNode.removeChild(i)}function h(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?P[W.call(e)]||"object":typeof e}var e="3.6.0",k=function(e,t){return new k.fn.init(e,t)};function G(e){var t=!!e&&"length"in e&&e.length,n=h(e);return!v(e)&&!m(e)&&("array"===n||0===t||"number"==typeof t&&0>10|55296,1023&e|56320))}function H(e,t){return t?"\0"===e?"�":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e}function R(){T()}var e,p,x,i,I,f,O,P,w,u,l,T,k,n,C,h,o,r,m,j="sizzle"+ +new Date,c=F.document,S=0,W=0,$=D(),z=D(),U=D(),g=D(),V=function(e,t){return e===t&&(l=!0),0},X={}.hasOwnProperty,t=[],G=t.pop,K=t.push,A=t.push,Q=t.slice,v=function(e,t){for(var n=0,o=e.length;n+~]|"+a+")"+a+"*"),oe=new RegExp(a+"|>"),re=new RegExp(Z),ie=new RegExp("^"+s+"$"),b={ID:new RegExp("^#("+s+")"),CLASS:new RegExp("^\\.("+s+")"),TAG:new RegExp("^("+s+"|[*])"),ATTR:new RegExp("^"+J),PSEUDO:new RegExp("^"+Z),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+a+"*(even|odd|(([+-]|)(\\d*)n|)"+a+"*(?:([+-]|)"+a+"*(\\d+)|))"+a+"*\\)|)","i"),bool:new RegExp("^(?:"+Y+")$","i"),needsContext:new RegExp("^"+a+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+a+"*((?:-\\d)?\\d*)"+a+"*\\)|)(?=[^-]|$)","i")},ae=/HTML$/i,se=/^(?:input|select|textarea|button)$/i,ue=/^h\d$/i,E=/^[^{]+\{\s*\[native \w/,le=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ce=/[+~]/,B=new RegExp("\\\\[\\da-fA-F]{1,6}"+a+"?|\\\\([^\\r\\n\\f])","g"),de=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,pe=ve(function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()},{dir:"parentNode",next:"legend"});try{A.apply(t=Q.call(c.childNodes),c.childNodes),t[c.childNodes.length].nodeType}catch(e){A={apply:t.length?function(e,t){K.apply(e,Q.call(t))}:function(e,t){for(var n=e.length,o=0;e[n++]=t[o++];);e.length=n-1}}}function _(t,e,n,o){var r,i,a,s,u,l,c=e&&e.ownerDocument,d=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==d&&9!==d&&11!==d)return n;if(!o&&(T(e),e=e||k,C)){if(11!==d&&(s=le.exec(t)))if(r=s[1]){if(9===d){if(!(l=e.getElementById(r)))return n;if(l.id===r)return n.push(l),n}else if(c&&(l=c.getElementById(r))&&m(e,l)&&l.id===r)return n.push(l),n}else{if(s[2])return A.apply(n,e.getElementsByTagName(t)),n;if((r=s[3])&&p.getElementsByClassName&&e.getElementsByClassName)return A.apply(n,e.getElementsByClassName(r)),n}if(p.qsa&&!g[t+" "]&&(!h||!h.test(t))&&(1!==d||"object"!==e.nodeName.toLowerCase())){if(l=t,c=e,1===d&&(oe.test(t)||ne.test(t))){for((c=ce.test(t)&&ge(e.parentNode)||e)===e&&p.scope||((a=e.getAttribute("id"))?a=a.replace(de,H):e.setAttribute("id",a=j)),i=(u=f(t)).length;i--;)u[i]=(a?"#"+a:":scope")+" "+q(u[i]);l=u.join(",")}try{return A.apply(n,c.querySelectorAll(l)),n}catch(e){g(t,!0)}finally{a===j&&e.removeAttribute("id")}}}return P(t.replace(y,"$1"),e,n,o)}function D(){var n=[];function o(e,t){return n.push(e+" ")>x.cacheLength&&delete o[n.shift()],o[e+" "]=t}return o}function N(e){return e[j]=!0,e}function M(e){var t=k.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t)}}function fe(e,t){for(var n=e.split("|"),o=n.length;o--;)x.attrHandle[n[o]]=t}function he(e,t){var n=t&&e,o=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(o)return o;if(n)for(;n=n.nextSibling;)if(n===t)return-1;return e?1:-1}function me(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&&pe(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function L(a){return N(function(i){return i=+i,N(function(e,t){for(var n,o=a([],e.length,i),r=o.length;r--;)e[n=o[r]]&&(e[n]=!(t[n]=e[n]))})})}function ge(e){return e&&void 0!==e.getElementsByTagName&&e}for(e in p=_.support={},I=_.isXML=function(e){var t=e&&e.namespaceURI,e=e&&(e.ownerDocument||e).documentElement;return!ae.test(t||e&&e.nodeName||"HTML")},T=_.setDocument=function(e){var e=e?e.ownerDocument||e:c;return e!=k&&9===e.nodeType&&e.documentElement&&(n=(k=e).documentElement,C=!I(k),c!=k&&(e=k.defaultView)&&e.top!==e&&(e.addEventListener?e.addEventListener("unload",R,!1):e.attachEvent&&e.attachEvent("onunload",R)),p.scope=M(function(e){return n.appendChild(e).appendChild(k.createElement("div")),void 0!==e.querySelectorAll&&!e.querySelectorAll(":scope fieldset div").length}),p.attributes=M(function(e){return e.className="i",!e.getAttribute("className")}),p.getElementsByTagName=M(function(e){return e.appendChild(k.createComment("")),!e.getElementsByTagName("*").length}),p.getElementsByClassName=E.test(k.getElementsByClassName),p.getById=M(function(e){return n.appendChild(e).id=j,!k.getElementsByName||!k.getElementsByName(j).length}),p.getById?(x.filter.ID=function(e){var t=e.replace(B,d);return function(e){return e.getAttribute("id")===t}},x.find.ID=function(e,t){if(void 0!==t.getElementById&&C)return(t=t.getElementById(e))?[t]:[]}):(x.filter.ID=function(e){var t=e.replace(B,d);return function(e){e=void 0!==e.getAttributeNode&&e.getAttributeNode("id");return e&&e.value===t}},x.find.ID=function(e,t){if(void 0!==t.getElementById&&C){var n,o,r,i=t.getElementById(e);if(i){if((n=i.getAttributeNode("id"))&&n.value===e)return[i];for(r=t.getElementsByName(e),o=0;i=r[o++];)if((n=i.getAttributeNode("id"))&&n.value===e)return[i]}return[]}}),x.find.TAG=p.getElementsByTagName?function(e,t){return void 0!==t.getElementsByTagName?t.getElementsByTagName(e):p.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,o=[],r=0,i=t.getElementsByTagName(e);if("*"!==e)return i;for(;n=i[r++];)1===n.nodeType&&o.push(n);return o},x.find.CLASS=p.getElementsByClassName&&function(e,t){if(void 0!==t.getElementsByClassName&&C)return t.getElementsByClassName(e)},o=[],h=[],(p.qsa=E.test(k.querySelectorAll))&&(M(function(e){var t;n.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&h.push("[*^$]="+a+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||h.push("\\["+a+"*(?:value|"+Y+")"),e.querySelectorAll("[id~="+j+"-]").length||h.push("~="),(t=k.createElement("input")).setAttribute("name",""),e.appendChild(t),e.querySelectorAll("[name='']").length||h.push("\\["+a+"*name"+a+"*="+a+"*(?:''|\"\")"),e.querySelectorAll(":checked").length||h.push(":checked"),e.querySelectorAll("a#"+j+"+*").length||h.push(".#.+[+~]"),e.querySelectorAll("\\\f"),h.push("[\\r\\n\\f]")}),M(function(e){e.innerHTML="";var t=k.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&h.push("name"+a+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&h.push(":enabled",":disabled"),n.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&h.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),h.push(",.*:")})),(p.matchesSelector=E.test(r=n.matches||n.webkitMatchesSelector||n.mozMatchesSelector||n.oMatchesSelector||n.msMatchesSelector))&&M(function(e){p.disconnectedMatch=r.call(e,"*"),r.call(e,"[s!='']:x"),o.push("!=",Z)}),h=h.length&&new RegExp(h.join("|")),o=o.length&&new RegExp(o.join("|")),e=E.test(n.compareDocumentPosition),m=e||E.test(n.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,t=t&&t.parentNode;return e===t||!(!t||1!==t.nodeType||!(n.contains?n.contains(t):e.compareDocumentPosition&&16&e.compareDocumentPosition(t)))}:function(e,t){if(t)for(;t=t.parentNode;)if(t===e)return!0;return!1},V=e?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)||!p.sortDetached&&t.compareDocumentPosition(e)===n?e==k||e.ownerDocument==c&&m(c,e)?-1:t==k||t.ownerDocument==c&&m(c,t)?1:u?v(u,e)-v(u,t):0:4&n?-1:1)}:function(e,t){if(e===t)return l=!0,0;var n,o=0,r=e.parentNode,i=t.parentNode,a=[e],s=[t];if(!r||!i)return e==k?-1:t==k?1:r?-1:i?1:u?v(u,e)-v(u,t):0;if(r===i)return he(e,t);for(n=e;n=n.parentNode;)a.unshift(n);for(n=t;n=n.parentNode;)s.unshift(n);for(;a[o]===s[o];)o++;return o?he(a[o],s[o]):a[o]==c?-1:s[o]==c?1:0}),k},_.matches=function(e,t){return _(e,null,null,t)},_.matchesSelector=function(e,t){if(T(e),p.matchesSelector&&C&&!g[t+" "]&&(!o||!o.test(t))&&(!h||!h.test(t)))try{var n=r.call(e,t);if(n||p.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){g(t,!0)}return 0<_(t,k,null,[e]).length},_.contains=function(e,t){return(e.ownerDocument||e)!=k&&T(e),m(e,t)},_.attr=function(e,t){(e.ownerDocument||e)!=k&&T(e);var n=x.attrHandle[t.toLowerCase()],n=n&&X.call(x.attrHandle,t.toLowerCase())?n(e,t,!C):void 0;return void 0!==n?n:p.attributes||!C?e.getAttribute(t):(n=e.getAttributeNode(t))&&n.specified?n.value:null},_.escape=function(e){return(e+"").replace(de,H)},_.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},_.uniqueSort=function(e){var t,n=[],o=0,r=0;if(l=!p.detectDuplicates,u=!p.sortStable&&e.slice(0),e.sort(V),l){for(;t=e[r++];)t===e[r]&&(o=n.push(r));for(;o--;)e.splice(n[o],1)}return u=null,e},i=_.getText=function(e){var t,n="",o=0,r=e.nodeType;if(r){if(1===r||9===r||11===r){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=i(e)}else if(3===r||4===r)return e.nodeValue}else for(;t=e[o++];)n+=i(t);return n},(x=_.selectors={cacheLength:50,createPseudo:N,match:b,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(B,d),e[3]=(e[3]||e[4]||e[5]||"").replace(B,d),"~="===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]||_.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]&&_.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return b.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&re.test(n)&&(t=f(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(B,d).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=$[e+" "];return t||(t=new RegExp("(^|"+a+")"+e+"("+a+"|$)"))&&$(e,function(e){return t.test("string"==typeof e.className&&e.className||void 0!==e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(t,n,o){return function(e){e=_.attr(e,t);return null==e?"!="===n:!n||(e+="","="===n?e===o:"!="===n?e!==o:"^="===n?o&&0===e.indexOf(o):"*="===n?o&&-1:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function J(e,n,o){return v(n)?k.grep(e,function(e,t){return!!n.call(e,t,e)!==o}):n.nodeType?k.grep(e,function(e){return e===n!==o}):"string"!=typeof n?k.grep(e,function(e){return-1)[^>]*|#([\w-]+))$/,te=((k.fn.init=function(e,t,n){if(!e)return this;if(n=n||Z,"string"!=typeof e)return e.nodeType?(this[0]=e,this.length=1,this):v(e)?void 0!==n.ready?n.ready(e):e(k):k.makeArray(e,this);if(!(o="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:ee.exec(e))||!o[1]&&t)return(!t||t.jquery?t||n:this.constructor(t)).find(e);if(o[1]){if(t=t instanceof k?t[0]:t,k.merge(this,k.parseHTML(o[1],t&&t.nodeType?t.ownerDocument||t:T,!0)),Y.test(o[1])&&k.isPlainObject(t))for(var o in t)v(this[o])?this[o](t[o]):this.attr(o,t[o]);return this}return(n=T.getElementById(o[2]))&&(this[0]=n,this.length=1),this}).prototype=k.fn,Z=k(T),/^(?:parents|prev(?:Until|All))/),ne={children:!0,contents:!0,next:!0,prev:!0};function oe(e,t){for(;(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,ke=/^$|^module$|\/(?:java|ecma)script/i,E=(N=T.createDocumentFragment().appendChild(T.createElement("div")),(a=T.createElement("input")).setAttribute("type","radio"),a.setAttribute("checked","checked"),a.setAttribute("name","t"),N.appendChild(a),g.checkClone=N.cloneNode(!0).cloneNode(!0).lastChild.checked,N.innerHTML="",g.noCloneChecked=!!N.cloneNode(!0).lastChild.defaultValue,N.innerHTML="",g.option=!!N.lastChild,{thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]});function B(e,t){var n=void 0!==e.getElementsByTagName?e.getElementsByTagName(t||"*"):void 0!==e.querySelectorAll?e.querySelectorAll(t||"*"):[];return void 0===t||t&&u(e,t)?k.merge([e],n):n}function Ce(e,t){for(var n=0,o=e.length;n",""]);var je=/<|&#?\w+;/;function Se(e,t,n,o,r){for(var i,a,s,u,l,c=t.createDocumentFragment(),d=[],p=0,f=e.length;p\s*$/g;function Le(e,t){return u(e,"table")&&u(11!==t.nodeType?t:t.firstChild,"tr")&&k(e).children("tbody")[0]||e}function qe(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function Fe(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function He(e,t){var n,o,r,i;if(1===t.nodeType){if(x.hasData(e)&&(i=x.get(e).events))for(r in x.remove(t,"handle events"),i)for(n=0,o=i[r].length;n").attr(n.scriptAttrs||{}).prop({charset:n.scriptCharset,src:n.url}).on("load error",r=function(e){o.remove(),r=null,e&&t("error"===e.type?404:200,e.type)}),T.head.appendChild(o[0])},abort:function(){r&&r()}}}),[]),Kt=/(=)\?(?=&|$)|\?\?/,Qt=(k.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Gt.pop()||k.expando+"_"+At.guid++;return this[e]=!0,e}}),k.ajaxPrefilter("json jsonp",function(e,t,n){var o,r,i,a=!1!==e.jsonp&&(Kt.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&Kt.test(e.data)&&"data");if(a||"jsonp"===e.dataTypes[0])return o=e.jsonpCallback=v(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,a?e[a]=e[a].replace(Kt,"$1"+o):!1!==e.jsonp&&(e.url+=(Et.test(e.url)?"&":"?")+e.jsonp+"="+o),e.converters["script json"]=function(){return i||k.error(o+" was not called"),i[0]},e.dataTypes[0]="json",r=w[o],w[o]=function(){i=arguments},n.always(function(){void 0===r?k(w).removeProp(o):w[o]=r,e[o]&&(e.jsonpCallback=t.jsonpCallback,Gt.push(o)),i&&v(r)&&r(i[0]),i=r=void 0}),"script"}),g.createHTMLDocument=((e=T.implementation.createHTMLDocument("").body).innerHTML="
",2===e.childNodes.length),k.parseHTML=function(e,t,n){return"string"!=typeof e?[]:("boolean"==typeof t&&(n=t,t=!1),t||(g.createHTMLDocument?((o=(t=T.implementation.createHTMLDocument("")).createElement("base")).href=T.location.href,t.head.appendChild(o)):t=T),o=!n&&[],(n=Y.exec(e))?[t.createElement(n[1])]:(n=Se([e],t,o),o&&o.length&&k(o).remove(),k.merge([],n.childNodes)));var o},k.fn.load=function(e,t,n){var o,r,i,a=this,s=e.indexOf(" ");return-1").append(k.parseHTML(e)).find(o):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,i||[e.responseText,t,e])})}),this},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 o,r,i,a,s=k.css(e,"position"),u=k(e),l={};"static"===s&&(e.style.position="relative"),i=u.offset(),o=k.css(e,"top"),a=k.css(e,"left"),s=("absolute"===s||"fixed"===s)&&-1<(o+a).indexOf("auto")?(r=(s=u.position()).top,s.left):(r=parseFloat(o)||0,parseFloat(a)||0),null!=(t=v(t)?t.call(e,n,k.extend({},i)):t).top&&(l.top=t.top-i.top+r),null!=t.left&&(l.left=t.left-i.left+s),"using"in t?t.using.call(e,l):u.css(l)}},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=this[0];return n?n.getClientRects().length?(e=n.getBoundingClientRect(),n=n.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,o=this[0],r={top:0,left:0};if("fixed"===k.css(o,"position"))t=o.getBoundingClientRect();else{for(t=this.offset(),n=o.ownerDocument,e=o.offsetParent||n.documentElement;e&&(e===n.body||e===n.documentElement)&&"static"===k.css(e,"position");)e=e.parentNode;e&&e!==o&&1===e.nodeType&&((r=k(e).offset()).top+=k.css(e,"borderTopWidth",!0),r.left+=k.css(e,"borderLeftWidth",!0))}return{top:t.top-r.top-k.css(o,"marginTop",!0),left:t.left-r.left-k.css(o,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){for(var e=this.offsetParent;e&&"static"===k.css(e,"position");)e=e.offsetParent;return e||j})}}),k.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,r){var i="pageYOffset"===r;k.fn[t]=function(e){return d(this,function(e,t,n){var o;if(m(e)?o=e:9===e.nodeType&&(o=e.defaultView),void 0===n)return o?o[r]:e[t];o?o.scrollTo(i?o.pageXOffset:n,i?n:o.pageYOffset):e[t]=n},t,e,arguments.length)}}),k.each(["top","left"],function(e,n){k.cssHooks[n]=Ze(g.pixelPosition,function(e,t){if(t)return t=Je(e,n),Ge.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(o,i){k.fn[i]=function(e,t){var n=arguments.length&&(o||"boolean"!=typeof e),r=o||(!0===e||!0===t?"margin":"border");return d(this,function(e,t,n){var o;return m(e)?0===i.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(o=e.documentElement,Math.max(e.body["scroll"+a],o["scroll"+a],e.body["offset"+a],o["offset"+a],o["client"+a])):void 0===n?k.css(e,t,r):k.style(e,t,n,r)},s,n?e:void 0,n)}})}),k.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){k.fn[t]=function(e){return this.on(t,e)}}),k.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,o){return this.on(t,e,n,o)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),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 0Remove')},u.AddAnother.prototype.resetItem=function(e){e.find("[data-name], [data-id]").each(function(e,t){"checkbox"==t.type||"radio"==t.type?t.checked=!1:t.value=""})},u.AddAnother.prototype.onRemoveButtonClick=function(e){s(e.currentTarget).parents(".moj-add-another__item").remove();e=this.getItems();1===e.length&&e.find(".moj-add-another__remove-button").remove(),e.each(s.proxy(function(e,t){this.updateAttributes(e,s(t))},this)),this.focusHeading()},u.AddAnother.prototype.focusHeading=function(){this.container.find(".moj-add-another__heading").focus()},u.ButtonMenu=function(e){this.container=e.container,this.menu=this.container.find(".moj-button-menu__wrapper"),e.menuClasses&&this.menu.addClass(e.menuClasses),this.menu.attr("role","menu"),this.mq=e.mq,this.buttonText=e.buttonText,this.buttonClasses=e.buttonClasses||"",this.keys={esc:27,up:38,down:40,tab:9},this.menu.on("keydown","[role=menuitem]",s.proxy(this,"onButtonKeydown")),this.createToggleButton(),this.setupResponsiveChecks(),s(document).on("click",s.proxy(this,"onDocumentClick"))},u.ButtonMenu.prototype.onDocumentClick=function(e){s.contains(this.container[0],e.target)||this.hideMenu()},u.ButtonMenu.prototype.createToggleButton=function(){this.menuButton=s('"),this.menuButton.on("click",s.proxy(this,"onMenuButtonClick")),this.menuButton.on("keydown",s.proxy(this,"onMenuKeyDown"))},u.ButtonMenu.prototype.setupResponsiveChecks=function(){this.mql=window.matchMedia(this.mq),this.mql.addListener(s.proxy(this,"checkMode")),this.checkMode(this.mql)},u.ButtonMenu.prototype.checkMode=function(e){e.matches?this.enableBigMode():this.enableSmallMode()},u.ButtonMenu.prototype.enableSmallMode=function(){this.container.prepend(this.menuButton),this.hideMenu(),this.removeButtonClasses(),this.menu.attr("role","menu"),this.container.find(".moj-button-menu__item").attr("role","menuitem")},u.ButtonMenu.prototype.enableBigMode=function(){this.menuButton.detach(),this.showMenu(),this.addButtonClasses(),this.menu.removeAttr("role"),this.container.find(".moj-button-menu__item").removeAttr("role")},u.ButtonMenu.prototype.removeButtonClasses=function(){this.menu.find(".moj-button-menu__item").each(function(e,t){s(t).hasClass("govuk-button--secondary")&&(s(t).attr("data-secondary","true"),s(t).removeClass("govuk-button--secondary")),s(t).hasClass("govuk-button--warning")&&(s(t).attr("data-warning","true"),s(t).removeClass("govuk-button--warning")),s(t).removeClass("govuk-button")})},u.ButtonMenu.prototype.addButtonClasses=function(){this.menu.find(".moj-button-menu__item").each(function(e,t){"true"==s(t).attr("data-secondary")&&s(t).addClass("govuk-button--secondary"),"true"==s(t).attr("data-warning")&&s(t).addClass("govuk-button--warning"),s(t).addClass("govuk-button")})},u.ButtonMenu.prototype.hideMenu=function(){this.menuButton.attr("aria-expanded","false")},u.ButtonMenu.prototype.showMenu=function(){this.menuButton.attr("aria-expanded","true")},u.ButtonMenu.prototype.onMenuButtonClick=function(){this.toggle()},u.ButtonMenu.prototype.toggle=function(){"false"==this.menuButton.attr("aria-expanded")?(this.showMenu(),this.menu.find("[role=menuitem]").first().focus()):(this.hideMenu(),this.menuButton.focus())},u.ButtonMenu.prototype.onMenuKeyDown=function(e){e.keyCode===this.keys.down&&this.toggle()},u.ButtonMenu.prototype.onButtonKeydown=function(e){switch(e.keyCode){case this.keys.up:e.preventDefault(),this.focusPrevious(e.currentTarget);break;case this.keys.down:e.preventDefault(),this.focusNext(e.currentTarget);break;case this.keys.esc:this.mql.matches||(this.menuButton.focus(),this.hideMenu());break;case this.keys.tab:this.mql.matches||this.hideMenu()}},u.ButtonMenu.prototype.focusNext=function(e){e=s(e).next();(e[0]?e:this.container.find("[role=menuitem]").first()).focus()},u.ButtonMenu.prototype.focusPrevious=function(e){e=s(e).prev();(e[0]?e:this.container.find("[role=menuitem]").last()).focus()},u.FilterToggleButton=function(e){this.options=e,this.container=this.options.toggleButton.container,this.createToggleButton(),this.setupResponsiveChecks(),this.options.filter.container.attr("tabindex","-1"),this.options.startHidden&&this.hideMenu()},u.FilterToggleButton.prototype.setupResponsiveChecks=function(){this.mq=window.matchMedia(this.options.bigModeMediaQuery),this.mq.addListener(s.proxy(this,"checkMode")),this.checkMode(this.mq)},u.FilterToggleButton.prototype.createToggleButton=function(){this.menuButton=s('"),this.menuButton.on("click",s.proxy(this,"onMenuButtonClick")),this.options.toggleButton.container.append(this.menuButton)},u.FilterToggleButton.prototype.checkMode=function(e){e.matches?this.enableBigMode():this.enableSmallMode()},u.FilterToggleButton.prototype.enableBigMode=function(){this.showMenu(),this.removeCloseButton()},u.FilterToggleButton.prototype.enableSmallMode=function(){this.hideMenu(),this.addCloseButton()},u.FilterToggleButton.prototype.addCloseButton=function(){this.options.closeButton&&(this.closeButton=s('"),this.closeButton.on("click",s.proxy(this,"onCloseClick")),this.options.closeButton.container.append(this.closeButton))},u.FilterToggleButton.prototype.onCloseClick=function(){this.hideMenu(),this.menuButton.focus()},u.FilterToggleButton.prototype.removeCloseButton=function(){this.closeButton&&(this.closeButton.remove(),this.closeButton=null)},u.FilterToggleButton.prototype.hideMenu=function(){this.menuButton.attr("aria-expanded","false"),this.options.filter.container.addClass("moj-js-hidden"),this.menuButton.text(this.options.toggleButton.showText)},u.FilterToggleButton.prototype.showMenu=function(){this.menuButton.attr("aria-expanded","true"),this.options.filter.container.removeClass("moj-js-hidden"),this.menuButton.text(this.options.toggleButton.hideText)},u.FilterToggleButton.prototype.onMenuButtonClick=function(){this.toggle()},u.FilterToggleButton.prototype.toggle=function(){"false"==this.menuButton.attr("aria-expanded")?(this.showMenu(),this.options.filter.container.focus()):this.hideMenu()},u.FormValidator=function(e,t){this.form=e,this.errors=[],this.validators=[],s(this.form).on("submit",s.proxy(this,"onSubmit")),this.summary=t&&t.summary?s(t.summary):s(".govuk-error-summary"),this.originalTitle=document.title},u.FormValidator.entityMap={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="},u.FormValidator.prototype.escapeHtml=function(e){return String(e).replace(/[&<>"'`=\/]/g,function(e){return u.FormValidator.entityMap[e]})},u.FormValidator.prototype.resetTitle=function(){document.title=this.originalTitle},u.FormValidator.prototype.updateTitle=function(){document.title=this.errors.length+" errors - "+document.title},u.FormValidator.prototype.showSummary=function(){this.summary.html(this.getSummaryHtml()),this.summary.removeClass("moj-hidden"),this.summary.attr("aria-labelledby","errorSummary-heading"),this.summary.focus()},u.FormValidator.prototype.getSummaryHtml=function(){o='

There is a problem

"+"
"},u.FormValidator.prototype.hideSummary=function(){this.summary.addClass("moj-hidden"),this.summary.removeAttr("aria-labelledby")},u.FormValidator.prototype.onSubmit=function(e){this.removeInlineErrors(),this.hideSummary(),this.resetTitle(),this.validate()||(e.preventDefault(),this.updateTitle(),this.showSummary(),this.showInlineErrors())},u.FormValidator.prototype.showInlineErrors=function(){for(var e=0,t=this.errors.length;e'+this.escapeHtml(e.message)+"",e=s("#"+e.fieldName),o=e.parents(".govuk-form-group"),r=o.find("label"),i=o.find("legend"),a=o.find("fieldset");o.addClass("govuk-form-group--error"),i.length?(i.after(n),o.attr("aria-invalid","true"),u.addAttributeValue(a[0],"aria-describedby",t)):(r.after(n),e.attr("aria-invalid","true"),u.addAttributeValue(e[0],"aria-describedby",t))},u.FormValidator.prototype.removeInlineErrors=function(){for(var e=0;e'),this.dropzone=this.params.container.find(".moj-multi-file-upload__dropzone"),this.dropzone.on("dragover",s.proxy(this,"onDragOver")),this.dropzone.on("dragleave",s.proxy(this,"onDragLeave")),this.dropzone.on("drop",s.proxy(this,"onDrop"))},u.MultiFileUpload.prototype.setupLabel=function(){this.label=s('"),this.dropzone.append('

'+this.params.dropzoneHintText+"

"),this.dropzone.append(this.label)},u.MultiFileUpload.prototype.setupFileInput=function(){this.fileInput=this.params.container.find(".moj-multi-file-upload__input"),this.fileInput.on("change",s.proxy(this,"onFileChange")),this.fileInput.on("focus",s.proxy(this,"onFileFocus")),this.fileInput.on("blur",s.proxy(this,"onFileBlur"))},u.MultiFileUpload.prototype.setupStatusBox=function(){this.status=s('
'),this.dropzone.append(this.status)},u.MultiFileUpload.prototype.onDragOver=function(e){e.preventDefault(),this.dropzone.addClass("moj-multi-file-upload--dragover")},u.MultiFileUpload.prototype.onDragLeave=function(){this.dropzone.removeClass("moj-multi-file-upload--dragover")},u.MultiFileUpload.prototype.onDrop=function(e){e.preventDefault(),this.dropzone.removeClass("moj-multi-file-upload--dragover"),this.feedbackContainer.removeClass("moj-hidden"),this.status.html(this.params.uploadStatusText),this.uploadFiles(e.originalEvent.dataTransfer.files)},u.MultiFileUpload.prototype.uploadFiles=function(e){for(var t=0;t '+e.messageHtml+""},u.MultiFileUpload.prototype.getErrorHtml=function(e){return' '+e.message+""},u.MultiFileUpload.prototype.getFileRowHtml=function(e){var t="";return(t+='
')+'
'+(''+e.name+"")+'0%'+"
"+'
'+"
"},u.MultiFileUpload.prototype.getDeleteButtonHtml=function(e){var t='"},u.MultiFileUpload.prototype.uploadFile=function(o){this.params.uploadFileEntryHook(this,o);var e=new FormData,t=(e.append("documents",o),s(this.getFileRowHtml(o)));this.feedbackContainer.find(".moj-multi-file-upload__list").append(t),s.ajax({url:this.params.uploadUrl,type:"post",data:e,processData:!1,contentType:!1,success:s.proxy(function(e){e.error?(t.find(".moj-multi-file-upload__message").html(this.getErrorHtml(e.error)),this.status.html(e.error.message)):(t.find(".moj-multi-file-upload__message").html(this.getSuccessHtml(e.success)),this.status.html(e.success.messageText)),t.find(".moj-multi-file-upload__actions").append(this.getDeleteButtonHtml(e.file)),this.params.uploadFileExitHook(this,o,e)},this),error:s.proxy(function(e,t,n){this.params.uploadFileErrorHook(this,o,e,t,n)},this),xhr:function(){var e=new XMLHttpRequest;return e.upload.addEventListener("progress",function(e){e.lengthComputable&&(e=e.loaded/e.total,e=parseInt(100*e,10),t.find(".moj-multi-file-upload__progress").text(" "+e+"%"))},!1),e}})},u.MultiFileUpload.prototype.onFileDeleteClick=function(e){e.preventDefault();var t=s(e.currentTarget),e={};e[t[0].name]=t[0].value,s.ajax({url:this.params.deleteUrl,type:"post",dataType:"json",data:e,success:s.proxy(function(e){e.error||(t.parents(".moj-multi-file-upload__row").remove(),0===this.feedbackContainer.find(".moj-multi-file-upload__row").length&&this.feedbackContainer.addClass("moj-hidden")),this.params.fileDeleteHook(this,e)},this)})}),u.MultiSelect=function(e){this.container=s(e.container),this.container.data("moj-multi-select-initialised")||(this.container.data("moj-multi-select-initialised",!0),this.toggle=s(this.getToggleHtml()),this.toggleButton=this.toggle.find("input"),this.toggleButton.on("click",s.proxy(this,"onButtonClick")),this.container.append(this.toggle),this.checkboxes=s(e.checkboxes),this.checkboxes.on("click",s.proxy(this,"onCheckboxClick")),this.checked=e.checked||!1)},u.MultiSelect.prototype.getToggleHtml=function(){return'
'},u.MultiSelect.prototype.onButtonClick=function(e){this.checked?(this.uncheckAll(),this.toggleButton[0].checked=!1):(this.checkAll(),this.toggleButton[0].checked=!0)},u.MultiSelect.prototype.checkAll=function(){this.checkboxes.each(s.proxy(function(e,t){t.checked=!0},this)),this.checked=!0},u.MultiSelect.prototype.uncheckAll=function(){this.checkboxes.each(s.proxy(function(e,t){t.checked=!1},this)),this.checked=!1},u.MultiSelect.prototype.onCheckboxClick=function(e){e.target.checked?this.checkboxes.filter(":checked").length===this.checkboxes.length&&(this.toggleButton[0].checked=!0,this.checked=!0):(this.toggleButton[0].checked=!1,this.checked=!1)},u.PasswordReveal=function(e){this.el=e;e=s(this.el);e.data("moj-password-reveal-initialised")||(e.data("moj-password-reveal-initialised",!0),e.attr("spellcheck","false"),e.wrap('
'),this.container=s(this.el).parent(),this.createButton())},u.PasswordReveal.prototype.createButton=function(){this.button=s(''),this.container.append(this.button),this.button.on("click",s.proxy(this,"onButtonClick"))},u.PasswordReveal.prototype.onButtonClick=function(){"password"===this.el.type?(this.el.type="text",this.button.html('Hide password')):(this.el.type="password",this.button.html('Show password'))},"contentEditable"in document.documentElement&&(u.RichTextEditor=function(e){this.options=e,this.options.toolbar=this.options.toolbar||{bold:!1,italic:!1,underline:!1,bullets:!0,numbers:!0},this.textarea=this.options.textarea,this.container=s(this.textarea).parent(),this.container.data("moj-rich-text-editor-initialised")||(this.container.data("moj-rich-text-editor-initialised",!0),this.createToolbar(),this.hideDefault(),this.configureToolbar(),this.keys={left:37,right:39,up:38,down:40},this.container.on("click",".moj-rich-text-editor__toolbar-button",s.proxy(this,"onButtonClick")),this.container.find(".moj-rich-text-editor__content").on("input",s.proxy(this,"onEditorInput")),this.container.find("label").on("click",s.proxy(this,"onLabelClick")),this.toolbar.on("keydown",s.proxy(this,"onToolbarKeydown")))},u.RichTextEditor.prototype.onToolbarKeydown=function(e){switch(e.keyCode){case this.keys.right:case this.keys.down:var t,n=(t=this.toolbar.find("button[tabindex=0]")).next("button");n[0]&&(n.focus(),t.attr("tabindex","-1"),n.attr("tabindex","0"));break;case this.keys.left:case this.keys.up:n=(t=this.toolbar.find("button[tabindex=0]")).prev("button");n[0]&&(n.focus(),t.attr("tabindex","-1"),n.attr("tabindex","0"))}},u.RichTextEditor.prototype.getToolbarHtml=function(){var e="";return e+='"},u.RichTextEditor.prototype.getEnhancedHtml=function(e){return this.getToolbarHtml()+'
'},u.RichTextEditor.prototype.hideDefault=function(){this.textarea=this.container.find("textarea"),this.textarea.addClass("govuk-visually-hidden"),this.textarea.attr("aria-hidden",!0),this.textarea.attr("tabindex","-1")},u.RichTextEditor.prototype.createToolbar=function(){this.toolbar=document.createElement("div"),this.toolbar.className="moj-rich-text-editor",this.toolbar.innerHTML=this.getEnhancedHtml(),this.container.append(this.toolbar),this.toolbar=this.container.find(".moj-rich-text-editor__toolbar"),this.container.find(".moj-rich-text-editor__content").html(this.textarea.val())},u.RichTextEditor.prototype.configureToolbar=function(){this.buttons=this.container.find(".moj-rich-text-editor__toolbar-button"),this.buttons.prop("tabindex","-1"),this.buttons.first().prop("tabindex","0")},u.RichTextEditor.prototype.onButtonClick=function(e){document.execCommand(s(e.currentTarget).data("command"),!1,null)},u.RichTextEditor.prototype.getContent=function(){return this.container.find(".moj-rich-text-editor__content").html()},u.RichTextEditor.prototype.onEditorInput=function(e){this.updateTextarea()},u.RichTextEditor.prototype.updateTextarea=function(){document.execCommand("defaultParagraphSeparator",!1,"p"),this.textarea.val(this.getContent())},u.RichTextEditor.prototype.onLabelClick=function(e){e.preventDefault(),this.container.find(".moj-rich-text-editor__content").focus()}),u.SearchToggle=function(e){this.options=e,this.options.search.container.data("moj-search-toggle-initialised")||(this.options.search.container.data("moj-search-toggle-initialised",!0),this.toggleButton=s(''),this.toggleButton.on("click",s.proxy(this,"onToggleButtonClick")),this.options.toggleButton.container.append(this.toggleButton))},u.SearchToggle.prototype.onToggleButtonClick=function(){"false"==this.toggleButton.attr("aria-expanded")?(this.toggleButton.attr("aria-expanded","true"),this.options.search.container.removeClass("moj-js-hidden"),this.options.search.container.find("input").first().focus()):(this.options.search.container.addClass("moj-js-hidden"),this.toggleButton.attr("aria-expanded","false"))},u.SortableTable=function(e){this.table=s(e.table),this.table.data("moj-search-toggle-initialised")||(this.table.data("moj-search-toggle-initialised",!0),this.setupOptions(e),this.body=this.table.find("tbody"),this.createHeadingButtons(),this.createStatusBox(),this.initialiseSortedColumn(),this.table.on("click","th button",s.proxy(this,"onSortButtonClick")))},u.SortableTable.prototype.setupOptions=function(e){this.statusMessage=(e=e||{}).statusMessage||"Sort by %heading% (%direction%)",this.ascendingText=e.ascendingText||"ascending",this.descendingText=e.descendingText||"descending"},u.SortableTable.prototype.createHeadingButtons=function(){for(var e,t=this.table.find("thead th"),n=0;n'+n+"");e.text(""),e.append(t)},u.SortableTable.prototype.createStatusBox=function(){this.status=s('
'),this.table.parent().append(this.status)},u.SortableTable.prototype.initialiseSortedColumn=function(){var o=this.getTableRowsArray();this.table.find("th").filter('[aria-sort="ascending"], [aria-sort="descending"]').first().each((e,t)=>{var n=s(t).attr("aria-sort"),t=s(t).find("button").attr("data-index"),t=this.sort(o,t,n);this.addRows(t)})},u.SortableTable.prototype.onSortButtonClick=function(e){var t=e.currentTarget.getAttribute("data-index"),n=s(e.currentTarget).parent().attr("aria-sort"),n="none"===n||"descending"===n?"ascending":"descending",o=this.getTableRowsArray(),o=this.sort(o,t,n);this.addRows(o),this.removeButtonStates(),this.updateButtonState(s(e.currentTarget),n)},u.SortableTable.prototype.updateButtonState=function(e,t){e.parent().attr("aria-sort",t);var n=this.statusMessage;n=(n=n.replace(/%heading%/,e.text())).replace(/%direction%/,this[t+"Text"]),this.status.text(n)},u.SortableTable.prototype.removeButtonStates=function(){this.table.find("thead th").attr("aria-sort","none")},u.SortableTable.prototype.addRows=function(e){for(var t=0;tRemove'); +}; + +MOJFrontend.AddAnother.prototype.resetItem = function(item) { + item.find('[data-name], [data-id]').each(function(index, el) { + if(el.type == 'checkbox' || el.type == 'radio') { + el.checked = false; + } else { + el.value = ''; + } + }); +}; + +MOJFrontend.AddAnother.prototype.onRemoveButtonClick = function(e) { + $(e.currentTarget).parents('.moj-add-another__item').remove(); + var items = this.getItems(); + if(items.length === 1) { + items.find('.moj-add-another__remove-button').remove(); + } + items.each($.proxy(function(index, el) { + this.updateAttributes(index, $(el)); + }, this)); + this.focusHeading(); +}; + +MOJFrontend.AddAnother.prototype.focusHeading = function() { + this.container.find('.moj-add-another__heading').focus(); +}; + +MOJFrontend.ButtonMenu = function(params) { + this.container = params.container; + this.menu = this.container.find('.moj-button-menu__wrapper'); + if(params.menuClasses) { + this.menu.addClass(params.menuClasses); + } + this.menu.attr('role', 'menu'); + this.mq = params.mq; + this.buttonText = params.buttonText; + this.buttonClasses = params.buttonClasses || ''; + this.keys = { esc: 27, up: 38, down: 40, tab: 9 }; + this.menu.on('keydown', '[role=menuitem]', $.proxy(this, 'onButtonKeydown')); + this.createToggleButton(); + this.setupResponsiveChecks(); + $(document).on('click', $.proxy(this, 'onDocumentClick')); +}; + +MOJFrontend.ButtonMenu.prototype.onDocumentClick = function(e) { + if(!$.contains(this.container[0], e.target)) { + this.hideMenu(); + } +}; + +MOJFrontend.ButtonMenu.prototype.createToggleButton = function() { + this.menuButton = $(''); + this.menuButton.on('click', $.proxy(this, 'onMenuButtonClick')); + this.menuButton.on('keydown', $.proxy(this, 'onMenuKeyDown')); +}; + +MOJFrontend.ButtonMenu.prototype.setupResponsiveChecks = function() { + this.mql = window.matchMedia(this.mq); + this.mql.addListener($.proxy(this, 'checkMode')); + this.checkMode(this.mql); +}; + +MOJFrontend.ButtonMenu.prototype.checkMode = function(mql) { + if(mql.matches) { + this.enableBigMode(); + } else { + this.enableSmallMode(); + } +}; + +MOJFrontend.ButtonMenu.prototype.enableSmallMode = function() { + this.container.prepend(this.menuButton); + this.hideMenu(); + this.removeButtonClasses(); + this.menu.attr('role', 'menu'); + this.container.find('.moj-button-menu__item').attr('role', 'menuitem'); +}; + +MOJFrontend.ButtonMenu.prototype.enableBigMode = function() { + this.menuButton.detach(); + this.showMenu(); + this.addButtonClasses(); + this.menu.removeAttr('role'); + this.container.find('.moj-button-menu__item').removeAttr('role'); +}; + +MOJFrontend.ButtonMenu.prototype.removeButtonClasses = function() { + this.menu.find('.moj-button-menu__item').each(function(index, el) { + if($(el).hasClass('govuk-button--secondary')) { + $(el).attr('data-secondary', 'true'); + $(el).removeClass('govuk-button--secondary'); + } + if($(el).hasClass('govuk-button--warning')) { + $(el).attr('data-warning', 'true'); + $(el).removeClass('govuk-button--warning'); + } + $(el).removeClass('govuk-button'); + }); +}; + +MOJFrontend.ButtonMenu.prototype.addButtonClasses = function() { + this.menu.find('.moj-button-menu__item').each(function(index, el) { + if($(el).attr('data-secondary') == 'true') { + $(el).addClass('govuk-button--secondary'); + } + if($(el).attr('data-warning') == 'true') { + $(el).addClass('govuk-button--warning'); + } + $(el).addClass('govuk-button'); + }); +}; + +MOJFrontend.ButtonMenu.prototype.hideMenu = function() { + this.menuButton.attr('aria-expanded', 'false'); +}; + +MOJFrontend.ButtonMenu.prototype.showMenu = function() { + this.menuButton.attr('aria-expanded', 'true'); +}; + +MOJFrontend.ButtonMenu.prototype.onMenuButtonClick = function() { + this.toggle(); +}; + +MOJFrontend.ButtonMenu.prototype.toggle = function() { + if(this.menuButton.attr('aria-expanded') == 'false') { + this.showMenu(); + this.menu.find('[role=menuitem]').first().focus(); + } else { + this.hideMenu(); + this.menuButton.focus(); + } +}; + +MOJFrontend.ButtonMenu.prototype.onMenuKeyDown = function(e) { + switch (e.keyCode) { + case this.keys.down: + this.toggle(); + break; + } +}; + +MOJFrontend.ButtonMenu.prototype.onButtonKeydown = function(e) { + switch (e.keyCode) { + case this.keys.up: + e.preventDefault(); + this.focusPrevious(e.currentTarget); + break; + case this.keys.down: + e.preventDefault(); + this.focusNext(e.currentTarget); + break; + case this.keys.esc: + if(!this.mql.matches) { + this.menuButton.focus(); + this.hideMenu(); + } + break; + case this.keys.tab: + if(!this.mql.matches) { + this.hideMenu(); + } + } +}; + +MOJFrontend.ButtonMenu.prototype.focusNext = function(currentButton) { + var next = $(currentButton).next(); + if(next[0]) { + next.focus(); + } else { + this.container.find('[role=menuitem]').first().focus(); + } +}; + +MOJFrontend.ButtonMenu.prototype.focusPrevious = function(currentButton) { + var prev = $(currentButton).prev(); + if(prev[0]) { + prev.focus(); + } else { + this.container.find('[role=menuitem]').last().focus(); + } +}; + +MOJFrontend.FilterToggleButton = function(options) { + this.options = options; + this.container = this.options.toggleButton.container; + this.createToggleButton(); + this.setupResponsiveChecks(); + this.options.filter.container.attr('tabindex', '-1'); + if(this.options.startHidden) { + this.hideMenu(); + } +}; + +MOJFrontend.FilterToggleButton.prototype.setupResponsiveChecks = function() { + this.mq = window.matchMedia(this.options.bigModeMediaQuery); + this.mq.addListener($.proxy(this, 'checkMode')); + this.checkMode(this.mq); +}; + +MOJFrontend.FilterToggleButton.prototype.createToggleButton = function() { + this.menuButton = $(''); + this.menuButton.on('click', $.proxy(this, 'onMenuButtonClick')); + this.options.toggleButton.container.append(this.menuButton); +}; + +MOJFrontend.FilterToggleButton.prototype.checkMode = function(mq) { + if(mq.matches) { + this.enableBigMode(); + } else { + this.enableSmallMode(); + } +}; + +MOJFrontend.FilterToggleButton.prototype.enableBigMode = function() { + this.showMenu(); + this.removeCloseButton(); +}; + +MOJFrontend.FilterToggleButton.prototype.enableSmallMode = function() { + this.hideMenu(); + this.addCloseButton(); +}; + +MOJFrontend.FilterToggleButton.prototype.addCloseButton = function() { + if(this.options.closeButton) { + this.closeButton = $(''); + this.closeButton.on('click', $.proxy(this, 'onCloseClick')); + this.options.closeButton.container.append(this.closeButton); + } +}; + +MOJFrontend.FilterToggleButton.prototype.onCloseClick = function() { + this.hideMenu(); + this.menuButton.focus(); +}; + +MOJFrontend.FilterToggleButton.prototype.removeCloseButton = function() { + if(this.closeButton) { + this.closeButton.remove(); + this.closeButton = null; + } +}; + +MOJFrontend.FilterToggleButton.prototype.hideMenu = function() { + this.menuButton.attr('aria-expanded', 'false'); + this.options.filter.container.addClass('moj-js-hidden'); + this.menuButton.text(this.options.toggleButton.showText); +}; + +MOJFrontend.FilterToggleButton.prototype.showMenu = function() { + this.menuButton.attr('aria-expanded', 'true'); + this.options.filter.container.removeClass('moj-js-hidden'); + this.menuButton.text(this.options.toggleButton.hideText); +}; + +MOJFrontend.FilterToggleButton.prototype.onMenuButtonClick = function() { + this.toggle(); +}; + +MOJFrontend.FilterToggleButton.prototype.toggle = function() { + if(this.menuButton.attr('aria-expanded') == 'false') { + this.showMenu(); + this.options.filter.container.focus(); + } else { + this.hideMenu(); + } +}; +MOJFrontend.FormValidator = function(form, options) { + this.form = form; + this.errors = []; + this.validators = []; + $(this.form).on('submit', $.proxy(this, 'onSubmit')); + this.summary = (options && options.summary) ? $(options.summary) : $('.govuk-error-summary'); + this.originalTitle = document.title; +}; + +MOJFrontend.FormValidator.entityMap = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''', + '/': '/', + '`': '`', + '=': '=' +}; + +MOJFrontend.FormValidator.prototype.escapeHtml = function(string) { + return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap (s) { + return MOJFrontend.FormValidator.entityMap[s]; + }); +}; + +MOJFrontend.FormValidator.prototype.resetTitle = function() { + document.title = this.originalTitle; +}; + +MOJFrontend.FormValidator.prototype.updateTitle = function() { + document.title = "" + this.errors.length + " errors - " + document.title; +}; + +MOJFrontend.FormValidator.prototype.showSummary = function () { + this.summary.html(this.getSummaryHtml()); + this.summary.removeClass('moj-hidden'); + this.summary.attr('aria-labelledby', 'errorSummary-heading'); + this.summary.focus(); +}; + +MOJFrontend.FormValidator.prototype.getSummaryHtml = function() { + var html = '

There is a problem

'; + html += '
'; + html += ''; + html += '
'; + return html; +}; + +MOJFrontend.FormValidator.prototype.hideSummary = function() { + this.summary.addClass('moj-hidden'); + this.summary.removeAttr('aria-labelledby'); +}; + +MOJFrontend.FormValidator.prototype.onSubmit = function (e) { + this.removeInlineErrors(); + this.hideSummary(); + this.resetTitle(); + if(!this.validate()) { + e.preventDefault(); + this.updateTitle(); + this.showSummary(); + this.showInlineErrors(); + } +}; + +MOJFrontend.FormValidator.prototype.showInlineErrors = function() { + for (var i = 0, j = this.errors.length; i < j; i++) { + this.showInlineError(this.errors[i]); + } +}; + +MOJFrontend.FormValidator.prototype.showInlineError = function (error) { + var errorSpanId = error.fieldName + '-error'; + var errorSpan = ''+this.escapeHtml(error.message)+''; + var control = $("#" + error.fieldName); + var fieldContainer = control.parents(".govuk-form-group"); + var label = fieldContainer.find('label'); + var legend = fieldContainer.find("legend"); + var fieldset = fieldContainer.find("fieldset"); + fieldContainer.addClass('govuk-form-group--error'); + if(legend.length) { + legend.after(errorSpan); + fieldContainer.attr('aria-invalid', 'true'); + MOJFrontend.addAttributeValue(fieldset[0], 'aria-describedby', errorSpanId); + } else { + label.after(errorSpan); + control.attr('aria-invalid', 'true'); + MOJFrontend.addAttributeValue(control[0], 'aria-describedby', errorSpanId); + } +}; + +MOJFrontend.FormValidator.prototype.removeInlineErrors = function() { + var error; + var i; + for (var i = 0; i < this.errors.length; i++) { + this.removeInlineError(this.errors[i]); + } +}; + +MOJFrontend.FormValidator.prototype.removeInlineError = function(error) { + var control = $("#" + error.fieldName); + var fieldContainer = control.parents(".govuk-form-group"); + fieldContainer.find('.govuk-error-message').remove(); + fieldContainer.removeClass('govuk-form-group--error'); + fieldContainer.find("[aria-invalid]").attr('aria-invalid', 'false'); + var errorSpanId = error.fieldName + '-error'; + MOJFrontend.removeAttributeValue(fieldContainer.find('[aria-describedby]')[0], 'aria-describedby', errorSpanId); +}; + +MOJFrontend.FormValidator.prototype.addValidator = function(fieldName, rules) { + this.validators.push({ + fieldName: fieldName, + rules: rules, + field: this.form.elements[fieldName] + }); +}; + +MOJFrontend.FormValidator.prototype.validate = function() { + this.errors = []; + var validator = null, + validatorReturnValue = true, + i, + j; + for (i = 0; i < this.validators.length; i++) { + validator = this.validators[i]; + for (j = 0; j < validator.rules.length; j++) { + validatorReturnValue = validator.rules[j].method(validator.field, + validator.rules[j].params); + + if (typeof validatorReturnValue === 'boolean' && !validatorReturnValue) { + this.errors.push({ + fieldName: validator.fieldName, + message: validator.rules[j].message + }); + break; + } else if(typeof validatorReturnValue === 'string') { + this.errors.push({ + fieldName: validatorReturnValue, + message: validator.rules[j].message + }); + break; + } + } + } + return this.errors.length === 0; +}; +if(MOJFrontend.dragAndDropSupported() && MOJFrontend.formDataSupported() && MOJFrontend.fileApiSupported()) { + MOJFrontend.MultiFileUpload = function(params) { + this.defaultParams = { + uploadFileEntryHook: $.noop, + uploadFileExitHook: $.noop, + uploadFileErrorHook: $.noop, + fileDeleteHook: $.noop, + uploadStatusText: 'Uploading files, please wait', + dropzoneHintText: 'Drag and drop files here or', + dropzoneButtonText: 'Choose files' + }; + + this.params = $.extend({}, this.defaultParams, params); + + this.params.container.addClass('moj-multi-file-upload--enhanced'); + + this.feedbackContainer = this.params.container.find('.moj-multi-file__uploaded-files'); + this.setupFileInput(); + this.setupDropzone(); + this.setupLabel(); + this.setupStatusBox(); + this.params.container.on('click', '.moj-multi-file-upload__delete', $.proxy(this, 'onFileDeleteClick')); + }; + + MOJFrontend.MultiFileUpload.prototype.setupDropzone = function() { + this.fileInput.wrap('
'); + this.dropzone = this.params.container.find('.moj-multi-file-upload__dropzone'); + this.dropzone.on('dragover', $.proxy(this, 'onDragOver')); + this.dropzone.on('dragleave', $.proxy(this, 'onDragLeave')); + this.dropzone.on('drop', $.proxy(this, 'onDrop')); + }; + + MOJFrontend.MultiFileUpload.prototype.setupLabel = function() { + this.label = $(''); + this.dropzone.append('

' + this.params.dropzoneHintText + '

'); + this.dropzone.append(this.label); + }; + + MOJFrontend.MultiFileUpload.prototype.setupFileInput = function() { + this.fileInput = this.params.container.find('.moj-multi-file-upload__input'); + this.fileInput.on('change', $.proxy(this, 'onFileChange')); + this.fileInput.on('focus', $.proxy(this, 'onFileFocus')); + this.fileInput.on('blur', $.proxy(this, 'onFileBlur')); + }; + + MOJFrontend.MultiFileUpload.prototype.setupStatusBox = function() { + this.status = $('
'); + this.dropzone.append(this.status); + }; + + MOJFrontend.MultiFileUpload.prototype.onDragOver = function(e) { + e.preventDefault(); + this.dropzone.addClass('moj-multi-file-upload--dragover'); + }; + + MOJFrontend.MultiFileUpload.prototype.onDragLeave = function() { + this.dropzone.removeClass('moj-multi-file-upload--dragover'); + }; + + MOJFrontend.MultiFileUpload.prototype.onDrop = function(e) { + e.preventDefault(); + this.dropzone.removeClass('moj-multi-file-upload--dragover'); + this.feedbackContainer.removeClass('moj-hidden'); + this.status.html(this.params.uploadStatusText); + this.uploadFiles(e.originalEvent.dataTransfer.files); + }; + + MOJFrontend.MultiFileUpload.prototype.uploadFiles = function(files) { + for(var i = 0; i < files.length; i++) { + this.uploadFile(files[i]); + } + }; + + MOJFrontend.MultiFileUpload.prototype.onFileChange = function(e) { + this.feedbackContainer.removeClass('moj-hidden'); + this.status.html(this.params.uploadStatusText); + this.uploadFiles(e.currentTarget.files); + this.fileInput.replaceWith($(e.currentTarget).val('').clone(true)); + this.setupFileInput(); + this.fileInput.focus(); + }; + + MOJFrontend.MultiFileUpload.prototype.onFileFocus = function(e) { + this.label.addClass('moj-multi-file-upload--focused'); + }; + + MOJFrontend.MultiFileUpload.prototype.onFileBlur = function(e) { + this.label.removeClass('moj-multi-file-upload--focused'); + }; + + MOJFrontend.MultiFileUpload.prototype.getSuccessHtml = function(success) { + return ' ' + success.messageHtml + ''; + }; + + MOJFrontend.MultiFileUpload.prototype.getErrorHtml = function(error) { + return ' '+ error.message +''; + }; + + MOJFrontend.MultiFileUpload.prototype.getFileRowHtml = function(file) { + var html = ''; + html += '
'; + html += '
'; + html += ''+file.name+''; + html += '0%'; + html += '
'; + html += '
'; + html += '
'; + return html; + }; + + MOJFrontend.MultiFileUpload.prototype.getDeleteButtonHtml = function(file) { + var html = ''; + return html; + }; + + MOJFrontend.MultiFileUpload.prototype.uploadFile = function(file) { + this.params.uploadFileEntryHook(this, file); + var formData = new FormData(); + formData.append('documents', file); + var item = $(this.getFileRowHtml(file)); + this.feedbackContainer.find('.moj-multi-file-upload__list').append(item); + + $.ajax({ + url: this.params.uploadUrl, + type: 'post', + data: formData, + processData: false, + contentType: false, + success: $.proxy(function(response){ + if(response.error) { + item.find('.moj-multi-file-upload__message').html(this.getErrorHtml(response.error)); + this.status.html(response.error.message); + } else { + item.find('.moj-multi-file-upload__message').html(this.getSuccessHtml(response.success)); + this.status.html(response.success.messageText); + } + item.find('.moj-multi-file-upload__actions').append(this.getDeleteButtonHtml(response.file)); + this.params.uploadFileExitHook(this, file, response); + }, this), + error: $.proxy(function(jqXHR, textStatus, errorThrown) { + this.params.uploadFileErrorHook(this, file, jqXHR, textStatus, errorThrown); + }, this), + xhr: function() { + var xhr = new XMLHttpRequest(); + xhr.upload.addEventListener('progress', function(e) { + if (e.lengthComputable) { + var percentComplete = e.loaded / e.total; + percentComplete = parseInt(percentComplete * 100, 10); + item.find('.moj-multi-file-upload__progress').text(' ' + percentComplete + '%'); + } + }, false); + return xhr; + } + }); + }; + + MOJFrontend.MultiFileUpload.prototype.onFileDeleteClick = function(e) { + e.preventDefault(); // if user refreshes page and then deletes + var button = $(e.currentTarget); + var data = {}; + data[button[0].name] = button[0].value; + $.ajax({ + url: this.params.deleteUrl, + type: 'post', + dataType: 'json', + data: data, + success: $.proxy(function(response){ + if(response.error) { + // handle error + } else { + button.parents('.moj-multi-file-upload__row').remove(); + if(this.feedbackContainer.find('.moj-multi-file-upload__row').length === 0) { + this.feedbackContainer.addClass('moj-hidden'); + } + } + this.params.fileDeleteHook(this, response); + }, this) + }); + }; +} + +MOJFrontend.MultiSelect = function(options) { + this.container = $(options.container); + + if (this.container.data('moj-multi-select-initialised')) { + return + } + + this.container.data('moj-multi-select-initialised', true); + + this.toggle = $(this.getToggleHtml()); + this.toggleButton = this.toggle.find('input'); + this.toggleButton.on('click', $.proxy(this, 'onButtonClick')); + this.container.append(this.toggle); + this.checkboxes = $(options.checkboxes); + this.checkboxes.on('click', $.proxy(this, 'onCheckboxClick')); + this.checked = options.checked || false; +}; + +MOJFrontend.MultiSelect.prototype.getToggleHtml = function() { + var html = ''; + html += '
'; + html += ' '; + html += ' '; + html += '
'; + return html; +}; + +MOJFrontend.MultiSelect.prototype.onButtonClick = function(e) { + if(this.checked) { + this.uncheckAll(); + this.toggleButton[0].checked = false; + } else { + this.checkAll(); + this.toggleButton[0].checked = true; + } +}; + +MOJFrontend.MultiSelect.prototype.checkAll = function() { + this.checkboxes.each($.proxy(function(index, el) { + el.checked = true; + }, this)); + this.checked = true; +}; + +MOJFrontend.MultiSelect.prototype.uncheckAll = function() { + this.checkboxes.each($.proxy(function(index, el) { + el.checked = false; + }, this)); + this.checked = false; +}; + +MOJFrontend.MultiSelect.prototype.onCheckboxClick = function(e) { + if(!e.target.checked) { + this.toggleButton[0].checked = false; + this.checked = false; + } else { + if(this.checkboxes.filter(':checked').length === this.checkboxes.length) { + this.toggleButton[0].checked = true; + this.checked = true; + } + } +}; + +MOJFrontend.PasswordReveal = function(element) { + this.el = element; + var $el = $(this.el) + + if ($el.data('moj-password-reveal-initialised')) { + return + } + + $el.data('moj-password-reveal-initialised', true); + $el.attr('spellcheck', 'false'); + + $el.wrap('
'); + this.container = $(this.el).parent(); + this.createButton(); +}; + +MOJFrontend.PasswordReveal.prototype.createButton = function() { + this.button = $(''); + this.container.append(this.button); + this.button.on('click', $.proxy(this, 'onButtonClick')); +}; + +MOJFrontend.PasswordReveal.prototype.onButtonClick = function() { + if (this.el.type === 'password') { + this.el.type = 'text'; + this.button.html('Hide password'); + } else { + this.el.type = 'password'; + this.button.html('Show password'); + } +}; + +if('contentEditable' in document.documentElement) { + MOJFrontend.RichTextEditor = function(options) { + this.options = options; + this.options.toolbar = this.options.toolbar || { + bold: false, + italic: false, + underline: false, + bullets: true, + numbers: true + }; + this.textarea = this.options.textarea; + this.container = $(this.textarea).parent(); + + if (this.container.data('moj-rich-text-editor-initialised')) { + return + } + + this.container.data('moj-rich-text-editor-initialised', true); + + this.createToolbar(); + this.hideDefault(); + this.configureToolbar(); + this.keys = { + left: 37, + right: 39, + up: 38, + down: 40 + }; + this.container.on('click', '.moj-rich-text-editor__toolbar-button', $.proxy(this, 'onButtonClick')); + this.container.find('.moj-rich-text-editor__content').on('input', $.proxy(this, 'onEditorInput')); + this.container.find('label').on('click', $.proxy(this, 'onLabelClick')); + this.toolbar.on('keydown', $.proxy(this, 'onToolbarKeydown')); + }; + + MOJFrontend.RichTextEditor.prototype.onToolbarKeydown = function(e) { + var focusableButton; + switch(e.keyCode) { + case this.keys.right: + case this.keys.down: + focusableButton = this.toolbar.find('button[tabindex=0]'); + var nextButton = focusableButton.next('button'); + if(nextButton[0]) { + nextButton.focus(); + focusableButton.attr('tabindex', '-1'); + nextButton.attr('tabindex', '0'); + } + break; + case this.keys.left: + case this.keys.up: + focusableButton = this.toolbar.find('button[tabindex=0]'); + var previousButton = focusableButton.prev('button'); + if(previousButton[0]) { + previousButton.focus(); + focusableButton.attr('tabindex', '-1'); + previousButton.attr('tabindex', '0'); + } + break; + } + }; + + MOJFrontend.RichTextEditor.prototype.getToolbarHtml = function() { + var html = ''; + + html += ''; + return html; + }; + + MOJFrontend.RichTextEditor.prototype.getEnhancedHtml = function(val) { + return this.getToolbarHtml() + '
'; + }; + + MOJFrontend.RichTextEditor.prototype.hideDefault = function() { + this.textarea = this.container.find('textarea'); + this.textarea.addClass('govuk-visually-hidden'); + this.textarea.attr('aria-hidden', true); + this.textarea.attr('tabindex', '-1'); + }; + + MOJFrontend.RichTextEditor.prototype.createToolbar = function() { + this.toolbar = document.createElement('div'); + this.toolbar.className = 'moj-rich-text-editor'; + this.toolbar.innerHTML = this.getEnhancedHtml(); + this.container.append(this.toolbar); + this.toolbar = this.container.find('.moj-rich-text-editor__toolbar'); + this.container.find('.moj-rich-text-editor__content').html(this.textarea.val()); + }; + + MOJFrontend.RichTextEditor.prototype.configureToolbar = function() { + this.buttons = this.container.find('.moj-rich-text-editor__toolbar-button'); + this.buttons.prop('tabindex', '-1'); + var firstTab = this.buttons.first(); + firstTab.prop('tabindex', '0'); + }; + + MOJFrontend.RichTextEditor.prototype.onButtonClick = function(e) { + document.execCommand($(e.currentTarget).data('command'), false, null); + }; + + MOJFrontend.RichTextEditor.prototype.getContent = function() { + return this.container.find('.moj-rich-text-editor__content').html(); + }; + + MOJFrontend.RichTextEditor.prototype.onEditorInput = function(e) { + this.updateTextarea(); + }; + + MOJFrontend.RichTextEditor.prototype.updateTextarea = function() { + document.execCommand('defaultParagraphSeparator', false, 'p'); + this.textarea.val(this.getContent()); + }; + + MOJFrontend.RichTextEditor.prototype.onLabelClick = function(e) { + e.preventDefault(); + this.container.find('.moj-rich-text-editor__content').focus(); + }; + +} + +MOJFrontend.SearchToggle = function(options) { + this.options = options; + + if (this.options.search.container.data('moj-search-toggle-initialised')) { + return + } + + this.options.search.container.data('moj-search-toggle-initialised', true); + + const svg = ''; + + this.toggleButton = $(''); + this.toggleButton.on('click', $.proxy(this, 'onToggleButtonClick')); + this.options.toggleButton.container.append(this.toggleButton); +}; + +MOJFrontend.SearchToggle.prototype.onToggleButtonClick = function() { + if(this.toggleButton.attr('aria-expanded') == 'false') { + this.toggleButton.attr('aria-expanded', 'true'); + this.options.search.container.removeClass('moj-js-hidden'); + this.options.search.container.find('input').first().focus(); + } else { + this.options.search.container.addClass('moj-js-hidden'); + this.toggleButton.attr('aria-expanded', 'false'); + } +}; + +MOJFrontend.SortableTable = function(params) { + this.table = $(params.table); + + if (this.table.data('moj-search-toggle-initialised')) { + return + } + + this.table.data('moj-search-toggle-initialised', true); + + this.setupOptions(params); + this.body = this.table.find('tbody'); + this.createHeadingButtons(); + this.createStatusBox(); + this.initialiseSortedColumn(); + this.table.on('click', 'th button', $.proxy(this, 'onSortButtonClick')); +}; + +MOJFrontend.SortableTable.prototype.setupOptions = function(params) { + params = params || {}; + this.statusMessage = params.statusMessage || 'Sort by %heading% (%direction%)'; + this.ascendingText = params.ascendingText || 'ascending'; + this.descendingText = params.descendingText || 'descending'; +}; + +MOJFrontend.SortableTable.prototype.createHeadingButtons = function() { + var headings = this.table.find('thead th'); + var heading; + for(var i = 0; i < headings.length; i++) { + heading = $(headings[i]); + if(heading.attr('aria-sort')) { + this.createHeadingButton(heading, i); + } + } +}; + +MOJFrontend.SortableTable.prototype.createHeadingButton = function(heading, i) { + var text = heading.text(); + var button = $(''); + heading.text(''); + heading.append(button); +}; + +MOJFrontend.SortableTable.prototype.createStatusBox = function() { + this.status = $('
'); + this.table.parent().append(this.status); +}; + +MOJFrontend.SortableTable.prototype.initialiseSortedColumn = function () { + var rows = this.getTableRowsArray(); + + this.table.find("th") + .filter('[aria-sort="ascending"], [aria-sort="descending"]') + .first() + .each((index, el) => { + var sortDirection = $(el).attr('aria-sort'); + var columnNumber = $(el).find('button').attr('data-index'); + var sortedRows = this.sort(rows, columnNumber, sortDirection); + this.addRows(sortedRows); + }) +}; + +MOJFrontend.SortableTable.prototype.onSortButtonClick = function(e) { + var columnNumber = e.currentTarget.getAttribute('data-index'); + var sortDirection = $(e.currentTarget).parent().attr('aria-sort'); + var newSortDirection; + if(sortDirection === 'none' || sortDirection === 'descending') { + newSortDirection = 'ascending'; + } else { + newSortDirection = 'descending'; + } + var rows = this.getTableRowsArray(); + var sortedRows = this.sort(rows, columnNumber, newSortDirection); + this.addRows(sortedRows); + this.removeButtonStates(); + this.updateButtonState($(e.currentTarget), newSortDirection); +}; + +MOJFrontend.SortableTable.prototype.updateButtonState = function(button, direction) { + button.parent().attr('aria-sort', direction); + var message = this.statusMessage; + message = message.replace(/%heading%/, button.text()); + message = message.replace(/%direction%/, this[direction+'Text']); + this.status.text(message); +}; + +MOJFrontend.SortableTable.prototype.removeButtonStates = function() { + this.table.find('thead th').attr('aria-sort', 'none'); +}; + +MOJFrontend.SortableTable.prototype.addRows = function(rows) { + for(var i = 0; i < rows.length; i++) { + this.body.append(rows[i]); + } +}; + +MOJFrontend.SortableTable.prototype.getTableRowsArray = function() { + var rows = []; + var trs = this.body.find('tr'); + for (var i = 0; i < trs.length; i++) { + rows.push(trs[i]); + } + return rows; +}; + +MOJFrontend.SortableTable.prototype.sort = function(rows, columnNumber, sortDirection) { + var newRows = rows.sort($.proxy(function(rowA, rowB) { + var tdA = $(rowA).find('td,th').eq(columnNumber); + var tdB = $(rowB).find('td,th').eq(columnNumber); + var valueA = this.getCellValue(tdA); + var valueB = this.getCellValue(tdB); + if(sortDirection === 'ascending') { + if(valueA < valueB) { + return -1; + } + if(valueA > valueB) { + return 1; + } + return 0; + } else { + if(valueB < valueA) { + return -1; + } + if(valueB > valueA) { + return 1; + } + return 0; + } + }, this)); + return newRows; +}; + +MOJFrontend.SortableTable.prototype.getCellValue = function(cell) { + var val = cell.attr('data-sort-value'); + val = val || cell.html(); + if($.isNumeric(val)) { + val = parseInt(val, 10); + } + return val; +}; + +return MOJFrontend; +})); diff --git a/node_modules/@ministryofjustice/frontend/moj/all.scss b/node_modules/@ministryofjustice/frontend/moj/all.scss new file mode 100644 index 00000000..126c82c8 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/all.scss @@ -0,0 +1,7 @@ +@import "node_modules/govuk-frontend/dist/govuk/base"; + +@import "settings/all"; +@import "helpers/all"; +@import "objects/all"; +@import "components/all"; +@import "utilities/all"; diff --git a/node_modules/@ministryofjustice/frontend/moj/assets/images/govuk-logotype-crown.png b/node_modules/@ministryofjustice/frontend/moj/assets/images/govuk-logotype-crown.png new file mode 100644 index 00000000..90638b3f Binary files /dev/null and b/node_modules/@ministryofjustice/frontend/moj/assets/images/govuk-logotype-crown.png differ diff --git a/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-alert-information.svg b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-alert-information.svg new file mode 100644 index 00000000..79ef1cd1 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-alert-information.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-alert-success.svg b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-alert-success.svg new file mode 100644 index 00000000..5469d843 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-alert-success.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-alert-warning.svg b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-alert-warning.svg new file mode 100644 index 00000000..3d4ffd64 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-alert-warning.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-arrow-black-down.svg b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-arrow-black-down.svg new file mode 100644 index 00000000..62d45425 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-arrow-black-down.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-arrow-black-up.svg b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-arrow-black-up.svg new file mode 100644 index 00000000..62736736 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-arrow-black-up.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-arrow-white-down.svg b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-arrow-white-down.svg new file mode 100644 index 00000000..d22f4da5 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-arrow-white-down.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-arrow-white-up.svg b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-arrow-white-up.svg new file mode 100644 index 00000000..608232fd --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-arrow-white-up.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-close-cross-black.svg b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-close-cross-black.svg new file mode 100644 index 00000000..bab6572e --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-close-cross-black.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-document.png b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-document.png new file mode 100644 index 00000000..793f6ae1 Binary files /dev/null and b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-document.png differ diff --git a/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-document.svg b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-document.svg new file mode 100644 index 00000000..4d0eea9f --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-document.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-progress-tick.png b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-progress-tick.png new file mode 100644 index 00000000..5be23704 Binary files /dev/null and b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-progress-tick.png differ diff --git a/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-progress-tick.svg b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-progress-tick.svg new file mode 100644 index 00000000..06baf025 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-progress-tick.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-search-black.svg b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-search-black.svg new file mode 100644 index 00000000..d704d54f --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-search-black.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-search-blue.svg b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-search-blue.svg new file mode 100644 index 00000000..4d40d255 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-search-blue.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-search-white.svg b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-search-white.svg new file mode 100644 index 00000000..f34b39ce --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-search-white.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-tag-remove-cross-white.svg b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-tag-remove-cross-white.svg new file mode 100644 index 00000000..2df2570f --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-tag-remove-cross-white.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-tag-remove-cross.svg b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-tag-remove-cross.svg new file mode 100644 index 00000000..c46b61c5 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-tag-remove-cross.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-toggle-plus-minus.svg b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-toggle-plus-minus.svg new file mode 100644 index 00000000..6830c1a2 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-toggle-plus-minus.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-wysiwyg-bold.svg b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-wysiwyg-bold.svg new file mode 100644 index 00000000..a4928eac --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-wysiwyg-bold.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-wysiwyg-italic.svg b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-wysiwyg-italic.svg new file mode 100644 index 00000000..12a6fc75 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-wysiwyg-italic.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-wysiwyg-ordered-list.svg b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-wysiwyg-ordered-list.svg new file mode 100644 index 00000000..e750152e --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-wysiwyg-ordered-list.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-wysiwyg-underline.svg b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-wysiwyg-underline.svg new file mode 100644 index 00000000..815999d8 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-wysiwyg-underline.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-wysiwyg-unordered-list.svg b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-wysiwyg-unordered-list.svg new file mode 100644 index 00000000..d055d094 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/assets/images/icon-wysiwyg-unordered-list.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/assets/images/moj-apple-touch-icon-152x152.png b/node_modules/@ministryofjustice/frontend/moj/assets/images/moj-apple-touch-icon-152x152.png new file mode 100644 index 00000000..5e842cb6 Binary files /dev/null and b/node_modules/@ministryofjustice/frontend/moj/assets/images/moj-apple-touch-icon-152x152.png differ diff --git a/node_modules/@ministryofjustice/frontend/moj/assets/images/moj-apple-touch-icon-167x167.png b/node_modules/@ministryofjustice/frontend/moj/assets/images/moj-apple-touch-icon-167x167.png new file mode 100644 index 00000000..1b1ad7cd Binary files /dev/null and b/node_modules/@ministryofjustice/frontend/moj/assets/images/moj-apple-touch-icon-167x167.png differ diff --git a/node_modules/@ministryofjustice/frontend/moj/assets/images/moj-apple-touch-icon-180x180.png b/node_modules/@ministryofjustice/frontend/moj/assets/images/moj-apple-touch-icon-180x180.png new file mode 100644 index 00000000..cf0cf650 Binary files /dev/null and b/node_modules/@ministryofjustice/frontend/moj/assets/images/moj-apple-touch-icon-180x180.png differ diff --git a/node_modules/@ministryofjustice/frontend/moj/assets/images/moj-apple-touch-icon.png b/node_modules/@ministryofjustice/frontend/moj/assets/images/moj-apple-touch-icon.png new file mode 100644 index 00000000..136fe89d Binary files /dev/null and b/node_modules/@ministryofjustice/frontend/moj/assets/images/moj-apple-touch-icon.png differ diff --git a/node_modules/@ministryofjustice/frontend/moj/assets/images/moj-logotype-crest.png b/node_modules/@ministryofjustice/frontend/moj/assets/images/moj-logotype-crest.png new file mode 100644 index 00000000..ba2fed1c Binary files /dev/null and b/node_modules/@ministryofjustice/frontend/moj/assets/images/moj-logotype-crest.png differ diff --git a/node_modules/@ministryofjustice/frontend/moj/assets/images/moj-logotype-crest.svg b/node_modules/@ministryofjustice/frontend/moj/assets/images/moj-logotype-crest.svg new file mode 100644 index 00000000..49e525e5 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/assets/images/moj-logotype-crest.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/assets/images/moj-opengraph-image.png b/node_modules/@ministryofjustice/frontend/moj/assets/images/moj-opengraph-image.png new file mode 100644 index 00000000..ef9f5530 Binary files /dev/null and b/node_modules/@ministryofjustice/frontend/moj/assets/images/moj-opengraph-image.png differ diff --git a/node_modules/@ministryofjustice/frontend/moj/components/_all.scss b/node_modules/@ministryofjustice/frontend/moj/components/_all.scss new file mode 100644 index 00000000..ffa08e9f --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/_all.scss @@ -0,0 +1,30 @@ +@import "action-bar/action-bar"; +@import "add-another/add-another"; +@import "badge/badge"; +@import "banner/banner"; +@import "button-menu/button-menu"; +@import "cookie-banner/cookie-banner"; +@import "currency-input/currency-input"; +@import "filter/filter"; +@import "header/header"; +@import "identity-bar/identity-bar"; +@import "messages/messages"; +@import "multi-file-upload/multi-file-upload"; +@import "multi-select/multi-select"; +@import "notification-badge/notification-badge"; +@import "organisation-switcher/organisation-switcher"; +@import "page-header-actions/page-header-actions"; +@import "pagination/pagination"; +@import "password-reveal/password-reveal"; +@import "primary-navigation/primary-navigation"; +@import "progress-bar/progress-bar"; +@import "rich-text-editor/rich-text-editor"; +@import "search-toggle/search-toggle"; +@import "search/search"; +@import "side-navigation/side-navigation"; +@import "sortable-table/sortable-table"; +@import "sub-navigation/sub-navigation"; +@import "tag/tag"; +@import "task-list/task-list"; +@import "timeline/timeline"; +@import "ticket-panel/ticket-panel"; diff --git a/node_modules/@ministryofjustice/frontend/moj/components/action-bar/README.md b/node_modules/@ministryofjustice/frontend/moj/components/action-bar/README.md new file mode 100644 index 00000000..493a7f91 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/action-bar/README.md @@ -0,0 +1,5 @@ +# Action bar + +- [Guidance](https://design-patterns.service.justice.gov.uk/patterns/filter-a-list) + +## Arguments diff --git a/node_modules/@ministryofjustice/frontend/moj/components/action-bar/_action-bar.scss b/node_modules/@ministryofjustice/frontend/moj/components/action-bar/_action-bar.scss new file mode 100644 index 00000000..70c2442a --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/action-bar/_action-bar.scss @@ -0,0 +1,28 @@ +.moj-action-bar { + font-size: 0; // Removes white space +} + +.moj-action-bar__filter { + display: inline-block; + position: relative; + + @include govuk-media-query($until: desktop) { + float: right; + } + + @include govuk-media-query($from: desktop) { + margin-right: govuk-spacing(2); + padding-right: govuk-spacing(2) + 2px; // Takes into account divider width + + &:after { + content: ""; + background-color: govuk-colour("light-grey"); + height: 40px; + position: absolute; + right: 0; + top: 0; + width: 2px; + } + } + +} \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/components/add-another/README.md b/node_modules/@ministryofjustice/frontend/moj/components/add-another/README.md new file mode 100644 index 00000000..ade778ac --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/add-another/README.md @@ -0,0 +1,5 @@ +# Add another + +- [Guidance](https://design-patterns.service.justice.gov.uk/components/add-another) + +## Arguments diff --git a/node_modules/@ministryofjustice/frontend/moj/components/add-another/_add-another.scss b/node_modules/@ministryofjustice/frontend/moj/components/add-another/_add-another.scss new file mode 100644 index 00000000..90ccf878 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/add-another/_add-another.scss @@ -0,0 +1,44 @@ +/* ========================================================================== + #ADD ANOTHER + ========================================================================== */ + +.moj-add-another { + &__item { + margin: 0; + margin-top: govuk-spacing(6); + padding: 0; + position: relative; + + &:first-of-type { + margin-top: 0; + } + } + + &__title { + float: left; + padding: 4px 100px 4px 0; + width: 100%; + + & + .govuk-form-group { + clear: left; + } + } + + &__remove-button { + position: absolute; + right: 0; + top: 0; + width: auto; + } + + &__add-button { + display: block; + } +} + +.moj-add-another__heading:focus { + background-color: $govuk-focus-colour; + color: $govuk-focus-text-colour; + box-shadow: 0 -2px $govuk-focus-colour, 0 4px $govuk-focus-text-colour; + outline: none; +} diff --git a/node_modules/@ministryofjustice/frontend/moj/components/add-another/add-another.js b/node_modules/@ministryofjustice/frontend/moj/components/add-another/add-another.js new file mode 100644 index 00000000..16baeb41 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/add-another/add-another.js @@ -0,0 +1,83 @@ +MOJFrontend.AddAnother = function(container) { + this.container = $(container); + + if (this.container.data('moj-add-another-initialised')) { + return + } + + this.container.data('moj-add-another-initialised', true); + + this.container.on('click', '.moj-add-another__remove-button', $.proxy(this, 'onRemoveButtonClick')); + this.container.on('click', '.moj-add-another__add-button', $.proxy(this, 'onAddButtonClick')); + this.container.find('.moj-add-another__add-button, moj-add-another__remove-button').prop('type', 'button'); +}; + +MOJFrontend.AddAnother.prototype.onAddButtonClick = function(e) { + var item = this.getNewItem(); + this.updateAttributes(this.getItems().length, item); + this.resetItem(item); + var firstItem = this.getItems().first(); + if(!this.hasRemoveButton(firstItem)) { + this.createRemoveButton(firstItem); + } + this.getItems().last().after(item); + item.find('input, textarea, select').first().focus(); +}; + +MOJFrontend.AddAnother.prototype.hasRemoveButton = function(item) { + return item.find('.moj-add-another__remove-button').length; +}; + +MOJFrontend.AddAnother.prototype.getItems = function() { + return this.container.find('.moj-add-another__item'); +}; + +MOJFrontend.AddAnother.prototype.getNewItem = function() { + var item = this.getItems().first().clone(); + if(!this.hasRemoveButton(item)) { + this.createRemoveButton(item); + } + return item; +}; + +MOJFrontend.AddAnother.prototype.updateAttributes = function(index, item) { + item.find('[data-name]').each(function(i, el) { + var originalId = el.id + + el.name = $(el).attr('data-name').replace(/%index%/, index); + el.id = $(el).attr('data-id').replace(/%index%/, index); + + var label = $(el).siblings('label')[0] || $(el).parents('label')[0] || item.find('[for="' + originalId + '"]')[0]; + label.htmlFor = el.id; + }); +}; + +MOJFrontend.AddAnother.prototype.createRemoveButton = function(item) { + item.append(''); +}; + +MOJFrontend.AddAnother.prototype.resetItem = function(item) { + item.find('[data-name], [data-id]').each(function(index, el) { + if(el.type == 'checkbox' || el.type == 'radio') { + el.checked = false; + } else { + el.value = ''; + } + }); +}; + +MOJFrontend.AddAnother.prototype.onRemoveButtonClick = function(e) { + $(e.currentTarget).parents('.moj-add-another__item').remove(); + var items = this.getItems(); + if(items.length === 1) { + items.find('.moj-add-another__remove-button').remove(); + } + items.each($.proxy(function(index, el) { + this.updateAttributes(index, $(el)); + }, this)); + this.focusHeading(); +}; + +MOJFrontend.AddAnother.prototype.focusHeading = function() { + this.container.find('.moj-add-another__heading').focus(); +}; diff --git a/node_modules/@ministryofjustice/frontend/moj/components/badge/README.md b/node_modules/@ministryofjustice/frontend/moj/components/badge/README.md new file mode 100644 index 00000000..b0a32b2f --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/badge/README.md @@ -0,0 +1,49 @@ +# Badge + +- [Guidance](https://design-patterns.service.justice.gov.uk/components/badge) + +## Example + +``` +{{ mojBadge({ + text: "Status text", + classes: "moj-badge--blue" +}) }} +``` + +## Arguments + +This component accepts the following arguments. + +| Name | Type | Required | Description | +| ---------- | ------ | -------- | -------------------------------------------------------------------------------------------------------------------------------- | +| text | string | Yes | If `html` is set, this is not required. Text to use within the span. If `html` is provided, the `text` argument will be ignored. | +| html | string | Yes | If `text` is set, this is not required. HTML to use within the span. If `html` is provided, the `text` argument will be ignored. | +| classes | string | Yes | Classes to add to the `span` container. See available [classes](#classes). | +| label | string | No | The `aria-label` to add to the `span` container. | +| attributes | object | No | HTML attributes (for example data attributes) to add to the `span` container. | + +### Classes + +| Name | Colour code | Colour contrast | +| ------------------------ | ----------- | --------------- | +| moj-badge--purple | #2e358b | Pass | +| moj-badge--light-purple | #6f72af | Fail | +| moj-badge--bright-purple | #912b88 | Pass | +| moj-badge--pink | #d53880 | Fail | +| moj-badge--light-pink | #f499be | Fail | +| moj-badge--red | #b10e1e | Pass | +| moj-badge--orange | #f47738 | Fail | +| moj-badge--brown | #b58840 | Fail | +| moj-badge--yellow | #ffbf47 | Fail | +| moj-badge--light-green | #85994b | Fail | +| moj-badge--green | #006435 | Pass | +| moj-badge--turquoise | #28a197 | Fail | +| moj-badge--light-blue | #2b8cc4 | Fail | +| moj-badge--blue | #005ea5 | Pass | +| moj-badge--black | #0b0c0c | Pass | +| moj-badge--dark-grey | #6f777b | Pass | +| moj-badge--mid-grey | #bfc1c3 | Fail | +| moj-badge--light-grey | #dee0e2 | Fail | +| moj-badge--light-grey | #f8f8f8 | Fail | +| moj-badge--white | #ffffff | Fail | diff --git a/node_modules/@ministryofjustice/frontend/moj/components/badge/_badge.scss b/node_modules/@ministryofjustice/frontend/moj/components/badge/_badge.scss new file mode 100644 index 00000000..1f7e2838 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/badge/_badge.scss @@ -0,0 +1,55 @@ +/* ========================================================================== + #BADGE + ========================================================================== */ + +.moj-badge { + @include govuk-font($size: 14, $weight: "bold"); + padding: 0 govuk-spacing(1); + display: inline-block; + border: 2px solid $govuk-brand-colour; + color: $govuk-brand-colour; + text-transform: uppercase; + vertical-align: middle; + outline: 2px solid transparent; + outline-offset: -2px; + + &--purple { + border-color: govuk-colour("purple"); + color: govuk-colour("purple"); + } + + &--bright-purple { + border-color: govuk-colour("bright-purple"); + color: govuk-colour("bright-purple"); + } + + &--red { + border-color: govuk-colour("red"); + color: govuk-colour("red"); + } + + &--green { + border-color: govuk-colour("green"); + color: govuk-colour("green"); + } + + &--blue { + border-color: govuk-colour("blue"); + color: govuk-colour("blue"); + } + + &--black { + border-color: govuk-colour("black"); + color: govuk-colour("black"); + } + + &--grey { + border-color: govuk-colour("dark-grey"); + color: govuk-colour("dark-grey"); + } + + &--large { + @include govuk-font($size: 16, $weight: "bold"); + } + +} diff --git a/node_modules/@ministryofjustice/frontend/moj/components/badge/macro.njk b/node_modules/@ministryofjustice/frontend/moj/components/badge/macro.njk new file mode 100644 index 00000000..9421faf5 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/badge/macro.njk @@ -0,0 +1,3 @@ +{% macro mojBadge(params) %} + {%- include "./template.njk" -%} +{% endmacro %} \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/components/badge/template.njk b/node_modules/@ministryofjustice/frontend/moj/components/badge/template.njk new file mode 100644 index 00000000..454ed344 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/badge/template.njk @@ -0,0 +1,3 @@ + + {{- params.html | safe if params.html else params.text -}} + diff --git a/node_modules/@ministryofjustice/frontend/moj/components/banner/README.md b/node_modules/@ministryofjustice/frontend/moj/components/banner/README.md new file mode 100644 index 00000000..e69de29b diff --git a/node_modules/@ministryofjustice/frontend/moj/components/banner/_banner.scss b/node_modules/@ministryofjustice/frontend/moj/components/banner/_banner.scss new file mode 100644 index 00000000..fed2f574 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/banner/_banner.scss @@ -0,0 +1,55 @@ +/* ========================================================================== + #BANNER + ========================================================================== */ + +.moj-banner { + border: 5px solid $govuk-brand-colour; + color: $govuk-brand-colour; + font-size: 0; // Removes white space when using inline-block on child element. + margin-bottom: govuk-spacing(6); + padding: govuk-spacing(2); +} + + +.moj-banner__icon { + fill: currentColor; + float: left; + margin-right: govuk-spacing(2); +} + +.moj-banner__message { + @include govuk-font($size: 19); + color: govuk-colour("black"); + display: block; + overflow: hidden; +} + +.moj-banner__message h2 { + margin-bottom: govuk-spacing(2); +} + + +.moj-banner__message h2:last-child, +.moj-banner__message p:last-child { + margin-bottom: 0; +} + + +.moj-banner__assistive { + @include govuk-visually-hidden; +} + + +/* Style variants + ========================================================================== */ + +.moj-banner--success { + border-color: govuk-colour("green"); + color: govuk-colour("green"); +} + + +.moj-banner--warning { + border-color: govuk-colour("red"); + color: govuk-colour("red"); +} diff --git a/node_modules/@ministryofjustice/frontend/moj/components/banner/macro.njk b/node_modules/@ministryofjustice/frontend/moj/components/banner/macro.njk new file mode 100644 index 00000000..3d11b5ea --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/banner/macro.njk @@ -0,0 +1,3 @@ +{% macro mojBanner(params) %} + {%- include "./template.njk" -%} +{% endmacro %} \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/components/banner/template.njk b/node_modules/@ministryofjustice/frontend/moj/components/banner/template.njk new file mode 100644 index 00000000..9bf697ae --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/banner/template.njk @@ -0,0 +1,16 @@ +
+ + {% if params.type == 'success' %} + + {% elif params.type == 'warning' %} + + {% elif params.type == 'information' %} + + {% endif %} + +
+ {{- params.html | safe if params.html else params.text -}} +
+ +
diff --git a/node_modules/@ministryofjustice/frontend/moj/components/button-menu/README.md b/node_modules/@ministryofjustice/frontend/moj/components/button-menu/README.md new file mode 100644 index 00000000..57d6c01a --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/button-menu/README.md @@ -0,0 +1,65 @@ +# Button menu + +- [Guidance](https://design-patterns.service.justice.gov.uk/components/button-menu) + +## Examples + +### Example 1 + +The macro + +``` +{{ mojButtonGroup({ + items: [{ + text: 'Archive', + classes: 'govuk-button--secondary', + href: '#' + }, { + text: 'Reassign', + classes: 'govuk-button--secondary', + href: '#' + }, { + text: 'Delete', + classes: 'govuk-button--secondary', + href: '#' + }] +}) }} +``` + +The JavaScript + +``` +new MOJFrontend.ButtonGroup({ + container: $('.moj-button-group'), + mq: '(min-width: 45em)', + buttonText: 'Actions' +}); +``` + +## Arguments + +### Container + +| Name | Type | Required | Description | +| ------------- | ------ | -------- | ------------------------------------------------------------------------- | +| items | array | Yes | An array of button item objects. See [items](#items). | +| buttonClasses | String | No | Classes to add to the button items. | +| attributes | Object | No | HTML attributes (for example data attributes) to add to the button group. | + +### Items + +See the [button component](https://design-system.service.gov.uk/components/button/) in the GOV.UK Design System for more details. + +| Name | Type | Required | Description | +| ------------------ | ------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| element | String | No | Whether to use an `input`, `button` or `a` element to create the button. In most cases you will not need to set this as it will be configured automatically if you use `href` or `html`. | +| text | String | Yes | If `html` is set, this is not required. Text for the button or link. If `html` is provided, the `text` argument will be ignored and `element` will be automatically set to `button` unless `href` is also set, or it has already been defined. This argument has no effect if `element` is set to `input`. | +| html | String | Yes | If `text` is set, this is not required. HTML for the button or link. If `html` is provided, the `text` argument will be ignored and element will be automatically set to `button` unless `href` is also set, or it has already been defined. This argument has no effect if `element` is set to `input`. | +| name | String | Yes | Name for the `input` or `button`. This has no effect on `a` elements. | +| type | String | Yes | Type of `input` or `button`. The options are `button`, `submit` or `reset`. Defaults to `submit`. This has no effect on `a` elements. | +| value | String | Yes | Value for the `button` tag. This has no effect on `a` or `input` elements. | +| disabled | Boolean | No | Whether the button should be disabled. For button and input elements, `disabled` and `aria-disabled` attributes will be set automatically. | +| href | String | No | The URL that the button should link to. If this is set, `element` will be automatically set to `a` if it has not already been defined. | +| classes | String | No | Classes to add to the button component. | +| attributes | Object | No | HTML attributes (for example data attributes) to add to the button component. | +| preventDoubleClick | Boolean | No | Prevent accidental double clicks on submit buttons from submitting forms multiple times. | diff --git a/node_modules/@ministryofjustice/frontend/moj/components/button-menu/_button-menu.scss b/node_modules/@ministryofjustice/frontend/moj/components/button-menu/_button-menu.scss new file mode 100644 index 00000000..622f4a2e --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/button-menu/_button-menu.scss @@ -0,0 +1,156 @@ +/* ========================================================================== + #BUTTON GROUP + ========================================================================== */ + +.moj-button-menu { + display: inline-block; + position: relative; +} + +/* TOGGLE BUTTON */ + +.moj-button-menu__toggle-button { + display: inline-block; + margin-right: govuk-spacing(2); + margin-bottom: govuk-spacing(2); + width: auto; // Override GDS’s 100% width + + &:last-child { + margin-right: 0; + } + + &:after { + background-repeat: no-repeat; + background-image: url(#{$moj-images-path}icon-arrow-white-down.svg); + content: ''; + display: inline-block; + height: 5px; + margin-left: govuk-spacing(2); + width: 10px; + vertical-align: middle; + } +} + +.moj-button-menu__toggle-button:focus { + &:after { + background-image: url(#{$moj-images-path}icon-arrow-black-down.svg); + } +} + +.moj-button-menu__toggle-button[aria-expanded="true"]:focus { + &:after { + background-image: url(#{$moj-images-path}icon-arrow-black-up.svg); + } +} + +.moj-button-menu__toggle-button:hover { + &:after { + background-image: url(#{$moj-images-path}icon-arrow-white-down.svg); + } +} + +.moj-button-menu__toggle-button[aria-expanded="true"]:hover { + &:after { + background-image: url(#{$moj-images-path}icon-arrow-white-up.svg); + } +} + +.moj-button-menu__toggle-button[aria-expanded="true"] { + &:after { + background-image: url(#{$moj-images-path}icon-arrow-white-up.svg); + } +} + +.moj-button-menu__toggle-button--secondary { + margin-bottom: govuk-spacing(1); + margin-right: 0; + &:after { + background-image: url(#{$moj-images-path}icon-arrow-black-down.svg); + } +} + +.moj-button-menu__toggle-button--secondary[aria-expanded="true"] { + &:after { + background-image: url(#{$moj-images-path}icon-arrow-black-up.svg); + } +} + +.moj-button-menu__toggle-button--secondary:hover { + &:after { + background-image: url(#{$moj-images-path}icon-arrow-black-down.svg); + } +} + +.moj-button-menu__toggle-button--secondary[aria-expanded="true"]:hover { + &:after { + background-image: url(#{$moj-images-path}icon-arrow-black-up.svg); + } +} + + +/* MENU ITEM */ + +.moj-button-menu__item { + display: inline-block; + margin-right: govuk-spacing(2); + margin-bottom: govuk-spacing(2); + width: auto; // Override GDS’s 100% width + &:last-child { + margin-right: 0; + } +} + +.moj-button-menu [role=menuitem] { + @include govuk-font(19); + background-color: govuk-colour("light-grey"); + border: none; + box-sizing: border-box; + display: block; + margin-bottom: 0; + padding: govuk-spacing(2); + text-align: left; + width: 100%; + -webkit-box-sizing: border-box; + -webkit-appearance: none; + + &:link, + &:visited { + text-decoration: none; + color: govuk-colour("black"); + } + + &:hover { + background-color: govuk-colour("mid-grey"); + } + + &:focus { + outline: 3px solid govuk-colour("yellow"); + outline-offset: 0; + position: relative; + z-index: 10; + } +} + +/* MENU WRAPPER */ + +.moj-button-menu__wrapper { + font-size: 0; /* Hide whitespace between elements */ +} + +.moj-button-menu__wrapper--right { + right: 0; +} + +.moj-button-menu [role=menu] { + position: absolute; + width: 200px; + z-index: 10; +} + +.moj-button-menu [aria-expanded="true"] + [role=menu] { + display: block; +} + +.moj-button-menu [aria-expanded="false"] + [role=menu] { + display: none; +} diff --git a/node_modules/@ministryofjustice/frontend/moj/components/button-menu/button-menu.js b/node_modules/@ministryofjustice/frontend/moj/components/button-menu/button-menu.js new file mode 100644 index 00000000..c1edb4aa --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/button-menu/button-menu.js @@ -0,0 +1,155 @@ +MOJFrontend.ButtonMenu = function(params) { + this.container = params.container; + this.menu = this.container.find('.moj-button-menu__wrapper'); + if(params.menuClasses) { + this.menu.addClass(params.menuClasses); + } + this.menu.attr('role', 'menu'); + this.mq = params.mq; + this.buttonText = params.buttonText; + this.buttonClasses = params.buttonClasses || ''; + this.keys = { esc: 27, up: 38, down: 40, tab: 9 }; + this.menu.on('keydown', '[role=menuitem]', $.proxy(this, 'onButtonKeydown')); + this.createToggleButton(); + this.setupResponsiveChecks(); + $(document).on('click', $.proxy(this, 'onDocumentClick')); +}; + +MOJFrontend.ButtonMenu.prototype.onDocumentClick = function(e) { + if(!$.contains(this.container[0], e.target)) { + this.hideMenu(); + } +}; + +MOJFrontend.ButtonMenu.prototype.createToggleButton = function() { + this.menuButton = $(''); + this.menuButton.on('click', $.proxy(this, 'onMenuButtonClick')); + this.menuButton.on('keydown', $.proxy(this, 'onMenuKeyDown')); +}; + +MOJFrontend.ButtonMenu.prototype.setupResponsiveChecks = function() { + this.mql = window.matchMedia(this.mq); + this.mql.addListener($.proxy(this, 'checkMode')); + this.checkMode(this.mql); +}; + +MOJFrontend.ButtonMenu.prototype.checkMode = function(mql) { + if(mql.matches) { + this.enableBigMode(); + } else { + this.enableSmallMode(); + } +}; + +MOJFrontend.ButtonMenu.prototype.enableSmallMode = function() { + this.container.prepend(this.menuButton); + this.hideMenu(); + this.removeButtonClasses(); + this.menu.attr('role', 'menu'); + this.container.find('.moj-button-menu__item').attr('role', 'menuitem'); +}; + +MOJFrontend.ButtonMenu.prototype.enableBigMode = function() { + this.menuButton.detach(); + this.showMenu(); + this.addButtonClasses(); + this.menu.removeAttr('role'); + this.container.find('.moj-button-menu__item').removeAttr('role'); +}; + +MOJFrontend.ButtonMenu.prototype.removeButtonClasses = function() { + this.menu.find('.moj-button-menu__item').each(function(index, el) { + if($(el).hasClass('govuk-button--secondary')) { + $(el).attr('data-secondary', 'true'); + $(el).removeClass('govuk-button--secondary'); + } + if($(el).hasClass('govuk-button--warning')) { + $(el).attr('data-warning', 'true'); + $(el).removeClass('govuk-button--warning'); + } + $(el).removeClass('govuk-button'); + }); +}; + +MOJFrontend.ButtonMenu.prototype.addButtonClasses = function() { + this.menu.find('.moj-button-menu__item').each(function(index, el) { + if($(el).attr('data-secondary') == 'true') { + $(el).addClass('govuk-button--secondary'); + } + if($(el).attr('data-warning') == 'true') { + $(el).addClass('govuk-button--warning'); + } + $(el).addClass('govuk-button'); + }); +}; + +MOJFrontend.ButtonMenu.prototype.hideMenu = function() { + this.menuButton.attr('aria-expanded', 'false'); +}; + +MOJFrontend.ButtonMenu.prototype.showMenu = function() { + this.menuButton.attr('aria-expanded', 'true'); +}; + +MOJFrontend.ButtonMenu.prototype.onMenuButtonClick = function() { + this.toggle(); +}; + +MOJFrontend.ButtonMenu.prototype.toggle = function() { + if(this.menuButton.attr('aria-expanded') == 'false') { + this.showMenu(); + this.menu.find('[role=menuitem]').first().focus(); + } else { + this.hideMenu(); + this.menuButton.focus(); + } +}; + +MOJFrontend.ButtonMenu.prototype.onMenuKeyDown = function(e) { + switch (e.keyCode) { + case this.keys.down: + this.toggle(); + break; + } +}; + +MOJFrontend.ButtonMenu.prototype.onButtonKeydown = function(e) { + switch (e.keyCode) { + case this.keys.up: + e.preventDefault(); + this.focusPrevious(e.currentTarget); + break; + case this.keys.down: + e.preventDefault(); + this.focusNext(e.currentTarget); + break; + case this.keys.esc: + if(!this.mql.matches) { + this.menuButton.focus(); + this.hideMenu(); + } + break; + case this.keys.tab: + if(!this.mql.matches) { + this.hideMenu(); + } + } +}; + +MOJFrontend.ButtonMenu.prototype.focusNext = function(currentButton) { + var next = $(currentButton).next(); + if(next[0]) { + next.focus(); + } else { + this.container.find('[role=menuitem]').first().focus(); + } +}; + +MOJFrontend.ButtonMenu.prototype.focusPrevious = function(currentButton) { + var prev = $(currentButton).prev(); + if(prev[0]) { + prev.focus(); + } else { + this.container.find('[role=menuitem]').last().focus(); + } +}; diff --git a/node_modules/@ministryofjustice/frontend/moj/components/button-menu/macro.njk b/node_modules/@ministryofjustice/frontend/moj/components/button-menu/macro.njk new file mode 100644 index 00000000..47b76ac3 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/button-menu/macro.njk @@ -0,0 +1,3 @@ +{% macro mojButtonMenu(params) %} + {%- include "./template.njk" -%} +{% endmacro %} \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/components/button-menu/template.njk b/node_modules/@ministryofjustice/frontend/moj/components/button-menu/template.njk new file mode 100644 index 00000000..3acab80a --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/button-menu/template.njk @@ -0,0 +1,22 @@ +{%- from "govuk/components/button/macro.njk" import govukButton %} + +
+
+ {%- for item in params.items %} + {{ govukButton({ + element: item.element, + classes: 'moj-button-menu__item ' + (item.classes if item.classes) + ' ' + (params.buttonClasses if params.buttonClasses), + text: item.text, + html: item.html, + name: item.name, + type: item.type, + value: item.value, + href: item.href, + disabled: item.disabled, + attributes: item.attributes, + preventDoubleClick: items.preventDoubleClick + }) }} + {% endfor -%} +
+
+ diff --git a/node_modules/@ministryofjustice/frontend/moj/components/cookie-banner/README.md b/node_modules/@ministryofjustice/frontend/moj/components/cookie-banner/README.md new file mode 100644 index 00000000..760cc220 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/cookie-banner/README.md @@ -0,0 +1,5 @@ +# Cookie banner + +- [Guidance](https://design-patterns.service.justice.gov.uk/components/cookie-banner) + +## Arguments diff --git a/node_modules/@ministryofjustice/frontend/moj/components/cookie-banner/_cookie-banner.scss b/node_modules/@ministryofjustice/frontend/moj/components/cookie-banner/_cookie-banner.scss new file mode 100644 index 00000000..d8b749e9 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/cookie-banner/_cookie-banner.scss @@ -0,0 +1,41 @@ +@import "node_modules/govuk-frontend/dist/govuk/objects/width-container"; + +.moj-cookie-banner { + display: none; + @include govuk-font(16); + + box-sizing: border-box; + + padding-top: govuk-spacing(3); + padding-bottom: govuk-spacing(3); + left: govuk-spacing(3); + padding-right: govuk-spacing(3); + background-color: govuk-colour("white"); + + &--show { + display: block !important; + } + + &__message { + margin: 0; + @include govuk-width-container; + } + + &__buttons { + .govuk-grid-column-full { + padding-left: 0; + } + } + + .govuk-button { + @include govuk-media-query($from: tablet) { + width: 90%; + } + } +} + +@include govuk-media-query($media-type: print) { + .moj-cookie-banner { + display: none !important; + } +} diff --git a/node_modules/@ministryofjustice/frontend/moj/components/cookie-banner/macro.njk b/node_modules/@ministryofjustice/frontend/moj/components/cookie-banner/macro.njk new file mode 100644 index 00000000..36645c55 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/cookie-banner/macro.njk @@ -0,0 +1,3 @@ +{% macro mojCookieBanner(params) %} + {%- include "./template.njk" -%} +{% endmacro %} \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/components/cookie-banner/template.njk b/node_modules/@ministryofjustice/frontend/moj/components/cookie-banner/template.njk new file mode 100644 index 00000000..6e8cffd7 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/cookie-banner/template.njk @@ -0,0 +1,25 @@ +{%- from "govuk/components/button/macro.njk" import govukButton %} + + diff --git a/node_modules/@ministryofjustice/frontend/moj/components/currency-input/README.md b/node_modules/@ministryofjustice/frontend/moj/components/currency-input/README.md new file mode 100644 index 00000000..cd809f60 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/currency-input/README.md @@ -0,0 +1,113 @@ +# Currency input + +- [Guidance](https://design-patterns.service.justice.gov.uk/components/currency-input) + +## Dependencies + +The currency input component is dependent on the following components from the [GOV.UK Frontend](https://github.com/alphagov/govuk-frontend/): + +- [GOV.UK Label component](https://github.com/alphagov/govuk-frontend/tree/main/src/govuk/components/label) +- [GOV.UK Hint component](https://github.com/alphagov/govuk-frontend/tree/main/src/govuk/components/hint) +- [GOV.UK Error message component](https://github.com/alphagov/govuk-frontend/tree/main/src/govuk/components/error-message) + +## Examples + +``` +{{ mojCurrencyInput({ + id: "amount", + classes: "govuk-input--width-10", + name: "amount", + label: { + text: "Amount", + classes: 'govuk-!-font-weight-bold' + }, + hint: { + text: "Enter the amount you want to exchange" + } +}) }} +``` + +### With currency specified + +``` +{{ mojCurrencyInput({ + id: "amount", + classes: "govuk-input--width-10", + name: "amount", + currencyLabel: { + text: "¥" + }, + label: { + text: "Amount", + classes: 'govuk-!-font-weight-bold' + }, + hint: { + text: "Enter the amount you want to exchange" + } +}) }} +``` + +## Arguments + +### Container + +| Name | Type | Required | Description | +| ------------- | ------ | -------- | -------------------------------------------------------------------------------------- | +| id | string | Yes | Optional `id` attribute to add to the text input. | +| name | string | Yes | Name attribute for the text input. | +| value | string | No | Optional value of the text input. | +| type | string | No | Type of input control to render. Defaults to text. | +| formGroup | object | No | Options for the form-group wrapper. See [formGroup](#formgroup). | +| label | object | No | Options for the label component (e.g. text). See [label](#label). | +| hint | object | No | Options for the hint component (e.g. text). See [hint](#hint). | +| errorMessage | object | No | Options for the errorMessage component (e.g. text). See [errorMessage](#errormessage). | +| currencyLabel | object | No | Options for the currency label (e.g. text). See [currencyLabel](#currencylabel). | +| classes | string | No | Classes to add to the text input. | +| attributes | object | No | HTML attributes (for example data attributes) to add to the text input. | + +### formGroup + +| Name | Type | Required | Description | +| ------- | ------ | -------- | ----------------------------------------- | +| classes | string | No | Classes to add to the form group wrapper. | + +### Label + +| Name | Type | Required | Description | +| ------------- | ------- | -------- | --------------------------------------------------------------------------------------------------------------------------------- | +| for | string | Yes | The value of the `for` attribute, the `id` of the `input` the label is associated with. | +| text | string | Yes | If `html` is set, this is not required. Text to use within the label. If `html` is provided, the `text` argument will be ignored. | +| html | string | Yes | If `text` is set, this is not required. HTML to use within the label. If `html` is provided, the `text` argument will be ignored. | +| isPageHeading | boolean | No | Whether the label also acts as the heading for the page. | +| classes | string | No | Classes to add to the label tag. | +| attributes | object | No | HTML attributes (for example data attributes) to add to the label tag. | + +### Hint + +| Name | Type | Required | Description | +| ---------- | ------ | -------- | -------------------------------------------------------------------------------------------------------------------------------- | +| id | string | No | Optional `id` attribute to add to the hint span tag. | +| text | string | Yes | If `html` is set, this is not required. Text to use within the hint. If `html` is provided, the `text` argument will be ignored. | +| html | string | Yes | If `text` is set, this is not required. HTML to use within the hint. If `html` is provided, the `text` argument will be ignored. | +| classes | string | No | Classes to add to the hint span tag. | +| attributes | object | No | HTML attributes (for example data attributes) to add to the hint span tag. | + +### errorMessage + +| Name | Type | Required | Description | +| ---------- | ------ | -------- | --------------------------------------------------------------------------------------------------------------------------------- | +| id | string | No | Optional `id` attribute to add to the error span tag. | +| text | string | Yes | If `html` is set, this is not required. Text to use within the error. If `html` is provided, the `text` argument will be ignored. | +| html | string | Yes | If `text` is set, this is not required. HTML to use within the error. If `html` is provided, the `text` argument will be ignored. | +| classes | string | No | Classes to add to the error span tag. | +| attributes | object | No | HTML attributes (for example data attributes) to add to the error span tag. | + +### currencyLabel + +| Name | Type | Required | Description | +| ------- | ------ | -------- | --------------------------------------------------------------------------------------------------------------------------------- | +| text | string | Yes | If `html` is set, this is not required. Text to use within the error. If `html` is provided, the `text` argument will be ignored. | +| html | string | Yes | If `text` is set, this is not required. HTML to use within the error. If `html` is provided, the `text` argument will be ignored. | +| classes | string | No | Classes to add to the currency span tag. | + +_Warning: If you’re using Nunjucks macros in production be aware that using HTML arguments, or ones ending with `.html` can be at risk from [cross-site scripting](https://en.wikipedia.org/wiki/Cross-site_scripting) attacks. More information about security vulnerabilities can be found in the [Nunjucks documentation](https://mozilla.github.io/nunjucks/api.html#user-defined-templates-warning)._ diff --git a/node_modules/@ministryofjustice/frontend/moj/components/currency-input/_currency-input.scss b/node_modules/@ministryofjustice/frontend/moj/components/currency-input/_currency-input.scss new file mode 100644 index 00000000..edaacf90 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/currency-input/_currency-input.scss @@ -0,0 +1,28 @@ +/* ========================================================================== + #DENOTE + ========================================================================== */ + +.moj-label__currency { + @include govuk-font(19); + background-color: govuk-colour("light-grey"); + position: absolute; + margin: 2px 0 0 2px !important; + padding: 5.5px 12px; + border-right: 2px solid govuk-colour("black"); + + &--error { + background-color: $govuk-error-colour; + border-right: 2px solid $govuk-error-colour; + color: govuk-colour("white"); + } + + @include govuk-media-query($until: tablet) { + padding: 8px 12px; + } + +} + +.moj-input__currency { + margin: 0; + padding-left: 40px; +} \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/components/currency-input/macro.njk b/node_modules/@ministryofjustice/frontend/moj/components/currency-input/macro.njk new file mode 100644 index 00000000..7fd22cd1 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/currency-input/macro.njk @@ -0,0 +1,3 @@ +{% macro mojCurrencyInput(params) %} + {%- include "./template.njk" -%} +{% endmacro %} \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/components/currency-input/template.njk b/node_modules/@ministryofjustice/frontend/moj/components/currency-input/template.njk new file mode 100644 index 00000000..2046d874 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/currency-input/template.njk @@ -0,0 +1,49 @@ +{% from "govuk/components/error-message/macro.njk" import govukErrorMessage -%} +{% from "govuk/components/hint/macro.njk" import govukHint %} +{% from "govuk/components/label/macro.njk" import govukLabel %} + +{#- a record of other elements that we need to associate with the input using + aria-describedby – for example hints or error messages -#} +{% set describedBy = params.describedBy if params.describedBy else "" %} +
+ {{ govukLabel({ + html: params.label.html, + text: params.label.text, + classes: params.label.classes, + isPageHeading: params.label.isPageHeading, + attributes: params.label.attributes, + for: params.id + }) | indent(2) | trim }} +{% if params.hint %} + {% set hintId = params.id + '-hint' %} + {% set describedBy = describedBy + ' ' + hintId if describedBy else hintId %} + {{ govukHint({ + id: hintId, + classes: params.hint.classes, + attributes: params.hint.attributes, + html: params.hint.html, + text: params.hint.text + }) | indent(2) | trim }} +{% endif %} +{% if params.errorMessage %} + {% set errorId = params.id + '-error' %} + {% set describedBy = describedBy + ' ' + errorId if describedBy else errorId %} + {{ govukErrorMessage({ + id: errorId, + classes: params.errorMessage.classes, + attributes: params.errorMessage.attributes, + html: params.errorMessage.html, + text: params.errorMessage.text, + visuallyHiddenText: params.errorMessage.visuallyHiddenText + }) | indent(2) | trim }} +{% endif %} + + {{- params.currencyLabel.html if params.currencyLabel.html else params.currencyLabel.text | default('£') | safe -}} + + +
\ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/components/filter-toggle-button/README.md b/node_modules/@ministryofjustice/frontend/moj/components/filter-toggle-button/README.md new file mode 100644 index 00000000..cc830bfe --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/filter-toggle-button/README.md @@ -0,0 +1,5 @@ +# Filter toggle button + +- [Guidance](https://design-patterns.service.justice.gov.uk/patterns/filter-a-list) + +## Arguments diff --git a/node_modules/@ministryofjustice/frontend/moj/components/filter-toggle-button/filter-toggle-button.js b/node_modules/@ministryofjustice/frontend/moj/components/filter-toggle-button/filter-toggle-button.js new file mode 100644 index 00000000..9b467897 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/filter-toggle-button/filter-toggle-button.js @@ -0,0 +1,85 @@ +MOJFrontend.FilterToggleButton = function(options) { + this.options = options; + this.container = this.options.toggleButton.container; + this.createToggleButton(); + this.setupResponsiveChecks(); + this.options.filter.container.attr('tabindex', '-1'); + if(this.options.startHidden) { + this.hideMenu(); + } +}; + +MOJFrontend.FilterToggleButton.prototype.setupResponsiveChecks = function() { + this.mq = window.matchMedia(this.options.bigModeMediaQuery); + this.mq.addListener($.proxy(this, 'checkMode')); + this.checkMode(this.mq); +}; + +MOJFrontend.FilterToggleButton.prototype.createToggleButton = function() { + this.menuButton = $(''); + this.menuButton.on('click', $.proxy(this, 'onMenuButtonClick')); + this.options.toggleButton.container.append(this.menuButton); +}; + +MOJFrontend.FilterToggleButton.prototype.checkMode = function(mq) { + if(mq.matches) { + this.enableBigMode(); + } else { + this.enableSmallMode(); + } +}; + +MOJFrontend.FilterToggleButton.prototype.enableBigMode = function() { + this.showMenu(); + this.removeCloseButton(); +}; + +MOJFrontend.FilterToggleButton.prototype.enableSmallMode = function() { + this.hideMenu(); + this.addCloseButton(); +}; + +MOJFrontend.FilterToggleButton.prototype.addCloseButton = function() { + if(this.options.closeButton) { + this.closeButton = $(''); + this.closeButton.on('click', $.proxy(this, 'onCloseClick')); + this.options.closeButton.container.append(this.closeButton); + } +}; + +MOJFrontend.FilterToggleButton.prototype.onCloseClick = function() { + this.hideMenu(); + this.menuButton.focus(); +}; + +MOJFrontend.FilterToggleButton.prototype.removeCloseButton = function() { + if(this.closeButton) { + this.closeButton.remove(); + this.closeButton = null; + } +}; + +MOJFrontend.FilterToggleButton.prototype.hideMenu = function() { + this.menuButton.attr('aria-expanded', 'false'); + this.options.filter.container.addClass('moj-js-hidden'); + this.menuButton.text(this.options.toggleButton.showText); +}; + +MOJFrontend.FilterToggleButton.prototype.showMenu = function() { + this.menuButton.attr('aria-expanded', 'true'); + this.options.filter.container.removeClass('moj-js-hidden'); + this.menuButton.text(this.options.toggleButton.hideText); +}; + +MOJFrontend.FilterToggleButton.prototype.onMenuButtonClick = function() { + this.toggle(); +}; + +MOJFrontend.FilterToggleButton.prototype.toggle = function() { + if(this.menuButton.attr('aria-expanded') == 'false') { + this.showMenu(); + this.options.filter.container.focus(); + } else { + this.hideMenu(); + } +}; \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/components/filter/README.md b/node_modules/@ministryofjustice/frontend/moj/components/filter/README.md new file mode 100644 index 00000000..50c51dc0 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/filter/README.md @@ -0,0 +1 @@ +#Filters \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/components/filter/_filter.scss b/node_modules/@ministryofjustice/frontend/moj/components/filter/_filter.scss new file mode 100644 index 00000000..4c8e5df4 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/filter/_filter.scss @@ -0,0 +1,238 @@ +/* ========================================================================== + #FILTER + ========================================================================== */ + +.moj-filter { + background-color: govuk-colour("white"); + box-shadow: inset 0 0 0 1px govuk-colour("mid-grey"); + + &:focus { + box-shadow: 0 -2px $govuk-focus-colour, 0 4px $govuk-focus-text-colour; + } +} + + +.moj-filter__header { + background-color: govuk-colour("mid-grey"); + font-size: 0; // Hide whitespace between elements + padding: govuk-spacing(2) govuk-spacing(4); + text-align: justify; // Trick to remove the need for floats + + &:after { + content: ''; + display: inline-block; + width: 100%; + } + + [class^=govuk-heading-] { + margin-bottom: 0; + } + +} + + +// JavaScript +.moj-filter__legend { + overflow: visible; // Override govuk to allow for focus style to be seen + width: 100%; + + button { + @include govuk-font($size: 24, $weight: bold); + background-color: transparent; + box-sizing: border-box; + border-radius: 0; + border: 0 none; + cursor: pointer; // Adam would not approve + display: block; + margin: 0; + padding: 0; + position: relative; + text-align: left; + width: 100%; + -webkit-appearance: none; + + // Fix unwanted button padding in Firefox + &::-moz-focus-inner { + padding: 0; + border: 0; + } + + &::after { + background-image: url(#{$moj-images-path}icon-toggle-plus-minus.svg); + background-position: 0 0; + content: ""; + display: block; + height: 16px; + margin-top: -8px; // Half the height of the icon + position: absolute; top: 50%; right: 0; + width: 16px; + } + + &[aria-expanded="true"] { + &::after { + background-position: 16px 16px; + } + } + + &:focus { + // @include govuk-focusable; + } + + } + +} + + +.moj-filter__header-title, +.moj-filter__header-action { + display: inline-block; + text-align: left; + vertical-align: middle; +} + + +.moj-filter__close { + // @include govuk-focusable; + color: govuk-colour("black"); + cursor: pointer; // I know Adam won’t like this + background-color: transparent; + border: none; + border-radius: 0; + margin: 0; + padding: 0; + -webkit-appearance: none; + + + &:focus { + background-color: $govuk-focus-colour; + color: $govuk-focus-text-colour; + box-shadow: 0 -2px $govuk-focus-colour, 0 4px $govuk-focus-text-colour; + outline: none; + } + + // Fix unwanted button padding in Firefox + &::-moz-focus-inner { + padding: 0; + border: 0; + } + + &::before { + background-image: url(#{$moj-images-path}icon-close-cross-black.svg); + content: ""; + display: inline-block; + height: 14px; + margin-right: govuk-spacing(1); + position: relative; + top: -1px; // Alignment tweak + vertical-align: middle; + width: 14px; + } + +} + + +.moj-filter__close { + @include govuk-font(19); +} + + +.moj-filter__selected { + background-color: govuk-colour("light-grey"); + box-shadow: inset 0 0 0 1px govuk-colour("mid-grey"); + padding: govuk-spacing(4); + + ul:last-of-type { + margin-bottom: 0; // IE9 + + } + +} + + +.moj-filter__selected-heading { + font-size: 0; // Hide whitespace between elements + text-align: justify; // Trick to remove the need for floats + + &:after { + content: ''; + display: inline-block; + width: 100%; + } + +} + + +.moj-filter__heading-title, +.moj-filter__heading-action { + @include govuk-font(16); + display: inline-block; + text-align: left; + vertical-align: middle; +} + + +.moj-filter-tags { + font-size: 0; + margin-bottom: govuk-spacing(4); // Needs to adjust to 15px on mobile + padding-left: 0; + + li { + display: inline-block; + margin-right: govuk-spacing(2); + } + +} + + +.moj-filter__tag { + @include govuk-font(16); + background-color: govuk-colour("white"); + border: 1px solid govuk-colour("black"); + color: govuk-colour("black"); + display: inline-block; + margin-top: govuk-spacing(1); + padding: govuk-spacing(1); + text-decoration: none; + + &:link, + &:visited { + color: govuk-colour("black"); + } + + &:focus { + color: $govuk-focus-text-colour; + background-color: $govuk-focus-colour; + } + + &:hover { + background-color: govuk-colour("black"); + color: govuk-colour("white"); + } + + &:after { + background-image: url(#{$moj-images-path}icon-tag-remove-cross.svg); + content: ""; + display: inline-block; + font-weight: bold; + height: 10px; + margin-left: govuk-spacing(1); + vertical-align: middle; + width: 10px; + } + + &:hover:after { + background-image: url(#{$moj-images-path}icon-tag-remove-cross-white.svg); + } + +} + + +.moj-filter__options { + box-shadow: inset 0 0 0 1px govuk-colour("mid-grey"); + margin-top: -1px; + padding: govuk-spacing(4); + + div:last-of-type { + margin-bottom: 0; // IE9 + + } + +} diff --git a/node_modules/@ministryofjustice/frontend/moj/components/filter/macro.njk b/node_modules/@ministryofjustice/frontend/moj/components/filter/macro.njk new file mode 100644 index 00000000..7a42a87a --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/filter/macro.njk @@ -0,0 +1,3 @@ +{% macro mojFilter(params) %} + {%- include "./template.njk" -%} +{% endmacro %} \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/components/filter/template.njk b/node_modules/@ministryofjustice/frontend/moj/components/filter/template.njk new file mode 100644 index 00000000..d619b708 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/filter/template.njk @@ -0,0 +1,61 @@ +{% from "govuk/components/button/macro.njk" import govukButton %} + +
+ +
+ +
+

{{ params.heading.html | safe if params.heading.html else params.heading.text }}

+
+ +
+ {# #} +
+ +
+ +
+ + {% if params.selectedFilters %} + +
+ +
+ +
+

{{ params.selectedFilters.heading.html | safe if params.selectedFilters.heading.html else params.selectedFilters.heading.text }}

+
+ + + +
+ + {% for category in params.selectedFilters.categories %} +

{{ category.heading.html | safe if category.heading.html else category.heading.text }}

+ + + {% endfor %} + +
+ {% endif %} + +
+ + {{ govukButton({ + text: params.submit.text if params.submit.text else 'Apply filters', + attributes: params.submit.attributes + }) }} + + {{params.optionsHtml | safe}} + +
+ +
+ +
diff --git a/node_modules/@ministryofjustice/frontend/moj/components/form-validator/README.md b/node_modules/@ministryofjustice/frontend/moj/components/form-validator/README.md new file mode 100644 index 00000000..6f5b117b --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/form-validator/README.md @@ -0,0 +1,5 @@ +# Form validator + +- [Guidance](https://design-patterns.service.justice.gov.uk/components/form-validator) + +## Arguments diff --git a/node_modules/@ministryofjustice/frontend/moj/components/form-validator/form-validator.js b/node_modules/@ministryofjustice/frontend/moj/components/form-validator/form-validator.js new file mode 100644 index 00000000..1d03a3e3 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/form-validator/form-validator.js @@ -0,0 +1,156 @@ +MOJFrontend.FormValidator = function(form, options) { + this.form = form; + this.errors = []; + this.validators = []; + $(this.form).on('submit', $.proxy(this, 'onSubmit')); + this.summary = (options && options.summary) ? $(options.summary) : $('.govuk-error-summary'); + this.originalTitle = document.title; +}; + +MOJFrontend.FormValidator.entityMap = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''', + '/': '/', + '`': '`', + '=': '=' +}; + +MOJFrontend.FormValidator.prototype.escapeHtml = function(string) { + return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap (s) { + return MOJFrontend.FormValidator.entityMap[s]; + }); +}; + +MOJFrontend.FormValidator.prototype.resetTitle = function() { + document.title = this.originalTitle; +}; + +MOJFrontend.FormValidator.prototype.updateTitle = function() { + document.title = "" + this.errors.length + " errors - " + document.title; +}; + +MOJFrontend.FormValidator.prototype.showSummary = function () { + this.summary.html(this.getSummaryHtml()); + this.summary.removeClass('moj-hidden'); + this.summary.attr('aria-labelledby', 'errorSummary-heading'); + this.summary.focus(); +}; + +MOJFrontend.FormValidator.prototype.getSummaryHtml = function() { + var html = '

There is a problem

'; + html += '
'; + html += ''; + html += '
'; + return html; +}; + +MOJFrontend.FormValidator.prototype.hideSummary = function() { + this.summary.addClass('moj-hidden'); + this.summary.removeAttr('aria-labelledby'); +}; + +MOJFrontend.FormValidator.prototype.onSubmit = function (e) { + this.removeInlineErrors(); + this.hideSummary(); + this.resetTitle(); + if(!this.validate()) { + e.preventDefault(); + this.updateTitle(); + this.showSummary(); + this.showInlineErrors(); + } +}; + +MOJFrontend.FormValidator.prototype.showInlineErrors = function() { + for (var i = 0, j = this.errors.length; i < j; i++) { + this.showInlineError(this.errors[i]); + } +}; + +MOJFrontend.FormValidator.prototype.showInlineError = function (error) { + var errorSpanId = error.fieldName + '-error'; + var errorSpan = ''+this.escapeHtml(error.message)+''; + var control = $("#" + error.fieldName); + var fieldContainer = control.parents(".govuk-form-group"); + var label = fieldContainer.find('label'); + var legend = fieldContainer.find("legend"); + var fieldset = fieldContainer.find("fieldset"); + fieldContainer.addClass('govuk-form-group--error'); + if(legend.length) { + legend.after(errorSpan); + fieldContainer.attr('aria-invalid', 'true'); + MOJFrontend.addAttributeValue(fieldset[0], 'aria-describedby', errorSpanId); + } else { + label.after(errorSpan); + control.attr('aria-invalid', 'true'); + MOJFrontend.addAttributeValue(control[0], 'aria-describedby', errorSpanId); + } +}; + +MOJFrontend.FormValidator.prototype.removeInlineErrors = function() { + var error; + var i; + for (var i = 0; i < this.errors.length; i++) { + this.removeInlineError(this.errors[i]); + } +}; + +MOJFrontend.FormValidator.prototype.removeInlineError = function(error) { + var control = $("#" + error.fieldName); + var fieldContainer = control.parents(".govuk-form-group"); + fieldContainer.find('.govuk-error-message').remove(); + fieldContainer.removeClass('govuk-form-group--error'); + fieldContainer.find("[aria-invalid]").attr('aria-invalid', 'false'); + var errorSpanId = error.fieldName + '-error'; + MOJFrontend.removeAttributeValue(fieldContainer.find('[aria-describedby]')[0], 'aria-describedby', errorSpanId); +}; + +MOJFrontend.FormValidator.prototype.addValidator = function(fieldName, rules) { + this.validators.push({ + fieldName: fieldName, + rules: rules, + field: this.form.elements[fieldName] + }); +}; + +MOJFrontend.FormValidator.prototype.validate = function() { + this.errors = []; + var validator = null, + validatorReturnValue = true, + i, + j; + for (i = 0; i < this.validators.length; i++) { + validator = this.validators[i]; + for (j = 0; j < validator.rules.length; j++) { + validatorReturnValue = validator.rules[j].method(validator.field, + validator.rules[j].params); + + if (typeof validatorReturnValue === 'boolean' && !validatorReturnValue) { + this.errors.push({ + fieldName: validator.fieldName, + message: validator.rules[j].message + }); + break; + } else if(typeof validatorReturnValue === 'string') { + this.errors.push({ + fieldName: validatorReturnValue, + message: validator.rules[j].message + }); + break; + } + } + } + return this.errors.length === 0; +}; \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/components/header/README.md b/node_modules/@ministryofjustice/frontend/moj/components/header/README.md new file mode 100644 index 00000000..0b72a178 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/header/README.md @@ -0,0 +1,70 @@ +# Header + +- [Guidance](https://design-patterns.service.justice.gov.uk/components/header) + +## Examples + +``` +{{ mojHeader({ + organisationLabel: { + text: 'Organisation name', + href: '#' + }, + serviceLabel: { + text: 'Service name', + href: '#' + }, + navigation: { + label: 'Account navigation', + items: [{ + text: 'Account name', + href: '#', + active: true + }, { + text: 'Sign out', + href: '#' + }] + } +}) }} +``` + +## Arguments + +This component accepts the following arguments. + +### Container + +| Name | Type | Required | Description | +| ----------------- | ------ | -------- | --------------------------------------------------------------------------------------------- | +| organisationLabel | object | Yes | An object containing the organisation's details. See [organisationLabel](#organisationlabel). | +| serviceLabel | object | Yes | An object containing the service's details. See [serviceLabel](#servicelabel). | +| navigation | array | No | An array of navigation item objects. See [navigation](#navigation). | +| containerClasses | string | No | Classes for the container, useful if you want to make the header fixed width. | +| classes | string | No | Classes to add to the `header` container. | +| attributes | object | No | HTML attributes (for example data attributes) to add to the header container. | + +### organisationLabel + +| Name | Type | Required | Description | +| ---- | ------ | -------- | ------------------------------------------------------------------------------------------------------------------- | +| text | string | Yes | Header title that is placed next to the crest. Used for organisation names (e.g., CICA, HMCTS, HMPPS, LAA and OPG). | +| href | string | Yes | URL for the organisation name anchor. | + +### serviceLabel + +| Name | Type | Required | Description | +| ---- | ------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | +| text | string | Yes | Header title that is placed next to the organisation name. Used for service names (e.g., Claim fees for Crown court defence; Send money to prisoners). | +| href | string | Yes | URL for the service name anchor. | + +### Navigation + +| Name | Type | Required | Description | +| ---------- | ------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------- | +| href | string | Yes | URL of the navigation item anchor. Both href and text attributes for navigation items need to be provided to create an item. | +| text | string | Yes | If `html` is set, this is not required. Text to use within the anchor. If `html` is provided, the `text` argument will be ignored. | +| html | string | Yes | If `text` is set, this is not required. HTML to use within the anchor. If `html` is provided, the `text` argument will be ignored. | +| active | boolean | No | Flag to mark the navigation item as active or not. Defaults to `false`. | +| attributes | object | No | HTML attributes (for example data attributes) to add to the navigation item anchor. | + +_Warning: If you’re using Nunjucks macros in production be aware that using HTML arguments, or ones ending with `.html` can be at risk from [cross-site scripting](https://en.wikipedia.org/wiki/Cross-site_scripting) attacks. More information about security vulnerabilities can be found in the [Nunjucks documentation](https://mozilla.github.io/nunjucks/api.html#user-defined-templates-warning)._ diff --git a/node_modules/@ministryofjustice/frontend/moj/components/header/_header.scss b/node_modules/@ministryofjustice/frontend/moj/components/header/_header.scss new file mode 100644 index 00000000..00080cf7 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/header/_header.scss @@ -0,0 +1,170 @@ +/* ========================================================================== + #HEADER + ========================================================================== */ + +.moj-header { + background-color: govuk-colour("black"); + padding-top: govuk-spacing(3); + border-bottom: 10px solid $govuk-brand-colour; +} + +.moj-header__container { + @include moj-width-container; + @include govuk-clearfix; + position: relative; +} + +.moj-header__logo { + padding-bottom: govuk-spacing(1); + + @include govuk-media-query($from: desktop) { + float: left; + } + +} + +.moj-header__logotype-crown { + position: relative; + top: -4px; + margin-right: govuk-spacing(1); + vertical-align: top; + +} + +.moj-header__logotype-crest { + position: relative; + top: -6px; + margin-right: govuk-spacing(1); + vertical-align: top; +} + +.moj-header__content { + padding-bottom: govuk-spacing(2); + + @include govuk-media-query($from: desktop) { + float: right; + } + +} + +.moj-header__link, .moj-header__link > a { + @include govuk-link-common; + @include govuk-link-style-default; + border-bottom: 1px solid transparent; + color: govuk-colour("white"); + display: inline-block; + text-decoration: none; + line-height: 25px; // Override due to alignment issue in Chrome + margin-bottom: -1px; + overflow: hidden; // Fixes focus gaps in background colour + vertical-align: middle; + + &:link, + &:visited, + &:hover, + &:active { + color: govuk-colour("white"); + } + + &:hover { + border-color: govuk-colour("white"); + } + + &:focus { + border-color: transparent; + color: govuk-colour("black"); + } + + &--organisation-name { + @include govuk-font($size: 24, $weight: "bold"); + vertical-align: middle; + &:hover { + border-color: transparent; + } + } + + &--service-name { + vertical-align: middle; + @include govuk-font($size: 24, $weight: "normal"); + + @include govuk-media-query($until: desktop) { + display: block; + } + @include govuk-media-query($from: desktop) { + margin-left: govuk-spacing(1); + } + &:hover { + border-color: transparent; + } + } +} + +.moj-header__link a { + vertical-align: text-bottom; + margin-bottom: 1px; + + &:hover { + border-color: govuk-colour("white"); + } + + @include govuk-media-query($until: desktop) { + vertical-align: middle; + margin-bottom: -1px; + } +} + + +span.moj-header__link { + &:hover { + border-color: transparent; + } +} + +// Navigation +.moj-header__navigation { + color: govuk-colour("white"); + margin-top: govuk-spacing(1)-2px; +} + +.moj-header__navigation-list { + font-size: 0; // Removes white space when using inline-block on child element. + list-style: none; + margin: 0; + padding: 0; +} + +.moj-header__navigation-item { + @include govuk-font(19); + display: inline-block; + margin-right: govuk-spacing(4); + + &:last-child { + margin-right: 0; + } + +} + +.moj-header__navigation-link { + @include govuk-link-common; + @include govuk-link-style-default; + + &:link, + &:visited, + &:active { + color: inherit; + text-decoration: none; + } + + &:hover { + text-decoration: underline !important; + } + + &:focus { + color: govuk-colour("black"); + } + +} + +.moj-header__navigation-link[aria-current=page] { + text-decoration: none; +} diff --git a/node_modules/@ministryofjustice/frontend/moj/components/header/macro.njk b/node_modules/@ministryofjustice/frontend/moj/components/header/macro.njk new file mode 100644 index 00000000..d4d9a7d2 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/header/macro.njk @@ -0,0 +1,3 @@ +{% macro mojHeader(params) %} + {%- include "./template.njk" -%} +{% endmacro %} \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/components/header/template.njk b/node_modules/@ministryofjustice/frontend/moj/components/header/template.njk new file mode 100644 index 00000000..096da1e8 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/header/template.njk @@ -0,0 +1,75 @@ + diff --git a/node_modules/@ministryofjustice/frontend/moj/components/identity-bar/README.md b/node_modules/@ministryofjustice/frontend/moj/components/identity-bar/README.md new file mode 100644 index 00000000..e69de29b diff --git a/node_modules/@ministryofjustice/frontend/moj/components/identity-bar/_identity-bar.scss b/node_modules/@ministryofjustice/frontend/moj/components/identity-bar/_identity-bar.scss new file mode 100644 index 00000000..2ed88ef3 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/identity-bar/_identity-bar.scss @@ -0,0 +1,67 @@ +/* ========================================================================== + #IDENTITY BAR + ========================================================================== */ + +.moj-identity-bar { + @include govuk-clearfix; + background-color: govuk-colour("white"); + box-shadow: inset 0 -1px 0 0 govuk-colour("mid-grey"); /* Takes up no space */ + color: govuk-colour("black"); + padding-bottom: govuk-spacing(2) - 1px; /* Negative by 1px to compensate */ + padding-top: govuk-spacing(2); +} + + +.moj-identity-bar__container { + @include moj-width-container; + font-size: 0; /* Hide whitespace between elements */ + text-align: justify; /* Trick to remove the need for floats */ + + &:after { + content: ''; + display: inline-block; + width: 100%; + } + +} + +.moj-identity-bar__title { + @include govuk-font(16); + display: inline-block; + vertical-align: top; +} + +.moj-identity-bar__details { + margin-right: govuk-spacing(2); + padding-top: govuk-spacing(1); + padding-bottom: govuk-spacing(1); + + @include govuk-media-query($from: tablet) { + display: inline-block; + vertical-align: top; + padding-top: govuk-spacing(2) + 1px; /* Alignment tweaks */ + padding-bottom: govuk-spacing(2) - 1px; /* Alignment tweaks */ + } + +} + + +.moj-identity-bar__actions { + margin-bottom: - govuk-spacing(2); + + @include govuk-media-query($from: tablet) { + display: inline-block; + vertical-align: middle; + } + +} + +.moj-identity-bar__menu { + display: inline-block; + margin-right: govuk-spacing(2); + + &:last-child { + margin-right: 0; + } + +} \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/components/identity-bar/macro.njk b/node_modules/@ministryofjustice/frontend/moj/components/identity-bar/macro.njk new file mode 100644 index 00000000..0a64d434 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/identity-bar/macro.njk @@ -0,0 +1,3 @@ +{% macro mojIdentityBar(params) %} + {%- include "./template.njk" -%} +{% endmacro %} \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/components/identity-bar/template.njk b/node_modules/@ministryofjustice/frontend/moj/components/identity-bar/template.njk new file mode 100644 index 00000000..21fa3ca1 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/identity-bar/template.njk @@ -0,0 +1,25 @@ +{%- from "moj/components/button-menu/macro.njk" import mojButtonMenu %} + +
+ +
+ +
+ {% if params.title %} + {{ params.title.html | safe if params.title.html else params.title.text }} + {% endif %} +
+ + {% if params.menus %} +
+ {% for menu in params.menus %} +
+ {{mojButtonMenu({ items: menu.items, classes: menu.classes })}} +
+ {% endfor %} +
+ {% endif %} + +
+ +
diff --git a/node_modules/@ministryofjustice/frontend/moj/components/messages/README.md b/node_modules/@ministryofjustice/frontend/moj/components/messages/README.md new file mode 100644 index 00000000..b0ae082d --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/messages/README.md @@ -0,0 +1,85 @@ +# Messages + +- [Guidance](https://design-patterns.service.justice.gov.uk/components/messages) + +### Installation + +You will need to install the following code at the bottom of `server.js`, just above `module.exports = app;` + +``` +// Add filters from MOJ Frontend +let mojFilters = require('./node_modules/@ministryofjustice/frontend/filters/all')(); +mojFilters = Object.assign(mojFilters); +Object.keys(mojFilters).forEach(function (filterName) { + nunjucksAppEnv.addFilter(filterName, mojFilters[filterName]) +}); +``` + +## Example + +Below is a typical example of the timeline component in use. + +``` +{{ mojMessages({ + items: [ + { + id: 1, + text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', + type: 'sent', + timestamp: '2018-10-16T10:50:00.000Z', + sender: 'Person A' + }, + { + id: 2, + text: 'Nullam vestibulum lorem vulputate velit euismod luctus.', + type: 'received', + timestamp: '2018-10-17T10:51:00.000Z', + sender: 'Person B' + }, + { + id: 3, + text: 'Fusce et vulputate justo. Integer suscipit felis non urna lobortis, vel finibus sem tristique.', + type: 'sent', + timestamp: '2018-10-19T10:53:00.000Z', + sender: 'Person A' + }, + { + id: 4, + text: 'Mauris tincidunt feugiat orci et convallis. Nam efficitur gravida justo non lobortis. Aliquam velit ante, lobortis eu venenatis sit amet, semper sit amet justo.', + type: 'sent', + timestamp: '2018-10-19T10:55:00.000Z', + sender: 'Person A' + }, + { + id: 5, + text: 'Proin dapibus, nisl id ultricies ultricies, erat magna pulvinar risus, sit amet commodo nunc purus eu nulla. Aliquam erat volutpat. Vestibulum in ante interdum, elementum arcu vel, viverra nibh. Etiam ultrices urna at suscipit sollicitudin. Nulla non lectus magna. Curabitur vel vestibulum lorem. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.', + type: 'received', + timestamp: '2018-10-21T11:56:00.000Z', + sender: 'Person B' + } + ] +}) }} +``` + +## Arguments + +This component accepts the following arguments. + +### Container + +| Name | Type | Required | Description | +| ---------- | ------ | -------- | -------------------------------------------------------------------------------- | +| items | array | Yes | An array of message item objects. See [items](#items). | +| classes | string | No | Classes to add to the messages's container. | +| attributes | object | No | HTML attributes (for example data attributes) to add to the message's container. | + +### Items + +| Name | Type | Required | Description | +| --------- | ------ | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| id | string | No | The unique ID of the item | +| text | string | Yes | If `html` is set, this is not required. Text to use within the item. If `html` is provided, the `text` argument will be ignored. | +| html | string | Yes | If `text` is set, this is not required. HTML to use within the item. If `html` is provided, the `text` argument will be ignored. | +| type | string | Yes | Used to show sent or received messages. Sent messages are blue and aligned to the right, received messages are grey and aligned to the left. Options: `sent` or `received`. | +| sender | string | Yes | The thing that created the message. | +| timestamp | string | Yes | A valid datetime string to be formatted. For example: `1970-01-01T11:59:59.000Z` | diff --git a/node_modules/@ministryofjustice/frontend/moj/components/messages/_messages.scss b/node_modules/@ministryofjustice/frontend/moj/components/messages/_messages.scss new file mode 100644 index 00000000..c98a5a79 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/messages/_messages.scss @@ -0,0 +1,112 @@ +/* ========================================================================== + #MESSAGES + ========================================================================== */ + +.moj-messages-container { + @include govuk-font(19); + border: 1px solid $govuk-border-colour; +} + +.moj-message-list { + min-height: 200px; + overflow-y: scroll; + overflow-x: hidden; + padding: govuk-spacing(1); + + &__date { + @include govuk-font($size: 19, $weight: "bold"); + padding: govuk-spacing(3) 0; + color: govuk-colour("dark-grey"); + display: inline-block; + text-align: center; + width: 100%; + } + +} + +.moj-message-item { + border-radius: 0.5em 0.5em 0.75em 0.5em; + margin-bottom: govuk-spacing(1); + padding: govuk-spacing(3); + position: relative; + + @include govuk-media-query($from: tablet) { + width: 50%; + } + + &--sent { + color: govuk-colour("white"); + background-color: $govuk-brand-colour; + margin-right: govuk-spacing(2); + padding-right: govuk-spacing(5); + text-align: right; + float: right; + + &::after { + content: ""; + position: absolute; + right: -1.5em; + bottom: 0; + width: 1.5em; + height: 1.5em; + border-left: 1em solid $govuk-brand-colour; + border-bottom-left-radius: 1.75em 1.5em; + } + } + + &--received { + background-color: govuk-colour("light-grey"); + float: left; + margin-left: govuk-spacing(2); + padding-left: govuk-spacing(5); + + &::after { + content: ""; + position: absolute; + left: -1.5em; + bottom: 0; + width: 1.5em; + height: 1.5em; + border-right: 1em solid govuk-colour("light-grey"); + border-bottom-right-radius: 1.75em 1.5em; + } + + } + +} + +.moj-message-item a:link, +.moj-message-item a:visited { + color: govuk-colour("white"); +} + +.moj-message-item a:focus { + color: $govuk-focus-text-colour; +} + +.moj-message-item__text { + + &--sent table { + color: govuk-colour("white"); + + & th, + & td { + border-bottom: 1px solid govuk-colour("white"); + } + + } + +} + +.moj-message-item__meta { + margin-top: govuk-spacing(2); + + &--sender { + @include govuk-font($size: 16, $weight: "bold"); + } + + &--timestamp { + @include govuk-font($size: 16, $weight: "bold"); + } + +} diff --git a/node_modules/@ministryofjustice/frontend/moj/components/messages/macro.njk b/node_modules/@ministryofjustice/frontend/moj/components/messages/macro.njk new file mode 100644 index 00000000..e957ee50 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/messages/macro.njk @@ -0,0 +1,3 @@ +{% macro mojMessages(params) %} + {%- include "./template.njk" -%} +{% endmacro %} \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/components/messages/template.njk b/node_modules/@ministryofjustice/frontend/moj/components/messages/template.njk new file mode 100644 index 00000000..97ad5be2 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/messages/template.njk @@ -0,0 +1,30 @@ +
+ +
+ + {%- for item in params.items %} + + {%- if previous_timestamp != item.timestamp | mojDate('date') %} + + + + {% endif -%} + +
+
+ {{- item.html | safe if item.html else item.text -}} +
+
+ {{ item.sender }} at +
+
+ + {%- set previous_timestamp = item.timestamp | mojDate('date') -%} + + {% endfor -%} + +
+ +
diff --git a/node_modules/@ministryofjustice/frontend/moj/components/multi-file-upload/README.md b/node_modules/@ministryofjustice/frontend/moj/components/multi-file-upload/README.md new file mode 100644 index 00000000..f801cc72 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/multi-file-upload/README.md @@ -0,0 +1 @@ +# Multi file upload \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/components/multi-file-upload/_multi-file-upload.scss b/node_modules/@ministryofjustice/frontend/moj/components/multi-file-upload/_multi-file-upload.scss new file mode 100644 index 00000000..c29e84d5 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/multi-file-upload/_multi-file-upload.scss @@ -0,0 +1,66 @@ +.moj-multi-file-upload { + margin-bottom: 40px; +} + +.moj-multi-file-upload--enhanced .moj-multi-file-upload__button { + display: none; +} + +.moj-multi-file-upload__dropzone { + outline: 3px dashed govuk-colour('black'); + display: flex; + text-align: center; + padding: govuk-spacing(9) govuk-spacing(3); + transition: outline-offset .1s ease-in-out, background-color .1s linear; +} + +.moj-multi-file-upload__dropzone label { + margin-bottom: 0; + display: inline-block; + width: auto; +} + +.moj-multi-file-upload__dropzone p { + margin-bottom: 0; + margin-right: 10px; + padding-top: 7px; +} + +.moj-multi-file-upload__dropzone [type=file] { + position: absolute; + left: -9999em; +} + +.moj-multi-file-upload--dragover { + background: #b1b4b6; + outline-color: #6f777b; +} + +.moj-multi-file-upload--focused { + background-color: $govuk-focus-colour; + color: $govuk-focus-text-colour; + box-shadow: 0 -2px $govuk-focus-colour, 0 4px $govuk-focus-text-colour; + outline: none; +} + +.moj-multi-file-upload__error { + color: govuk-colour('red'); + font-weight: bold; +} + +.moj-multi-file-upload__success { + color: govuk-colour('green'); + font-weight: bold; +} + +.moj-multi-file-upload__error svg { + fill: currentColor; + float: left; + margin-right: govuk-spacing(2); +} + +.moj-multi-file-upload__success svg { + fill: currentColor; + float: left; + margin-right: govuk-spacing(2); +} \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/components/multi-file-upload/macro.njk b/node_modules/@ministryofjustice/frontend/moj/components/multi-file-upload/macro.njk new file mode 100644 index 00000000..3b9c6d45 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/multi-file-upload/macro.njk @@ -0,0 +1,3 @@ +{% macro mojMultiFileUpload(params) %} + {%- include "./template.njk" -%} +{% endmacro %} \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/components/multi-file-upload/multi-file-upload.js b/node_modules/@ministryofjustice/frontend/moj/components/multi-file-upload/multi-file-upload.js new file mode 100644 index 00000000..5fb6382c --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/multi-file-upload/multi-file-upload.js @@ -0,0 +1,182 @@ +if(MOJFrontend.dragAndDropSupported() && MOJFrontend.formDataSupported() && MOJFrontend.fileApiSupported()) { + MOJFrontend.MultiFileUpload = function(params) { + this.defaultParams = { + uploadFileEntryHook: $.noop, + uploadFileExitHook: $.noop, + uploadFileErrorHook: $.noop, + fileDeleteHook: $.noop, + uploadStatusText: 'Uploading files, please wait', + dropzoneHintText: 'Drag and drop files here or', + dropzoneButtonText: 'Choose files' + }; + + this.params = $.extend({}, this.defaultParams, params); + + this.params.container.addClass('moj-multi-file-upload--enhanced'); + + this.feedbackContainer = this.params.container.find('.moj-multi-file__uploaded-files'); + this.setupFileInput(); + this.setupDropzone(); + this.setupLabel(); + this.setupStatusBox(); + this.params.container.on('click', '.moj-multi-file-upload__delete', $.proxy(this, 'onFileDeleteClick')); + }; + + MOJFrontend.MultiFileUpload.prototype.setupDropzone = function() { + this.fileInput.wrap('
'); + this.dropzone = this.params.container.find('.moj-multi-file-upload__dropzone'); + this.dropzone.on('dragover', $.proxy(this, 'onDragOver')); + this.dropzone.on('dragleave', $.proxy(this, 'onDragLeave')); + this.dropzone.on('drop', $.proxy(this, 'onDrop')); + }; + + MOJFrontend.MultiFileUpload.prototype.setupLabel = function() { + this.label = $(''); + this.dropzone.append('

' + this.params.dropzoneHintText + '

'); + this.dropzone.append(this.label); + }; + + MOJFrontend.MultiFileUpload.prototype.setupFileInput = function() { + this.fileInput = this.params.container.find('.moj-multi-file-upload__input'); + this.fileInput.on('change', $.proxy(this, 'onFileChange')); + this.fileInput.on('focus', $.proxy(this, 'onFileFocus')); + this.fileInput.on('blur', $.proxy(this, 'onFileBlur')); + }; + + MOJFrontend.MultiFileUpload.prototype.setupStatusBox = function() { + this.status = $('
'); + this.dropzone.append(this.status); + }; + + MOJFrontend.MultiFileUpload.prototype.onDragOver = function(e) { + e.preventDefault(); + this.dropzone.addClass('moj-multi-file-upload--dragover'); + }; + + MOJFrontend.MultiFileUpload.prototype.onDragLeave = function() { + this.dropzone.removeClass('moj-multi-file-upload--dragover'); + }; + + MOJFrontend.MultiFileUpload.prototype.onDrop = function(e) { + e.preventDefault(); + this.dropzone.removeClass('moj-multi-file-upload--dragover'); + this.feedbackContainer.removeClass('moj-hidden'); + this.status.html(this.params.uploadStatusText); + this.uploadFiles(e.originalEvent.dataTransfer.files); + }; + + MOJFrontend.MultiFileUpload.prototype.uploadFiles = function(files) { + for(var i = 0; i < files.length; i++) { + this.uploadFile(files[i]); + } + }; + + MOJFrontend.MultiFileUpload.prototype.onFileChange = function(e) { + this.feedbackContainer.removeClass('moj-hidden'); + this.status.html(this.params.uploadStatusText); + this.uploadFiles(e.currentTarget.files); + this.fileInput.replaceWith($(e.currentTarget).val('').clone(true)); + this.setupFileInput(); + this.fileInput.focus(); + }; + + MOJFrontend.MultiFileUpload.prototype.onFileFocus = function(e) { + this.label.addClass('moj-multi-file-upload--focused'); + }; + + MOJFrontend.MultiFileUpload.prototype.onFileBlur = function(e) { + this.label.removeClass('moj-multi-file-upload--focused'); + }; + + MOJFrontend.MultiFileUpload.prototype.getSuccessHtml = function(success) { + return ' ' + success.messageHtml + ''; + }; + + MOJFrontend.MultiFileUpload.prototype.getErrorHtml = function(error) { + return ' '+ error.message +''; + }; + + MOJFrontend.MultiFileUpload.prototype.getFileRowHtml = function(file) { + var html = ''; + html += '
'; + html += '
'; + html += ''+file.name+''; + html += '0%'; + html += '
'; + html += '
'; + html += '
'; + return html; + }; + + MOJFrontend.MultiFileUpload.prototype.getDeleteButtonHtml = function(file) { + var html = ''; + return html; + }; + + MOJFrontend.MultiFileUpload.prototype.uploadFile = function(file) { + this.params.uploadFileEntryHook(this, file); + var formData = new FormData(); + formData.append('documents', file); + var item = $(this.getFileRowHtml(file)); + this.feedbackContainer.find('.moj-multi-file-upload__list').append(item); + + $.ajax({ + url: this.params.uploadUrl, + type: 'post', + data: formData, + processData: false, + contentType: false, + success: $.proxy(function(response){ + if(response.error) { + item.find('.moj-multi-file-upload__message').html(this.getErrorHtml(response.error)); + this.status.html(response.error.message); + } else { + item.find('.moj-multi-file-upload__message').html(this.getSuccessHtml(response.success)); + this.status.html(response.success.messageText); + } + item.find('.moj-multi-file-upload__actions').append(this.getDeleteButtonHtml(response.file)); + this.params.uploadFileExitHook(this, file, response); + }, this), + error: $.proxy(function(jqXHR, textStatus, errorThrown) { + this.params.uploadFileErrorHook(this, file, jqXHR, textStatus, errorThrown); + }, this), + xhr: function() { + var xhr = new XMLHttpRequest(); + xhr.upload.addEventListener('progress', function(e) { + if (e.lengthComputable) { + var percentComplete = e.loaded / e.total; + percentComplete = parseInt(percentComplete * 100, 10); + item.find('.moj-multi-file-upload__progress').text(' ' + percentComplete + '%'); + } + }, false); + return xhr; + } + }); + }; + + MOJFrontend.MultiFileUpload.prototype.onFileDeleteClick = function(e) { + e.preventDefault(); // if user refreshes page and then deletes + var button = $(e.currentTarget); + var data = {}; + data[button[0].name] = button[0].value; + $.ajax({ + url: this.params.deleteUrl, + type: 'post', + dataType: 'json', + data: data, + success: $.proxy(function(response){ + if(response.error) { + // handle error + } else { + button.parents('.moj-multi-file-upload__row').remove(); + if(this.feedbackContainer.find('.moj-multi-file-upload__row').length === 0) { + this.feedbackContainer.addClass('moj-hidden'); + } + } + this.params.fileDeleteHook(this, response); + }, this) + }); + }; +} diff --git a/node_modules/@ministryofjustice/frontend/moj/components/multi-file-upload/template.njk b/node_modules/@ministryofjustice/frontend/moj/components/multi-file-upload/template.njk new file mode 100644 index 00000000..59e198d2 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/multi-file-upload/template.njk @@ -0,0 +1,25 @@ +
+
+

{{ params.uploadedFiles.heading.html | safe if params.uploadedFiles.heading.html else params.uploadedFiles.heading.text }}

+
+ {% if params.uploadedFiles.items and params.uploadedFiles.items.length > 0 %} + {% for item in params.uploadedFiles.items %} +
+
+ {{ item.message.html | safe if item.message.html else item.message.text }} +
+
+ +
+
+ {% endfor %} + {% endif %} +
+
+ +
+ {{ params.uploadHtml | safe }} +
+
diff --git a/node_modules/@ministryofjustice/frontend/moj/components/multi-select/README.md b/node_modules/@ministryofjustice/frontend/moj/components/multi-select/README.md new file mode 100644 index 00000000..633141df --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/multi-select/README.md @@ -0,0 +1,3 @@ +# Table multi-select + +- [Guidance](https://design-patterns.service.justice.gov.uk/components/table-multi-select) diff --git a/node_modules/@ministryofjustice/frontend/moj/components/multi-select/_multi-select.scss b/node_modules/@ministryofjustice/frontend/moj/components/multi-select/_multi-select.scss new file mode 100644 index 00000000..b024ba7f --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/multi-select/_multi-select.scss @@ -0,0 +1,14 @@ +/* ========================================================================== + # MULTI-SELECT + ========================================================================== */ + + +.moj-multi-select__checkbox { + display: inline-block; + padding-left: 0; +} + +.moj-multi-select__toggle-label { + padding: 0 !important; + margin: 0 !important; +} \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/components/multi-select/multi-select.js b/node_modules/@ministryofjustice/frontend/moj/components/multi-select/multi-select.js new file mode 100644 index 00000000..b6e541c9 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/multi-select/multi-select.js @@ -0,0 +1,64 @@ +MOJFrontend.MultiSelect = function(options) { + this.container = $(options.container); + + if (this.container.data('moj-multi-select-initialised')) { + return + } + + this.container.data('moj-multi-select-initialised', true); + + this.toggle = $(this.getToggleHtml()); + this.toggleButton = this.toggle.find('input'); + this.toggleButton.on('click', $.proxy(this, 'onButtonClick')); + this.container.append(this.toggle); + this.checkboxes = $(options.checkboxes); + this.checkboxes.on('click', $.proxy(this, 'onCheckboxClick')); + this.checked = options.checked || false; +}; + +MOJFrontend.MultiSelect.prototype.getToggleHtml = function() { + var html = ''; + html += '
'; + html += ' '; + html += ' '; + html += '
'; + return html; +}; + +MOJFrontend.MultiSelect.prototype.onButtonClick = function(e) { + if(this.checked) { + this.uncheckAll(); + this.toggleButton[0].checked = false; + } else { + this.checkAll(); + this.toggleButton[0].checked = true; + } +}; + +MOJFrontend.MultiSelect.prototype.checkAll = function() { + this.checkboxes.each($.proxy(function(index, el) { + el.checked = true; + }, this)); + this.checked = true; +}; + +MOJFrontend.MultiSelect.prototype.uncheckAll = function() { + this.checkboxes.each($.proxy(function(index, el) { + el.checked = false; + }, this)); + this.checked = false; +}; + +MOJFrontend.MultiSelect.prototype.onCheckboxClick = function(e) { + if(!e.target.checked) { + this.toggleButton[0].checked = false; + this.checked = false; + } else { + if(this.checkboxes.filter(':checked').length === this.checkboxes.length) { + this.toggleButton[0].checked = true; + this.checked = true; + } + } +}; diff --git a/node_modules/@ministryofjustice/frontend/moj/components/notification-badge/README.md b/node_modules/@ministryofjustice/frontend/moj/components/notification-badge/README.md new file mode 100644 index 00000000..cb624aca --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/notification-badge/README.md @@ -0,0 +1,8 @@ +# Notification badge + +- [Guidance](https://design-patterns.service.justice.gov.uk/components/notification-badge) + +## Arguments + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | diff --git a/node_modules/@ministryofjustice/frontend/moj/components/notification-badge/_notification-badge.scss b/node_modules/@ministryofjustice/frontend/moj/components/notification-badge/_notification-badge.scss new file mode 100644 index 00000000..6bf8ff3e --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/notification-badge/_notification-badge.scss @@ -0,0 +1,17 @@ +/* ========================================================================== + #NOTIFICATION BADGE + ========================================================================== */ + +.moj-notification-badge { + @include govuk-font($size: 16, $weight: "bold"); + color: govuk-colour("white"); + display: inline-block; + min-width: 15px; + padding: 5px 8px 2px 8px; + border-radius: 75px; + background-color: govuk-colour("red"); + font-size: 16px; + font-weight: 600; + text-align: center; + white-space: nowrap; +} \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/components/notification-badge/macro.njk b/node_modules/@ministryofjustice/frontend/moj/components/notification-badge/macro.njk new file mode 100644 index 00000000..0f190967 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/notification-badge/macro.njk @@ -0,0 +1,3 @@ +{% macro mojNotificationBadge(params) %} + {%- include "./template.njk" -%} +{% endmacro %} \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/components/notification-badge/template.njk b/node_modules/@ministryofjustice/frontend/moj/components/notification-badge/template.njk new file mode 100644 index 00000000..db757cd5 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/notification-badge/template.njk @@ -0,0 +1,5 @@ +{%- if params.text.length %} + + {{- params.text | safe -}} + +{% endif -%} diff --git a/node_modules/@ministryofjustice/frontend/moj/components/organisation-switcher/README.md b/node_modules/@ministryofjustice/frontend/moj/components/organisation-switcher/README.md new file mode 100644 index 00000000..aaf9b7ba --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/organisation-switcher/README.md @@ -0,0 +1,8 @@ +# Organisation switcher + +- [Guidance](https://design-patterns.service.justice.gov.uk/components/organisation-switcher) + +## Arguments + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | diff --git a/node_modules/@ministryofjustice/frontend/moj/components/organisation-switcher/_organisation-switcher.scss b/node_modules/@ministryofjustice/frontend/moj/components/organisation-switcher/_organisation-switcher.scss new file mode 100644 index 00000000..fe0b9558 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/organisation-switcher/_organisation-switcher.scss @@ -0,0 +1,28 @@ +/* ========================================================================== + #ORGANISATION SWITCHER + ========================================================================== */ + +.moj-organisation-nav { + @include govuk-clearfix; + margin-top: govuk-spacing(2); + margin-bottom: govuk-spacing(3); + padding-bottom: govuk-spacing(1); + border-bottom: 1px solid $govuk-border-colour; +} + +.moj-organisation-nav__title { + @include govuk-font($size: 19, $weight: "bold"); + @include govuk-media-query($from: tablet) { + float: left; + width: 75%; + } +} + +.moj-organisation-nav__link { + @include govuk-link-common; + @include govuk-link-style-default; + @include govuk-link-print-friendly; + @include govuk-media-query($from: tablet) { + float: right; + } +} diff --git a/node_modules/@ministryofjustice/frontend/moj/components/organisation-switcher/macro.njk b/node_modules/@ministryofjustice/frontend/moj/components/organisation-switcher/macro.njk new file mode 100644 index 00000000..5c0d0936 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/organisation-switcher/macro.njk @@ -0,0 +1,3 @@ +{% macro mojOrganisationSwitcher(params) %} + {%- include "./template.njk" -%} +{% endmacro %} \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/components/organisation-switcher/template.njk b/node_modules/@ministryofjustice/frontend/moj/components/organisation-switcher/template.njk new file mode 100644 index 00000000..3158c12a --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/organisation-switcher/template.njk @@ -0,0 +1,12 @@ +
+
+ {{- params.html | safe if params.html else params.text -}} +
+ + {% if params.link %} + {%- set linkText = params.link.text | default('Change organisation') -%} + + {{- linkText -}} + + {% endif %} +
diff --git a/node_modules/@ministryofjustice/frontend/moj/components/page-header-actions/README.md b/node_modules/@ministryofjustice/frontend/moj/components/page-header-actions/README.md new file mode 100644 index 00000000..09eb27e8 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/page-header-actions/README.md @@ -0,0 +1,5 @@ +# Page header actions + +- [Guidance](https://design-patterns.service.justice.gov.uk/components/page-header-actions) + +## Arguments diff --git a/node_modules/@ministryofjustice/frontend/moj/components/page-header-actions/_page-header-actions.scss b/node_modules/@ministryofjustice/frontend/moj/components/page-header-actions/_page-header-actions.scss new file mode 100644 index 00000000..fd8eb225 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/page-header-actions/_page-header-actions.scss @@ -0,0 +1,54 @@ +.moj-page-header-actions { + @include govuk-clearfix; + font-size: 0; // Hide whitespace between elements + margin-bottom: govuk-spacing(7); + min-height: govuk-spacing(7); // Match button height + text-align: justify; // Trick to remove the need for floats + &:after { + content: ''; + display: inline-block; + width: 100%; + } + +} + + +.moj-page-header-actions__title { + + [class^=govuk-heading-] { + margin-bottom: govuk-spacing(2); + text-align: left; + @include govuk-media-query($from: tablet) { + margin-bottom: 0; + } + } + + @include govuk-media-query($from: tablet) { + display: inline-block; + vertical-align: middle; + } + +} + + +.moj-page-header-actions__actions { + + @include govuk-media-query($from: tablet) { + display: inline-block; + vertical-align: middle; + } + +} + +.moj-page-header-actions__action { + + &:last-child { + margin-bottom: 0; + } + + @include govuk-media-query($from: tablet) { + margin-bottom: 0; + } + +} + diff --git a/node_modules/@ministryofjustice/frontend/moj/components/page-header-actions/macro.njk b/node_modules/@ministryofjustice/frontend/moj/components/page-header-actions/macro.njk new file mode 100644 index 00000000..f9ce4c3e --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/page-header-actions/macro.njk @@ -0,0 +1,3 @@ +{% macro mojPageHeaderActions(params) %} + {%- include "./template.njk" -%} +{% endmacro %} \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/components/page-header-actions/template.njk b/node_modules/@ministryofjustice/frontend/moj/components/page-header-actions/template.njk new file mode 100644 index 00000000..17d60af1 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/page-header-actions/template.njk @@ -0,0 +1,20 @@ +{%- from "moj/components/button-menu/macro.njk" import mojButtonMenu %} + +
+ +
+ + {{- params.heading.html | safe if params.heading.html else params.heading.text -}} + +
+ + {% if params.items %} +
+ {{mojButtonMenu({ + buttonClasses: 'moj-page-header-actions__action', + items: params.items + })}} +
+ {% endif %} + +
diff --git a/node_modules/@ministryofjustice/frontend/moj/components/pagination/README.md b/node_modules/@ministryofjustice/frontend/moj/components/pagination/README.md new file mode 100644 index 00000000..339679b6 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/pagination/README.md @@ -0,0 +1,5 @@ +# Pagination + +- [Guidance](https://design-patterns.service.justice.gov.uk/components/pagination) + +## Arguments diff --git a/node_modules/@ministryofjustice/frontend/moj/components/pagination/_pagination.scss b/node_modules/@ministryofjustice/frontend/moj/components/pagination/_pagination.scss new file mode 100644 index 00000000..c321d790 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/pagination/_pagination.scss @@ -0,0 +1,114 @@ +.moj-pagination { + // text-align: center; + + @include govuk-media-query($from: desktop) { + + // Alignment adjustments + margin-left: - govuk-spacing(1); + margin-right: - govuk-spacing(1); + + // Hide whitespace between elements + font-size: 0; + + // Trick to remove the need for floats + text-align: justify; + + &:after { + content: ''; + display: inline-block; + width: 100%; + } + } + +} + +.moj-pagination__list { + list-style: none; + margin: 0; + padding: 0; + @include govuk-media-query($from: desktop) { + display: inline-block; + margin-bottom: 0; + vertical-align: middle; + } +} + +.moj-pagination__results { + @include govuk-font(19); + margin-top: 0; + @include govuk-media-query($from: desktop) { + display: inline-block; + margin-bottom: 0; + vertical-align: middle; + } +} + +.moj-pagination__item { + @include govuk-font(19); + display: inline-block; +} + +.moj-pagination__item--active, +.moj-pagination__item--dots { + font-weight: bold; + height: 25px; + padding: govuk-spacing(1) govuk-spacing(2); + text-align: center; +} + +.moj-pagination__item--dots { + padding-left: 0; + padding-right: 0; +} + +.moj-pagination__item--prev .moj-pagination__link:before, +.moj-pagination__item--next .moj-pagination__link:after { + display: inline-block; + height: 10px; + width: 10px; + border-style: solid; + color: govuk-colour("black"); + background: transparent; + -webkit-transform: rotate(-45deg); + -ms-transform: rotate(-45deg); + transform: rotate(-45deg); + content: ""; +} + +.moj-pagination__item--prev .moj-pagination__link:before { + border-width: 3px 0 0 3px; + margin-right: govuk-spacing(1); +} + +.moj-pagination__item--next .moj-pagination__link:after { + border-width: 0 3px 3px 0; + margin-left: govuk-spacing(1); +} + +.moj-pagination__link { + @include govuk-link-common; + @include govuk-link-style-default; + display: block; + padding: govuk-spacing(1); + text-align: center; + text-decoration: none; + min-width: 25px; + + &:link, + &:visited { + color: $govuk-link-colour; + } + + &:hover { + color: govuk-tint($govuk-link-colour, 25); + } + + &:focus { + color: govuk-colour("black"); + } + +} + +.moj-pagination__results { + padding: govuk-spacing(1); +} diff --git a/node_modules/@ministryofjustice/frontend/moj/components/pagination/macro.njk b/node_modules/@ministryofjustice/frontend/moj/components/pagination/macro.njk new file mode 100644 index 00000000..3c23490c --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/pagination/macro.njk @@ -0,0 +1,3 @@ +{% macro mojPagination(params) %} + {%- include "./template.njk" -%} +{% endmacro %} \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/components/pagination/template.njk b/node_modules/@ministryofjustice/frontend/moj/components/pagination/template.njk new file mode 100644 index 00000000..b6fc2a21 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/pagination/template.njk @@ -0,0 +1,33 @@ + diff --git a/node_modules/@ministryofjustice/frontend/moj/components/password-reveal/README.md b/node_modules/@ministryofjustice/frontend/moj/components/password-reveal/README.md new file mode 100644 index 00000000..e098b1ab --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/password-reveal/README.md @@ -0,0 +1,3 @@ +# Password reveal + +- [Guidance](https://design-patterns.service.justice.gov.uk/components/password-reveal) diff --git a/node_modules/@ministryofjustice/frontend/moj/components/password-reveal/_password-reveal.scss b/node_modules/@ministryofjustice/frontend/moj/components/password-reveal/_password-reveal.scss new file mode 100644 index 00000000..42e1ec8a --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/password-reveal/_password-reveal.scss @@ -0,0 +1,16 @@ +/* ========================================================================== + #PASSWORD SHOW/HIDE + ========================================================================== */ + +.moj-password-reveal { + display: flex; + + &__input { + margin-right: govuk-spacing(1); + } + + &__button { + width: 80px; + } + +} \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/components/password-reveal/password-reveal.js b/node_modules/@ministryofjustice/frontend/moj/components/password-reveal/password-reveal.js new file mode 100644 index 00000000..9fcbd5e8 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/password-reveal/password-reveal.js @@ -0,0 +1,31 @@ +MOJFrontend.PasswordReveal = function(element) { + this.el = element; + var $el = $(this.el) + + if ($el.data('moj-password-reveal-initialised')) { + return + } + + $el.data('moj-password-reveal-initialised', true); + $el.attr('spellcheck', 'false'); + + $el.wrap('
'); + this.container = $(this.el).parent(); + this.createButton(); +}; + +MOJFrontend.PasswordReveal.prototype.createButton = function() { + this.button = $(''); + this.container.append(this.button); + this.button.on('click', $.proxy(this, 'onButtonClick')); +}; + +MOJFrontend.PasswordReveal.prototype.onButtonClick = function() { + if (this.el.type === 'password') { + this.el.type = 'text'; + this.button.html('Hide password'); + } else { + this.el.type = 'password'; + this.button.html('Show password'); + } +}; diff --git a/node_modules/@ministryofjustice/frontend/moj/components/primary-navigation/README.md b/node_modules/@ministryofjustice/frontend/moj/components/primary-navigation/README.md new file mode 100644 index 00000000..17b518f1 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/primary-navigation/README.md @@ -0,0 +1,49 @@ +# Primary navigation + +- [Guidance](https://design-patterns.service.justice.gov.uk/components/primary-navigation) + +## Example + +``` +{{ mojPrimaryNavigation({ + label: 'Primary navigation', + items: [{ + text: 'Nav item 1', + href: '#1', + active: true + }, { + text: 'Nav item 2', + href: '#2' + }, { + text: 'Nav item 3', + href: '#3' + }] +}) }} +``` + +## Arguments + +This component accepts the following arguments. + +### Container + +| Name | Type | Required | Description | +| ---------------- | ------ | -------- | ---------------------------------------------------------------------------- | +| label | string | No | The `aria-label` to add to the navigation container. | +| items | array | Yes | An array of navigation item objects. See [items](#items). | +| searchHtml | sting | No | | +| containerClasses | string | No | Classes to add to the parent `div` container. | +| classes | string | No | Classes to add to the `nav` container. | +| attributes | object | No | HTML attributes (for example data attributes) to add to the `nav` container. | + +### Items + +| Name | Type | Required | Description | +| ---------- | ------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------- | +| href | string | Yes | URL of the navigation item anchor. Both href and text attributes for navigation items need to be provided to create an item. | +| text | string | Yes | If `html` is set, this is not required. Text to use within the anchor. If `html` is provided, the `text` argument will be ignored. | +| html | string | Yes | If `text` is set, this is not required. HTML to use within the anchor. If `html` is provided, the `text` argument will be ignored. | +| active | boolean | No | Flag to mark the navigation item as active or not. Defaults to `false`. | +| attributes | object | No | HTML attributes (for example data attributes) to add to the navigation item anchor. | + +_Warning: If you’re using Nunjucks macros in production be aware that using HTML arguments, or ones ending with `.html` can be at risk from [cross-site scripting](https://en.wikipedia.org/wiki/Cross-site_scripting) attacks. More information about security vulnerabilities can be found in the [Nunjucks documentation](https://mozilla.github.io/nunjucks/api.html#user-defined-templates-warning)._ diff --git a/node_modules/@ministryofjustice/frontend/moj/components/primary-navigation/_primary-navigation.scss b/node_modules/@ministryofjustice/frontend/moj/components/primary-navigation/_primary-navigation.scss new file mode 100644 index 00000000..66ce1968 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/primary-navigation/_primary-navigation.scss @@ -0,0 +1,120 @@ +/* ========================================================================== + #PRIMARY NAVIGATION + ========================================================================== */ + +.moj-primary-navigation { + background-color: govuk-colour("light-grey"); +} + +.moj-primary-navigation__container { + @include moj-width-container; + font-size: 0; // Hide whitespace between elements + text-align: justify; // Trick to remove the need for floats + + &:after { + content: ''; + display: inline-block; + width: 100%; + } + +} + +.moj-primary-navigation__nav { + text-align: left; + @include govuk-media-query($from: desktop) { + display: inline-block; + vertical-align: middle; + } + +} + +.moj-primary-navigation__list { + font-size: 0; // Removes white space when using inline-block on child element. + list-style: none; + margin: 0; + padding: 0; +} + +.moj-primary-navigation__item { + @include govuk-font($size: 19); + display: inline-block; + margin-right: govuk-spacing(4); + margin-top: 0; + + &:last-child { + margin-right: 0; + } + +} + +.moj-primary-navigation__link { + @include govuk-link-common; + @include govuk-link-style-default; + display: block; + padding-bottom: 15px; + padding-top: 15px; + text-decoration: none; + font-weight: bold; + + &:link, + &:visited { + color: $govuk-link-colour; + } + + &:hover { + color: govuk-tint($govuk-link-colour, 25); + } + + &:focus { + color: govuk-colour("black"); // Focus colour on yellow should really be black. + position: relative; // Ensure focus sits above everything else. + z-index: 1; + box-shadow: none; + } + + &:focus:before { + background-color: govuk-colour("black"); + content: ""; + display: block; + height: 5px; + position: absolute; bottom: 0; left: 0; + width: 100%; + } + + &[aria-current] { + color: $govuk-link-colour; + position: relative; + text-decoration: none; + font-weight: bold; + &:before { + background-color: $govuk-link-colour; + content: ""; + display: block; + height: 5px; + position: absolute; bottom: 0; left: 0; + width: 100%; + } + + &:focus { + color: govuk-colour("black"); // Focus colour on yellow should really be black. + position: relative; // Ensure focus sits above everything else. + border: none; + + &:before { + background-color: govuk-colour("black"); + } + + } + + } + +} + +.moj-primary-navigation__search { + + @include govuk-media-query($from: desktop) { + display: inline-block; + vertical-align: middle; + } + +} diff --git a/node_modules/@ministryofjustice/frontend/moj/components/primary-navigation/macro.njk b/node_modules/@ministryofjustice/frontend/moj/components/primary-navigation/macro.njk new file mode 100644 index 00000000..67238890 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/primary-navigation/macro.njk @@ -0,0 +1,3 @@ +{% macro mojPrimaryNavigation(params) %} + {%- include "./template.njk" -%} +{% endmacro %} \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/components/primary-navigation/template.njk b/node_modules/@ministryofjustice/frontend/moj/components/primary-navigation/template.njk new file mode 100644 index 00000000..da9a5d72 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/primary-navigation/template.njk @@ -0,0 +1,33 @@ +
+ +
+ +
+ + + +
+ + {%- if params.searchHtml %} + + {% endif -%} + +
+ +
diff --git a/node_modules/@ministryofjustice/frontend/moj/components/progress-bar/README.md b/node_modules/@ministryofjustice/frontend/moj/components/progress-bar/README.md new file mode 100644 index 00000000..269d212f --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/progress-bar/README.md @@ -0,0 +1,8 @@ +# Progress bar + +- [Guidance](https://design-patterns.service.justice.gov.uk/components/progress-bar) + +## Arguments + +| Name | Type | Required | Description | +| ---- | ---- | -------- | ----------- | diff --git a/node_modules/@ministryofjustice/frontend/moj/components/progress-bar/_progress-bar.scss b/node_modules/@ministryofjustice/frontend/moj/components/progress-bar/_progress-bar.scss new file mode 100644 index 00000000..55568a3d --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/progress-bar/_progress-bar.scss @@ -0,0 +1,105 @@ +/* ========================================================================== + #PROGRESS BAR + ========================================================================== */ + +.moj-progress-bar { + margin-bottom: govuk-spacing(7); +} + +.moj-progress-bar__list { + font-size: 0; // Hide white space between elements + list-style: none; + margin: 0; + padding: 0; + position: relative; + text-align: justify; + vertical-align: top; + + &::after { + content: ""; + display: inline-block; + width: 100%; + } + + &::before { + border-top: 6px solid govuk-colour("green"); + content: ""; + left: 0; + position: absolute; + top: 13px; + width: 100%; + } + +} + +.moj-progress-bar__item { + @include govuk-font(19); + display: inline-block; + max-width: 20%; + position: relative; + text-align: center; + vertical-align: top; + + &:first-child, + &:last-child { + &::before { + border-top: 6px solid govuk-colour("white"); + content: ""; + position: absolute; + top: 13px; left: 0; + width: 50%; + } + + } + + &:first-child { + + &::before { + left: 0; + } + + } + + &:last-child { + + &::before { + left: auto; + right: 0; + } + + } + + &[aria-current=step] { // https://tink.uk/using-the-aria-current-attribute + @include govuk-font($size: 19, $weight: "bold"); + } + +} + +.moj-progress-bar__icon { + position: relative; + background-color: govuk-colour("white"); + border: 6px solid govuk-colour("green"); + border-radius: 50%; + box-sizing: border-box; + display: block; + height: 32px; + margin-left: auto; + margin-right: auto; + width: 32px; +} + +.moj-progress-bar__icon--complete { + background-color: govuk-colour("green"); + background-image: url(#{$moj-images-path}icon-progress-tick.svg); + background-position: 50% 50%; + background-repeat: no-repeat; +} + +.moj-progress-bar__label { + @include govuk-font(16); + display: block; + font-weight: inherit; + margin-top: govuk-spacing(3); + position: relative; + word-wrap: break-word; // Just in case +} diff --git a/node_modules/@ministryofjustice/frontend/moj/components/progress-bar/macro.njk b/node_modules/@ministryofjustice/frontend/moj/components/progress-bar/macro.njk new file mode 100644 index 00000000..da8e38b3 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/progress-bar/macro.njk @@ -0,0 +1,3 @@ +{% macro mojProgressBar(params) %} + {%- include "./template.njk" -%} +{% endmacro %} \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/components/progress-bar/template.njk b/node_modules/@ministryofjustice/frontend/moj/components/progress-bar/template.njk new file mode 100644 index 00000000..cbe12196 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/progress-bar/template.njk @@ -0,0 +1,12 @@ +
+
    + {%- for item in params.items %} +
  1. + + + {{- item.label.html | safe if item.label.html else item.label.text -}} + +
  2. + {% endfor -%} +
+
diff --git a/node_modules/@ministryofjustice/frontend/moj/components/rich-text-editor/README.md b/node_modules/@ministryofjustice/frontend/moj/components/rich-text-editor/README.md new file mode 100644 index 00000000..24e50fe0 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/rich-text-editor/README.md @@ -0,0 +1,16 @@ +# Rich text editor + +- [Guidance](https://design-patterns.service.justice.gov.uk/components/rich-text-editor) + +## Example + +``` + +``` + +## Options diff --git a/node_modules/@ministryofjustice/frontend/moj/components/rich-text-editor/_rich-text-editor.scss b/node_modules/@ministryofjustice/frontend/moj/components/rich-text-editor/_rich-text-editor.scss new file mode 100644 index 00000000..b99dda6c --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/rich-text-editor/_rich-text-editor.scss @@ -0,0 +1,73 @@ +/* ========================================================================== + #RICH TEXT EDITOR + ========================================================================== */ + +.moj-rich-text-editor__toolbar { + @include govuk-clearfix; + margin-bottom: govuk-spacing(2); +} + +.moj-rich-text-editor__toolbar-button { + background-color: govuk-colour("white"); + background-position: 50% 50%; + background-repeat: no-repeat; + background-size: 40px 40px; + border: 2px solid govuk-colour("black"); + color: govuk-colour("black"); + cursor: pointer; + float: left; + text-decoration: none; + height: 40px; + margin-left: -2px; + outline: 0; + vertical-align: top; + width: 40px; + + &:first-child { + margin-left: 0; + } + + // Fix unwanted button padding in Firefox + &::-moz-focus-inner { + padding: 0; + border: 0; + } + + &:focus { + background-color: $govuk-focus-colour; + color: $govuk-focus-text-colour; + box-shadow: 0 -2px $govuk-focus-colour, 0 4px $govuk-focus-text-colour; + outline: none; + position: relative; + z-index: 2; + } + +} + +.moj-rich-text-editor__toolbar-button--bold { + background-image: url(#{$moj-images-path}icon-wysiwyg-bold.svg); +} + +.moj-rich-text-editor__toolbar-button--italic { + background-image: url(#{$moj-images-path}icon-wysiwyg-italic.svg); +} + +.moj-rich-text-editor__toolbar-button--underline { + background-image: url(#{$moj-images-path}icon-wysiwyg-underline.svg); +} + +.moj-rich-text-editor__toolbar-button--unordered-list { + background-image: url(#{$moj-images-path}icon-wysiwyg-unordered-list.svg); + margin-left: govuk-spacing(2); +} + +.moj-rich-text-editor__toolbar-button--ordered-list { + background-image: url(#{$moj-images-path}icon-wysiwyg-ordered-list.svg); +} + +.moj-rich-text-editor__content { + min-height: 130px; + outline: none; + overflow: auto; + resize: vertical; +} diff --git a/node_modules/@ministryofjustice/frontend/moj/components/rich-text-editor/rich-text-editor.js b/node_modules/@ministryofjustice/frontend/moj/components/rich-text-editor/rich-text-editor.js new file mode 100644 index 00000000..6e0e5722 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/rich-text-editor/rich-text-editor.js @@ -0,0 +1,139 @@ +if('contentEditable' in document.documentElement) { + MOJFrontend.RichTextEditor = function(options) { + this.options = options; + this.options.toolbar = this.options.toolbar || { + bold: false, + italic: false, + underline: false, + bullets: true, + numbers: true + }; + this.textarea = this.options.textarea; + this.container = $(this.textarea).parent(); + + if (this.container.data('moj-rich-text-editor-initialised')) { + return + } + + this.container.data('moj-rich-text-editor-initialised', true); + + this.createToolbar(); + this.hideDefault(); + this.configureToolbar(); + this.keys = { + left: 37, + right: 39, + up: 38, + down: 40 + }; + this.container.on('click', '.moj-rich-text-editor__toolbar-button', $.proxy(this, 'onButtonClick')); + this.container.find('.moj-rich-text-editor__content').on('input', $.proxy(this, 'onEditorInput')); + this.container.find('label').on('click', $.proxy(this, 'onLabelClick')); + this.toolbar.on('keydown', $.proxy(this, 'onToolbarKeydown')); + }; + + MOJFrontend.RichTextEditor.prototype.onToolbarKeydown = function(e) { + var focusableButton; + switch(e.keyCode) { + case this.keys.right: + case this.keys.down: + focusableButton = this.toolbar.find('button[tabindex=0]'); + var nextButton = focusableButton.next('button'); + if(nextButton[0]) { + nextButton.focus(); + focusableButton.attr('tabindex', '-1'); + nextButton.attr('tabindex', '0'); + } + break; + case this.keys.left: + case this.keys.up: + focusableButton = this.toolbar.find('button[tabindex=0]'); + var previousButton = focusableButton.prev('button'); + if(previousButton[0]) { + previousButton.focus(); + focusableButton.attr('tabindex', '-1'); + previousButton.attr('tabindex', '0'); + } + break; + } + }; + + MOJFrontend.RichTextEditor.prototype.getToolbarHtml = function() { + var html = ''; + + html += ''; + return html; + }; + + MOJFrontend.RichTextEditor.prototype.getEnhancedHtml = function(val) { + return this.getToolbarHtml() + '
'; + }; + + MOJFrontend.RichTextEditor.prototype.hideDefault = function() { + this.textarea = this.container.find('textarea'); + this.textarea.addClass('govuk-visually-hidden'); + this.textarea.attr('aria-hidden', true); + this.textarea.attr('tabindex', '-1'); + }; + + MOJFrontend.RichTextEditor.prototype.createToolbar = function() { + this.toolbar = document.createElement('div'); + this.toolbar.className = 'moj-rich-text-editor'; + this.toolbar.innerHTML = this.getEnhancedHtml(); + this.container.append(this.toolbar); + this.toolbar = this.container.find('.moj-rich-text-editor__toolbar'); + this.container.find('.moj-rich-text-editor__content').html(this.textarea.val()); + }; + + MOJFrontend.RichTextEditor.prototype.configureToolbar = function() { + this.buttons = this.container.find('.moj-rich-text-editor__toolbar-button'); + this.buttons.prop('tabindex', '-1'); + var firstTab = this.buttons.first(); + firstTab.prop('tabindex', '0'); + }; + + MOJFrontend.RichTextEditor.prototype.onButtonClick = function(e) { + document.execCommand($(e.currentTarget).data('command'), false, null); + }; + + MOJFrontend.RichTextEditor.prototype.getContent = function() { + return this.container.find('.moj-rich-text-editor__content').html(); + }; + + MOJFrontend.RichTextEditor.prototype.onEditorInput = function(e) { + this.updateTextarea(); + }; + + MOJFrontend.RichTextEditor.prototype.updateTextarea = function() { + document.execCommand('defaultParagraphSeparator', false, 'p'); + this.textarea.val(this.getContent()); + }; + + MOJFrontend.RichTextEditor.prototype.onLabelClick = function(e) { + e.preventDefault(); + this.container.find('.moj-rich-text-editor__content').focus(); + }; + +} diff --git a/node_modules/@ministryofjustice/frontend/moj/components/search-toggle/README.md b/node_modules/@ministryofjustice/frontend/moj/components/search-toggle/README.md new file mode 100644 index 00000000..5b2c4376 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/search-toggle/README.md @@ -0,0 +1 @@ +# Search toggle diff --git a/node_modules/@ministryofjustice/frontend/moj/components/search-toggle/search-toggle.js b/node_modules/@ministryofjustice/frontend/moj/components/search-toggle/search-toggle.js new file mode 100644 index 00000000..2f128359 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/search-toggle/search-toggle.js @@ -0,0 +1,26 @@ +MOJFrontend.SearchToggle = function(options) { + this.options = options; + + if (this.options.search.container.data('moj-search-toggle-initialised')) { + return + } + + this.options.search.container.data('moj-search-toggle-initialised', true); + + const svg = ''; + + this.toggleButton = $(''); + this.toggleButton.on('click', $.proxy(this, 'onToggleButtonClick')); + this.options.toggleButton.container.append(this.toggleButton); +}; + +MOJFrontend.SearchToggle.prototype.onToggleButtonClick = function() { + if(this.toggleButton.attr('aria-expanded') == 'false') { + this.toggleButton.attr('aria-expanded', 'true'); + this.options.search.container.removeClass('moj-js-hidden'); + this.options.search.container.find('input').first().focus(); + } else { + this.options.search.container.addClass('moj-js-hidden'); + this.toggleButton.attr('aria-expanded', 'false'); + } +}; diff --git a/node_modules/@ministryofjustice/frontend/moj/components/search-toggle/search-toggle.scss b/node_modules/@ministryofjustice/frontend/moj/components/search-toggle/search-toggle.scss new file mode 100644 index 00000000..c4f00ccc --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/search-toggle/search-toggle.scss @@ -0,0 +1,69 @@ +.moj-search-toggle__button { + @include govuk-font($size: 19, $weight: bold); + background-color: transparent; + border: none; + color: $govuk-link-colour; + cursor: pointer; + display: inline-block; + padding-top: 12px; + padding-bottom: 13px; + padding-left: 0; + padding-right: 0; + -webkit-font-smoothing: antialiased; + -webkit-appearance: none; + + &__icon { + display: inline-block; + height: 20px; + margin-left: govuk-spacing(2); + vertical-align: middle; + width: 20px; + fill: currentColor; + + @media screen and (forced-colors: active) { + fill: windowText; + } + } + + &:focus { + background-color: $govuk-focus-colour; + color: $govuk-focus-text-colour; + box-shadow: 0 -2px $govuk-focus-colour, 0 4px $govuk-focus-text-colour; + outline: none; + position: relative; + z-index: 1; + } +} + +.moj-search--toggle { + padding: govuk-spacing(3); + + @include govuk-media-query($until: desktop) { + padding-left: 0 !important; + padding-right: 0 !important; + } +} + +// JS enabled +.js-enabled .moj-search--toggle { + @include govuk-media-query($until: desktop) { + padding-top: 0 !important; + } +} + +.js-enabled .moj-search-toggle { + position: relative; +} + +.js-enabled .moj-search-toggle__search { + background-color: govuk-colour("light-grey"); + + @include govuk-media-query($from: desktop) { + max-width: 450px; + position: absolute; + right: -15px; + top: 50px; // Height of nav bar + width: 450px; + z-index: 10; + } +} diff --git a/node_modules/@ministryofjustice/frontend/moj/components/search/README.md b/node_modules/@ministryofjustice/frontend/moj/components/search/README.md new file mode 100644 index 00000000..433c4d11 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/search/README.md @@ -0,0 +1,5 @@ +# Search + +- [Guidance](https://design-patterns.service.justice.gov.uk/components/search) + +## Arguments diff --git a/node_modules/@ministryofjustice/frontend/moj/components/search/_search.scss b/node_modules/@ministryofjustice/frontend/moj/components/search/_search.scss new file mode 100644 index 00000000..a6fa71b9 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/search/_search.scss @@ -0,0 +1,42 @@ +.moj-search { + font-size: 0; // Fallback +} + +.moj-search form { + align-items: flex-end; + display: flex; +} + +.moj-search .govuk-form-group { + display: inline-block; + flex: 1; + margin-bottom: 0; + vertical-align: top; +} + +.moj-search__label, +.moj-search__hint { + text-align: left; +} + +.moj-search__input:focus { + position: relative; + z-index: 1; +} + +.moj-search__button { + display: inline-block; + margin-bottom: 0; + margin-left: govuk-spacing(2); + position: relative; + top: -2px; // Override default gov properties due to active pixel movement + vertical-align: bottom; + width: auto; +} + +.moj-search--inline { + padding: govuk-spacing(2) 0 !important; + @include govuk-media-query($from: desktop) { + padding: 0 !important; + } +} \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/components/search/macro.njk b/node_modules/@ministryofjustice/frontend/moj/components/search/macro.njk new file mode 100644 index 00000000..d569b513 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/search/macro.njk @@ -0,0 +1,3 @@ +{% macro mojSearch(params) %} + {%- include "./template.njk" -%} +{% endmacro %} \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/components/search/template.njk b/node_modules/@ministryofjustice/frontend/moj/components/search/template.njk new file mode 100644 index 00000000..24c5225f --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/search/template.njk @@ -0,0 +1,34 @@ +{%- from "govuk/components/input/macro.njk" import govukInput %} +{%- from "govuk/components/button/macro.njk" import govukButton %} + + diff --git a/node_modules/@ministryofjustice/frontend/moj/components/side-navigation/README.md b/node_modules/@ministryofjustice/frontend/moj/components/side-navigation/README.md new file mode 100644 index 00000000..3b9754c7 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/side-navigation/README.md @@ -0,0 +1,65 @@ +# Side navigation + +- [Guidance](https://design-patterns.service.justice.gov.uk/components/side-navigation) + +## Example + +``` +{{ mojSideNavigation({ + label: 'Side navigation', + items: [{ + text: 'Nav item 1', + href: '#1', + active: true + }, { + text: 'Nav item 2', + href: '#2' + }, { + text: 'Nav item 3', + href: '#3' + }] +}) }} +``` + +## Arguments + +This component accepts the following arguments. + +### Container + +| Name | Type | Required | Description | +| ---------- | ------ | -------- | ---------------------------------------------------------------------------- | +| label | string | No | The `aria-label` to add to the navigation container. | +| items | array | Yes | An array of navigation item objects. See [items](#items). | +| sections | array | No | An array of navigation section objects. See [sections](#sections). | +| classes | string | No | Classes to add to the `nav` container. | +| attributes | object | No | HTML attributes (for example data attributes) to add to the `nav` container. | + +### Sections + +| Name | Type | Required | Description | +| ------- | ------ | -------- | --------------------------------------------------------- | +| items | array | Yes | An array of navigation item objects. See [items](#items). | +| heading | object | Yes | See [heading](#headings) | + +#### Headings + +| Name | Type | Required | Description | +| ------------ | ------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------- | +| headingLevel | numeric | No | A number for the heading level. Defaults to 4 (`

`) | +| text | string | Yes | If `html` is set, this is not required. Text to use within the heading. If `html` is provided, the `text` argument will be ignored. | +| html | string | Yes | If `text` is set, this is not required. HTML to use within the heading. If `html` is provided, the `text` argument will be ignored. | +| classes | string | No | Classes to add to the heading. | +| attributes | object | No | HTML attributes (for example data attributes) to add to the navigation item anchor. | + +### Items + +| Name | Type | Required | Description | +| ---------- | ------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------- | +| href | string | Yes | URL of the navigation item anchor. Both href and text attributes for navigation items need to be provided to create an item. | +| text | string | Yes | If `html` is set, this is not required. Text to use within the anchor. If `html` is provided, the `text` argument will be ignored. | +| html | string | Yes | If `text` is set, this is not required. HTML to use within the anchor. If `html` is provided, the `text` argument will be ignored. | +| active | boolean | No | Flag to mark the navigation item as active or not. Defaults to `false`. | +| attributes | object | No | HTML attributes (for example data attributes) to add to the navigation item anchor. | + +_Warning: If you’re using Nunjucks macros in production be aware that using HTML arguments, or ones ending with `.html` can be at risk from [cross-site scripting](https://en.wikipedia.org/wiki/Cross-site_scripting) attacks. More information about security vulnerabilities can be found in the [Nunjucks documentation](https://mozilla.github.io/nunjucks/api.html#user-defined-templates-warning)._ diff --git a/node_modules/@ministryofjustice/frontend/moj/components/side-navigation/_side-navigation.scss b/node_modules/@ministryofjustice/frontend/moj/components/side-navigation/_side-navigation.scss new file mode 100644 index 00000000..143f953e --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/side-navigation/_side-navigation.scss @@ -0,0 +1,125 @@ +/* ========================================================================== + #SIDE NAVIGATION + ========================================================================== */ + +.moj-side-navigation { + @include govuk-font(16); + + @include govuk-media-query($until: tablet) { + display: flex; + overflow-x: scroll; + } + + @include govuk-media-query($from: tablet) { + display: block; + padding: govuk-spacing(4) 0 0; + } + +} + +.moj-side-navigation__title { + @include govuk-font($size: 19); + color: govuk-colour("dark-grey"); + font-weight: normal; + margin: 0; + padding: govuk-spacing(2); + padding-left: govuk-spacing(2) + 4px; + + @include govuk-media-query($until: tablet) { + display: none; + } + +} + +.moj-side-navigation__list { + list-style: none; + margin: 0; + padding: 0; + + @include govuk-media-query($until: tablet) { + display: flex; + margin: 0; + white-space: nowrap; + } + + @include govuk-media-query($from: tablet) { + margin-bottom: govuk-spacing(4); + } +} + +.moj-side-navigation__item { + + @include govuk-media-query($until: tablet) { + display: flex; + } + + a, + a:link, + a:visited { + background-color: inherit; + color: $govuk-link-colour; + display: block; + text-decoration: none; + + @include govuk-media-query($until: tablet) { + border-bottom: 4px solid transparent; + padding: govuk-spacing(3); + padding-bottom: govuk-spacing(3) - 4px; // Compensate for 4px border + } + + @include govuk-media-query($from: tablet) { + background-color: inherit; + border-left: 4px solid transparent; + padding: govuk-spacing(2); + } + + + } + + a:hover { + border-color: govuk-tint($govuk-link-colour, 25); + } + + a:focus { + color: $govuk-focus-text-colour; + background-color: $govuk-focus-colour; + box-shadow: 0 -2px $govuk-focus-colour, 0 4px $govuk-focus-text-colour; + border-color: $govuk-focus-text-colour; + border-left-color: transparent; + position: relative; + } + +} + +.moj-side-navigation__item--active { + + a:link, + a:visited { + border-color: $govuk-link-colour; + color: $govuk-link-colour; + font-weight: bold; + } + + a:focus { + color: $govuk-focus-text-colour; + background-color: $govuk-focus-colour; + box-shadow: 0 -2px $govuk-focus-colour, 0 4px $govuk-focus-text-colour; + border-color: $govuk-focus-text-colour; + border-left-color: transparent; + } + + @include govuk-media-query($from: tablet) { + a:link, + a:visited { + background-color: govuk-colour("light-grey"); + } + + a:focus { + color: $govuk-focus-text-colour; + background-color: $govuk-focus-colour; + border-color: transparent; + } + } + + +} diff --git a/node_modules/@ministryofjustice/frontend/moj/components/side-navigation/macro.njk b/node_modules/@ministryofjustice/frontend/moj/components/side-navigation/macro.njk new file mode 100644 index 00000000..c8e57165 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/side-navigation/macro.njk @@ -0,0 +1,3 @@ +{% macro mojSideNavigation(params) %} + {%- include "./template.njk" -%} +{% endmacro %} \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/components/side-navigation/template.njk b/node_modules/@ministryofjustice/frontend/moj/components/side-navigation/template.njk new file mode 100644 index 00000000..fb2b0d1e --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/side-navigation/template.njk @@ -0,0 +1,28 @@ + \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/components/sortable-table/README.md b/node_modules/@ministryofjustice/frontend/moj/components/sortable-table/README.md new file mode 100644 index 00000000..6675b6ff --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/sortable-table/README.md @@ -0,0 +1,5 @@ +# Sortable table + +- [Guidance](https://design-patterns.service.justice.gov.uk/components/sortable-table) + +## Arguments diff --git a/node_modules/@ministryofjustice/frontend/moj/components/sortable-table/_sortable-table.scss b/node_modules/@ministryofjustice/frontend/moj/components/sortable-table/_sortable-table.scss new file mode 100644 index 00000000..3eef8b6a --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/sortable-table/_sortable-table.scss @@ -0,0 +1,66 @@ +[aria-sort] button, +[aria-sort] button:hover { + background-color: transparent; + border-width: 0; + -webkit-box-shadow: 0 0 0 0; + -moz-box-shadow: 0 0 0 0; + box-shadow: 0 0 0 0; + color: #005ea5; + cursor: pointer; + font-family: inherit; + font-size: inherit; + font-weight: inherit; + padding: 0 10px 0 0; + position: relative; + text-align: inherit; + font-size: 1em; + margin: 0; +} + +[aria-sort] button:focus { + background-color: $govuk-focus-colour; + color: $govuk-focus-text-colour; + box-shadow: 0 -2px $govuk-focus-colour, 0 4px $govuk-focus-text-colour; + outline: none; +} + +[aria-sort]:first-child button { + right: auto; +} + +[aria-sort] button:before { + content: " \25bc"; + position: absolute; + right: -1px; + top: 9px; + font-size: 0.5em; +} + +[aria-sort] button:after { + content: " \25b2"; + position: absolute; + right: -1px; + top: 1px; + font-size: 0.5em; +} + +[aria-sort="ascending"] button:before, +[aria-sort="descending"] button:before { + content: none; +} + +[aria-sort="ascending"] button:after { + content: " \25b2"; + font-size: .8em; + position: absolute; + right: -5px; + top: 2px; +} + +[aria-sort="descending"] button:after { + content: " \25bc"; + font-size: .8em; + position: absolute; + right: -5px; + top: 2px; +} \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/components/sortable-table/sortable-table.js b/node_modules/@ministryofjustice/frontend/moj/components/sortable-table/sortable-table.js new file mode 100644 index 00000000..5d9a459b --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/sortable-table/sortable-table.js @@ -0,0 +1,139 @@ +MOJFrontend.SortableTable = function(params) { + this.table = $(params.table); + + if (this.table.data('moj-search-toggle-initialised')) { + return + } + + this.table.data('moj-search-toggle-initialised', true); + + this.setupOptions(params); + this.body = this.table.find('tbody'); + this.createHeadingButtons(); + this.createStatusBox(); + this.initialiseSortedColumn(); + this.table.on('click', 'th button', $.proxy(this, 'onSortButtonClick')); +}; + +MOJFrontend.SortableTable.prototype.setupOptions = function(params) { + params = params || {}; + this.statusMessage = params.statusMessage || 'Sort by %heading% (%direction%)'; + this.ascendingText = params.ascendingText || 'ascending'; + this.descendingText = params.descendingText || 'descending'; +}; + +MOJFrontend.SortableTable.prototype.createHeadingButtons = function() { + var headings = this.table.find('thead th'); + var heading; + for(var i = 0; i < headings.length; i++) { + heading = $(headings[i]); + if(heading.attr('aria-sort')) { + this.createHeadingButton(heading, i); + } + } +}; + +MOJFrontend.SortableTable.prototype.createHeadingButton = function(heading, i) { + var text = heading.text(); + var button = $(''); + heading.text(''); + heading.append(button); +}; + +MOJFrontend.SortableTable.prototype.createStatusBox = function() { + this.status = $('
'); + this.table.parent().append(this.status); +}; + +MOJFrontend.SortableTable.prototype.initialiseSortedColumn = function () { + var rows = this.getTableRowsArray(); + + this.table.find("th") + .filter('[aria-sort="ascending"], [aria-sort="descending"]') + .first() + .each((index, el) => { + var sortDirection = $(el).attr('aria-sort'); + var columnNumber = $(el).find('button').attr('data-index'); + var sortedRows = this.sort(rows, columnNumber, sortDirection); + this.addRows(sortedRows); + }) +}; + +MOJFrontend.SortableTable.prototype.onSortButtonClick = function(e) { + var columnNumber = e.currentTarget.getAttribute('data-index'); + var sortDirection = $(e.currentTarget).parent().attr('aria-sort'); + var newSortDirection; + if(sortDirection === 'none' || sortDirection === 'descending') { + newSortDirection = 'ascending'; + } else { + newSortDirection = 'descending'; + } + var rows = this.getTableRowsArray(); + var sortedRows = this.sort(rows, columnNumber, newSortDirection); + this.addRows(sortedRows); + this.removeButtonStates(); + this.updateButtonState($(e.currentTarget), newSortDirection); +}; + +MOJFrontend.SortableTable.prototype.updateButtonState = function(button, direction) { + button.parent().attr('aria-sort', direction); + var message = this.statusMessage; + message = message.replace(/%heading%/, button.text()); + message = message.replace(/%direction%/, this[direction+'Text']); + this.status.text(message); +}; + +MOJFrontend.SortableTable.prototype.removeButtonStates = function() { + this.table.find('thead th').attr('aria-sort', 'none'); +}; + +MOJFrontend.SortableTable.prototype.addRows = function(rows) { + for(var i = 0; i < rows.length; i++) { + this.body.append(rows[i]); + } +}; + +MOJFrontend.SortableTable.prototype.getTableRowsArray = function() { + var rows = []; + var trs = this.body.find('tr'); + for (var i = 0; i < trs.length; i++) { + rows.push(trs[i]); + } + return rows; +}; + +MOJFrontend.SortableTable.prototype.sort = function(rows, columnNumber, sortDirection) { + var newRows = rows.sort($.proxy(function(rowA, rowB) { + var tdA = $(rowA).find('td,th').eq(columnNumber); + var tdB = $(rowB).find('td,th').eq(columnNumber); + var valueA = this.getCellValue(tdA); + var valueB = this.getCellValue(tdB); + if(sortDirection === 'ascending') { + if(valueA < valueB) { + return -1; + } + if(valueA > valueB) { + return 1; + } + return 0; + } else { + if(valueB < valueA) { + return -1; + } + if(valueB > valueA) { + return 1; + } + return 0; + } + }, this)); + return newRows; +}; + +MOJFrontend.SortableTable.prototype.getCellValue = function(cell) { + var val = cell.attr('data-sort-value'); + val = val || cell.html(); + if($.isNumeric(val)) { + val = parseInt(val, 10); + } + return val; +}; diff --git a/node_modules/@ministryofjustice/frontend/moj/components/sub-navigation/README.md b/node_modules/@ministryofjustice/frontend/moj/components/sub-navigation/README.md new file mode 100644 index 00000000..54ab3fc3 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/sub-navigation/README.md @@ -0,0 +1,48 @@ +# Sub navigation + +- [Guidance](https://design-patterns.service.justice.gov.uk/components/sub-navigation) + +## Example + +``` +{{ mojSubNavigation({ + label: 'Sub navigation', + items: [{ + text: 'Nav item 1', + href: '#1', + active: true + }, { + text: 'Nav item 2', + href: '#2' + }, { + text: 'Nav item 3', + href: '#3' + }] +}) }} +``` + +## Arguments + +This component accepts the following arguments. + +### Container + +| Name | Type | Required | Description | +| ---------- | ------ | -------- | ---------------------------------------------------------------------------- | +| label | string | No | The `aria-label` to add to the `nav` container. | +| items | array | Yes | An array of navigation item objects. See [items](#items). | +| classes | string | No | Classes to add to the `nav` container. | +| attributes | object | No | HTML attributes (for example data attributes) to add to the `nav` container. | + +### Items + +| Name | Type | Required | Description | +| ---------- | ------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------- | +| href | string | Yes | URL of the navigation item anchor. Both href and text attributes for navigation items need to be provided to create an item. | +| text | string | Yes | If `html` is set, this is not required. Text to use within the anchor. If `html` is provided, the `text` argument will be ignored. | +| html | string | Yes | If `text` is set, this is not required. HTML to use within the anchor. If `html` is provided, the `text` argument will be ignored. | +| active | boolean | No | Flag to mark the navigation item as active or not. Defaults to `false`. | +| classes | string | No | Classes to add to the list `li` item. | +| attributes | object | No | HTML attributes (for example data attributes) to add to the navigation item anchor. | + +_Warning: If you’re using Nunjucks macros in production be aware that using HTML arguments, or ones ending with `.html` can be at risk from [cross-site scripting](https://en.wikipedia.org/wiki/Cross-site_scripting) attacks. More information about security vulnerabilities can be found in the [Nunjucks documentation](https://mozilla.github.io/nunjucks/api.html#user-defined-templates-warning)._ diff --git a/node_modules/@ministryofjustice/frontend/moj/components/sub-navigation/_sub-navigation.scss b/node_modules/@ministryofjustice/frontend/moj/components/sub-navigation/_sub-navigation.scss new file mode 100644 index 00000000..efc66525 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/sub-navigation/_sub-navigation.scss @@ -0,0 +1,108 @@ +/* ========================================================================== + #SECONDARY NAV + ========================================================================== */ + +.moj-sub-navigation { + margin-bottom: govuk-spacing(7); +} + + +.moj-sub-navigation__list { + font-size: 0; // Removes white space when using inline-block on child element. + list-style: none; + margin: 0; + padding: 0; + + @include govuk-media-query($from: tablet) { + box-shadow: inset 0 -1px 0 $govuk-border-colour; + width: 100%; + } +} + + +.moj-sub-navigation__item { + @include govuk-font(19); + box-shadow: inset 0 -1px 0 $govuk-border-colour; + display: block; + margin-top: -1px; + + &:last-child { + box-shadow: none; + } + + @include govuk-media-query($from: tablet) { + box-shadow: none; + display: inline-block; + margin-right: govuk-spacing(4); + margin-top: 0; + } + +} + + +.moj-sub-navigation__link { + @include govuk-link-common; + @include govuk-link-style-default; + display: block; + padding-top: 12px; + padding-bottom: 12px; + padding-left: govuk-spacing(3); + text-decoration: none; + position: relative; + + @include govuk-media-query($from: tablet) { + padding-left: 0; + } + + &:link, + &:visited { + color: $govuk-link-colour; + } + + &:hover { + color: govuk-tint($govuk-link-colour, 25); + } + + &:focus { + color: govuk-colour("black"); // Focus colour on yellow should really be black. + position: relative; // Ensure focus sits above everything else. + box-shadow: none; + } + + &:focus:before { + background-color: govuk-colour("black"); + content: ""; + display: block; + width: 100%; + position: absolute; bottom: 0; left: 0; right: 0; + height: 5px; + } + +} + + +.moj-sub-navigation__link[aria-current="page"] { + color: $govuk-link-active-colour; + position: relative; + text-decoration: none; + + &:before { + background-color: $govuk-link-colour; + content: ""; + display: block; + height: 100%; + position: absolute; bottom: 0; left: 0; + width: 5px; + + @include govuk-media-query($from: tablet) { + height: 5px; + width: 100%; + } + + } + + &:focus:before { + background-color: govuk-colour("black"); + } + +} diff --git a/node_modules/@ministryofjustice/frontend/moj/components/sub-navigation/macro.njk b/node_modules/@ministryofjustice/frontend/moj/components/sub-navigation/macro.njk new file mode 100644 index 00000000..370a2a07 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/sub-navigation/macro.njk @@ -0,0 +1,3 @@ +{% macro mojSubNavigation(params) %} + {%- include "./template.njk" -%} +{% endmacro %} \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/components/sub-navigation/template.njk b/node_modules/@ministryofjustice/frontend/moj/components/sub-navigation/template.njk new file mode 100644 index 00000000..8d616990 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/sub-navigation/template.njk @@ -0,0 +1,15 @@ + diff --git a/node_modules/@ministryofjustice/frontend/moj/components/tag/README.md b/node_modules/@ministryofjustice/frontend/moj/components/tag/README.md new file mode 100644 index 00000000..63ba37ad --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/tag/README.md @@ -0,0 +1,28 @@ +# Badge + +- [Guidance](https://design-patterns.service.justice.gov.uk/components/tag) + +## Classes + +| Name | Colour code | Colour contrast | +| ---------------------- | ----------- | --------------- | +| moj-tag--purple | #2e358b | | +| moj-tag--light-purple | #6f72af | | +| moj-tag--bright-purple | #912b88 | | +| moj-tag--pink | #d53880 | | +| moj-tag--light-pink | #f499be | | +| moj-tag--red | #b10e1e | | +| moj-tag--orange | #f47738 | | +| moj-tag--brown | #b58840 | | +| moj-tag--yellow | #ffbf47 | | +| moj-tag--light-green | #85994b | | +| moj-tag--green | #006435 | | +| moj-tag--turquoise | #28a197 | | +| moj-tag--light-blue | #2b8cc4 | | +| moj-tag--blue | #005ea5 | | +| moj-tag--black | #0b0c0c | | +| moj-tag--dark-grey | #6f777b | | +| moj-tag--mid-grey | #bfc1c3 | | +| moj-tag--light-grey | #dee0e2 | | +| moj-tag--light-grey | #f8f8f8 | | +| moj-tag--white | #ffffff | | diff --git a/node_modules/@ministryofjustice/frontend/moj/components/tag/_tag.scss b/node_modules/@ministryofjustice/frontend/moj/components/tag/_tag.scss new file mode 100644 index 00000000..18d79aa2 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/tag/_tag.scss @@ -0,0 +1,55 @@ +/* ========================================================================== + #TAG + ========================================================================== */ + +.moj-tag { + border: 2px solid $govuk-brand-colour; + background-color: $govuk-brand-colour; + color: govuk-colour("white"); + + &--purple { + border: 2px solid govuk-colour("purple"); + background-color: govuk-colour("purple"); + color: govuk-colour("white"); + } + + &--bright-purple { + border: 2px solid govuk-colour("bright-purple"); + background-color: govuk-colour("bright-purple"); + color: govuk-colour("white"); + } + + &--red, + &--error { + border: 2px solid govuk-colour("red"); + background-color: govuk-colour("red"); + color: govuk-colour("white"); + } + + &--green, + &--success { + border: 2px solid govuk-colour("green"); + background-color: govuk-colour("green"); + color: govuk-colour("white"); + } + + &--blue, + &--information { + border: 2px solid govuk-colour("blue"); + background-color: govuk-colour("blue"); + color: govuk-colour("white"); + } + + &--black { + border: 2px solid govuk-colour("black"); + background-color: govuk-colour("black"); + color: govuk-colour("white"); + } + + &--grey { + border: 2px solid govuk-colour("dark-grey"); + background-color: govuk-colour("dark-grey"); + color: govuk-colour("white"); + } + +} diff --git a/node_modules/@ministryofjustice/frontend/moj/components/task-list/README.md b/node_modules/@ministryofjustice/frontend/moj/components/task-list/README.md new file mode 100644 index 00000000..be5cf289 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/task-list/README.md @@ -0,0 +1,85 @@ +# Task list + +- [Guidance](https://design-patterns.service.justice.gov.uk/patterns/task-list) + +## Example + +``` +{{ mojTaskList({ + sections: [ + { + heading: { + text: 'Section 1' + }, + items: [{ + text: 'Item 1.1', + href: '#', + complete: true + }, { + text: 'Item 1.2', + href: '#' + }, { + text: 'Item 1.3', + href: '#' + }] + }, + { + heading: { + text: 'Section 2' + }, + items: [{ + text: 'Item 2.1', + href: '#' + }, { + text: 'Item 2.2', + href: '#' + }, { + text: 'Item 2.3', + href: '#' + }] + } + ] +}) }} +``` + +## Arguments + +This component accepts the following arguments. + +### Container + +| Name | Type | Required | Description | +| ---------- | ------ | -------- | ---------------------------------------------------------------------------------- | +| sections | array | No | An array of section objects containing task list items. See [sections](#sections). | +| classes | string | No | Classes to add to the `nav` container. | +| attributes | object | No | HTML attributes (for example data attributes) to add to the `ol` container. | + +### Sections + +| Name | Type | Required | Description | +| ---------- | ------ | -------- | ------------------------------------------------------------------------- | +| items | array | Yes | An array of task list item objects. See [items](#items). | +| heading | object | Yes | See [heading](#headings) | +| attributes | object | No | HTML attributes (for example data attributes) to add to the section `li`. | + +#### Headings + +| Name | Type | Required | Description | +| ------------ | ------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------- | +| headingLevel | numeric | No | A number for the heading level. Defaults to 2 (`

`) | +| text | string | Yes | If `html` is set, this is not required. Text to use within the heading. If `html` is provided, the `text` argument will be ignored. | +| html | string | Yes | If `text` is set, this is not required. HTML to use within the heading. If `html` is provided, the `text` argument will be ignored. | +| classes | string | No | Classes to add to the heading. | +| attributes | object | No | HTML attributes (for example data attributes) to add to the item anchor. | + +#### Items + +| Name | Type | Required | Description | +| ---------- | ------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------- | +| href | string | Yes | URL of the item anchor. Both href and text attributes for items need to be provided to create an item. | +| text | string | Yes | If `html` is set, this is not required. Text to use within the anchor. If `html` is provided, the `text` argument will be ignored. | +| html | string | Yes | If `text` is set, this is not required. HTML to use within the anchor. If `html` is provided, the `text` argument will be ignored. | +| complete | boolean | No | Flag to mark the item as complete or not. Defaults to `false`. | +| attributes | object | No | HTML attributes (for example data attributes) to add to the item anchor. | + +_Warning: If you’re using Nunjucks macros in production be aware that using HTML arguments, or ones ending with `.html` can be at risk from [cross-site scripting](https://en.wikipedia.org/wiki/Cross-site_scripting) attacks. More information about security vulnerabilities can be found in the [Nunjucks documentation](https://mozilla.github.io/nunjucks/api.html#user-defined-templates-warning)._ diff --git a/node_modules/@ministryofjustice/frontend/moj/components/task-list/_task-list.scss b/node_modules/@ministryofjustice/frontend/moj/components/task-list/_task-list.scss new file mode 100644 index 00000000..8cfe82d9 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/task-list/_task-list.scss @@ -0,0 +1,68 @@ +/* ========================================================================== + #TASK LIST + ========================================================================== */ + +.moj-task-list { + list-style-type: none; + padding-left: 0; + margin-top: 0; + margin-bottom: 0; + @include govuk-media-query($from: tablet) { + min-width: 550px; + } +} + +.moj-task-list__section { + display: table; + @include govuk-font($size:24, $weight: bold); +} + +.moj-task-list__section-number { + display: table-cell; + + @include govuk-media-query($from: tablet) { + min-width: govuk-spacing(6); + padding-right: 0; + } +} + +.moj-task-list__items { + @include govuk-font($size: 19); + @include govuk-responsive-margin(9, "bottom"); + list-style: none; + padding-left: 0; + @include govuk-media-query($from: tablet) { + padding-left: govuk-spacing(6); + } +} + +.moj-task-list__item { + border-bottom: 1px solid $govuk-border-colour; + margin-bottom: 0 !important; + padding-top: govuk-spacing(2); + padding-bottom: govuk-spacing(2); + @include govuk-clearfix; +} + +.moj-task-list__item:first-child { + border-top: 1px solid $govuk-border-colour; +} + +.moj-task-list__task-name { + display: block; + @include govuk-media-query($from: 450px) { + float: left; + width: 75%; + } +} + +.moj-task-list__task-completed { + margin-top: govuk-spacing(2); + margin-bottom: govuk-spacing(1); + + @include govuk-media-query($from: 450px) { + float: right; + margin-top: 0; + margin-bottom: 0; + } +} diff --git a/node_modules/@ministryofjustice/frontend/moj/components/task-list/macro.njk b/node_modules/@ministryofjustice/frontend/moj/components/task-list/macro.njk new file mode 100644 index 00000000..dfad4177 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/task-list/macro.njk @@ -0,0 +1,3 @@ +{% macro mojTaskList(params) %} + {%- include "./template.njk" -%} +{% endmacro %} \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/components/task-list/template.njk b/node_modules/@ministryofjustice/frontend/moj/components/task-list/template.njk new file mode 100644 index 00000000..1ee3a38a --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/task-list/template.njk @@ -0,0 +1,25 @@ +{%- from "govuk/components/tag/macro.njk" import govukTag -%} +
    + {%- for section in params.sections %} +
  1. + + {{ loop.index }}. {{- section.heading.html | safe if section.heading.html else section.heading.text -}} + + +
  2. + {% endfor -%} +
\ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/components/ticket-panel/README.md b/node_modules/@ministryofjustice/frontend/moj/components/ticket-panel/README.md new file mode 100644 index 00000000..3b6f6c84 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/ticket-panel/README.md @@ -0,0 +1,56 @@ +# Ticket Panel + +- [Guidance](https://design-patterns.service.justice.gov.uk/components/ticket-panel) + +## Example + +Below is a typical example of the timeline component in use. + +``` +{{ mojTicketPanel({ + attributes: { + 'aria-label': 'Sub navigation 1' + }, + items: [{ + html: '

This is a heading 2

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

+ + Save and continue + ', + attributes: { + 'aria-label': 'Section 1' + } + }] +}) }} +``` + +## Arguments + +This component accepts the following arguments. + +### Container + +| Name | Type | Required | Description | +| ---------- | ------ | -------- | ------------------------------------------------------------------------------------- | +| classes | string | No | Classes to add to the ticket panel's container. | +| attributes | object | No | HTML attributes (for example data attributes) to add to the ticket panel's container. | + +### Items + +| Name | Type | Required | Description | +| ---------- | ------ | -------- | -------------------------------------------------------------------------------------------------------------------------------- | +| text | string | Yes | If `html` is set, this is not required. Text to use within the item. If `html` is provided, the `text` argument will be ignored. | +| html | string | Yes | If `text` is set, this is not required. HTML to use within the item. If `html` is provided, the `text` argument will be ignored. | +| classes | string | No | Classes to add to the ticket panel's container. | +| attributes | object | No | HTML attributes (for example data attributes) to add to the ticket panel's container. | + +### Classes + +| Name | +| ----------------------------------- | +| moj-ticket-panel\_\_content--blue | +| moj-ticket-panel\_\_content--red | +| moj-ticket-panel\_\_content--yellow | +| moj-ticket-panel\_\_content--green | +| moj-ticket-panel\_\_content--purple | +| moj-ticket-panel\_\_content--orange | diff --git a/node_modules/@ministryofjustice/frontend/moj/components/ticket-panel/_ticket-panel.scss b/node_modules/@ministryofjustice/frontend/moj/components/ticket-panel/_ticket-panel.scss new file mode 100644 index 00000000..a826359b --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/ticket-panel/_ticket-panel.scss @@ -0,0 +1,56 @@ +/* ========================================================================== + #TICKET PANEL + ========================================================================== */ + +.moj-ticket-panel { + display: block; + margin-right: govuk-spacing(0); + flex-wrap: wrap; + + &--inline { + @include govuk-media-query($from: desktop) { + display: flex; + flex-wrap: nowrap; + + & > * + * { + margin-left: govuk-spacing(3); + } + } + } + + &__content *:last-child { + margin-bottom: govuk-spacing(0); + } + + &__content { + display: block; + position: relative; + background-color: govuk-colour("light-grey"); + padding: govuk-spacing(4); + margin-bottom: govuk-spacing(3); + flex-grow: 1; + border-left: 4px solid transparent; + + &--grey { + border-left-color: $govuk-border-colour; + } + &--blue { + border-left-color: govuk-colour("blue"); + } + &--red { + border-left-color: govuk-colour("red"); + } + &--yellow { + border-left-color: govuk-colour("yellow"); + } + &--green { + border-left-color: govuk-colour("green"); + } + &--purple { + border-left-color: govuk-colour("purple"); + } + &--orange { + border-left-color: govuk-colour("orange"); + } + } +} diff --git a/node_modules/@ministryofjustice/frontend/moj/components/ticket-panel/macro.njk b/node_modules/@ministryofjustice/frontend/moj/components/ticket-panel/macro.njk new file mode 100644 index 00000000..22db0221 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/ticket-panel/macro.njk @@ -0,0 +1,3 @@ +{% macro mojTicketPanel(params) %} + {%- include "./template.njk" -%} +{% endmacro %} diff --git a/node_modules/@ministryofjustice/frontend/moj/components/ticket-panel/template.njk b/node_modules/@ministryofjustice/frontend/moj/components/ticket-panel/template.njk new file mode 100644 index 00000000..260b7acd --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/ticket-panel/template.njk @@ -0,0 +1,15 @@ +
+ + {%- for item in params.items %} + +
+ {{- item.html | safe if item.html else item.text -}} +
+ + {% endfor -%} + +
diff --git a/node_modules/@ministryofjustice/frontend/moj/components/timeline/README.md b/node_modules/@ministryofjustice/frontend/moj/components/timeline/README.md new file mode 100644 index 00000000..5e2c85d1 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/timeline/README.md @@ -0,0 +1,150 @@ +# Timeline + +- [Guidance](https://design-patterns.service.justice.gov.uk/components/timeline) + +### Installation + +You will need to install the following code at the bottom of `server.js`, just above `module.exports = app;` + +``` +// Add filters from MOJ Frontend +let mojFilters = require('./node_modules/@ministryofjustice/frontend/filters/all')(); +mojFilters = Object.assign(mojFilters); +Object.keys(mojFilters).forEach(function (filterName) { + nunjucksAppEnv.addFilter(filterName, mojFilters[filterName]) +}); +``` + +## Example + +Below is a typical example of the timeline component in use. + +``` +{{ mojTimeline({ + items: [ + { + label: { + text: "Application requires confirmation" + }, + html: confirmationHtml, + datetime: { + timestamp: "2019-06-14T14:01:00.000Z", + type: "datetime" + }, + byline: { + text: "Joe Bloggs" + } + }, + { + label: { + text: "Application review in progress" + }, + text: "Your application is being reviewed by one of our case workers.", + datetime: { + timestamp: "2019-06-07T12:32:00.000Z", + type: "datetime" + }, + byline: { + text: "Caseworker 1" + } + }, + { + label: { + text: "Application received" + }, + text: "Your application has been received – reference MOJ-1234-5678", + datetime: { + timestamp: "2019-06-06T09:12:00.000Z", + type: "datetime" + }, + byline: { + text: "Caseworker 1" + } + }, + { + label: { + text: "Application submitted" + }, + html: detailsHtml, + datetime: { + timestamp: "2019-05-28T10:45:00.000Z", + type: "datetime" + }, + byline: { + text: "Joe Bloggs" + } + }, + { + label: { + text: "Documents uploaded" + }, + html: documentsHtml, + datetime: { + timestamp: "2019-05-28T10:15:00.000Z", + type: "datetime" + }, + byline: { + text: "Joe Bloggs" + } + }, + { + label: { + text: "Application started" + }, + html: listHtml, + datetime: { + timestamp: "2019-05-21T13:15:00.000Z", + type: "datetime" + }, + byline: { + text: "Joe Bloggs" + } + } + ] +}) }} +``` + +## Arguments + +This component accepts the following arguments. + +### Container + +| Name | Type | Required | Description | +| ---------- | ------ | -------- | --------------------------------------------------------------------------------- | +| classes | string | No | Classes to add to the timeline's container. | +| attributes | object | No | HTML attributes (for example data attributes) to add to the timeline's container. | + +### Items + +| Name | Type | Required | Description | +| ---------- | ------ | -------- | -------------------------------------------------------------------------------------------------------------------------------- | +| label | object | Yes | See [item label](#itemlabel). | +| text | string | Yes | If `html` is set, this is not required. Text to use within the item. If `html` is provided, the `text` argument will be ignored. | +| html | string | Yes | If `text` is set, this is not required. HTML to use within the item. If `html` is provided, the `text` argument will be ignored. | +| datetime | object | No | See [item date and time](#itemdatetime). | +| byline | object | No | See [item byline](#itembyline). | +| classes | string | No | Classes to add to the timeline's items container. | +| attributes | object | No | HTML attributes (for example data attributes) to add to the timeline's items container. | + +#### Item label + +| Name | Type | Required | Description | +| ---- | ------ | -------- | -------------------------------------------------------------------------------------------------------------------------------------- | +| text | string | Yes | If `html` is set, this is not required. Text to use within the item label. If `html` is provided, the `text` argument will be ignored. | +| html | string | Yes | If `text` is set, this is not required. HTML to use within the item label. If `html` is provided, the `text` argument will be ignored. | + +#### Item datetime + +| Name | Type | Required | Description | +| --------- | ------ | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| timestamp | string | Yes | A valid datetime string to be formatted. For example: `1970-01-01T11:59:59.000Z` | +| type | string | Yes | If `format` is set, this is not required. The standard date format to use within the item. If `type` is provided, the `format` argument will be ignored. Values include: `datetime`, `shortdatetime`, `date`, `shortdate` and `time` | +| format | string | Yes | If `type` is set, this is not required. The user-defined date format to use within the item. If `type` is provided, the `format` argument will be ignored. See the [Moment.js document on display formats](https://momentjs.com/docs/). | + +#### Item byline + +| Name | Type | Required | Description | +| ---- | ------ | -------- | --------------------------------------------------------------------------------------------------------------------------------------- | +| text | string | Yes | If `html` is set, this is not required. Text to use within the item byline. If `html` is provided, the `text` argument will be ignored. | +| html | string | Yes | If `text` is set, this is not required. HTML to use within the item byline. If `html` is provided, the `text` argument will be ignored. | diff --git a/node_modules/@ministryofjustice/frontend/moj/components/timeline/_timeline.scss b/node_modules/@ministryofjustice/frontend/moj/components/timeline/_timeline.scss new file mode 100644 index 00000000..3b61b3e4 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/timeline/_timeline.scss @@ -0,0 +1,109 @@ +/* ========================================================================== + #TIMELINE + ========================================================================== */ + +.moj-timeline { + margin-bottom: govuk-spacing(4); + overflow: hidden; + position: relative; + + &:before { + background-color: $govuk-brand-colour; + content: ""; + height: 100%; + left: 0; + position: absolute; + top: govuk-spacing(2); + width: 5px; + } + +} + +.moj-timeline--full { + margin-bottom: 0; + &:before { + height: calc(100% - 75px); + } +} + +.moj-timeline__item { + padding-bottom: govuk-spacing(6); + padding-left: govuk-spacing(4); + position: relative; + + &:before { + background-color: $govuk-brand-colour; + content: ""; + height: 5px; + left: 0; + position: absolute; + top: govuk-spacing(2); + width: 15px; + } + +} + +.moj-timeline__title { + @include govuk-font($size: 19, $weight: bold); + display: inline; +} + +.moj-timeline__byline { + @include govuk-font($size: 19); + color: $govuk-secondary-text-colour; + display: inline; + margin: 0; +} + +.moj-timeline__date { + @include govuk-font($size: 16); + margin-top: govuk-spacing(1); + margin-bottom: 0; +} + +.moj-timeline__description { + @include govuk-font($size: 19); + margin-top: govuk-spacing(4); +} + +/* ========================================================================== + #TIMELINE DOCUMENT STYLES – FOR BACKWARDS COMPATIBILITY + ========================================================================== */ + +.moj-timeline__documents { + list-style: none; + margin-bottom: 0; + padding-left: 0; +} + +.moj-timeline__document-item { + margin-bottom: govuk-spacing(1); + + &:last-child { + margin-bottom: 0; + } + +} + +.moj-timeline__document-icon { + float: left; + margin-top: 4px; + margin-right: 4px; + fill: currentColor; + + @media screen and (forced-colors: active) { + fill: linkText; + } +} + +.moj-timeline__document-link { + background-image: url(#{$moj-images-path}icon-document.svg); + background-repeat: no-repeat; + background-size: 20px 16px; + background-position: 0 50%; + padding-left: govuk-spacing(5); + + &:focus { + color: govuk-colour("black"); // Focus colour on yellow should really be black. + } +} diff --git a/node_modules/@ministryofjustice/frontend/moj/components/timeline/macro.njk b/node_modules/@ministryofjustice/frontend/moj/components/timeline/macro.njk new file mode 100644 index 00000000..22c53cc8 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/timeline/macro.njk @@ -0,0 +1,3 @@ +{% macro mojTimeline(params) %} + {%- include "./template.njk" -%} +{% endmacro %} \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/components/timeline/template.njk b/node_modules/@ministryofjustice/frontend/moj/components/timeline/template.njk new file mode 100644 index 00000000..14484e64 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/components/timeline/template.njk @@ -0,0 +1,32 @@ +
+ + {%- for item in params.items %} +
+ +
+ + {{- item.label.html | safe if item.label.html else item.label.text -}} + + {% if item.byline %} + + {% endif %} +
+ +

+ +

+ +
+ {{- item.html | safe if item.html else item.text -}} +
+ +
+ {% endfor -%} + +
diff --git a/node_modules/@ministryofjustice/frontend/moj/filters/all.js b/node_modules/@ministryofjustice/frontend/moj/filters/all.js new file mode 100644 index 00000000..292604be --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/filters/all.js @@ -0,0 +1,69 @@ +const moment = require('moment'); + +module.exports = function () { + /** + * Instantiate object used to store the methods registered as a + * 'filter' (of the same name) within nunjucks. You can override + * gov.uk core filters by creating filter methods of the same name. + * @type {Object} + */ + let filters = {} + + /* ------------------------------------------------------------------ + date filter for use in Nunjucks + example: {{ params.date | date("DD/MM/YYYY") }} + outputs: 01/01/1970 + ------------------------------------------------------------------ */ + filters.date = function(timestamp, format) { + return moment(timestamp).format(format); + } + + /* ------------------------------------------------------------------ + utility functions for use in mojDate function/filter + ------------------------------------------------------------------ */ + function govDate(timestamp) { + return moment(timestamp).format('D MMMM YYYY'); + } + + function govShortDate(timestamp) { + return moment(timestamp).format('D MMM YYYY'); + } + + function govTime(timestamp) { + let t = moment(timestamp); + if(t.minutes() > 0) { + return t.format('h:mma'); + } else { + return t.format('ha'); + } + } + + /* ------------------------------------------------------------------ + standard dates for use in Nunjucks, + example: {{ params.date | mojDate("datetime") }} + outputs: 1 Jan 1970 at 1:32pm + ------------------------------------------------------------------ */ + filters.mojDate = function(timestamp, type) { + + switch(type) { + case "datetime": + return govDate(timestamp) + " at " + govTime(timestamp); + case "shortdatetime": + return govShortDate(timestamp) + " at " + govTime(timestamp); + case "date": + return govDate(timestamp); + case "shortdate": + return govShortDate(timestamp); + case "time": + return govTime(timestamp); + default: + return timestamp; + } + + } + + /* ------------------------------------------------------------------ + keep the following line to return your filters to the app + ------------------------------------------------------------------ */ + return filters; +} diff --git a/node_modules/@ministryofjustice/frontend/moj/filters/prototype-kit-13-filters.js b/node_modules/@ministryofjustice/frontend/moj/filters/prototype-kit-13-filters.js new file mode 100644 index 00000000..bdd5f0b6 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/filters/prototype-kit-13-filters.js @@ -0,0 +1,8 @@ +const { addFilter } = require('govuk-prototype-kit').views +const getAllFilters = require('./all') + +const allFilters = getAllFilters() + +Object.keys(allFilters).forEach(name => { + addFilter(name, allFilters[name]) +}) diff --git a/node_modules/@ministryofjustice/frontend/moj/helpers.js b/node_modules/@ministryofjustice/frontend/moj/helpers.js new file mode 100644 index 00000000..e5dc31e8 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/helpers.js @@ -0,0 +1,51 @@ +MOJFrontend.removeAttributeValue = function(el, attr, value) { + var re, m; + if (el.getAttribute(attr)) { + if (el.getAttribute(attr) == value) { + el.removeAttribute(attr); + } else { + re = new RegExp('(^|\\s)' + value + '(\\s|$)'); + m = el.getAttribute(attr).match(re); + if (m && m.length == 3) { + el.setAttribute(attr, el.getAttribute(attr).replace(re, (m[1] && m[2])?' ':'')) + } + } + } +} + +MOJFrontend.addAttributeValue = function(el, attr, value) { + var re; + if (!el.getAttribute(attr)) { + el.setAttribute(attr, value); + } + else { + re = new RegExp('(^|\\s)' + value + '(\\s|$)'); + if (!re.test(el.getAttribute(attr))) { + el.setAttribute(attr, el.getAttribute(attr) + ' ' + value); + } + } +}; + +MOJFrontend.dragAndDropSupported = function() { + var div = document.createElement('div'); + return typeof div.ondrop != 'undefined'; +}; + +MOJFrontend.formDataSupported = function() { + return typeof FormData == 'function'; +}; + +MOJFrontend.fileApiSupported = function() { + var input = document.createElement('input'); + input.type = 'file'; + return typeof input.files != 'undefined'; +}; + +MOJFrontend.nodeListForEach = function(nodes, callback) { + if (window.NodeList.prototype.forEach) { + return nodes.forEach(callback) + } + for (var i = 0; i < nodes.length; i++) { + callback.call(window, nodes[i], i, nodes) + } +}; diff --git a/node_modules/@ministryofjustice/frontend/moj/helpers/_all.scss b/node_modules/@ministryofjustice/frontend/moj/helpers/_all.scss new file mode 100644 index 00000000..48acab9b --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/helpers/_all.scss @@ -0,0 +1 @@ +@import "hidden"; diff --git a/node_modules/@ministryofjustice/frontend/moj/helpers/_hidden.scss b/node_modules/@ministryofjustice/frontend/moj/helpers/_hidden.scss new file mode 100644 index 00000000..1e004971 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/helpers/_hidden.scss @@ -0,0 +1,3 @@ +@mixin moj-hidden() { + display: none; +} \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/init.js b/node_modules/@ministryofjustice/frontend/moj/init.js new file mode 100644 index 00000000..58d3377e --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/init.js @@ -0,0 +1,5 @@ +if (window.GOVUKPrototypeKit && window.GOVUKPrototypeKit.documentReady) { + window.GOVUKPrototypeKit.documentReady(function () { + window.MOJFrontend.initAll(); + }); +} diff --git a/node_modules/@ministryofjustice/frontend/moj/namespace.js b/node_modules/@ministryofjustice/frontend/moj/namespace.js new file mode 100644 index 00000000..26d111b2 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/namespace.js @@ -0,0 +1 @@ +var MOJFrontend = {}; \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/objects/_all.scss b/node_modules/@ministryofjustice/frontend/moj/objects/_all.scss new file mode 100644 index 00000000..e8075f6b --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/objects/_all.scss @@ -0,0 +1,3 @@ +@import "width-container"; +@import "filter-layout"; +@import "scrollable-pane"; diff --git a/node_modules/@ministryofjustice/frontend/moj/objects/_filter-layout.scss b/node_modules/@ministryofjustice/frontend/moj/objects/_filter-layout.scss new file mode 100644 index 00000000..a62b7d17 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/objects/_filter-layout.scss @@ -0,0 +1,32 @@ +.moj-filter-layout { + @include govuk-clearfix; +} + +.moj-filter-layout__filter { + box-shadow: inset 0 0 0 1px govuk-colour("light-grey"); // Extends the inset border left full height of the filters on mobile + + @include govuk-media-query(desktop) { + float: left; + margin-right: govuk-spacing(7); + max-width: 385px; + min-width: 260px; + width: 100%; + } +} + +// Filters with javascript enabled +@include govuk-media-query($until: desktop) { + + .js-enabled .moj-filter-layout__filter { + background-color: govuk-colour("white"); + position: fixed; top: 0; right: 0; bottom: 0; + overflow-y: scroll; + z-index: 100; + } + +} + +.moj-filter-layout__content { + overflow: hidden; + overflow-x: auto; +} \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/objects/_scrollable-pane.scss b/node_modules/@ministryofjustice/frontend/moj/objects/_scrollable-pane.scss new file mode 100644 index 00000000..b08eebb7 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/objects/_scrollable-pane.scss @@ -0,0 +1,43 @@ +.moj-scrollable-pane { + $scrollableBgColor: white; + $scrollableTransparentColor: rgba(255, 255, 255, 0); + $scrollableShadowColor: rgba(0, 0, 0, 0.2); + $scrollableShadowSize: 0.75em; + + overflow-x: scroll; + background: linear-gradient( + to right, + $scrollableBgColor, + $scrollableBgColor, + $scrollableTransparentColor calc(var($scrollableShadowSize) * 2) + ), + radial-gradient( + farthest-side at 0 50%, + $scrollableShadowColor, + $scrollableTransparentColor + ), + linear-gradient( + to left, + $scrollableBgColor, + $scrollableBgColor, + $scrollableTransparentColor calc(var($scrollableShadowSize) * 2) + ), + radial-gradient( + farthest-side at 100% 50%, + $scrollableShadowColor, + $scrollableTransparentColor + ) + 100%; + background-color: $scrollableBgColor; + background-repeat: no-repeat; + background-attachment: local, scroll, local, scroll; + background-size: 100% 100%, $scrollableShadowSize 100%, 100% 100%, + $scrollableShadowSize 100%; +} + +@include govuk-media-query($until: 1020px) { + .moj-scrollable-pane .govuk-table__header, + .moj-scrollable-pane .govuk-table__cell { + white-space: nowrap; + } +} diff --git a/node_modules/@ministryofjustice/frontend/moj/objects/_width-container.scss b/node_modules/@ministryofjustice/frontend/moj/objects/_width-container.scss new file mode 100644 index 00000000..70fa20d0 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/objects/_width-container.scss @@ -0,0 +1,18 @@ +@mixin moj-width-container($width: $moj-page-width) { + // Limit the width of the container to the page width + max-width: $width; + + // On mobile, add half width gutters + margin: 0 $moj-gutter-half; + + // On tablet, add full width gutters + @include govuk-media-query($from: tablet) { + margin: 0 $moj-gutter; + } + + // As soon as the viewport is greater than the width of the page plus the + // gutters, just centre the content instead of adding gutters. + @include govuk-media-query($and: "(min-width: #{($width + $moj-gutter * 2)})") { + margin: 0 auto; + } +} diff --git a/node_modules/@ministryofjustice/frontend/moj/settings/_all.scss b/node_modules/@ministryofjustice/frontend/moj/settings/_all.scss new file mode 100644 index 00000000..82de2414 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/settings/_all.scss @@ -0,0 +1,3 @@ +@import "assets"; +@import "measurements"; +@import "colours"; diff --git a/node_modules/@ministryofjustice/frontend/moj/settings/_assets.scss b/node_modules/@ministryofjustice/frontend/moj/settings/_assets.scss new file mode 100644 index 00000000..cdfa8cca --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/settings/_assets.scss @@ -0,0 +1,9 @@ +/* ========================================================================== + #ASSETS + ========================================================================== */ + +// Assets folder +$moj-assets-path: "/assets/" !default; + +// Path the images folder +$moj-images-path: "#{$moj-assets-path}images/" !default; diff --git a/node_modules/@ministryofjustice/frontend/moj/settings/_colours.scss b/node_modules/@ministryofjustice/frontend/moj/settings/_colours.scss new file mode 100644 index 00000000..dc7a1630 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/settings/_colours.scss @@ -0,0 +1,9 @@ +/* ========================================================================== + #COLOURS + ========================================================================== */ + +$moj-border-color: rgb(161, 172, 178); +$moj-secondary-text-color: rgb(69, 74, 76); + +$moj-secondary-link-color: rgb(69, 74, 76); +$moj-secondary-link-hover-color: rgb(23, 24, 25); diff --git a/node_modules/@ministryofjustice/frontend/moj/settings/_measurements.scss b/node_modules/@ministryofjustice/frontend/moj/settings/_measurements.scss new file mode 100644 index 00000000..b76438fa --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/settings/_measurements.scss @@ -0,0 +1,14 @@ +/* ========================================================================== + #MEASUREMENTS + ========================================================================== */ + +// Width of main container +$moj-page-width: 960px !default; + + +// Width of gutter between grid columns +$moj-gutter: 30px !default; + + +// Width of half the gutter between grid columns +$moj-gutter-half: $moj-gutter / 2; diff --git a/node_modules/@ministryofjustice/frontend/moj/utilities/_all.scss b/node_modules/@ministryofjustice/frontend/moj/utilities/_all.scss new file mode 100644 index 00000000..e9a58b43 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/utilities/_all.scss @@ -0,0 +1,2 @@ +@import "hidden"; +@import "width-container"; diff --git a/node_modules/@ministryofjustice/frontend/moj/utilities/_hidden.scss b/node_modules/@ministryofjustice/frontend/moj/utilities/_hidden.scss new file mode 100644 index 00000000..2251d612 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/utilities/_hidden.scss @@ -0,0 +1,7 @@ +.js-enabled .moj-js-hidden { + @include moj-hidden(); +} + +.moj-hidden { + @include moj-hidden(); +} \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/utilities/_width-container.scss b/node_modules/@ministryofjustice/frontend/moj/utilities/_width-container.scss new file mode 100644 index 00000000..67a7cc34 --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/utilities/_width-container.scss @@ -0,0 +1,3 @@ +.moj-width-container { + @include moj-width-container; +} \ No newline at end of file diff --git a/node_modules/@ministryofjustice/frontend/moj/vendor/html5shiv.js b/node_modules/@ministryofjustice/frontend/moj/vendor/html5shiv.js new file mode 100644 index 00000000..45ea723d --- /dev/null +++ b/node_modules/@ministryofjustice/frontend/moj/vendor/html5shiv.js @@ -0,0 +1,326 @@ +/** +* @preserve HTML5 Shiv 3.7.3 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed +*/ +;(function(window, document) { +/*jshint evil:true */ + /** version */ + var version = '3.7.3'; + + /** Preset options */ + var options = window.html5 || {}; + + /** Used to skip problem elements */ + var reSkip = /^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i; + + /** Not all elements can be cloned in IE **/ + var saveClones = /^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i; + + /** Detect whether the browser supports default html5 styles */ + var supportsHtml5Styles; + + /** Name of the expando, to work with multiple documents or to re-shiv one document */ + var expando = '_html5shiv'; + + /** The id for the the documents expando */ + var expanID = 0; + + /** Cached data for each document */ + var expandoData = {}; + + /** Detect whether the browser supports unknown elements */ + var supportsUnknownElements; + + (function() { + try { + var a = document.createElement('a'); + a.innerHTML = ''; + //if the hidden property is implemented we can assume, that the browser supports basic HTML5 Styles + supportsHtml5Styles = ('hidden' in a); + + supportsUnknownElements = a.childNodes.length == 1 || (function() { + // assign a false positive if unable to shiv + (document.createElement)('a'); + var frag = document.createDocumentFragment(); + return ( + typeof frag.cloneNode == 'undefined' || + typeof frag.createDocumentFragment == 'undefined' || + typeof frag.createElement == 'undefined' + ); + }()); + } catch(e) { + // assign a false positive if detection fails => unable to shiv + supportsHtml5Styles = true; + supportsUnknownElements = true; + } + + }()); + + /*--------------------------------------------------------------------------*/ + + /** + * Creates a style sheet with the given CSS text and adds it to the document. + * @private + * @param {Document} ownerDocument The document. + * @param {String} cssText The CSS text. + * @returns {StyleSheet} The style element. + */ + function addStyleSheet(ownerDocument, cssText) { + var p = ownerDocument.createElement('p'), + parent = ownerDocument.getElementsByTagName('head')[0] || ownerDocument.documentElement; + + p.innerHTML = 'x'; + return parent.insertBefore(p.lastChild, parent.firstChild); + } + + /** + * Returns the value of `html5.elements` as an array. + * @private + * @returns {Array} An array of shived element node names. + */ + function getElements() { + var elements = html5.elements; + return typeof elements == 'string' ? elements.split(' ') : elements; + } + + /** + * Extends the built-in list of html5 elements + * @memberOf html5 + * @param {String|Array} newElements whitespace separated list or array of new element names to shiv + * @param {Document} ownerDocument The context document. + */ + function addElements(newElements, ownerDocument) { + var elements = html5.elements; + if(typeof elements != 'string'){ + elements = elements.join(' '); + } + if(typeof newElements != 'string'){ + newElements = newElements.join(' '); + } + html5.elements = elements +' '+ newElements; + shivDocument(ownerDocument); + } + + /** + * Returns the data associated to the given document + * @private + * @param {Document} ownerDocument The document. + * @returns {Object} An object of data. + */ + function getExpandoData(ownerDocument) { + var data = expandoData[ownerDocument[expando]]; + if (!data) { + data = {}; + expanID++; + ownerDocument[expando] = expanID; + expandoData[expanID] = data; + } + return data; + } + + /** + * returns a shived element for the given nodeName and document + * @memberOf html5 + * @param {String} nodeName name of the element + * @param {Document|DocumentFragment} ownerDocument The context document. + * @returns {Object} The shived element. + */ + function createElement(nodeName, ownerDocument, data){ + if (!ownerDocument) { + ownerDocument = document; + } + if(supportsUnknownElements){ + return ownerDocument.createElement(nodeName); + } + if (!data) { + data = getExpandoData(ownerDocument); + } + var node; + + if (data.cache[nodeName]) { + node = data.cache[nodeName].cloneNode(); + } else if (saveClones.test(nodeName)) { + node = (data.cache[nodeName] = data.createElem(nodeName)).cloneNode(); + } else { + node = data.createElem(nodeName); + } + + // Avoid adding some elements to fragments in IE < 9 because + // * Attributes like `name` or `type` cannot be set/changed once an element + // is inserted into a document/fragment + // * Link elements with `src` attributes that are inaccessible, as with + // a 403 response, will cause the tab/window to crash + // * Script elements appended to fragments will execute when their `src` + // or `text` property is set + return node.canHaveChildren && !reSkip.test(nodeName) && !node.tagUrn ? data.frag.appendChild(node) : node; + } + + /** + * returns a shived DocumentFragment for the given document + * @memberOf html5 + * @param {Document} ownerDocument The context document. + * @returns {Object} The shived DocumentFragment. + */ + function createDocumentFragment(ownerDocument, data){ + if (!ownerDocument) { + ownerDocument = document; + } + if(supportsUnknownElements){ + return ownerDocument.createDocumentFragment(); + } + data = data || getExpandoData(ownerDocument); + var clone = data.frag.cloneNode(), + i = 0, + elems = getElements(), + l = elems.length; + for(;i to avoid XSS via location.hash (#9521) + quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/, + + // Check if a string has a non-whitespace character in it + rnotwhite = /\S/, + + // Used for trimming whitespace + trimLeft = /^\s+/, + trimRight = /\s+$/, + + // Check for digits + rdigit = /\d/, + + // Match a standalone tag + rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/, + + // JSON RegExp + rvalidchars = /^[\],:{}\s]*$/, + rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, + rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, + rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g, + + // Useragent RegExp + rwebkit = /(webkit)[ \/]([\w.]+)/, + ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/, + rmsie = /(msie) ([\w.]+)/, + rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/, + + // Matches dashed string for camelizing + rdashAlpha = /-([a-z]|[0-9])/ig, + rmsPrefix = /^-ms-/, + + // Used by jQuery.camelCase as callback to replace() + fcamelCase = function( all, letter ) { + return ( letter + "" ).toUpperCase(); + }, + + // Keep a UserAgent string for use with jQuery.browser + userAgent = navigator.userAgent, + + // For matching the engine and version of the browser + browserMatch, + + // The deferred used on DOM ready + readyList, + + // The ready event handler + DOMContentLoaded, + + // Save a reference to some core methods + toString = Object.prototype.toString, + hasOwn = Object.prototype.hasOwnProperty, + push = Array.prototype.push, + slice = Array.prototype.slice, + trim = String.prototype.trim, + indexOf = Array.prototype.indexOf, + + // [[Class]] -> type pairs + class2type = {}; + + jQuery.fn = jQuery.prototype = { + constructor: jQuery, + init: function( selector, context, rootjQuery ) { + var match, elem, ret, doc; + + // Handle $(""), $(null), or $(undefined) + if ( !selector ) { + return this; + } + + // Handle $(DOMElement) + if ( selector.nodeType ) { + this.context = this[0] = selector; + this.length = 1; + return this; + } + + // The body element only exists once, optimize finding it + if ( selector === "body" && !context && document.body ) { + this.context = document; + this[0] = document.body; + this.selector = selector; + this.length = 1; + return this; + } + + // Handle HTML strings + if ( typeof selector === "string" ) { + // Are we dealing with HTML string or an ID? + if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) { + // Assume that strings that start and end with <> are HTML and skip the regex check + match = [ null, selector, null ]; + + } else { + match = quickExpr.exec( selector ); + } + + // Verify a match, and that no context was specified for #id + if ( match && (match[1] || !context) ) { + + // HANDLE: $(html) -> $(array) + if ( match[1] ) { + context = context instanceof jQuery ? context[0] : context; + doc = ( context ? context.ownerDocument || context : document ); + + // If a single string is passed in and it's a single tag + // just do a createElement and skip the rest + ret = rsingleTag.exec( selector ); + + if ( ret ) { + if ( jQuery.isPlainObject( context ) ) { + selector = [ document.createElement( ret[1] ) ]; + jQuery.fn.attr.call( selector, context, true ); + + } else { + selector = [ doc.createElement( ret[1] ) ]; + } + + } else { + ret = jQuery.buildFragment( [ match[1] ], [ doc ] ); + selector = ( ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment ).childNodes; + } + + return jQuery.merge( this, selector ); + + // HANDLE: $("#id") + } else { + elem = document.getElementById( match[2] ); + + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + if ( elem && elem.parentNode ) { + // Handle the case where IE and Opera return items + // by name instead of ID + if ( elem.id !== match[2] ) { + return rootjQuery.find( selector ); + } + + // Otherwise, we inject the element directly into the jQuery object + this.length = 1; + this[0] = elem; + } + + this.context = document; + this.selector = selector; + return this; + } + + // HANDLE: $(expr, $(...)) + } else if ( !context || context.jquery ) { + return ( context || rootjQuery ).find( selector ); + + // HANDLE: $(expr, context) + // (which is just equivalent to: $(context).find(expr) + } else { + return this.constructor( context ).find( selector ); + } + + // HANDLE: $(function) + // Shortcut for document ready + } else if ( jQuery.isFunction( selector ) ) { + return rootjQuery.ready( selector ); + } + + if ( selector.selector !== undefined ) { + this.selector = selector.selector; + this.context = selector.context; + } + + return jQuery.makeArray( selector, this ); + }, + + // Start with an empty selector + selector: "", + + // The current version of jQuery being used + jquery: "1.7", + + // The default length of a jQuery object is 0 + length: 0, + + // The number of elements contained in the matched element set + size: function() { + return this.length; + }, + + toArray: function() { + return slice.call( this, 0 ); + }, + + // Get the Nth element in the matched element set OR + // Get the whole matched element set as a clean array + get: function( num ) { + return num == null ? + + // Return a 'clean' array + this.toArray() : + + // Return just the object + ( num < 0 ? this[ this.length + num ] : this[ num ] ); + }, + + // Take an array of elements and push it onto the stack + // (returning the new matched element set) + pushStack: function( elems, name, selector ) { + // Build a new jQuery matched element set + var ret = this.constructor(); + + if ( jQuery.isArray( elems ) ) { + push.apply( ret, elems ); + + } else { + jQuery.merge( ret, elems ); + } + + // Add the old object onto the stack (as a reference) + ret.prevObject = this; + + ret.context = this.context; + + if ( name === "find" ) { + ret.selector = this.selector + ( this.selector ? " " : "" ) + selector; + } else if ( name ) { + ret.selector = this.selector + "." + name + "(" + selector + ")"; + } + + // Return the newly-formed element set + return ret; + }, + + // Execute a callback for every element in the matched set. + // (You can seed the arguments with an array of args, but this is + // only used internally.) + each: function( callback, args ) { + return jQuery.each( this, callback, args ); + }, + + ready: function( fn ) { + // Attach the listeners + jQuery.bindReady(); + + // Add the callback + readyList.add( fn ); + + return this; + }, + + eq: function( i ) { + return i === -1 ? + this.slice( i ) : + this.slice( i, +i + 1 ); + }, + + first: function() { + return this.eq( 0 ); + }, + + last: function() { + return this.eq( -1 ); + }, + + slice: function() { + return this.pushStack( slice.apply( this, arguments ), + "slice", slice.call(arguments).join(",") ); + }, + + map: function( callback ) { + return this.pushStack( jQuery.map(this, function( elem, i ) { + return callback.call( elem, i, elem ); + })); + }, + + end: function() { + return this.prevObject || this.constructor(null); + }, + + // For internal use only. + // Behaves like an Array's method, not like a jQuery method. + push: push, + sort: [].sort, + splice: [].splice + }; + + // Give the init function the jQuery prototype for later instantiation + jQuery.fn.init.prototype = jQuery.fn; + + jQuery.extend = jQuery.fn.extend = function() { + var options, name, src, copy, copyIsArray, clone, + target = arguments[0] || {}, + i = 1, + length = arguments.length, + deep = false; + + // Handle a deep copy situation + if ( typeof target === "boolean" ) { + deep = target; + target = arguments[1] || {}; + // skip the boolean and the target + i = 2; + } + + // Handle case when target is a string or something (possible in deep copy) + if ( typeof target !== "object" && !jQuery.isFunction(target) ) { + target = {}; + } + + // extend jQuery itself if only one argument is passed + if ( length === i ) { + target = this; + --i; + } + + for ( ; i < length; i++ ) { + // Only deal with non-null/undefined values + if ( (options = arguments[ i ]) != null ) { + // Extend the base object + for ( name in options ) { + src = target[ name ]; + copy = options[ name ]; + + // Prevent never-ending loop + if ( target === copy ) { + continue; + } + + // Recurse if we're merging plain objects or arrays + if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) { + if ( copyIsArray ) { + copyIsArray = false; + clone = src && jQuery.isArray(src) ? src : []; + + } else { + clone = src && jQuery.isPlainObject(src) ? src : {}; + } + + // Never move original objects, clone them + target[ name ] = jQuery.extend( deep, clone, copy ); + + // Don't bring in undefined values + } else if ( copy !== undefined ) { + target[ name ] = copy; + } + } + } + } + + // Return the modified object + return target; + }; + + jQuery.extend({ + noConflict: function( deep ) { + if ( window.$ === jQuery ) { + window.$ = _$; + } + + if ( deep && window.jQuery === jQuery ) { + window.jQuery = _jQuery; + } + + return jQuery; + }, + + // Is the DOM ready to be used? Set to true once it occurs. + isReady: false, + + // A counter to track how many items to wait for before + // the ready event fires. See #6781 + readyWait: 1, + + // Hold (or release) the ready event + holdReady: function( hold ) { + if ( hold ) { + jQuery.readyWait++; + } else { + jQuery.ready( true ); + } + }, + + // Handle when the DOM is ready + ready: function( wait ) { + // Either a released hold or an DOMready/load event and not yet ready + if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) { + // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). + if ( !document.body ) { + return setTimeout( jQuery.ready, 1 ); + } + + // Remember that the DOM is ready + jQuery.isReady = true; + + // If a normal DOM Ready event fired, decrement, and wait if need be + if ( wait !== true && --jQuery.readyWait > 0 ) { + return; + } + + // If there are functions bound, to execute + readyList.fireWith( document, [ jQuery ] ); + + // Trigger any bound ready events + if ( jQuery.fn.trigger ) { + jQuery( document ).trigger( "ready" ).unbind( "ready" ); + } + } + }, + + bindReady: function() { + if ( readyList ) { + return; + } + + readyList = jQuery.Callbacks( "once memory" ); + + // Catch cases where $(document).ready() is called after the + // browser event has already occurred. + if ( document.readyState === "complete" ) { + // Handle it asynchronously to allow scripts the opportunity to delay ready + return setTimeout( jQuery.ready, 1 ); + } + + // Mozilla, Opera and webkit nightlies currently support this event + if ( document.addEventListener ) { + // Use the handy event callback + document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false ); + + // A fallback to window.onload, that will always work + window.addEventListener( "load", jQuery.ready, false ); + + // If IE event model is used + } else if ( document.attachEvent ) { + // ensure firing before onload, + // maybe late but safe also for iframes + document.attachEvent( "onreadystatechange", DOMContentLoaded ); + + // A fallback to window.onload, that will always work + window.attachEvent( "onload", jQuery.ready ); + + // If IE and not a frame + // continually check to see if the document is ready + var toplevel = false; + + try { + toplevel = window.frameElement == null; + } catch(e) {} + + if ( document.documentElement.doScroll && toplevel ) { + doScrollCheck(); + } + } + }, + + // See test/unit/core.js for details concerning isFunction. + // Since version 1.3, DOM methods and functions like alert + // aren't supported. They return false on IE (#2968). + isFunction: function( obj ) { + return jQuery.type(obj) === "function"; + }, + + isArray: Array.isArray || function( obj ) { + return jQuery.type(obj) === "array"; + }, + + // A crude way of determining if an object is a window + isWindow: function( obj ) { + return obj && typeof obj === "object" && "setInterval" in obj; + }, + + isNumeric: function( obj ) { + return obj != null && rdigit.test( obj ) && !isNaN( obj ); + }, + + type: function( obj ) { + return obj == null ? + String( obj ) : + class2type[ toString.call(obj) ] || "object"; + }, + + isPlainObject: function( obj ) { + // Must be an Object. + // Because of IE, we also have to check the presence of the constructor property. + // Make sure that DOM nodes and window objects don't pass through, as well + if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { + return false; + } + + try { + // Not own constructor property must be Object + if ( obj.constructor && + !hasOwn.call(obj, "constructor") && + !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { + return false; + } + } catch ( e ) { + // IE8,9 Will throw exceptions on certain host objects #9897 + return false; + } + + // Own properties are enumerated firstly, so to speed up, + // if last one is own, then all properties are own. + + var key; + for ( key in obj ) {} + + return key === undefined || hasOwn.call( obj, key ); + }, + + isEmptyObject: function( obj ) { + for ( var name in obj ) { + return false; + } + return true; + }, + + error: function( msg ) { + throw msg; + }, + + parseJSON: function( data ) { + if ( typeof data !== "string" || !data ) { + return null; + } + + // Make sure leading/trailing whitespace is removed (IE can't handle it) + data = jQuery.trim( data ); + + // Attempt to parse using the native JSON parser first + if ( window.JSON && window.JSON.parse ) { + return window.JSON.parse( data ); + } + + // Make sure the incoming data is actual JSON + // Logic borrowed from http://json.org/json2.js + if ( rvalidchars.test( data.replace( rvalidescape, "@" ) + .replace( rvalidtokens, "]" ) + .replace( rvalidbraces, "")) ) { + + return ( new Function( "return " + data ) )(); + + } + jQuery.error( "Invalid JSON: " + data ); + }, + + // Cross-browser xml parsing + parseXML: function( data ) { + var xml, tmp; + try { + if ( window.DOMParser ) { // Standard + tmp = new DOMParser(); + xml = tmp.parseFromString( data , "text/xml" ); + } else { // IE + xml = new ActiveXObject( "Microsoft.XMLDOM" ); + xml.async = "false"; + xml.loadXML( data ); + } + } catch( e ) { + xml = undefined; + } + if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) { + jQuery.error( "Invalid XML: " + data ); + } + return xml; + }, + + noop: function() {}, + + // Evaluates a script in a global context + // Workarounds based on findings by Jim Driscoll + // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context + globalEval: function( data ) { + if ( data && rnotwhite.test( data ) ) { + // We use execScript on Internet Explorer + // We use an anonymous function so that context is window + // rather than jQuery in Firefox + ( window.execScript || function( data ) { + window[ "eval" ].call( window, data ); + } )( data ); + } + }, + + // Convert dashed to camelCase; used by the css and data modules + // Microsoft forgot to hump their vendor prefix (#9572) + camelCase: function( string ) { + return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); + }, + + nodeName: function( elem, name ) { + return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase(); + }, + + // args is for internal usage only + each: function( object, callback, args ) { + var name, i = 0, + length = object.length, + isObj = length === undefined || jQuery.isFunction( object ); + + if ( args ) { + if ( isObj ) { + for ( name in object ) { + if ( callback.apply( object[ name ], args ) === false ) { + break; + } + } + } else { + for ( ; i < length; ) { + if ( callback.apply( object[ i++ ], args ) === false ) { + break; + } + } + } + + // A special, fast, case for the most common use of each + } else { + if ( isObj ) { + for ( name in object ) { + if ( callback.call( object[ name ], name, object[ name ] ) === false ) { + break; + } + } + } else { + for ( ; i < length; ) { + if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) { + break; + } + } + } + } + + return object; + }, + + // Use native String.trim function wherever possible + trim: trim ? + function( text ) { + return text == null ? + "" : + trim.call( text ); + } : + + // Otherwise use our own trimming functionality + function( text ) { + return text == null ? + "" : + text.toString().replace( trimLeft, "" ).replace( trimRight, "" ); + }, + + // results is for internal usage only + makeArray: function( array, results ) { + var ret = results || []; + + if ( array != null ) { + // The window, strings (and functions) also have 'length' + // The extra typeof function check is to prevent crashes + // in Safari 2 (See: #3039) + // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930 + var type = jQuery.type( array ); + + if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) { + push.call( ret, array ); + } else { + jQuery.merge( ret, array ); + } + } + + return ret; + }, + + inArray: function( elem, array, i ) { + var len; + + if ( array ) { + if ( indexOf ) { + return indexOf.call( array, elem, i ); + } + + len = array.length; + i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0; + + for ( ; i < len; i++ ) { + // Skip accessing in sparse arrays + if ( i in array && array[ i ] === elem ) { + return i; + } + } + } + + return -1; + }, + + merge: function( first, second ) { + var i = first.length, + j = 0; + + if ( typeof second.length === "number" ) { + for ( var l = second.length; j < l; j++ ) { + first[ i++ ] = second[ j ]; + } + + } else { + while ( second[j] !== undefined ) { + first[ i++ ] = second[ j++ ]; + } + } + + first.length = i; + + return first; + }, + + grep: function( elems, callback, inv ) { + var ret = [], retVal; + inv = !!inv; + + // Go through the array, only saving the items + // that pass the validator function + for ( var i = 0, length = elems.length; i < length; i++ ) { + retVal = !!callback( elems[ i ], i ); + if ( inv !== retVal ) { + ret.push( elems[ i ] ); + } + } + + return ret; + }, + + // arg is for internal usage only + map: function( elems, callback, arg ) { + var value, key, ret = [], + i = 0, + length = elems.length, + // jquery objects are treated as arrays + isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ; + + // Go through the array, translating each of the items to their + if ( isArray ) { + for ( ; i < length; i++ ) { + value = callback( elems[ i ], i, arg ); + + if ( value != null ) { + ret[ ret.length ] = value; + } + } + + // Go through every key on the object, + } else { + for ( key in elems ) { + value = callback( elems[ key ], key, arg ); + + if ( value != null ) { + ret[ ret.length ] = value; + } + } + } + + // Flatten any nested arrays + return ret.concat.apply( [], ret ); + }, + + // A global GUID counter for objects + guid: 1, + + // Bind a function to a context, optionally partially applying any + // arguments. + proxy: function( fn, context ) { + if ( typeof context === "string" ) { + var tmp = fn[ context ]; + context = fn; + fn = tmp; + } + + // Quick check to determine if target is callable, in the spec + // this throws a TypeError, but we will just return undefined. + if ( !jQuery.isFunction( fn ) ) { + return undefined; + } + + // Simulated bind + var args = slice.call( arguments, 2 ), + proxy = function() { + return fn.apply( context, args.concat( slice.call( arguments ) ) ); + }; + + // Set the guid of unique handler to the same of original handler, so it can be removed + proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++; + + return proxy; + }, + + // Mutifunctional method to get and set values to a collection + // The value/s can optionally be executed if it's a function + access: function( elems, key, value, exec, fn, pass ) { + var length = elems.length; + + // Setting many attributes + if ( typeof key === "object" ) { + for ( var k in key ) { + jQuery.access( elems, k, key[k], exec, fn, value ); + } + return elems; + } + + // Setting one attribute + if ( value !== undefined ) { + // Optionally, function values get executed if exec is true + exec = !pass && exec && jQuery.isFunction(value); + + for ( var i = 0; i < length; i++ ) { + fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass ); + } + + return elems; + } + + // Getting an attribute + return length ? fn( elems[0], key ) : undefined; + }, + + now: function() { + return ( new Date() ).getTime(); + }, + + // Use of jQuery.browser is frowned upon. + // More details: http://docs.jquery.com/Utilities/jQuery.browser + uaMatch: function( ua ) { + ua = ua.toLowerCase(); + + var match = rwebkit.exec( ua ) || + ropera.exec( ua ) || + rmsie.exec( ua ) || + ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) || + []; + + return { browser: match[1] || "", version: match[2] || "0" }; + }, + + sub: function() { + function jQuerySub( selector, context ) { + return new jQuerySub.fn.init( selector, context ); + } + jQuery.extend( true, jQuerySub, this ); + jQuerySub.superclass = this; + jQuerySub.fn = jQuerySub.prototype = this(); + jQuerySub.fn.constructor = jQuerySub; + jQuerySub.sub = this.sub; + jQuerySub.fn.init = function init( selector, context ) { + if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) { + context = jQuerySub( context ); + } + + return jQuery.fn.init.call( this, selector, context, rootjQuerySub ); + }; + jQuerySub.fn.init.prototype = jQuerySub.fn; + var rootjQuerySub = jQuerySub(document); + return jQuerySub; + }, + + browser: {} + }); + + // Populate the class2type map + jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) { + class2type[ "[object " + name + "]" ] = name.toLowerCase(); + }); + + browserMatch = jQuery.uaMatch( userAgent ); + if ( browserMatch.browser ) { + jQuery.browser[ browserMatch.browser ] = true; + jQuery.browser.version = browserMatch.version; + } + + // Deprecated, use jQuery.browser.webkit instead + if ( jQuery.browser.webkit ) { + jQuery.browser.safari = true; + } + + // IE doesn't match non-breaking spaces with \s + if ( rnotwhite.test( "\xA0" ) ) { + trimLeft = /^[\s\xA0]+/; + trimRight = /[\s\xA0]+$/; + } + + // All jQuery objects should point back to these + rootjQuery = jQuery(document); + + // Cleanup functions for the document ready method + if ( document.addEventListener ) { + DOMContentLoaded = function() { + document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false ); + jQuery.ready(); + }; + + } else if ( document.attachEvent ) { + DOMContentLoaded = function() { + // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). + if ( document.readyState === "complete" ) { + document.detachEvent( "onreadystatechange", DOMContentLoaded ); + jQuery.ready(); + } + }; + } + + // The DOM ready check for Internet Explorer + function doScrollCheck() { + if ( jQuery.isReady ) { + return; + } + + try { + // If IE is used, use the trick by Diego Perini + // http://javascript.nwbox.com/IEContentLoaded/ + document.documentElement.doScroll("left"); + } catch(e) { + setTimeout( doScrollCheck, 1 ); + return; + } + + // and execute any waiting functions + jQuery.ready(); + } + + // Expose jQuery as an AMD module, but only for AMD loaders that + // understand the issues with loading multiple versions of jQuery + // in a page that all might call define(). The loader will indicate + // they have special allowances for multiple jQuery versions by + // specifying define.amd.jQuery = true. Register as a named module, + // since jQuery can be concatenated with other files that may use define, + // but not use a proper concatenation script that understands anonymous + // AMD modules. A named AMD is safest and most robust way to register. + // Lowercase jquery is used because AMD module names are derived from + // file names, and jQuery is normally delivered in a lowercase file name. + if ( typeof define === "function" && define.amd && define.amd.jQuery ) { + define( "jquery", [], function () { return jQuery; } ); + } + + return jQuery; + + })(); + + + // String to Object flags format cache + var flagsCache = {}; + + // Convert String-formatted flags into Object-formatted ones and store in cache + function createFlags( flags ) { + var object = flagsCache[ flags ] = {}, + i, length; + flags = flags.split( /\s+/ ); + for ( i = 0, length = flags.length; i < length; i++ ) { + object[ flags[i] ] = true; + } + return object; + } + + /* + * Create a callback list using the following parameters: + * + * flags: an optional list of space-separated flags that will change how + * the callback list behaves + * + * By default a callback list will act like an event callback list and can be + * "fired" multiple times. + * + * Possible flags: + * + * once: will ensure the callback list can only be fired once (like a Deferred) + * + * memory: will keep track of previous values and will call any callback added + * after the list has been fired right away with the latest "memorized" + * values (like a Deferred) + * + * unique: will ensure a callback can only be added once (no duplicate in the list) + * + * stopOnFalse: interrupt callings when a callback returns false + * + */ + jQuery.Callbacks = function( flags ) { + + // Convert flags from String-formatted to Object-formatted + // (we check in cache first) + flags = flags ? ( flagsCache[ flags ] || createFlags( flags ) ) : {}; + + var // Actual callback list + list = [], + // Stack of fire calls for repeatable lists + stack = [], + // Last fire value (for non-forgettable lists) + memory, + // Flag to know if list is currently firing + firing, + // First callback to fire (used internally by add and fireWith) + firingStart, + // End of the loop when firing + firingLength, + // Index of currently firing callback (modified by remove if needed) + firingIndex, + // Add one or several callbacks to the list + add = function( args ) { + var i, + length, + elem, + type, + actual; + for ( i = 0, length = args.length; i < length; i++ ) { + elem = args[ i ]; + type = jQuery.type( elem ); + if ( type === "array" ) { + // Inspect recursively + add( elem ); + } else if ( type === "function" ) { + // Add if not in unique mode and callback is not in + if ( !flags.unique || !self.has( elem ) ) { + list.push( elem ); + } + } + } + }, + // Fire callbacks + fire = function( context, args ) { + args = args || []; + memory = !flags.memory || [ context, args ]; + firing = true; + firingIndex = firingStart || 0; + firingStart = 0; + firingLength = list.length; + for ( ; list && firingIndex < firingLength; firingIndex++ ) { + if ( list[ firingIndex ].apply( context, args ) === false && flags.stopOnFalse ) { + memory = true; // Mark as halted + break; + } + } + firing = false; + if ( list ) { + if ( !flags.once ) { + if ( stack && stack.length ) { + memory = stack.shift(); + self.fireWith( memory[ 0 ], memory[ 1 ] ); + } + } else if ( memory === true ) { + self.disable(); + } else { + list = []; + } + } + }, + // Actual Callbacks object + self = { + // Add a callback or a collection of callbacks to the list + add: function() { + if ( list ) { + var length = list.length; + add( arguments ); + // Do we need to add the callbacks to the + // current firing batch? + if ( firing ) { + firingLength = list.length; + // With memory, if we're not firing then + // we should call right away, unless previous + // firing was halted (stopOnFalse) + } else if ( memory && memory !== true ) { + firingStart = length; + fire( memory[ 0 ], memory[ 1 ] ); + } + } + return this; + }, + // Remove a callback from the list + remove: function() { + if ( list ) { + var args = arguments, + argIndex = 0, + argLength = args.length; + for ( ; argIndex < argLength ; argIndex++ ) { + for ( var i = 0; i < list.length; i++ ) { + if ( args[ argIndex ] === list[ i ] ) { + // Handle firingIndex and firingLength + if ( firing ) { + if ( i <= firingLength ) { + firingLength--; + if ( i <= firingIndex ) { + firingIndex--; + } + } + } + // Remove the element + list.splice( i--, 1 ); + // If we have some unicity property then + // we only need to do this once + if ( flags.unique ) { + break; + } + } + } + } + } + return this; + }, + // Control if a given callback is in the list + has: function( fn ) { + if ( list ) { + var i = 0, + length = list.length; + for ( ; i < length; i++ ) { + if ( fn === list[ i ] ) { + return true; + } + } + } + return false; + }, + // Remove all callbacks from the list + empty: function() { + list = []; + return this; + }, + // Have the list do nothing anymore + disable: function() { + list = stack = memory = undefined; + return this; + }, + // Is it disabled? + disabled: function() { + return !list; + }, + // Lock the list in its current state + lock: function() { + stack = undefined; + if ( !memory || memory === true ) { + self.disable(); + } + return this; + }, + // Is it locked? + locked: function() { + return !stack; + }, + // Call all callbacks with the given context and arguments + fireWith: function( context, args ) { + if ( stack ) { + if ( firing ) { + if ( !flags.once ) { + stack.push( [ context, args ] ); + } + } else if ( !( flags.once && memory ) ) { + fire( context, args ); + } + } + return this; + }, + // Call all the callbacks with the given arguments + fire: function() { + self.fireWith( this, arguments ); + return this; + }, + // To know if the callbacks have already been called at least once + fired: function() { + return !!memory; + } + }; + + return self; + }; + + + + + var // Static reference to slice + sliceDeferred = [].slice; + + jQuery.extend({ + + Deferred: function( func ) { + var doneList = jQuery.Callbacks( "once memory" ), + failList = jQuery.Callbacks( "once memory" ), + progressList = jQuery.Callbacks( "memory" ), + state = "pending", + lists = { + resolve: doneList, + reject: failList, + notify: progressList + }, + promise = { + done: doneList.add, + fail: failList.add, + progress: progressList.add, + + state: function() { + return state; + }, + + // Deprecated + isResolved: doneList.fired, + isRejected: failList.fired, + + then: function( doneCallbacks, failCallbacks, progressCallbacks ) { + deferred.done( doneCallbacks ).fail( failCallbacks ).progress( progressCallbacks ); + return this; + }, + always: function() { + return deferred.done.apply( deferred, arguments ).fail.apply( deferred, arguments ); + }, + pipe: function( fnDone, fnFail, fnProgress ) { + return jQuery.Deferred(function( newDefer ) { + jQuery.each( { + done: [ fnDone, "resolve" ], + fail: [ fnFail, "reject" ], + progress: [ fnProgress, "notify" ] + }, function( handler, data ) { + var fn = data[ 0 ], + action = data[ 1 ], + returned; + if ( jQuery.isFunction( fn ) ) { + deferred[ handler ](function() { + returned = fn.apply( this, arguments ); + if ( returned && jQuery.isFunction( returned.promise ) ) { + returned.promise().then( newDefer.resolve, newDefer.reject, newDefer.notify ); + } else { + newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] ); + } + }); + } else { + deferred[ handler ]( newDefer[ action ] ); + } + }); + }).promise(); + }, + // Get a promise for this deferred + // If obj is provided, the promise aspect is added to the object + promise: function( obj ) { + if ( obj == null ) { + obj = promise; + } else { + for ( var key in promise ) { + obj[ key ] = promise[ key ]; + } + } + return obj; + } + }, + deferred = promise.promise({}), + key; + + for ( key in lists ) { + deferred[ key ] = lists[ key ].fire; + deferred[ key + "With" ] = lists[ key ].fireWith; + } + + // Handle state + deferred.done( function() { + state = "resolved"; + }, failList.disable, progressList.lock ).fail( function() { + state = "rejected"; + }, doneList.disable, progressList.lock ); + + // Call given func if any + if ( func ) { + func.call( deferred, deferred ); + } + + // All done! + return deferred; + }, + + // Deferred helper + when: function( firstParam ) { + var args = sliceDeferred.call( arguments, 0 ), + i = 0, + length = args.length, + pValues = new Array( length ), + count = length, + pCount = length, + deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ? + firstParam : + jQuery.Deferred(), + promise = deferred.promise(); + function resolveFunc( i ) { + return function( value ) { + args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; + if ( !( --count ) ) { + deferred.resolveWith( deferred, args ); + } + }; + } + function progressFunc( i ) { + return function( value ) { + pValues[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; + deferred.notifyWith( promise, pValues ); + }; + } + if ( length > 1 ) { + for ( ; i < length; i++ ) { + if ( args[ i ] && args[ i ].promise && jQuery.isFunction( args[ i ].promise ) ) { + args[ i ].promise().then( resolveFunc(i), deferred.reject, progressFunc(i) ); + } else { + --count; + } + } + if ( !count ) { + deferred.resolveWith( deferred, args ); + } + } else if ( deferred !== firstParam ) { + deferred.resolveWith( deferred, length ? [ firstParam ] : [] ); + } + return promise; + } + }); + + + + + jQuery.support = (function() { + + var div = document.createElement( "div" ), + documentElement = document.documentElement, + all, + a, + select, + opt, + input, + marginDiv, + support, + fragment, + body, + testElementParent, + testElement, + testElementStyle, + tds, + events, + eventName, + i, + isSupported; + + // Preliminary tests + div.setAttribute("className", "t"); + div.innerHTML = "
a"; + + + all = div.getElementsByTagName( "*" ); + a = div.getElementsByTagName( "a" )[ 0 ]; + + // Can't get basic test support + if ( !all || !all.length || !a ) { + return {}; + } + + // First batch of supports tests + select = document.createElement( "select" ); + opt = select.appendChild( document.createElement("option") ); + input = div.getElementsByTagName( "input" )[ 0 ]; + + support = { + // IE strips leading whitespace when .innerHTML is used + leadingWhitespace: ( div.firstChild.nodeType === 3 ), + + // Make sure that tbody elements aren't automatically inserted + // IE will insert them into empty tables + tbody: !div.getElementsByTagName( "tbody" ).length, + + // Make sure that link elements get serialized correctly by innerHTML + // This requires a wrapper element in IE + htmlSerialize: !!div.getElementsByTagName( "link" ).length, + + // Get the style information from getAttribute + // (IE uses .cssText instead) + style: /top/.test( a.getAttribute("style") ), + + // Make sure that URLs aren't manipulated + // (IE normalizes it by default) + hrefNormalized: ( a.getAttribute( "href" ) === "/a" ), + + // Make sure that element opacity exists + // (IE uses filter instead) + // Use a regex to work around a WebKit issue. See #5145 + opacity: /^0.55/.test( a.style.opacity ), + + // Verify style float existence + // (IE uses styleFloat instead of cssFloat) + cssFloat: !!a.style.cssFloat, + + // Make sure unknown elements (like HTML5 elems) are handled appropriately + unknownElems: !!div.getElementsByTagName( "nav" ).length, + + // Make sure that if no value is specified for a checkbox + // that it defaults to "on". + // (WebKit defaults to "" instead) + checkOn: ( input.value === "on" ), + + // Make sure that a selected-by-default option has a working selected property. + // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) + optSelected: opt.selected, + + // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7) + getSetAttribute: div.className !== "t", + + // Tests for enctype support on a form(#6743) + enctype: !!document.createElement("form").enctype, + + // Will be defined later + submitBubbles: true, + changeBubbles: true, + focusinBubbles: false, + deleteExpando: true, + noCloneEvent: true, + inlineBlockNeedsLayout: false, + shrinkWrapBlocks: false, + reliableMarginRight: true + }; + + // Make sure checked status is properly cloned + input.checked = true; + support.noCloneChecked = input.cloneNode( true ).checked; + + // Make sure that the options inside disabled selects aren't marked as disabled + // (WebKit marks them as disabled) + select.disabled = true; + support.optDisabled = !opt.disabled; + + // Test to see if it's possible to delete an expando from an element + // Fails in Internet Explorer + try { + delete div.test; + } catch( e ) { + support.deleteExpando = false; + } + + if ( !div.addEventListener && div.attachEvent && div.fireEvent ) { + div.attachEvent( "onclick", function() { + // Cloning a node shouldn't copy over any + // bound event handlers (IE does this) + support.noCloneEvent = false; + }); + div.cloneNode( true ).fireEvent( "onclick" ); + } + + // Check if a radio maintains its value + // after being appended to the DOM + input = document.createElement("input"); + input.value = "t"; + input.setAttribute("type", "radio"); + support.radioValue = input.value === "t"; + + input.setAttribute("checked", "checked"); + div.appendChild( input ); + fragment = document.createDocumentFragment(); + fragment.appendChild( div.lastChild ); + + // WebKit doesn't clone checked state correctly in fragments + support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked; + + div.innerHTML = ""; + + // Figure out if the W3C box model works as expected + div.style.width = div.style.paddingLeft = "1px"; + + // We don't want to do body-related feature tests on frameset + // documents, which lack a body. So we use + // document.getElementsByTagName("body")[0], which is undefined in + // frameset documents, while document.body isn’t. (7398) + body = document.getElementsByTagName("body")[ 0 ]; + // We use our own, invisible, body unless the body is already present + // in which case we use a div (#9239) + testElement = document.createElement( body ? "div" : "body" ); + testElementStyle = { + visibility: "hidden", + width: 0, + height: 0, + border: 0, + margin: 0, + background: "none" + }; + if ( body ) { + jQuery.extend( testElementStyle, { + position: "absolute", + left: "-999px", + top: "-999px" + }); + } + for ( i in testElementStyle ) { + testElement.style[ i ] = testElementStyle[ i ]; + } + testElement.appendChild( div ); + testElementParent = body || documentElement; + testElementParent.insertBefore( testElement, testElementParent.firstChild ); + + // Check if a disconnected checkbox will retain its checked + // value of true after appended to the DOM (IE6/7) + support.appendChecked = input.checked; + + support.boxModel = div.offsetWidth === 2; + + if ( "zoom" in div.style ) { + // Check if natively block-level elements act like inline-block + // elements when setting their display to 'inline' and giving + // them layout + // (IE < 8 does this) + div.style.display = "inline"; + div.style.zoom = 1; + support.inlineBlockNeedsLayout = ( div.offsetWidth === 2 ); + + // Check if elements with layout shrink-wrap their children + // (IE 6 does this) + div.style.display = ""; + div.innerHTML = "
"; + support.shrinkWrapBlocks = ( div.offsetWidth !== 2 ); + } + + div.innerHTML = "
t
"; + tds = div.getElementsByTagName( "td" ); + + // Check if table cells still have offsetWidth/Height when they are set + // to display:none and there are still other visible table cells in a + // table row; if so, offsetWidth/Height are not reliable for use when + // determining if an element has been hidden directly using + // display:none (it is still safe to use offsets if a parent element is + // hidden; don safety goggles and see bug #4512 for more information). + // (only IE 8 fails this test) + isSupported = ( tds[ 0 ].offsetHeight === 0 ); + + tds[ 0 ].style.display = ""; + tds[ 1 ].style.display = "none"; + + // Check if empty table cells still have offsetWidth/Height + // (IE < 8 fail this test) + support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 ); + div.innerHTML = ""; + + // Check if div with explicit width and no margin-right incorrectly + // gets computed margin-right based on width of container. For more + // info see bug #3333 + // Fails in WebKit before Feb 2011 nightlies + // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right + if ( document.defaultView && document.defaultView.getComputedStyle ) { + marginDiv = document.createElement( "div" ); + marginDiv.style.width = "0"; + marginDiv.style.marginRight = "0"; + div.appendChild( marginDiv ); + support.reliableMarginRight = + ( parseInt( ( document.defaultView.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0; + } + + // Technique from Juriy Zaytsev + // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/ + // We only care about the case where non-standard event systems + // are used, namely in IE. Short-circuiting here helps us to + // avoid an eval call (in setAttribute) which can cause CSP + // to go haywire. See: https://developer.mozilla.org/en/Security/CSP + if ( div.attachEvent ) { + for( i in { + submit: 1, + change: 1, + focusin: 1 + } ) { + eventName = "on" + i; + isSupported = ( eventName in div ); + if ( !isSupported ) { + div.setAttribute( eventName, "return;" ); + isSupported = ( typeof div[ eventName ] === "function" ); + } + support[ i + "Bubbles" ] = isSupported; + } + } + + // Run fixed position tests at doc ready to avoid a crash + // related to the invisible body in IE8 + jQuery(function() { + var container, outer, inner, table, td, offsetSupport, + conMarginTop = 1, + ptlm = "position:absolute;top:0;left:0;width:1px;height:1px;margin:0;", + vb = "visibility:hidden;border:0;", + style = "style='" + ptlm + "border:5px solid #000;padding:0;'", + html = "
" + + "" + + "
"; + + // Reconstruct a container + body = document.getElementsByTagName("body")[0]; + if ( !body ) { + // Return for frameset docs that don't have a body + // These tests cannot be done + return; + } + + container = document.createElement("div"); + container.style.cssText = vb + "width:0;height:0;position:static;top:0;margin-top:" + conMarginTop + "px"; + body.insertBefore( container, body.firstChild ); + + // Construct a test element + testElement = document.createElement("div"); + testElement.style.cssText = ptlm + vb; + + testElement.innerHTML = html; + container.appendChild( testElement ); + outer = testElement.firstChild; + inner = outer.firstChild; + td = outer.nextSibling.firstChild.firstChild; + + offsetSupport = { + doesNotAddBorder: ( inner.offsetTop !== 5 ), + doesAddBorderForTableAndCells: ( td.offsetTop === 5 ) + }; + + inner.style.position = "fixed"; + inner.style.top = "20px"; + + // safari subtracts parent border width here which is 5px + offsetSupport.fixedPosition = ( inner.offsetTop === 20 || inner.offsetTop === 15 ); + inner.style.position = inner.style.top = ""; + + outer.style.overflow = "hidden"; + outer.style.position = "relative"; + + offsetSupport.subtractsBorderForOverflowNotVisible = ( inner.offsetTop === -5 ); + offsetSupport.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== conMarginTop ); + + body.removeChild( container ); + testElement = container = null; + + jQuery.extend( support, offsetSupport ); + }); + + testElement.innerHTML = ""; + testElementParent.removeChild( testElement ); + + // Null connected elements to avoid leaks in IE + testElement = fragment = select = opt = body = marginDiv = div = input = null; + + return support; + })(); + + // Keep track of boxModel + jQuery.boxModel = jQuery.support.boxModel; + + + + + var rbrace = /^(?:\{.*\}|\[.*\])$/, + rmultiDash = /([A-Z])/g; + + jQuery.extend({ + cache: {}, + + // Please use with caution + uuid: 0, + + // Unique for each copy of jQuery on the page + // Non-digits removed to match rinlinejQuery + expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ), + + // The following elements throw uncatchable exceptions if you + // attempt to add expando properties to them. + noData: { + "embed": true, + // Ban all objects except for Flash (which handle expandos) + "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000", + "applet": true + }, + + hasData: function( elem ) { + elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; + return !!elem && !isEmptyDataObject( elem ); + }, + + data: function( elem, name, data, pvt /* Internal Use Only */ ) { + if ( !jQuery.acceptData( elem ) ) { + return; + } + + var privateCache, thisCache, ret, + internalKey = jQuery.expando, + getByName = typeof name === "string", + + // We have to handle DOM nodes and JS objects differently because IE6-7 + // can't GC object references properly across the DOM-JS boundary + isNode = elem.nodeType, + + // Only DOM nodes need the global jQuery cache; JS object data is + // attached directly to the object so GC can occur automatically + cache = isNode ? jQuery.cache : elem, + + // Only defining an ID for JS objects if its cache already exists allows + // the code to shortcut on the same path as a DOM node with no cache + id = isNode ? elem[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando, + isEvents = name === "events"; + + // Avoid doing any more work than we need to when trying to get data on an + // object that has no data at all + if ( (!id || !cache[id] || (!isEvents && !pvt && !cache[id].data)) && getByName && data === undefined ) { + return; + } + + if ( !id ) { + // Only DOM nodes need a new unique ID for each element since their data + // ends up in the global cache + if ( isNode ) { + elem[ jQuery.expando ] = id = ++jQuery.uuid; + } else { + id = jQuery.expando; + } + } + + if ( !cache[ id ] ) { + cache[ id ] = {}; + + // Avoids exposing jQuery metadata on plain JS objects when the object + // is serialized using JSON.stringify + if ( !isNode ) { + cache[ id ].toJSON = jQuery.noop; + } + } + + // An object can be passed to jQuery.data instead of a key/value pair; this gets + // shallow copied over onto the existing cache + if ( typeof name === "object" || typeof name === "function" ) { + if ( pvt ) { + cache[ id ] = jQuery.extend( cache[ id ], name ); + } else { + cache[ id ].data = jQuery.extend( cache[ id ].data, name ); + } + } + + privateCache = thisCache = cache[ id ]; + + // jQuery data() is stored in a separate object inside the object's internal data + // cache in order to avoid key collisions between internal data and user-defined + // data. + if ( !pvt ) { + if ( !thisCache.data ) { + thisCache.data = {}; + } + + thisCache = thisCache.data; + } + + if ( data !== undefined ) { + thisCache[ jQuery.camelCase( name ) ] = data; + } + + // Users should not attempt to inspect the internal events object using jQuery.data, + // it is undocumented and subject to change. But does anyone listen? No. + if ( isEvents && !thisCache[ name ] ) { + return privateCache.events; + } + + // Check for both converted-to-camel and non-converted data property names + // If a data property was specified + if ( getByName ) { + + // First Try to find as-is property data + ret = thisCache[ name ]; + + // Test for null|undefined property data + if ( ret == null ) { + + // Try to find the camelCased property + ret = thisCache[ jQuery.camelCase( name ) ]; + } + } else { + ret = thisCache; + } + + return ret; + }, + + removeData: function( elem, name, pvt /* Internal Use Only */ ) { + if ( !jQuery.acceptData( elem ) ) { + return; + } + + var thisCache, i, l, + + // Reference to internal data cache key + internalKey = jQuery.expando, + + isNode = elem.nodeType, + + // See jQuery.data for more information + cache = isNode ? jQuery.cache : elem, + + // See jQuery.data for more information + id = isNode ? elem[ jQuery.expando ] : jQuery.expando; + + // If there is already no cache entry for this object, there is no + // purpose in continuing + if ( !cache[ id ] ) { + return; + } + + if ( name ) { + + thisCache = pvt ? cache[ id ] : cache[ id ].data; + + if ( thisCache ) { + + // Support space separated names + if ( jQuery.isArray( name ) ) { + name = name; + } else if ( name in thisCache ) { + name = [ name ]; + } else { + + // split the camel cased version by spaces + name = jQuery.camelCase( name ); + if ( name in thisCache ) { + name = [ name ]; + } else { + name = name.split( " " ); + } + } + + for ( i = 0, l = name.length; i < l; i++ ) { + delete thisCache[ name[i] ]; + } + + // If there is no data left in the cache, we want to continue + // and let the cache object itself get destroyed + if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) { + return; + } + } + } + + // See jQuery.data for more information + if ( !pvt ) { + delete cache[ id ].data; + + // Don't destroy the parent cache unless the internal data object + // had been the only thing left in it + if ( !isEmptyDataObject(cache[ id ]) ) { + return; + } + } + + // Browsers that fail expando deletion also refuse to delete expandos on + // the window, but it will allow it on all other JS objects; other browsers + // don't care + // Ensure that `cache` is not a window object #10080 + if ( jQuery.support.deleteExpando || !cache.setInterval ) { + delete cache[ id ]; + } else { + cache[ id ] = null; + } + + // We destroyed the cache and need to eliminate the expando on the node to avoid + // false lookups in the cache for entries that no longer exist + if ( isNode ) { + // IE does not allow us to delete expando properties from nodes, + // nor does it have a removeAttribute function on Document nodes; + // we must handle all of these cases + if ( jQuery.support.deleteExpando ) { + delete elem[ jQuery.expando ]; + } else if ( elem.removeAttribute ) { + elem.removeAttribute( jQuery.expando ); + } else { + elem[ jQuery.expando ] = null; + } + } + }, + + // For internal use only. + _data: function( elem, name, data ) { + return jQuery.data( elem, name, data, true ); + }, + + // A method for determining if a DOM node can handle the data expando + acceptData: function( elem ) { + if ( elem.nodeName ) { + var match = jQuery.noData[ elem.nodeName.toLowerCase() ]; + + if ( match ) { + return !(match === true || elem.getAttribute("classid") !== match); + } + } + + return true; + } + }); + + jQuery.fn.extend({ + data: function( key, value ) { + var parts, attr, name, + data = null; + + if ( typeof key === "undefined" ) { + if ( this.length ) { + data = jQuery.data( this[0] ); + + if ( this[0].nodeType === 1 && !jQuery._data( this[0], "parsedAttrs" ) ) { + attr = this[0].attributes; + for ( var i = 0, l = attr.length; i < l; i++ ) { + name = attr[i].name; + + if ( name.indexOf( "data-" ) === 0 ) { + name = jQuery.camelCase( name.substring(5) ); + + dataAttr( this[0], name, data[ name ] ); + } + } + jQuery._data( this[0], "parsedAttrs", true ); + } + } + + return data; + + } else if ( typeof key === "object" ) { + return this.each(function() { + jQuery.data( this, key ); + }); + } + + parts = key.split("."); + parts[1] = parts[1] ? "." + parts[1] : ""; + + if ( value === undefined ) { + data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]); + + // Try to fetch any internally stored data first + if ( data === undefined && this.length ) { + data = jQuery.data( this[0], key ); + data = dataAttr( this[0], key, data ); + } + + return data === undefined && parts[1] ? + this.data( parts[0] ) : + data; + + } else { + return this.each(function() { + var $this = jQuery( this ), + args = [ parts[0], value ]; + + $this.triggerHandler( "setData" + parts[1] + "!", args ); + jQuery.data( this, key, value ); + $this.triggerHandler( "changeData" + parts[1] + "!", args ); + }); + } + }, + + removeData: function( key ) { + return this.each(function() { + jQuery.removeData( this, key ); + }); + } + }); + + function dataAttr( elem, key, data ) { + // If nothing was found internally, try to fetch any + // data from the HTML5 data-* attribute + if ( data === undefined && elem.nodeType === 1 ) { + + var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); + + data = elem.getAttribute( name ); + + if ( typeof data === "string" ) { + try { + data = data === "true" ? true : + data === "false" ? false : + data === "null" ? null : + jQuery.isNumeric( data ) ? parseFloat( data ) : + rbrace.test( data ) ? jQuery.parseJSON( data ) : + data; + } catch( e ) {} + + // Make sure we set the data so it isn't changed later + jQuery.data( elem, key, data ); + + } else { + data = undefined; + } + } + + return data; + } + + // checks a cache object for emptiness + function isEmptyDataObject( obj ) { + for ( var name in obj ) { + + // if the public data object is empty, the private is still empty + if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) { + continue; + } + if ( name !== "toJSON" ) { + return false; + } + } + + return true; + } + + + + + function handleQueueMarkDefer( elem, type, src ) { + var deferDataKey = type + "defer", + queueDataKey = type + "queue", + markDataKey = type + "mark", + defer = jQuery._data( elem, deferDataKey ); + if ( defer && + ( src === "queue" || !jQuery._data(elem, queueDataKey) ) && + ( src === "mark" || !jQuery._data(elem, markDataKey) ) ) { + // Give room for hard-coded callbacks to fire first + // and eventually mark/queue something else on the element + setTimeout( function() { + if ( !jQuery._data( elem, queueDataKey ) && + !jQuery._data( elem, markDataKey ) ) { + jQuery.removeData( elem, deferDataKey, true ); + defer.fire(); + } + }, 0 ); + } + } + + jQuery.extend({ + + _mark: function( elem, type ) { + if ( elem ) { + type = ( type || "fx" ) + "mark"; + jQuery._data( elem, type, (jQuery._data( elem, type ) || 0) + 1 ); + } + }, + + _unmark: function( force, elem, type ) { + if ( force !== true ) { + type = elem; + elem = force; + force = false; + } + if ( elem ) { + type = type || "fx"; + var key = type + "mark", + count = force ? 0 : ( (jQuery._data( elem, key ) || 1) - 1 ); + if ( count ) { + jQuery._data( elem, key, count ); + } else { + jQuery.removeData( elem, key, true ); + handleQueueMarkDefer( elem, type, "mark" ); + } + } + }, + + queue: function( elem, type, data ) { + var q; + if ( elem ) { + type = ( type || "fx" ) + "queue"; + q = jQuery._data( elem, type ); + + // Speed up dequeue by getting out quickly if this is just a lookup + if ( data ) { + if ( !q || jQuery.isArray(data) ) { + q = jQuery._data( elem, type, jQuery.makeArray(data) ); + } else { + q.push( data ); + } + } + return q || []; + } + }, + + dequeue: function( elem, type ) { + type = type || "fx"; + + var queue = jQuery.queue( elem, type ), + fn = queue.shift(), + hooks = {}; + + // If the fx queue is dequeued, always remove the progress sentinel + if ( fn === "inprogress" ) { + fn = queue.shift(); + } + + if ( fn ) { + // Add a progress sentinel to prevent the fx queue from being + // automatically dequeued + if ( type === "fx" ) { + queue.unshift( "inprogress" ); + } + + jQuery._data( elem, type + ".run", hooks ); + fn.call( elem, function() { + jQuery.dequeue( elem, type ); + }, hooks ); + } + + if ( !queue.length ) { + jQuery.removeData( elem, type + "queue " + type + ".run", true ); + handleQueueMarkDefer( elem, type, "queue" ); + } + } + }); + + jQuery.fn.extend({ + queue: function( type, data ) { + if ( typeof type !== "string" ) { + data = type; + type = "fx"; + } + + if ( data === undefined ) { + return jQuery.queue( this[0], type ); + } + return this.each(function() { + var queue = jQuery.queue( this, type, data ); + + if ( type === "fx" && queue[0] !== "inprogress" ) { + jQuery.dequeue( this, type ); + } + }); + }, + dequeue: function( type ) { + return this.each(function() { + jQuery.dequeue( this, type ); + }); + }, + // Based off of the plugin by Clint Helfers, with permission. + // http://blindsignals.com/index.php/2009/07/jquery-delay/ + delay: function( time, type ) { + time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; + type = type || "fx"; + + return this.queue( type, function( next, hooks ) { + var timeout = setTimeout( next, time ); + hooks.stop = function() { + clearTimeout( timeout ); + }; + }); + }, + clearQueue: function( type ) { + return this.queue( type || "fx", [] ); + }, + // Get a promise resolved when queues of a certain type + // are emptied (fx is the type by default) + promise: function( type, object ) { + if ( typeof type !== "string" ) { + object = type; + type = undefined; + } + type = type || "fx"; + var defer = jQuery.Deferred(), + elements = this, + i = elements.length, + count = 1, + deferDataKey = type + "defer", + queueDataKey = type + "queue", + markDataKey = type + "mark", + tmp; + function resolve() { + if ( !( --count ) ) { + defer.resolveWith( elements, [ elements ] ); + } + } + while( i-- ) { + if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) || + ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) || + jQuery.data( elements[ i ], markDataKey, undefined, true ) ) && + jQuery.data( elements[ i ], deferDataKey, jQuery.Callbacks( "once memory" ), true ) )) { + count++; + tmp.add( resolve ); + } + } + resolve(); + return defer.promise(); + } + }); + + + + + var rclass = /[\n\t\r]/g, + rspace = /\s+/, + rreturn = /\r/g, + rtype = /^(?:button|input)$/i, + rfocusable = /^(?:button|input|object|select|textarea)$/i, + rclickable = /^a(?:rea)?$/i, + rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, + getSetAttribute = jQuery.support.getSetAttribute, + nodeHook, boolHook, fixSpecified; + + jQuery.fn.extend({ + attr: function( name, value ) { + return jQuery.access( this, name, value, true, jQuery.attr ); + }, + + removeAttr: function( name ) { + return this.each(function() { + jQuery.removeAttr( this, name ); + }); + }, + + prop: function( name, value ) { + return jQuery.access( this, name, value, true, jQuery.prop ); + }, + + removeProp: function( name ) { + name = jQuery.propFix[ name ] || name; + return this.each(function() { + // try/catch handles cases where IE balks (such as removing a property on window) + try { + this[ name ] = undefined; + delete this[ name ]; + } catch( e ) {} + }); + }, + + addClass: function( value ) { + var classNames, i, l, elem, + setClass, c, cl; + + if ( jQuery.isFunction( value ) ) { + return this.each(function( j ) { + jQuery( this ).addClass( value.call(this, j, this.className) ); + }); + } + + if ( value && typeof value === "string" ) { + classNames = value.split( rspace ); + + for ( i = 0, l = this.length; i < l; i++ ) { + elem = this[ i ]; + + if ( elem.nodeType === 1 ) { + if ( !elem.className && classNames.length === 1 ) { + elem.className = value; + + } else { + setClass = " " + elem.className + " "; + + for ( c = 0, cl = classNames.length; c < cl; c++ ) { + if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) { + setClass += classNames[ c ] + " "; + } + } + elem.className = jQuery.trim( setClass ); + } + } + } + } + + return this; + }, + + removeClass: function( value ) { + var classNames, i, l, elem, className, c, cl; + + if ( jQuery.isFunction( value ) ) { + return this.each(function( j ) { + jQuery( this ).removeClass( value.call(this, j, this.className) ); + }); + } + + if ( (value && typeof value === "string") || value === undefined ) { + classNames = ( value || "" ).split( rspace ); + + for ( i = 0, l = this.length; i < l; i++ ) { + elem = this[ i ]; + + if ( elem.nodeType === 1 && elem.className ) { + if ( value ) { + className = (" " + elem.className + " ").replace( rclass, " " ); + for ( c = 0, cl = classNames.length; c < cl; c++ ) { + className = className.replace(" " + classNames[ c ] + " ", " "); + } + elem.className = jQuery.trim( className ); + + } else { + elem.className = ""; + } + } + } + } + + return this; + }, + + toggleClass: function( value, stateVal ) { + var type = typeof value, + isBool = typeof stateVal === "boolean"; + + if ( jQuery.isFunction( value ) ) { + return this.each(function( i ) { + jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal ); + }); + } + + return this.each(function() { + if ( type === "string" ) { + // toggle individual class names + var className, + i = 0, + self = jQuery( this ), + state = stateVal, + classNames = value.split( rspace ); + + while ( (className = classNames[ i++ ]) ) { + // check each className given, space seperated list + state = isBool ? state : !self.hasClass( className ); + self[ state ? "addClass" : "removeClass" ]( className ); + } + + } else if ( type === "undefined" || type === "boolean" ) { + if ( this.className ) { + // store className if set + jQuery._data( this, "__className__", this.className ); + } + + // toggle whole className + this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || ""; + } + }); + }, + + hasClass: function( selector ) { + var className = " " + selector + " ", + i = 0, + l = this.length; + for ( ; i < l; i++ ) { + if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) { + return true; + } + } + + return false; + }, + + val: function( value ) { + var hooks, ret, isFunction, + elem = this[0]; + + if ( !arguments.length ) { + if ( elem ) { + hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ]; + + if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { + return ret; + } + + ret = elem.value; + + return typeof ret === "string" ? + // handle most common string cases + ret.replace(rreturn, "") : + // handle cases where value is null/undef or number + ret == null ? "" : ret; + } + + return undefined; + } + + isFunction = jQuery.isFunction( value ); + + return this.each(function( i ) { + var self = jQuery(this), val; + + if ( this.nodeType !== 1 ) { + return; + } + + if ( isFunction ) { + val = value.call( this, i, self.val() ); + } else { + val = value; + } + + // Treat null/undefined as ""; convert numbers to string + if ( val == null ) { + val = ""; + } else if ( typeof val === "number" ) { + val += ""; + } else if ( jQuery.isArray( val ) ) { + val = jQuery.map(val, function ( value ) { + return value == null ? "" : value + ""; + }); + } + + hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ]; + + // If set returns undefined, fall back to normal setting + if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { + this.value = val; + } + }); + } + }); + + jQuery.extend({ + valHooks: { + option: { + get: function( elem ) { + // attributes.value is undefined in Blackberry 4.7 but + // uses .value. See #6932 + var val = elem.attributes.value; + return !val || val.specified ? elem.value : elem.text; + } + }, + select: { + get: function( elem ) { + var value, i, max, option, + index = elem.selectedIndex, + values = [], + options = elem.options, + one = elem.type === "select-one"; + + // Nothing was selected + if ( index < 0 ) { + return null; + } + + // Loop through all the selected options + i = one ? index : 0; + max = one ? index + 1 : options.length; + for ( ; i < max; i++ ) { + option = options[ i ]; + + // Don't return options that are disabled or in a disabled optgroup + if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) && + (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) { + + // Get the specific value for the option + value = jQuery( option ).val(); + + // We don't need an array for one selects + if ( one ) { + return value; + } + + // Multi-Selects return an array + values.push( value ); + } + } + + // Fixes Bug #2551 -- select.val() broken in IE after form.reset() + if ( one && !values.length && options.length ) { + return jQuery( options[ index ] ).val(); + } + + return values; + }, + + set: function( elem, value ) { + var values = jQuery.makeArray( value ); + + jQuery(elem).find("option").each(function() { + this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0; + }); + + if ( !values.length ) { + elem.selectedIndex = -1; + } + return values; + } + } + }, + + attrFn: { + val: true, + css: true, + html: true, + text: true, + data: true, + width: true, + height: true, + offset: true + }, + + attr: function( elem, name, value, pass ) { + var ret, hooks, notxml, + nType = elem.nodeType; + + // don't get/set attributes on text, comment and attribute nodes + if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { + return undefined; + } + + if ( pass && name in jQuery.attrFn ) { + return jQuery( elem )[ name ]( value ); + } + + // Fallback to prop when attributes are not supported + if ( !("getAttribute" in elem) ) { + return jQuery.prop( elem, name, value ); + } + + notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); + + // All attributes are lowercase + // Grab necessary hook if one is defined + if ( notxml ) { + name = name.toLowerCase(); + hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook ); + } + + if ( value !== undefined ) { + + if ( value === null ) { + jQuery.removeAttr( elem, name ); + return undefined; + + } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) { + return ret; + + } else { + elem.setAttribute( name, "" + value ); + return value; + } + + } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) { + return ret; + + } else { + + ret = elem.getAttribute( name ); + + // Non-existent attributes return null, we normalize to undefined + return ret === null ? + undefined : + ret; + } + }, + + removeAttr: function( elem, value ) { + var propName, attrNames, name, l, + i = 0; + + if ( elem.nodeType === 1 ) { + attrNames = ( value || "" ).split( rspace ); + l = attrNames.length; + + for ( ; i < l; i++ ) { + name = attrNames[ i ].toLowerCase(); + propName = jQuery.propFix[ name ] || name; + + // See #9699 for explanation of this approach (setting first, then removal) + jQuery.attr( elem, name, "" ); + elem.removeAttribute( getSetAttribute ? name : propName ); + + // Set corresponding property to false for boolean attributes + if ( rboolean.test( name ) && propName in elem ) { + elem[ propName ] = false; + } + } + } + }, + + attrHooks: { + type: { + set: function( elem, value ) { + // We can't allow the type property to be changed (since it causes problems in IE) + if ( rtype.test( elem.nodeName ) && elem.parentNode ) { + jQuery.error( "type property can't be changed" ); + } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) { + // Setting the type on a radio button after the value resets the value in IE6-9 + // Reset value to it's default in case type is set after value + // This is for element creation + var val = elem.value; + elem.setAttribute( "type", value ); + if ( val ) { + elem.value = val; + } + return value; + } + } + }, + // Use the value property for back compat + // Use the nodeHook for button elements in IE6/7 (#1954) + value: { + get: function( elem, name ) { + if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { + return nodeHook.get( elem, name ); + } + return name in elem ? + elem.value : + null; + }, + set: function( elem, value, name ) { + if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { + return nodeHook.set( elem, value, name ); + } + // Does not return so that setAttribute is also used + elem.value = value; + } + } + }, + + propFix: { + tabindex: "tabIndex", + readonly: "readOnly", + "for": "htmlFor", + "class": "className", + maxlength: "maxLength", + cellspacing: "cellSpacing", + cellpadding: "cellPadding", + rowspan: "rowSpan", + colspan: "colSpan", + usemap: "useMap", + frameborder: "frameBorder", + contenteditable: "contentEditable" + }, + + prop: function( elem, name, value ) { + var ret, hooks, notxml, + nType = elem.nodeType; + + // don't get/set properties on text, comment and attribute nodes + if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { + return undefined; + } + + notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); + + if ( notxml ) { + // Fix name and attach hooks + name = jQuery.propFix[ name ] || name; + hooks = jQuery.propHooks[ name ]; + } + + if ( value !== undefined ) { + if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { + return ret; + + } else { + return ( elem[ name ] = value ); + } + + } else { + if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { + return ret; + + } else { + return elem[ name ]; + } + } + }, + + propHooks: { + tabIndex: { + get: function( elem ) { + // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set + // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ + var attributeNode = elem.getAttributeNode("tabindex"); + + return attributeNode && attributeNode.specified ? + parseInt( attributeNode.value, 10 ) : + rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? + 0 : + undefined; + } + } + } + }); + + // Add the tabIndex propHook to attrHooks for back-compat (different case is intentional) + jQuery.attrHooks.tabindex = jQuery.propHooks.tabIndex; + + // Hook for boolean attributes + boolHook = { + get: function( elem, name ) { + // Align boolean attributes with corresponding properties + // Fall back to attribute presence where some booleans are not supported + var attrNode, + property = jQuery.prop( elem, name ); + return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ? + name.toLowerCase() : + undefined; + }, + set: function( elem, value, name ) { + var propName; + if ( value === false ) { + // Remove boolean attributes when set to false + jQuery.removeAttr( elem, name ); + } else { + // value is true since we know at this point it's type boolean and not false + // Set boolean attributes to the same name and set the DOM property + propName = jQuery.propFix[ name ] || name; + if ( propName in elem ) { + // Only set the IDL specifically if it already exists on the element + elem[ propName ] = true; + } + + elem.setAttribute( name, name.toLowerCase() ); + } + return name; + } + }; + + // IE6/7 do not support getting/setting some attributes with get/setAttribute + if ( !getSetAttribute ) { + + fixSpecified = { + name: true, + id: true + }; + + // Use this for any attribute in IE6/7 + // This fixes almost every IE6/7 issue + nodeHook = jQuery.valHooks.button = { + get: function( elem, name ) { + var ret; + ret = elem.getAttributeNode( name ); + return ret && ( fixSpecified[ name ] ? ret.nodeValue !== "" : ret.specified ) ? + ret.nodeValue : + undefined; + }, + set: function( elem, value, name ) { + // Set the existing or create a new attribute node + var ret = elem.getAttributeNode( name ); + if ( !ret ) { + ret = document.createAttribute( name ); + elem.setAttributeNode( ret ); + } + return ( ret.nodeValue = value + "" ); + } + }; + + // Apply the nodeHook to tabindex + jQuery.attrHooks.tabindex.set = nodeHook.set; + + // Set width and height to auto instead of 0 on empty string( Bug #8150 ) + // This is for removals + jQuery.each([ "width", "height" ], function( i, name ) { + jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { + set: function( elem, value ) { + if ( value === "" ) { + elem.setAttribute( name, "auto" ); + return value; + } + } + }); + }); + + // Set contenteditable to false on removals(#10429) + // Setting to empty string throws an error as an invalid value + jQuery.attrHooks.contenteditable = { + get: nodeHook.get, + set: function( elem, value, name ) { + if ( value === "" ) { + value = "false"; + } + nodeHook.set( elem, value, name ); + } + }; + } + + + // Some attributes require a special call on IE + if ( !jQuery.support.hrefNormalized ) { + jQuery.each([ "href", "src", "width", "height" ], function( i, name ) { + jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { + get: function( elem ) { + var ret = elem.getAttribute( name, 2 ); + return ret === null ? undefined : ret; + } + }); + }); + } + + if ( !jQuery.support.style ) { + jQuery.attrHooks.style = { + get: function( elem ) { + // Return undefined in the case of empty string + // Normalize to lowercase since IE uppercases css property names + return elem.style.cssText.toLowerCase() || undefined; + }, + set: function( elem, value ) { + return ( elem.style.cssText = "" + value ); + } + }; + } + + // Safari mis-reports the default selected property of an option + // Accessing the parent's selectedIndex property fixes it + if ( !jQuery.support.optSelected ) { + jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, { + get: function( elem ) { + var parent = elem.parentNode; + + if ( parent ) { + parent.selectedIndex; + + // Make sure that it also works with optgroups, see #5701 + if ( parent.parentNode ) { + parent.parentNode.selectedIndex; + } + } + return null; + } + }); + } + + // IE6/7 call enctype encoding + if ( !jQuery.support.enctype ) { + jQuery.propFix.enctype = "encoding"; + } + + // Radios and checkboxes getter/setter + if ( !jQuery.support.checkOn ) { + jQuery.each([ "radio", "checkbox" ], function() { + jQuery.valHooks[ this ] = { + get: function( elem ) { + // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified + return elem.getAttribute("value") === null ? "on" : elem.value; + } + }; + }); + } + jQuery.each([ "radio", "checkbox" ], function() { + jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], { + set: function( elem, value ) { + if ( jQuery.isArray( value ) ) { + return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 ); + } + } + }); + }); + + + + + var rnamespaces = /\.(.*)$/, + rformElems = /^(?:textarea|input|select)$/i, + rperiod = /\./g, + rspaces = / /g, + rescape = /[^\w\s.|`]/g, + rtypenamespace = /^([^\.]*)?(?:\.(.+))?$/, + rhoverHack = /\bhover(\.\S+)?/, + rkeyEvent = /^key/, + rmouseEvent = /^(?:mouse|contextmenu)|click/, + rquickIs = /^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/, + quickParse = function( selector ) { + var quick = rquickIs.exec( selector ); + if ( quick ) { + // 0 1 2 3 + // [ _, tag, id, class ] + quick[1] = ( quick[1] || "" ).toLowerCase(); + quick[3] = quick[3] && new RegExp( "(?:^|\\s)" + quick[3] + "(?:\\s|$)" ); + } + return quick; + }, + quickIs = function( elem, m ) { + return ( + (!m[1] || elem.nodeName.toLowerCase() === m[1]) && + (!m[2] || elem.id === m[2]) && + (!m[3] || m[3].test( elem.className )) + ); + }, + hoverHack = function( events ) { + return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" ); + }; + + /* + * Helper functions for managing events -- not part of the public interface. + * Props to Dean Edwards' addEvent library for many of the ideas. + */ + jQuery.event = { + + add: function( elem, types, handler, data, selector ) { + + var elemData, eventHandle, events, + t, tns, type, namespaces, handleObj, + handleObjIn, quick, handlers, special; + + // Don't attach events to noData or text/comment nodes (allow plain objects tho) + if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) { + return; + } + + // Caller can pass in an object of custom data in lieu of the handler + if ( handler.handler ) { + handleObjIn = handler; + handler = handleObjIn.handler; + } + + // Make sure that the handler has a unique ID, used to find/remove it later + if ( !handler.guid ) { + handler.guid = jQuery.guid++; + } + + // Init the element's event structure and main handler, if this is the first + events = elemData.events; + if ( !events ) { + elemData.events = events = {}; + } + eventHandle = elemData.handle; + if ( !eventHandle ) { + elemData.handle = eventHandle = function( e ) { + // Discard the second event of a jQuery.event.trigger() and + // when an event is called after a page has unloaded + return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ? + jQuery.event.dispatch.apply( eventHandle.elem, arguments ) : + undefined; + }; + // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events + eventHandle.elem = elem; + } + + // Handle multiple events separated by a space + // jQuery(...).bind("mouseover mouseout", fn); + types = hoverHack(types).split( " " ); + for ( t = 0; t < types.length; t++ ) { + + tns = rtypenamespace.exec( types[t] ) || []; + type = tns[1]; + namespaces = ( tns[2] || "" ).split( "." ).sort(); + + // If event changes its type, use the special event handlers for the changed type + special = jQuery.event.special[ type ] || {}; + + // If selector defined, determine special event api type, otherwise given type + type = ( selector ? special.delegateType : special.bindType ) || type; + + // Update special based on newly reset type + special = jQuery.event.special[ type ] || {}; + + // handleObj is passed to all event handlers + handleObj = jQuery.extend({ + type: type, + origType: tns[1], + data: data, + handler: handler, + guid: handler.guid, + selector: selector, + namespace: namespaces.join(".") + }, handleObjIn ); + + // Delegated event; pre-analyze selector so it's processed quickly on event dispatch + if ( selector ) { + handleObj.quick = quickParse( selector ); + if ( !handleObj.quick && jQuery.expr.match.POS.test( selector ) ) { + handleObj.isPositional = true; + } + } + + // Init the event handler queue if we're the first + handlers = events[ type ]; + if ( !handlers ) { + handlers = events[ type ] = []; + handlers.delegateCount = 0; + + // Only use addEventListener/attachEvent if the special events handler returns false + if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { + // Bind the global event handler to the element + if ( elem.addEventListener ) { + elem.addEventListener( type, eventHandle, false ); + + } else if ( elem.attachEvent ) { + elem.attachEvent( "on" + type, eventHandle ); + } + } + } + + if ( special.add ) { + special.add.call( elem, handleObj ); + + if ( !handleObj.handler.guid ) { + handleObj.handler.guid = handler.guid; + } + } + + // Add to the element's handler list, delegates in front + if ( selector ) { + handlers.splice( handlers.delegateCount++, 0, handleObj ); + } else { + handlers.push( handleObj ); + } + + // Keep track of which events have ever been used, for event optimization + jQuery.event.global[ type ] = true; + } + + // Nullify elem to prevent memory leaks in IE + elem = null; + }, + + global: {}, + + // Detach an event or set of events from an element + remove: function( elem, types, handler, selector ) { + + var elemData = jQuery.hasData( elem ) && jQuery._data( elem ), + t, tns, type, namespaces, origCount, + j, events, special, handle, eventType, handleObj; + + if ( !elemData || !(events = elemData.events) ) { + return; + } + + // Once for each type.namespace in types; type may be omitted + types = hoverHack( types || "" ).split(" "); + for ( t = 0; t < types.length; t++ ) { + tns = rtypenamespace.exec( types[t] ) || []; + type = tns[1]; + namespaces = tns[2]; + + // Unbind all events (on this namespace, if provided) for the element + if ( !type ) { + namespaces = namespaces? "." + namespaces : ""; + for ( j in events ) { + jQuery.event.remove( elem, j + namespaces, handler, selector ); + } + return; + } + + special = jQuery.event.special[ type ] || {}; + type = ( selector? special.delegateType : special.bindType ) || type; + eventType = events[ type ] || []; + origCount = eventType.length; + namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.)?") + "(\\.|$)") : null; + + // Only need to loop for special events or selective removal + if ( handler || namespaces || selector || special.remove ) { + for ( j = 0; j < eventType.length; j++ ) { + handleObj = eventType[ j ]; + + if ( !handler || handler.guid === handleObj.guid ) { + if ( !namespaces || namespaces.test( handleObj.namespace ) ) { + if ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) { + eventType.splice( j--, 1 ); + + if ( handleObj.selector ) { + eventType.delegateCount--; + } + if ( special.remove ) { + special.remove.call( elem, handleObj ); + } + } + } + } + } + } else { + // Removing all events + eventType.length = 0; + } + + // Remove generic event handler if we removed something and no more handlers exist + // (avoids potential for endless recursion during removal of special event handlers) + if ( eventType.length === 0 && origCount !== eventType.length ) { + if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) { + jQuery.removeEvent( elem, type, elemData.handle ); + } + + delete events[ type ]; + } + } + + // Remove the expando if it's no longer used + if ( jQuery.isEmptyObject( events ) ) { + handle = elemData.handle; + if ( handle ) { + handle.elem = null; + } + + // removeData also checks for emptiness and clears the expando if empty + // so use it instead of delete + jQuery.removeData( elem, [ "events", "handle" ], true ); + } + }, + + // Events that are safe to short-circuit if no handlers are attached. + // Native DOM events should not be added, they may have inline handlers. + customEvent: { + "getData": true, + "setData": true, + "changeData": true + }, + + trigger: function( event, data, elem, onlyHandlers ) { + // Don't do events on text and comment nodes + if ( elem && (elem.nodeType === 3 || elem.nodeType === 8) ) { + return; + } + + // Event object or event type + var type = event.type || event, + namespaces = [], + cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType; + + if ( type.indexOf( "!" ) >= 0 ) { + // Exclusive events trigger only for the exact event (no namespaces) + type = type.slice(0, -1); + exclusive = true; + } + + if ( type.indexOf( "." ) >= 0 ) { + // Namespaced trigger; create a regexp to match event type in handle() + namespaces = type.split("."); + type = namespaces.shift(); + namespaces.sort(); + } + + if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) { + // No jQuery handlers for this event type, and it can't have inline handlers + return; + } + + // Caller can pass in an Event, Object, or just an event type string + event = typeof event === "object" ? + // jQuery.Event object + event[ jQuery.expando ] ? event : + // Object literal + new jQuery.Event( type, event ) : + // Just the event type (string) + new jQuery.Event( type ); + + event.type = type; + event.isTrigger = true; + event.exclusive = exclusive; + event.namespace = namespaces.join( "." ); + event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)") : null; + ontype = type.indexOf( ":" ) < 0 ? "on" + type : ""; + + // triggerHandler() and global events don't bubble or run the default action + if ( onlyHandlers || !elem ) { + event.preventDefault(); + } + + // Handle a global trigger + if ( !elem ) { + + // TODO: Stop taunting the data cache; remove global events and always attach to document + cache = jQuery.cache; + for ( i in cache ) { + if ( cache[ i ].events && cache[ i ].events[ type ] ) { + jQuery.event.trigger( event, data, cache[ i ].handle.elem, true ); + } + } + return; + } + + // Clean up the event in case it is being reused + event.result = undefined; + if ( !event.target ) { + event.target = elem; + } + + // Clone any incoming data and prepend the event, creating the handler arg list + data = data != null ? jQuery.makeArray( data ) : []; + data.unshift( event ); + + // Allow special events to draw outside the lines + special = jQuery.event.special[ type ] || {}; + if ( special.trigger && special.trigger.apply( elem, data ) === false ) { + return; + } + + // Determine event propagation path in advance, per W3C events spec (#9951) + // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) + eventPath = [[ elem, special.bindType || type ]]; + if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { + + bubbleType = special.delegateType || type; + old = null; + for ( cur = elem.parentNode; cur; cur = cur.parentNode ) { + eventPath.push([ cur, bubbleType ]); + old = cur; + } + + // Only add window if we got to document (e.g., not plain obj or detached DOM) + if ( old && old === elem.ownerDocument ) { + eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]); + } + } + + // Fire handlers on the event path + for ( i = 0; i < eventPath.length; i++ ) { + + cur = eventPath[i][0]; + event.type = eventPath[i][1]; + + handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" ); + if ( handle ) { + handle.apply( cur, data ); + } + handle = ontype && cur[ ontype ]; + if ( handle && jQuery.acceptData( cur ) ) { + handle.apply( cur, data ); + } + + if ( event.isPropagationStopped() ) { + break; + } + } + event.type = type; + + // If nobody prevented the default action, do it now + if ( !event.isDefaultPrevented() ) { + + if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) && + !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) { + + // Call a native DOM method on the target with the same name name as the event. + // Can't use an .isFunction() check here because IE6/7 fails that test. + // Don't do default actions on window, that's where global variables be (#6170) + // IE<9 dies on focus/blur to hidden element (#1486) + if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow( elem ) ) { + + // Don't re-trigger an onFOO event when we call its FOO() method + old = elem[ ontype ]; + + if ( old ) { + elem[ ontype ] = null; + } + + // Prevent re-triggering of the same event, since we already bubbled it above + jQuery.event.triggered = type; + elem[ type ](); + jQuery.event.triggered = undefined; + + if ( old ) { + elem[ ontype ] = old; + } + } + } + } + + return event.result; + }, + + dispatch: function( event ) { + + // Make a writable jQuery.Event from the native event object + event = jQuery.event.fix( event || window.event ); + + var handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []), + delegateCount = handlers.delegateCount, + args = [].slice.call( arguments, 0 ), + run_all = !event.exclusive && !event.namespace, + specialHandle = ( jQuery.event.special[ event.type ] || {} ).handle, + handlerQueue = [], + i, j, cur, ret, selMatch, matched, matches, handleObj, sel, hit, related; + + // Use the fix-ed jQuery.Event rather than the (read-only) native event + args[0] = event; + event.delegateTarget = this; + + // Determine handlers that should run if there are delegated events + // Avoid disabled elements in IE (#6911) and non-left-click bubbling in Firefox (#3861) + if ( delegateCount && !event.target.disabled && !(event.button && event.type === "click") ) { + + for ( cur = event.target; cur != this; cur = cur.parentNode || this ) { + selMatch = {}; + matches = []; + for ( i = 0; i < delegateCount; i++ ) { + handleObj = handlers[ i ]; + sel = handleObj.selector; + hit = selMatch[ sel ]; + + if ( handleObj.isPositional ) { + // Since .is() does not work for positionals; see http://jsfiddle.net/eJ4yd/3/ + hit = ( hit || (selMatch[ sel ] = jQuery( sel )) ).index( cur ) >= 0; + } else if ( hit === undefined ) { + hit = selMatch[ sel ] = ( handleObj.quick ? quickIs( cur, handleObj.quick ) : jQuery( cur ).is( sel ) ); + } + if ( hit ) { + matches.push( handleObj ); + } + } + if ( matches.length ) { + handlerQueue.push({ elem: cur, matches: matches }); + } + } + } + + // Add the remaining (directly-bound) handlers + if ( handlers.length > delegateCount ) { + handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) }); + } + + // Run delegates first; they may want to stop propagation beneath us + for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) { + matched = handlerQueue[ i ]; + event.currentTarget = matched.elem; + + for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) { + handleObj = matched.matches[ j ]; + + // Triggered event must either 1) be non-exclusive and have no namespace, or + // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace). + if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) { + + event.data = handleObj.data; + event.handleObj = handleObj; + + ret = ( specialHandle || handleObj.handler ).apply( matched.elem, args ); + + if ( ret !== undefined ) { + event.result = ret; + if ( ret === false ) { + event.preventDefault(); + event.stopPropagation(); + } + } + } + } + } + + return event.result; + }, + + // Includes some event props shared by KeyEvent and MouseEvent + // *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 *** + props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), + + fixHooks: {}, + + keyHooks: { + props: "char charCode key keyCode".split(" "), + filter: function( event, original ) { + + // Add which for key events + if ( event.which == null ) { + event.which = original.charCode != null ? original.charCode : original.keyCode; + } + + return event; + } + }, + + mouseHooks: { + props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement wheelDelta".split(" "), + filter: function( event, original ) { + var eventDoc, doc, body, + button = original.button, + fromElement = original.fromElement; + + // Calculate pageX/Y if missing and clientX/Y available + if ( event.pageX == null && original.clientX != null ) { + eventDoc = event.target.ownerDocument || document; + doc = eventDoc.documentElement; + body = eventDoc.body; + + event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); + event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 ); + } + + // Add relatedTarget, if necessary + if ( !event.relatedTarget && fromElement ) { + event.relatedTarget = fromElement === event.target ? original.toElement : fromElement; + } + + // Add which for click: 1 === left; 2 === middle; 3 === right + // Note: button is not normalized, so don't use it + if ( !event.which && button !== undefined ) { + event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); + } + + return event; + } + }, + + fix: function( event ) { + if ( event[ jQuery.expando ] ) { + return event; + } + + // Create a writable copy of the event object and normalize some properties + var i, prop, + originalEvent = event, + fixHook = jQuery.event.fixHooks[ event.type ] || {}, + copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; + + event = jQuery.Event( originalEvent ); + + for ( i = copy.length; i; ) { + prop = copy[ --i ]; + event[ prop ] = originalEvent[ prop ]; + } + + // Fix target property, if necessary (#1925, IE 6/7/8 & Safari2) + if ( !event.target ) { + event.target = originalEvent.srcElement || document; + } + + // Target should not be a text node (#504, Safari) + if ( event.target.nodeType === 3 ) { + event.target = event.target.parentNode; + } + + // For mouse/key events; add metaKey if it's not there (#3368, IE6/7/8) + if ( event.metaKey === undefined ) { + event.metaKey = event.ctrlKey; + } + + return fixHook.filter? fixHook.filter( event, originalEvent ) : event; + }, + + special: { + ready: { + // Make sure the ready event is setup + setup: jQuery.bindReady + }, + + focus: { + delegateType: "focusin", + noBubble: true + }, + blur: { + delegateType: "focusout", + noBubble: true + }, + + beforeunload: { + setup: function( data, namespaces, eventHandle ) { + // We only want to do this special case on windows + if ( jQuery.isWindow( this ) ) { + this.onbeforeunload = eventHandle; + } + }, + + teardown: function( namespaces, eventHandle ) { + if ( this.onbeforeunload === eventHandle ) { + this.onbeforeunload = null; + } + } + } + }, + + simulate: function( type, elem, event, bubble ) { + // Piggyback on a donor event to simulate a different one. + // Fake originalEvent to avoid donor's stopPropagation, but if the + // simulated event prevents default then we do the same on the donor. + var e = jQuery.extend( + new jQuery.Event(), + event, + { type: type, + isSimulated: true, + originalEvent: {} + } + ); + if ( bubble ) { + jQuery.event.trigger( e, null, elem ); + } else { + jQuery.event.dispatch.call( elem, e ); + } + if ( e.isDefaultPrevented() ) { + event.preventDefault(); + } + } + }; + + // Some plugins are using, but it's undocumented/deprecated and will be removed. + // The 1.7 special event interface should provide all the hooks needed now. + jQuery.event.handle = jQuery.event.dispatch; + + jQuery.removeEvent = document.removeEventListener ? + function( elem, type, handle ) { + if ( elem.removeEventListener ) { + elem.removeEventListener( type, handle, false ); + } + } : + function( elem, type, handle ) { + if ( elem.detachEvent ) { + elem.detachEvent( "on" + type, handle ); + } + }; + + jQuery.Event = function( src, props ) { + // Allow instantiation without the 'new' keyword + if ( !(this instanceof jQuery.Event) ) { + return new jQuery.Event( src, props ); + } + + // Event object + if ( src && src.type ) { + this.originalEvent = src; + this.type = src.type; + + // Events bubbling up the document may have been marked as prevented + // by a handler lower down the tree; reflect the correct value. + this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false || + src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse; + + // Event type + } else { + this.type = src; + } + + // Put explicitly provided properties onto the event object + if ( props ) { + jQuery.extend( this, props ); + } + + // Create a timestamp if incoming event doesn't have one + this.timeStamp = src && src.timeStamp || jQuery.now(); + + // Mark it as fixed + this[ jQuery.expando ] = true; + }; + + function returnFalse() { + return false; + } + function returnTrue() { + return true; + } + + // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding + // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html + jQuery.Event.prototype = { + preventDefault: function() { + this.isDefaultPrevented = returnTrue; + + var e = this.originalEvent; + if ( !e ) { + return; + } + + // if preventDefault exists run it on the original event + if ( e.preventDefault ) { + e.preventDefault(); + + // otherwise set the returnValue property of the original event to false (IE) + } else { + e.returnValue = false; + } + }, + stopPropagation: function() { + this.isPropagationStopped = returnTrue; + + var e = this.originalEvent; + if ( !e ) { + return; + } + // if stopPropagation exists run it on the original event + if ( e.stopPropagation ) { + e.stopPropagation(); + } + // otherwise set the cancelBubble property of the original event to true (IE) + e.cancelBubble = true; + }, + stopImmediatePropagation: function() { + this.isImmediatePropagationStopped = returnTrue; + this.stopPropagation(); + }, + isDefaultPrevented: returnFalse, + isPropagationStopped: returnFalse, + isImmediatePropagationStopped: returnFalse + }; + + // Create mouseenter/leave events using mouseover/out and event-time checks + jQuery.each({ + mouseenter: "mouseover", + mouseleave: "mouseout" + }, function( orig, fix ) { + jQuery.event.special[ orig ] = jQuery.event.special[ fix ] = { + delegateType: fix, + bindType: fix, + + handle: function( event ) { + var target = this, + related = event.relatedTarget, + handleObj = event.handleObj, + selector = handleObj.selector, + oldType, ret; + + // For a real mouseover/out, always call the handler; for + // mousenter/leave call the handler if related is outside the target. + // NB: No relatedTarget if the mouse left/entered the browser window + if ( !related || handleObj.origType === event.type || (related !== target && !jQuery.contains( target, related )) ) { + oldType = event.type; + event.type = handleObj.origType; + ret = handleObj.handler.apply( this, arguments ); + event.type = oldType; + } + return ret; + } + }; + }); + + // IE submit delegation + if ( !jQuery.support.submitBubbles ) { + + jQuery.event.special.submit = { + setup: function() { + // Only need this for delegated form submit events + if ( jQuery.nodeName( this, "form" ) ) { + return false; + } + + // Lazy-add a submit handler when a descendant form may potentially be submitted + jQuery.event.add( this, "click._submit keypress._submit", function( e ) { + // Node name check avoids a VML-related crash in IE (#9807) + var elem = e.target, + form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined; + if ( form && !form._submit_attached ) { + jQuery.event.add( form, "submit._submit", function( event ) { + // Form was submitted, bubble the event up the tree + if ( this.parentNode ) { + jQuery.event.simulate( "submit", this.parentNode, event, true ); + } + }); + form._submit_attached = true; + } + }); + // return undefined since we don't need an event listener + }, + + teardown: function() { + // Only need this for delegated form submit events + if ( jQuery.nodeName( this, "form" ) ) { + return false; + } + + // Remove delegated handlers; cleanData eventually reaps submit handlers attached above + jQuery.event.remove( this, "._submit" ); + } + }; + } + + // IE change delegation and checkbox/radio fix + if ( !jQuery.support.changeBubbles ) { + + jQuery.event.special.change = { + + setup: function() { + + if ( rformElems.test( this.nodeName ) ) { + // IE doesn't fire change on a check/radio until blur; trigger it on click + // after a propertychange. Eat the blur-change in special.change.handle. + // This still fires onchange a second time for check/radio after blur. + if ( this.type === "checkbox" || this.type === "radio" ) { + jQuery.event.add( this, "propertychange._change", function( event ) { + if ( event.originalEvent.propertyName === "checked" ) { + this._just_changed = true; + } + }); + jQuery.event.add( this, "click._change", function( event ) { + if ( this._just_changed ) { + this._just_changed = false; + jQuery.event.simulate( "change", this, event, true ); + } + }); + } + return false; + } + // Delegated event; lazy-add a change handler on descendant inputs + jQuery.event.add( this, "beforeactivate._change", function( e ) { + var elem = e.target; + + if ( rformElems.test( elem.nodeName ) && !elem._change_attached ) { + jQuery.event.add( elem, "change._change", function( event ) { + if ( this.parentNode && !event.isSimulated ) { + jQuery.event.simulate( "change", this.parentNode, event, true ); + } + }); + elem._change_attached = true; + } + }); + }, + + handle: function( event ) { + var elem = event.target; + + // Swallow native change events from checkbox/radio, we already triggered them above + if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) { + return event.handleObj.handler.apply( this, arguments ); + } + }, + + teardown: function() { + jQuery.event.remove( this, "._change" ); + + return rformElems.test( this.nodeName ); + } + }; + } + + // Create "bubbling" focus and blur events + if ( !jQuery.support.focusinBubbles ) { + jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { + + // Attach a single capturing handler while someone wants focusin/focusout + var attaches = 0, + handler = function( event ) { + jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true ); + }; + + jQuery.event.special[ fix ] = { + setup: function() { + if ( attaches++ === 0 ) { + document.addEventListener( orig, handler, true ); + } + }, + teardown: function() { + if ( --attaches === 0 ) { + document.removeEventListener( orig, handler, true ); + } + } + }; + }); + } + + jQuery.fn.extend({ + + on: function( types, selector, data, fn, /*INTERNAL*/ one ) { + var origFn, type; + + // Types can be a map of types/handlers + if ( typeof types === "object" ) { + // ( types-Object, selector, data ) + if ( typeof selector !== "string" ) { + // ( types-Object, data ) + data = selector; + selector = undefined; + } + for ( type in types ) { + this.on( type, selector, data, types[ type ], one ); + } + return this; + } + + if ( data == null && fn == null ) { + // ( types, fn ) + fn = selector; + data = selector = undefined; + } else if ( fn == null ) { + if ( typeof selector === "string" ) { + // ( types, selector, fn ) + fn = data; + data = undefined; + } else { + // ( types, data, fn ) + fn = data; + data = selector; + selector = undefined; + } + } + if ( fn === false ) { + fn = returnFalse; + } else if ( !fn ) { + return this; + } + + if ( one === 1 ) { + origFn = fn; + fn = function( event ) { + // Can use an empty set, since event contains the info + jQuery().off( event ); + return origFn.apply( this, arguments ); + }; + // Use same guid so caller can remove using origFn + fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); + } + return this.each( function() { + jQuery.event.add( this, types, fn, data, selector ); + }); + }, + one: function( types, selector, data, fn ) { + return this.on.call( this, types, selector, data, fn, 1 ); + }, + off: function( types, selector, fn ) { + if ( types && types.preventDefault && types.handleObj ) { + // ( event ) dispatched jQuery.Event + var handleObj = types.handleObj; + jQuery( types.delegateTarget ).off( + handleObj.namespace? handleObj.type + "." + handleObj.namespace : handleObj.type, + handleObj.selector, + handleObj.handler + ); + return this; + } + if ( typeof types === "object" ) { + // ( types-object [, selector] ) + for ( var type in types ) { + this.off( type, selector, types[ type ] ); + } + return this; + } + if ( selector === false || typeof selector === "function" ) { + // ( types [, fn] ) + fn = selector; + selector = undefined; + } + if ( fn === false ) { + fn = returnFalse; + } + return this.each(function() { + jQuery.event.remove( this, types, fn, selector ); + }); + }, + + bind: function( types, data, fn ) { + return this.on( types, null, data, fn ); + }, + unbind: function( types, fn ) { + return this.off( types, null, fn ); + }, + + live: function( types, data, fn ) { + jQuery( this.context ).on( types, this.selector, data, fn ); + return this; + }, + die: function( types, fn ) { + jQuery( this.context ).off( types, this.selector || "**", fn ); + return this; + }, + + delegate: function( selector, types, data, fn ) { + return this.on( types, selector, data, fn ); + }, + undelegate: function( selector, types, fn ) { + // ( namespace ) or ( selector, types [, fn] ) + return arguments.length == 1? this.off( selector, "**" ) : this.off( types, selector, fn ); + }, + + trigger: function( type, data ) { + return this.each(function() { + jQuery.event.trigger( type, data, this ); + }); + }, + triggerHandler: function( type, data ) { + if ( this[0] ) { + return jQuery.event.trigger( type, data, this[0], true ); + } + }, + + toggle: function( fn ) { + // Save reference to arguments for access in closure + var args = arguments, + guid = fn.guid || jQuery.guid++, + i = 0, + toggler = function( event ) { + // Figure out which function to execute + var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i; + jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 ); + + // Make sure that clicks stop + event.preventDefault(); + + // and execute the function + return args[ lastToggle ].apply( this, arguments ) || false; + }; + + // link all the functions, so any of them can unbind this click handler + toggler.guid = guid; + while ( i < args.length ) { + args[ i++ ].guid = guid; + } + + return this.click( toggler ); + }, + + hover: function( fnOver, fnOut ) { + return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); + } + }); + + jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + + "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + + "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) { + + // Handle event binding + jQuery.fn[ name ] = function( data, fn ) { + if ( fn == null ) { + fn = data; + data = null; + } + + return arguments.length > 0 ? + this.bind( name, data, fn ) : + this.trigger( name ); + }; + + if ( jQuery.attrFn ) { + jQuery.attrFn[ name ] = true; + } + + if ( rkeyEvent.test( name ) ) { + jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks; + } + + if ( rmouseEvent.test( name ) ) { + jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks; + } + }); + + + + /*! + * Sizzle CSS Selector Engine + * Copyright 2011, The Dojo Foundation + * Released under the MIT, BSD, and GPL Licenses. + * More information: http://sizzlejs.com/ + */ + (function(){ + + var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g, + expando = "sizcache" + (Math.random() + '').replace('.', ''), + done = 0, + toString = Object.prototype.toString, + hasDuplicate = false, + baseHasDuplicate = true, + rBackslash = /\\/g, + rReturn = /\r\n/g, + rNonWord = /\W/; + + // Here we check if the JavaScript engine is using some sort of + // optimization where it does not always call our comparision + // function. If that is the case, discard the hasDuplicate value. + // Thus far that includes Google Chrome. + [0, 0].sort(function() { + baseHasDuplicate = false; + return 0; + }); + + var Sizzle = function( selector, context, results, seed ) { + results = results || []; + context = context || document; + + var origContext = context; + + if ( context.nodeType !== 1 && context.nodeType !== 9 ) { + return []; + } + + if ( !selector || typeof selector !== "string" ) { + return results; + } + + var m, set, checkSet, extra, ret, cur, pop, i, + prune = true, + contextXML = Sizzle.isXML( context ), + parts = [], + soFar = selector; + + // Reset the position of the chunker regexp (start from head) + do { + chunker.exec( "" ); + m = chunker.exec( soFar ); + + if ( m ) { + soFar = m[3]; + + parts.push( m[1] ); + + if ( m[2] ) { + extra = m[3]; + break; + } + } + } while ( m ); + + if ( parts.length > 1 && origPOS.exec( selector ) ) { + + if ( parts.length === 2 && Expr.relative[ parts[0] ] ) { + set = posProcess( parts[0] + parts[1], context, seed ); + + } else { + set = Expr.relative[ parts[0] ] ? + [ context ] : + Sizzle( parts.shift(), context ); + + while ( parts.length ) { + selector = parts.shift(); + + if ( Expr.relative[ selector ] ) { + selector += parts.shift(); + } + + set = posProcess( selector, set, seed ); + } + } + + } else { + // Take a shortcut and set the context if the root selector is an ID + // (but not if it'll be faster if the inner selector is an ID) + if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML && + Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) { + + ret = Sizzle.find( parts.shift(), context, contextXML ); + context = ret.expr ? + Sizzle.filter( ret.expr, ret.set )[0] : + ret.set[0]; + } + + if ( context ) { + ret = seed ? + { expr: parts.pop(), set: makeArray(seed) } : + Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML ); + + set = ret.expr ? + Sizzle.filter( ret.expr, ret.set ) : + ret.set; + + if ( parts.length > 0 ) { + checkSet = makeArray( set ); + + } else { + prune = false; + } + + while ( parts.length ) { + cur = parts.pop(); + pop = cur; + + if ( !Expr.relative[ cur ] ) { + cur = ""; + } else { + pop = parts.pop(); + } + + if ( pop == null ) { + pop = context; + } + + Expr.relative[ cur ]( checkSet, pop, contextXML ); + } + + } else { + checkSet = parts = []; + } + } + + if ( !checkSet ) { + checkSet = set; + } + + if ( !checkSet ) { + Sizzle.error( cur || selector ); + } + + if ( toString.call(checkSet) === "[object Array]" ) { + if ( !prune ) { + results.push.apply( results, checkSet ); + + } else if ( context && context.nodeType === 1 ) { + for ( i = 0; checkSet[i] != null; i++ ) { + if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) { + results.push( set[i] ); + } + } + + } else { + for ( i = 0; checkSet[i] != null; i++ ) { + if ( checkSet[i] && checkSet[i].nodeType === 1 ) { + results.push( set[i] ); + } + } + } + + } else { + makeArray( checkSet, results ); + } + + if ( extra ) { + Sizzle( extra, origContext, results, seed ); + Sizzle.uniqueSort( results ); + } + + return results; + }; + + Sizzle.uniqueSort = function( results ) { + if ( sortOrder ) { + hasDuplicate = baseHasDuplicate; + results.sort( sortOrder ); + + if ( hasDuplicate ) { + for ( var i = 1; i < results.length; i++ ) { + if ( results[i] === results[ i - 1 ] ) { + results.splice( i--, 1 ); + } + } + } + } + + return results; + }; + + Sizzle.matches = function( expr, set ) { + return Sizzle( expr, null, null, set ); + }; + + Sizzle.matchesSelector = function( node, expr ) { + return Sizzle( expr, null, null, [node] ).length > 0; + }; + + Sizzle.find = function( expr, context, isXML ) { + var set, i, len, match, type, left; + + if ( !expr ) { + return []; + } + + for ( i = 0, len = Expr.order.length; i < len; i++ ) { + type = Expr.order[i]; + + if ( (match = Expr.leftMatch[ type ].exec( expr )) ) { + left = match[1]; + match.splice( 1, 1 ); + + if ( left.substr( left.length - 1 ) !== "\\" ) { + match[1] = (match[1] || "").replace( rBackslash, "" ); + set = Expr.find[ type ]( match, context, isXML ); + + if ( set != null ) { + expr = expr.replace( Expr.match[ type ], "" ); + break; + } + } + } + } + + if ( !set ) { + set = typeof context.getElementsByTagName !== "undefined" ? + context.getElementsByTagName( "*" ) : + []; + } + + return { set: set, expr: expr }; + }; + + Sizzle.filter = function( expr, set, inplace, not ) { + var match, anyFound, + type, found, item, filter, left, + i, pass, + old = expr, + result = [], + curLoop = set, + isXMLFilter = set && set[0] && Sizzle.isXML( set[0] ); + + while ( expr && set.length ) { + for ( type in Expr.filter ) { + if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) { + filter = Expr.filter[ type ]; + left = match[1]; + + anyFound = false; + + match.splice(1,1); + + if ( left.substr( left.length - 1 ) === "\\" ) { + continue; + } + + if ( curLoop === result ) { + result = []; + } + + if ( Expr.preFilter[ type ] ) { + match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter ); + + if ( !match ) { + anyFound = found = true; + + } else if ( match === true ) { + continue; + } + } + + if ( match ) { + for ( i = 0; (item = curLoop[i]) != null; i++ ) { + if ( item ) { + found = filter( item, match, i, curLoop ); + pass = not ^ found; + + if ( inplace && found != null ) { + if ( pass ) { + anyFound = true; + + } else { + curLoop[i] = false; + } + + } else if ( pass ) { + result.push( item ); + anyFound = true; + } + } + } + } + + if ( found !== undefined ) { + if ( !inplace ) { + curLoop = result; + } + + expr = expr.replace( Expr.match[ type ], "" ); + + if ( !anyFound ) { + return []; + } + + break; + } + } + } + + // Improper expression + if ( expr === old ) { + if ( anyFound == null ) { + Sizzle.error( expr ); + + } else { + break; + } + } + + old = expr; + } + + return curLoop; + }; + + Sizzle.error = function( msg ) { + throw "Syntax error, unrecognized expression: " + msg; + }; + + /** + * Utility function for retreiving the text value of an array of DOM nodes + * @param {Array|Element} elem + */ + var getText = Sizzle.getText = function( elem ) { + var i, node, + nodeType = elem.nodeType, + ret = ""; + + if ( nodeType ) { + if ( nodeType === 1 ) { + // Use textContent || innerText for elements + if ( typeof elem.textContent === 'string' ) { + return elem.textContent; + } else if ( typeof elem.innerText === 'string' ) { + // Replace IE's carriage returns + return elem.innerText.replace( rReturn, '' ); + } else { + // Traverse it's children + for ( elem = elem.firstChild; elem; elem = elem.nextSibling) { + ret += getText( elem ); + } + } + } else if ( nodeType === 3 || nodeType === 4 ) { + return elem.nodeValue; + } + } else { + + // If no nodeType, this is expected to be an array + for ( i = 0; (node = elem[i]); i++ ) { + // Do not traverse comment nodes + if ( node.nodeType !== 8 ) { + ret += getText( node ); + } + } + } + return ret; + }; + + var Expr = Sizzle.selectors = { + order: [ "ID", "NAME", "TAG" ], + + match: { + ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, + CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, + NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/, + ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/, + TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/, + CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/, + POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/, + PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/ + }, + + leftMatch: {}, + + attrMap: { + "class": "className", + "for": "htmlFor" + }, + + attrHandle: { + href: function( elem ) { + return elem.getAttribute( "href" ); + }, + type: function( elem ) { + return elem.getAttribute( "type" ); + } + }, + + relative: { + "+": function(checkSet, part){ + var isPartStr = typeof part === "string", + isTag = isPartStr && !rNonWord.test( part ), + isPartStrNotTag = isPartStr && !isTag; + + if ( isTag ) { + part = part.toLowerCase(); + } + + for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) { + if ( (elem = checkSet[i]) ) { + while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {} + + checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ? + elem || false : + elem === part; + } + } + + if ( isPartStrNotTag ) { + Sizzle.filter( part, checkSet, true ); + } + }, + + ">": function( checkSet, part ) { + var elem, + isPartStr = typeof part === "string", + i = 0, + l = checkSet.length; + + if ( isPartStr && !rNonWord.test( part ) ) { + part = part.toLowerCase(); + + for ( ; i < l; i++ ) { + elem = checkSet[i]; + + if ( elem ) { + var parent = elem.parentNode; + checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false; + } + } + + } else { + for ( ; i < l; i++ ) { + elem = checkSet[i]; + + if ( elem ) { + checkSet[i] = isPartStr ? + elem.parentNode : + elem.parentNode === part; + } + } + + if ( isPartStr ) { + Sizzle.filter( part, checkSet, true ); + } + } + }, + + "": function(checkSet, part, isXML){ + var nodeCheck, + doneName = done++, + checkFn = dirCheck; + + if ( typeof part === "string" && !rNonWord.test( part ) ) { + part = part.toLowerCase(); + nodeCheck = part; + checkFn = dirNodeCheck; + } + + checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML ); + }, + + "~": function( checkSet, part, isXML ) { + var nodeCheck, + doneName = done++, + checkFn = dirCheck; + + if ( typeof part === "string" && !rNonWord.test( part ) ) { + part = part.toLowerCase(); + nodeCheck = part; + checkFn = dirNodeCheck; + } + + checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML ); + } + }, + + find: { + ID: function( match, context, isXML ) { + if ( typeof context.getElementById !== "undefined" && !isXML ) { + var m = context.getElementById(match[1]); + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + return m && m.parentNode ? [m] : []; + } + }, + + NAME: function( match, context ) { + if ( typeof context.getElementsByName !== "undefined" ) { + var ret = [], + results = context.getElementsByName( match[1] ); + + for ( var i = 0, l = results.length; i < l; i++ ) { + if ( results[i].getAttribute("name") === match[1] ) { + ret.push( results[i] ); + } + } + + return ret.length === 0 ? null : ret; + } + }, + + TAG: function( match, context ) { + if ( typeof context.getElementsByTagName !== "undefined" ) { + return context.getElementsByTagName( match[1] ); + } + } + }, + preFilter: { + CLASS: function( match, curLoop, inplace, result, not, isXML ) { + match = " " + match[1].replace( rBackslash, "" ) + " "; + + if ( isXML ) { + return match; + } + + for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) { + if ( elem ) { + if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) { + if ( !inplace ) { + result.push( elem ); + } + + } else if ( inplace ) { + curLoop[i] = false; + } + } + } + + return false; + }, + + ID: function( match ) { + return match[1].replace( rBackslash, "" ); + }, + + TAG: function( match, curLoop ) { + return match[1].replace( rBackslash, "" ).toLowerCase(); + }, + + CHILD: function( match ) { + if ( match[1] === "nth" ) { + if ( !match[2] ) { + Sizzle.error( match[0] ); + } + + match[2] = match[2].replace(/^\+|\s*/g, ''); + + // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6' + var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec( + match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" || + !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]); + + // calculate the numbers (first)n+(last) including if they are negative + match[2] = (test[1] + (test[2] || 1)) - 0; + match[3] = test[3] - 0; + } + else if ( match[2] ) { + Sizzle.error( match[0] ); + } + + // TODO: Move to normal caching system + match[0] = done++; + + return match; + }, + + ATTR: function( match, curLoop, inplace, result, not, isXML ) { + var name = match[1] = match[1].replace( rBackslash, "" ); + + if ( !isXML && Expr.attrMap[name] ) { + match[1] = Expr.attrMap[name]; + } + + // Handle if an un-quoted value was used + match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" ); + + if ( match[2] === "~=" ) { + match[4] = " " + match[4] + " "; + } + + return match; + }, + + PSEUDO: function( match, curLoop, inplace, result, not ) { + if ( match[1] === "not" ) { + // If we're dealing with a complex expression, or a simple one + if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) { + match[3] = Sizzle(match[3], null, null, curLoop); + + } else { + var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); + + if ( !inplace ) { + result.push.apply( result, ret ); + } + + return false; + } + + } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { + return true; + } + + return match; + }, + + POS: function( match ) { + match.unshift( true ); + + return match; + } + }, + + filters: { + enabled: function( elem ) { + return elem.disabled === false && elem.type !== "hidden"; + }, + + disabled: function( elem ) { + return elem.disabled === true; + }, + + checked: function( elem ) { + return elem.checked === true; + }, + + selected: function( elem ) { + // Accessing this property makes selected-by-default + // options in Safari work properly + if ( elem.parentNode ) { + elem.parentNode.selectedIndex; + } + + return elem.selected === true; + }, + + parent: function( elem ) { + return !!elem.firstChild; + }, + + empty: function( elem ) { + return !elem.firstChild; + }, + + has: function( elem, i, match ) { + return !!Sizzle( match[3], elem ).length; + }, + + header: function( elem ) { + return (/h\d/i).test( elem.nodeName ); + }, + + text: function( elem ) { + var attr = elem.getAttribute( "type" ), type = elem.type; + // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) + // use getAttribute instead to test this case + return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null ); + }, + + radio: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type; + }, + + checkbox: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type; + }, + + file: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "file" === elem.type; + }, + + password: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "password" === elem.type; + }, + + submit: function( elem ) { + var name = elem.nodeName.toLowerCase(); + return (name === "input" || name === "button") && "submit" === elem.type; + }, + + image: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "image" === elem.type; + }, + + reset: function( elem ) { + var name = elem.nodeName.toLowerCase(); + return (name === "input" || name === "button") && "reset" === elem.type; + }, + + button: function( elem ) { + var name = elem.nodeName.toLowerCase(); + return name === "input" && "button" === elem.type || name === "button"; + }, + + input: function( elem ) { + return (/input|select|textarea|button/i).test( elem.nodeName ); + }, + + focus: function( elem ) { + return elem === elem.ownerDocument.activeElement; + } + }, + setFilters: { + first: function( elem, i ) { + return i === 0; + }, + + last: function( elem, i, match, array ) { + return i === array.length - 1; + }, + + even: function( elem, i ) { + return i % 2 === 0; + }, + + odd: function( elem, i ) { + return i % 2 === 1; + }, + + lt: function( elem, i, match ) { + return i < match[3] - 0; + }, + + gt: function( elem, i, match ) { + return i > match[3] - 0; + }, + + nth: function( elem, i, match ) { + return match[3] - 0 === i; + }, + + eq: function( elem, i, match ) { + return match[3] - 0 === i; + } + }, + filter: { + PSEUDO: function( elem, match, i, array ) { + var name = match[1], + filter = Expr.filters[ name ]; + + if ( filter ) { + return filter( elem, i, match, array ); + + } else if ( name === "contains" ) { + return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0; + + } else if ( name === "not" ) { + var not = match[3]; + + for ( var j = 0, l = not.length; j < l; j++ ) { + if ( not[j] === elem ) { + return false; + } + } + + return true; + + } else { + Sizzle.error( name ); + } + }, + + CHILD: function( elem, match ) { + var first, last, + doneName, parent, cache, + count, diff, + type = match[1], + node = elem; + + switch ( type ) { + case "only": + case "first": + while ( (node = node.previousSibling) ) { + if ( node.nodeType === 1 ) { + return false; + } + } + + if ( type === "first" ) { + return true; + } + + node = elem; + + case "last": + while ( (node = node.nextSibling) ) { + if ( node.nodeType === 1 ) { + return false; + } + } + + return true; + + case "nth": + first = match[2]; + last = match[3]; + + if ( first === 1 && last === 0 ) { + return true; + } + + doneName = match[0]; + parent = elem.parentNode; + + if ( parent && (parent[ expando ] !== doneName || !elem.nodeIndex) ) { + count = 0; + + for ( node = parent.firstChild; node; node = node.nextSibling ) { + if ( node.nodeType === 1 ) { + node.nodeIndex = ++count; + } + } + + parent[ expando ] = doneName; + } + + diff = elem.nodeIndex - last; + + if ( first === 0 ) { + return diff === 0; + + } else { + return ( diff % first === 0 && diff / first >= 0 ); + } + } + }, + + ID: function( elem, match ) { + return elem.nodeType === 1 && elem.getAttribute("id") === match; + }, + + TAG: function( elem, match ) { + return (match === "*" && elem.nodeType === 1) || !!elem.nodeName && elem.nodeName.toLowerCase() === match; + }, + + CLASS: function( elem, match ) { + return (" " + (elem.className || elem.getAttribute("class")) + " ") + .indexOf( match ) > -1; + }, + + ATTR: function( elem, match ) { + var name = match[1], + result = Sizzle.attr ? + Sizzle.attr( elem, name ) : + Expr.attrHandle[ name ] ? + Expr.attrHandle[ name ]( elem ) : + elem[ name ] != null ? + elem[ name ] : + elem.getAttribute( name ), + value = result + "", + type = match[2], + check = match[4]; + + return result == null ? + type === "!=" : + !type && Sizzle.attr ? + result != null : + type === "=" ? + value === check : + type === "*=" ? + value.indexOf(check) >= 0 : + type === "~=" ? + (" " + value + " ").indexOf(check) >= 0 : + !check ? + value && result !== false : + type === "!=" ? + value !== check : + type === "^=" ? + value.indexOf(check) === 0 : + type === "$=" ? + value.substr(value.length - check.length) === check : + type === "|=" ? + value === check || value.substr(0, check.length + 1) === check + "-" : + false; + }, + + POS: function( elem, match, i, array ) { + var name = match[2], + filter = Expr.setFilters[ name ]; + + if ( filter ) { + return filter( elem, i, match, array ); + } + } + } + }; + + var origPOS = Expr.match.POS, + fescape = function(all, num){ + return "\\" + (num - 0 + 1); + }; + + for ( var type in Expr.match ) { + Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) ); + Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) ); + } + + var makeArray = function( array, results ) { + array = Array.prototype.slice.call( array, 0 ); + + if ( results ) { + results.push.apply( results, array ); + return results; + } + + return array; + }; + + // Perform a simple check to determine if the browser is capable of + // converting a NodeList to an array using builtin methods. + // Also verifies that the returned array holds DOM nodes + // (which is not the case in the Blackberry browser) + try { + Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType; + + // Provide a fallback method if it does not work + } catch( e ) { + makeArray = function( array, results ) { + var i = 0, + ret = results || []; + + if ( toString.call(array) === "[object Array]" ) { + Array.prototype.push.apply( ret, array ); + + } else { + if ( typeof array.length === "number" ) { + for ( var l = array.length; i < l; i++ ) { + ret.push( array[i] ); + } + + } else { + for ( ; array[i]; i++ ) { + ret.push( array[i] ); + } + } + } + + return ret; + }; + } + + var sortOrder, siblingCheck; + + if ( document.documentElement.compareDocumentPosition ) { + sortOrder = function( a, b ) { + if ( a === b ) { + hasDuplicate = true; + return 0; + } + + if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) { + return a.compareDocumentPosition ? -1 : 1; + } + + return a.compareDocumentPosition(b) & 4 ? -1 : 1; + }; + + } else { + sortOrder = function( a, b ) { + // The nodes are identical, we can exit early + if ( a === b ) { + hasDuplicate = true; + return 0; + + // Fallback to using sourceIndex (in IE) if it's available on both nodes + } else if ( a.sourceIndex && b.sourceIndex ) { + return a.sourceIndex - b.sourceIndex; + } + + var al, bl, + ap = [], + bp = [], + aup = a.parentNode, + bup = b.parentNode, + cur = aup; + + // If the nodes are siblings (or identical) we can do a quick check + if ( aup === bup ) { + return siblingCheck( a, b ); + + // If no parents were found then the nodes are disconnected + } else if ( !aup ) { + return -1; + + } else if ( !bup ) { + return 1; + } + + // Otherwise they're somewhere else in the tree so we need + // to build up a full list of the parentNodes for comparison + while ( cur ) { + ap.unshift( cur ); + cur = cur.parentNode; + } + + cur = bup; + + while ( cur ) { + bp.unshift( cur ); + cur = cur.parentNode; + } + + al = ap.length; + bl = bp.length; + + // Start walking down the tree looking for a discrepancy + for ( var i = 0; i < al && i < bl; i++ ) { + if ( ap[i] !== bp[i] ) { + return siblingCheck( ap[i], bp[i] ); + } + } + + // We ended someplace up the tree so do a sibling check + return i === al ? + siblingCheck( a, bp[i], -1 ) : + siblingCheck( ap[i], b, 1 ); + }; + + siblingCheck = function( a, b, ret ) { + if ( a === b ) { + return ret; + } + + var cur = a.nextSibling; + + while ( cur ) { + if ( cur === b ) { + return -1; + } + + cur = cur.nextSibling; + } + + return 1; + }; + } + + // Check to see if the browser returns elements by name when + // querying by getElementById (and provide a workaround) + (function(){ + // We're going to inject a fake input element with a specified name + var form = document.createElement("div"), + id = "script" + (new Date()).getTime(), + root = document.documentElement; + + form.innerHTML = ""; + + // Inject it into the root element, check its status, and remove it quickly + root.insertBefore( form, root.firstChild ); + + // The workaround has to do additional checks after a getElementById + // Which slows things down for other browsers (hence the branching) + if ( document.getElementById( id ) ) { + Expr.find.ID = function( match, context, isXML ) { + if ( typeof context.getElementById !== "undefined" && !isXML ) { + var m = context.getElementById(match[1]); + + return m ? + m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? + [m] : + undefined : + []; + } + }; + + Expr.filter.ID = function( elem, match ) { + var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); + + return elem.nodeType === 1 && node && node.nodeValue === match; + }; + } + + root.removeChild( form ); + + // release memory in IE + root = form = null; + })(); + + (function(){ + // Check to see if the browser returns only elements + // when doing getElementsByTagName("*") + + // Create a fake element + var div = document.createElement("div"); + div.appendChild( document.createComment("") ); + + // Make sure no comments are found + if ( div.getElementsByTagName("*").length > 0 ) { + Expr.find.TAG = function( match, context ) { + var results = context.getElementsByTagName( match[1] ); + + // Filter out possible comments + if ( match[1] === "*" ) { + var tmp = []; + + for ( var i = 0; results[i]; i++ ) { + if ( results[i].nodeType === 1 ) { + tmp.push( results[i] ); + } + } + + results = tmp; + } + + return results; + }; + } + + // Check to see if an attribute returns normalized href attributes + div.innerHTML = ""; + + if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" && + div.firstChild.getAttribute("href") !== "#" ) { + + Expr.attrHandle.href = function( elem ) { + return elem.getAttribute( "href", 2 ); + }; + } + + // release memory in IE + div = null; + })(); + + if ( document.querySelectorAll ) { + (function(){ + var oldSizzle = Sizzle, + div = document.createElement("div"), + id = "__sizzle__"; + + div.innerHTML = "

"; + + // Safari can't handle uppercase or unicode characters when + // in quirks mode. + if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { + return; + } + + Sizzle = function( query, context, extra, seed ) { + context = context || document; + + // Only use querySelectorAll on non-XML documents + // (ID selectors don't work in non-HTML documents) + if ( !seed && !Sizzle.isXML(context) ) { + // See if we find a selector to speed up + var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query ); + + if ( match && (context.nodeType === 1 || context.nodeType === 9) ) { + // Speed-up: Sizzle("TAG") + if ( match[1] ) { + return makeArray( context.getElementsByTagName( query ), extra ); + + // Speed-up: Sizzle(".CLASS") + } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) { + return makeArray( context.getElementsByClassName( match[2] ), extra ); + } + } + + if ( context.nodeType === 9 ) { + // Speed-up: Sizzle("body") + // The body element only exists once, optimize finding it + if ( query === "body" && context.body ) { + return makeArray( [ context.body ], extra ); + + // Speed-up: Sizzle("#ID") + } else if ( match && match[3] ) { + var elem = context.getElementById( match[3] ); + + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + if ( elem && elem.parentNode ) { + // Handle the case where IE and Opera return items + // by name instead of ID + if ( elem.id === match[3] ) { + return makeArray( [ elem ], extra ); + } + + } else { + return makeArray( [], extra ); + } + } + + try { + return makeArray( context.querySelectorAll(query), extra ); + } catch(qsaError) {} + + // qSA works strangely on Element-rooted queries + // We can work around this by specifying an extra ID on the root + // and working up from there (Thanks to Andrew Dupont for the technique) + // IE 8 doesn't work on object elements + } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { + var oldContext = context, + old = context.getAttribute( "id" ), + nid = old || id, + hasParent = context.parentNode, + relativeHierarchySelector = /^\s*[+~]/.test( query ); + + if ( !old ) { + context.setAttribute( "id", nid ); + } else { + nid = nid.replace( /'/g, "\\$&" ); + } + if ( relativeHierarchySelector && hasParent ) { + context = context.parentNode; + } + + try { + if ( !relativeHierarchySelector || hasParent ) { + return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra ); + } + + } catch(pseudoError) { + } finally { + if ( !old ) { + oldContext.removeAttribute( "id" ); + } + } + } + } + + return oldSizzle(query, context, extra, seed); + }; + + for ( var prop in oldSizzle ) { + Sizzle[ prop ] = oldSizzle[ prop ]; + } + + // release memory in IE + div = null; + })(); + } + + (function(){ + var html = document.documentElement, + matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector; + + if ( matches ) { + // Check to see if it's possible to do matchesSelector + // on a disconnected node (IE 9 fails this) + var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ), + pseudoWorks = false; + + try { + // This should fail with an exception + // Gecko does not error, returns false instead + matches.call( document.documentElement, "[test!='']:sizzle" ); + + } catch( pseudoError ) { + pseudoWorks = true; + } + + Sizzle.matchesSelector = function( node, expr ) { + // Make sure that attribute selectors are quoted + expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); + + if ( !Sizzle.isXML( node ) ) { + try { + if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) { + var ret = matches.call( node, expr ); + + // IE 9's matchesSelector returns false on disconnected nodes + if ( ret || !disconnectedMatch || + // As well, disconnected nodes are said to be in a document + // fragment in IE 9, so check for that + node.document && node.document.nodeType !== 11 ) { + return ret; + } + } + } catch(e) {} + } + + return Sizzle(expr, null, null, [node]).length > 0; + }; + } + })(); + + (function(){ + var div = document.createElement("div"); + + div.innerHTML = "
"; + + // Opera can't find a second classname (in 9.6) + // Also, make sure that getElementsByClassName actually exists + if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) { + return; + } + + // Safari caches class attributes, doesn't catch changes (in 3.2) + div.lastChild.className = "e"; + + if ( div.getElementsByClassName("e").length === 1 ) { + return; + } + + Expr.order.splice(1, 0, "CLASS"); + Expr.find.CLASS = function( match, context, isXML ) { + if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { + return context.getElementsByClassName(match[1]); + } + }; + + // release memory in IE + div = null; + })(); + + function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { + for ( var i = 0, l = checkSet.length; i < l; i++ ) { + var elem = checkSet[i]; + + if ( elem ) { + var match = false; + + elem = elem[dir]; + + while ( elem ) { + if ( elem[ expando ] === doneName ) { + match = checkSet[elem.sizset]; + break; + } + + if ( elem.nodeType === 1 && !isXML ){ + elem[ expando ] = doneName; + elem.sizset = i; + } + + if ( elem.nodeName.toLowerCase() === cur ) { + match = elem; + break; + } + + elem = elem[dir]; + } + + checkSet[i] = match; + } + } + } + + function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { + for ( var i = 0, l = checkSet.length; i < l; i++ ) { + var elem = checkSet[i]; + + if ( elem ) { + var match = false; + + elem = elem[dir]; + + while ( elem ) { + if ( elem[ expando ] === doneName ) { + match = checkSet[elem.sizset]; + break; + } + + if ( elem.nodeType === 1 ) { + if ( !isXML ) { + elem[ expando ] = doneName; + elem.sizset = i; + } + + if ( typeof cur !== "string" ) { + if ( elem === cur ) { + match = true; + break; + } + + } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) { + match = elem; + break; + } + } + + elem = elem[dir]; + } + + checkSet[i] = match; + } + } + } + + if ( document.documentElement.contains ) { + Sizzle.contains = function( a, b ) { + return a !== b && (a.contains ? a.contains(b) : true); + }; + + } else if ( document.documentElement.compareDocumentPosition ) { + Sizzle.contains = function( a, b ) { + return !!(a.compareDocumentPosition(b) & 16); + }; + + } else { + Sizzle.contains = function() { + return false; + }; + } + + Sizzle.isXML = function( elem ) { + // documentElement is verified for cases where it doesn't yet exist + // (such as loading iframes in IE - #4833) + var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement; + + return documentElement ? documentElement.nodeName !== "HTML" : false; + }; + + var posProcess = function( selector, context, seed ) { + var match, + tmpSet = [], + later = "", + root = context.nodeType ? [context] : context; + + // Position selectors must be done after the filter + // And so must :not(positional) so we move all PSEUDOs to the end + while ( (match = Expr.match.PSEUDO.exec( selector )) ) { + later += match[0]; + selector = selector.replace( Expr.match.PSEUDO, "" ); + } + + selector = Expr.relative[selector] ? selector + "*" : selector; + + for ( var i = 0, l = root.length; i < l; i++ ) { + Sizzle( selector, root[i], tmpSet, seed ); + } + + return Sizzle.filter( later, tmpSet ); + }; + + // EXPOSE + // Override sizzle attribute retrieval + Sizzle.attr = jQuery.attr; + Sizzle.selectors.attrMap = {}; + jQuery.find = Sizzle; + jQuery.expr = Sizzle.selectors; + jQuery.expr[":"] = jQuery.expr.filters; + jQuery.unique = Sizzle.uniqueSort; + jQuery.text = Sizzle.getText; + jQuery.isXMLDoc = Sizzle.isXML; + jQuery.contains = Sizzle.contains; + + + })(); + + + var runtil = /Until$/, + rparentsprev = /^(?:parents|prevUntil|prevAll)/, + // Note: This RegExp should be improved, or likely pulled from Sizzle + rmultiselector = /,/, + isSimple = /^.[^:#\[\.,]*$/, + slice = Array.prototype.slice, + POS = jQuery.expr.match.POS, + // methods guaranteed to produce a unique set when starting from a unique set + guaranteedUnique = { + children: true, + contents: true, + next: true, + prev: true + }; + + jQuery.fn.extend({ + find: function( selector ) { + var self = this, + i, l; + + if ( typeof selector !== "string" ) { + return jQuery( selector ).filter(function() { + for ( i = 0, l = self.length; i < l; i++ ) { + if ( jQuery.contains( self[ i ], this ) ) { + return true; + } + } + }); + } + + var ret = this.pushStack( "", "find", selector ), + length, n, r; + + for ( i = 0, l = this.length; i < l; i++ ) { + length = ret.length; + jQuery.find( selector, this[i], ret ); + + if ( i > 0 ) { + // Make sure that the results are unique + for ( n = length; n < ret.length; n++ ) { + for ( r = 0; r < length; r++ ) { + if ( ret[r] === ret[n] ) { + ret.splice(n--, 1); + break; + } + } + } + } + } + + return ret; + }, + + has: function( target ) { + var targets = jQuery( target ); + return this.filter(function() { + for ( var i = 0, l = targets.length; i < l; i++ ) { + if ( jQuery.contains( this, targets[i] ) ) { + return true; + } + } + }); + }, + + not: function( selector ) { + return this.pushStack( winnow(this, selector, false), "not", selector); + }, + + filter: function( selector ) { + return this.pushStack( winnow(this, selector, true), "filter", selector ); + }, + + is: function( selector ) { + return !!selector && ( + typeof selector === "string" ? + // If this is a positional selector, check membership in the returned set + // so $("p:first").is("p:last") won't return true for a doc with two "p". + POS.test( selector ) ? + jQuery( selector, this.context ).index( this[0] ) >= 0 : + jQuery.filter( selector, this ).length > 0 : + this.filter( selector ).length > 0 ); + }, + + closest: function( selectors, context ) { + var ret = [], i, l, cur = this[0]; + + // Array (deprecated as of jQuery 1.7) + if ( jQuery.isArray( selectors ) ) { + var level = 1; + + while ( cur && cur.ownerDocument && cur !== context ) { + for ( i = 0; i < selectors.length; i++ ) { + + if ( jQuery( cur ).is( selectors[ i ] ) ) { + ret.push({ selector: selectors[ i ], elem: cur, level: level }); + } + } + + cur = cur.parentNode; + level++; + } + + return ret; + } + + // String + var pos = POS.test( selectors ) || typeof selectors !== "string" ? + jQuery( selectors, context || this.context ) : + 0; + + for ( i = 0, l = this.length; i < l; i++ ) { + cur = this[i]; + + while ( cur ) { + if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) { + ret.push( cur ); + break; + + } else { + cur = cur.parentNode; + if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) { + break; + } + } + } + } + + ret = ret.length > 1 ? jQuery.unique( ret ) : ret; + + return this.pushStack( ret, "closest", selectors ); + }, + + // Determine the position of an element within + // the matched set of elements + index: function( elem ) { + + // No argument, return index in parent + if ( !elem ) { + return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1; + } + + // index in selector + if ( typeof elem === "string" ) { + return jQuery.inArray( this[0], jQuery( elem ) ); + } + + // Locate the position of the desired element + return jQuery.inArray( + // If it receives a jQuery object, the first element is used + elem.jquery ? elem[0] : elem, this ); + }, + + add: function( selector, context ) { + var set = typeof selector === "string" ? + jQuery( selector, context ) : + jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ), + all = jQuery.merge( this.get(), set ); + + return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ? + all : + jQuery.unique( all ) ); + }, + + andSelf: function() { + return this.add( this.prevObject ); + } + }); + + // A painfully simple check to see if an element is disconnected + // from a document (should be improved, where feasible). + function isDisconnected( node ) { + return !node || !node.parentNode || node.parentNode.nodeType === 11; + } + + jQuery.each({ + parent: function( elem ) { + var parent = elem.parentNode; + return parent && parent.nodeType !== 11 ? parent : null; + }, + parents: function( elem ) { + return jQuery.dir( elem, "parentNode" ); + }, + parentsUntil: function( elem, i, until ) { + return jQuery.dir( elem, "parentNode", until ); + }, + next: function( elem ) { + return jQuery.nth( elem, 2, "nextSibling" ); + }, + prev: function( elem ) { + return jQuery.nth( elem, 2, "previousSibling" ); + }, + nextAll: function( elem ) { + return jQuery.dir( elem, "nextSibling" ); + }, + prevAll: function( elem ) { + return jQuery.dir( elem, "previousSibling" ); + }, + nextUntil: function( elem, i, until ) { + return jQuery.dir( elem, "nextSibling", until ); + }, + prevUntil: function( elem, i, until ) { + return jQuery.dir( elem, "previousSibling", until ); + }, + siblings: function( elem ) { + return jQuery.sibling( elem.parentNode.firstChild, elem ); + }, + children: function( elem ) { + return jQuery.sibling( elem.firstChild ); + }, + contents: function( elem ) { + return jQuery.nodeName( elem, "iframe" ) ? + elem.contentDocument || elem.contentWindow.document : + jQuery.makeArray( elem.childNodes ); + } + }, function( name, fn ) { + jQuery.fn[ name ] = function( until, selector ) { + var ret = jQuery.map( this, fn, until ), + // The variable 'args' was introduced in + // https://github.com/jquery/jquery/commit/52a0238 + // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed. + // http://code.google.com/p/v8/issues/detail?id=1050 + args = slice.call(arguments); + + if ( !runtil.test( name ) ) { + selector = until; + } + + if ( selector && typeof selector === "string" ) { + ret = jQuery.filter( selector, ret ); + } + + ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret; + + if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) { + ret = ret.reverse(); + } + + return this.pushStack( ret, name, args.join(",") ); + }; + }); + + jQuery.extend({ + filter: function( expr, elems, not ) { + if ( not ) { + expr = ":not(" + expr + ")"; + } + + return elems.length === 1 ? + jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] : + jQuery.find.matches(expr, elems); + }, + + dir: function( elem, dir, until ) { + var matched = [], + cur = elem[ dir ]; + + while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) { + if ( cur.nodeType === 1 ) { + matched.push( cur ); + } + cur = cur[dir]; + } + return matched; + }, + + nth: function( cur, result, dir, elem ) { + result = result || 1; + var num = 0; + + for ( ; cur; cur = cur[dir] ) { + if ( cur.nodeType === 1 && ++num === result ) { + break; + } + } + + return cur; + }, + + sibling: function( n, elem ) { + var r = []; + + for ( ; n; n = n.nextSibling ) { + if ( n.nodeType === 1 && n !== elem ) { + r.push( n ); + } + } + + return r; + } + }); + + // Implement the identical functionality for filter and not + function winnow( elements, qualifier, keep ) { + + // Can't pass null or undefined to indexOf in Firefox 4 + // Set to 0 to skip string check + qualifier = qualifier || 0; + + if ( jQuery.isFunction( qualifier ) ) { + return jQuery.grep(elements, function( elem, i ) { + var retVal = !!qualifier.call( elem, i, elem ); + return retVal === keep; + }); + + } else if ( qualifier.nodeType ) { + return jQuery.grep(elements, function( elem, i ) { + return ( elem === qualifier ) === keep; + }); + + } else if ( typeof qualifier === "string" ) { + var filtered = jQuery.grep(elements, function( elem ) { + return elem.nodeType === 1; + }); + + if ( isSimple.test( qualifier ) ) { + return jQuery.filter(qualifier, filtered, !keep); + } else { + qualifier = jQuery.filter( qualifier, filtered ); + } + } + + return jQuery.grep(elements, function( elem, i ) { + return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep; + }); + } + + + + + function createSafeFragment( document ) { + var list = nodeNames.split( " " ), + safeFrag = document.createDocumentFragment(); + + if ( safeFrag.createElement ) { + while ( list.length ) { + safeFrag.createElement( + list.pop() + ); + } + } + return safeFrag; + } + + var nodeNames = "abbr article aside audio canvas datalist details figcaption figure footer " + + "header hgroup mark meter nav output progress section summary time video", + rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, + rleadingWhitespace = /^\s+/, + rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig, + rtagName = /<([\w:]+)/, + rtbody = /", "" ], + legend: [ 1, "
", "
" ], + thead: [ 1, "", "
" ], + tr: [ 2, "", "
" ], + td: [ 3, "", "
" ], + col: [ 2, "", "
" ], + area: [ 1, "", "" ], + _default: [ 0, "", "" ] + }, + safeFragment = createSafeFragment( document ); + + wrapMap.optgroup = wrapMap.option; + wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; + wrapMap.th = wrapMap.td; + + // IE can't serialize and +``` + +Next you need to import and initialise GOV.UK Frontend by adding: + +```html + +``` + +[More details on importing JavaScript and advanced options](https://frontend.design-system.service.gov.uk/importing-css-assets-and-javascript/#javascript) + +## Importing assets + +In order to import GOV.UK Frontend images and fonts to your project, you should configure your application to reference or copy the relevant GOV.UK Frontend assets. + +[More details on importing assets](https://frontend.design-system.service.gov.uk/importing-css-assets-and-javascript/#font-and-image-assets) + +## Getting updates + +To be notified when there’s a new release, you can either: + +- [watch the govuk-frontend Github repository](https://help.github.com/en/articles/watching-and-unwatching-repositories) +- join the [#govuk-design-system channel on cross-government Slack](https://ukgovernmentdigital.slack.com/app_redirect?channel=govuk-design-system) + +Find out how to [update with npm](https://frontend.design-system.service.gov.uk/updating-with-npm/). + +## Licence + +Unless stated otherwise, the codebase is released under the MIT License. This +covers both the codebase and any sample code in the documentation. The +documentation is © Crown copyright and available under the terms of the +Open Government 3.0 licence. + +## Contribution guidelines + +If you want to help us build GOV.UK Frontend, view our [contribution guidelines](/CONTRIBUTING.md). diff --git a/node_modules/govuk-frontend/govuk-prototype-kit.config.json b/node_modules/govuk-frontend/govuk-prototype-kit.config.json new file mode 100644 index 00000000..5cfb1969 --- /dev/null +++ b/node_modules/govuk-frontend/govuk-prototype-kit.config.json @@ -0,0 +1,168 @@ +{ + "meta": { + "description": "GOV.UK Frontend contains the code you need to start building a user interface for government platforms and services.", + "urls": { + "documentation": "https://design-system.service.gov.uk/", + "releaseNotes": "https://github.com/alphagov/govuk-frontend/releases/tag/v5.0.0", + "versionHistory": "https://github.com/alphagov/govuk-frontend/releases" + } + }, + "assets": [ + "/dist/govuk/assets", + "/dist/govuk/govuk-frontend.min.js.map" + ], + "sass": [ + "/dist/govuk-prototype-kit/init.scss" + ], + "scripts": [ + { + "path": "/dist/govuk/govuk-frontend.min.js", + "type": "module" + }, + { + "path": "/dist/govuk-prototype-kit/init.js", + "type": "module" + } + ], + "nunjucksMacros": [ + { + "importFrom": "govuk/components/accordion/macro.njk", + "macroName": "govukAccordion" + }, + { + "importFrom": "govuk/components/back-link/macro.njk", + "macroName": "govukBackLink" + }, + { + "importFrom": "govuk/components/breadcrumbs/macro.njk", + "macroName": "govukBreadcrumbs" + }, + { + "importFrom": "govuk/components/button/macro.njk", + "macroName": "govukButton" + }, + { + "importFrom": "govuk/components/character-count/macro.njk", + "macroName": "govukCharacterCount" + }, + { + "importFrom": "govuk/components/checkboxes/macro.njk", + "macroName": "govukCheckboxes" + }, + { + "importFrom": "govuk/components/cookie-banner/macro.njk", + "macroName": "govukCookieBanner" + }, + { + "importFrom": "govuk/components/date-input/macro.njk", + "macroName": "govukDateInput" + }, + { + "importFrom": "govuk/components/details/macro.njk", + "macroName": "govukDetails" + }, + { + "importFrom": "govuk/components/error-message/macro.njk", + "macroName": "govukErrorMessage" + }, + { + "importFrom": "govuk/components/error-summary/macro.njk", + "macroName": "govukErrorSummary" + }, + { + "importFrom": "govuk/components/exit-this-page/macro.njk", + "macroName": "govukExitThisPage" + }, + { + "importFrom": "govuk/components/fieldset/macro.njk", + "macroName": "govukFieldset" + }, + { + "importFrom": "govuk/components/file-upload/macro.njk", + "macroName": "govukFileUpload" + }, + { + "importFrom": "govuk/components/footer/macro.njk", + "macroName": "govukFooter" + }, + { + "importFrom": "govuk/components/header/macro.njk", + "macroName": "govukHeader" + }, + { + "importFrom": "govuk/components/hint/macro.njk", + "macroName": "govukHint" + }, + { + "importFrom": "govuk/components/input/macro.njk", + "macroName": "govukInput" + }, + { + "importFrom": "govuk/components/inset-text/macro.njk", + "macroName": "govukInsetText" + }, + { + "importFrom": "govuk/components/label/macro.njk", + "macroName": "govukLabel" + }, + { + "importFrom": "govuk/components/notification-banner/macro.njk", + "macroName": "govukNotificationBanner" + }, + { + "importFrom": "govuk/components/pagination/macro.njk", + "macroName": "govukPagination" + }, + { + "importFrom": "govuk/components/panel/macro.njk", + "macroName": "govukPanel" + }, + { + "importFrom": "govuk/components/phase-banner/macro.njk", + "macroName": "govukPhaseBanner" + }, + { + "importFrom": "govuk/components/radios/macro.njk", + "macroName": "govukRadios" + }, + { + "importFrom": "govuk/components/select/macro.njk", + "macroName": "govukSelect" + }, + { + "importFrom": "govuk/components/skip-link/macro.njk", + "macroName": "govukSkipLink" + }, + { + "importFrom": "govuk/components/summary-list/macro.njk", + "macroName": "govukSummaryList" + }, + { + "importFrom": "govuk/components/table/macro.njk", + "macroName": "govukTable" + }, + { + "importFrom": "govuk/components/tabs/macro.njk", + "macroName": "govukTabs" + }, + { + "importFrom": "govuk/components/tag/macro.njk", + "macroName": "govukTag" + }, + { + "importFrom": "govuk/components/task-list/macro.njk", + "macroName": "govukTaskList" + }, + { + "importFrom": "govuk/components/textarea/macro.njk", + "macroName": "govukTextarea" + }, + { + "importFrom": "govuk/components/warning-text/macro.njk", + "macroName": "govukWarningText" + } + ], + "nunjucksPaths": [ + "/dist" + ] +} diff --git a/node_modules/govuk-frontend/package.json b/node_modules/govuk-frontend/package.json new file mode 100644 index 00000000..0fd94afd --- /dev/null +++ b/node_modules/govuk-frontend/package.json @@ -0,0 +1,91 @@ +{ + "name": "govuk-frontend", + "description": "GOV.UK Frontend contains the code you need to start building a user interface for government platforms and services.", + "version": "5.0.0", + "main": "dist/govuk/all.bundle.js", + "module": "dist/govuk/all.mjs", + "sass": "dist/govuk/all.scss", + "files": [ + "dist", + "govuk-prototype-kit.config.json", + "package.json", + "README.md" + ], + "exports": { + ".": { + "sass": "./dist/govuk/all.scss", + "import": "./dist/govuk/all.mjs", + "require": "./dist/govuk/all.bundle.js", + "default": "./dist/govuk/all.bundle.js" + }, + "./*": "./*", + "./dist/": "./dist/", + "./govuk-prototype-kit.config.json": "./govuk-prototype-kit.config.json", + "./package.json": "./package.json" + }, + "engines": { + "node": ">= 4.2.0" + }, + "author": { + "name": "GOV.UK Design System Team (Government Digital Service)", + "email": "design-system-developers@digital.cabinet-office.gov.uk" + }, + "repository": { + "type": "git", + "url": "https://github.com/alphagov/govuk-frontend.git" + }, + "bugs": { + "url": "https://github.com/alphagov/govuk-frontend/issues" + }, + "homepage": "https://frontend.design-system.service.gov.uk/", + "keywords": [ + "govuk", + "frontend", + "design system", + "template" + ], + "license": "MIT", + "scripts": { + "dev": "gulp dev --color", + "prebuild:package": "npm run clean:package", + "prebuild:release": "npm run clean:release", + "build": "npm run build:package", + "build:package": "gulp build:package --color", + "build:release": "gulp build:release --color", + "build:stats": "npm run stats --workspace @govuk-frontend/stats", + "build:types": "tsc --build tsconfig.build.json", + "clean": "npm run clean:package", + "clean:package": "del-cli *.tsbuildinfo dist govuk-prototype-kit.config.json", + "clean:release": "del-cli ../../dist --force", + "postbuild:package": "npm run build:stats && govuk-prototype-kit validate-plugin .", + "version": "echo $npm_package_version" + }, + "devDependencies": { + "@govuk-frontend/config": "*", + "@govuk-frontend/helpers": "*", + "@govuk-frontend/lib": "*", + "@govuk-frontend/tasks": "*", + "@babel/core": "^7.23.5", + "@babel/preset-env": "^7.23.5", + "@rollup/plugin-babel": "^6.0.4", + "@rollup/plugin-replace": "^5.0.5", + "@rollup/plugin-terser": "^0.4.4", + "autoprefixer": "^10.4.16", + "cssnano": "^6.0.1", + "cssnano-preset-default": "^6.0.1", + "govuk-prototype-kit": "^13.16.0", + "gulp": "^4.0.2", + "gulp-cli": "^2.3.0", + "html-validate": "8.7.3", + "nunjucks": "^3.2.4", + "outdent": "^0.8.0", + "postcss": "^8.4.32", + "postcss-scss": "^4.0.9", + "puppeteer": "^21.5.2", + "rollup": "^4.6.1", + "sass-color-helpers": "^2.1.1", + "sass-embedded": "^1.69.5", + "sassdoc": "^2.7.4", + "slash": "^5.1.0" + } +} diff --git a/node_modules/immutable/LICENSE b/node_modules/immutable/LICENSE new file mode 100644 index 00000000..1e3c4f39 --- /dev/null +++ b/node_modules/immutable/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2014-present, Lee Byron and other contributors. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/immutable/README.md b/node_modules/immutable/README.md new file mode 100644 index 00000000..02e143cd --- /dev/null +++ b/node_modules/immutable/README.md @@ -0,0 +1,761 @@ +# Immutable collections for JavaScript + +[![Build Status](https://github.com/immutable-js/immutable-js/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/immutable-js/immutable-js/actions/workflows/ci.yml?query=branch%3Amain) [Chat on slack](https://immutable-js.slack.com) + +[Read the docs](https://immutable-js.com) and eat your vegetables. + +Docs are automatically generated from [README.md][] and [immutable.d.ts][]. +Please contribute! Also, don't miss the [wiki][] which contains articles on +additional specific topics. Can't find something? Open an [issue][]. + +**Table of contents:** + +- [Introduction](#introduction) +- [Getting started](#getting-started) +- [The case for Immutability](#the-case-for-immutability) +- [JavaScript-first API](#javascript-first-api) +- [Nested Structures](#nested-structures) +- [Equality treats Collections as Values](#equality-treats-collections-as-values) +- [Batching Mutations](#batching-mutations) +- [Lazy Seq](#lazy-seq) +- [Additional Tools and Resources](#additional-tools-and-resources) +- [Contributing](#contributing) + +## Introduction + +[Immutable][] data cannot be changed once created, leading to much simpler +application development, no defensive copying, and enabling advanced memoization +and change detection techniques with simple logic. [Persistent][] data presents +a mutative API which does not update the data in-place, but instead always +yields new updated data. + +Immutable.js provides many Persistent Immutable data structures including: +`List`, `Stack`, `Map`, `OrderedMap`, `Set`, `OrderedSet` and `Record`. + +These data structures are highly efficient on modern JavaScript VMs by using +structural sharing via [hash maps tries][] and [vector tries][] as popularized +by Clojure and Scala, minimizing the need to copy or cache data. + +Immutable.js also provides a lazy `Seq`, allowing efficient +chaining of collection methods like `map` and `filter` without creating +intermediate representations. Create some `Seq` with `Range` and `Repeat`. + +Want to hear more? Watch the presentation about Immutable.js: + +[![Immutable Data and React](website/public/Immutable-Data-and-React-YouTube.png)](https://youtu.be/I7IdS-PbEgI) + +[README.md]: https://github.com/immutable-js/immutable-js/blob/main/README.md +[immutable.d.ts]: https://github.com/immutable-js/immutable-js/blob/main/type-definitions/immutable.d.ts +[wiki]: https://github.com/immutable-js/immutable-js/wiki +[issue]: https://github.com/immutable-js/immutable-js/issues +[Persistent]: https://en.wikipedia.org/wiki/Persistent_data_structure +[Immutable]: https://en.wikipedia.org/wiki/Immutable_object +[hash maps tries]: https://en.wikipedia.org/wiki/Hash_array_mapped_trie +[vector tries]: https://hypirion.com/musings/understanding-persistent-vector-pt-1 + +## Getting started + +Install `immutable` using npm. + +```shell +# using npm +npm install immutable + +# using Yarn +yarn add immutable + +# using pnpm +pnpm add immutable + +# using Bun +bun add immutable +``` + +Then require it into any module. + + + +```js +const { Map } = require('immutable'); +const map1 = Map({ a: 1, b: 2, c: 3 }); +const map2 = map1.set('b', 50); +map1.get('b') + ' vs. ' + map2.get('b'); // 2 vs. 50 +``` + +### Browser + +Immutable.js has no dependencies, which makes it predictable to include in a Browser. + +It's highly recommended to use a module bundler like [webpack](https://webpack.github.io/), +[rollup](https://rollupjs.org/), or +[browserify](https://browserify.org/). The `immutable` npm module works +without any additional consideration. All examples throughout the documentation +will assume use of this kind of tool. + +Alternatively, Immutable.js may be directly included as a script tag. Download +or link to a CDN such as [CDNJS](https://cdnjs.com/libraries/immutable) +or [jsDelivr](https://www.jsdelivr.com/package/npm/immutable). + +Use a script tag to directly add `Immutable` to the global scope: + +```html + + +``` + +Or use an AMD-style loader (such as [RequireJS](https://requirejs.org/)): + +```js +require(['./immutable.min.js'], function (Immutable) { + var map1 = Immutable.Map({ a: 1, b: 2, c: 3 }); + var map2 = map1.set('b', 50); + map1.get('b'); // 2 + map2.get('b'); // 50 +}); +``` + +### Flow & TypeScript + +Use these Immutable collections and sequences as you would use native +collections in your [Flowtype](https://flowtype.org/) or [TypeScript](https://typescriptlang.org) programs while still taking +advantage of type generics, error detection, and auto-complete in your IDE. + +Installing `immutable` via npm brings with it type definitions for Flow (v0.55.0 or higher) +and TypeScript (v2.1.0 or higher), so you shouldn't need to do anything at all! + +#### Using TypeScript with Immutable.js v4 + +Immutable.js type definitions embrace ES2015. While Immutable.js itself supports +legacy browsers and environments, its type definitions require TypeScript's 2015 +lib. Include either `"target": "es2015"` or `"lib": "es2015"` in your +`tsconfig.json`, or provide `--target es2015` or `--lib es2015` to the +`tsc` command. + + + +```js +const { Map } = require('immutable'); +const map1 = Map({ a: 1, b: 2, c: 3 }); +const map2 = map1.set('b', 50); +map1.get('b') + ' vs. ' + map2.get('b'); // 2 vs. 50 +``` + +#### Using TypeScript with Immutable.js v3 and earlier: + +Previous versions of Immutable.js include a reference file which you can include +via relative path to the type definitions at the top of your file. + +```js +/// +import Immutable from 'immutable'; +var map1: Immutable.Map; +map1 = Immutable.Map({ a: 1, b: 2, c: 3 }); +var map2 = map1.set('b', 50); +map1.get('b'); // 2 +map2.get('b'); // 50 +``` + +## The case for Immutability + +Much of what makes application development difficult is tracking mutation and +maintaining state. Developing with immutable data encourages you to think +differently about how data flows through your application. + +Subscribing to data events throughout your application creates a huge overhead of +book-keeping which can hurt performance, sometimes dramatically, and creates +opportunities for areas of your application to get out of sync with each other +due to easy to make programmer error. Since immutable data never changes, +subscribing to changes throughout the model is a dead-end and new data can only +ever be passed from above. + +This model of data flow aligns well with the architecture of [React][] +and especially well with an application designed using the ideas of [Flux][]. + +When data is passed from above rather than being subscribed to, and you're only +interested in doing work when something has changed, you can use equality. + +Immutable collections should be treated as _values_ rather than _objects_. While +objects represent some thing which could change over time, a value represents +the state of that thing at a particular instance of time. This principle is most +important to understanding the appropriate use of immutable data. In order to +treat Immutable.js collections as values, it's important to use the +`Immutable.is()` function or `.equals()` method to determine _value equality_ +instead of the `===` operator which determines object _reference identity_. + + + +```js +const { Map } = require('immutable'); +const map1 = Map({ a: 1, b: 2, c: 3 }); +const map2 = Map({ a: 1, b: 2, c: 3 }); +map1.equals(map2); // true +map1 === map2; // false +``` + +Note: As a performance optimization Immutable.js attempts to return the existing +collection when an operation would result in an identical collection, allowing +for using `===` reference equality to determine if something definitely has not +changed. This can be extremely useful when used within a memoization function +which would prefer to re-run the function if a deeper equality check could +potentially be more costly. The `===` equality check is also used internally by +`Immutable.is` and `.equals()` as a performance optimization. + + + +```js +const { Map } = require('immutable'); +const map1 = Map({ a: 1, b: 2, c: 3 }); +const map2 = map1.set('b', 2); // Set to same value +map1 === map2; // true +``` + +If an object is immutable, it can be "copied" simply by making another reference +to it instead of copying the entire object. Because a reference is much smaller +than the object itself, this results in memory savings and a potential boost in +execution speed for programs which rely on copies (such as an undo-stack). + + + +```js +const { Map } = require('immutable'); +const map = Map({ a: 1, b: 2, c: 3 }); +const mapCopy = map; // Look, "copies" are free! +``` + +[React]: https://reactjs.org/ +[Flux]: https://facebook.github.io/flux/docs/in-depth-overview/ + + +## JavaScript-first API + +While Immutable.js is inspired by Clojure, Scala, Haskell and other functional +programming environments, it's designed to bring these powerful concepts to +JavaScript, and therefore has an Object-Oriented API that closely mirrors that +of [ES2015][] [Array][], [Map][], and [Set][]. + +[es2015]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/ECMAScript_6_support_in_Mozilla +[array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array +[map]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map +[set]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set + +The difference for the immutable collections is that methods which would mutate +the collection, like `push`, `set`, `unshift` or `splice`, instead return a new +immutable collection. Methods which return new arrays, like `slice` or `concat`, +instead return new immutable collections. + + + +```js +const { List } = require('immutable'); +const list1 = List([1, 2]); +const list2 = list1.push(3, 4, 5); +const list3 = list2.unshift(0); +const list4 = list1.concat(list2, list3); +assert.equal(list1.size, 2); +assert.equal(list2.size, 5); +assert.equal(list3.size, 6); +assert.equal(list4.size, 13); +assert.equal(list4.get(0), 1); +``` + +Almost all of the methods on [Array][] will be found in similar form on +`Immutable.List`, those of [Map][] found on `Immutable.Map`, and those of [Set][] +found on `Immutable.Set`, including collection operations like `forEach()` +and `map()`. + + + +```js +const { Map } = require('immutable'); +const alpha = Map({ a: 1, b: 2, c: 3, d: 4 }); +alpha.map((v, k) => k.toUpperCase()).join(); +// 'A,B,C,D' +``` + +### Convert from raw JavaScript objects and arrays. + +Designed to inter-operate with your existing JavaScript, Immutable.js +accepts plain JavaScript Arrays and Objects anywhere a method expects a +`Collection`. + + + +```js +const { Map, List } = require('immutable'); +const map1 = Map({ a: 1, b: 2, c: 3, d: 4 }); +const map2 = Map({ c: 10, a: 20, t: 30 }); +const obj = { d: 100, o: 200, g: 300 }; +const map3 = map1.merge(map2, obj); +// Map { a: 20, b: 2, c: 10, d: 100, t: 30, o: 200, g: 300 } +const list1 = List([1, 2, 3]); +const list2 = List([4, 5, 6]); +const array = [7, 8, 9]; +const list3 = list1.concat(list2, array); +// List [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ] +``` + +This is possible because Immutable.js can treat any JavaScript Array or Object +as a Collection. You can take advantage of this in order to get sophisticated +collection methods on JavaScript Objects, which otherwise have a very sparse +native API. Because Seq evaluates lazily and does not cache intermediate +results, these operations can be extremely efficient. + + + +```js +const { Seq } = require('immutable'); +const myObject = { a: 1, b: 2, c: 3 }; +Seq(myObject) + .map(x => x * x) + .toObject(); +// { a: 1, b: 4, c: 9 } +``` + +Keep in mind, when using JS objects to construct Immutable Maps, that +JavaScript Object properties are always strings, even if written in a quote-less +shorthand, while Immutable Maps accept keys of any type. + + + +```js +const { fromJS } = require('immutable'); + +const obj = { 1: 'one' }; +console.log(Object.keys(obj)); // [ "1" ] +console.log(obj['1'], obj[1]); // "one", "one" + +const map = fromJS(obj); +console.log(map.get('1'), map.get(1)); // "one", undefined +``` + +Property access for JavaScript Objects first converts the key to a string, but +since Immutable Map keys can be of any type the argument to `get()` is +not altered. + +### Converts back to raw JavaScript objects. + +All Immutable.js Collections can be converted to plain JavaScript Arrays and +Objects shallowly with `toArray()` and `toObject()` or deeply with `toJS()`. +All Immutable Collections also implement `toJSON()` allowing them to be passed +to `JSON.stringify` directly. They also respect the custom `toJSON()` methods of +nested objects. + + + +```js +const { Map, List } = require('immutable'); +const deep = Map({ a: 1, b: 2, c: List([3, 4, 5]) }); +console.log(deep.toObject()); // { a: 1, b: 2, c: List [ 3, 4, 5 ] } +console.log(deep.toArray()); // [ 1, 2, List [ 3, 4, 5 ] ] +console.log(deep.toJS()); // { a: 1, b: 2, c: [ 3, 4, 5 ] } +JSON.stringify(deep); // '{"a":1,"b":2,"c":[3,4,5]}' +``` + +### Embraces ES2015 + +Immutable.js supports all JavaScript environments, including legacy +browsers (even IE11). However it also takes advantage of features added to +JavaScript in [ES2015][], the latest standard version of JavaScript, including +[Iterators][], [Arrow Functions][], [Classes][], and [Modules][]. It's inspired +by the native [Map][] and [Set][] collections added to ES2015. + +All examples in the Documentation are presented in ES2015. To run in all +browsers, they need to be translated to ES5. + +```js +// ES2015 +const mapped = foo.map(x => x * x); +// ES5 +var mapped = foo.map(function (x) { + return x * x; +}); +``` + +All Immutable.js collections are [Iterable][iterators], which allows them to be +used anywhere an Iterable is expected, such as when spreading into an Array. + + + +```js +const { List } = require('immutable'); +const aList = List([1, 2, 3]); +const anArray = [0, ...aList, 4, 5]; // [ 0, 1, 2, 3, 4, 5 ] +``` + +Note: A Collection is always iterated in the same order, however that order may +not always be well defined, as is the case for the `Map` and `Set`. + +[Iterators]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/The_Iterator_protocol +[Arrow Functions]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions +[Classes]: https://wiki.ecmascript.org/doku.php?id=strawman:maximally_minimal_classes +[Modules]: https://www.2ality.com/2014/09/es6-modules-final.html + + +## Nested Structures + +The collections in Immutable.js are intended to be nested, allowing for deep +trees of data, similar to JSON. + + + +```js +const { fromJS } = require('immutable'); +const nested = fromJS({ a: { b: { c: [3, 4, 5] } } }); +// Map { a: Map { b: Map { c: List [ 3, 4, 5 ] } } } +``` + +A few power-tools allow for reading and operating on nested data. The +most useful are `mergeDeep`, `getIn`, `setIn`, and `updateIn`, found on `List`, +`Map` and `OrderedMap`. + + + +```js +const { fromJS } = require('immutable'); +const nested = fromJS({ a: { b: { c: [3, 4, 5] } } }); + +const nested2 = nested.mergeDeep({ a: { b: { d: 6 } } }); +// Map { a: Map { b: Map { c: List [ 3, 4, 5 ], d: 6 } } } + +console.log(nested2.getIn(['a', 'b', 'd'])); // 6 + +const nested3 = nested2.updateIn(['a', 'b', 'd'], value => value + 1); +console.log(nested3); +// Map { a: Map { b: Map { c: List [ 3, 4, 5 ], d: 7 } } } + +const nested4 = nested3.updateIn(['a', 'b', 'c'], list => list.push(6)); +// Map { a: Map { b: Map { c: List [ 3, 4, 5, 6 ], d: 7 } } } +``` + +## Equality treats Collections as Values + +Immutable.js collections are treated as pure data _values_. Two immutable +collections are considered _value equal_ (via `.equals()` or `is()`) if they +represent the same collection of values. This differs from JavaScript's typical +_reference equal_ (via `===` or `==`) for Objects and Arrays which only +determines if two variables represent references to the same object instance. + +Consider the example below where two identical `Map` instances are not +_reference equal_ but are _value equal_. + + + +```js +// First consider: +const obj1 = { a: 1, b: 2, c: 3 }; +const obj2 = { a: 1, b: 2, c: 3 }; +obj1 !== obj2; // two different instances are always not equal with === + +const { Map, is } = require('immutable'); +const map1 = Map({ a: 1, b: 2, c: 3 }); +const map2 = Map({ a: 1, b: 2, c: 3 }); +map1 !== map2; // two different instances are not reference-equal +map1.equals(map2); // but are value-equal if they have the same values +is(map1, map2); // alternatively can use the is() function +``` + +Value equality allows Immutable.js collections to be used as keys in Maps or +values in Sets, and retrieved with different but equivalent collections: + + + +```js +const { Map, Set } = require('immutable'); +const map1 = Map({ a: 1, b: 2, c: 3 }); +const map2 = Map({ a: 1, b: 2, c: 3 }); +const set = Set().add(map1); +set.has(map2); // true because these are value-equal +``` + +Note: `is()` uses the same measure of equality as [Object.is][] for scalar +strings and numbers, but uses value equality for Immutable collections, +determining if both are immutable and all keys and values are equal +using the same measure of equality. + +[object.is]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is + +#### Performance tradeoffs + +While value equality is useful in many circumstances, it has different +performance characteristics than reference equality. Understanding these +tradeoffs may help you decide which to use in each case, especially when used +to memoize some operation. + +When comparing two collections, value equality may require considering every +item in each collection, on an `O(N)` time complexity. For large collections of +values, this could become a costly operation. Though if the two are not equal +and hardly similar, the inequality is determined very quickly. In contrast, when +comparing two collections with reference equality, only the initial references +to memory need to be compared which is not based on the size of the collections, +which has an `O(1)` time complexity. Checking reference equality is always very +fast, however just because two collections are not reference-equal does not rule +out the possibility that they may be value-equal. + +#### Return self on no-op optimization + +When possible, Immutable.js avoids creating new objects for updates where no +change in _value_ occurred, to allow for efficient _reference equality_ checking +to quickly determine if no change occurred. + + + +```js +const { Map } = require('immutable'); +const originalMap = Map({ a: 1, b: 2, c: 3 }); +const updatedMap = originalMap.set('b', 2); +updatedMap === originalMap; // No-op .set() returned the original reference. +``` + +However updates which do result in a change will return a new reference. Each +of these operations occur independently, so two similar updates will not return +the same reference: + + + +```js +const { Map } = require('immutable'); +const originalMap = Map({ a: 1, b: 2, c: 3 }); +const updatedMap = originalMap.set('b', 1000); +// New instance, leaving the original immutable. +updatedMap !== originalMap; +const anotherUpdatedMap = originalMap.set('b', 1000); +// Despite both the results of the same operation, each created a new reference. +anotherUpdatedMap !== updatedMap; +// However the two are value equal. +anotherUpdatedMap.equals(updatedMap); +``` + +## Batching Mutations + +> If a tree falls in the woods, does it make a sound? +> +> If a pure function mutates some local data in order to produce an immutable +> return value, is that ok? +> +> — Rich Hickey, Clojure + +Applying a mutation to create a new immutable object results in some overhead, +which can add up to a minor performance penalty. If you need to apply a series +of mutations locally before returning, Immutable.js gives you the ability to +create a temporary mutable (transient) copy of a collection and apply a batch of +mutations in a performant manner by using `withMutations`. In fact, this is +exactly how Immutable.js applies complex mutations itself. + +As an example, building `list2` results in the creation of 1, not 3, new +immutable Lists. + + + +```js +const { List } = require('immutable'); +const list1 = List([1, 2, 3]); +const list2 = list1.withMutations(function (list) { + list.push(4).push(5).push(6); +}); +assert.equal(list1.size, 3); +assert.equal(list2.size, 6); +``` + +Note: Immutable.js also provides `asMutable` and `asImmutable`, but only +encourages their use when `withMutations` will not suffice. Use caution to not +return a mutable copy, which could result in undesired behavior. + +_Important!_: Only a select few methods can be used in `withMutations` including +`set`, `push` and `pop`. These methods can be applied directly against a +persistent data-structure where other methods like `map`, `filter`, `sort`, +and `splice` will always return new immutable data-structures and never mutate +a mutable collection. + +## Lazy Seq + +`Seq` describes a lazy operation, allowing them to efficiently chain +use of all the higher-order collection methods (such as `map` and `filter`) +by not creating intermediate collections. + +**Seq is immutable** — Once a Seq is created, it cannot be +changed, appended to, rearranged or otherwise modified. Instead, any mutative +method called on a `Seq` will return a new `Seq`. + +**Seq is lazy** — `Seq` does as little work as necessary to respond to any +method call. Values are often created during iteration, including implicit +iteration when reducing or converting to a concrete data structure such as +a `List` or JavaScript `Array`. + +For example, the following performs no work, because the resulting +`Seq`'s values are never iterated: + +```js +const { Seq } = require('immutable'); +const oddSquares = Seq([1, 2, 3, 4, 5, 6, 7, 8]) + .filter(x => x % 2 !== 0) + .map(x => x * x); +``` + +Once the `Seq` is used, it performs only the work necessary. In this +example, no intermediate arrays are ever created, filter is called three +times, and map is only called once: + +```js +oddSquares.get(1); // 9 +``` + +Any collection can be converted to a lazy Seq with `Seq()`. + + + +```js +const { Map, Seq } = require('immutable'); +const map = Map({ a: 1, b: 2, c: 3 }); +const lazySeq = Seq(map); +``` + +`Seq` allows for the efficient chaining of operations, allowing for the +expression of logic that can otherwise be very tedious: + +```js +lazySeq + .flip() + .map(key => key.toUpperCase()) + .flip(); +// Seq { A: 1, B: 2, C: 3 } +``` + +As well as expressing logic that would otherwise seem memory or time +limited, for example `Range` is a special kind of Lazy sequence. + + + +```js +const { Range } = require('immutable'); +Range(1, Infinity) + .skip(1000) + .map(n => -n) + .filter(n => n % 2 === 0) + .take(2) + .reduce((r, n) => r * n, 1); +// 1006008 +``` + +## Comparison of filter(), groupBy(), and partition() + +The `filter()`, `groupBy()`, and `partition()` methods are similar in that they +all divide a collection into parts based on applying a function to each element. +All three call the predicate or grouping function once for each item in the +input collection. All three return zero or more collections of the same type as +their input. The returned collections are always distinct from the input +(according to `===`), even if the contents are identical. + +Of these methods, `filter()` is the only one that is lazy and the only one which +discards items from the input collection. It is the simplest to use, and the +fact that it returns exactly one collection makes it easy to combine with other +methods to form a pipeline of operations. + +The `partition()` method is similar to an eager version of `filter()`, but it +returns two collections; the first contains the items that would have been +discarded by `filter()`, and the second contains the items that would have been +kept. It always returns an array of exactly two collections, which can make it +easier to use than `groupBy()`. Compared to making two separate calls to +`filter()`, `partition()` makes half as many calls it the predicate passed to +it. + +The `groupBy()` method is a more generalized version of `partition()` that can +group by an arbitrary function rather than just a predicate. It returns a map +with zero or more entries, where the keys are the values returned by the +grouping function, and the values are nonempty collections of the corresponding +arguments. Although `groupBy()` is more powerful than `partition()`, it can be +harder to use because it is not always possible predict in advance how many +entries the returned map will have and what their keys will be. + +| Summary | `filter` | `partition` | `groupBy` | +|:------------------------------|:---------|:------------|:---------------| +| ease of use | easiest | moderate | hardest | +| generality | least | moderate | most | +| laziness | lazy | eager | eager | +| # of returned sub-collections | 1 | 2 | 0 or more | +| sub-collections may be empty | yes | yes | no | +| can discard items | yes | no | no | +| wrapping container | none | array | Map/OrderedMap | + +## Additional Tools and Resources + +- [Atom-store](https://github.com/jameshopkins/atom-store/) + - A Clojure-inspired atom implementation in Javascript with configurability + for external persistance. + +- [Chai Immutable](https://github.com/astorije/chai-immutable) + - If you are using the [Chai Assertion Library](https://chaijs.com/), this + provides a set of assertions to use against Immutable.js collections. + +- [Fantasy-land](https://github.com/fantasyland/fantasy-land) + - Specification for interoperability of common algebraic structures in JavaScript. + +- [Immutagen](https://github.com/pelotom/immutagen) + - A library for simulating immutable generators in JavaScript. + +- [Immutable-cursor](https://github.com/redbadger/immutable-cursor) + - Immutable cursors incorporating the Immutable.js interface over + Clojure-inspired atom. + +- [Immutable-ext](https://github.com/DrBoolean/immutable-ext) + - Fantasyland extensions for immutablejs + +- [Immutable-js-tools](https://github.com/madeinfree/immutable-js-tools) + - Util tools for immutable.js + +- [Immutable-Redux](https://github.com/gajus/redux-immutable) + - redux-immutable is used to create an equivalent function of Redux + combineReducers that works with Immutable.js state. + +- [Immutable-Treeutils](https://github.com/lukasbuenger/immutable-treeutils) + - Functional tree traversal helpers for ImmutableJS data structures. + +- [Irecord](https://github.com/ericelliott/irecord) + - An immutable store that exposes an RxJS observable. Great for React. + +- [Mudash](https://github.com/brianneisler/mudash) + - Lodash wrapper providing Immutable.JS support. + +- [React-Immutable-PropTypes](https://github.com/HurricaneJames/react-immutable-proptypes) + - PropType validators that work with Immutable.js. + +- [Redux-Immutablejs](https://github.com/indexiatech/redux-immutablejs) + - Redux Immutable facilities. + +- [Rxstate](https://github.com/yamalight/rxstate) + - Simple opinionated state management library based on RxJS and Immutable.js. + +- [Transit-Immutable-js](https://github.com/glenjamin/transit-immutable-js) + - Transit serialisation for Immutable.js. + - See also: [Transit-js](https://github.com/cognitect/transit-js) + +Have an additional tool designed to work with Immutable.js? +Submit a PR to add it to this list in alphabetical order. + +## Contributing + +Use [Github issues](https://github.com/immutable-js/immutable-js/issues) for requests. + +We actively welcome pull requests, learn how to [contribute](https://github.com/immutable-js/immutable-js/blob/main/.github/CONTRIBUTING.md). + +Immutable.js is maintained within the [Contributor Covenant's Code of Conduct](https://www.contributor-covenant.org/version/2/0/code_of_conduct/). + +### Changelog + +Changes are tracked as [Github releases](https://github.com/immutable-js/immutable-js/releases). + +### License + +Immutable.js is [MIT-licensed](./LICENSE). + +### Thanks + +[Phil Bagwell](https://www.youtube.com/watch?v=K2NYwP90bNs), for his inspiration +and research in persistent data structures. + +[Hugh Jackson](https://github.com/hughfdjackson/), for providing the npm package +name. If you're looking for his unsupported package, see [this repository](https://github.com/hughfdjackson/immutable). diff --git a/node_modules/immutable/package.json b/node_modules/immutable/package.json new file mode 100644 index 00000000..de54a3d1 --- /dev/null +++ b/node_modules/immutable/package.json @@ -0,0 +1,39 @@ +{ + "name": "immutable", + "version": "4.3.4", + "description": "Immutable Data Collections", + "license": "MIT", + "homepage": "https://immutable-js.com", + "author": { + "name": "Lee Byron", + "url": "https://github.com/leebyron" + }, + "repository": { + "type": "git", + "url": "git://github.com/immutable-js/immutable-js.git" + }, + "bugs": { + "url": "https://github.com/immutable-js/immutable-js/issues" + }, + "main": "dist/immutable.js", + "module": "dist/immutable.es.js", + "sideEffects": false, + "types": "dist/immutable.d.ts", + "files": [ + "dist", + "README.md", + "LICENSE" + ], + "keywords": [ + "immutable", + "persistent", + "lazy", + "data", + "datastructure", + "functional", + "collection", + "stateless", + "sequence", + "iteration" + ] +} \ No newline at end of file diff --git a/node_modules/is-binary-path/index.d.ts b/node_modules/is-binary-path/index.d.ts new file mode 100644 index 00000000..19dcd432 --- /dev/null +++ b/node_modules/is-binary-path/index.d.ts @@ -0,0 +1,17 @@ +/** +Check if a file path is a binary file. + +@example +``` +import isBinaryPath = require('is-binary-path'); + +isBinaryPath('source/unicorn.png'); +//=> true + +isBinaryPath('source/unicorn.txt'); +//=> false +``` +*/ +declare function isBinaryPath(filePath: string): boolean; + +export = isBinaryPath; diff --git a/node_modules/is-binary-path/index.js b/node_modules/is-binary-path/index.js new file mode 100644 index 00000000..ef7548c8 --- /dev/null +++ b/node_modules/is-binary-path/index.js @@ -0,0 +1,7 @@ +'use strict'; +const path = require('path'); +const binaryExtensions = require('binary-extensions'); + +const extensions = new Set(binaryExtensions); + +module.exports = filePath => extensions.has(path.extname(filePath).slice(1).toLowerCase()); diff --git a/node_modules/is-binary-path/license b/node_modules/is-binary-path/license new file mode 100644 index 00000000..401b1c73 --- /dev/null +++ b/node_modules/is-binary-path/license @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2019 Sindre Sorhus (https://sindresorhus.com), Paul Miller (https://paulmillr.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/is-binary-path/package.json b/node_modules/is-binary-path/package.json new file mode 100644 index 00000000..a8d005ae --- /dev/null +++ b/node_modules/is-binary-path/package.json @@ -0,0 +1,40 @@ +{ + "name": "is-binary-path", + "version": "2.1.0", + "description": "Check if a file path is a binary file", + "license": "MIT", + "repository": "sindresorhus/is-binary-path", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "engines": { + "node": ">=8" + }, + "scripts": { + "test": "xo && ava && tsd" + }, + "files": [ + "index.js", + "index.d.ts" + ], + "keywords": [ + "binary", + "extensions", + "extension", + "file", + "path", + "check", + "detect", + "is" + ], + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "devDependencies": { + "ava": "^1.4.1", + "tsd": "^0.7.2", + "xo": "^0.24.0" + } +} diff --git a/node_modules/is-binary-path/readme.md b/node_modules/is-binary-path/readme.md new file mode 100644 index 00000000..b4ab0251 --- /dev/null +++ b/node_modules/is-binary-path/readme.md @@ -0,0 +1,34 @@ +# is-binary-path [![Build Status](https://travis-ci.org/sindresorhus/is-binary-path.svg?branch=master)](https://travis-ci.org/sindresorhus/is-binary-path) + +> Check if a file path is a binary file + + +## Install + +``` +$ npm install is-binary-path +``` + + +## Usage + +```js +const isBinaryPath = require('is-binary-path'); + +isBinaryPath('source/unicorn.png'); +//=> true + +isBinaryPath('source/unicorn.txt'); +//=> false +``` + + +## Related + +- [binary-extensions](https://github.com/sindresorhus/binary-extensions) - List of binary file extensions +- [is-text-path](https://github.com/sindresorhus/is-text-path) - Check if a filepath is a text file + + +## License + +MIT © [Sindre Sorhus](https://sindresorhus.com), [Paul Miller](https://paulmillr.com) diff --git a/node_modules/is-extglob/LICENSE b/node_modules/is-extglob/LICENSE new file mode 100644 index 00000000..842218cf --- /dev/null +++ b/node_modules/is-extglob/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014-2016, Jon Schlinkert + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/is-extglob/README.md b/node_modules/is-extglob/README.md new file mode 100644 index 00000000..0416af5c --- /dev/null +++ b/node_modules/is-extglob/README.md @@ -0,0 +1,107 @@ +# is-extglob [![NPM version](https://img.shields.io/npm/v/is-extglob.svg?style=flat)](https://www.npmjs.com/package/is-extglob) [![NPM downloads](https://img.shields.io/npm/dm/is-extglob.svg?style=flat)](https://npmjs.org/package/is-extglob) [![Build Status](https://img.shields.io/travis/jonschlinkert/is-extglob.svg?style=flat)](https://travis-ci.org/jonschlinkert/is-extglob) + +> Returns true if a string has an extglob. + +## Install + +Install with [npm](https://www.npmjs.com/): + +```sh +$ npm install --save is-extglob +``` + +## Usage + +```js +var isExtglob = require('is-extglob'); +``` + +**True** + +```js +isExtglob('?(abc)'); +isExtglob('@(abc)'); +isExtglob('!(abc)'); +isExtglob('*(abc)'); +isExtglob('+(abc)'); +``` + +**False** + +Escaped extglobs: + +```js +isExtglob('\\?(abc)'); +isExtglob('\\@(abc)'); +isExtglob('\\!(abc)'); +isExtglob('\\*(abc)'); +isExtglob('\\+(abc)'); +``` + +Everything else... + +```js +isExtglob('foo.js'); +isExtglob('!foo.js'); +isExtglob('*.js'); +isExtglob('**/abc.js'); +isExtglob('abc/*.js'); +isExtglob('abc/(aaa|bbb).js'); +isExtglob('abc/[a-z].js'); +isExtglob('abc/{a,b}.js'); +isExtglob('abc/?.js'); +isExtglob('abc.js'); +isExtglob('abc/def/ghi.js'); +``` + +## History + +**v2.0** + +Adds support for escaping. Escaped exglobs no longer return true. + +## About + +### Related projects + +* [has-glob](https://www.npmjs.com/package/has-glob): Returns `true` if an array has a glob pattern. | [homepage](https://github.com/jonschlinkert/has-glob "Returns `true` if an array has a glob pattern.") +* [is-glob](https://www.npmjs.com/package/is-glob): Returns `true` if the given string looks like a glob pattern or an extglob pattern… [more](https://github.com/jonschlinkert/is-glob) | [homepage](https://github.com/jonschlinkert/is-glob "Returns `true` if the given string looks like a glob pattern or an extglob pattern. This makes it easy to create code that only uses external modules like node-glob when necessary, resulting in much faster code execution and initialization time, and a bet") +* [micromatch](https://www.npmjs.com/package/micromatch): Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. | [homepage](https://github.com/jonschlinkert/micromatch "Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch.") + +### Contributing + +Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). + +### Building docs + +_(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_ + +To generate the readme and API documentation with [verb](https://github.com/verbose/verb): + +```sh +$ npm install -g verb verb-generate-readme && verb +``` + +### Running tests + +Install dev dependencies: + +```sh +$ npm install -d && npm test +``` + +### Author + +**Jon Schlinkert** + +* [github/jonschlinkert](https://github.com/jonschlinkert) +* [twitter/jonschlinkert](http://twitter.com/jonschlinkert) + +### License + +Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert). +Released under the [MIT license](https://github.com/jonschlinkert/is-extglob/blob/master/LICENSE). + +*** + +_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.1.31, on October 12, 2016._ \ No newline at end of file diff --git a/node_modules/is-extglob/index.js b/node_modules/is-extglob/index.js new file mode 100644 index 00000000..c1d986fc --- /dev/null +++ b/node_modules/is-extglob/index.js @@ -0,0 +1,20 @@ +/*! + * is-extglob + * + * Copyright (c) 2014-2016, Jon Schlinkert. + * Licensed under the MIT License. + */ + +module.exports = function isExtglob(str) { + if (typeof str !== 'string' || str === '') { + return false; + } + + var match; + while ((match = /(\\).|([@?!+*]\(.*\))/g.exec(str))) { + if (match[2]) return true; + str = str.slice(match.index + match[0].length); + } + + return false; +}; diff --git a/node_modules/is-extglob/package.json b/node_modules/is-extglob/package.json new file mode 100644 index 00000000..7a908369 --- /dev/null +++ b/node_modules/is-extglob/package.json @@ -0,0 +1,69 @@ +{ + "name": "is-extglob", + "description": "Returns true if a string has an extglob.", + "version": "2.1.1", + "homepage": "https://github.com/jonschlinkert/is-extglob", + "author": "Jon Schlinkert (https://github.com/jonschlinkert)", + "repository": "jonschlinkert/is-extglob", + "bugs": { + "url": "https://github.com/jonschlinkert/is-extglob/issues" + }, + "license": "MIT", + "files": [ + "index.js" + ], + "main": "index.js", + "engines": { + "node": ">=0.10.0" + }, + "scripts": { + "test": "mocha" + }, + "devDependencies": { + "gulp-format-md": "^0.1.10", + "mocha": "^3.0.2" + }, + "keywords": [ + "bash", + "braces", + "check", + "exec", + "expression", + "extglob", + "glob", + "globbing", + "globstar", + "is", + "match", + "matches", + "pattern", + "regex", + "regular", + "string", + "test" + ], + "verb": { + "toc": false, + "layout": "default", + "tasks": [ + "readme" + ], + "plugins": [ + "gulp-format-md" + ], + "related": { + "list": [ + "has-glob", + "is-glob", + "micromatch" + ] + }, + "reflinks": [ + "verb", + "verb-generate-readme" + ], + "lint": { + "reflinks": true + } + } +} diff --git a/node_modules/is-glob/LICENSE b/node_modules/is-glob/LICENSE new file mode 100644 index 00000000..3f2eca18 --- /dev/null +++ b/node_modules/is-glob/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014-2017, Jon Schlinkert. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/is-glob/README.md b/node_modules/is-glob/README.md new file mode 100644 index 00000000..740724b2 --- /dev/null +++ b/node_modules/is-glob/README.md @@ -0,0 +1,206 @@ +# is-glob [![NPM version](https://img.shields.io/npm/v/is-glob.svg?style=flat)](https://www.npmjs.com/package/is-glob) [![NPM monthly downloads](https://img.shields.io/npm/dm/is-glob.svg?style=flat)](https://npmjs.org/package/is-glob) [![NPM total downloads](https://img.shields.io/npm/dt/is-glob.svg?style=flat)](https://npmjs.org/package/is-glob) [![Build Status](https://img.shields.io/github/workflow/status/micromatch/is-glob/dev)](https://github.com/micromatch/is-glob/actions) + +> Returns `true` if the given string looks like a glob pattern or an extglob pattern. This makes it easy to create code that only uses external modules like node-glob when necessary, resulting in much faster code execution and initialization time, and a better user experience. + +Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support. + +## Install + +Install with [npm](https://www.npmjs.com/): + +```sh +$ npm install --save is-glob +``` + +You might also be interested in [is-valid-glob](https://github.com/jonschlinkert/is-valid-glob) and [has-glob](https://github.com/jonschlinkert/has-glob). + +## Usage + +```js +var isGlob = require('is-glob'); +``` + +### Default behavior + +**True** + +Patterns that have glob characters or regex patterns will return `true`: + +```js +isGlob('!foo.js'); +isGlob('*.js'); +isGlob('**/abc.js'); +isGlob('abc/*.js'); +isGlob('abc/(aaa|bbb).js'); +isGlob('abc/[a-z].js'); +isGlob('abc/{a,b}.js'); +//=> true +``` + +Extglobs + +```js +isGlob('abc/@(a).js'); +isGlob('abc/!(a).js'); +isGlob('abc/+(a).js'); +isGlob('abc/*(a).js'); +isGlob('abc/?(a).js'); +//=> true +``` + +**False** + +Escaped globs or extglobs return `false`: + +```js +isGlob('abc/\\@(a).js'); +isGlob('abc/\\!(a).js'); +isGlob('abc/\\+(a).js'); +isGlob('abc/\\*(a).js'); +isGlob('abc/\\?(a).js'); +isGlob('\\!foo.js'); +isGlob('\\*.js'); +isGlob('\\*\\*/abc.js'); +isGlob('abc/\\*.js'); +isGlob('abc/\\(aaa|bbb).js'); +isGlob('abc/\\[a-z].js'); +isGlob('abc/\\{a,b}.js'); +//=> false +``` + +Patterns that do not have glob patterns return `false`: + +```js +isGlob('abc.js'); +isGlob('abc/def/ghi.js'); +isGlob('foo.js'); +isGlob('abc/@.js'); +isGlob('abc/+.js'); +isGlob('abc/?.js'); +isGlob(); +isGlob(null); +//=> false +``` + +Arrays are also `false` (If you want to check if an array has a glob pattern, use [has-glob](https://github.com/jonschlinkert/has-glob)): + +```js +isGlob(['**/*.js']); +isGlob(['foo.js']); +//=> false +``` + +### Option strict + +When `options.strict === false` the behavior is less strict in determining if a pattern is a glob. Meaning that +some patterns that would return `false` may return `true`. This is done so that matching libraries like [micromatch](https://github.com/micromatch/micromatch) have a chance at determining if the pattern is a glob or not. + +**True** + +Patterns that have glob characters or regex patterns will return `true`: + +```js +isGlob('!foo.js', {strict: false}); +isGlob('*.js', {strict: false}); +isGlob('**/abc.js', {strict: false}); +isGlob('abc/*.js', {strict: false}); +isGlob('abc/(aaa|bbb).js', {strict: false}); +isGlob('abc/[a-z].js', {strict: false}); +isGlob('abc/{a,b}.js', {strict: false}); +//=> true +``` + +Extglobs + +```js +isGlob('abc/@(a).js', {strict: false}); +isGlob('abc/!(a).js', {strict: false}); +isGlob('abc/+(a).js', {strict: false}); +isGlob('abc/*(a).js', {strict: false}); +isGlob('abc/?(a).js', {strict: false}); +//=> true +``` + +**False** + +Escaped globs or extglobs return `false`: + +```js +isGlob('\\!foo.js', {strict: false}); +isGlob('\\*.js', {strict: false}); +isGlob('\\*\\*/abc.js', {strict: false}); +isGlob('abc/\\*.js', {strict: false}); +isGlob('abc/\\(aaa|bbb).js', {strict: false}); +isGlob('abc/\\[a-z].js', {strict: false}); +isGlob('abc/\\{a,b}.js', {strict: false}); +//=> false +``` + +## About + +
+Contributing + +Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). + +
+ +
+Running Tests + +Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command: + +```sh +$ npm install && npm test +``` + +
+ +
+Building docs + +_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_ + +To generate the readme, run the following command: + +```sh +$ npm install -g verbose/verb#dev verb-generate-readme && verb +``` + +
+ +### Related projects + +You might also be interested in these projects: + +* [assemble](https://www.npmjs.com/package/assemble): Get the rocks out of your socks! Assemble makes you fast at creating web projects… [more](https://github.com/assemble/assemble) | [homepage](https://github.com/assemble/assemble "Get the rocks out of your socks! Assemble makes you fast at creating web projects. Assemble is used by thousands of projects for rapid prototyping, creating themes, scaffolds, boilerplates, e-books, UI components, API documentation, blogs, building websit") +* [base](https://www.npmjs.com/package/base): Framework for rapidly creating high quality, server-side node.js applications, using plugins like building blocks | [homepage](https://github.com/node-base/base "Framework for rapidly creating high quality, server-side node.js applications, using plugins like building blocks") +* [update](https://www.npmjs.com/package/update): Be scalable! Update is a new, open source developer framework and CLI for automating updates… [more](https://github.com/update/update) | [homepage](https://github.com/update/update "Be scalable! Update is a new, open source developer framework and CLI for automating updates of any kind in code projects.") +* [verb](https://www.npmjs.com/package/verb): Documentation generator for GitHub projects. Verb is extremely powerful, easy to use, and is used… [more](https://github.com/verbose/verb) | [homepage](https://github.com/verbose/verb "Documentation generator for GitHub projects. Verb is extremely powerful, easy to use, and is used on hundreds of projects of all sizes to generate everything from API docs to readmes.") + +### Contributors + +| **Commits** | **Contributor** | +| --- | --- | +| 47 | [jonschlinkert](https://github.com/jonschlinkert) | +| 5 | [doowb](https://github.com/doowb) | +| 1 | [phated](https://github.com/phated) | +| 1 | [danhper](https://github.com/danhper) | +| 1 | [paulmillr](https://github.com/paulmillr) | + +### Author + +**Jon Schlinkert** + +* [GitHub Profile](https://github.com/jonschlinkert) +* [Twitter Profile](https://twitter.com/jonschlinkert) +* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert) + +### License + +Copyright © 2019, [Jon Schlinkert](https://github.com/jonschlinkert). +Released under the [MIT License](LICENSE). + +*** + +_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on March 27, 2019._ \ No newline at end of file diff --git a/node_modules/is-glob/index.js b/node_modules/is-glob/index.js new file mode 100644 index 00000000..620f563e --- /dev/null +++ b/node_modules/is-glob/index.js @@ -0,0 +1,150 @@ +/*! + * is-glob + * + * Copyright (c) 2014-2017, Jon Schlinkert. + * Released under the MIT License. + */ + +var isExtglob = require('is-extglob'); +var chars = { '{': '}', '(': ')', '[': ']'}; +var strictCheck = function(str) { + if (str[0] === '!') { + return true; + } + var index = 0; + var pipeIndex = -2; + var closeSquareIndex = -2; + var closeCurlyIndex = -2; + var closeParenIndex = -2; + var backSlashIndex = -2; + while (index < str.length) { + if (str[index] === '*') { + return true; + } + + if (str[index + 1] === '?' && /[\].+)]/.test(str[index])) { + return true; + } + + if (closeSquareIndex !== -1 && str[index] === '[' && str[index + 1] !== ']') { + if (closeSquareIndex < index) { + closeSquareIndex = str.indexOf(']', index); + } + if (closeSquareIndex > index) { + if (backSlashIndex === -1 || backSlashIndex > closeSquareIndex) { + return true; + } + backSlashIndex = str.indexOf('\\', index); + if (backSlashIndex === -1 || backSlashIndex > closeSquareIndex) { + return true; + } + } + } + + if (closeCurlyIndex !== -1 && str[index] === '{' && str[index + 1] !== '}') { + closeCurlyIndex = str.indexOf('}', index); + if (closeCurlyIndex > index) { + backSlashIndex = str.indexOf('\\', index); + if (backSlashIndex === -1 || backSlashIndex > closeCurlyIndex) { + return true; + } + } + } + + if (closeParenIndex !== -1 && str[index] === '(' && str[index + 1] === '?' && /[:!=]/.test(str[index + 2]) && str[index + 3] !== ')') { + closeParenIndex = str.indexOf(')', index); + if (closeParenIndex > index) { + backSlashIndex = str.indexOf('\\', index); + if (backSlashIndex === -1 || backSlashIndex > closeParenIndex) { + return true; + } + } + } + + if (pipeIndex !== -1 && str[index] === '(' && str[index + 1] !== '|') { + if (pipeIndex < index) { + pipeIndex = str.indexOf('|', index); + } + if (pipeIndex !== -1 && str[pipeIndex + 1] !== ')') { + closeParenIndex = str.indexOf(')', pipeIndex); + if (closeParenIndex > pipeIndex) { + backSlashIndex = str.indexOf('\\', pipeIndex); + if (backSlashIndex === -1 || backSlashIndex > closeParenIndex) { + return true; + } + } + } + } + + if (str[index] === '\\') { + var open = str[index + 1]; + index += 2; + var close = chars[open]; + + if (close) { + var n = str.indexOf(close, index); + if (n !== -1) { + index = n + 1; + } + } + + if (str[index] === '!') { + return true; + } + } else { + index++; + } + } + return false; +}; + +var relaxedCheck = function(str) { + if (str[0] === '!') { + return true; + } + var index = 0; + while (index < str.length) { + if (/[*?{}()[\]]/.test(str[index])) { + return true; + } + + if (str[index] === '\\') { + var open = str[index + 1]; + index += 2; + var close = chars[open]; + + if (close) { + var n = str.indexOf(close, index); + if (n !== -1) { + index = n + 1; + } + } + + if (str[index] === '!') { + return true; + } + } else { + index++; + } + } + return false; +}; + +module.exports = function isGlob(str, options) { + if (typeof str !== 'string' || str === '') { + return false; + } + + if (isExtglob(str)) { + return true; + } + + var check = strictCheck; + + // optionally relax check + if (options && options.strict === false) { + check = relaxedCheck; + } + + return check(str); +}; diff --git a/node_modules/is-glob/package.json b/node_modules/is-glob/package.json new file mode 100644 index 00000000..858af037 --- /dev/null +++ b/node_modules/is-glob/package.json @@ -0,0 +1,81 @@ +{ + "name": "is-glob", + "description": "Returns `true` if the given string looks like a glob pattern or an extglob pattern. This makes it easy to create code that only uses external modules like node-glob when necessary, resulting in much faster code execution and initialization time, and a better user experience.", + "version": "4.0.3", + "homepage": "https://github.com/micromatch/is-glob", + "author": "Jon Schlinkert (https://github.com/jonschlinkert)", + "contributors": [ + "Brian Woodward (https://twitter.com/doowb)", + "Daniel Perez (https://tuvistavie.com)", + "Jon Schlinkert (http://twitter.com/jonschlinkert)" + ], + "repository": "micromatch/is-glob", + "bugs": { + "url": "https://github.com/micromatch/is-glob/issues" + }, + "license": "MIT", + "files": [ + "index.js" + ], + "main": "index.js", + "engines": { + "node": ">=0.10.0" + }, + "scripts": { + "test": "mocha && node benchmark.js" + }, + "dependencies": { + "is-extglob": "^2.1.1" + }, + "devDependencies": { + "gulp-format-md": "^0.1.10", + "mocha": "^3.0.2" + }, + "keywords": [ + "bash", + "braces", + "check", + "exec", + "expression", + "extglob", + "glob", + "globbing", + "globstar", + "is", + "match", + "matches", + "pattern", + "regex", + "regular", + "string", + "test" + ], + "verb": { + "layout": "default", + "plugins": [ + "gulp-format-md" + ], + "related": { + "list": [ + "assemble", + "base", + "update", + "verb" + ] + }, + "reflinks": [ + "assemble", + "bach", + "base", + "composer", + "gulp", + "has-glob", + "is-valid-glob", + "micromatch", + "npm", + "scaffold", + "verb", + "vinyl" + ] + } +} diff --git a/node_modules/is-number/LICENSE b/node_modules/is-number/LICENSE new file mode 100644 index 00000000..9af4a67d --- /dev/null +++ b/node_modules/is-number/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014-present, Jon Schlinkert. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/is-number/README.md b/node_modules/is-number/README.md new file mode 100644 index 00000000..eb8149e8 --- /dev/null +++ b/node_modules/is-number/README.md @@ -0,0 +1,187 @@ +# is-number [![NPM version](https://img.shields.io/npm/v/is-number.svg?style=flat)](https://www.npmjs.com/package/is-number) [![NPM monthly downloads](https://img.shields.io/npm/dm/is-number.svg?style=flat)](https://npmjs.org/package/is-number) [![NPM total downloads](https://img.shields.io/npm/dt/is-number.svg?style=flat)](https://npmjs.org/package/is-number) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/is-number.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/is-number) + +> Returns true if the value is a finite number. + +Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support. + +## Install + +Install with [npm](https://www.npmjs.com/): + +```sh +$ npm install --save is-number +``` + +## Why is this needed? + +In JavaScript, it's not always as straightforward as it should be to reliably check if a value is a number. It's common for devs to use `+`, `-`, or `Number()` to cast a string value to a number (for example, when values are returned from user input, regex matches, parsers, etc). But there are many non-intuitive edge cases that yield unexpected results: + +```js +console.log(+[]); //=> 0 +console.log(+''); //=> 0 +console.log(+' '); //=> 0 +console.log(typeof NaN); //=> 'number' +``` + +This library offers a performant way to smooth out edge cases like these. + +## Usage + +```js +const isNumber = require('is-number'); +``` + +See the [tests](./test.js) for more examples. + +### true + +```js +isNumber(5e3); // true +isNumber(0xff); // true +isNumber(-1.1); // true +isNumber(0); // true +isNumber(1); // true +isNumber(1.1); // true +isNumber(10); // true +isNumber(10.10); // true +isNumber(100); // true +isNumber('-1.1'); // true +isNumber('0'); // true +isNumber('012'); // true +isNumber('0xff'); // true +isNumber('1'); // true +isNumber('1.1'); // true +isNumber('10'); // true +isNumber('10.10'); // true +isNumber('100'); // true +isNumber('5e3'); // true +isNumber(parseInt('012')); // true +isNumber(parseFloat('012')); // true +``` + +### False + +Everything else is false, as you would expect: + +```js +isNumber(Infinity); // false +isNumber(NaN); // false +isNumber(null); // false +isNumber(undefined); // false +isNumber(''); // false +isNumber(' '); // false +isNumber('foo'); // false +isNumber([1]); // false +isNumber([]); // false +isNumber(function () {}); // false +isNumber({}); // false +``` + +## Release history + +### 7.0.0 + +* Refactor. Now uses `.isFinite` if it exists. +* Performance is about the same as v6.0 when the value is a string or number. But it's now 3x-4x faster when the value is not a string or number. + +### 6.0.0 + +* Optimizations, thanks to @benaadams. + +### 5.0.0 + +**Breaking changes** + +* removed support for `instanceof Number` and `instanceof String` + +## Benchmarks + +As with all benchmarks, take these with a grain of salt. See the [benchmarks](./benchmark/index.js) for more detail. + +``` +# all +v7.0 x 413,222 ops/sec ±2.02% (86 runs sampled) +v6.0 x 111,061 ops/sec ±1.29% (85 runs sampled) +parseFloat x 317,596 ops/sec ±1.36% (86 runs sampled) +fastest is 'v7.0' + +# string +v7.0 x 3,054,496 ops/sec ±1.05% (89 runs sampled) +v6.0 x 2,957,781 ops/sec ±0.98% (88 runs sampled) +parseFloat x 3,071,060 ops/sec ±1.13% (88 runs sampled) +fastest is 'parseFloat,v7.0' + +# number +v7.0 x 3,146,895 ops/sec ±0.89% (89 runs sampled) +v6.0 x 3,214,038 ops/sec ±1.07% (89 runs sampled) +parseFloat x 3,077,588 ops/sec ±1.07% (87 runs sampled) +fastest is 'v6.0' +``` + +## About + +
+Contributing + +Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). + +
+ +
+Running Tests + +Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command: + +```sh +$ npm install && npm test +``` + +
+ +
+Building docs + +_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_ + +To generate the readme, run the following command: + +```sh +$ npm install -g verbose/verb#dev verb-generate-readme && verb +``` + +
+ +### Related projects + +You might also be interested in these projects: + +* [is-plain-object](https://www.npmjs.com/package/is-plain-object): Returns true if an object was created by the `Object` constructor. | [homepage](https://github.com/jonschlinkert/is-plain-object "Returns true if an object was created by the `Object` constructor.") +* [is-primitive](https://www.npmjs.com/package/is-primitive): Returns `true` if the value is a primitive. | [homepage](https://github.com/jonschlinkert/is-primitive "Returns `true` if the value is a primitive. ") +* [isobject](https://www.npmjs.com/package/isobject): Returns true if the value is an object and not an array or null. | [homepage](https://github.com/jonschlinkert/isobject "Returns true if the value is an object and not an array or null.") +* [kind-of](https://www.npmjs.com/package/kind-of): Get the native type of a value. | [homepage](https://github.com/jonschlinkert/kind-of "Get the native type of a value.") + +### Contributors + +| **Commits** | **Contributor** | +| --- | --- | +| 49 | [jonschlinkert](https://github.com/jonschlinkert) | +| 5 | [charlike-old](https://github.com/charlike-old) | +| 1 | [benaadams](https://github.com/benaadams) | +| 1 | [realityking](https://github.com/realityking) | + +### Author + +**Jon Schlinkert** + +* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert) +* [GitHub Profile](https://github.com/jonschlinkert) +* [Twitter Profile](https://twitter.com/jonschlinkert) + +### License + +Copyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert). +Released under the [MIT License](LICENSE). + +*** + +_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on June 15, 2018._ \ No newline at end of file diff --git a/node_modules/is-number/index.js b/node_modules/is-number/index.js new file mode 100644 index 00000000..27f19b75 --- /dev/null +++ b/node_modules/is-number/index.js @@ -0,0 +1,18 @@ +/*! + * is-number + * + * Copyright (c) 2014-present, Jon Schlinkert. + * Released under the MIT License. + */ + +'use strict'; + +module.exports = function(num) { + if (typeof num === 'number') { + return num - num === 0; + } + if (typeof num === 'string' && num.trim() !== '') { + return Number.isFinite ? Number.isFinite(+num) : isFinite(+num); + } + return false; +}; diff --git a/node_modules/is-number/package.json b/node_modules/is-number/package.json new file mode 100644 index 00000000..37150726 --- /dev/null +++ b/node_modules/is-number/package.json @@ -0,0 +1,82 @@ +{ + "name": "is-number", + "description": "Returns true if a number or string value is a finite number. Useful for regex matches, parsing, user input, etc.", + "version": "7.0.0", + "homepage": "https://github.com/jonschlinkert/is-number", + "author": "Jon Schlinkert (https://github.com/jonschlinkert)", + "contributors": [ + "Jon Schlinkert (http://twitter.com/jonschlinkert)", + "Olsten Larck (https://i.am.charlike.online)", + "Rouven Weßling (www.rouvenwessling.de)" + ], + "repository": "jonschlinkert/is-number", + "bugs": { + "url": "https://github.com/jonschlinkert/is-number/issues" + }, + "license": "MIT", + "files": [ + "index.js" + ], + "main": "index.js", + "engines": { + "node": ">=0.12.0" + }, + "scripts": { + "test": "mocha" + }, + "devDependencies": { + "ansi": "^0.3.1", + "benchmark": "^2.1.4", + "gulp-format-md": "^1.0.0", + "mocha": "^3.5.3" + }, + "keywords": [ + "cast", + "check", + "coerce", + "coercion", + "finite", + "integer", + "is", + "isnan", + "is-nan", + "is-num", + "is-number", + "isnumber", + "isfinite", + "istype", + "kind", + "math", + "nan", + "num", + "number", + "numeric", + "parseFloat", + "parseInt", + "test", + "type", + "typeof", + "value" + ], + "verb": { + "toc": false, + "layout": "default", + "tasks": [ + "readme" + ], + "related": { + "list": [ + "is-plain-object", + "is-primitive", + "isobject", + "kind-of" + ] + }, + "plugins": [ + "gulp-format-md" + ], + "lint": { + "reflinks": true + } + } +} diff --git a/node_modules/jquery/AUTHORS.txt b/node_modules/jquery/AUTHORS.txt new file mode 100644 index 00000000..648a3f0f --- /dev/null +++ b/node_modules/jquery/AUTHORS.txt @@ -0,0 +1,371 @@ +John Resig +Gilles van den Hoven +Michael Geary +Stefan Petre +Yehuda Katz +Corey Jewett +Klaus Hartl +Franck Marcia +Jörn Zaefferer +Paul Bakaus +Brandon Aaron +Mike Alsup +Dave Methvin +Ed Engelhardt +Sean Catchpole +Paul Mclanahan +David Serduke +Richard D. Worth +Scott González +Ariel Flesler +Cheah Chu Yeow +Andrew Chalkley +Fabio Buffoni +Stefan Bauckmeier  +Jon Evans +TJ Holowaychuk +Riccardo De Agostini +Michael Bensoussan +Louis-Rémi Babé +Robert Katić +Damian Janowski +Anton Kovalyov +Dušan B. Jovanovic +Earle Castledine +Rich Dougherty +Kim Dalsgaard +Andrea Giammarchi +Fabian Jakobs +Mark Gibson +Karl Swedberg +Justin Meyer +Ben Alman +James Padolsey +David Petersen +Batiste Bieler +Jake Archibald +Alexander Farkas +Filipe Fortes +Rick Waldron +Neeraj Singh +Paul Irish +Iraê Carvalho +Matt Curry +Michael Monteleone +Noah Sloan +Tom Viner +J. Ryan Stinnett +Douglas Neiner +Adam J. Sontag +Heungsub Lee +Dave Reed +Carl Fürstenberg +Jacob Wright +Ralph Whitbeck +unknown +temp01 +Colin Snover +Jared Grippe +Ryan W Tenney +Alex Sexton +Pinhook +Ron Otten +Jephte Clain +Anton Matzneller +Dan Heberden +Henri Wiechers +Russell Holbrook +Julian Aubourg +Gianni Alessandro Chiappetta +Scott Jehl +James Burke +Jonas Pfenniger +Xavi Ramirez +Sylvester Keil +Brandon Sterne +Mathias Bynens +Lee Carpenter +Timmy Willison <4timmywil@gmail.com> +Corey Frang +Digitalxero +David Murdoch +Josh Varner +Charles McNulty +Jordan Boesch +Jess Thrysoee +Michael Murray +Alexis Abril +Rob Morgan +John Firebaugh +Sam Bisbee +Gilmore Davidson +Brian Brennan +Xavier Montillet +Daniel Pihlstrom +Sahab Yazdani +avaly +Scott Hughes +Mike Sherov +Greg Hazel +Schalk Neethling +Denis Knauf +Timo Tijhof +Steen Nielsen +Anton Ryzhov +Shi Chuan +Matt Mueller +Berker Peksag +Toby Brain +Justin +Daniel Herman +Oleg Gaidarenko +Rock Hymas +Richard Gibson +Rafaël Blais Masson +cmc3cn <59194618@qq.com> +Joe Presbrey +Sindre Sorhus +Arne de Bree +Vladislav Zarakovsky +Andrew E Monat +Oskari +Joao Henrique de Andrade Bruni +tsinha +Dominik D. Geyer +Matt Farmer +Trey Hunner +Jason Moon +Jeffery To +Kris Borchers +Vladimir Zhuravlev +Jacob Thornton +Chad Killingsworth +Vitya Muhachev +Nowres Rafid +David Benjamin +Alan Plum +Uri Gilad +Chris Faulkner +Marcel Greter +Elijah Manor +Daniel Chatfield +Daniel Gálvez +Nikita Govorov +Wesley Walser +Mike Pennisi +Matthias Jäggli +Devin Cooper +Markus Staab +Dave Riddle +Callum Macrae +Jonathan Sampson +Benjamin Truyman +Jay Merrifield +James Huston +Sai Lung Wong +Erick Ruiz de Chávez +David Bonner +Allen J Schmidt Jr +Akintayo Akinwunmi +MORGAN +Ismail Khair +Carl Danley +Mike Petrovich +Greg Lavallee +Tom H Fuertes +Roland Eckl +Yiming He +David Fox +Bennett Sorbo +Paul Ramos +Rod Vagg +Sebastian Burkhard +Zachary Adam Kaplan +Adam Coulombe +nanto_vi +nanto +Danil Somsikov +Ryunosuke SATO +Diego Tres +Jean Boussier +Andrew Plummer +Mark Raddatz +Pascal Borreli +Isaac Z. Schlueter +Karl Sieburg +Nguyen Phuc Lam +Dmitry Gusev +Steven Benner +Li Xudong +Michał Gołębiowski-Owczarek +Renato Oliveira dos Santos +Frederic Junod +Tom H Fuertes +Mitch Foley +ros3cin +Kyle Robinson Young +John Paul +Jason Bedard +Chris Talkington +Eddie Monge +Terry Jones +Jason Merino +Dan Burzo +Jeremy Dunck +Chris Price +Guy Bedford +njhamann +Goare Mao +Amey Sakhadeo +Mike Sidorov +Anthony Ryan +Lihan Li +George Kats +Dongseok Paeng +Ronny Springer +Ilya Kantor +Marian Sollmann +Chris Antaki +David Hong +Jakob Stoeck +Christopher Jones +Forbes Lindesay +S. Andrew Sheppard +Leonardo Balter +Rodrigo Rosenfeld Rosas +Daniel Husar +Philip Jägenstedt +John Hoven +Roman Reiß +Benjy Cui +Christian Kosmowski +David Corbacho +Liang Peng +TJ VanToll +Aurelio De Rosa +Senya Pugach +Dan Hart +Nazar Mokrynskyi +Benjamin Tan +Amit Merchant +Jason Bedard +Veaceslav Grimalschi +Richard McDaniel +Arthur Verschaeve +Shivaji Varma +Ben Toews +Bin Xin +Neftaly Hernandez +T.J. Crowder +Nicolas HENRY +Frederic Hemberger +Victor Homyakov +Aditya Raghavan +Anne-Gaelle Colom +Leonardo Braga +George Mauer +Stephen Edgar +Thomas Tortorini +Jörn Wagner +Jon Hester +Colin Frick +Winston Howes +Alexander O'Mara +Chris Rebert +Bastian Buchholz +Mu Haibao +Calvin Metcalf +Arthur Stolyar +Gabriel Schulhof +Gilad Peleg +Julian Alexander Murillo +Kevin Kirsche +Martin Naumann +Yongwoo Jeon +John-David Dalton +Marek Lewandowski +Bruno Pérel +Daniel Nill +Reed Loden +Sean Henderson +Gary Ye +Richard Kraaijenhagen +Connor Atherton +Christian Grete +Tom von Clef +Liza Ramo +Joelle Fleurantin +Steve Mao +Jon Dufresne +Jae Sung Park +Josh Soref +Saptak Sengupta +Henry Wong +Jun Sun +Martijn W. van der Lee +Devin Wilson +Damian Senn +Zack Hall +Vitaliy Terziev +Todor Prikumov +Bernhard M. Wiedemann +Jha Naman +Alexander Lisianoi +William Robinet +Joe Trumbull +Alexander K +Ralin Chimev +Felipe Sateler +Christophe Tafani-Dereeper +Manoj Kumar +David Broder-Rodgers +Alex Louden +Alex Padilla +karan-96 +南漂一卒 +Erik Lax +Boom Lee +Andreas Solleder +Pierre Spring +Shashanka Nataraj +CDAGaming +Matan Kotler-Berkowitz <205matan@gmail.com> +Jordan Beland +Henry Zhu +Nilton Cesar +basil.belokon +Andrey Meshkov +tmybr11 +Luis Emilio Velasco Sanchez +Ed S +Bert Zhang +Sébastien Règne +wartmanm <3869625+wartmanm@users.noreply.github.com> +Siddharth Dungarwal +abnud1 +Andrei Fangli +Marja Hölttä +buddh4 +Hoang +Wonseop Kim +Pat O'Callaghan +JuanMa Ruiz +Ahmed.S.ElAfifi +Christian Oliff +Christian Wenz +Sean Robinson +Jonathan +Pierre Grimaud +Beatriz Rezener +Natalia Sroka <37873210+natipo@users.noreply.github.com> +Wonhyoung Park +Dallas Fraser +fecore1 <89127124+fecore1@users.noreply.github.com> +ygj6 <7699524+ygj6@users.noreply.github.com> +Simon Legner +Vladimir Sitnikov +Anders Kaseorg +Alex +Timo Tijhof +Gabriela Gutierrez +Dimitri Papadopoulos Orfanos <3234522+DimitriPapadopoulos@users.noreply.github.com> diff --git a/node_modules/jquery/LICENSE.txt b/node_modules/jquery/LICENSE.txt new file mode 100644 index 00000000..f642c3f7 --- /dev/null +++ b/node_modules/jquery/LICENSE.txt @@ -0,0 +1,20 @@ +Copyright OpenJS Foundation and other contributors, https://openjsf.org/ + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/jquery/README.md b/node_modules/jquery/README.md new file mode 100644 index 00000000..fcc11f3b --- /dev/null +++ b/node_modules/jquery/README.md @@ -0,0 +1,60 @@ +# jQuery + +> jQuery is a fast, small, and feature-rich JavaScript library. + +For information on how to get started and how to use jQuery, please see [jQuery's documentation](https://api.jquery.com/). +For source files and issues, please visit the [jQuery repo](https://github.com/jquery/jquery). + +If upgrading, please see the [blog post for 3.7.1](https://blog.jquery.com/2023/08/28/jquery-3-7-1-released-reliable-table-row-dimensions/). This includes notable differences from the previous version and a more readable changelog. + +## Including jQuery + +Below are some of the most common ways to include jQuery. + +### Browser + +#### Script tag + +```html + +``` + +#### Webpack / Browserify / Babel + +There are several ways to use [Webpack](https://webpack.js.org/), [Browserify](http://browserify.org/) or [Babel](https://babeljs.io/). For more information on using these tools, please refer to the corresponding project's documentation. In the script, including jQuery will usually look like this: + +```js +import $ from "jquery"; +``` + +If you need to use jQuery in a file that's not an ECMAScript module, you can use the CommonJS syntax: + +```js +var $ = require( "jquery" ); +``` + +#### AMD (Asynchronous Module Definition) + +AMD is a module format built for the browser. For more information, we recommend [require.js' documentation](https://requirejs.org/docs/whyamd.html). + +```js +define( [ "jquery" ], function( $ ) { + +} ); +``` + +### Node + +To include jQuery in [Node](https://nodejs.org/), first install with npm. + +```sh +npm install jquery +``` + +For jQuery to work in Node, a window with a document is required. Since no such window exists natively in Node, one can be mocked by tools such as [jsdom](https://github.com/jsdom/jsdom). This can be useful for testing purposes. + +```js +const { JSDOM } = require( "jsdom" ); +const { window } = new JSDOM( "" ); +const $ = require( "jquery" )( window ); +``` diff --git a/node_modules/jquery/bower.json b/node_modules/jquery/bower.json new file mode 100644 index 00000000..95798d5a --- /dev/null +++ b/node_modules/jquery/bower.json @@ -0,0 +1,14 @@ +{ + "name": "jquery", + "main": "dist/jquery.js", + "license": "MIT", + "ignore": [ + "package.json" + ], + "keywords": [ + "jquery", + "javascript", + "browser", + "library" + ] +} \ No newline at end of file diff --git a/node_modules/jquery/package.json b/node_modules/jquery/package.json new file mode 100644 index 00000000..944c39b8 --- /dev/null +++ b/node_modules/jquery/package.json @@ -0,0 +1,122 @@ +{ + "name": "jquery", + "title": "jQuery", + "description": "JavaScript library for DOM operations", + "version": "3.7.1", + "main": "dist/jquery.js", + "homepage": "https://jquery.com", + "author": { + "name": "OpenJS Foundation and other contributors", + "url": "https://github.com/jquery/jquery/blob/3.7.1/AUTHORS.txt" + }, + "repository": { + "type": "git", + "url": "https://github.com/jquery/jquery.git" + }, + "keywords": [ + "jquery", + "javascript", + "browser", + "library" + ], + "bugs": { + "url": "https://github.com/jquery/jquery/issues" + }, + "license": "MIT", + "devDependencies": { + "@babel/core": "7.3.3", + "@babel/plugin-transform-for-of": "7.2.0", + "bootstrap": "5.3.0", + "colors": "1.4.0", + "commitplease": "3.2.0", + "core-js": "2.6.5", + "eslint-config-jquery": "3.0.0", + "grunt": "1.5.3", + "grunt-babel": "8.0.0", + "grunt-cli": "1.4.3", + "grunt-compare-size": "0.4.2", + "grunt-contrib-uglify": "3.4.0", + "grunt-contrib-watch": "1.1.0", + "grunt-eslint": "22.0.0", + "grunt-git-authors": "3.2.0", + "grunt-jsonlint": "2.1.2", + "grunt-karma": "4.0.2", + "grunt-newer": "1.3.0", + "grunt-npmcopy": "0.2.0", + "gzip-js": "0.3.2", + "husky": "4.2.5", + "jsdom": "19.0.0", + "karma": "6.4.1", + "karma-browserstack-launcher": "1.6.0", + "karma-chrome-launcher": "3.1.1", + "karma-firefox-launcher": "2.1.2", + "karma-ie-launcher": "1.0.0", + "karma-jsdom-launcher": "12.0.0", + "karma-qunit": "4.1.2", + "karma-webkit-launcher": "2.1.0", + "load-grunt-tasks": "5.1.0", + "native-promise-only": "0.8.1", + "playwright-webkit": "1.30.0", + "promises-aplus-tests": "2.1.2", + "q": "1.5.1", + "qunit": "2.9.2", + "raw-body": "2.3.3", + "requirejs": "2.3.6", + "sinon": "2.3.7", + "strip-json-comments": "2.0.1", + "testswarm": "1.1.2", + "uglify-js": "3.4.7" + }, + "scripts": { + "build": "npm install && npm run build-all-variants", + "build-all-variants": "grunt custom:slim --filename=jquery.slim.js && grunt custom", + "start": "grunt watch", + "test:browserless": "grunt && npm run test:node_smoke_tests && grunt test:slow", + "test:browser": "grunt && grunt karma:main", + "test:amd": "grunt && grunt karma:amd", + "test:no-deprecated": "grunt test:prepare && grunt custom:-deprecated && grunt karma:main", + "test:selector-native": "grunt test:prepare && grunt custom:-selector && grunt karma:main", + "test:slim": "grunt test:prepare && grunt custom:slim && grunt karma:main", + "test:node_smoke_tests:full": "grunt node_smoke_tests:./dist/jquery.js", + "test:node_smoke_tests:slim": "grunt node_smoke_tests:./dist/jquery.slim.js", + "test:node_smoke_tests": "npm run test:node_smoke_tests:full && npm run test:node_smoke_tests:slim", + "test": "npm run test:browserless && npm run test:slim && npm run test:no-deprecated && npm run test:selector-native && grunt && grunt test:slow && grunt karma:main && grunt karma:amd", + "jenkins": "npm run test:browserless" + }, + "commitplease": { + "nohook": true, + "components": [ + "Docs", + "Tests", + "Build", + "Support", + "Release", + "Core", + "Ajax", + "Attributes", + "Callbacks", + "CSS", + "Data", + "Deferred", + "Deprecated", + "Dimensions", + "Effects", + "Event", + "Manipulation", + "Offset", + "Queue", + "Selector", + "Serialize", + "Traversing", + "Wrap" + ], + "markerPattern": "^((clos|fix|resolv)(e[sd]|ing))|^(refs?)", + "ticketPattern": "^((Closes|Fixes) ([a-zA-Z]{2,}-)[0-9]+)|^(Refs? [^#])" + }, + "husky": { + "hooks": { + "commit-msg": "commitplease .git/COMMIT_EDITMSG", + "pre-commit": "grunt lint:newer qunit_fixture" + } + } +} diff --git a/node_modules/jquery/src/ajax.js b/node_modules/jquery/src/ajax.js new file mode 100644 index 00000000..1fa31042 --- /dev/null +++ b/node_modules/jquery/src/ajax.js @@ -0,0 +1,876 @@ +define( [ + "./core", + "./var/document", + "./var/isFunction", + "./var/rnothtmlwhite", + "./ajax/var/location", + "./ajax/var/nonce", + "./ajax/var/rquery", + + "./core/init", + "./core/parseXML", + "./event/trigger", + "./deferred", + "./serialize" // jQuery.param +], function( jQuery, document, isFunction, rnothtmlwhite, location, nonce, rquery ) { + +"use strict"; + +var + r20 = /%20/g, + rhash = /#.*$/, + rantiCache = /([?&])_=[^&]*/, + rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg, + + // trac-7653, trac-8125, trac-8152: local protocol detection + rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/, + rnoContent = /^(?:GET|HEAD)$/, + rprotocol = /^\/\//, + + /* Prefilters + * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example) + * 2) These are called: + * - BEFORE asking for a transport + * - AFTER param serialization (s.data is a string if s.processData is true) + * 3) key is the dataType + * 4) the catchall symbol "*" can be used + * 5) execution will start with transport dataType and THEN continue down to "*" if needed + */ + prefilters = {}, + + /* Transports bindings + * 1) key is the dataType + * 2) the catchall symbol "*" can be used + * 3) selection will start with transport dataType and THEN go to "*" if needed + */ + transports = {}, + + // Avoid comment-prolog char sequence (trac-10098); must appease lint and evade compression + allTypes = "*/".concat( "*" ), + + // Anchor tag for parsing the document origin + originAnchor = document.createElement( "a" ); + +originAnchor.href = location.href; + +// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport +function addToPrefiltersOrTransports( structure ) { + + // dataTypeExpression is optional and defaults to "*" + return function( dataTypeExpression, func ) { + + if ( typeof dataTypeExpression !== "string" ) { + func = dataTypeExpression; + dataTypeExpression = "*"; + } + + var dataType, + i = 0, + dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || []; + + if ( isFunction( func ) ) { + + // For each dataType in the dataTypeExpression + while ( ( dataType = dataTypes[ i++ ] ) ) { + + // Prepend if requested + if ( dataType[ 0 ] === "+" ) { + dataType = dataType.slice( 1 ) || "*"; + ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func ); + + // Otherwise append + } else { + ( structure[ dataType ] = structure[ dataType ] || [] ).push( func ); + } + } + } + }; +} + +// Base inspection function for prefilters and transports +function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) { + + var inspected = {}, + seekingTransport = ( structure === transports ); + + function inspect( dataType ) { + var selected; + inspected[ dataType ] = true; + jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) { + var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR ); + if ( typeof dataTypeOrTransport === "string" && + !seekingTransport && !inspected[ dataTypeOrTransport ] ) { + + options.dataTypes.unshift( dataTypeOrTransport ); + inspect( dataTypeOrTransport ); + return false; + } else if ( seekingTransport ) { + return !( selected = dataTypeOrTransport ); + } + } ); + return selected; + } + + return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" ); +} + +// A special extend for ajax options +// that takes "flat" options (not to be deep extended) +// Fixes trac-9887 +function ajaxExtend( target, src ) { + var key, deep, + flatOptions = jQuery.ajaxSettings.flatOptions || {}; + + for ( key in src ) { + if ( src[ key ] !== undefined ) { + ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ]; + } + } + if ( deep ) { + jQuery.extend( true, target, deep ); + } + + return target; +} + +/* Handles responses to an ajax request: + * - finds the right dataType (mediates between content-type and expected dataType) + * - returns the corresponding response + */ +function ajaxHandleResponses( s, jqXHR, responses ) { + + var ct, type, finalDataType, firstDataType, + contents = s.contents, + dataTypes = s.dataTypes; + + // Remove auto dataType and get content-type in the process + while ( dataTypes[ 0 ] === "*" ) { + dataTypes.shift(); + if ( ct === undefined ) { + ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" ); + } + } + + // Check if we're dealing with a known content-type + if ( ct ) { + for ( type in contents ) { + if ( contents[ type ] && contents[ type ].test( ct ) ) { + dataTypes.unshift( type ); + break; + } + } + } + + // Check to see if we have a response for the expected dataType + if ( dataTypes[ 0 ] in responses ) { + finalDataType = dataTypes[ 0 ]; + } else { + + // Try convertible dataTypes + for ( type in responses ) { + if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) { + finalDataType = type; + break; + } + if ( !firstDataType ) { + firstDataType = type; + } + } + + // Or just use first one + finalDataType = finalDataType || firstDataType; + } + + // If we found a dataType + // We add the dataType to the list if needed + // and return the corresponding response + if ( finalDataType ) { + if ( finalDataType !== dataTypes[ 0 ] ) { + dataTypes.unshift( finalDataType ); + } + return responses[ finalDataType ]; + } +} + +/* Chain conversions given the request and the original response + * Also sets the responseXXX fields on the jqXHR instance + */ +function ajaxConvert( s, response, jqXHR, isSuccess ) { + var conv2, current, conv, tmp, prev, + converters = {}, + + // Work with a copy of dataTypes in case we need to modify it for conversion + dataTypes = s.dataTypes.slice(); + + // Create converters map with lowercased keys + if ( dataTypes[ 1 ] ) { + for ( conv in s.converters ) { + converters[ conv.toLowerCase() ] = s.converters[ conv ]; + } + } + + current = dataTypes.shift(); + + // Convert to each sequential dataType + while ( current ) { + + if ( s.responseFields[ current ] ) { + jqXHR[ s.responseFields[ current ] ] = response; + } + + // Apply the dataFilter if provided + if ( !prev && isSuccess && s.dataFilter ) { + response = s.dataFilter( response, s.dataType ); + } + + prev = current; + current = dataTypes.shift(); + + if ( current ) { + + // There's only work to do if current dataType is non-auto + if ( current === "*" ) { + + current = prev; + + // Convert response if prev dataType is non-auto and differs from current + } else if ( prev !== "*" && prev !== current ) { + + // Seek a direct converter + conv = converters[ prev + " " + current ] || converters[ "* " + current ]; + + // If none found, seek a pair + if ( !conv ) { + for ( conv2 in converters ) { + + // If conv2 outputs current + tmp = conv2.split( " " ); + if ( tmp[ 1 ] === current ) { + + // If prev can be converted to accepted input + conv = converters[ prev + " " + tmp[ 0 ] ] || + converters[ "* " + tmp[ 0 ] ]; + if ( conv ) { + + // Condense equivalence converters + if ( conv === true ) { + conv = converters[ conv2 ]; + + // Otherwise, insert the intermediate dataType + } else if ( converters[ conv2 ] !== true ) { + current = tmp[ 0 ]; + dataTypes.unshift( tmp[ 1 ] ); + } + break; + } + } + } + } + + // Apply converter (if not an equivalence) + if ( conv !== true ) { + + // Unless errors are allowed to bubble, catch and return them + if ( conv && s.throws ) { + response = conv( response ); + } else { + try { + response = conv( response ); + } catch ( e ) { + return { + state: "parsererror", + error: conv ? e : "No conversion from " + prev + " to " + current + }; + } + } + } + } + } + } + + return { state: "success", data: response }; +} + +jQuery.extend( { + + // Counter for holding the number of active queries + active: 0, + + // Last-Modified header cache for next request + lastModified: {}, + etag: {}, + + ajaxSettings: { + url: location.href, + type: "GET", + isLocal: rlocalProtocol.test( location.protocol ), + global: true, + processData: true, + async: true, + contentType: "application/x-www-form-urlencoded; charset=UTF-8", + + /* + timeout: 0, + data: null, + dataType: null, + username: null, + password: null, + cache: null, + throws: false, + traditional: false, + headers: {}, + */ + + accepts: { + "*": allTypes, + text: "text/plain", + html: "text/html", + xml: "application/xml, text/xml", + json: "application/json, text/javascript" + }, + + contents: { + xml: /\bxml\b/, + html: /\bhtml/, + json: /\bjson\b/ + }, + + responseFields: { + xml: "responseXML", + text: "responseText", + json: "responseJSON" + }, + + // Data converters + // Keys separate source (or catchall "*") and destination types with a single space + converters: { + + // Convert anything to text + "* text": String, + + // Text to html (true = no transformation) + "text html": true, + + // Evaluate text as a json expression + "text json": JSON.parse, + + // Parse text as xml + "text xml": jQuery.parseXML + }, + + // For options that shouldn't be deep extended: + // you can add your own custom options here if + // and when you create one that shouldn't be + // deep extended (see ajaxExtend) + flatOptions: { + url: true, + context: true + } + }, + + // Creates a full fledged settings object into target + // with both ajaxSettings and settings fields. + // If target is omitted, writes into ajaxSettings. + ajaxSetup: function( target, settings ) { + return settings ? + + // Building a settings object + ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) : + + // Extending ajaxSettings + ajaxExtend( jQuery.ajaxSettings, target ); + }, + + ajaxPrefilter: addToPrefiltersOrTransports( prefilters ), + ajaxTransport: addToPrefiltersOrTransports( transports ), + + // Main method + ajax: function( url, options ) { + + // If url is an object, simulate pre-1.5 signature + if ( typeof url === "object" ) { + options = url; + url = undefined; + } + + // Force options to be an object + options = options || {}; + + var transport, + + // URL without anti-cache param + cacheURL, + + // Response headers + responseHeadersString, + responseHeaders, + + // timeout handle + timeoutTimer, + + // Url cleanup var + urlAnchor, + + // Request state (becomes false upon send and true upon completion) + completed, + + // To know if global events are to be dispatched + fireGlobals, + + // Loop variable + i, + + // uncached part of the url + uncached, + + // Create the final options object + s = jQuery.ajaxSetup( {}, options ), + + // Callbacks context + callbackContext = s.context || s, + + // Context for global events is callbackContext if it is a DOM node or jQuery collection + globalEventContext = s.context && + ( callbackContext.nodeType || callbackContext.jquery ) ? + jQuery( callbackContext ) : + jQuery.event, + + // Deferreds + deferred = jQuery.Deferred(), + completeDeferred = jQuery.Callbacks( "once memory" ), + + // Status-dependent callbacks + statusCode = s.statusCode || {}, + + // Headers (they are sent all at once) + requestHeaders = {}, + requestHeadersNames = {}, + + // Default abort message + strAbort = "canceled", + + // Fake xhr + jqXHR = { + readyState: 0, + + // Builds headers hashtable if needed + getResponseHeader: function( key ) { + var match; + if ( completed ) { + if ( !responseHeaders ) { + responseHeaders = {}; + while ( ( match = rheaders.exec( responseHeadersString ) ) ) { + responseHeaders[ match[ 1 ].toLowerCase() + " " ] = + ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] ) + .concat( match[ 2 ] ); + } + } + match = responseHeaders[ key.toLowerCase() + " " ]; + } + return match == null ? null : match.join( ", " ); + }, + + // Raw string + getAllResponseHeaders: function() { + return completed ? responseHeadersString : null; + }, + + // Caches the header + setRequestHeader: function( name, value ) { + if ( completed == null ) { + name = requestHeadersNames[ name.toLowerCase() ] = + requestHeadersNames[ name.toLowerCase() ] || name; + requestHeaders[ name ] = value; + } + return this; + }, + + // Overrides response content-type header + overrideMimeType: function( type ) { + if ( completed == null ) { + s.mimeType = type; + } + return this; + }, + + // Status-dependent callbacks + statusCode: function( map ) { + var code; + if ( map ) { + if ( completed ) { + + // Execute the appropriate callbacks + jqXHR.always( map[ jqXHR.status ] ); + } else { + + // Lazy-add the new callbacks in a way that preserves old ones + for ( code in map ) { + statusCode[ code ] = [ statusCode[ code ], map[ code ] ]; + } + } + } + return this; + }, + + // Cancel the request + abort: function( statusText ) { + var finalText = statusText || strAbort; + if ( transport ) { + transport.abort( finalText ); + } + done( 0, finalText ); + return this; + } + }; + + // Attach deferreds + deferred.promise( jqXHR ); + + // Add protocol if not provided (prefilters might expect it) + // Handle falsy url in the settings object (trac-10093: consistency with old signature) + // We also use the url parameter if available + s.url = ( ( url || s.url || location.href ) + "" ) + .replace( rprotocol, location.protocol + "//" ); + + // Alias method option to type as per ticket trac-12004 + s.type = options.method || options.type || s.method || s.type; + + // Extract dataTypes list + s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ]; + + // A cross-domain request is in order when the origin doesn't match the current origin. + if ( s.crossDomain == null ) { + urlAnchor = document.createElement( "a" ); + + // Support: IE <=8 - 11, Edge 12 - 15 + // IE throws exception on accessing the href property if url is malformed, + // e.g. http://example.com:80x/ + try { + urlAnchor.href = s.url; + + // Support: IE <=8 - 11 only + // Anchor's host property isn't correctly set when s.url is relative + urlAnchor.href = urlAnchor.href; + s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !== + urlAnchor.protocol + "//" + urlAnchor.host; + } catch ( e ) { + + // If there is an error parsing the URL, assume it is crossDomain, + // it can be rejected by the transport if it is invalid + s.crossDomain = true; + } + } + + // Convert data if not already a string + if ( s.data && s.processData && typeof s.data !== "string" ) { + s.data = jQuery.param( s.data, s.traditional ); + } + + // Apply prefilters + inspectPrefiltersOrTransports( prefilters, s, options, jqXHR ); + + // If request was aborted inside a prefilter, stop there + if ( completed ) { + return jqXHR; + } + + // We can fire global events as of now if asked to + // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (trac-15118) + fireGlobals = jQuery.event && s.global; + + // Watch for a new set of requests + if ( fireGlobals && jQuery.active++ === 0 ) { + jQuery.event.trigger( "ajaxStart" ); + } + + // Uppercase the type + s.type = s.type.toUpperCase(); + + // Determine if request has content + s.hasContent = !rnoContent.test( s.type ); + + // Save the URL in case we're toying with the If-Modified-Since + // and/or If-None-Match header later on + // Remove hash to simplify url manipulation + cacheURL = s.url.replace( rhash, "" ); + + // More options handling for requests with no content + if ( !s.hasContent ) { + + // Remember the hash so we can put it back + uncached = s.url.slice( cacheURL.length ); + + // If data is available and should be processed, append data to url + if ( s.data && ( s.processData || typeof s.data === "string" ) ) { + cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data; + + // trac-9682: remove data so that it's not used in an eventual retry + delete s.data; + } + + // Add or update anti-cache param if needed + if ( s.cache === false ) { + cacheURL = cacheURL.replace( rantiCache, "$1" ); + uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce.guid++ ) + + uncached; + } + + // Put hash and anti-cache on the URL that will be requested (gh-1732) + s.url = cacheURL + uncached; + + // Change '%20' to '+' if this is encoded form body content (gh-2658) + } else if ( s.data && s.processData && + ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) { + s.data = s.data.replace( r20, "+" ); + } + + // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. + if ( s.ifModified ) { + if ( jQuery.lastModified[ cacheURL ] ) { + jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] ); + } + if ( jQuery.etag[ cacheURL ] ) { + jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] ); + } + } + + // Set the correct header, if data is being sent + if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) { + jqXHR.setRequestHeader( "Content-Type", s.contentType ); + } + + // Set the Accepts header for the server, depending on the dataType + jqXHR.setRequestHeader( + "Accept", + s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ? + s.accepts[ s.dataTypes[ 0 ] ] + + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) : + s.accepts[ "*" ] + ); + + // Check for headers option + for ( i in s.headers ) { + jqXHR.setRequestHeader( i, s.headers[ i ] ); + } + + // Allow custom headers/mimetypes and early abort + if ( s.beforeSend && + ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) { + + // Abort if not done already and return + return jqXHR.abort(); + } + + // Aborting is no longer a cancellation + strAbort = "abort"; + + // Install callbacks on deferreds + completeDeferred.add( s.complete ); + jqXHR.done( s.success ); + jqXHR.fail( s.error ); + + // Get transport + transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR ); + + // If no transport, we auto-abort + if ( !transport ) { + done( -1, "No Transport" ); + } else { + jqXHR.readyState = 1; + + // Send global event + if ( fireGlobals ) { + globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] ); + } + + // If request was aborted inside ajaxSend, stop there + if ( completed ) { + return jqXHR; + } + + // Timeout + if ( s.async && s.timeout > 0 ) { + timeoutTimer = window.setTimeout( function() { + jqXHR.abort( "timeout" ); + }, s.timeout ); + } + + try { + completed = false; + transport.send( requestHeaders, done ); + } catch ( e ) { + + // Rethrow post-completion exceptions + if ( completed ) { + throw e; + } + + // Propagate others as results + done( -1, e ); + } + } + + // Callback for when everything is done + function done( status, nativeStatusText, responses, headers ) { + var isSuccess, success, error, response, modified, + statusText = nativeStatusText; + + // Ignore repeat invocations + if ( completed ) { + return; + } + + completed = true; + + // Clear timeout if it exists + if ( timeoutTimer ) { + window.clearTimeout( timeoutTimer ); + } + + // Dereference transport for early garbage collection + // (no matter how long the jqXHR object will be used) + transport = undefined; + + // Cache response headers + responseHeadersString = headers || ""; + + // Set readyState + jqXHR.readyState = status > 0 ? 4 : 0; + + // Determine if successful + isSuccess = status >= 200 && status < 300 || status === 304; + + // Get response data + if ( responses ) { + response = ajaxHandleResponses( s, jqXHR, responses ); + } + + // Use a noop converter for missing script but not if jsonp + if ( !isSuccess && + jQuery.inArray( "script", s.dataTypes ) > -1 && + jQuery.inArray( "json", s.dataTypes ) < 0 ) { + s.converters[ "text script" ] = function() {}; + } + + // Convert no matter what (that way responseXXX fields are always set) + response = ajaxConvert( s, response, jqXHR, isSuccess ); + + // If successful, handle type chaining + if ( isSuccess ) { + + // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. + if ( s.ifModified ) { + modified = jqXHR.getResponseHeader( "Last-Modified" ); + if ( modified ) { + jQuery.lastModified[ cacheURL ] = modified; + } + modified = jqXHR.getResponseHeader( "etag" ); + if ( modified ) { + jQuery.etag[ cacheURL ] = modified; + } + } + + // if no content + if ( status === 204 || s.type === "HEAD" ) { + statusText = "nocontent"; + + // if not modified + } else if ( status === 304 ) { + statusText = "notmodified"; + + // If we have data, let's convert it + } else { + statusText = response.state; + success = response.data; + error = response.error; + isSuccess = !error; + } + } else { + + // Extract error from statusText and normalize for non-aborts + error = statusText; + if ( status || !statusText ) { + statusText = "error"; + if ( status < 0 ) { + status = 0; + } + } + } + + // Set data for the fake xhr object + jqXHR.status = status; + jqXHR.statusText = ( nativeStatusText || statusText ) + ""; + + // Success/Error + if ( isSuccess ) { + deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] ); + } else { + deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] ); + } + + // Status-dependent callbacks + jqXHR.statusCode( statusCode ); + statusCode = undefined; + + if ( fireGlobals ) { + globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError", + [ jqXHR, s, isSuccess ? success : error ] ); + } + + // Complete + completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] ); + + if ( fireGlobals ) { + globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] ); + + // Handle the global AJAX counter + if ( !( --jQuery.active ) ) { + jQuery.event.trigger( "ajaxStop" ); + } + } + } + + return jqXHR; + }, + + getJSON: function( url, data, callback ) { + return jQuery.get( url, data, callback, "json" ); + }, + + getScript: function( url, callback ) { + return jQuery.get( url, undefined, callback, "script" ); + } +} ); + +jQuery.each( [ "get", "post" ], function( _i, method ) { + jQuery[ method ] = function( url, data, callback, type ) { + + // Shift arguments if data argument was omitted + if ( isFunction( data ) ) { + type = type || callback; + callback = data; + data = undefined; + } + + // The url can be an options object (which then must have .url) + return jQuery.ajax( jQuery.extend( { + url: url, + type: method, + dataType: type, + data: data, + success: callback + }, jQuery.isPlainObject( url ) && url ) ); + }; +} ); + +jQuery.ajaxPrefilter( function( s ) { + var i; + for ( i in s.headers ) { + if ( i.toLowerCase() === "content-type" ) { + s.contentType = s.headers[ i ] || ""; + } + } +} ); + +return jQuery; +} ); diff --git a/node_modules/jquery/src/ajax/jsonp.js b/node_modules/jquery/src/ajax/jsonp.js new file mode 100644 index 00000000..10186dea --- /dev/null +++ b/node_modules/jquery/src/ajax/jsonp.js @@ -0,0 +1,103 @@ +define( [ + "../core", + "../var/isFunction", + "./var/nonce", + "./var/rquery", + "../ajax" +], function( jQuery, isFunction, nonce, rquery ) { + +"use strict"; + +var oldCallbacks = [], + rjsonp = /(=)\?(?=&|$)|\?\?/; + +// Default jsonp settings +jQuery.ajaxSetup( { + jsonp: "callback", + jsonpCallback: function() { + var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce.guid++ ) ); + this[ callback ] = true; + return callback; + } +} ); + +// Detect, normalize options and install callbacks for jsonp requests +jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { + + var callbackName, overwritten, responseContainer, + jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ? + "url" : + typeof s.data === "string" && + ( s.contentType || "" ) + .indexOf( "application/x-www-form-urlencoded" ) === 0 && + rjsonp.test( s.data ) && "data" + ); + + // Handle iff the expected data type is "jsonp" or we have a parameter to set + if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) { + + // Get callback name, remembering preexisting value associated with it + callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ? + s.jsonpCallback() : + s.jsonpCallback; + + // Insert callback into url or form data + if ( jsonProp ) { + s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName ); + } else if ( s.jsonp !== false ) { + s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName; + } + + // Use data converter to retrieve json after script execution + s.converters[ "script json" ] = function() { + if ( !responseContainer ) { + jQuery.error( callbackName + " was not called" ); + } + return responseContainer[ 0 ]; + }; + + // Force json dataType + s.dataTypes[ 0 ] = "json"; + + // Install callback + overwritten = window[ callbackName ]; + window[ callbackName ] = function() { + responseContainer = arguments; + }; + + // Clean-up function (fires after converters) + jqXHR.always( function() { + + // If previous value didn't exist - remove it + if ( overwritten === undefined ) { + jQuery( window ).removeProp( callbackName ); + + // Otherwise restore preexisting value + } else { + window[ callbackName ] = overwritten; + } + + // Save back as free + if ( s[ callbackName ] ) { + + // Make sure that re-using the options doesn't screw things around + s.jsonpCallback = originalSettings.jsonpCallback; + + // Save the callback name for future use + oldCallbacks.push( callbackName ); + } + + // Call if it was a function and we have a response + if ( responseContainer && isFunction( overwritten ) ) { + overwritten( responseContainer[ 0 ] ); + } + + responseContainer = overwritten = undefined; + } ); + + // Delegate to script + return "script"; + } +} ); + +} ); diff --git a/node_modules/jquery/src/ajax/load.js b/node_modules/jquery/src/ajax/load.js new file mode 100644 index 00000000..defdb017 --- /dev/null +++ b/node_modules/jquery/src/ajax/load.js @@ -0,0 +1,77 @@ +define( [ + "../core", + "../core/stripAndCollapse", + "../var/isFunction", + "../core/parseHTML", + "../ajax", + "../traversing", + "../manipulation", + "../selector" +], function( jQuery, stripAndCollapse, isFunction ) { + +"use strict"; + +/** + * Load a url into a page + */ +jQuery.fn.load = function( url, params, callback ) { + var selector, type, response, + self = this, + off = url.indexOf( " " ); + + if ( off > -1 ) { + selector = stripAndCollapse( url.slice( off ) ); + url = url.slice( 0, off ); + } + + // If it's a function + if ( isFunction( params ) ) { + + // We assume that it's the callback + callback = params; + params = undefined; + + // Otherwise, build a param string + } else if ( params && typeof params === "object" ) { + type = "POST"; + } + + // If we have elements to modify, make the request + if ( self.length > 0 ) { + jQuery.ajax( { + url: url, + + // If "type" variable is undefined, then "GET" method will be used. + // Make value of this field explicit since + // user can override it through ajaxSetup method + type: type || "GET", + dataType: "html", + data: params + } ).done( function( responseText ) { + + // Save response for use in complete callback + response = arguments; + + self.html( selector ? + + // If a selector was specified, locate the right elements in a dummy div + // Exclude scripts to avoid IE 'Permission Denied' errors + jQuery( "
" ).append( jQuery.parseHTML( responseText ) ).find( selector ) : + + // Otherwise use the full result + responseText ); + + // If the request succeeds, this function gets "data", "status", "jqXHR" + // but they are ignored because response was set above. + // If it fails, this function gets "jqXHR", "status", "error" + } ).always( callback && function( jqXHR, status ) { + self.each( function() { + callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] ); + } ); + } ); + } + + return this; +}; + +} ); diff --git a/node_modules/jquery/src/ajax/script.js b/node_modules/jquery/src/ajax/script.js new file mode 100644 index 00000000..410c82ca --- /dev/null +++ b/node_modules/jquery/src/ajax/script.js @@ -0,0 +1,74 @@ +define( [ + "../core", + "../var/document", + "../ajax" +], function( jQuery, document ) { + +"use strict"; + +// Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432) +jQuery.ajaxPrefilter( function( s ) { + if ( s.crossDomain ) { + s.contents.script = false; + } +} ); + +// Install script dataType +jQuery.ajaxSetup( { + accepts: { + script: "text/javascript, application/javascript, " + + "application/ecmascript, application/x-ecmascript" + }, + contents: { + script: /\b(?:java|ecma)script\b/ + }, + converters: { + "text script": function( text ) { + jQuery.globalEval( text ); + return text; + } + } +} ); + +// Handle cache's special case and crossDomain +jQuery.ajaxPrefilter( "script", function( s ) { + if ( s.cache === undefined ) { + s.cache = false; + } + if ( s.crossDomain ) { + s.type = "GET"; + } +} ); + +// Bind script tag hack transport +jQuery.ajaxTransport( "script", function( s ) { + + // This transport only deals with cross domain or forced-by-attrs requests + if ( s.crossDomain || s.scriptAttrs ) { + var script, callback; + return { + send: function( _, complete ) { + script = jQuery( "