Skip to content

Commit

Permalink
handleStyle should now callback with load error, closed dialogs will …
Browse files Browse the repository at this point in the history
…now emit event
  • Loading branch information
skerit committed Feb 11, 2016
1 parent 9ba788d commit e21e68b
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions lib/class/scene.js
Expand Up @@ -277,7 +277,14 @@ module.exports = function hawkejsSceneClass(Hawkejs, Blast) {
that.handleScripts(options, next);
}, function loadStyles(next) {
// Get styles
that.handleStyles(options, next);
that.handleStyles(options, function handledStyles(err) {

if (err) {
if (console) console.error('Failed to handle styles:', err);
}

next();
});
}, function done(err) {

if (err != null) {
Expand Down Expand Up @@ -1164,7 +1171,14 @@ module.exports = function hawkejsSceneClass(Hawkejs, Blast) {
Function.parallel(false, function loadScripts(next) {
that.handleScripts(viewRender, next);
}, function loadStyles(next) {
that.handleStyles(viewRender, next);
that.handleStyles(viewRender, function handledStyles(err) {

if (err) {
if (console) console.error('Failed to handle styles:', err);
}

next();
});
}, function setAttributes(next) {

var oldElement,
Expand Down Expand Up @@ -1476,9 +1490,15 @@ module.exports = function hawkejsSceneClass(Hawkejs, Blast) {

// Set the onload event
if (callback != null) {

// Add onload callback
style.onload = function onStyleLoad() {
callback();
};

style.onerror = function onStyleError(event) {
callback(new Error('Failed to load style "' + path + '"'));
};
}

// Add it to the document
Expand Down Expand Up @@ -2200,9 +2220,14 @@ module.exports = function hawkejsSceneClass(Hawkejs, Blast) {
* @version 1.0.0
*/
Scene.setMethod(function dialogListener() {

var that = this;

this.on({type: 'set', category: 'dialog'}, function newDialog(el, variables) {

var wrapper,
var thatEvent = this,
filter = this.filter,
wrapper,
style;

style = 'position:fixed;width:100vw;height:100vh;background-color:rgba(0,0,0,0.4);top:0;';
Expand All @@ -2221,6 +2246,13 @@ module.exports = function hawkejsSceneClass(Hawkejs, Blast) {
// Only remove the wrapper if it was clicked itself
if (e.target == wrapper) {
wrapper.remove();

that.emit({
type: 'remove',
category: 'dialog',
template: filter.template,
theme: filter.theme
}, el);
}
});

Expand Down

0 comments on commit e21e68b

Please sign in to comment.