Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ You can add project name, project logo or change settings modifying `config.txt`
"projectName": "", //Project name
"projectUrl": "", //Domain name of your project
"projectLogo": "", //path to your project logo
"defaultJsResources": [], //Javascript resources that will load for all snippets automatically
"jsResources": [], //Javascript resources that's going to be included into the snippets
"viewportWidths": [ //Predefinded viewport breakpoints
480,
Expand Down
1 change: 1 addition & 0 deletions bin/styleguide
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var getMainConfig = function(folder) {
projectUrl: '',
projectLogo: '',

defaultJsResources: [],
jsResources: [],
viewportWidths: [320, 480, 768, 1024, 1200],

Expand Down
10 changes: 10 additions & 0 deletions templates/js/iframes.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ var iframesService = (function ($, snippetService) {
});
};

module.getDefaultJavaScripts = function (callback) {
getConfig(function (config) {
if (config.defaultJsResources) {
callback(config.defaultJsResources);
} else {
console.log('No default JavaScript files are defined in configuration to load into iframe.');
}
});
};

module.getJavaScripts = function (callback) {
getConfig(function (config) {
if (config.jsResources) {
Expand Down
8 changes: 8 additions & 0 deletions templates/js/snippetActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ var snippetActions = (function ($, snippetService, iframesService, editorService
.find('script')
.remove();

iframesService.getDefaultJavaScripts(function (defaultJsResources) {
length = defaultJsResources.length;

for (index = 0; index < length; index++) {
injectJavaScript(document.getElementById(frameId.attr('id')), defaultJsResources[index]);
}
});

if (includeJs === true || includeJs === "true") {
rawJsFrame = document.getElementById(frameId.attr('id'));

Expand Down