Event unit and some minor cleanups

This commit is contained in:
Max Lynch
2013-09-25 10:42:20 -05:00
parent 37d708b05e
commit a8a2217182
3 changed files with 6 additions and 15 deletions

8
dist/ionic.js vendored
View File

@ -100,7 +100,7 @@ if ( document.readyState === "complete" ) {
* detects special events like tap/swipe/etc. and emits them * detects special events like tap/swipe/etc. and emits them
* as custom events that can be used in an app. * as custom events that can be used in an app.
* *
* Portions lovingly adapted from github.com/maker/ratchet and github.com/alexgibson/tap.js - thanks guys! * Portions adapted from github.com/maker/ratchet and github.com/alexgibson/tap.js - thanks guys!
*/ */
(function(ionic) { (function(ionic) {
@ -109,9 +109,7 @@ if ( document.readyState === "complete" ) {
// Trigger a new event // Trigger a new event
trigger: function(eventType, data) { trigger: function(eventType, data) {
// TODO: Do we need to use the old-school createEvent stuff?
var event = new CustomEvent(eventType, data); var event = new CustomEvent(eventType, data);
// Make sure to trigger the event on the given target, or dispatch it from // Make sure to trigger the event on the given target, or dispatch it from
// the window if we don't have an event target // the window if we don't have an event target
data.target && data.target.dispatchEvent(event) || window.dispatchEvent(event); data.target && data.target.dispatchEvent(event) || window.dispatchEvent(event);
@ -182,10 +180,6 @@ if ( document.readyState === "complete" ) {
e.preventDefault(); e.preventDefault();
}, },
handlePopState: function(event) {
console.log("EVENT: popstate", event);
},
}; };

View File

@ -7,7 +7,7 @@
* detects special events like tap/swipe/etc. and emits them * detects special events like tap/swipe/etc. and emits them
* as custom events that can be used in an app. * as custom events that can be used in an app.
* *
* Portions lovingly adapted from github.com/maker/ratchet and github.com/alexgibson/tap.js - thanks guys! * Portions adapted from github.com/maker/ratchet and github.com/alexgibson/tap.js - thanks guys!
*/ */
(function(ionic) { (function(ionic) {
@ -16,9 +16,7 @@
// Trigger a new event // Trigger a new event
trigger: function(eventType, data) { trigger: function(eventType, data) {
// TODO: Do we need to use the old-school createEvent stuff?
var event = new CustomEvent(eventType, data); var event = new CustomEvent(eventType, data);
// Make sure to trigger the event on the given target, or dispatch it from // Make sure to trigger the event on the given target, or dispatch it from
// the window if we don't have an event target // the window if we don't have an event target
data.target && data.target.dispatchEvent(event) || window.dispatchEvent(event); data.target && data.target.dispatchEvent(event) || window.dispatchEvent(event);
@ -89,10 +87,6 @@
e.preventDefault(); e.preventDefault();
}, },
handlePopState: function(event) {
console.log("EVENT: popstate", event);
},
}; };

View File

@ -1,6 +1,9 @@
describe('Ionic Events', function() { describe('Ionic Events', function() {
it('Should block all click events', function() { it('Should block all click events', function() {
var a = document.createElement('a'); var a = document.createElement('a');
a.click();
ionic.trigger('click', {
target: a
});
}); });
}); });