diff --git a/js/utils/activator.js b/js/utils/activator.js
index 2210517f3a2..8be60e38e9f 100644
--- a/js/utils/activator.js
+++ b/js/utils/activator.js
@@ -14,7 +14,7 @@
// when an element is touched/clicked, it climbs up a few
// parents to see if it is an .item or .button element
ionic.requestAnimationFrame(function(){
- if (tapRequiresNativeClick(e.target)) return;
+ if ( ionic.tap.requiresNativeClick(e.target) ) return;
var ele = e.target;
var eleToActivate;
diff --git a/js/utils/tap.js b/js/utils/tap.js
index 5f63e783f10..7ec97a2cf7e 100644
--- a/js/utils/tap.js
+++ b/js/utils/tap.js
@@ -84,7 +84,7 @@ ionic.tap = {
ignoreScrollStart: function(e) {
return (e.defaultPrevented) || // defaultPrevented has been assigned by another component handling the event
(e.target.isContentEditable) ||
- (e.target.type === 'range') ||
+ (/file|range/i).test(e.target.type) ||
(e.target.dataset ? e.target.dataset.preventScroll : e.target.getAttribute('data-prevent-default')) == 'true' || // manually set within an elements attributes
(!!(/object|embed/i).test(e.target.tagName)); // flash/movie/object touches should not try to scroll
},
@@ -149,6 +149,22 @@ ionic.tap = {
previousInputFocus[x].focus();
}
});
+ },
+
+ requiresNativeClick: function(ele) {
+ if(!ele || ele.disabled || (/file|range/i).test(ele.type) || (/object|video/i).test(ele.tagName) ) {
+ return true;
+ }
+ if(ele.nodeType === 1) {
+ var element = ele;
+ while(element) {
+ if( (element.dataset ? element.dataset.tapDisabled : element.getAttribute('data-tap-disabled')) == 'true' ) {
+ return true;
+ }
+ element = element.parentElement;
+ }
+ }
+ return false;
}
};
@@ -166,7 +182,7 @@ function tapClick(e) {
var container = tapContainingElement(e.target);
var ele = tapTargetElement(container);
- if( tapRequiresNativeClick(ele) || tapPointerMoved ) return false;
+ if( ionic.tap.requiresNativeClick(ele) || tapPointerMoved ) return false;
var c = getPointerCoordinates(e);
@@ -193,7 +209,7 @@ function tapClickGateKeeper(e) {
// do not allow through any click events that were not created by ionic.tap
if( (ionic.scroll.isScrolling && ionic.tap.containsOrIsTextInput(e.target) ) ||
- (!e.isIonicTap && !tapRequiresNativeClick(e.target)) ) {
+ (!e.isIonicTap && !ionic.tap.requiresNativeClick(e.target)) ) {
console.debug('clickPrevent', e.target.tagName);
e.stopPropagation();
@@ -205,22 +221,6 @@ function tapClickGateKeeper(e) {
}
}
-function tapRequiresNativeClick(ele) {
- if(!ele || ele.disabled || (/file|range/i).test(ele.type) || (/object|video/i).test(ele.tagName) ) {
- return true;
- }
- if(ele.nodeType === 1) {
- var element = ele;
- while(element) {
- if( (element.dataset ? element.dataset.tapDisabled : element.getAttribute('data-tap-disabled')) == 'true' ) {
- return true;
- }
- element = element.parentElement;
- }
- }
- return false;
-}
-
// MOUSE
function tapMouseDown(e) {
if(e.isIonicTap || tapIgnoreEvent(e)) return;
diff --git a/test/unit/angular/service/activator.unit.js b/test/unit/utils/activator.unit.js
similarity index 95%
rename from test/unit/angular/service/activator.unit.js
rename to test/unit/utils/activator.unit.js
index 658f27518dc..ef0e44fdbe3 100644
--- a/test/unit/angular/service/activator.unit.js
+++ b/test/unit/utils/activator.unit.js
@@ -4,8 +4,8 @@ describe('Ionic Element Activator', function() {
window.setTimeout = ionic.requestAnimationFrame = function(cb) { cb(); };
});
- it('should not active an if tapRequiresNativeClick is true', function() {
- spyOn(window, 'tapRequiresNativeClick').andReturn(true);
+ it('should not active an if ionic.tap.requiresNativeClick is true', function() {
+ spyOn(ionic.tap, 'requiresNativeClick').andReturn(true);
var e = { target: document.createElement('a') };
ionic.activator.start(e);
expect(e.target.classList.contains('activated')).toEqual(false);
diff --git a/test/unit/utils/tap.unit.js b/test/unit/utils/tap.unit.js
index 5963522f4f5..537ed4a525b 100644
--- a/test/unit/utils/tap.unit.js
+++ b/test/unit/utils/tap.unit.js
@@ -549,60 +549,60 @@ describe('Ionic Tap', function() {
expect( tapClick(e) ).toEqual(false);
});
- it('Should tapRequiresNativeClick for invalid element', function() {
- expect( tapRequiresNativeClick( null ) ).toEqual(true);
+ it('Should ionic.tap.requiresNativeClick for invalid element', function() {
+ expect( ionic.tap.requiresNativeClick( null ) ).toEqual(true);
});
- it('Should tapRequiresNativeClick for input.disabled', function() {
+ it('Should ionic.tap.requiresNativeClick for input.disabled', function() {
var ele = document.createElement('input');
ele.disabled = true;
- expect( tapRequiresNativeClick( ele ) ).toEqual(true);
+ expect( ionic.tap.requiresNativeClick( ele ) ).toEqual(true);
});
- it('Should tapRequiresNativeClick for input[range]', function() {
+ it('Should ionic.tap.requiresNativeClick for input[range]', function() {
var ele = document.createElement('input');
ele.type = 'range';
- expect( tapRequiresNativeClick( ele ) ).toEqual(true);
+ expect( ionic.tap.requiresNativeClick( ele ) ).toEqual(true);
});
- it('Should tapRequiresNativeClick for input[file]', function() {
+ it('Should ionic.tap.requiresNativeClick for input[file]', function() {
var ele = document.createElement('input');
ele.type = 'file';
- expect( tapRequiresNativeClick( ele ) ).toEqual(true);
+ expect( ionic.tap.requiresNativeClick( ele ) ).toEqual(true);
});
- it('Should tapRequiresNativeClick for video element', function() {
+ it('Should ionic.tap.requiresNativeClick for video element', function() {
var ele = document.createElement('video');
- expect( tapRequiresNativeClick( ele ) ).toEqual(true);
+ expect( ionic.tap.requiresNativeClick( ele ) ).toEqual(true);
});
- it('Should tapRequiresNativeClick for object element', function() {
+ it('Should ionic.tap.requiresNativeClick for object element', function() {
var ele = document.createElement('object');
- expect( tapRequiresNativeClick( ele ) ).toEqual(true);
+ expect( ionic.tap.requiresNativeClick( ele ) ).toEqual(true);
});
- it('Should not tapRequiresNativeClick for common inputs', function() {
+ it('Should not ionic.tap.requiresNativeClick for common inputs', function() {
var inputTypes = ['text', 'email', 'search', 'tel', 'number', 'date', 'month', 'password', null, undefined, ''];
for(var x=0; x