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

Commit

Permalink
fix(demos): codepen demos load svg assets
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ThomasBurleson committed Jan 19, 2016
1 parent 689a34d commit d860274
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
15 changes: 8 additions & 7 deletions docs/app/js/codepen.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@

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

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


return {
translate: translate
Expand All @@ -75,7 +76,7 @@
js: processJs(files.js),
css: mergeFiles( files.css ).join(' '),

js_external: externalScripts.concat([CORE_JS, ASSET_CACHE_JS]).join(';'),
js_external: externalScripts.concat([ASSET_CACHE_JS, CORE_JS]).join(';'),
css_external: [CORE_CSS, DOC_CSS].join(';')
});
}
Expand Down Expand Up @@ -184,18 +185,18 @@
.replace(/&/g, "&amp;");
}

// Required to make codepen work. Demos define their own module when running on the
// docs site. In order to ensure the codepen example can use the asset-cache, the
// Required to make codePen work. Demos define their own module when running on the
// docs site. In order to ensure the codepen example can use the svg-asset-cache.js, the
// module needs to match so that the $templateCache is populated with the necessary
// assets.

function replaceDemoModuleWithCodepenModule(file) {
var matchAngularModule = /\.module\(('[^']*'|"[^"]*")\s*,(\s*\[([^\]]*)\]\s*\))/ig;
var modules = "['ngMaterial', 'ngMessages', 'material.svgAssetsCache']";

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

return file.replace(matchAngularModule, ".module('MyApp',['ngMaterial', 'ngMessages'])");
return file.replace(matchAngularModule, ".module('MyApp',"+ modules + ")");
}
}
})();
Loading

0 comments on commit d860274

Please sign in to comment.