diff options
author | Alexander Schmitz <arschmitz@gmail.com> | 2015-05-14 09:57:50 -0400 |
---|---|---|
committer | Alexander Schmitz <arschmitz@gmail.com> | 2015-07-21 11:00:40 -0400 |
commit | 7336a5869ceb2bf27779b5f089277c365fc7d278 (patch) | |
tree | be78b7a4add4c74c4f2d42065398d029f1d688fb /demos/bootstrap.js | |
parent | 62446d957efb69cd53015919edf71501fcbd2599 (diff) | |
download | jquery-ui-7336a5869ceb2bf27779b5f089277c365fc7d278.tar.gz jquery-ui-7336a5869ceb2bf27779b5f089277c365fc7d278.zip |
Demos: Add new infrastructure using a require.js bootstrap
Fixes #10119
Closes gh-1557
Diffstat (limited to 'demos/bootstrap.js')
-rw-r--r-- | demos/bootstrap.js | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/demos/bootstrap.js b/demos/bootstrap.js new file mode 100644 index 000000000..c82ecc1b0 --- /dev/null +++ b/demos/bootstrap.js @@ -0,0 +1,60 @@ +/* globals window:true, document:true */ +( function() { + +// Find the script element +var scripts = document.getElementsByTagName( "script" ); +var script = scripts[ scripts.length - 1 ]; + +// Read the modules +var modules = script.getAttribute( "data-modules" ); +var pathParts = window.location.pathname.split( "/" ); +var effectsAll = [ + "effect-blind", + "effect-bounce", + "effect-clip", + "effect-drop", + "effect-explode", + "effect-fade", + "effect-fold", + "effect-highlight", + "effect-puff", + "effect-pulsate", + "effect-scale", + "effect-shake", + "effect-size", + "effect-slide" +]; + +// Hide the page while things are loading to prevent a FOUC +document.documentElement.className = "demo-loading"; + +require.config( { + baseUrl: "../../ui", + paths: { + jquery: "../external/jquery/jquery", + external: "../external/" + }, + shim: { + "external/globalize/globalize.culture.de-DE": [ "external/globalize/globalize" ], + "external/globalize/globalize.culture.ja-JP": [ "external/globalize/globalize" ] + } +} ); + +// Replace effects all shortcut modules with all the effects modules +if ( modules && modules.indexOf( "effects-all" ) !== -1 ) { + modules = modules.replace( /effects-all/, effectsAll.join( " " ) ); +} + +modules = modules ? modules.replace( /^\s+|\s+$/g, "" ).split( /\s+/ ) : []; +modules.push( pathParts[ pathParts.length - 2 ] ); + +require( modules, function() { + var newScript = document.createElement( "script" ); + + document.documentElement.className = ""; + + newScript.text = "( function() { " + script.innerHTML + " } )();"; + document.head.appendChild( script ).parentNode.removeChild( script ); +} ); + +} )(); |