mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 23:16:52 +08:00
Event unit and some minor cleanups
This commit is contained in:
8
dist/ionic.js
vendored
8
dist/ionic.js
vendored
@ -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);
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -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);
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -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
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user