corrade-http-templates – Blame information for rev 57

Subversion Repositories:
Rev:
Rev Author Line No. Line
57 office 1 /* globals window, document */
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 composite = script.getAttribute( "data-composite" ) || false;
11 var pathParts = window.location.pathname.split( "/" );
12 var effectsAll = [
13 "effects/effect-blind",
14 "effects/effect-bounce",
15 "effects/effect-clip",
16 "effects/effect-drop",
17 "effects/effect-explode",
18 "effects/effect-fade",
19 "effects/effect-fold",
20 "effects/effect-highlight",
21 "effects/effect-puff",
22 "effects/effect-pulsate",
23 "effects/effect-scale",
24 "effects/effect-shake",
25 "effects/effect-size",
26 "effects/effect-slide",
27 "effects/effect-transfer"
28 ];
29 var widgets = [
30 "accordion",
31 "autocomplete",
32 "button",
33 "checkboxradio",
34 "controlgroup",
35 "datepicker",
36 "dialog",
37 "draggable",
38 "droppable",
39 "menu",
40 "mouse",
41 "progressbar",
42 "resizable",
43 "selectable",
44 "selectmenu",
45 "slider",
46 "sortable",
47 "spinner",
48 "tabs",
49 "tooltip"
50 ];
51  
52 function getPath( module ) {
53 for ( var i = 0; i < widgets.length; i++ ) {
54 if ( widgets[ i ] === module ) {
55 return "widgets/" + module;
56 }
57 }
58 for ( var j = 0; j < effectsAll.length; j++ ) {
59 if ( module !== "effect" ) {
60 if ( effectsAll[ j ] === module ) {
61 return module;
62 }
63 if ( effectsAll[ j ].indexOf( module ) !== -1 ) {
64 return "effects/" + module;
65 }
66 }
67 }
68 return module;
69 }
70 function fixPaths( modules ) {
71 for ( var i = 0; i < modules.length; i++ ) {
72 modules[ i ] = getPath( modules[ i ] );
73 }
74 return modules;
75 }
76  
77 // Hide the page while things are loading to prevent a FOUC
78 document.documentElement.className = "demo-loading";
79  
80 require.config( {
81 baseUrl: window.location.pathname.indexOf( "demos/" ) !== -1 ? "../../ui" : "../../../ui",
82 paths: {
83 jquery: "../external/jquery/jquery",
84 external: "../external/"
85 },
86 shim: {
87 "external/globalize/globalize.culture.de-DE": [ "external/globalize/globalize" ],
88 "external/globalize/globalize.culture.ja-JP": [ "external/globalize/globalize" ]
89 }
90 } );
91  
92 // Replace effects all shortcut modules with all the effects modules
93 if ( modules && modules.indexOf( "effects-all" ) !== -1 ) {
94 modules = modules.replace( /effects-all/, effectsAll.join( " " ) );
95 }
96  
97 modules = modules ? modules.replace( /^\s+|\s+$/g, "" ).split( /\s+/ ) : [];
98 if ( !composite ) {
99 modules.push( pathParts[ pathParts.length - 2 ] );
100 }
101 modules = fixPaths( modules );
102  
103 require( modules, function() {
104 var newScript = document.createElement( "script" );
105  
106 document.documentElement.className = "";
107  
108 newScript.text = "( function() { " + script.innerHTML + " } )();";
109 document.body.appendChild( newScript ).parentNode.removeChild( newScript );
110 } );
111  
112 } )();