From c7b96cb52d25d1fb92d7bab7db8f7b485bb30544 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Tue, 1 Oct 2013 09:42:54 -0500 Subject: [PATCH 1/3] toggle drag --- dist/ionic-simple.js | 4 ---- dist/ionic.css | 7 ++++++ dist/ionic.js | 47 +++++++++++++++++++++++++++++++++++----- dist/ionicIcons.css | 7 ++++++ js/ext/simple/init.js | 4 ---- js/gestures.js | 2 ++ js/views/toggleView.js | 45 +++++++++++++++++++++++++++++++++----- scss/ionic/_toggle.scss | 9 ++++++++ test/index.html | 48 ++++++++++++++++++++++------------------- test/input-toggle.html | 8 +++---- 10 files changed, 137 insertions(+), 44 deletions(-) diff --git a/dist/ionic-simple.js b/dist/ionic-simple.js index fbff374a68..fdc2fa738a 100644 --- a/dist/ionic-simple.js +++ b/dist/ionic-simple.js @@ -7,10 +7,6 @@ ionic.Components.push(instance); }; - ionic.get = function(elementId) { - return ionic.component( document.getElementById(elementId) ); - }; - ionic.component = function(el) { if(el) { if(el.component) { diff --git a/dist/ionic.css b/dist/ionic.css index 78049739f0..f8fd1689b3 100644 --- a/dist/ionic.css +++ b/dist/ionic.css @@ -1909,6 +1909,13 @@ input[type="checkbox"][readonly] { border-radius: 50%; background-color: white; transition: -webkit-transform 0.1s ease-in-out; } + .toggle .handle:before { + position: absolute; + content: '.'; + color: transparent; + left: -14px; + top: -11px; + padding: 14px 30px; } /* When the toggle is "on" */ .toggle :checked + .track { diff --git a/dist/ionic.js b/dist/ionic.js index 7ae84f94a8..3d2a2b7df0 100644 --- a/dist/ionic.js +++ b/dist/ionic.js @@ -270,6 +270,8 @@ window.ionic = { if(this === this.window) { // this is a window, then only allow the Tap gesture to be added ionic.Gestures.detection.register(ionic.Gestures.gestures.Tap); + ionic.Gestures.detection.register(ionic.Gestures.gestures.Drag); + ionic.Gestures.detection.register(ionic.Gestures.gestures.Release); } else { // everything else but the window for(var name in ionic.Gestures.gestures) { @@ -1971,6 +1973,7 @@ ionic.views.TabBar.prototype = { this.checkbox = opts.checkbox; this.track = opts.track; this.handle = opts.handle; + this.openPercent = -1; // remember that this element, and all its children are apart of a component // and assign the component instance to each element so the lookups @@ -1980,21 +1983,55 @@ ionic.views.TabBar.prototype = { this.track.isComponent = true; this.handle.component = this; this.handle.isComponent = true; - - // ensure the handle is draggable - this.handle.draggable = true; }; ionic.views.Toggle.prototype = { tap: function(e) { - e.stopPropa - return false; + this.val( !this.checkbox.checked ); + }, + + drag: function(e) { + var slidePageLeft = this.track.offsetLeft + (this.handle.offsetWidth / 2); + var slidePageRight = this.track.offsetLeft + this.track.offsetWidth - (this.handle.offsetWidth / 2); + + if(e.pageX >= slidePageRight - 4) { + this.val(true); + } else if(e.pageX <= slidePageLeft) { + this.val(false); + } else { + this.setOpenPercent( Math.round( (1 - ((slidePageRight - e.pageX) / (slidePageRight - slidePageLeft) )) * 100) ); + } + }, + + setOpenPercent: function(openPercent) { + // only make a change if the new open percent has changed + if(this.openPercent < 0 || (openPercent < (this.openPercent - 3) || openPercent > (this.openPercent + 3) ) ) { + this.openPercent = openPercent; + + if(openPercent === 0) { + this.val(false); + } else if(openPercent === 100) { + this.val(true); + } else { + var openPixel = Math.round( (openPercent / 100) * this.track.offsetWidth - (this.handle.offsetWidth) ); + openPixel = (openPixel < 1 ? 0 : openPixel); + this.handle.style.webkitTransform = 'translate3d(' + openPixel + 'px,0,0)'; + } + } + }, + + release: function(e) { + this.val( this.openPercent >= 50 ); }, val: function(value) { if(value === true || value === false) { + if(this.handle.style.webkitTransform !== "") { + this.handle.style.webkitTransform = ""; + } this.checkbox.checked = value; + this.openPercent = (value ? 100 : 0); } return this.checkbox.checked; } diff --git a/dist/ionicIcons.css b/dist/ionicIcons.css index 78049739f0..f8fd1689b3 100644 --- a/dist/ionicIcons.css +++ b/dist/ionicIcons.css @@ -1909,6 +1909,13 @@ input[type="checkbox"][readonly] { border-radius: 50%; background-color: white; transition: -webkit-transform 0.1s ease-in-out; } + .toggle .handle:before { + position: absolute; + content: '.'; + color: transparent; + left: -14px; + top: -11px; + padding: 14px 30px; } /* When the toggle is "on" */ .toggle :checked + .track { diff --git a/js/ext/simple/init.js b/js/ext/simple/init.js index 308f2b6894..fd7afd64c9 100644 --- a/js/ext/simple/init.js +++ b/js/ext/simple/init.js @@ -7,10 +7,6 @@ ionic.Components.push(instance); }; - ionic.get = function(elementId) { - return ionic.component( document.getElementById(elementId) ); - }; - ionic.component = function(el) { if(el) { if(el.component) { diff --git a/js/gestures.js b/js/gestures.js index e836e94232..32346c3d99 100644 --- a/js/gestures.js +++ b/js/gestures.js @@ -93,6 +93,8 @@ if(this === this.window) { // this is a window, then only allow the Tap gesture to be added ionic.Gestures.detection.register(ionic.Gestures.gestures.Tap); + ionic.Gestures.detection.register(ionic.Gestures.gestures.Drag); + ionic.Gestures.detection.register(ionic.Gestures.gestures.Release); } else { // everything else but the window for(var name in ionic.Gestures.gestures) { diff --git a/js/views/toggleView.js b/js/views/toggleView.js index e8fe6af0b6..5c3c27c8e0 100644 --- a/js/views/toggleView.js +++ b/js/views/toggleView.js @@ -6,6 +6,7 @@ this.checkbox = opts.checkbox; this.track = opts.track; this.handle = opts.handle; + this.openPercent = -1; // remember that this element, and all its children are apart of a component // and assign the component instance to each element so the lookups @@ -15,21 +16,55 @@ this.track.isComponent = true; this.handle.component = this; this.handle.isComponent = true; - - // ensure the handle is draggable - this.handle.draggable = true; }; ionic.views.Toggle.prototype = { tap: function(e) { - e.stopPropa - return false; + this.val( !this.checkbox.checked ); + }, + + drag: function(e) { + var slidePageLeft = this.track.offsetLeft + (this.handle.offsetWidth / 2); + var slidePageRight = this.track.offsetLeft + this.track.offsetWidth - (this.handle.offsetWidth / 2); + + if(e.pageX >= slidePageRight - 4) { + this.val(true); + } else if(e.pageX <= slidePageLeft) { + this.val(false); + } else { + this.setOpenPercent( Math.round( (1 - ((slidePageRight - e.pageX) / (slidePageRight - slidePageLeft) )) * 100) ); + } + }, + + setOpenPercent: function(openPercent) { + // only make a change if the new open percent has changed + if(this.openPercent < 0 || (openPercent < (this.openPercent - 3) || openPercent > (this.openPercent + 3) ) ) { + this.openPercent = openPercent; + + if(openPercent === 0) { + this.val(false); + } else if(openPercent === 100) { + this.val(true); + } else { + var openPixel = Math.round( (openPercent / 100) * this.track.offsetWidth - (this.handle.offsetWidth) ); + openPixel = (openPixel < 1 ? 0 : openPixel); + this.handle.style.webkitTransform = 'translate3d(' + openPixel + 'px,0,0)'; + } + } + }, + + release: function(e) { + this.val( this.openPercent >= 50 ); }, val: function(value) { if(value === true || value === false) { + if(this.handle.style.webkitTransform !== "") { + this.handle.style.webkitTransform = ""; + } this.checkbox.checked = value; + this.openPercent = (value ? 100 : 0); } return this.checkbox.checked; } diff --git a/scss/ionic/_toggle.scss b/scss/ionic/_toggle.scss index 105fd34e33..8e21465a44 100644 --- a/scss/ionic/_toggle.scss +++ b/scss/ionic/_toggle.scss @@ -36,6 +36,15 @@ border-radius: $toggle-handle-radius; background-color: $toggle-handle-off-bg-color; transition: -webkit-transform $toggle-transition-duration ease-in-out; + + &:before { + position: absolute; + content: '.'; + color: transparent; + left: ( ($toggle-handle-width / 2) * -1); + top: ( ($toggle-handle-height / 2) * -1) + 3; + padding: ($toggle-handle-height / 2) ($toggle-handle-width + 2); + } } diff --git a/test/index.html b/test/index.html index d407da003b..7fe863d48a 100644 --- a/test/index.html +++ b/test/index.html @@ -16,28 +16,32 @@

Ionic Tests

-
-

Alerts

-

Buttons

-

Button Groups

-

Cards

-

Footers

-

Headers

-

Input: Text (single-line)

-

Input: Text (multi-line)

-

Input: Radio Buttons

-

Input: Range

-

Input: Select

-

Input: Toggle

-

Lists

-

Modals

-

Popovers

-

Pull To Refresh

-

Side Menus

-

Swipe

-

Tab Bars

-

Type

-
+
+ +
+

Alerts

+

Buttons

+

Button Groups

+

Cards

+

Footers

+

Headers

+

Input: Text (single-line)

+

Input: Text (multi-line)

+

Input: Radio Buttons

+

Input: Range

+

Input: Select

+

Input: Toggle

+

Lists

+

Modals

+

Popovers

+

Pull To Refresh

+

Side Menus

+

Swipe

+

Tab Bars

+

Type

+
+ +
diff --git a/test/input-toggle.html b/test/input-toggle.html index 3c54c77ef8..02b15edc5e 100644 --- a/test/input-toggle.html +++ b/test/input-toggle.html @@ -21,21 +21,21 @@ From 7386f3f468212aff3f00e4b225ef8509386ec2c0 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Tue, 1 Oct 2013 09:57:49 -0500 Subject: [PATCH 2/3] filename updates --- Gruntfile.js | 18 ++++--- dist/ionic.js | 53 +++++++++++---------- js/views/{headerBar.js => headerBarView.js} | 1 + js/views/{navBar.js => navBarView.js} | 0 js/views/{sideMenu.js => sideMenuView.js} | 0 js/views/{tabBar.js => tabBarView.js} | 0 6 files changed, 40 insertions(+), 32 deletions(-) rename js/views/{headerBar.js => headerBarView.js} (99%) rename js/views/{navBar.js => navBarView.js} (100%) rename js/views/{sideMenu.js => sideMenuView.js} (100%) rename js/views/{tabBar.js => tabBarView.js} (100%) diff --git a/Gruntfile.js b/Gruntfile.js index 04af4b649d..628f36dffc 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -9,32 +9,38 @@ module.exports = function(grunt) { }, dist: { src: [ + 'js/ionic.js', 'js/platform.js', 'js/utils.js', 'js/events.js', 'js/gestures.js', 'js/animate.js', + 'js/viewController.js', - 'js/views/navBar.js', - 'js/views/headerBar.js', - 'js/views/tabBar.js', - 'js/views/sideMenu.js', + + 'js/views/navBarView.js', + 'js/views/headerBarView.js', + 'js/views/sideMenuView.js', + 'js/views/tabBarView.js', 'js/views/toggleView.js', + 'js/controllers/**/*.js', + 'js/tapPolyfill.js' + ], dest: 'dist/<%= pkg.name %>.js' }, distAngular: { src: [ - 'ext/angular/src/*.js' + 'js/ext/angular/src/*.js' ], dest: 'dist/<%= pkg.name %>-angular.js' }, distSimple: { src: [ - 'ext/simple/*.js' + 'js/ext/simple/*.js' ], dest: 'dist/<%= pkg.name %>-simple.js' } diff --git a/dist/ionic.js b/dist/ionic.js index 3d2a2b7df0..d0aac8adb5 100644 --- a/dist/ionic.js +++ b/dist/ionic.js @@ -1712,7 +1712,8 @@ window.ionic = { }; })(ionic); -;(function(ionic) { +; +(function(ionic) { ionic.views.HeaderBar = function(opts) { this.el = opts.el; @@ -1738,6 +1739,31 @@ window.ionic = { } }; +})(ionic); +; +(function(ionic) { + + ionic.views.SideMenu = function(opts) { + this.el = opts.el; + this.width = opts.width; + this.isEnabled = opts.isEnabled || true; + }; + + ionic.views.SideMenu.prototype = { + getFullWidth: function() { + return this.width; + }, + setIsEnabled: function(isEnabled) { + this.isEnabled = isEnabled; + }, + bringUp: function() { + this.el.style.zIndex = 0; + }, + pushDown: function() { + this.el.style.zIndex = -1; + } + }; + })(ionic); ;(function(ionic) { @@ -1941,31 +1967,6 @@ ionic.views.TabBar.prototype = { })(window.ionic); ; -(function(ionic) { - - ionic.views.SideMenu = function(opts) { - this.el = opts.el; - this.width = opts.width; - this.isEnabled = opts.isEnabled || true; - }; - - ionic.views.SideMenu.prototype = { - getFullWidth: function() { - return this.width; - }, - setIsEnabled: function(isEnabled) { - this.isEnabled = isEnabled; - }, - bringUp: function() { - this.el.style.zIndex = 0; - }, - pushDown: function() { - this.el.style.zIndex = -1; - } - }; - -})(ionic); -; (function(ionic) { ionic.views.Toggle = function(opts) { diff --git a/js/views/headerBar.js b/js/views/headerBarView.js similarity index 99% rename from js/views/headerBar.js rename to js/views/headerBarView.js index 4b43c58bbe..636e1181ee 100644 --- a/js/views/headerBar.js +++ b/js/views/headerBarView.js @@ -1,3 +1,4 @@ + (function(ionic) { ionic.views.HeaderBar = function(opts) { diff --git a/js/views/navBar.js b/js/views/navBarView.js similarity index 100% rename from js/views/navBar.js rename to js/views/navBarView.js diff --git a/js/views/sideMenu.js b/js/views/sideMenuView.js similarity index 100% rename from js/views/sideMenu.js rename to js/views/sideMenuView.js diff --git a/js/views/tabBar.js b/js/views/tabBarView.js similarity index 100% rename from js/views/tabBar.js rename to js/views/tabBarView.js From a0a720988d103bf0a7be0620bb241fafde1bb6df Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Tue, 1 Oct 2013 10:45:20 -0500 Subject: [PATCH 3/3] move stuff to js/utils --- Gruntfile.js | 15 +- dist/ionic.js | 315 +++++++++++++------------ js/{ => controllers}/viewController.js | 0 js/{ => utils}/animate.js | 3 +- js/{ => utils}/events.js | 0 js/{ => utils}/gestures.js | 0 js/{ => utils}/platform.js | 0 js/{ => utils}/tapPolyfill.js | 0 js/{ => utils}/utils.js | 0 9 files changed, 166 insertions(+), 167 deletions(-) rename js/{ => controllers}/viewController.js (100%) rename js/{ => utils}/animate.js (98%) rename js/{ => utils}/events.js (100%) rename js/{ => utils}/gestures.js (100%) rename js/{ => utils}/platform.js (100%) rename js/{ => utils}/tapPolyfill.js (100%) rename js/{ => utils}/utils.js (100%) diff --git a/Gruntfile.js b/Gruntfile.js index 628f36dffc..afd1a967be 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -10,24 +10,21 @@ module.exports = function(grunt) { dist: { src: [ + // Base 'js/ionic.js', - 'js/platform.js', - 'js/utils.js', - 'js/events.js', - 'js/gestures.js', - 'js/animate.js', - 'js/viewController.js', + // Utils + 'js/utils/**/*.js', + // Views 'js/views/navBarView.js', 'js/views/headerBarView.js', 'js/views/sideMenuView.js', 'js/views/tabBarView.js', 'js/views/toggleView.js', - 'js/controllers/**/*.js', - - 'js/tapPolyfill.js' + // Controllers + 'js/controllers/**/*.js' ], dest: 'dist/<%= pkg.name %>.js' diff --git a/dist/ionic.js b/dist/ionic.js index d0aac8adb5..bf14bf0152 100644 --- a/dist/ionic.js +++ b/dist/ionic.js @@ -4,67 +4,50 @@ window.ionic = { controllers: {}, views: {} }; -;(function(ionic) { +; +(function(ionic) { + ionic.Animator = { + animate: function(element, className, fn) { + return { + leave: function() { + var endFunc = function() { + console.log('Animation finished for element', element); - ionic.Platform = { - detect: function() { - var platforms = []; + element.classList.remove('leave'); + element.classList.remove('leave-active'); - this._checkPlatforms(platforms); + element.removeEventListener('webkitTransitionEnd', endFunc); + element.removeEventListener('transitionEnd', endFunc); + }; + element.addEventListener('webkitTransitionEnd', endFunc); + element.addEventListener('transitionEnd', endFunc); - for(var i = 0; i < platforms.length; i++) { - document.body.classList.add('platform-' + platforms[i]); - } + element.classList.add('leave'); + element.classList.add('leave-active'); + return this; + }, + enter: function() { + var endFunc = function() { + console.log('Animation finished for element', element); - }, - _checkPlatforms: function(platforms) { - if(this.isCordova()) { - platforms.push('cordova'); - } - if(this.isIOS7()) { - platforms.push('ios7'); - } - }, + element.classList.remove('enter'); + element.classList.remove('enter-active'); - // Check if we are running in Cordova, which will have - // window.device available. - isCordova: function() { - return (window.cordova || window.PhoneGap || window.phonegap); - //&& /^file:\/{3}[^\/]/i.test(window.location.href) - //&& /ios|iphone|ipod|ipad|android/i.test(navigator.userAgent); - }, - isIOS7: function() { - if(!window.device) { - return false; - } - return parseFloat(window.device.version) >= 7.0; - } - } + element.removeEventListener('webkitTransitionEnd', endFunc); + element.removeEventListener('transitionEnd', endFunc); + }; + element.addEventListener('webkitTransitionEnd', endFunc); + element.addEventListener('transitionEnd', endFunc); - ionic.Platform.detect(); -})(window.ionic); -;(function(ionic) { - - ionic.Utils = { - /** - * extend method, - * also used for cloning when dest is an empty object - * @param {Object} dest - * @param {Object} src - * @parm {Boolean} merge do a merge - * @returns {Object} dest - */ - extend: function extend(dest, src, merge) { - for (var key in src) { - if(dest[key] !== undefined && merge) { - continue; + element.classList.add('enter'); + element.classList.add('enter-active'); + + return this; } - dest[key] = src[key]; - } - return dest; - }, - } -})(window.ionic); + }; + } + }; +})(ionic); ;/** * ion-events.js * @@ -1612,61 +1595,121 @@ window.ionic = { }; })(window.ionic); ;(function(ionic) { - ionic.Animator = { - animate: function(element, className, fn) { - return { - leave: function() { - var endFunc = function() { - console.log('Animation finished for element', element); - element.classList.remove('leave'); - element.classList.remove('leave-active'); + ionic.Platform = { + detect: function() { + var platforms = []; - element.removeEventListener('webkitTransitionEnd', endFunc); - element.removeEventListener('transitionEnd', endFunc); - }; - element.addEventListener('webkitTransitionEnd', endFunc); - element.addEventListener('transitionEnd', endFunc); + this._checkPlatforms(platforms); - element.classList.add('leave'); - element.classList.add('leave-active'); - return this; - }, - enter: function() { - var endFunc = function() { - console.log('Animation finished for element', element); + for(var i = 0; i < platforms.length; i++) { + document.body.classList.add('platform-' + platforms[i]); + } - element.classList.remove('enter'); - element.classList.remove('enter-active'); - - element.removeEventListener('webkitTransitionEnd', endFunc); - element.removeEventListener('transitionEnd', endFunc); - }; - element.addEventListener('webkitTransitionEnd', endFunc); - element.addEventListener('transitionEnd', endFunc); - - element.classList.add('enter'); - element.classList.add('enter-active'); - - return this; - } - }; - } - }; -})(window.ionic); -;(function(ionic) { - ionic.ViewController = function(options) { - this.init(); - }; - - ionic.ViewController.prototype = { - // Initialize this view controller - init: function() { }, - // Destroy this view controller, including all child views - destroy: function() { + _checkPlatforms: function(platforms) { + if(this.isCordova()) { + platforms.push('cordova'); + } + if(this.isIOS7()) { + platforms.push('ios7'); + } + }, + + // Check if we are running in Cordova, which will have + // window.device available. + isCordova: function() { + return (window.cordova || window.PhoneGap || window.phonegap); + //&& /^file:\/{3}[^\/]/i.test(window.location.href) + //&& /ios|iphone|ipod|ipad|android/i.test(navigator.userAgent); + }, + isIOS7: function() { + if(!window.device) { + return false; + } + return parseFloat(window.device.version) >= 7.0; } - }; + } + + ionic.Platform.detect(); +})(window.ionic); +;(function(window, document, ionic) { + + // polyfill use to simulate native "tap" + function inputTapPolyfill(ele, e) { + if(ele.type === "radio" || ele.type === "checkbox") { + ele.checked = !ele.checked; + } else if(ele.type === "submit" || ele.type === "button") { + ele.click(); + } else { + ele.focus(); + } + e.stopPropagation(); + e.preventDefault(); + return false; + } + + function tapPolyfill(e) { + // if the source event wasn't from a touch event then don't use this polyfill + if(!e.gesture || e.gesture.pointerType !== "touch" || !e.gesture.srcEvent) return; + + var + e = e.gesture.srcEvent, // evaluate the actual source event, not the created event by gestures.js + ele = e.target; + + while(ele) { + if( ele.tagName === "INPUT" || ele.tagName === "TEXTAREA" || ele.tagName === "SELECT" ) { + return inputTapPolyfill(ele, e); + } else if( ele.tagName === "LABEL" ) { + if(ele.control) { + return inputTapPolyfill(ele.control, e); + } + } else if( ele.tagName === "A" || ele.tagName === "BUTTON" ) { + ele.click(); + e.stopPropagation(); + e.preventDefault(); + return false; + } + ele = ele.parentElement; + } + + // they didn't tap one of the above elements + // if the currently active element is an input, and they tapped outside + // of the current input, then unset its focus (blur) so the keyboard goes away + var activeElement = document.activeElement; + if(activeElement && (activeElement.tagName === "INPUT" || activeElement.tagName === "TEXTAREA" || activeElement.tagName === "SELECT")) { + activeElement.blur(); + e.stopPropagation(); + e.preventDefault(); + return false; + } + } + + // global tap event listener polyfill for HTML elements that were "tapped" by the user + ionic.on("tap", tapPolyfill, window); + +})(this, document, ionic); +;(function(ionic) { + + ionic.Utils = { + /** + * extend method, + * also used for cloning when dest is an empty object + * @param {Object} dest + * @param {Object} src + * @parm {Boolean} merge do a merge + * @returns {Object} dest + */ + extend: function extend(dest, src, merge) { + for (var key in src) { + if(dest[key] !== undefined && merge) { + continue; + } + dest[key] = src[key]; + } + return dest; + }, + } })(window.ionic); ; (function(ionic) { @@ -2575,59 +2618,17 @@ ionic.controllers.TabBarController.prototype = { } })(ionic = window.ionic || {}); -;(function(window, document, ionic) { +;(function(ionic) { + ionic.ViewController = function(options) { + this.init(); + }; - // polyfill use to simulate native "tap" - function inputTapPolyfill(ele, e) { - if(ele.type === "radio" || ele.type === "checkbox") { - ele.checked = !ele.checked; - } else if(ele.type === "submit" || ele.type === "button") { - ele.click(); - } else { - ele.focus(); + ionic.ViewController.prototype = { + // Initialize this view controller + init: function() { + }, + // Destroy this view controller, including all child views + destroy: function() { } - e.stopPropagation(); - e.preventDefault(); - return false; - } - - function tapPolyfill(e) { - // if the source event wasn't from a touch event then don't use this polyfill - if(!e.gesture || e.gesture.pointerType !== "touch" || !e.gesture.srcEvent) return; - - var - e = e.gesture.srcEvent, // evaluate the actual source event, not the created event by gestures.js - ele = e.target; - - while(ele) { - if( ele.tagName === "INPUT" || ele.tagName === "TEXTAREA" || ele.tagName === "SELECT" ) { - return inputTapPolyfill(ele, e); - } else if( ele.tagName === "LABEL" ) { - if(ele.control) { - return inputTapPolyfill(ele.control, e); - } - } else if( ele.tagName === "A" || ele.tagName === "BUTTON" ) { - ele.click(); - e.stopPropagation(); - e.preventDefault(); - return false; - } - ele = ele.parentElement; - } - - // they didn't tap one of the above elements - // if the currently active element is an input, and they tapped outside - // of the current input, then unset its focus (blur) so the keyboard goes away - var activeElement = document.activeElement; - if(activeElement && (activeElement.tagName === "INPUT" || activeElement.tagName === "TEXTAREA" || activeElement.tagName === "SELECT")) { - activeElement.blur(); - e.stopPropagation(); - e.preventDefault(); - return false; - } - } - - // global tap event listener polyfill for HTML elements that were "tapped" by the user - ionic.on("tap", tapPolyfill, window); - -})(this, document, ionic); + }; +})(window.ionic); diff --git a/js/viewController.js b/js/controllers/viewController.js similarity index 100% rename from js/viewController.js rename to js/controllers/viewController.js diff --git a/js/animate.js b/js/utils/animate.js similarity index 98% rename from js/animate.js rename to js/utils/animate.js index bedaad67b2..89cca3b0ef 100644 --- a/js/animate.js +++ b/js/utils/animate.js @@ -1,3 +1,4 @@ + (function(ionic) { ionic.Animator = { animate: function(element, className, fn) { @@ -40,4 +41,4 @@ }; } }; -})(window.ionic); +})(ionic); diff --git a/js/events.js b/js/utils/events.js similarity index 100% rename from js/events.js rename to js/utils/events.js diff --git a/js/gestures.js b/js/utils/gestures.js similarity index 100% rename from js/gestures.js rename to js/utils/gestures.js diff --git a/js/platform.js b/js/utils/platform.js similarity index 100% rename from js/platform.js rename to js/utils/platform.js diff --git a/js/tapPolyfill.js b/js/utils/tapPolyfill.js similarity index 100% rename from js/tapPolyfill.js rename to js/utils/tapPolyfill.js diff --git a/js/utils.js b/js/utils/utils.js similarity index 100% rename from js/utils.js rename to js/utils/utils.js