Skip to content

Commit 0930dfc

Browse files
committed
Demos: Add special case for effects and wrap eval code in an IIFE
1 parent 7441810 commit 0930dfc

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

demos/bootstrap.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,22 @@
77
// Read the modules
88
var modules = script.getAttribute( "data-modules" );
99
var pathParts = window.location.pathname.split( "/" );
10+
var effectsAll = [
11+
"effect-blind",
12+
"effect-bounce",
13+
"effect-clip",
14+
"effect-drop",
15+
"effect-explode",
16+
"effect-fade",
17+
"effect-fold",
18+
"effect-highlight",
19+
"effect-puff",
20+
"effect-pulsate",
21+
"effect-scale",
22+
"effect-shake",
23+
"effect-size",
24+
"effect-slide"
25+
];
1026

1127
require.config( {
1228
baseUrl: "../../ui",
@@ -15,11 +31,19 @@
1531
}
1632
} );
1733

34+
// Replace effects all shortcut modules with all the effects modules
35+
if ( modules && modules.indexOf( "effects-all" ) !== -1 ) {
36+
modules = modules.replace( /effects-all/, effectsAll.join( " " ) );
37+
}
38+
1839
modules = modules ? modules.replace( /^\s+|\s+$/g, "" ).split( /\s+/ ) : [];
1940
modules.push( pathParts[ pathParts.length - 2 ] );
2041

2142
require( modules, function() {
2243
$( "body" ).css( "visibility", "visible" );
23-
eval( $( script ).html() );
44+
45+
// We wrap the code in an IIFE so that return statements work and we
46+
// dont polute the global scope with variables
47+
$.globalEval( "(function(){ " + $( script ).html() + "})();" );
2448
} );
2549
})();

0 commit comments

Comments
 (0)