jazz-jss 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +44 -19
- data/bin/jazz +20 -8
- data/lib/jazz/cli.rb +73 -9
- data/lib/jazz/generators/controller/controller.rb +22 -0
- data/lib/jazz/generators/controller/templates/controller.js +38 -0
- data/lib/jazz/generators/helper/helper.rb +22 -0
- data/lib/jazz/generators/helper/templates/helper.js +6 -0
- data/lib/jazz/generators/model/model.rb +50 -0
- data/lib/jazz/generators/model/templates/database.js +14 -0
- data/lib/jazz/generators/model/templates/fixture.js +10 -0
- data/{templates → lib/jazz/generators/model/templates}/model.js +9 -12
- data/lib/jazz/generators/project/project.rb +27 -0
- data/{templates/app_root/development/app/assets/javascripts/application.js → lib/jazz/generators/project/templates/app_root/JEMFILE.js} +0 -0
- data/{templates/app_root/development/app/assets/stylesheets/application.css → lib/jazz/generators/project/templates/app_root/app/assets/javascripts/application.js} +0 -0
- data/{templates/view_create.html → lib/jazz/generators/project/templates/app_root/app/assets/stylesheets/application.sass} +0 -0
- data/lib/jazz/generators/project/templates/app_root/app/controllers/application_controller.js +9 -0
- data/{templates/app_root/development → lib/jazz/generators/project/templates/app_root}/app/helpers/application_helper.js +0 -1
- data/lib/jazz/generators/project/templates/app_root/app/scenarios/application_scenario.js +13 -0
- data/lib/jazz/generators/project/templates/app_root/app/views/layouts/index.handlebars +1 -0
- data/lib/jazz/generators/project/templates/app_root/config/boot.js +23 -0
- data/lib/jazz/generators/project/templates/app_root/config/routes.js +6 -0
- data/{templates/view_index.html → lib/jazz/generators/project/templates/app_root/db/fixtures/touch} +0 -0
- data/lib/jazz/generators/project/templates/app_root/index.html +11 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/_.js +9 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/controller/_.js +1 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/controller/controller.js +22 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/core/_.js +1 -0
- data/{dist/jazz/lib → lib/jazz/generators/project/templates/app_root/lib/jazz/lib/core}/core.js +0 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/database/_.js +3 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/database/database.js +10 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/database/finder.js +41 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/database/modifier.js +10 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/helper/_.js +2 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/helper/helper.js +49 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/helper/underscore.js +13 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/model/_.js +4 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/model/conditional.js +3 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/model/finder.js +21 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/model/model.js +23 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/model/modifier.js +44 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/route/_.js +1 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/route/route.js +115 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/scenario/_.js +2 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/scenario/initialize_scenarios/application.js +3 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/scenario/scenario.js +13 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/view/_.js +1 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/view/view.js +39 -0
- data/{dist/handlebars → lib/jazz/generators/project/templates/app_root/vendor}/handlebars.js +0 -0
- data/{dist/hashchange → lib/jazz/generators/project/templates/app_root/vendor}/hashchange.js +0 -0
- data/{dist/jquery → lib/jazz/generators/project/templates/app_root/vendor}/jquery.js +0 -0
- data/lib/jazz/generators/project/templates/app_root/vendor/simplemodal.js +698 -0
- data/lib/jazz/generators/project/templates/app_root/vendor/tipTip.js +191 -0
- data/{dist/underscore → lib/jazz/generators/project/templates/app_root/vendor}/underscore.js +0 -0
- data/lib/jazz/generators/project/templates/application.js +12 -0
- data/lib/jazz/generators/scaffold/scaffold.rb +73 -0
- data/lib/jazz/generators/scaffold/templates/controller.js +49 -0
- data/lib/jazz/generators/scaffold/templates/database.js +14 -0
- data/lib/jazz/generators/scaffold/templates/fixture.js +10 -0
- data/lib/jazz/generators/scaffold/templates/helper.js +6 -0
- data/lib/jazz/generators/scaffold/templates/model.js +13 -0
- data/lib/jazz/generators/scaffold/templates/scenario.js +7 -0
- data/lib/jazz/generators/scaffold/templates/view_edit.handlebars +6 -0
- data/lib/jazz/generators/scaffold/templates/view_form.handlebars +12 -0
- data/lib/jazz/generators/scaffold/templates/view_index.handlebars +27 -0
- data/lib/jazz/generators/scaffold/templates/view_new.handlebars +5 -0
- data/lib/jazz/generators/scaffold/templates/view_show.handlebars +10 -0
- data/lib/jazz/generators/scenario/scenario.rb +22 -0
- data/lib/jazz/generators/scenario/templates/scenario.js +7 -0
- data/lib/jazz/rack/config.ru +16 -0
- data/lib/jazz/sprockets/templates/handlebars.rb +30 -0
- metadata +120 -234
- data/dist/jazz/lib/controller.js +0 -17
- data/dist/jazz/lib/db.js +0 -41
- data/dist/jazz/lib/helper.js +0 -38
- data/dist/jazz/lib/model.js +0 -95
- data/dist/jazz/lib/route.js +0 -74
- data/dist/jazz/lib/view.js +0 -1
- data/dist/jazz/module.js +0 -15
- data/dist/require/order.js +0 -180
- data/dist/require/require.js +0 -31
- data/dist/require/template.js +0 -98
- data/lib/jazz.rb +0 -12
- data/lib/jazz/app_detector.rb +0 -70
- data/lib/jazz/app_generator.rb +0 -41
- data/lib/jazz/controller_generator.rb +0 -34
- data/lib/jazz/helper_generator.rb +0 -30
- data/lib/jazz/model_generator.rb +0 -27
- data/lib/jazz/scaffold_generator.rb +0 -49
- data/templates/app_root/Rakefile +0 -11
- data/templates/app_root/development/app/controllers/application_controller.js +0 -11
- data/templates/app_root/development/config/glue.js +0 -9
- data/templates/app_root/development/config/routes.js +0 -5
- data/templates/app_root/scripts/build.js +0 -30
- data/templates/app_root/scripts/r.js/LICENSE +0 -58
- data/templates/app_root/scripts/r.js/README.md +0 -177
- data/templates/app_root/scripts/r.js/build/build.js +0 -26
- data/templates/app_root/scripts/r.js/build/buildebug.sh +0 -4
- data/templates/app_root/scripts/r.js/build/example.build.js +0 -296
- data/templates/app_root/scripts/r.js/build/jslib/blank.js +0 -4
- data/templates/app_root/scripts/r.js/build/jslib/build.js +0 -952
- data/templates/app_root/scripts/r.js/build/jslib/commandLine.js +0 -23
- data/templates/app_root/scripts/r.js/build/jslib/commonJs.js +0 -152
- data/templates/app_root/scripts/r.js/build/jslib/env.js +0 -47
- data/templates/app_root/scripts/r.js/build/jslib/lang.js +0 -49
- data/templates/app_root/scripts/r.js/build/jslib/logger.js +0 -58
- data/templates/app_root/scripts/r.js/build/jslib/node.js +0 -106
- data/templates/app_root/scripts/r.js/build/jslib/node/args.js +0 -20
- data/templates/app_root/scripts/r.js/build/jslib/node/file.js +0 -263
- data/templates/app_root/scripts/r.js/build/jslib/node/load.js +0 -17
- data/templates/app_root/scripts/r.js/build/jslib/node/optimize.js +0 -10
- data/templates/app_root/scripts/r.js/build/jslib/node/print.js +0 -16
- data/templates/app_root/scripts/r.js/build/jslib/optimize.js +0 -279
- data/templates/app_root/scripts/r.js/build/jslib/opto.build.js +0 -11
- data/templates/app_root/scripts/r.js/build/jslib/parse.js +0 -590
- data/templates/app_root/scripts/r.js/build/jslib/pragma.js +0 -251
- data/templates/app_root/scripts/r.js/build/jslib/requirePatch.js +0 -286
- data/templates/app_root/scripts/r.js/build/jslib/rhino.js +0 -22
- data/templates/app_root/scripts/r.js/build/jslib/rhino/args.js +0 -21
- data/templates/app_root/scripts/r.js/build/jslib/rhino/file.js +0 -244
- data/templates/app_root/scripts/r.js/build/jslib/rhino/load.js +0 -12
- data/templates/app_root/scripts/r.js/build/jslib/rhino/optimize.js +0 -100
- data/templates/app_root/scripts/r.js/build/jslib/rhino/print.js +0 -12
- data/templates/app_root/scripts/r.js/build/jslib/uglifyjs/README.md +0 -16
- data/templates/app_root/scripts/r.js/build/jslib/uglifyjs/index.js +0 -21
- data/templates/app_root/scripts/r.js/build/jslib/uglifyjs/parse-js.js +0 -1342
- data/templates/app_root/scripts/r.js/build/jslib/uglifyjs/process.js +0 -2005
- data/templates/app_root/scripts/r.js/build/jslib/uglifyjs/squeeze-more.js +0 -55
- data/templates/app_root/scripts/r.js/build/jslib/x.js +0 -243
- data/templates/app_root/scripts/r.js/build/tests/all.js +0 -47
- data/templates/app_root/scripts/r.js/build/tests/allj.sh +0 -3
- data/templates/app_root/scripts/r.js/build/tests/alln.sh +0 -18
- data/templates/app_root/scripts/r.js/build/tests/anonSimple.build.js +0 -7
- data/templates/app_root/scripts/r.js/build/tests/buildUtils.js +0 -19
- data/templates/app_root/scripts/r.js/build/tests/builds.js +0 -489
- data/templates/app_root/scripts/r.js/build/tests/circular.build.js +0 -18
- data/templates/app_root/scripts/r.js/build/tests/convert.js +0 -18
- data/templates/app_root/scripts/r.js/build/tests/css.build.js +0 -6
- data/templates/app_root/scripts/r.js/build/tests/css/common/common.css +0 -4
- data/templates/app_root/scripts/r.js/build/tests/css/master.css +0 -10
- data/templates/app_root/scripts/r.js/build/tests/css/sub/sub1.css +0 -7
- data/templates/app_root/scripts/r.js/build/tests/cssTestCompare.css +0 -13
- data/templates/app_root/scripts/r.js/build/tests/end.frag +0 -3
- data/templates/app_root/scripts/r.js/build/tests/expected/unoExcludeShallow.js +0 -23
- data/templates/app_root/scripts/r.js/build/tests/exports.build.js +0 -12
- data/templates/app_root/scripts/r.js/build/tests/hasTestModule.build.js +0 -10
- data/templates/app_root/scripts/r.js/build/tests/hasTestModule.js +0 -30
- data/templates/app_root/scripts/r.js/build/tests/http/httpBuild.js +0 -70
- data/templates/app_root/scripts/r.js/build/tests/http/main.html +0 -28
- data/templates/app_root/scripts/r.js/build/tests/http/scripts/main.js +0 -18
- data/templates/app_root/scripts/r.js/build/tests/http/scripts/one.js +0 -3
- data/templates/app_root/scripts/r.js/build/tests/http/scripts/three.js +0 -5
- data/templates/app_root/scripts/r.js/build/tests/http/scripts/two.js +0 -7
- data/templates/app_root/scripts/r.js/build/tests/i18n.build.js +0 -17
- data/templates/app_root/scripts/r.js/build/tests/indexBuilder.build.js +0 -8
- data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/a.js +0 -17
- data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/b.js +0 -8
- data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/build.js +0 -6
- data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/c.js +0 -7
- data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/d.js +0 -5
- data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/expected.js +0 -36
- data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/node_modules/amdefine/LICENSE +0 -58
- data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/node_modules/amdefine/amdefine.js +0 -188
- data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/node_modules/amdefine/package.json +0 -21
- data/templates/app_root/scripts/r.js/build/tests/lib/comments/bang.js +0 -10
- data/templates/app_root/scripts/r.js/build/tests/lib/comments/build.js +0 -6
- data/templates/app_root/scripts/r.js/build/tests/lib/comments/expected.js +0 -9
- data/templates/app_root/scripts/r.js/build/tests/lib/comments/license.js +0 -13
- data/templates/app_root/scripts/r.js/build/tests/lib/dotpackage/scripts/app.build.js +0 -15
- data/templates/app_root/scripts/r.js/build/tests/lib/dotpackage/scripts/main-expected.js +0 -13
- data/templates/app_root/scripts/r.js/build/tests/lib/dotpackage/scripts/main.js +0 -7
- data/templates/app_root/scripts/r.js/build/tests/lib/empty/build.js +0 -13
- data/templates/app_root/scripts/r.js/build/tests/lib/empty/expected.js +0 -8
- data/templates/app_root/scripts/r.js/build/tests/lib/empty/main.js +0 -1
- data/templates/app_root/scripts/r.js/build/tests/lib/empty/sub1.js +0 -1
- data/templates/app_root/scripts/r.js/build/tests/lib/empty/sub2.js +0 -1
- data/templates/app_root/scripts/r.js/build/tests/lib/nameInsertion/build.js +0 -6
- data/templates/app_root/scripts/r.js/build/tests/lib/nameInsertion/expected.js +0 -12
- data/templates/app_root/scripts/r.js/build/tests/lib/nameInsertion/main.js +0 -9
- data/templates/app_root/scripts/r.js/build/tests/lib/namespace/build.js +0 -8
- data/templates/app_root/scripts/r.js/build/tests/lib/namespace/expected.js +0 -47
- data/templates/app_root/scripts/r.js/build/tests/lib/namespace/main.js +0 -6
- data/templates/app_root/scripts/r.js/build/tests/lib/namespace/modules/four.js +0 -7
- data/templates/app_root/scripts/r.js/build/tests/lib/namespace/modules/one.js +0 -9
- data/templates/app_root/scripts/r.js/build/tests/lib/namespace/modules/three.js +0 -14
- data/templates/app_root/scripts/r.js/build/tests/lib/namespace/modules/two.js +0 -5
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/a.js +0 -12
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/b.js +0 -3
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/build.js +0 -6
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/buildWithCE.js +0 -7
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/c.js +0 -3
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/d.js +0 -3
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/e.js +0 -3
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/expected-built.js +0 -36
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/expected-builtWithCE.js +0 -42
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/main.js +0 -3
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/top.js +0 -10
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/a.js +0 -3
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/b.js +0 -3
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/build.js +0 -6
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/buildNeedAll.js +0 -9
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/buildNeedB.js +0 -11
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/buildNeedC.js +0 -11
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/buildNeedD.js +0 -11
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/buildNested.js +0 -7
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/c.js +0 -3
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/d.js +0 -3
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-built.js +0 -21
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-builtNeedAll.js +0 -31
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-builtNeedB.js +0 -24
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-builtNeedC.js +0 -24
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-builtNeedD.js +0 -25
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-builtNested.js +0 -31
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/main.js +0 -17
- data/templates/app_root/scripts/r.js/build/tests/lib/plugins/build.js +0 -6
- data/templates/app_root/scripts/r.js/build/tests/lib/plugins/converter.js +0 -11
- data/templates/app_root/scripts/r.js/build/tests/lib/plugins/main.js +0 -6
- data/templates/app_root/scripts/r.js/build/tests/lib/plugins/plug.js +0 -29
- data/templates/app_root/scripts/r.js/build/tests/lib/plugins/util.js +0 -7
- data/templates/app_root/scripts/r.js/build/tests/nameOnly.build.js +0 -10
- data/templates/app_root/scripts/r.js/build/tests/nodeAll.js +0 -3
- data/templates/app_root/scripts/r.js/build/tests/nodeOptimize.js +0 -12
- data/templates/app_root/scripts/r.js/build/tests/nodeOptimizeNoCallback.js +0 -10
- data/templates/app_root/scripts/r.js/build/tests/order.build.js +0 -16
- data/templates/app_root/scripts/r.js/build/tests/override/override.js +0 -36
- data/templates/app_root/scripts/r.js/build/tests/packages.build.js +0 -59
- data/templates/app_root/scripts/r.js/build/tests/parse.js +0 -103
- data/templates/app_root/scripts/r.js/build/tests/simple.build.js +0 -13
- data/templates/app_root/scripts/r.js/build/tests/simpleNamespace.build.js +0 -17
- data/templates/app_root/scripts/r.js/build/tests/start.frag +0 -4
- data/templates/app_root/scripts/r.js/build/tests/text.build.js +0 -16
- data/templates/app_root/scripts/r.js/build/tests/textExclude.build.js +0 -16
- data/templates/app_root/scripts/r.js/dist.js +0 -95
- data/templates/app_root/scripts/r.js/dist/README.md +0 -6
- data/templates/app_root/scripts/r.js/dist/r-1.0.0.js +0 -9042
- data/templates/app_root/scripts/r.js/dist/r-edge.js +0 -9191
- data/templates/app_root/scripts/r.js/dist/r.js +0 -9099
- data/templates/app_root/scripts/r.js/lib/closure/COPYING +0 -202
- data/templates/app_root/scripts/r.js/lib/closure/README +0 -292
- data/templates/app_root/scripts/r.js/lib/closure/compiler.jar +0 -0
- data/templates/app_root/scripts/r.js/lib/rhino/LICENSE +0 -4
- data/templates/app_root/scripts/r.js/lib/rhino/js.jar +0 -0
- data/templates/app_root/scripts/r.js/require.js +0 -1952
- data/templates/app_root/scripts/r.js/tasks.txt +0 -2
- data/templates/app_root/scripts/r.js/tests/all.js +0 -49
- data/templates/app_root/scripts/r.js/tests/allNode.js +0 -3
- data/templates/app_root/scripts/r.js/tests/allj.sh +0 -1
- data/templates/app_root/scripts/r.js/tests/alln.sh +0 -2
- data/templates/app_root/scripts/r.js/tests/alpha.js +0 -3
- data/templates/app_root/scripts/r.js/tests/beta.js +0 -6
- data/templates/app_root/scripts/r.js/tests/doh/LICENSE +0 -195
- data/templates/app_root/scripts/r.js/tests/doh/README +0 -12
- data/templates/app_root/scripts/r.js/tests/doh/_browserRunner.js +0 -855
- data/templates/app_root/scripts/r.js/tests/doh/_nodeRunner.js +0 -20
- data/templates/app_root/scripts/r.js/tests/doh/_rhinoRunner.js +0 -17
- data/templates/app_root/scripts/r.js/tests/doh/_sounds/LICENSE +0 -10
- data/templates/app_root/scripts/r.js/tests/doh/_sounds/doh.wav +0 -0
- data/templates/app_root/scripts/r.js/tests/doh/_sounds/dohaaa.wav +0 -0
- data/templates/app_root/scripts/r.js/tests/doh/_sounds/woohoo.wav +0 -0
- data/templates/app_root/scripts/r.js/tests/doh/runner.html +0 -316
- data/templates/app_root/scripts/r.js/tests/doh/runner.js +0 -1499
- data/templates/app_root/scripts/r.js/tests/doh/runner.sh +0 -3
- data/templates/app_root/scripts/r.js/tests/doh/small_logo.png +0 -0
- data/templates/app_root/scripts/r.js/tests/node/canvasTest.js +0 -39
- data/templates/app_root/scripts/r.js/tests/node/embedded/README.md +0 -15
- data/templates/app_root/scripts/r.js/tests/node/embedded/coffee/foo.coffee +0 -1
- data/templates/app_root/scripts/r.js/tests/node/embedded/main.js +0 -13
- data/templates/app_root/scripts/r.js/tests/node/embedded/scripts/bar.js +0 -13
- data/templates/app_root/scripts/r.js/tests/node/index.js +0 -11
- data/templates/app_root/scripts/r.js/tests/node/tests/alpha/foo.js +0 -6
- data/templates/app_root/scripts/r.js/tests/node/tests/alpha/hello.html +0 -9
- data/templates/app_root/scripts/r.js/tests/node/tests/foo.js +0 -3
- data/templates/app_root/scripts/r.js/tests/node/tests/server.js +0 -11
- data/templates/app_root/scripts/r.js/tests/relative.js +0 -10
- data/templates/app_root/scripts/r.js/tests/sub/betaSub.js +0 -3
- data/templates/application.js +0 -7
- data/templates/boot.js +0 -42
- data/templates/controller.js +0 -19
- data/templates/db.js +0 -14
- data/templates/helper.js +0 -9
- data/templates/index.html +0 -9
- data/templates/scaffold_controller.js +0 -19
- data/templates/view_show.html +0 -0
- data/templates/view_update.html +0 -0
Binary file
|
Binary file
|
@@ -1,1952 +0,0 @@
|
|
1
|
-
/** vim: et:ts=4:sw=4:sts=4
|
2
|
-
* @license RequireJS 1.0.2 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
|
3
|
-
* Available via the MIT or new BSD license.
|
4
|
-
* see: http://github.com/jrburke/requirejs for details
|
5
|
-
*/
|
6
|
-
/*jslint strict: false, plusplus: false, sub: true */
|
7
|
-
/*global window: false, navigator: false, document: false, importScripts: false,
|
8
|
-
jQuery: false, clearInterval: false, setInterval: false, self: false,
|
9
|
-
setTimeout: false, opera: false */
|
10
|
-
|
11
|
-
var requirejs, require, define;
|
12
|
-
(function () {
|
13
|
-
//Change this version number for each release.
|
14
|
-
var version = "1.0.2",
|
15
|
-
commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
|
16
|
-
cjsRequireRegExp = /require\(\s*["']([^'"\s]+)["']\s*\)/g,
|
17
|
-
currDirRegExp = /^\.\//,
|
18
|
-
jsSuffixRegExp = /\.js$/,
|
19
|
-
ostring = Object.prototype.toString,
|
20
|
-
ap = Array.prototype,
|
21
|
-
aps = ap.slice,
|
22
|
-
apsp = ap.splice,
|
23
|
-
isBrowser = !!(typeof window !== "undefined" && navigator && document),
|
24
|
-
isWebWorker = !isBrowser && typeof importScripts !== "undefined",
|
25
|
-
//PS3 indicates loaded and complete, but need to wait for complete
|
26
|
-
//specifically. Sequence is "loading", "loaded", execution,
|
27
|
-
// then "complete". The UA check is unfortunate, but not sure how
|
28
|
-
//to feature test w/o causing perf issues.
|
29
|
-
readyRegExp = isBrowser && navigator.platform === 'PLAYSTATION 3' ?
|
30
|
-
/^complete$/ : /^(complete|loaded)$/,
|
31
|
-
defContextName = "_",
|
32
|
-
//Oh the tragedy, detecting opera. See the usage of isOpera for reason.
|
33
|
-
isOpera = typeof opera !== "undefined" && opera.toString() === "[object Opera]",
|
34
|
-
empty = {},
|
35
|
-
contexts = {},
|
36
|
-
globalDefQueue = [],
|
37
|
-
interactiveScript = null,
|
38
|
-
checkLoadedDepth = 0,
|
39
|
-
useInteractive = false,
|
40
|
-
req, cfg = {}, currentlyAddingScript, s, head, baseElement, scripts, script,
|
41
|
-
src, subPath, mainScript, dataMain, i, ctx, jQueryCheck, checkLoadedTimeoutId;
|
42
|
-
|
43
|
-
function isFunction(it) {
|
44
|
-
return ostring.call(it) === "[object Function]";
|
45
|
-
}
|
46
|
-
|
47
|
-
function isArray(it) {
|
48
|
-
return ostring.call(it) === "[object Array]";
|
49
|
-
}
|
50
|
-
|
51
|
-
/**
|
52
|
-
* Simple function to mix in properties from source into target,
|
53
|
-
* but only if target does not already have a property of the same name.
|
54
|
-
* This is not robust in IE for transferring methods that match
|
55
|
-
* Object.prototype names, but the uses of mixin here seem unlikely to
|
56
|
-
* trigger a problem related to that.
|
57
|
-
*/
|
58
|
-
function mixin(target, source, force) {
|
59
|
-
for (var prop in source) {
|
60
|
-
if (!(prop in empty) && (!(prop in target) || force)) {
|
61
|
-
target[prop] = source[prop];
|
62
|
-
}
|
63
|
-
}
|
64
|
-
return req;
|
65
|
-
}
|
66
|
-
|
67
|
-
/**
|
68
|
-
* Constructs an error with a pointer to an URL with more information.
|
69
|
-
* @param {String} id the error ID that maps to an ID on a web page.
|
70
|
-
* @param {String} message human readable error.
|
71
|
-
* @param {Error} [err] the original error, if there is one.
|
72
|
-
*
|
73
|
-
* @returns {Error}
|
74
|
-
*/
|
75
|
-
function makeError(id, msg, err) {
|
76
|
-
var e = new Error(msg + '\nhttp://requirejs.org/docs/errors.html#' + id);
|
77
|
-
if (err) {
|
78
|
-
e.originalError = err;
|
79
|
-
}
|
80
|
-
return e;
|
81
|
-
}
|
82
|
-
|
83
|
-
/**
|
84
|
-
* Used to set up package paths from a packagePaths or packages config object.
|
85
|
-
* @param {Object} pkgs the object to store the new package config
|
86
|
-
* @param {Array} currentPackages an array of packages to configure
|
87
|
-
* @param {String} [dir] a prefix dir to use.
|
88
|
-
*/
|
89
|
-
function configurePackageDir(pkgs, currentPackages, dir) {
|
90
|
-
var i, location, pkgObj;
|
91
|
-
|
92
|
-
for (i = 0; (pkgObj = currentPackages[i]); i++) {
|
93
|
-
pkgObj = typeof pkgObj === "string" ? { name: pkgObj } : pkgObj;
|
94
|
-
location = pkgObj.location;
|
95
|
-
|
96
|
-
//Add dir to the path, but avoid paths that start with a slash
|
97
|
-
//or have a colon (indicates a protocol)
|
98
|
-
if (dir && (!location || (location.indexOf("/") !== 0 && location.indexOf(":") === -1))) {
|
99
|
-
location = dir + "/" + (location || pkgObj.name);
|
100
|
-
}
|
101
|
-
|
102
|
-
//Create a brand new object on pkgs, since currentPackages can
|
103
|
-
//be passed in again, and config.pkgs is the internal transformed
|
104
|
-
//state for all package configs.
|
105
|
-
pkgs[pkgObj.name] = {
|
106
|
-
name: pkgObj.name,
|
107
|
-
location: location || pkgObj.name,
|
108
|
-
//Remove leading dot in main, so main paths are normalized,
|
109
|
-
//and remove any trailing .js, since different package
|
110
|
-
//envs have different conventions: some use a module name,
|
111
|
-
//some use a file name.
|
112
|
-
main: (pkgObj.main || "main")
|
113
|
-
.replace(currDirRegExp, '')
|
114
|
-
.replace(jsSuffixRegExp, '')
|
115
|
-
};
|
116
|
-
}
|
117
|
-
}
|
118
|
-
|
119
|
-
/**
|
120
|
-
* jQuery 1.4.3-1.5.x use a readyWait/ready() pairing to hold DOM
|
121
|
-
* ready callbacks, but jQuery 1.6 supports a holdReady() API instead.
|
122
|
-
* At some point remove the readyWait/ready() support and just stick
|
123
|
-
* with using holdReady.
|
124
|
-
*/
|
125
|
-
function jQueryHoldReady($, shouldHold) {
|
126
|
-
if ($.holdReady) {
|
127
|
-
$.holdReady(shouldHold);
|
128
|
-
} else if (shouldHold) {
|
129
|
-
$.readyWait += 1;
|
130
|
-
} else {
|
131
|
-
$.ready(true);
|
132
|
-
}
|
133
|
-
}
|
134
|
-
|
135
|
-
if (typeof define !== "undefined") {
|
136
|
-
//If a define is already in play via another AMD loader,
|
137
|
-
//do not overwrite.
|
138
|
-
return;
|
139
|
-
}
|
140
|
-
|
141
|
-
if (typeof requirejs !== "undefined") {
|
142
|
-
if (isFunction(requirejs)) {
|
143
|
-
//Do not overwrite and existing requirejs instance.
|
144
|
-
return;
|
145
|
-
} else {
|
146
|
-
cfg = requirejs;
|
147
|
-
requirejs = undefined;
|
148
|
-
}
|
149
|
-
}
|
150
|
-
|
151
|
-
//Allow for a require config object
|
152
|
-
if (typeof require !== "undefined" && !isFunction(require)) {
|
153
|
-
//assume it is a config object.
|
154
|
-
cfg = require;
|
155
|
-
require = undefined;
|
156
|
-
}
|
157
|
-
|
158
|
-
/**
|
159
|
-
* Creates a new context for use in require and define calls.
|
160
|
-
* Handle most of the heavy lifting. Do not want to use an object
|
161
|
-
* with prototype here to avoid using "this" in require, in case it
|
162
|
-
* needs to be used in more super secure envs that do not want this.
|
163
|
-
* Also there should not be that many contexts in the page. Usually just
|
164
|
-
* one for the default context, but could be extra for multiversion cases
|
165
|
-
* or if a package needs a special context for a dependency that conflicts
|
166
|
-
* with the standard context.
|
167
|
-
*/
|
168
|
-
function newContext(contextName) {
|
169
|
-
var context, resume,
|
170
|
-
config = {
|
171
|
-
waitSeconds: 7,
|
172
|
-
baseUrl: "./",
|
173
|
-
paths: {},
|
174
|
-
pkgs: {},
|
175
|
-
catchError: {}
|
176
|
-
},
|
177
|
-
defQueue = [],
|
178
|
-
specified = {
|
179
|
-
"require": true,
|
180
|
-
"exports": true,
|
181
|
-
"module": true
|
182
|
-
},
|
183
|
-
urlMap = {},
|
184
|
-
defined = {},
|
185
|
-
loaded = {},
|
186
|
-
waiting = {},
|
187
|
-
waitAry = [],
|
188
|
-
urlFetched = {},
|
189
|
-
managerCounter = 0,
|
190
|
-
managerCallbacks = {},
|
191
|
-
plugins = {},
|
192
|
-
//Used to indicate which modules in a build scenario
|
193
|
-
//need to be full executed.
|
194
|
-
needFullExec = {},
|
195
|
-
fullExec = {},
|
196
|
-
resumeDepth = 0;
|
197
|
-
|
198
|
-
/**
|
199
|
-
* Trims the . and .. from an array of path segments.
|
200
|
-
* It will keep a leading path segment if a .. will become
|
201
|
-
* the first path segment, to help with module name lookups,
|
202
|
-
* which act like paths, but can be remapped. But the end result,
|
203
|
-
* all paths that use this function should look normalized.
|
204
|
-
* NOTE: this method MODIFIES the input array.
|
205
|
-
* @param {Array} ary the array of path segments.
|
206
|
-
*/
|
207
|
-
function trimDots(ary) {
|
208
|
-
var i, part;
|
209
|
-
for (i = 0; (part = ary[i]); i++) {
|
210
|
-
if (part === ".") {
|
211
|
-
ary.splice(i, 1);
|
212
|
-
i -= 1;
|
213
|
-
} else if (part === "..") {
|
214
|
-
if (i === 1 && (ary[2] === '..' || ary[0] === '..')) {
|
215
|
-
//End of the line. Keep at least one non-dot
|
216
|
-
//path segment at the front so it can be mapped
|
217
|
-
//correctly to disk. Otherwise, there is likely
|
218
|
-
//no path mapping for a path starting with '..'.
|
219
|
-
//This can still fail, but catches the most reasonable
|
220
|
-
//uses of ..
|
221
|
-
break;
|
222
|
-
} else if (i > 0) {
|
223
|
-
ary.splice(i - 1, 2);
|
224
|
-
i -= 2;
|
225
|
-
}
|
226
|
-
}
|
227
|
-
}
|
228
|
-
}
|
229
|
-
|
230
|
-
/**
|
231
|
-
* Given a relative module name, like ./something, normalize it to
|
232
|
-
* a real name that can be mapped to a path.
|
233
|
-
* @param {String} name the relative name
|
234
|
-
* @param {String} baseName a real name that the name arg is relative
|
235
|
-
* to.
|
236
|
-
* @returns {String} normalized name
|
237
|
-
*/
|
238
|
-
function normalize(name, baseName) {
|
239
|
-
var pkgName, pkgConfig;
|
240
|
-
|
241
|
-
//Adjust any relative paths.
|
242
|
-
if (name && name.charAt(0) === ".") {
|
243
|
-
//If have a base name, try to normalize against it,
|
244
|
-
//otherwise, assume it is a top-level require that will
|
245
|
-
//be relative to baseUrl in the end.
|
246
|
-
if (baseName) {
|
247
|
-
if (config.pkgs[baseName]) {
|
248
|
-
//If the baseName is a package name, then just treat it as one
|
249
|
-
//name to concat the name with.
|
250
|
-
baseName = [baseName];
|
251
|
-
} else {
|
252
|
-
//Convert baseName to array, and lop off the last part,
|
253
|
-
//so that . matches that "directory" and not name of the baseName's
|
254
|
-
//module. For instance, baseName of "one/two/three", maps to
|
255
|
-
//"one/two/three.js", but we want the directory, "one/two" for
|
256
|
-
//this normalization.
|
257
|
-
baseName = baseName.split("/");
|
258
|
-
baseName = baseName.slice(0, baseName.length - 1);
|
259
|
-
}
|
260
|
-
|
261
|
-
name = baseName.concat(name.split("/"));
|
262
|
-
trimDots(name);
|
263
|
-
|
264
|
-
//Some use of packages may use a . path to reference the
|
265
|
-
//"main" module name, so normalize for that.
|
266
|
-
pkgConfig = config.pkgs[(pkgName = name[0])];
|
267
|
-
name = name.join("/");
|
268
|
-
if (pkgConfig && name === pkgName + '/' + pkgConfig.main) {
|
269
|
-
name = pkgName;
|
270
|
-
}
|
271
|
-
} else if (name.indexOf("./") === 0) {
|
272
|
-
// No baseName, so this is ID is resolved relative
|
273
|
-
// to baseUrl, pull off the leading dot.
|
274
|
-
name = name.substring(2);
|
275
|
-
}
|
276
|
-
}
|
277
|
-
return name;
|
278
|
-
}
|
279
|
-
|
280
|
-
/**
|
281
|
-
* Creates a module mapping that includes plugin prefix, module
|
282
|
-
* name, and path. If parentModuleMap is provided it will
|
283
|
-
* also normalize the name via require.normalize()
|
284
|
-
*
|
285
|
-
* @param {String} name the module name
|
286
|
-
* @param {String} [parentModuleMap] parent module map
|
287
|
-
* for the module name, used to resolve relative names.
|
288
|
-
*
|
289
|
-
* @returns {Object}
|
290
|
-
*/
|
291
|
-
function makeModuleMap(name, parentModuleMap) {
|
292
|
-
var index = name ? name.indexOf("!") : -1,
|
293
|
-
prefix = null,
|
294
|
-
parentName = parentModuleMap ? parentModuleMap.name : null,
|
295
|
-
originalName = name,
|
296
|
-
normalizedName, url, pluginModule;
|
297
|
-
|
298
|
-
if (index !== -1) {
|
299
|
-
prefix = name.substring(0, index);
|
300
|
-
name = name.substring(index + 1, name.length);
|
301
|
-
}
|
302
|
-
|
303
|
-
if (prefix) {
|
304
|
-
prefix = normalize(prefix, parentName);
|
305
|
-
}
|
306
|
-
|
307
|
-
//Account for relative paths if there is a base name.
|
308
|
-
if (name) {
|
309
|
-
if (prefix) {
|
310
|
-
pluginModule = defined[prefix];
|
311
|
-
if (pluginModule && pluginModule.normalize) {
|
312
|
-
//Plugin is loaded, use its normalize method.
|
313
|
-
normalizedName = pluginModule.normalize(name, function (name) {
|
314
|
-
return normalize(name, parentName);
|
315
|
-
});
|
316
|
-
} else {
|
317
|
-
normalizedName = normalize(name, parentName);
|
318
|
-
}
|
319
|
-
} else {
|
320
|
-
//A regular module.
|
321
|
-
normalizedName = normalize(name, parentName);
|
322
|
-
|
323
|
-
url = urlMap[normalizedName];
|
324
|
-
if (!url) {
|
325
|
-
//Calculate url for the module, if it has a name.
|
326
|
-
url = context.nameToUrl(normalizedName, null, parentModuleMap);
|
327
|
-
|
328
|
-
//Store the URL mapping for later.
|
329
|
-
urlMap[normalizedName] = url;
|
330
|
-
}
|
331
|
-
}
|
332
|
-
}
|
333
|
-
|
334
|
-
return {
|
335
|
-
prefix: prefix,
|
336
|
-
name: normalizedName,
|
337
|
-
parentMap: parentModuleMap,
|
338
|
-
url: url,
|
339
|
-
originalName: originalName,
|
340
|
-
fullName: prefix ? prefix + "!" + (normalizedName || '') : normalizedName
|
341
|
-
};
|
342
|
-
}
|
343
|
-
|
344
|
-
/**
|
345
|
-
* Determine if priority loading is done. If so clear the priorityWait
|
346
|
-
*/
|
347
|
-
function isPriorityDone() {
|
348
|
-
var priorityDone = true,
|
349
|
-
priorityWait = config.priorityWait,
|
350
|
-
priorityName, i;
|
351
|
-
if (priorityWait) {
|
352
|
-
for (i = 0; (priorityName = priorityWait[i]); i++) {
|
353
|
-
if (!loaded[priorityName]) {
|
354
|
-
priorityDone = false;
|
355
|
-
break;
|
356
|
-
}
|
357
|
-
}
|
358
|
-
if (priorityDone) {
|
359
|
-
delete config.priorityWait;
|
360
|
-
}
|
361
|
-
}
|
362
|
-
return priorityDone;
|
363
|
-
}
|
364
|
-
|
365
|
-
function makeContextModuleFunc(func, relModuleMap, enableBuildCallback) {
|
366
|
-
return function () {
|
367
|
-
//A version of a require function that passes a moduleName
|
368
|
-
//value for items that may need to
|
369
|
-
//look up paths relative to the moduleName
|
370
|
-
var args = aps.call(arguments, 0), lastArg;
|
371
|
-
if (enableBuildCallback &&
|
372
|
-
isFunction((lastArg = args[args.length - 1]))) {
|
373
|
-
lastArg.__requireJsBuild = true;
|
374
|
-
}
|
375
|
-
args.push(relModuleMap);
|
376
|
-
return func.apply(null, args);
|
377
|
-
};
|
378
|
-
}
|
379
|
-
|
380
|
-
/**
|
381
|
-
* Helper function that creates a require function object to give to
|
382
|
-
* modules that ask for it as a dependency. It needs to be specific
|
383
|
-
* per module because of the implication of path mappings that may
|
384
|
-
* need to be relative to the module name.
|
385
|
-
*/
|
386
|
-
function makeRequire(relModuleMap, enableBuildCallback) {
|
387
|
-
var modRequire = makeContextModuleFunc(context.require, relModuleMap, enableBuildCallback);
|
388
|
-
|
389
|
-
mixin(modRequire, {
|
390
|
-
nameToUrl: makeContextModuleFunc(context.nameToUrl, relModuleMap),
|
391
|
-
toUrl: makeContextModuleFunc(context.toUrl, relModuleMap),
|
392
|
-
defined: makeContextModuleFunc(context.requireDefined, relModuleMap),
|
393
|
-
specified: makeContextModuleFunc(context.requireSpecified, relModuleMap),
|
394
|
-
isBrowser: req.isBrowser
|
395
|
-
});
|
396
|
-
return modRequire;
|
397
|
-
}
|
398
|
-
|
399
|
-
/*
|
400
|
-
* Queues a dependency for checking after the loader is out of a
|
401
|
-
* "paused" state, for example while a script file is being loaded
|
402
|
-
* in the browser, where it may have many modules defined in it.
|
403
|
-
*/
|
404
|
-
function queueDependency(manager) {
|
405
|
-
context.paused.push(manager);
|
406
|
-
}
|
407
|
-
|
408
|
-
function execManager(manager) {
|
409
|
-
var i, ret, err, errFile, errModuleTree,
|
410
|
-
cb = manager.callback,
|
411
|
-
map = manager.map,
|
412
|
-
fullName = map.fullName,
|
413
|
-
args = manager.deps,
|
414
|
-
listeners = manager.listeners,
|
415
|
-
cjsModule;
|
416
|
-
|
417
|
-
//Call the callback to define the module, if necessary.
|
418
|
-
if (cb && isFunction(cb)) {
|
419
|
-
if (config.catchError.define) {
|
420
|
-
try {
|
421
|
-
ret = req.execCb(fullName, manager.callback, args, defined[fullName]);
|
422
|
-
} catch (e) {
|
423
|
-
err = e;
|
424
|
-
}
|
425
|
-
} else {
|
426
|
-
ret = req.execCb(fullName, manager.callback, args, defined[fullName]);
|
427
|
-
}
|
428
|
-
|
429
|
-
if (fullName) {
|
430
|
-
//If setting exports via "module" is in play,
|
431
|
-
//favor that over return value and exports. After that,
|
432
|
-
//favor a non-undefined return value over exports use.
|
433
|
-
cjsModule = manager.cjsModule;
|
434
|
-
if (cjsModule &&
|
435
|
-
cjsModule.exports !== undefined &&
|
436
|
-
//Make sure it is not already the exports value
|
437
|
-
cjsModule.exports !== defined[fullName]) {
|
438
|
-
ret = defined[fullName] = manager.cjsModule.exports;
|
439
|
-
} else if (ret === undefined && manager.usingExports) {
|
440
|
-
//exports already set the defined value.
|
441
|
-
ret = defined[fullName];
|
442
|
-
} else {
|
443
|
-
//Use the return value from the function.
|
444
|
-
defined[fullName] = ret;
|
445
|
-
//If this module needed full execution in a build
|
446
|
-
//environment, mark that now.
|
447
|
-
if (needFullExec[fullName]) {
|
448
|
-
fullExec[fullName] = true;
|
449
|
-
}
|
450
|
-
}
|
451
|
-
}
|
452
|
-
} else if (fullName) {
|
453
|
-
//May just be an object definition for the module. Only
|
454
|
-
//worry about defining if have a module name.
|
455
|
-
ret = defined[fullName] = cb;
|
456
|
-
|
457
|
-
//If this module needed full execution in a build
|
458
|
-
//environment, mark that now.
|
459
|
-
if (needFullExec[fullName]) {
|
460
|
-
fullExec[fullName] = true;
|
461
|
-
}
|
462
|
-
}
|
463
|
-
|
464
|
-
//Clean up waiting. Do this before error calls, and before
|
465
|
-
//calling back listeners, so that bookkeeping is correct
|
466
|
-
//in the event of an error and error is reported in correct order,
|
467
|
-
//since the listeners will likely have errors if the
|
468
|
-
//onError function does not throw.
|
469
|
-
if (waiting[manager.id]) {
|
470
|
-
delete waiting[manager.id];
|
471
|
-
manager.isDone = true;
|
472
|
-
context.waitCount -= 1;
|
473
|
-
if (context.waitCount === 0) {
|
474
|
-
//Clear the wait array used for cycles.
|
475
|
-
waitAry = [];
|
476
|
-
}
|
477
|
-
}
|
478
|
-
|
479
|
-
//Do not need to track manager callback now that it is defined.
|
480
|
-
delete managerCallbacks[fullName];
|
481
|
-
|
482
|
-
//Allow instrumentation like the optimizer to know the order
|
483
|
-
//of modules executed and their dependencies.
|
484
|
-
if (req.onResourceLoad && !manager.placeholder) {
|
485
|
-
req.onResourceLoad(context, map, manager.depArray);
|
486
|
-
}
|
487
|
-
|
488
|
-
if (err) {
|
489
|
-
errFile = (fullName ? makeModuleMap(fullName).url : '') ||
|
490
|
-
err.fileName || err.sourceURL;
|
491
|
-
errModuleTree = err.moduleTree;
|
492
|
-
err = makeError('defineerror', 'Error evaluating ' +
|
493
|
-
'module "' + fullName + '" at location "' +
|
494
|
-
errFile + '":\n' +
|
495
|
-
err + '\nfileName:' + errFile +
|
496
|
-
'\nlineNumber: ' + (err.lineNumber || err.line), err);
|
497
|
-
err.moduleName = fullName;
|
498
|
-
err.moduleTree = errModuleTree;
|
499
|
-
return req.onError(err);
|
500
|
-
}
|
501
|
-
|
502
|
-
//Let listeners know of this manager's value.
|
503
|
-
for (i = 0; (cb = listeners[i]); i++) {
|
504
|
-
cb(ret);
|
505
|
-
}
|
506
|
-
|
507
|
-
return undefined;
|
508
|
-
}
|
509
|
-
|
510
|
-
/**
|
511
|
-
* Helper that creates a callack function that is called when a dependency
|
512
|
-
* is ready, and sets the i-th dependency for the manager as the
|
513
|
-
* value passed to the callback generated by this function.
|
514
|
-
*/
|
515
|
-
function makeArgCallback(manager, i) {
|
516
|
-
return function (value) {
|
517
|
-
//Only do the work if it has not been done
|
518
|
-
//already for a dependency. Cycle breaking
|
519
|
-
//logic in forceExec could mean this function
|
520
|
-
//is called more than once for a given dependency.
|
521
|
-
if (!manager.depDone[i]) {
|
522
|
-
manager.depDone[i] = true;
|
523
|
-
manager.deps[i] = value;
|
524
|
-
manager.depCount -= 1;
|
525
|
-
if (!manager.depCount) {
|
526
|
-
//All done, execute!
|
527
|
-
execManager(manager);
|
528
|
-
}
|
529
|
-
}
|
530
|
-
};
|
531
|
-
}
|
532
|
-
|
533
|
-
function callPlugin(pluginName, depManager) {
|
534
|
-
var map = depManager.map,
|
535
|
-
fullName = map.fullName,
|
536
|
-
name = map.name,
|
537
|
-
plugin = plugins[pluginName] ||
|
538
|
-
(plugins[pluginName] = defined[pluginName]),
|
539
|
-
load;
|
540
|
-
|
541
|
-
//No need to continue if the manager is already
|
542
|
-
//in the process of loading.
|
543
|
-
if (depManager.loading) {
|
544
|
-
return;
|
545
|
-
}
|
546
|
-
depManager.loading = true;
|
547
|
-
|
548
|
-
load = function (ret) {
|
549
|
-
depManager.callback = function () {
|
550
|
-
return ret;
|
551
|
-
};
|
552
|
-
execManager(depManager);
|
553
|
-
|
554
|
-
loaded[depManager.id] = true;
|
555
|
-
|
556
|
-
//The loading of this plugin
|
557
|
-
//might have placed other things
|
558
|
-
//in the paused queue. In particular,
|
559
|
-
//a loader plugin that depends on
|
560
|
-
//a different plugin loaded resource.
|
561
|
-
resume();
|
562
|
-
};
|
563
|
-
|
564
|
-
//Allow plugins to load other code without having to know the
|
565
|
-
//context or how to "complete" the load.
|
566
|
-
load.fromText = function (moduleName, text) {
|
567
|
-
/*jslint evil: true */
|
568
|
-
var hasInteractive = useInteractive;
|
569
|
-
|
570
|
-
//Indicate a the module is in process of loading.
|
571
|
-
loaded[moduleName] = false;
|
572
|
-
context.scriptCount += 1;
|
573
|
-
|
574
|
-
//Indicate this is not a "real" module, so do not track it
|
575
|
-
//for builds, it does not map to a real file.
|
576
|
-
context.fake[moduleName] = true;
|
577
|
-
|
578
|
-
//Turn off interactive script matching for IE for any define
|
579
|
-
//calls in the text, then turn it back on at the end.
|
580
|
-
if (hasInteractive) {
|
581
|
-
useInteractive = false;
|
582
|
-
}
|
583
|
-
|
584
|
-
req.exec(text);
|
585
|
-
|
586
|
-
if (hasInteractive) {
|
587
|
-
useInteractive = true;
|
588
|
-
}
|
589
|
-
|
590
|
-
//Support anonymous modules.
|
591
|
-
context.completeLoad(moduleName);
|
592
|
-
};
|
593
|
-
|
594
|
-
//No need to continue if the plugin value has already been
|
595
|
-
//defined by a build.
|
596
|
-
if (fullName in defined) {
|
597
|
-
load(defined[fullName]);
|
598
|
-
} else {
|
599
|
-
//Use parentName here since the plugin's name is not reliable,
|
600
|
-
//could be some weird string with no path that actually wants to
|
601
|
-
//reference the parentName's path.
|
602
|
-
plugin.load(name, makeRequire(map.parentMap, true), load, config);
|
603
|
-
}
|
604
|
-
}
|
605
|
-
|
606
|
-
/**
|
607
|
-
* Adds the manager to the waiting queue. Only fully
|
608
|
-
* resolved items should be in the waiting queue.
|
609
|
-
*/
|
610
|
-
function addWait(manager) {
|
611
|
-
if (!waiting[manager.id]) {
|
612
|
-
waiting[manager.id] = manager;
|
613
|
-
waitAry.push(manager);
|
614
|
-
context.waitCount += 1;
|
615
|
-
}
|
616
|
-
}
|
617
|
-
|
618
|
-
/**
|
619
|
-
* Function added to every manager object. Created out here
|
620
|
-
* to avoid new function creation for each manager instance.
|
621
|
-
*/
|
622
|
-
function managerAdd(cb) {
|
623
|
-
this.listeners.push(cb);
|
624
|
-
}
|
625
|
-
|
626
|
-
function getManager(map, shouldQueue) {
|
627
|
-
var fullName = map.fullName,
|
628
|
-
prefix = map.prefix,
|
629
|
-
plugin = prefix ? plugins[prefix] ||
|
630
|
-
(plugins[prefix] = defined[prefix]) : null,
|
631
|
-
manager, created, pluginManager;
|
632
|
-
|
633
|
-
if (fullName) {
|
634
|
-
manager = managerCallbacks[fullName];
|
635
|
-
}
|
636
|
-
|
637
|
-
if (!manager) {
|
638
|
-
created = true;
|
639
|
-
manager = {
|
640
|
-
//ID is just the full name, but if it is a plugin resource
|
641
|
-
//for a plugin that has not been loaded,
|
642
|
-
//then add an ID counter to it.
|
643
|
-
id: (prefix && !plugin ?
|
644
|
-
(managerCounter++) + '__p@:' : '') +
|
645
|
-
(fullName || '__r@' + (managerCounter++)),
|
646
|
-
map: map,
|
647
|
-
depCount: 0,
|
648
|
-
depDone: [],
|
649
|
-
depCallbacks: [],
|
650
|
-
deps: [],
|
651
|
-
listeners: [],
|
652
|
-
add: managerAdd
|
653
|
-
};
|
654
|
-
|
655
|
-
specified[manager.id] = true;
|
656
|
-
|
657
|
-
//Only track the manager/reuse it if this is a non-plugin
|
658
|
-
//resource. Also only track plugin resources once
|
659
|
-
//the plugin has been loaded, and so the fullName is the
|
660
|
-
//true normalized value.
|
661
|
-
if (fullName && (!prefix || plugins[prefix])) {
|
662
|
-
managerCallbacks[fullName] = manager;
|
663
|
-
}
|
664
|
-
}
|
665
|
-
|
666
|
-
//If there is a plugin needed, but it is not loaded,
|
667
|
-
//first load the plugin, then continue on.
|
668
|
-
if (prefix && !plugin) {
|
669
|
-
pluginManager = getManager(makeModuleMap(prefix), true);
|
670
|
-
pluginManager.add(function (plugin) {
|
671
|
-
//Create a new manager for the normalized
|
672
|
-
//resource ID and have it call this manager when
|
673
|
-
//done.
|
674
|
-
var newMap = makeModuleMap(map.originalName, map.parentMap),
|
675
|
-
normalizedManager = getManager(newMap, true);
|
676
|
-
|
677
|
-
//Indicate this manager is a placeholder for the real,
|
678
|
-
//normalized thing. Important for when trying to map
|
679
|
-
//modules and dependencies, for instance, in a build.
|
680
|
-
manager.placeholder = true;
|
681
|
-
|
682
|
-
normalizedManager.add(function (resource) {
|
683
|
-
manager.callback = function () {
|
684
|
-
return resource;
|
685
|
-
};
|
686
|
-
execManager(manager);
|
687
|
-
});
|
688
|
-
});
|
689
|
-
} else if (created && shouldQueue) {
|
690
|
-
//Indicate the resource is not loaded yet if it is to be
|
691
|
-
//queued.
|
692
|
-
loaded[manager.id] = false;
|
693
|
-
queueDependency(manager);
|
694
|
-
addWait(manager);
|
695
|
-
}
|
696
|
-
|
697
|
-
return manager;
|
698
|
-
}
|
699
|
-
|
700
|
-
function main(inName, depArray, callback, relModuleMap) {
|
701
|
-
var moduleMap = makeModuleMap(inName, relModuleMap),
|
702
|
-
name = moduleMap.name,
|
703
|
-
fullName = moduleMap.fullName,
|
704
|
-
manager = getManager(moduleMap),
|
705
|
-
id = manager.id,
|
706
|
-
deps = manager.deps,
|
707
|
-
i, depArg, depName, depPrefix, cjsMod;
|
708
|
-
|
709
|
-
if (fullName) {
|
710
|
-
//If module already defined for context, or already loaded,
|
711
|
-
//then leave. Also leave if jQuery is registering but it does
|
712
|
-
//not match the desired version number in the config.
|
713
|
-
if (fullName in defined || loaded[id] === true ||
|
714
|
-
(fullName === "jquery" && config.jQuery &&
|
715
|
-
config.jQuery !== callback().fn.jquery)) {
|
716
|
-
return;
|
717
|
-
}
|
718
|
-
|
719
|
-
//Set specified/loaded here for modules that are also loaded
|
720
|
-
//as part of a layer, where onScriptLoad is not fired
|
721
|
-
//for those cases. Do this after the inline define and
|
722
|
-
//dependency tracing is done.
|
723
|
-
specified[id] = true;
|
724
|
-
loaded[id] = true;
|
725
|
-
|
726
|
-
//If module is jQuery set up delaying its dom ready listeners.
|
727
|
-
if (fullName === "jquery" && callback) {
|
728
|
-
jQueryCheck(callback());
|
729
|
-
}
|
730
|
-
}
|
731
|
-
|
732
|
-
//Attach real depArray and callback to the manager. Do this
|
733
|
-
//only if the module has not been defined already, so do this after
|
734
|
-
//the fullName checks above. IE can call main() more than once
|
735
|
-
//for a module.
|
736
|
-
manager.depArray = depArray;
|
737
|
-
manager.callback = callback;
|
738
|
-
|
739
|
-
//Add the dependencies to the deps field, and register for callbacks
|
740
|
-
//on the dependencies.
|
741
|
-
for (i = 0; i < depArray.length; i++) {
|
742
|
-
depArg = depArray[i];
|
743
|
-
//There could be cases like in IE, where a trailing comma will
|
744
|
-
//introduce a null dependency, so only treat a real dependency
|
745
|
-
//value as a dependency.
|
746
|
-
if (depArg) {
|
747
|
-
//Split the dependency name into plugin and name parts
|
748
|
-
depArg = makeModuleMap(depArg, (name ? moduleMap : relModuleMap));
|
749
|
-
depName = depArg.fullName;
|
750
|
-
depPrefix = depArg.prefix;
|
751
|
-
|
752
|
-
//Fix the name in depArray to be just the name, since
|
753
|
-
//that is how it will be called back later.
|
754
|
-
depArray[i] = depName;
|
755
|
-
|
756
|
-
//Fast path CommonJS standard dependencies.
|
757
|
-
if (depName === "require") {
|
758
|
-
deps[i] = makeRequire(moduleMap);
|
759
|
-
} else if (depName === "exports") {
|
760
|
-
//CommonJS module spec 1.1
|
761
|
-
deps[i] = defined[fullName] = {};
|
762
|
-
manager.usingExports = true;
|
763
|
-
} else if (depName === "module") {
|
764
|
-
//CommonJS module spec 1.1
|
765
|
-
manager.cjsModule = cjsMod = deps[i] = {
|
766
|
-
id: name,
|
767
|
-
uri: name ? context.nameToUrl(name, null, relModuleMap) : undefined,
|
768
|
-
exports: defined[fullName]
|
769
|
-
};
|
770
|
-
} else if (depName in defined && !(depName in waiting) &&
|
771
|
-
(!(fullName in needFullExec) ||
|
772
|
-
(fullName in needFullExec && fullExec[depName]))) {
|
773
|
-
//Module already defined, and not in a build situation
|
774
|
-
//where the module is a something that needs full
|
775
|
-
//execution and this dependency has not been fully
|
776
|
-
//executed. See r.js's requirePatch.js for more info
|
777
|
-
//on fullExec.
|
778
|
-
deps[i] = defined[depName];
|
779
|
-
} else {
|
780
|
-
//Mark this dependency as needing full exec if
|
781
|
-
//the current module needs full exec.
|
782
|
-
if (fullName in needFullExec) {
|
783
|
-
needFullExec[depName] = true;
|
784
|
-
//Reset state so fully executed code will get
|
785
|
-
//picked up correctly.
|
786
|
-
delete defined[depName];
|
787
|
-
urlFetched[depArg.url] = false;
|
788
|
-
}
|
789
|
-
|
790
|
-
//Either a resource that is not loaded yet, or a plugin
|
791
|
-
//resource for either a plugin that has not
|
792
|
-
//loaded yet.
|
793
|
-
manager.depCount += 1;
|
794
|
-
manager.depCallbacks[i] = makeArgCallback(manager, i);
|
795
|
-
getManager(depArg, true).add(manager.depCallbacks[i]);
|
796
|
-
}
|
797
|
-
}
|
798
|
-
}
|
799
|
-
|
800
|
-
//Do not bother tracking the manager if it is all done.
|
801
|
-
if (!manager.depCount) {
|
802
|
-
//All done, execute!
|
803
|
-
execManager(manager);
|
804
|
-
} else {
|
805
|
-
addWait(manager);
|
806
|
-
}
|
807
|
-
}
|
808
|
-
|
809
|
-
/**
|
810
|
-
* Convenience method to call main for a define call that was put on
|
811
|
-
* hold in the defQueue.
|
812
|
-
*/
|
813
|
-
function callDefMain(args) {
|
814
|
-
main.apply(null, args);
|
815
|
-
}
|
816
|
-
|
817
|
-
/**
|
818
|
-
* jQuery 1.4.3+ supports ways to hold off calling
|
819
|
-
* calling jQuery ready callbacks until all scripts are loaded. Be sure
|
820
|
-
* to track it if the capability exists.. Also, since jQuery 1.4.3 does
|
821
|
-
* not register as a module, need to do some global inference checking.
|
822
|
-
* Even if it does register as a module, not guaranteed to be the precise
|
823
|
-
* name of the global. If a jQuery is tracked for this context, then go
|
824
|
-
* ahead and register it as a module too, if not already in process.
|
825
|
-
*/
|
826
|
-
jQueryCheck = function (jqCandidate) {
|
827
|
-
if (!context.jQuery) {
|
828
|
-
var $ = jqCandidate || (typeof jQuery !== "undefined" ? jQuery : null);
|
829
|
-
|
830
|
-
if ($) {
|
831
|
-
//If a specific version of jQuery is wanted, make sure to only
|
832
|
-
//use this jQuery if it matches.
|
833
|
-
if (config.jQuery && $.fn.jquery !== config.jQuery) {
|
834
|
-
return;
|
835
|
-
}
|
836
|
-
|
837
|
-
if ("holdReady" in $ || "readyWait" in $) {
|
838
|
-
context.jQuery = $;
|
839
|
-
|
840
|
-
//Manually create a "jquery" module entry if not one already
|
841
|
-
//or in process. Note this could trigger an attempt at
|
842
|
-
//a second jQuery registration, but does no harm since
|
843
|
-
//the first one wins, and it is the same value anyway.
|
844
|
-
callDefMain(["jquery", [], function () {
|
845
|
-
return jQuery;
|
846
|
-
}]);
|
847
|
-
|
848
|
-
//Ask jQuery to hold DOM ready callbacks.
|
849
|
-
if (context.scriptCount) {
|
850
|
-
jQueryHoldReady($, true);
|
851
|
-
context.jQueryIncremented = true;
|
852
|
-
}
|
853
|
-
}
|
854
|
-
}
|
855
|
-
}
|
856
|
-
};
|
857
|
-
|
858
|
-
function forceExec(manager, traced) {
|
859
|
-
if (manager.isDone) {
|
860
|
-
return undefined;
|
861
|
-
}
|
862
|
-
|
863
|
-
var fullName = manager.map.fullName,
|
864
|
-
depArray = manager.depArray,
|
865
|
-
i, depName, depManager, prefix, prefixManager, value;
|
866
|
-
|
867
|
-
if (fullName) {
|
868
|
-
if (traced[fullName]) {
|
869
|
-
return defined[fullName];
|
870
|
-
}
|
871
|
-
|
872
|
-
traced[fullName] = true;
|
873
|
-
}
|
874
|
-
|
875
|
-
//Trace through the dependencies.
|
876
|
-
if (depArray) {
|
877
|
-
for (i = 0; i < depArray.length; i++) {
|
878
|
-
//Some array members may be null, like if a trailing comma
|
879
|
-
//IE, so do the explicit [i] access and check if it has a value.
|
880
|
-
depName = depArray[i];
|
881
|
-
if (depName) {
|
882
|
-
//First, make sure if it is a plugin resource that the
|
883
|
-
//plugin is not blocked.
|
884
|
-
prefix = makeModuleMap(depName).prefix;
|
885
|
-
if (prefix && (prefixManager = waiting[prefix])) {
|
886
|
-
forceExec(prefixManager, traced);
|
887
|
-
}
|
888
|
-
depManager = waiting[depName];
|
889
|
-
if (depManager && !depManager.isDone && loaded[depName]) {
|
890
|
-
value = forceExec(depManager, traced);
|
891
|
-
manager.depCallbacks[i](value);
|
892
|
-
}
|
893
|
-
}
|
894
|
-
}
|
895
|
-
}
|
896
|
-
|
897
|
-
return fullName ? defined[fullName] : undefined;
|
898
|
-
}
|
899
|
-
|
900
|
-
/**
|
901
|
-
* Checks if all modules for a context are loaded, and if so, evaluates the
|
902
|
-
* new ones in right dependency order.
|
903
|
-
*
|
904
|
-
* @private
|
905
|
-
*/
|
906
|
-
function checkLoaded() {
|
907
|
-
var waitInterval = config.waitSeconds * 1000,
|
908
|
-
//It is possible to disable the wait interval by using waitSeconds of 0.
|
909
|
-
expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(),
|
910
|
-
noLoads = "", hasLoadedProp = false, stillLoading = false, prop,
|
911
|
-
err, manager;
|
912
|
-
|
913
|
-
//If there are items still in the paused queue processing wait.
|
914
|
-
//This is particularly important in the sync case where each paused
|
915
|
-
//item is processed right away but there may be more waiting.
|
916
|
-
if (context.pausedCount > 0) {
|
917
|
-
return undefined;
|
918
|
-
}
|
919
|
-
|
920
|
-
//Determine if priority loading is done. If so clear the priority. If
|
921
|
-
//not, then do not check
|
922
|
-
if (config.priorityWait) {
|
923
|
-
if (isPriorityDone()) {
|
924
|
-
//Call resume, since it could have
|
925
|
-
//some waiting dependencies to trace.
|
926
|
-
resume();
|
927
|
-
} else {
|
928
|
-
return undefined;
|
929
|
-
}
|
930
|
-
}
|
931
|
-
|
932
|
-
//See if anything is still in flight.
|
933
|
-
for (prop in loaded) {
|
934
|
-
if (!(prop in empty)) {
|
935
|
-
hasLoadedProp = true;
|
936
|
-
if (!loaded[prop]) {
|
937
|
-
if (expired) {
|
938
|
-
noLoads += prop + " ";
|
939
|
-
} else {
|
940
|
-
stillLoading = true;
|
941
|
-
break;
|
942
|
-
}
|
943
|
-
}
|
944
|
-
}
|
945
|
-
}
|
946
|
-
|
947
|
-
//Check for exit conditions.
|
948
|
-
if (!hasLoadedProp && !context.waitCount) {
|
949
|
-
//If the loaded object had no items, then the rest of
|
950
|
-
//the work below does not need to be done.
|
951
|
-
return undefined;
|
952
|
-
}
|
953
|
-
if (expired && noLoads) {
|
954
|
-
//If wait time expired, throw error of unloaded modules.
|
955
|
-
err = makeError("timeout", "Load timeout for modules: " + noLoads);
|
956
|
-
err.requireType = "timeout";
|
957
|
-
err.requireModules = noLoads;
|
958
|
-
return req.onError(err);
|
959
|
-
}
|
960
|
-
if (stillLoading || context.scriptCount) {
|
961
|
-
//Something is still waiting to load. Wait for it, but only
|
962
|
-
//if a timeout is not already in effect.
|
963
|
-
if ((isBrowser || isWebWorker) && !checkLoadedTimeoutId) {
|
964
|
-
checkLoadedTimeoutId = setTimeout(function () {
|
965
|
-
checkLoadedTimeoutId = 0;
|
966
|
-
checkLoaded();
|
967
|
-
}, 50);
|
968
|
-
}
|
969
|
-
return undefined;
|
970
|
-
}
|
971
|
-
|
972
|
-
//If still have items in the waiting cue, but all modules have
|
973
|
-
//been loaded, then it means there are some circular dependencies
|
974
|
-
//that need to be broken.
|
975
|
-
//However, as a waiting thing is fired, then it can add items to
|
976
|
-
//the waiting cue, and those items should not be fired yet, so
|
977
|
-
//make sure to redo the checkLoaded call after breaking a single
|
978
|
-
//cycle, if nothing else loaded then this logic will pick it up
|
979
|
-
//again.
|
980
|
-
if (context.waitCount) {
|
981
|
-
//Cycle through the waitAry, and call items in sequence.
|
982
|
-
for (i = 0; (manager = waitAry[i]); i++) {
|
983
|
-
forceExec(manager, {});
|
984
|
-
}
|
985
|
-
|
986
|
-
//If anything got placed in the paused queue, run it down.
|
987
|
-
if (context.paused.length) {
|
988
|
-
resume();
|
989
|
-
}
|
990
|
-
|
991
|
-
//Only allow this recursion to a certain depth. Only
|
992
|
-
//triggered by errors in calling a module in which its
|
993
|
-
//modules waiting on it cannot finish loading, or some circular
|
994
|
-
//dependencies that then may add more dependencies.
|
995
|
-
//The value of 5 is a bit arbitrary. Hopefully just one extra
|
996
|
-
//pass, or two for the case of circular dependencies generating
|
997
|
-
//more work that gets resolved in the sync node case.
|
998
|
-
if (checkLoadedDepth < 5) {
|
999
|
-
checkLoadedDepth += 1;
|
1000
|
-
checkLoaded();
|
1001
|
-
}
|
1002
|
-
}
|
1003
|
-
|
1004
|
-
checkLoadedDepth = 0;
|
1005
|
-
|
1006
|
-
//Check for DOM ready, and nothing is waiting across contexts.
|
1007
|
-
req.checkReadyState();
|
1008
|
-
|
1009
|
-
return undefined;
|
1010
|
-
}
|
1011
|
-
|
1012
|
-
/**
|
1013
|
-
* Resumes tracing of dependencies and then checks if everything is loaded.
|
1014
|
-
*/
|
1015
|
-
resume = function () {
|
1016
|
-
var manager, map, url, i, p, args, fullName;
|
1017
|
-
|
1018
|
-
resumeDepth += 1;
|
1019
|
-
|
1020
|
-
if (context.scriptCount <= 0) {
|
1021
|
-
//Synchronous envs will push the number below zero with the
|
1022
|
-
//decrement above, be sure to set it back to zero for good measure.
|
1023
|
-
//require() calls that also do not end up loading scripts could
|
1024
|
-
//push the number negative too.
|
1025
|
-
context.scriptCount = 0;
|
1026
|
-
}
|
1027
|
-
|
1028
|
-
//Make sure any remaining defQueue items get properly processed.
|
1029
|
-
while (defQueue.length) {
|
1030
|
-
args = defQueue.shift();
|
1031
|
-
if (args[0] === null) {
|
1032
|
-
return req.onError(makeError('mismatch', 'Mismatched anonymous define() module: ' + args[args.length - 1]));
|
1033
|
-
} else {
|
1034
|
-
callDefMain(args);
|
1035
|
-
}
|
1036
|
-
}
|
1037
|
-
|
1038
|
-
//Skip the resume of paused dependencies
|
1039
|
-
//if current context is in priority wait.
|
1040
|
-
if (!config.priorityWait || isPriorityDone()) {
|
1041
|
-
while (context.paused.length) {
|
1042
|
-
p = context.paused;
|
1043
|
-
context.pausedCount += p.length;
|
1044
|
-
//Reset paused list
|
1045
|
-
context.paused = [];
|
1046
|
-
|
1047
|
-
for (i = 0; (manager = p[i]); i++) {
|
1048
|
-
map = manager.map;
|
1049
|
-
url = map.url;
|
1050
|
-
fullName = map.fullName;
|
1051
|
-
|
1052
|
-
//If the manager is for a plugin managed resource,
|
1053
|
-
//ask the plugin to load it now.
|
1054
|
-
if (map.prefix) {
|
1055
|
-
callPlugin(map.prefix, manager);
|
1056
|
-
} else {
|
1057
|
-
//Regular dependency.
|
1058
|
-
if (!urlFetched[url] && !loaded[fullName]) {
|
1059
|
-
req.load(context, fullName, url);
|
1060
|
-
|
1061
|
-
//Mark the URL as fetched, but only if it is
|
1062
|
-
//not an empty: URL, used by the optimizer.
|
1063
|
-
//In that case we need to be sure to call
|
1064
|
-
//load() for each module that is mapped to
|
1065
|
-
//empty: so that dependencies are satisfied
|
1066
|
-
//correctly.
|
1067
|
-
if (url.indexOf('empty:') !== 0) {
|
1068
|
-
urlFetched[url] = true;
|
1069
|
-
}
|
1070
|
-
}
|
1071
|
-
}
|
1072
|
-
}
|
1073
|
-
|
1074
|
-
//Move the start time for timeout forward.
|
1075
|
-
context.startTime = (new Date()).getTime();
|
1076
|
-
context.pausedCount -= p.length;
|
1077
|
-
}
|
1078
|
-
}
|
1079
|
-
|
1080
|
-
//Only check if loaded when resume depth is 1. It is likely that
|
1081
|
-
//it is only greater than 1 in sync environments where a factory
|
1082
|
-
//function also then calls the callback-style require. In those
|
1083
|
-
//cases, the checkLoaded should not occur until the resume
|
1084
|
-
//depth is back at the top level.
|
1085
|
-
if (resumeDepth === 1) {
|
1086
|
-
checkLoaded();
|
1087
|
-
}
|
1088
|
-
|
1089
|
-
resumeDepth -= 1;
|
1090
|
-
|
1091
|
-
return undefined;
|
1092
|
-
};
|
1093
|
-
|
1094
|
-
//Define the context object. Many of these fields are on here
|
1095
|
-
//just to make debugging easier.
|
1096
|
-
context = {
|
1097
|
-
contextName: contextName,
|
1098
|
-
config: config,
|
1099
|
-
defQueue: defQueue,
|
1100
|
-
waiting: waiting,
|
1101
|
-
waitCount: 0,
|
1102
|
-
specified: specified,
|
1103
|
-
loaded: loaded,
|
1104
|
-
urlMap: urlMap,
|
1105
|
-
urlFetched: urlFetched,
|
1106
|
-
scriptCount: 0,
|
1107
|
-
defined: defined,
|
1108
|
-
paused: [],
|
1109
|
-
pausedCount: 0,
|
1110
|
-
plugins: plugins,
|
1111
|
-
needFullExec: needFullExec,
|
1112
|
-
fake: {},
|
1113
|
-
fullExec: fullExec,
|
1114
|
-
managerCallbacks: managerCallbacks,
|
1115
|
-
makeModuleMap: makeModuleMap,
|
1116
|
-
normalize: normalize,
|
1117
|
-
/**
|
1118
|
-
* Set a configuration for the context.
|
1119
|
-
* @param {Object} cfg config object to integrate.
|
1120
|
-
*/
|
1121
|
-
configure: function (cfg) {
|
1122
|
-
var paths, prop, packages, pkgs, packagePaths, requireWait;
|
1123
|
-
|
1124
|
-
//Make sure the baseUrl ends in a slash.
|
1125
|
-
if (cfg.baseUrl) {
|
1126
|
-
if (cfg.baseUrl.charAt(cfg.baseUrl.length - 1) !== "/") {
|
1127
|
-
cfg.baseUrl += "/";
|
1128
|
-
}
|
1129
|
-
}
|
1130
|
-
|
1131
|
-
//Save off the paths and packages since they require special processing,
|
1132
|
-
//they are additive.
|
1133
|
-
paths = config.paths;
|
1134
|
-
packages = config.packages;
|
1135
|
-
pkgs = config.pkgs;
|
1136
|
-
|
1137
|
-
//Mix in the config values, favoring the new values over
|
1138
|
-
//existing ones in context.config.
|
1139
|
-
mixin(config, cfg, true);
|
1140
|
-
|
1141
|
-
//Adjust paths if necessary.
|
1142
|
-
if (cfg.paths) {
|
1143
|
-
for (prop in cfg.paths) {
|
1144
|
-
if (!(prop in empty)) {
|
1145
|
-
paths[prop] = cfg.paths[prop];
|
1146
|
-
}
|
1147
|
-
}
|
1148
|
-
config.paths = paths;
|
1149
|
-
}
|
1150
|
-
|
1151
|
-
packagePaths = cfg.packagePaths;
|
1152
|
-
if (packagePaths || cfg.packages) {
|
1153
|
-
//Convert packagePaths into a packages config.
|
1154
|
-
if (packagePaths) {
|
1155
|
-
for (prop in packagePaths) {
|
1156
|
-
if (!(prop in empty)) {
|
1157
|
-
configurePackageDir(pkgs, packagePaths[prop], prop);
|
1158
|
-
}
|
1159
|
-
}
|
1160
|
-
}
|
1161
|
-
|
1162
|
-
//Adjust packages if necessary.
|
1163
|
-
if (cfg.packages) {
|
1164
|
-
configurePackageDir(pkgs, cfg.packages);
|
1165
|
-
}
|
1166
|
-
|
1167
|
-
//Done with modifications, assing packages back to context config
|
1168
|
-
config.pkgs = pkgs;
|
1169
|
-
}
|
1170
|
-
|
1171
|
-
//If priority loading is in effect, trigger the loads now
|
1172
|
-
if (cfg.priority) {
|
1173
|
-
//Hold on to requireWait value, and reset it after done
|
1174
|
-
requireWait = context.requireWait;
|
1175
|
-
|
1176
|
-
//Allow tracing some require calls to allow the fetching
|
1177
|
-
//of the priority config.
|
1178
|
-
context.requireWait = false;
|
1179
|
-
//But first, call resume to register any defined modules that may
|
1180
|
-
//be in a data-main built file before the priority config
|
1181
|
-
//call. Also grab any waiting define calls for this context.
|
1182
|
-
context.takeGlobalQueue();
|
1183
|
-
resume();
|
1184
|
-
|
1185
|
-
context.require(cfg.priority);
|
1186
|
-
|
1187
|
-
//Trigger a resume right away, for the case when
|
1188
|
-
//the script with the priority load is done as part
|
1189
|
-
//of a data-main call. In that case the normal resume
|
1190
|
-
//call will not happen because the scriptCount will be
|
1191
|
-
//at 1, since the script for data-main is being processed.
|
1192
|
-
resume();
|
1193
|
-
|
1194
|
-
//Restore previous state.
|
1195
|
-
context.requireWait = requireWait;
|
1196
|
-
config.priorityWait = cfg.priority;
|
1197
|
-
}
|
1198
|
-
|
1199
|
-
//If a deps array or a config callback is specified, then call
|
1200
|
-
//require with those args. This is useful when require is defined as a
|
1201
|
-
//config object before require.js is loaded.
|
1202
|
-
if (cfg.deps || cfg.callback) {
|
1203
|
-
context.require(cfg.deps || [], cfg.callback);
|
1204
|
-
}
|
1205
|
-
},
|
1206
|
-
|
1207
|
-
requireDefined: function (moduleName, relModuleMap) {
|
1208
|
-
return makeModuleMap(moduleName, relModuleMap).fullName in defined;
|
1209
|
-
},
|
1210
|
-
|
1211
|
-
requireSpecified: function (moduleName, relModuleMap) {
|
1212
|
-
return makeModuleMap(moduleName, relModuleMap).fullName in specified;
|
1213
|
-
},
|
1214
|
-
|
1215
|
-
require: function (deps, callback, relModuleMap) {
|
1216
|
-
var moduleName, fullName, moduleMap;
|
1217
|
-
if (typeof deps === "string") {
|
1218
|
-
if (isFunction(callback)) {
|
1219
|
-
//Invalid call
|
1220
|
-
return req.onError(makeError("requireargs", "Invalid require call"));
|
1221
|
-
}
|
1222
|
-
|
1223
|
-
//Synchronous access to one module. If require.get is
|
1224
|
-
//available (as in the Node adapter), prefer that.
|
1225
|
-
//In this case deps is the moduleName and callback is
|
1226
|
-
//the relModuleMap
|
1227
|
-
if (req.get) {
|
1228
|
-
return req.get(context, deps, callback);
|
1229
|
-
}
|
1230
|
-
|
1231
|
-
//Just return the module wanted. In this scenario, the
|
1232
|
-
//second arg (if passed) is just the relModuleMap.
|
1233
|
-
moduleName = deps;
|
1234
|
-
relModuleMap = callback;
|
1235
|
-
|
1236
|
-
//Normalize module name, if it contains . or ..
|
1237
|
-
moduleMap = makeModuleMap(moduleName, relModuleMap);
|
1238
|
-
fullName = moduleMap.fullName;
|
1239
|
-
|
1240
|
-
if (!(fullName in defined)) {
|
1241
|
-
return req.onError(makeError("notloaded", "Module name '" +
|
1242
|
-
moduleMap.fullName +
|
1243
|
-
"' has not been loaded yet for context: " +
|
1244
|
-
contextName));
|
1245
|
-
}
|
1246
|
-
return defined[fullName];
|
1247
|
-
}
|
1248
|
-
|
1249
|
-
//Call main but only if there are dependencies or
|
1250
|
-
//a callback to call.
|
1251
|
-
if (deps && deps.length || callback) {
|
1252
|
-
main(null, deps, callback, relModuleMap);
|
1253
|
-
}
|
1254
|
-
|
1255
|
-
//If the require call does not trigger anything new to load,
|
1256
|
-
//then resume the dependency processing.
|
1257
|
-
if (!context.requireWait) {
|
1258
|
-
while (!context.scriptCount && context.paused.length) {
|
1259
|
-
//For built layers, there can be some defined
|
1260
|
-
//modules waiting for intake into the context,
|
1261
|
-
//in particular module plugins. Take them.
|
1262
|
-
context.takeGlobalQueue();
|
1263
|
-
resume();
|
1264
|
-
}
|
1265
|
-
}
|
1266
|
-
return context.require;
|
1267
|
-
},
|
1268
|
-
|
1269
|
-
/**
|
1270
|
-
* Internal method to transfer globalQueue items to this context's
|
1271
|
-
* defQueue.
|
1272
|
-
*/
|
1273
|
-
takeGlobalQueue: function () {
|
1274
|
-
//Push all the globalDefQueue items into the context's defQueue
|
1275
|
-
if (globalDefQueue.length) {
|
1276
|
-
//Array splice in the values since the context code has a
|
1277
|
-
//local var ref to defQueue, so cannot just reassign the one
|
1278
|
-
//on context.
|
1279
|
-
apsp.apply(context.defQueue,
|
1280
|
-
[context.defQueue.length - 1, 0].concat(globalDefQueue));
|
1281
|
-
globalDefQueue = [];
|
1282
|
-
}
|
1283
|
-
},
|
1284
|
-
|
1285
|
-
/**
|
1286
|
-
* Internal method used by environment adapters to complete a load event.
|
1287
|
-
* A load event could be a script load or just a load pass from a synchronous
|
1288
|
-
* load call.
|
1289
|
-
* @param {String} moduleName the name of the module to potentially complete.
|
1290
|
-
*/
|
1291
|
-
completeLoad: function (moduleName) {
|
1292
|
-
var args;
|
1293
|
-
|
1294
|
-
context.takeGlobalQueue();
|
1295
|
-
|
1296
|
-
while (defQueue.length) {
|
1297
|
-
args = defQueue.shift();
|
1298
|
-
|
1299
|
-
if (args[0] === null) {
|
1300
|
-
args[0] = moduleName;
|
1301
|
-
break;
|
1302
|
-
} else if (args[0] === moduleName) {
|
1303
|
-
//Found matching define call for this script!
|
1304
|
-
break;
|
1305
|
-
} else {
|
1306
|
-
//Some other named define call, most likely the result
|
1307
|
-
//of a build layer that included many define calls.
|
1308
|
-
callDefMain(args);
|
1309
|
-
args = null;
|
1310
|
-
}
|
1311
|
-
}
|
1312
|
-
if (args) {
|
1313
|
-
callDefMain(args);
|
1314
|
-
} else {
|
1315
|
-
//A script that does not call define(), so just simulate
|
1316
|
-
//the call for it. Special exception for jQuery dynamic load.
|
1317
|
-
callDefMain([moduleName, [],
|
1318
|
-
moduleName === "jquery" && typeof jQuery !== "undefined" ?
|
1319
|
-
function () {
|
1320
|
-
return jQuery;
|
1321
|
-
} : null]);
|
1322
|
-
}
|
1323
|
-
|
1324
|
-
//If a global jQuery is defined, check for it. Need to do it here
|
1325
|
-
//instead of main() since stock jQuery does not register as
|
1326
|
-
//a module via define.
|
1327
|
-
jQueryCheck();
|
1328
|
-
|
1329
|
-
//Doing this scriptCount decrement branching because sync envs
|
1330
|
-
//need to decrement after resume, otherwise it looks like
|
1331
|
-
//loading is complete after the first dependency is fetched.
|
1332
|
-
//For browsers, it works fine to decrement after, but it means
|
1333
|
-
//the checkLoaded setTimeout 50 ms cost is taken. To avoid
|
1334
|
-
//that cost, decrement beforehand.
|
1335
|
-
if (req.isAsync) {
|
1336
|
-
context.scriptCount -= 1;
|
1337
|
-
}
|
1338
|
-
resume();
|
1339
|
-
if (!req.isAsync) {
|
1340
|
-
context.scriptCount -= 1;
|
1341
|
-
}
|
1342
|
-
},
|
1343
|
-
|
1344
|
-
/**
|
1345
|
-
* Converts a module name + .extension into an URL path.
|
1346
|
-
* *Requires* the use of a module name. It does not support using
|
1347
|
-
* plain URLs like nameToUrl.
|
1348
|
-
*/
|
1349
|
-
toUrl: function (moduleNamePlusExt, relModuleMap) {
|
1350
|
-
var index = moduleNamePlusExt.lastIndexOf("."),
|
1351
|
-
ext = null;
|
1352
|
-
|
1353
|
-
if (index !== -1) {
|
1354
|
-
ext = moduleNamePlusExt.substring(index, moduleNamePlusExt.length);
|
1355
|
-
moduleNamePlusExt = moduleNamePlusExt.substring(0, index);
|
1356
|
-
}
|
1357
|
-
|
1358
|
-
return context.nameToUrl(moduleNamePlusExt, ext, relModuleMap);
|
1359
|
-
},
|
1360
|
-
|
1361
|
-
/**
|
1362
|
-
* Converts a module name to a file path. Supports cases where
|
1363
|
-
* moduleName may actually be just an URL.
|
1364
|
-
*/
|
1365
|
-
nameToUrl: function (moduleName, ext, relModuleMap) {
|
1366
|
-
var paths, pkgs, pkg, pkgPath, syms, i, parentModule, url,
|
1367
|
-
config = context.config;
|
1368
|
-
|
1369
|
-
//Normalize module name if have a base relative module name to work from.
|
1370
|
-
moduleName = normalize(moduleName, relModuleMap && relModuleMap.fullName);
|
1371
|
-
|
1372
|
-
//If a colon is in the URL, it indicates a protocol is used and it is just
|
1373
|
-
//an URL to a file, or if it starts with a slash or ends with .js, it is just a plain file.
|
1374
|
-
//The slash is important for protocol-less URLs as well as full paths.
|
1375
|
-
if (req.jsExtRegExp.test(moduleName)) {
|
1376
|
-
//Just a plain path, not module name lookup, so just return it.
|
1377
|
-
//Add extension if it is included. This is a bit wonky, only non-.js things pass
|
1378
|
-
//an extension, this method probably needs to be reworked.
|
1379
|
-
url = moduleName + (ext ? ext : "");
|
1380
|
-
} else {
|
1381
|
-
//A module that needs to be converted to a path.
|
1382
|
-
paths = config.paths;
|
1383
|
-
pkgs = config.pkgs;
|
1384
|
-
|
1385
|
-
syms = moduleName.split("/");
|
1386
|
-
//For each module name segment, see if there is a path
|
1387
|
-
//registered for it. Start with most specific name
|
1388
|
-
//and work up from it.
|
1389
|
-
for (i = syms.length; i > 0; i--) {
|
1390
|
-
parentModule = syms.slice(0, i).join("/");
|
1391
|
-
if (paths[parentModule]) {
|
1392
|
-
syms.splice(0, i, paths[parentModule]);
|
1393
|
-
break;
|
1394
|
-
} else if ((pkg = pkgs[parentModule])) {
|
1395
|
-
//If module name is just the package name, then looking
|
1396
|
-
//for the main module.
|
1397
|
-
if (moduleName === pkg.name) {
|
1398
|
-
pkgPath = pkg.location + '/' + pkg.main;
|
1399
|
-
} else {
|
1400
|
-
pkgPath = pkg.location;
|
1401
|
-
}
|
1402
|
-
syms.splice(0, i, pkgPath);
|
1403
|
-
break;
|
1404
|
-
}
|
1405
|
-
}
|
1406
|
-
|
1407
|
-
//Join the path parts together, then figure out if baseUrl is needed.
|
1408
|
-
url = syms.join("/") + (ext || ".js");
|
1409
|
-
url = (url.charAt(0) === '/' || url.match(/^\w+:/) ? "" : config.baseUrl) + url;
|
1410
|
-
}
|
1411
|
-
|
1412
|
-
return config.urlArgs ? url +
|
1413
|
-
((url.indexOf('?') === -1 ? '?' : '&') +
|
1414
|
-
config.urlArgs) : url;
|
1415
|
-
}
|
1416
|
-
};
|
1417
|
-
|
1418
|
-
//Make these visible on the context so can be called at the very
|
1419
|
-
//end of the file to bootstrap
|
1420
|
-
context.jQueryCheck = jQueryCheck;
|
1421
|
-
context.resume = resume;
|
1422
|
-
|
1423
|
-
return context;
|
1424
|
-
}
|
1425
|
-
|
1426
|
-
/**
|
1427
|
-
* Main entry point.
|
1428
|
-
*
|
1429
|
-
* If the only argument to require is a string, then the module that
|
1430
|
-
* is represented by that string is fetched for the appropriate context.
|
1431
|
-
*
|
1432
|
-
* If the first argument is an array, then it will be treated as an array
|
1433
|
-
* of dependency string names to fetch. An optional function callback can
|
1434
|
-
* be specified to execute when all of those dependencies are available.
|
1435
|
-
*
|
1436
|
-
* Make a local req variable to help Caja compliance (it assumes things
|
1437
|
-
* on a require that are not standardized), and to give a short
|
1438
|
-
* name for minification/local scope use.
|
1439
|
-
*/
|
1440
|
-
req = requirejs = function (deps, callback) {
|
1441
|
-
|
1442
|
-
//Find the right context, use default
|
1443
|
-
var contextName = defContextName,
|
1444
|
-
context, config;
|
1445
|
-
|
1446
|
-
// Determine if have config object in the call.
|
1447
|
-
if (!isArray(deps) && typeof deps !== "string") {
|
1448
|
-
// deps is a config object
|
1449
|
-
config = deps;
|
1450
|
-
if (isArray(callback)) {
|
1451
|
-
// Adjust args if there are dependencies
|
1452
|
-
deps = callback;
|
1453
|
-
callback = arguments[2];
|
1454
|
-
} else {
|
1455
|
-
deps = [];
|
1456
|
-
}
|
1457
|
-
}
|
1458
|
-
|
1459
|
-
if (config && config.context) {
|
1460
|
-
contextName = config.context;
|
1461
|
-
}
|
1462
|
-
|
1463
|
-
context = contexts[contextName] ||
|
1464
|
-
(contexts[contextName] = newContext(contextName));
|
1465
|
-
|
1466
|
-
if (config) {
|
1467
|
-
context.configure(config);
|
1468
|
-
}
|
1469
|
-
|
1470
|
-
return context.require(deps, callback);
|
1471
|
-
};
|
1472
|
-
|
1473
|
-
/**
|
1474
|
-
* Support require.config() to make it easier to cooperate with other
|
1475
|
-
* AMD loaders on globally agreed names.
|
1476
|
-
*/
|
1477
|
-
req.config = function (config) {
|
1478
|
-
return req(config);
|
1479
|
-
};
|
1480
|
-
|
1481
|
-
/**
|
1482
|
-
* Export require as a global, but only if it does not already exist.
|
1483
|
-
*/
|
1484
|
-
if (!require) {
|
1485
|
-
require = req;
|
1486
|
-
}
|
1487
|
-
|
1488
|
-
/**
|
1489
|
-
* Global require.toUrl(), to match global require, mostly useful
|
1490
|
-
* for debugging/work in the global space.
|
1491
|
-
*/
|
1492
|
-
req.toUrl = function (moduleNamePlusExt) {
|
1493
|
-
return contexts[defContextName].toUrl(moduleNamePlusExt);
|
1494
|
-
};
|
1495
|
-
|
1496
|
-
req.version = version;
|
1497
|
-
|
1498
|
-
//Used to filter out dependencies that are already paths.
|
1499
|
-
req.jsExtRegExp = /^\/|:|\?|\.js$/;
|
1500
|
-
s = req.s = {
|
1501
|
-
contexts: contexts,
|
1502
|
-
//Stores a list of URLs that should not get async script tag treatment.
|
1503
|
-
skipAsync: {}
|
1504
|
-
};
|
1505
|
-
|
1506
|
-
req.isAsync = req.isBrowser = isBrowser;
|
1507
|
-
if (isBrowser) {
|
1508
|
-
head = s.head = document.getElementsByTagName("head")[0];
|
1509
|
-
//If BASE tag is in play, using appendChild is a problem for IE6.
|
1510
|
-
//When that browser dies, this can be removed. Details in this jQuery bug:
|
1511
|
-
//http://dev.jquery.com/ticket/2709
|
1512
|
-
baseElement = document.getElementsByTagName("base")[0];
|
1513
|
-
if (baseElement) {
|
1514
|
-
head = s.head = baseElement.parentNode;
|
1515
|
-
}
|
1516
|
-
}
|
1517
|
-
|
1518
|
-
/**
|
1519
|
-
* Any errors that require explicitly generates will be passed to this
|
1520
|
-
* function. Intercept/override it if you want custom error handling.
|
1521
|
-
* @param {Error} err the error object.
|
1522
|
-
*/
|
1523
|
-
req.onError = function (err) {
|
1524
|
-
throw err;
|
1525
|
-
};
|
1526
|
-
|
1527
|
-
/**
|
1528
|
-
* Does the request to load a module for the browser case.
|
1529
|
-
* Make this a separate function to allow other environments
|
1530
|
-
* to override it.
|
1531
|
-
*
|
1532
|
-
* @param {Object} context the require context to find state.
|
1533
|
-
* @param {String} moduleName the name of the module.
|
1534
|
-
* @param {Object} url the URL to the module.
|
1535
|
-
*/
|
1536
|
-
req.load = function (context, moduleName, url) {
|
1537
|
-
req.resourcesReady(false);
|
1538
|
-
|
1539
|
-
context.scriptCount += 1;
|
1540
|
-
req.attach(url, context, moduleName);
|
1541
|
-
|
1542
|
-
//If tracking a jQuery, then make sure its ready callbacks
|
1543
|
-
//are put on hold to prevent its ready callbacks from
|
1544
|
-
//triggering too soon.
|
1545
|
-
if (context.jQuery && !context.jQueryIncremented) {
|
1546
|
-
jQueryHoldReady(context.jQuery, true);
|
1547
|
-
context.jQueryIncremented = true;
|
1548
|
-
}
|
1549
|
-
};
|
1550
|
-
|
1551
|
-
function getInteractiveScript() {
|
1552
|
-
var scripts, i, script;
|
1553
|
-
if (interactiveScript && interactiveScript.readyState === 'interactive') {
|
1554
|
-
return interactiveScript;
|
1555
|
-
}
|
1556
|
-
|
1557
|
-
scripts = document.getElementsByTagName('script');
|
1558
|
-
for (i = scripts.length - 1; i > -1 && (script = scripts[i]); i--) {
|
1559
|
-
if (script.readyState === 'interactive') {
|
1560
|
-
return (interactiveScript = script);
|
1561
|
-
}
|
1562
|
-
}
|
1563
|
-
|
1564
|
-
return null;
|
1565
|
-
}
|
1566
|
-
|
1567
|
-
/**
|
1568
|
-
* The function that handles definitions of modules. Differs from
|
1569
|
-
* require() in that a string for the module should be the first argument,
|
1570
|
-
* and the function to execute after dependencies are loaded should
|
1571
|
-
* return a value to define the module corresponding to the first argument's
|
1572
|
-
* name.
|
1573
|
-
*/
|
1574
|
-
define = function (name, deps, callback) {
|
1575
|
-
var node, context;
|
1576
|
-
|
1577
|
-
//Allow for anonymous functions
|
1578
|
-
if (typeof name !== 'string') {
|
1579
|
-
//Adjust args appropriately
|
1580
|
-
callback = deps;
|
1581
|
-
deps = name;
|
1582
|
-
name = null;
|
1583
|
-
}
|
1584
|
-
|
1585
|
-
//This module may not have dependencies
|
1586
|
-
if (!isArray(deps)) {
|
1587
|
-
callback = deps;
|
1588
|
-
deps = [];
|
1589
|
-
}
|
1590
|
-
|
1591
|
-
//If no name, and callback is a function, then figure out if it a
|
1592
|
-
//CommonJS thing with dependencies.
|
1593
|
-
if (!deps.length && isFunction(callback)) {
|
1594
|
-
//Remove comments from the callback string,
|
1595
|
-
//look for require calls, and pull them into the dependencies,
|
1596
|
-
//but only if there are function args.
|
1597
|
-
if (callback.length) {
|
1598
|
-
callback
|
1599
|
-
.toString()
|
1600
|
-
.replace(commentRegExp, "")
|
1601
|
-
.replace(cjsRequireRegExp, function (match, dep) {
|
1602
|
-
deps.push(dep);
|
1603
|
-
});
|
1604
|
-
|
1605
|
-
//May be a CommonJS thing even without require calls, but still
|
1606
|
-
//could use exports, and module. Avoid doing exports and module
|
1607
|
-
//work though if it just needs require.
|
1608
|
-
//REQUIRES the function to expect the CommonJS variables in the
|
1609
|
-
//order listed below.
|
1610
|
-
deps = (callback.length === 1 ? ["require"] : ["require", "exports", "module"]).concat(deps);
|
1611
|
-
}
|
1612
|
-
}
|
1613
|
-
|
1614
|
-
//If in IE 6-8 and hit an anonymous define() call, do the interactive
|
1615
|
-
//work.
|
1616
|
-
if (useInteractive) {
|
1617
|
-
node = currentlyAddingScript || getInteractiveScript();
|
1618
|
-
if (node) {
|
1619
|
-
if (!name) {
|
1620
|
-
name = node.getAttribute("data-requiremodule");
|
1621
|
-
}
|
1622
|
-
context = contexts[node.getAttribute("data-requirecontext")];
|
1623
|
-
}
|
1624
|
-
}
|
1625
|
-
|
1626
|
-
//Always save off evaluating the def call until the script onload handler.
|
1627
|
-
//This allows multiple modules to be in a file without prematurely
|
1628
|
-
//tracing dependencies, and allows for anonymous module support,
|
1629
|
-
//where the module name is not known until the script onload event
|
1630
|
-
//occurs. If no context, use the global queue, and get it processed
|
1631
|
-
//in the onscript load callback.
|
1632
|
-
(context ? context.defQueue : globalDefQueue).push([name, deps, callback]);
|
1633
|
-
|
1634
|
-
return undefined;
|
1635
|
-
};
|
1636
|
-
|
1637
|
-
define.amd = {
|
1638
|
-
multiversion: true,
|
1639
|
-
plugins: true,
|
1640
|
-
jQuery: true
|
1641
|
-
};
|
1642
|
-
|
1643
|
-
/**
|
1644
|
-
* Executes the text. Normally just uses eval, but can be modified
|
1645
|
-
* to use a more environment specific call.
|
1646
|
-
* @param {String} text the text to execute/evaluate.
|
1647
|
-
*/
|
1648
|
-
req.exec = function (text) {
|
1649
|
-
return eval(text);
|
1650
|
-
};
|
1651
|
-
|
1652
|
-
/**
|
1653
|
-
* Executes a module callack function. Broken out as a separate function
|
1654
|
-
* solely to allow the build system to sequence the files in the built
|
1655
|
-
* layer in the right sequence.
|
1656
|
-
*
|
1657
|
-
* @private
|
1658
|
-
*/
|
1659
|
-
req.execCb = function (name, callback, args, exports) {
|
1660
|
-
return callback.apply(exports, args);
|
1661
|
-
};
|
1662
|
-
|
1663
|
-
|
1664
|
-
/**
|
1665
|
-
* Adds a node to the DOM. Public function since used by the order plugin.
|
1666
|
-
* This method should not normally be called by outside code.
|
1667
|
-
*/
|
1668
|
-
req.addScriptToDom = function (node) {
|
1669
|
-
//For some cache cases in IE 6-8, the script executes before the end
|
1670
|
-
//of the appendChild execution, so to tie an anonymous define
|
1671
|
-
//call to the module name (which is stored on the node), hold on
|
1672
|
-
//to a reference to this node, but clear after the DOM insertion.
|
1673
|
-
currentlyAddingScript = node;
|
1674
|
-
if (baseElement) {
|
1675
|
-
head.insertBefore(node, baseElement);
|
1676
|
-
} else {
|
1677
|
-
head.appendChild(node);
|
1678
|
-
}
|
1679
|
-
currentlyAddingScript = null;
|
1680
|
-
};
|
1681
|
-
|
1682
|
-
/**
|
1683
|
-
* callback for script loads, used to check status of loading.
|
1684
|
-
*
|
1685
|
-
* @param {Event} evt the event from the browser for the script
|
1686
|
-
* that was loaded.
|
1687
|
-
*
|
1688
|
-
* @private
|
1689
|
-
*/
|
1690
|
-
req.onScriptLoad = function (evt) {
|
1691
|
-
//Using currentTarget instead of target for Firefox 2.0's sake. Not
|
1692
|
-
//all old browsers will be supported, but this one was easy enough
|
1693
|
-
//to support and still makes sense.
|
1694
|
-
var node = evt.currentTarget || evt.srcElement, contextName, moduleName,
|
1695
|
-
context;
|
1696
|
-
|
1697
|
-
if (evt.type === "load" || (node && readyRegExp.test(node.readyState))) {
|
1698
|
-
//Reset interactive script so a script node is not held onto for
|
1699
|
-
//to long.
|
1700
|
-
interactiveScript = null;
|
1701
|
-
|
1702
|
-
//Pull out the name of the module and the context.
|
1703
|
-
contextName = node.getAttribute("data-requirecontext");
|
1704
|
-
moduleName = node.getAttribute("data-requiremodule");
|
1705
|
-
context = contexts[contextName];
|
1706
|
-
|
1707
|
-
contexts[contextName].completeLoad(moduleName);
|
1708
|
-
|
1709
|
-
//Clean up script binding. Favor detachEvent because of IE9
|
1710
|
-
//issue, see attachEvent/addEventListener comment elsewhere
|
1711
|
-
//in this file.
|
1712
|
-
if (node.detachEvent && !isOpera) {
|
1713
|
-
//Probably IE. If not it will throw an error, which will be
|
1714
|
-
//useful to know.
|
1715
|
-
node.detachEvent("onreadystatechange", req.onScriptLoad);
|
1716
|
-
} else {
|
1717
|
-
node.removeEventListener("load", req.onScriptLoad, false);
|
1718
|
-
}
|
1719
|
-
}
|
1720
|
-
};
|
1721
|
-
|
1722
|
-
/**
|
1723
|
-
* Attaches the script represented by the URL to the current
|
1724
|
-
* environment. Right now only supports browser loading,
|
1725
|
-
* but can be redefined in other environments to do the right thing.
|
1726
|
-
* @param {String} url the url of the script to attach.
|
1727
|
-
* @param {Object} context the context that wants the script.
|
1728
|
-
* @param {moduleName} the name of the module that is associated with the script.
|
1729
|
-
* @param {Function} [callback] optional callback, defaults to require.onScriptLoad
|
1730
|
-
* @param {String} [type] optional type, defaults to text/javascript
|
1731
|
-
* @param {Function} [fetchOnlyFunction] optional function to indicate the script node
|
1732
|
-
* should be set up to fetch the script but do not attach it to the DOM
|
1733
|
-
* so that it can later be attached to execute it. This is a way for the
|
1734
|
-
* order plugin to support ordered loading in IE. Once the script is fetched,
|
1735
|
-
* but not executed, the fetchOnlyFunction will be called.
|
1736
|
-
*/
|
1737
|
-
req.attach = function (url, context, moduleName, callback, type, fetchOnlyFunction) {
|
1738
|
-
var node;
|
1739
|
-
if (isBrowser) {
|
1740
|
-
//In the browser so use a script tag
|
1741
|
-
callback = callback || req.onScriptLoad;
|
1742
|
-
node = context && context.config && context.config.xhtml ?
|
1743
|
-
document.createElementNS("http://www.w3.org/1999/xhtml", "html:script") :
|
1744
|
-
document.createElement("script");
|
1745
|
-
node.type = type || "text/javascript";
|
1746
|
-
node.charset = "utf-8";
|
1747
|
-
//Use async so Gecko does not block on executing the script if something
|
1748
|
-
//like a long-polling comet tag is being run first. Gecko likes
|
1749
|
-
//to evaluate scripts in DOM order, even for dynamic scripts.
|
1750
|
-
//It will fetch them async, but only evaluate the contents in DOM
|
1751
|
-
//order, so a long-polling script tag can delay execution of scripts
|
1752
|
-
//after it. But telling Gecko we expect async gets us the behavior
|
1753
|
-
//we want -- execute it whenever it is finished downloading. Only
|
1754
|
-
//Helps Firefox 3.6+
|
1755
|
-
//Allow some URLs to not be fetched async. Mostly helps the order!
|
1756
|
-
//plugin
|
1757
|
-
node.async = !s.skipAsync[url];
|
1758
|
-
|
1759
|
-
if (context) {
|
1760
|
-
node.setAttribute("data-requirecontext", context.contextName);
|
1761
|
-
}
|
1762
|
-
node.setAttribute("data-requiremodule", moduleName);
|
1763
|
-
|
1764
|
-
//Set up load listener. Test attachEvent first because IE9 has
|
1765
|
-
//a subtle issue in its addEventListener and script onload firings
|
1766
|
-
//that do not match the behavior of all other browsers with
|
1767
|
-
//addEventListener support, which fire the onload event for a
|
1768
|
-
//script right after the script execution. See:
|
1769
|
-
//https://connect.microsoft.com/IE/feedback/details/648057/script-onload-event-is-not-fired-immediately-after-script-execution
|
1770
|
-
//UNFORTUNATELY Opera implements attachEvent but does not follow the script
|
1771
|
-
//script execution mode.
|
1772
|
-
if (node.attachEvent && !isOpera) {
|
1773
|
-
//Probably IE. IE (at least 6-8) do not fire
|
1774
|
-
//script onload right after executing the script, so
|
1775
|
-
//we cannot tie the anonymous define call to a name.
|
1776
|
-
//However, IE reports the script as being in "interactive"
|
1777
|
-
//readyState at the time of the define call.
|
1778
|
-
useInteractive = true;
|
1779
|
-
|
1780
|
-
|
1781
|
-
if (fetchOnlyFunction) {
|
1782
|
-
//Need to use old school onreadystate here since
|
1783
|
-
//when the event fires and the node is not attached
|
1784
|
-
//to the DOM, the evt.srcElement is null, so use
|
1785
|
-
//a closure to remember the node.
|
1786
|
-
node.onreadystatechange = function (evt) {
|
1787
|
-
//Script loaded but not executed.
|
1788
|
-
//Clear loaded handler, set the real one that
|
1789
|
-
//waits for script execution.
|
1790
|
-
if (node.readyState === 'loaded') {
|
1791
|
-
node.onreadystatechange = null;
|
1792
|
-
node.attachEvent("onreadystatechange", callback);
|
1793
|
-
fetchOnlyFunction(node);
|
1794
|
-
}
|
1795
|
-
};
|
1796
|
-
} else {
|
1797
|
-
node.attachEvent("onreadystatechange", callback);
|
1798
|
-
}
|
1799
|
-
} else {
|
1800
|
-
node.addEventListener("load", callback, false);
|
1801
|
-
}
|
1802
|
-
node.src = url;
|
1803
|
-
|
1804
|
-
//Fetch only means waiting to attach to DOM after loaded.
|
1805
|
-
if (!fetchOnlyFunction) {
|
1806
|
-
req.addScriptToDom(node);
|
1807
|
-
}
|
1808
|
-
|
1809
|
-
return node;
|
1810
|
-
} else if (isWebWorker) {
|
1811
|
-
//In a web worker, use importScripts. This is not a very
|
1812
|
-
//efficient use of importScripts, importScripts will block until
|
1813
|
-
//its script is downloaded and evaluated. However, if web workers
|
1814
|
-
//are in play, the expectation that a build has been done so that
|
1815
|
-
//only one script needs to be loaded anyway. This may need to be
|
1816
|
-
//reevaluated if other use cases become common.
|
1817
|
-
importScripts(url);
|
1818
|
-
|
1819
|
-
//Account for anonymous modules
|
1820
|
-
context.completeLoad(moduleName);
|
1821
|
-
}
|
1822
|
-
return null;
|
1823
|
-
};
|
1824
|
-
|
1825
|
-
//Look for a data-main script attribute, which could also adjust the baseUrl.
|
1826
|
-
if (isBrowser) {
|
1827
|
-
//Figure out baseUrl. Get it from the script tag with require.js in it.
|
1828
|
-
scripts = document.getElementsByTagName("script");
|
1829
|
-
|
1830
|
-
for (i = scripts.length - 1; i > -1 && (script = scripts[i]); i--) {
|
1831
|
-
//Set the "head" where we can append children by
|
1832
|
-
//using the script's parent.
|
1833
|
-
if (!head) {
|
1834
|
-
head = script.parentNode;
|
1835
|
-
}
|
1836
|
-
|
1837
|
-
//Look for a data-main attribute to set main script for the page
|
1838
|
-
//to load. If it is there, the path to data main becomes the
|
1839
|
-
//baseUrl, if it is not already set.
|
1840
|
-
if ((dataMain = script.getAttribute('data-main'))) {
|
1841
|
-
if (!cfg.baseUrl) {
|
1842
|
-
//Pull off the directory of data-main for use as the
|
1843
|
-
//baseUrl.
|
1844
|
-
src = dataMain.split('/');
|
1845
|
-
mainScript = src.pop();
|
1846
|
-
subPath = src.length ? src.join('/') + '/' : './';
|
1847
|
-
|
1848
|
-
//Set final config.
|
1849
|
-
cfg.baseUrl = subPath;
|
1850
|
-
//Strip off any trailing .js since dataMain is now
|
1851
|
-
//like a module name.
|
1852
|
-
dataMain = mainScript.replace(jsSuffixRegExp, '');
|
1853
|
-
}
|
1854
|
-
|
1855
|
-
//Put the data-main script in the files to load.
|
1856
|
-
cfg.deps = cfg.deps ? cfg.deps.concat(dataMain) : [dataMain];
|
1857
|
-
|
1858
|
-
break;
|
1859
|
-
}
|
1860
|
-
}
|
1861
|
-
}
|
1862
|
-
|
1863
|
-
//See if there is nothing waiting across contexts, and if not, trigger
|
1864
|
-
//resourcesReady.
|
1865
|
-
req.checkReadyState = function () {
|
1866
|
-
var contexts = s.contexts, prop;
|
1867
|
-
for (prop in contexts) {
|
1868
|
-
if (!(prop in empty)) {
|
1869
|
-
if (contexts[prop].waitCount) {
|
1870
|
-
return;
|
1871
|
-
}
|
1872
|
-
}
|
1873
|
-
}
|
1874
|
-
req.resourcesReady(true);
|
1875
|
-
};
|
1876
|
-
|
1877
|
-
/**
|
1878
|
-
* Internal function that is triggered whenever all scripts/resources
|
1879
|
-
* have been loaded by the loader. Can be overridden by other, for
|
1880
|
-
* instance the domReady plugin, which wants to know when all resources
|
1881
|
-
* are loaded.
|
1882
|
-
*/
|
1883
|
-
req.resourcesReady = function (isReady) {
|
1884
|
-
var contexts, context, prop;
|
1885
|
-
|
1886
|
-
//First, set the public variable indicating that resources are loading.
|
1887
|
-
req.resourcesDone = isReady;
|
1888
|
-
|
1889
|
-
if (req.resourcesDone) {
|
1890
|
-
//If jQuery with DOM ready delayed, release it now.
|
1891
|
-
contexts = s.contexts;
|
1892
|
-
for (prop in contexts) {
|
1893
|
-
if (!(prop in empty)) {
|
1894
|
-
context = contexts[prop];
|
1895
|
-
if (context.jQueryIncremented) {
|
1896
|
-
jQueryHoldReady(context.jQuery, false);
|
1897
|
-
context.jQueryIncremented = false;
|
1898
|
-
}
|
1899
|
-
}
|
1900
|
-
}
|
1901
|
-
}
|
1902
|
-
};
|
1903
|
-
|
1904
|
-
//FF < 3.6 readyState fix. Needed so that domReady plugin
|
1905
|
-
//works well in that environment, since require.js is normally
|
1906
|
-
//loaded via an HTML script tag so it will be there before window load,
|
1907
|
-
//where the domReady plugin is more likely to be loaded after window load.
|
1908
|
-
req.pageLoaded = function () {
|
1909
|
-
if (document.readyState !== "complete") {
|
1910
|
-
document.readyState = "complete";
|
1911
|
-
}
|
1912
|
-
};
|
1913
|
-
if (isBrowser) {
|
1914
|
-
if (document.addEventListener) {
|
1915
|
-
if (!document.readyState) {
|
1916
|
-
document.readyState = "loading";
|
1917
|
-
window.addEventListener("load", req.pageLoaded, false);
|
1918
|
-
}
|
1919
|
-
}
|
1920
|
-
}
|
1921
|
-
|
1922
|
-
//Set up default context. If require was a configuration object, use that as base config.
|
1923
|
-
req(cfg);
|
1924
|
-
|
1925
|
-
//If modules are built into require.js, then need to make sure dependencies are
|
1926
|
-
//traced. Use a setTimeout in the browser world, to allow all the modules to register
|
1927
|
-
//themselves. In a non-browser env, assume that modules are not built into require.js,
|
1928
|
-
//which seems odd to do on the server.
|
1929
|
-
if (req.isAsync && typeof setTimeout !== "undefined") {
|
1930
|
-
ctx = s.contexts[(cfg.context || defContextName)];
|
1931
|
-
//Indicate that the script that includes require() is still loading,
|
1932
|
-
//so that require()'d dependencies are not traced until the end of the
|
1933
|
-
//file is parsed (approximated via the setTimeout call).
|
1934
|
-
ctx.requireWait = true;
|
1935
|
-
setTimeout(function () {
|
1936
|
-
ctx.requireWait = false;
|
1937
|
-
|
1938
|
-
//Any modules included with the require.js file will be in the
|
1939
|
-
//global queue, assign them to this context.
|
1940
|
-
ctx.takeGlobalQueue();
|
1941
|
-
|
1942
|
-
//Allow for jQuery to be loaded/already in the page, and if jQuery 1.4.3,
|
1943
|
-
//make sure to hold onto it for readyWait triggering.
|
1944
|
-
ctx.jQueryCheck();
|
1945
|
-
|
1946
|
-
if (!ctx.scriptCount) {
|
1947
|
-
ctx.resume();
|
1948
|
-
}
|
1949
|
-
req.checkReadyState();
|
1950
|
-
}, 0);
|
1951
|
-
}
|
1952
|
-
}());
|