mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 06:57:02 +08:00
move stuff to js/utils
This commit is contained in:
15
Gruntfile.js
15
Gruntfile.js
@ -10,24 +10,21 @@ module.exports = function(grunt) {
|
|||||||
dist: {
|
dist: {
|
||||||
src: [
|
src: [
|
||||||
|
|
||||||
|
// Base
|
||||||
'js/ionic.js',
|
'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/navBarView.js',
|
||||||
'js/views/headerBarView.js',
|
'js/views/headerBarView.js',
|
||||||
'js/views/sideMenuView.js',
|
'js/views/sideMenuView.js',
|
||||||
'js/views/tabBarView.js',
|
'js/views/tabBarView.js',
|
||||||
'js/views/toggleView.js',
|
'js/views/toggleView.js',
|
||||||
|
|
||||||
'js/controllers/**/*.js',
|
// Controllers
|
||||||
|
'js/controllers/**/*.js'
|
||||||
'js/tapPolyfill.js'
|
|
||||||
|
|
||||||
],
|
],
|
||||||
dest: 'dist/<%= pkg.name %>.js'
|
dest: 'dist/<%= pkg.name %>.js'
|
||||||
|
|||||||
313
dist/ionic.js
vendored
313
dist/ionic.js
vendored
@ -4,67 +4,50 @@ window.ionic = {
|
|||||||
controllers: {},
|
controllers: {},
|
||||||
views: {}
|
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 = {
|
element.classList.remove('leave');
|
||||||
detect: function() {
|
element.classList.remove('leave-active');
|
||||||
var platforms = [];
|
|
||||||
|
|
||||||
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++) {
|
element.classList.add('leave');
|
||||||
document.body.classList.add('platform-' + platforms[i]);
|
element.classList.add('leave-active');
|
||||||
}
|
return this;
|
||||||
|
},
|
||||||
|
enter: function() {
|
||||||
|
var endFunc = function() {
|
||||||
|
console.log('Animation finished for element', element);
|
||||||
|
|
||||||
},
|
element.classList.remove('enter');
|
||||||
_checkPlatforms: function(platforms) {
|
element.classList.remove('enter-active');
|
||||||
if(this.isCordova()) {
|
|
||||||
platforms.push('cordova');
|
|
||||||
}
|
|
||||||
if(this.isIOS7()) {
|
|
||||||
platforms.push('ios7');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// Check if we are running in Cordova, which will have
|
element.removeEventListener('webkitTransitionEnd', endFunc);
|
||||||
// window.device available.
|
element.removeEventListener('transitionEnd', endFunc);
|
||||||
isCordova: function() {
|
};
|
||||||
return (window.cordova || window.PhoneGap || window.phonegap);
|
element.addEventListener('webkitTransitionEnd', endFunc);
|
||||||
//&& /^file:\/{3}[^\/]/i.test(window.location.href)
|
element.addEventListener('transitionEnd', endFunc);
|
||||||
//&& /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();
|
element.classList.add('enter');
|
||||||
})(window.ionic);
|
element.classList.add('enter-active');
|
||||||
;(function(ionic) {
|
|
||||||
|
|
||||||
ionic.Utils = {
|
return this;
|
||||||
/**
|
|
||||||
* 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;
|
};
|
||||||
},
|
})(ionic);
|
||||||
}
|
|
||||||
})(window.ionic);
|
|
||||||
;/**
|
;/**
|
||||||
* ion-events.js
|
* ion-events.js
|
||||||
*
|
*
|
||||||
@ -1612,61 +1595,121 @@ window.ionic = {
|
|||||||
};
|
};
|
||||||
})(window.ionic);
|
})(window.ionic);
|
||||||
;(function(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');
|
ionic.Platform = {
|
||||||
element.classList.remove('leave-active');
|
detect: function() {
|
||||||
|
var platforms = [];
|
||||||
|
|
||||||
element.removeEventListener('webkitTransitionEnd', endFunc);
|
this._checkPlatforms(platforms);
|
||||||
element.removeEventListener('transitionEnd', endFunc);
|
|
||||||
};
|
|
||||||
element.addEventListener('webkitTransitionEnd', endFunc);
|
|
||||||
element.addEventListener('transitionEnd', endFunc);
|
|
||||||
|
|
||||||
element.classList.add('leave');
|
for(var i = 0; i < platforms.length; i++) {
|
||||||
element.classList.add('leave-active');
|
document.body.classList.add('platform-' + platforms[i]);
|
||||||
return this;
|
}
|
||||||
},
|
|
||||||
enter: function() {
|
|
||||||
var endFunc = function() {
|
|
||||||
console.log('Animation finished for element', element);
|
|
||||||
|
|
||||||
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
|
_checkPlatforms: function(platforms) {
|
||||||
destroy: function() {
|
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);
|
})(window.ionic);
|
||||||
;
|
;
|
||||||
(function(ionic) {
|
(function(ionic) {
|
||||||
@ -2575,59 +2618,17 @@ ionic.controllers.TabBarController.prototype = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
})(ionic = window.ionic || {});
|
})(ionic = window.ionic || {});
|
||||||
;(function(window, document, ionic) {
|
;(function(ionic) {
|
||||||
|
ionic.ViewController = function(options) {
|
||||||
|
this.init();
|
||||||
|
};
|
||||||
|
|
||||||
// polyfill use to simulate native "tap"
|
ionic.ViewController.prototype = {
|
||||||
function inputTapPolyfill(ele, e) {
|
// Initialize this view controller
|
||||||
if(ele.type === "radio" || ele.type === "checkbox") {
|
init: function() {
|
||||||
ele.checked = !ele.checked;
|
},
|
||||||
} else if(ele.type === "submit" || ele.type === "button") {
|
// Destroy this view controller, including all child views
|
||||||
ele.click();
|
destroy: function() {
|
||||||
} else {
|
|
||||||
ele.focus();
|
|
||||||
}
|
}
|
||||||
e.stopPropagation();
|
};
|
||||||
e.preventDefault();
|
})(window.ionic);
|
||||||
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);
|
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
(function(ionic) {
|
(function(ionic) {
|
||||||
ionic.Animator = {
|
ionic.Animator = {
|
||||||
animate: function(element, className, fn) {
|
animate: function(element, className, fn) {
|
||||||
@ -40,4 +41,4 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})(window.ionic);
|
})(ionic);
|
||||||
Reference in New Issue
Block a user