Skip to content

Commit 7336a58

Browse files
committed
Demos: Add new infrastructure using a require.js bootstrap
Fixes #10119 Closes jquerygh-1557
1 parent 62446d9 commit 7336a58

File tree

3 files changed

+74
-1
lines changed

3 files changed

+74
-1
lines changed

Gruntfile.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,18 @@ grunt.initConfig({
205205
},
206206
uglify: minify,
207207
htmllint: {
208-
good: [ "demos/**/*.html", "tests/**/*.html" ].concat( htmllintBad.map( function( file ) {
208+
good: [ "tests/**/*.html" ].concat( htmllintBad.map( function( file ) {
209209
return "!" + file;
210210
} ) ),
211+
demos: {
212+
options: {
213+
ignore: [
214+
/The text content of element script was not in the required format: Expected space, tab, newline, or slash but found . instead/
215+
] },
216+
src: [ "demos/**/*.html" ].concat( htmllintBad.map( function( file ) {
217+
return "!" + file;
218+
} ) )
219+
},
211220
bad: {
212221
options: {
213222
ignore: [

demos/bootstrap.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/* globals window:true, document:true */
2+
( function() {
3+
4+
// Find the script element
5+
var scripts = document.getElementsByTagName( "script" );
6+
var script = scripts[ scripts.length - 1 ];
7+
8+
// Read the modules
9+
var modules = script.getAttribute( "data-modules" );
10+
var pathParts = window.location.pathname.split( "/" );
11+
var effectsAll = [
12+
"effect-blind",
13+
"effect-bounce",
14+
"effect-clip",
15+
"effect-drop",
16+
"effect-explode",
17+
"effect-fade",
18+
"effect-fold",
19+
"effect-highlight",
20+
"effect-puff",
21+
"effect-pulsate",
22+
"effect-scale",
23+
"effect-shake",
24+
"effect-size",
25+
"effect-slide"
26+
];
27+
28+
// Hide the page while things are loading to prevent a FOUC
29+
document.documentElement.className = "demo-loading";
30+
31+
require.config( {
32+
baseUrl: "../../ui",
33+
paths: {
34+
jquery: "../external/jquery/jquery",
35+
external: "../external/"
36+
},
37+
shim: {
38+
"external/globalize/globalize.culture.de-DE": [ "external/globalize/globalize" ],
39+
"external/globalize/globalize.culture.ja-JP": [ "external/globalize/globalize" ]
40+
}
41+
} );
42+
43+
// Replace effects all shortcut modules with all the effects modules
44+
if ( modules && modules.indexOf( "effects-all" ) !== -1 ) {
45+
modules = modules.replace( /effects-all/, effectsAll.join( " " ) );
46+
}
47+
48+
modules = modules ? modules.replace( /^\s+|\s+$/g, "" ).split( /\s+/ ) : [];
49+
modules.push( pathParts[ pathParts.length - 2 ] );
50+
51+
require( modules, function() {
52+
var newScript = document.createElement( "script" );
53+
54+
document.documentElement.className = "";
55+
56+
newScript.text = "( function() { " + script.innerHTML + " } )();";
57+
document.head.appendChild( script ).parentNode.removeChild( script );
58+
} );
59+
60+
} )();

demos/demos.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ body {
22
font-family: Arial, Helvetica, sans-serif;
33
}
44

5+
.demo-loading {
6+
visibility: hidden;
7+
}
8+
59
table {
610
font-size: 1em;
711
}

0 commit comments

Comments
 (0)