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