This repository has been archived by the owner on Feb 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from virtualidentityag/dependency-management
Dependency management, minification
- Loading branch information
Showing
18 changed files
with
866 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# EditorConfig helps developers define and maintain consistent | ||
# coding styles between different editors and IDEs | ||
# editorconfig.org | ||
|
||
root = true | ||
|
||
|
||
[*] | ||
|
||
# Change these settings to your own preference | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
# We recommend you to keep these unchanged | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[bower.json] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[package.json] | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/node_modules | ||
/.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "resourceLoader", | ||
"homepage": "https://github.com/virtualidentityag/conditional-resource-loader", | ||
"version": "0.0.8", | ||
"version": "1.2.0", | ||
"main": "resourceLoader.js" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>Demo for conditional loader</title> | ||
<script src="http://code.jquery.com/jquery-3.1.1.js"></script> | ||
<!--<script src="http://code.jquery.com/jquery-2.2.0.min.js"></script>--> | ||
<script src="../src/resourceLoader.js"></script> | ||
<script> | ||
$(document).ready(function(){ | ||
console.log('domReady fired!'); | ||
|
||
$(window).on('resourcesReady', function() { | ||
console.log('ressourcesReady fired!'); | ||
|
||
//initiazlie components with data-init attribute | ||
$('*[data-init]').each(function() { | ||
var init = eval($(this).attr('data-init')); | ||
init($(this)); | ||
}); | ||
}); | ||
|
||
resourceLoader({ | ||
base: 'resources/', | ||
baseMap: { | ||
'##content': 'resources-content/' | ||
}, | ||
debug: true | ||
}); | ||
}); | ||
</script> | ||
</head> | ||
<body> | ||
<div class="demo4" | ||
data-init="(function($elm) { $elm.component2(); $elm.component1(); })" | ||
data-resources=" | ||
[ | ||
{ | ||
paths: ['js/jquery.component1.js'] | ||
}, | ||
{ | ||
paths: ['js/jquery.component2.js', '/demo/resources-content/css/demo4.css'], | ||
dependsOn: ['js/jquery.component1.js'] | ||
} | ||
]"> | ||
Resources are loaded in order of dependencies: component1.js -> component2.js, demo4.css | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.demo1, | ||
.demo2, | ||
.demo3, | ||
.demo4 { | ||
font-weight: bold; | ||
} | ||
|
||
.demo4 { | ||
padding: 20px; | ||
margin-bottom: 20px; | ||
background-color: greenyellow; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
.demo1, | ||
.demo2 { | ||
.demo2, | ||
.demo3 { | ||
padding: 20px; | ||
margin-bottom: 20px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.demo3 { | ||
background-color: lightblue; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
* @name jQuery Boilerplate | ||
* @version 1.0 | ||
* @lastmodified 2015-04-24 | ||
* @package html-css-js | ||
* @subpackage jQuery plugin | ||
* @author JR, VI | ||
* | ||
* based on: http://jqueryboilerplate.com/ | ||
*/ | ||
|
||
;(function ($, window, document, undefined) { | ||
'use strict'; | ||
|
||
var pluginName = 'component', | ||
defaults = { | ||
foo: 'bar' | ||
}; | ||
|
||
// The actual plugin constructor | ||
function Plugin(element, options) { | ||
this.$element = $(element); | ||
this.options = $.extend({}, defaults, options); | ||
this.init(); | ||
} | ||
|
||
// methods | ||
var methods = { | ||
init: function() { | ||
// your init is goes here | ||
this.myFunction(); | ||
}, | ||
|
||
myFunction: function(){ | ||
console.log('initializing component'); | ||
} | ||
}; | ||
|
||
// build | ||
$.extend(Plugin.prototype, methods); | ||
|
||
// A really lightweight plugin wrapper around the constructor, | ||
// preventing against multiple instantiations | ||
$.fn[pluginName] = function(options) { | ||
this.each(function() { | ||
if(!$.data(this, 'plugin_' + pluginName)) { | ||
$.data(this, 'plugin_' + pluginName, new Plugin(this, options)); | ||
|
||
/** | ||
* DEV-note: Use trigger failsafe events if other plugins depend on this plugins ready state | ||
*/ | ||
// trigger ready event on element - optional | ||
//$.triggerFailsafeEvent($(this), 'plugin_' + pluginName + '.ready'); | ||
} | ||
}); | ||
|
||
// trigger ready event globally - optional | ||
//if(this.length > 0) { | ||
// $.triggerFailsafeEvent($(window), 'plugin_' + pluginName + '.ready_all'); | ||
//} | ||
|
||
return this; | ||
}; | ||
|
||
})(jQuery, window, document); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
* @name jQuery Boilerplate | ||
* @version 1.0 | ||
* @lastmodified 2015-04-24 | ||
* @package html-css-js | ||
* @subpackage jQuery plugin | ||
* @author JR, VI | ||
* | ||
* based on: http://jqueryboilerplate.com/ | ||
*/ | ||
|
||
;(function ($, window, document, undefined) { | ||
'use strict'; | ||
|
||
var pluginName = 'component1', | ||
defaults = { | ||
foo: 'bar' | ||
}; | ||
|
||
// The actual plugin constructor | ||
function Plugin(element, options) { | ||
this.$element = $(element); | ||
this.options = $.extend({}, defaults, options); | ||
this.init(); | ||
} | ||
|
||
// methods | ||
var methods = { | ||
init: function() { | ||
// your init is goes here | ||
this.myFunction(); | ||
}, | ||
|
||
myFunction: function(){ | ||
console.log('initializing component1'); | ||
} | ||
}; | ||
|
||
// build | ||
$.extend(Plugin.prototype, methods); | ||
|
||
// A really lightweight plugin wrapper around the constructor, | ||
// preventing against multiple instantiations | ||
$.fn[pluginName] = function(options) { | ||
this.each(function() { | ||
if(!$.data(this, 'plugin_' + pluginName)) { | ||
$.data(this, 'plugin_' + pluginName, new Plugin(this, options)); | ||
|
||
/** | ||
* DEV-note: Use trigger failsafe events if other plugins depend on this plugins ready state | ||
*/ | ||
// trigger ready event on element - optional | ||
//$.triggerFailsafeEvent($(this), 'plugin_' + pluginName + '.ready'); | ||
} | ||
}); | ||
|
||
// trigger ready event globally - optional | ||
//if(this.length > 0) { | ||
// $.triggerFailsafeEvent($(window), 'plugin_' + pluginName + '.ready_all'); | ||
//} | ||
|
||
return this; | ||
}; | ||
|
||
})(jQuery, window, document); |
Oops, something went wrong.