diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 000000000..f73a88c0b --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,5 @@ +# Contributing to requirejs + +[See the requirejs.org contributing page](https://requirejs.org/docs/contributing.html). + +If you have a question about a specific setup or using particular libraries or file layouts with requirejs, then it is best to ask that on [Stack Overflow using the requirejs tag](https://stackoverflow.com/questions/tagged/requirejs). New issues here are best used for bug reports that have test cases or examples. diff --git a/.gitignore b/.gitignore index 6b9dabf52..6e5147069 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,7 @@ docs/jquery-require-sample/webapp-build/ docs/jquery-require-sample/dist dist/dist-site/ dist/dist-build/ +shrinktest.sh tests/layers/allplugins-require.js tests/packages/optimizing/built/ +node_modules/ diff --git a/.jscsrc b/.jscsrc new file mode 100644 index 000000000..fef17751c --- /dev/null +++ b/.jscsrc @@ -0,0 +1,16 @@ +{ + "preset": "google", + "validateIndentation": 4, + "disallowSpacesInAnonymousFunctionExpression": null, + "disallowMultipleVarDecl": null, + "maximumLineLength": { + "value": 120, + "allowComments": true, + "allowRegex": true + }, + "excludeFiles": [ + "dist/**", + "node_modules/**", + "tests/**" + ] +} diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 000000000..9bce45e49 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,6 @@ +{ + "predef": [ + "console" + ], + "undef": true +} diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..7f1070790 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,4 @@ +sudo: false +language: node_js +node_js: + - 0.12 diff --git a/LICENSE b/LICENSE index ffaf31710..5769475db 100644 --- a/LICENSE +++ b/LICENSE @@ -1,58 +1,45 @@ -RequireJS is released under two licenses: new BSD, and MIT. You may pick the -license that best suits your development needs. The text of both licenses are -provided below. - - -The "New" BSD License: ----------------------- - -Copyright (c) 2010-2011, The Dojo Foundation -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the Dojo Foundation nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - -MIT License ------------ - -Copyright (c) 2010-2011, The Dojo Foundation - -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. +Copyright jQuery Foundation and other contributors, https://jquery.org/ + +This software consists of voluntary contributions made by many +individuals. For exact contribution history, see the revision history +available at https://github.com/requirejs/requirejs + +The following license applies to all parts of this software except as +documented below: + +==== + +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. + +==== + +Copyright and related rights for sample code are waived via CC0. Sample +code is defined as all source code displayed within the prose of the +documentation. + +CC0: http://creativecommons.org/publicdomain/zero/1.0/ + +==== + +Files located in the node_modules directory, and certain utilities used +to build or test the software in the test and dist directories, are +externally maintained libraries used by this software which have their own +licenses; we recommend you read them, as their terms may differ from the +terms above. diff --git a/README.md b/README.md index 4d3f25e37..a39713345 100644 --- a/README.md +++ b/README.md @@ -2,40 +2,44 @@ RequireJS loads plain JavaScript files as well as more defined modules. It is optimized for in-browser use, including in -[a Web Worker](http://requirejs.org/docs/api.html#webworker), but it can be used +[a Web Worker](https://requirejs.org/docs/api.html#webworker), but it can be used in other JavaScript environments, like Rhino and -[Node](http://requirejs.org/docs/node.html). It implements the +[Node](https://requirejs.org/docs/node.html). It implements the [Asynchronous Module](https://github.com/amdjs/amdjs-api/wiki/AMD) API. RequireJS uses plain script tags to load modules/files, so it should allow for easy debugging. It can be used -[simply to load existing JavaScript files](http://requirejs.org/docs/api.html#jsfiles), +[simply to load existing JavaScript files](https://requirejs.org/docs/api.html#jsfiles), so you can add it to your existing project without having to re-write your JavaScript files. -RequireJS includes [an optimization tool](http://requirejs.org/docs/optimization.html) +RequireJS includes [an optimization tool](https://requirejs.org/docs/optimization.html) you can run as part of your packaging steps for deploying your code. The optimization tool can combine and minify your JavaScript files to allow for better performance. If the JavaScript file defines a JavaScript module via -[define()](http://requirejs.org/docs/api.html#define), then there are other benefits -RequireJS can offer: [improvements over traditional CommonJS modules](http://requirejs.org/docs/commonjs.html) -and [loading multiple versions](http://requirejs.org/docs/api.html#multiversion) +[define()](https://requirejs.org/docs/api.html#define), then there are other benefits +RequireJS can offer: [improvements over traditional CommonJS modules](https://requirejs.org/docs/commonjs.html) +and [loading multiple versions](https://requirejs.org/docs/api.html#multiversion) of a module in a page. RequireJS also has a plugin system that supports features like -[i18n string bundles](http://requirejs.org/docs/api.html#i18n), and -[text file dependencies](http://requirejs.org/docs/api.html#text). +[i18n string bundles](https://requirejs.org/docs/api.html#i18n), and +[text file dependencies](https://requirejs.org/docs/api.html#text). RequireJS does not have any dependencies on a JavaScript framework. -It is dual-licensed -- new BSD or MIT. - -The standard require.js file is around 5.5KB when minified via Closure Compiler -and gzipped. RequireJS works in IE 6+, Firefox 2+, Safari 3.2+, Chrome 3+, and Opera 10+. -[Latest Release](http://requirejs.org/docs/download.html) +[Latest Release](https://requirejs.org/docs/download.html) + +## License + +MIT + +## Code of Conduct + +[jQuery Foundation Code of Conduct](https://jquery.org/conduct/). ## Directories @@ -49,3 +53,27 @@ placed outside the tests directory for testing paths that go outside a baseUrl. * **updatesubs.sh**: Updates projects that depend on require.js Assumes the projects are siblings to this directory and have specific names. Useful to copy require.js to dependent projects easily while in development. + +## Tests + +This repo assumes some other repos are checked out as siblings to this repo: + + git clone https://github.com/requirejs/text.git + git clone https://github.com/requirejs/i18n.git + git clone https://github.com/requirejs/domReady.git + git clone https://github.com/requirejs/requirejs.git + +So when the above clones are done, the directory structure should look like: + +* domReady +* i18n +* text +* requirejs (this repo) + +You will need to be connected to the internet because the JSONP and +remoteUrls tests access the internet to complete their tests. + +Serve the directory with these 4 siblings from a web server. It can be a local web server. + +Open requirejs/tests/index.html in all the browsers, click the arrow button to run all +the tests. diff --git a/dist/README.md b/dist/README.md index 4ed2396e0..2a04b97c5 100644 --- a/dist/README.md +++ b/dist/README.md @@ -6,21 +6,33 @@ When doing a release, do the following: * Update files to the new version number: * require.js, both places - * all plugins, both places * docs/download.md: check for nested paths too, add new release section * pre.html * post.html * Update version in x.js in the r.js project if necessary. -* .updatesubs.sh +* ./updatesubs.sh * Check in changes to r.js project. -* Check version of cs plugin, update download.html if necessary. -* Check version of jQuery in the jQuery sample project, update the download.html if necessary. - * Upload change in jQuery project to website even before the current release. -* Commit/push changes -* Commit changes to: - * require-cs: make a new tag if cs.js changed since last release. - * require-jquery - * jqueryui-amd: update the downloadable content if necessary. +* Check in changes to sample projects: + * requirejs/example-jquery-cdn + * requirejs/example-jquery-shim + * requirejs/example-multipage + * requirejs/example-multipage-shim + * requirejs/example-libglobal + * volojs/create-template + * volojs/create-responsive-template + * amodrojs/amodro-trace (UPDATE ESPRIMA(?), parse.js?, run tests too) + +* Tag the requirejs and r.js trees: + * git tag -am "Release 0.0.0" 0.0.0 + * git push --tags + +* UPDATE THE "latest" tags + +* Commit changes to cajon, test + * Rev cajon version + * change package.json + * tag it + * npm publish * Update the requirejs-npm directory * Update version in package.json * Modify bin/r.js to add: #!/usr/bin/env node @@ -30,15 +42,20 @@ When doing a release, do the following: * node (then use repl to do require("requirejs")) * Try a local install. * npm publish (in the requirejs-npm/requirejs directory) - -* Tag the requirejs and r.js trees: - * git tag -am "Release 0.0.0" 0.0.0 - * git push --tags +* Update requirejs-bower + * tag the repo, with "latest" too. + * git push +* Update the requirejs-nuget directory (DO ON WINDOWS) + * Update the require.js and r.js versions in content/Scripts using `volo add -nostamp -f` + * Update Package.nuspec to rev version number. + * .\nuget.exe pack Package.nuspec + * .\nuget.exe push RequireJS.0.0.0.nupkg API_KEY -Source https://www.nuget.org/api/v2/package +* Update alameda, alameda-prim if appropriate Now pull down the tagged version to do a distribution, do this in git/ directory: * rm -rf ./requirejs-dist ./requirejs-build -* git clone git://github.com/jrburke/requirejs.git requirejs-dist +* git clone git://github.com/requirejs/requirejs.git requirejs-dist * cd requirejs-dist * git checkout 0.0.0 * cd dist @@ -55,10 +72,3 @@ To generate the web site: * cd dist-site * zip -r docs.zip ./* * mv docs.zip ../../../requirejs-build/ - -Be sure the links for the CoffeeScript and jQuery Sample project work. - -When done, reset versions to: - -* 0.0.0+ in require.js -* X.X.X in pre.html diff --git a/dist/dist-build.sh b/dist/dist-build.sh index f18b4e788..962e53f00 100755 --- a/dist/dist-build.sh +++ b/dist/dist-build.sh @@ -1,9 +1,5 @@ #!/bin/bash -#@license RequireJS Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved. -#Available via the MIT or new BSD license. -#see: http://github.com/jrburke/requirejs for details - #version should be something like 0.9.0beta or 0.9.0 version=$1 if [ -z $version ]; then @@ -37,6 +33,7 @@ cp $myDir/../require.js $version/comments/require.js # Minify any of the browser-based JS files cd $version/comments -java -jar ../../../r.js/lib/closure/compiler.jar --js require.js --js_output_file ../minified/require.js + +uglifyjs require.js -mc --comments -o ../minified/require.js cd ../../../ diff --git a/dist/dist-site.js b/dist/dist-site.js index 61413b7b7..3bdaa95e3 100644 --- a/dist/dist-site.js +++ b/dist/dist-site.js @@ -1,9 +1,3 @@ -/** - * @license RequireJS Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved. - * Available via the MIT or new BSD license. - * see: http://github.com/jrburke/requirejs for details - */ - /* To run this file: diff --git a/dist/file.js b/dist/file.js index 7db7730b2..256188db9 100644 --- a/dist/file.js +++ b/dist/file.js @@ -1,9 +1,3 @@ -/** - * @license Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved. - * Available via the MIT or new BSD license. - * see: http://github.com/jrburke/requirejs for details - */ - /*jslint plusplus: false, octal:false, strict: false */ /*global require: false, exports: false */ @@ -12,7 +6,7 @@ var fs = require('fs'), file, prop; function mkDir(dir) { - if (!path.existsSync(dir)) { + if (!fs.existsSync(dir)) { fs.mkdirSync(dir, 0777); } } @@ -39,7 +33,7 @@ file = { }, exists: function (fileName) { - return path.existsSync(fileName); + return fs.existsSync(fileName); }, parent: function (fileName) { @@ -82,7 +76,7 @@ file = { regExpInclude = regExpFilters.include || regExpFilters; regExpExclude = regExpFilters.exclude || null; - if (path.existsSync(topDir)) { + if (fs.existsSync(topDir)) { dirFileArray = fs.readdirSync(topDir); for (i = 0; i < dirFileArray.length; i++) { fileName = dirFileArray[i]; @@ -148,14 +142,14 @@ file = { //If onlyCopyNew is true, then compare dates and only copy if the src is newer //than dest. if (onlyCopyNew) { - if (path.existsSync(destFileName) && fs.statSync(destFileName).mtime.getTime() >= fs.statSync(srcFileName).mtime.getTime()) { + if (fs.existsSync(destFileName) && fs.statSync(destFileName).mtime.getTime() >= fs.statSync(srcFileName).mtime.getTime()) { return false; //Boolean } } //Make sure destination dir exists. parentDir = path.dirname(destFileName); - if (!path.existsSync(parentDir)) { + if (!fs.existsSync(parentDir)) { mkFullDir(parentDir); } @@ -195,7 +189,7 @@ file = { //Make sure destination directories exist. parentDir = path.dirname(fileName); - if (!path.existsSync(parentDir)) { + if (!fs.existsSync(parentDir)) { mkFullDir(parentDir); } @@ -205,7 +199,7 @@ file = { deleteFile: function (/*String*/fileName) { //summary: deletes a file or directory if it exists. var files, i, stat; - if (path.existsSync(fileName)) { + if (fs.existsSync(fileName)) { stat = fs.statSync(fileName); if (stat.isDirectory()) { files = fs.readdirSync(fileName); diff --git a/dist/init.js b/dist/init.js index 93b34e8d0..588299dbf 100644 --- a/dist/init.js +++ b/dist/init.js @@ -21,8 +21,15 @@ $(document).ready(function($) { $(window).bind("load resize", function(){ var w = $(window).height(); var h = $("#nav").outerHeight(); - $("#nav").css("position",(w < h) ? ("relative") : ("fixed")); + $("#nav").css("position",(w < h) ? "" : "fixed"); }); + // open / close off-canvas navigation + $('.off-canvas-button').click(function() { + // transform button to close shape + $(this).toggleClass('open'); + // slide in side navigation + $('#nav').toggleClass('open'); + }); // done! }); diff --git a/dist/post.html b/dist/post.html index 3e8b3de79..3c49c16e5 100644 --- a/dist/post.html +++ b/dist/post.html @@ -1,8 +1,8 @@
diff --git a/dist/pre.html b/dist/pre.html index d73e9dea7..4c072afd2 100644 --- a/dist/pre.html +++ b/dist/pre.html @@ -3,17 +3,20 @@This test requires PHP. Rename one.dphpd in this directory to - one.php before trying this test.
- -This test looks at scripts added via appendChild before the page loads. - Do the scripts execute in the order added to the DOM or the order in which - they are received from the network?
- -Normally after page load, IE and WebKit - will evaluate scripts in network receive order, not in DOM order. This test - is checking the behavior before page load.
- -Expected results:
- ONE
- TWO
-
>Actual results: see browser console. IE and WebKit will execute scripts - in network receive order, not in DOM order.
- -