Browse Source

Emitters now include the triggering element in the emitted event. Modal updated for the new element.

dev-bank
Bryan Miller 5 years ago
parent
commit
9d661281c3
2 changed files with 5 additions and 4 deletions
  1. +3
    -2
      app/js/ui/Emitters.js
  2. +2
    -2
      app/js/ui/Modal.js

+ 3
- 2
app/js/ui/Emitters.js View File

@@ -3,7 +3,7 @@ import GlobalEvents from "/app/js/common/EventCaller.js";

function handle_emitter(event){
if (this.hasAttribute("emit")){
var args = [this.getAttribute("emit")];
var args = [this.getAttribute("emit"), this];
if (this.hasAttribute("emit-args")){
try {
var j = JSON.parse(this.getAttribute("emit-args"));
@@ -13,7 +13,8 @@ function handle_emitter(event){
args.push(j);
}
} catch (e) {
console.log("Failed to emit '" + args[0] + "'. Attribute 'emit-args' contains malformed JSON.");
console.log("Failed to emit '" + args[0] +"': " + e.toString());
//console.log("Failed to emit '" + args[0] + "'. Attribute 'emit-args' contains malformed JSON.");
}
}
GlobalEvents.emit.apply(GlobalEvents, args);

+ 2
- 2
app/js/ui/Modal.js View File

@@ -11,14 +11,14 @@ class Modal{
}
}).bind(this));

GlobalEvents.listen("modal-open", (function(event){
GlobalEvents.listen("modal-open", (function(target, event){
if (event.hasOwnProperty("id") && typeof(event.id) === 'string'){
var force = (event.hasOwnProperty("force")) ? event.force === true : false;
this.open_modal_id(event.id, force);
}
}).bind(this));

GlobalEvents.listen("modal-close", (function(event){
GlobalEvents.listen("modal-close", (function(target, event){
this.close_modal();
}).bind(this));
}

Loading…
Cancel
Save