Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit d860274

Browse files
fix(demos): codepen demos load svg assets
The CodePen demo launches will now correctly load the external, svg-assets (and post-load $templateCache) used in some of the md-icon demos. * now defines external module 'material.svgAssetsCache' * now defines extra svgs for 'ic_euro_24px.svg', and 'ic_card_giftcard_24px.svg' Fixes #6695. Closes #6727
1 parent 689a34d commit d860274

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

docs/app/js/codepen.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@
5656

5757
var LINK_FONTS_ROBOTO = '<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700,400italic">';
5858

59-
var ASSET_CACHE_JS = 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-114/assets-cache.js';
59+
var ASSET_CACHE_JS = 'http://ngmaterial.assets.s3.amazonaws.com/svg-assets-cache.js';
60+
6061

6162
return {
6263
translate: translate
@@ -75,7 +76,7 @@
7576
js: processJs(files.js),
7677
css: mergeFiles( files.css ).join(' '),
7778

78-
js_external: externalScripts.concat([CORE_JS, ASSET_CACHE_JS]).join(';'),
79+
js_external: externalScripts.concat([ASSET_CACHE_JS, CORE_JS]).join(';'),
7980
css_external: [CORE_CSS, DOC_CSS].join(';')
8081
});
8182
}
@@ -184,18 +185,18 @@
184185
.replace(/&/g, "&amp;");
185186
}
186187

187-
// Required to make codepen work. Demos define their own module when running on the
188-
// docs site. In order to ensure the codepen example can use the asset-cache, the
188+
// Required to make codePen work. Demos define their own module when running on the
189+
// docs site. In order to ensure the codepen example can use the svg-asset-cache.js, the
189190
// module needs to match so that the $templateCache is populated with the necessary
190191
// assets.
192+
191193
function replaceDemoModuleWithCodepenModule(file) {
192194
var matchAngularModule = /\.module\(('[^']*'|"[^"]*")\s*,(\s*\[([^\]]*)\]\s*\))/ig;
195+
var modules = "['ngMaterial', 'ngMessages', 'material.svgAssetsCache']";
193196

194-
// Include 'ngMessages' since the 'assets-cache.js' has the same dependencies
195-
// angular.module('MyApp', ['ngMaterial', 'ngMessages'])
196197
// See scripts.js for list of external Angular libraries used for the demos
197198

198-
return file.replace(matchAngularModule, ".module('MyApp',['ngMaterial', 'ngMessages'])");
199+
return file.replace(matchAngularModule, ".module('MyApp',"+ modules + ")");
199200
}
200201
}
201202
})();

0 commit comments

Comments
 (0)