Fixed #153 with tests

This commit is contained in:
Max Lynch
2013-11-17 15:14:02 -06:00
parent 531044e9b0
commit ea2ff85e91
5 changed files with 58 additions and 4 deletions

View File

@ -23095,6 +23095,9 @@ angular.module('ionic.service.gesture', [])
return {
on: function(eventType, cb, $element) {
return window.ionic.onGesture(eventType, cb, $element[0]);
},
off: function(gesture, eventType, cb) {
return window.ionic.offGesture(gesture, eventType, cb);
}
};
}]);

4
dist/js/ionic.js vendored
View File

@ -291,8 +291,8 @@ window.ionic = {
ionic.on = function() { ionic.EventController.on.apply(ionic.EventController, arguments); };
ionic.off = function() { ionic.EventController.off.apply(ionic.EventController, arguments); };
ionic.trigger = function() { ionic.EventController.trigger.apply(ionic.EventController.trigger, arguments); };
ionic.onGesture = function() { ionic.EventController.onGesture.apply(ionic.EventController.onGesture, arguments); };
ionic.offGesture = function() { ionic.EventController.offGesture.apply(ionic.EventController.offGesture, arguments); };
ionic.onGesture = function() { return ionic.EventController.onGesture.apply(ionic.EventController.onGesture, arguments); };
ionic.offGesture = function() { return ionic.EventController.offGesture.apply(ionic.EventController.offGesture, arguments); };
// DISABLING FOR NOW. THE TAP CODE AT THE EXT LEVEL SHOULD BE DOING THIS
// Set up various listeners

View File

@ -4,6 +4,9 @@ angular.module('ionic.service.gesture', [])
return {
on: function(eventType, cb, $element) {
return window.ionic.onGesture(eventType, cb, $element[0]);
},
off: function(gesture, eventType, cb) {
return window.ionic.offGesture(gesture, eventType, cb);
}
};
}]);

View File

@ -0,0 +1,48 @@
describe('Ionic Gesture Service', function() {
var gesture;
beforeEach(module('ionic.service.gesture'));
beforeEach(inject(function(Gesture) {
gesture = Gesture;
}));
iit('Should bind', function() {
var el = document.createElement('div');
var handlers = {
dragHandle: function(e) {
}
};
spyOn(handlers, 'dragHandle');
gesture.on('drag', handlers.dragHandle, angular.element(el));
var event = new CustomEvent('drag', { target: el });
el.dispatchEvent(event);
expect(handlers.dragHandle).toHaveBeenCalled();
});
iit('Should unbind', function() {
var el = document.createElement('div');
var handlers = {
dragHandle: function(e) {
}
};
spyOn(handlers, 'dragHandle');
var g = gesture.on('drag', handlers.dragHandle, angular.element(el));
var event = new CustomEvent('drag', { target: el });
el.dispatchEvent(event);
expect(handlers.dragHandle).toHaveBeenCalled();
gesture.off(g, 'drag', handlers.dragHandle);
var event = new CustomEvent('drag', { target: el });
el.dispatchEvent(event);
expect(handlers.dragHandle).toHaveBeenCalled();
});
})

View File

@ -98,8 +98,8 @@
ionic.on = function() { ionic.EventController.on.apply(ionic.EventController, arguments); };
ionic.off = function() { ionic.EventController.off.apply(ionic.EventController, arguments); };
ionic.trigger = function() { ionic.EventController.trigger.apply(ionic.EventController.trigger, arguments); };
ionic.onGesture = function() { ionic.EventController.onGesture.apply(ionic.EventController.onGesture, arguments); };
ionic.offGesture = function() { ionic.EventController.offGesture.apply(ionic.EventController.offGesture, arguments); };
ionic.onGesture = function() { return ionic.EventController.onGesture.apply(ionic.EventController.onGesture, arguments); };
ionic.offGesture = function() { return ionic.EventController.offGesture.apply(ionic.EventController.offGesture, arguments); };
// DISABLING FOR NOW. THE TAP CODE AT THE EXT LEVEL SHOULD BE DOING THIS
// Set up various listeners