mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
style(jscs): code formatting
This commit is contained in:
2
js/angular/controller/headerBarController.js
vendored
2
js/angular/controller/headerBarController.js
vendored
@@ -74,7 +74,7 @@ function($scope, $element, $attrs, $q, $ionicConfig, $ionicHistory) {
|
||||
|
||||
|
||||
self.updateBackButton = function() {
|
||||
if ( (isBackShown && isNavBackShown && isBackEnabled) !== isBackElementShown) {
|
||||
if ((isBackShown && isNavBackShown && isBackEnabled) !== isBackElementShown) {
|
||||
isBackElementShown = isBackShown && isNavBackShown && isBackEnabled;
|
||||
var backBtnEle = getEle(BACK_BUTTON);
|
||||
backBtnEle && backBtnEle.classList[ isBackElementShown ? 'remove' : 'add' ](HIDE);
|
||||
|
||||
3
js/angular/controller/viewController.js
vendored
3
js/angular/controller/viewController.js
vendored
@@ -15,7 +15,7 @@ function($scope, $element, $attrs, $compile, $rootScope, $ionicViewSwitcher) {
|
||||
var deregisters = [];
|
||||
var viewTitle;
|
||||
|
||||
var deregIonNavBarInit = $scope.$on('ionNavBar.init', function(ev, delegateHandle){
|
||||
var deregIonNavBarInit = $scope.$on('ionNavBar.init', function(ev, delegateHandle) {
|
||||
// this view has its own ion-nav-bar, remember the navBarDelegateHandle for this view
|
||||
ev.stopPropagation();
|
||||
navBarDelegateHandle = delegateHandle;
|
||||
@@ -129,4 +129,3 @@ function($scope, $element, $attrs, $compile, $rootScope, $ionicViewSwitcher) {
|
||||
};
|
||||
|
||||
}]);
|
||||
|
||||
|
||||
5
js/angular/deprecated.js
vendored
5
js/angular/deprecated.js
vendored
@@ -8,7 +8,7 @@
|
||||
var deprecated = {
|
||||
method: function(msg, log, fn) {
|
||||
var called = false;
|
||||
return function deprecatedMethod(){
|
||||
return function deprecatedMethod() {
|
||||
if (!called) {
|
||||
called = true;
|
||||
log(msg);
|
||||
@@ -19,7 +19,7 @@ var deprecated = {
|
||||
|
||||
field: function(msg, log, parent, field, val) {
|
||||
var called = false;
|
||||
var getter = function(){
|
||||
var getter = function() {
|
||||
if (!called) {
|
||||
called = true;
|
||||
log(msg);
|
||||
@@ -42,4 +42,3 @@ var deprecated = {
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
4
js/angular/directive/ngClick.js
vendored
4
js/angular/directive/ngClick.js
vendored
@@ -35,10 +35,10 @@ IonicModule
|
||||
};
|
||||
}])
|
||||
|
||||
.directive('ionStopEvent', function () {
|
||||
.directive('ionStopEvent', function() {
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: function (scope, element, attr) {
|
||||
link: function(scope, element, attr) {
|
||||
element.bind(attr.ionStopEvent, eventStopPropagation);
|
||||
}
|
||||
};
|
||||
|
||||
8
js/angular/directive/sideMenuContent.js
vendored
8
js/angular/directive/sideMenuContent.js
vendored
@@ -74,14 +74,14 @@ function($timeout, $ionicGesture, $window) {
|
||||
function onDragX(e) {
|
||||
if (!sideMenuCtrl.isDraggableTarget(e)) return;
|
||||
|
||||
if ( getPrimaryScrollAxis(e) == 'x') {
|
||||
if (getPrimaryScrollAxis(e) == 'x') {
|
||||
sideMenuCtrl._handleDrag(e);
|
||||
e.gesture.srcEvent.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
function onDragY(e) {
|
||||
if ( getPrimaryScrollAxis(e) == 'x' ) {
|
||||
if (getPrimaryScrollAxis(e) == 'x') {
|
||||
e.gesture.srcEvent.preventDefault();
|
||||
}
|
||||
}
|
||||
@@ -115,9 +115,9 @@ function($timeout, $ionicGesture, $window) {
|
||||
var xDistance = Math.abs(endCoord.x - startCoord.x);
|
||||
var yDistance = Math.abs(endCoord.y - startCoord.y);
|
||||
|
||||
var scrollAxis = ( xDistance < yDistance ? 'y' : 'x' );
|
||||
var scrollAxis = (xDistance < yDistance ? 'y' : 'x');
|
||||
|
||||
if ( Math.max(xDistance, yDistance) > 30 ) {
|
||||
if (Math.max(xDistance, yDistance) > 30) {
|
||||
// ok, we pretty much know which way they're going
|
||||
// let's lock it in
|
||||
primaryScrollAxis = scrollAxis;
|
||||
|
||||
8
js/angular/directive/tab.js
vendored
8
js/angular/directive/tab.js
vendored
@@ -42,7 +42,7 @@ IonicModule
|
||||
function($compile, $ionicConfig, $ionicBind, $ionicViewSwitcher) {
|
||||
|
||||
//Returns ' key="value"' if value exists
|
||||
function attrStr(k,v) {
|
||||
function attrStr(k, v) {
|
||||
return angular.isDefined(v) ? ' ' + k + '="' + v + '"' : '';
|
||||
}
|
||||
return {
|
||||
@@ -83,7 +83,7 @@ function($compile, $ionicConfig, $ionicBind, $ionicViewSwitcher) {
|
||||
tabContentEle.children[0].classList.add('view-container');
|
||||
isNavView = true;
|
||||
}
|
||||
if(childElementCount === 1) {
|
||||
if (childElementCount === 1) {
|
||||
// make the 1 child element the primary tab content container
|
||||
tabContentEle = tabContentEle.children[0];
|
||||
}
|
||||
@@ -152,7 +152,7 @@ function($compile, $ionicConfig, $ionicBind, $ionicViewSwitcher) {
|
||||
childScope = $scope.$new();
|
||||
childElement = jqLite(tabContentEle);
|
||||
$ionicViewSwitcher.viewEleIsActive(childElement, true);
|
||||
tabsCtrl.$element.append( childElement );
|
||||
tabsCtrl.$element.append(childElement);
|
||||
$compile(childElement)(childScope);
|
||||
isTabContentAttached = true;
|
||||
}
|
||||
@@ -163,7 +163,7 @@ function($compile, $ionicConfig, $ionicBind, $ionicViewSwitcher) {
|
||||
} else if (isTabContentAttached && childElement) {
|
||||
// this tab should NOT be selected, and it is already in the DOM
|
||||
|
||||
if ( $ionicConfig.views.maxCache() > 0 ) {
|
||||
if ($ionicConfig.views.maxCache() > 0) {
|
||||
// keep the tabs in the DOM, only css hide it
|
||||
$ionicViewSwitcher.viewEleIsActive(childElement, false);
|
||||
|
||||
|
||||
2
js/angular/directive/tabNav.js
vendored
2
js/angular/directive/tabNav.js
vendored
@@ -43,7 +43,7 @@ IonicModule
|
||||
}
|
||||
|
||||
$scope.isHidden = function() {
|
||||
if($attrs.hidden === 'true' || $attrs.hidden === true)return true;
|
||||
if ($attrs.hidden === 'true' || $attrs.hidden === true) return true;
|
||||
return false;
|
||||
};
|
||||
|
||||
|
||||
5
js/angular/directive/tabs.js
vendored
5
js/angular/directive/tabs.js
vendored
@@ -60,8 +60,7 @@ function($ionicTabsDelegate, $ionicConfig, $ionicHistory) {
|
||||
innerElement.append(tElement.contents());
|
||||
|
||||
tElement.append(innerElement)
|
||||
.addClass( 'tabs-' + $ionicConfig.tabs.position() )
|
||||
.addClass( 'tabs-' + $ionicConfig.tabs.style() );
|
||||
.addClass('tabs-' + $ionicConfig.tabs.position() + ' tabs-' + $ionicConfig.tabs.style());
|
||||
|
||||
return { pre: prelink, post: postLink };
|
||||
function prelink($scope, $element, $attr, tabsCtrl) {
|
||||
@@ -80,7 +79,7 @@ function($ionicTabsDelegate, $ionicConfig, $ionicHistory) {
|
||||
$scope.$hasTabsTop = isTabsTop && !isHidden;
|
||||
});
|
||||
|
||||
$scope.$on('$destroy', function(){
|
||||
$scope.$on('$destroy', function() {
|
||||
// variable to inform child tabs that they're all being blown away
|
||||
// used so that while destorying an individual tab, each one
|
||||
// doesn't select the next tab as the active one, which causes unnecessary
|
||||
|
||||
16
js/angular/service/angularOverrides.js
vendored
16
js/angular/service/angularOverrides.js
vendored
@@ -2,18 +2,18 @@
|
||||
jqLite.prototype.addClass = function(cssClasses) {
|
||||
var x, y, cssClass, el, splitClasses, existingClasses;
|
||||
if (cssClasses && cssClasses != 'ng-scope' && cssClasses != 'ng-isolate-scope') {
|
||||
for(x=0; x<this.length; x++) {
|
||||
for (x = 0; x < this.length; x++) {
|
||||
el = this[x];
|
||||
if(el.setAttribute) {
|
||||
if (el.setAttribute) {
|
||||
|
||||
if(cssClasses.indexOf(' ') < 0 && el.classList.add) {
|
||||
if (cssClasses.indexOf(' ') < 0 && el.classList.add) {
|
||||
el.classList.add(cssClasses);
|
||||
} else {
|
||||
existingClasses = (' ' + (el.getAttribute('class') || '') + ' ')
|
||||
.replace(/[\n\t]/g, " ");
|
||||
splitClasses = cssClasses.split(' ');
|
||||
|
||||
for (y=0; y<splitClasses.length; y++) {
|
||||
for (y = 0; y < splitClasses.length; y++) {
|
||||
cssClass = splitClasses[y].trim();
|
||||
if (existingClasses.indexOf(' ' + cssClass + ' ') === -1) {
|
||||
existingClasses += cssClass + ' ';
|
||||
@@ -30,15 +30,15 @@ jqLite.prototype.addClass = function(cssClasses) {
|
||||
jqLite.prototype.removeClass = function(cssClasses) {
|
||||
var x, y, splitClasses, cssClass, el;
|
||||
if (cssClasses) {
|
||||
for(x=0; x<this.length; x++) {
|
||||
for (x = 0; x < this.length; x++) {
|
||||
el = this[x];
|
||||
if(el.getAttribute) {
|
||||
if(cssClasses.indexOf(' ') < 0 && el.classList.remove) {
|
||||
if (el.getAttribute) {
|
||||
if (cssClasses.indexOf(' ') < 0 && el.classList.remove) {
|
||||
el.classList.remove(cssClasses);
|
||||
} else {
|
||||
splitClasses = cssClasses.split(' ');
|
||||
|
||||
for (y=0; y<splitClasses.length; y++) {
|
||||
for (y = 0; y < splitClasses.length; y++) {
|
||||
cssClass = splitClasses[y];
|
||||
el.setAttribute('class', (
|
||||
(" " + (el.getAttribute('class') || '') + " ")
|
||||
|
||||
2
js/angular/service/attachDrag.js
vendored
2
js/angular/service/attachDrag.js
vendored
@@ -12,7 +12,7 @@ IonicModule
|
||||
getDistance: function() { return opts.element.prop('offsetWidth'); },
|
||||
onDragStart: angular.noop,
|
||||
onDrag: angular.noop,
|
||||
onDragEnd: angular.noop,
|
||||
onDragEnd: angular.noop
|
||||
}, options);
|
||||
|
||||
var dragStartGesture = ionic.onGesture('dragstart', handleDragStart, element[0]);
|
||||
|
||||
4
js/angular/service/backdrop.js
vendored
4
js/angular/service/backdrop.js
vendored
@@ -64,7 +64,7 @@ function($document, $timeout) {
|
||||
};
|
||||
|
||||
function retain() {
|
||||
if ( (++backdropHolds) === 1 ) {
|
||||
if ((++backdropHolds) === 1) {
|
||||
el.addClass('visible');
|
||||
ionic.requestAnimationFrame(function() {
|
||||
backdropHolds && el.addClass('active');
|
||||
@@ -72,7 +72,7 @@ function($document, $timeout) {
|
||||
}
|
||||
}
|
||||
function release() {
|
||||
if ( (--backdropHolds) === 0 ) {
|
||||
if ((--backdropHolds) === 0) {
|
||||
el.removeClass('active');
|
||||
$timeout(function() {
|
||||
!backdropHolds && el.removeClass('visible');
|
||||
|
||||
8
js/angular/service/body.js
vendored
8
js/angular/service/body.js
vendored
@@ -16,7 +16,7 @@ IonicModule
|
||||
* @returns {$ionicBody} The $ionicBody service so methods can be chained.
|
||||
*/
|
||||
addClass: function() {
|
||||
for(var x=0; x<arguments.length; x++) {
|
||||
for (var x = 0; x < arguments.length; x++) {
|
||||
$document[0].body.classList.add(arguments[x]);
|
||||
}
|
||||
return this;
|
||||
@@ -29,7 +29,7 @@ IonicModule
|
||||
* @returns {$ionicBody} The $ionicBody service so methods can be chained.
|
||||
*/
|
||||
removeClass: function() {
|
||||
for(var x=0; x<arguments.length; x++) {
|
||||
for (var x = 0; x < arguments.length; x++) {
|
||||
$document[0].body.classList.remove(arguments[x]);
|
||||
}
|
||||
return this;
|
||||
@@ -48,7 +48,7 @@ IonicModule
|
||||
*/
|
||||
enableClass: function(shouldEnableClass) {
|
||||
var args = Array.prototype.slice.call(arguments).slice(1);
|
||||
if(shouldEnableClass) {
|
||||
if (shouldEnableClass) {
|
||||
this.addClass.apply(this, args);
|
||||
} else {
|
||||
this.removeClass.apply(this, args);
|
||||
@@ -64,7 +64,7 @@ IonicModule
|
||||
* @returns {$ionicBody} The $ionicBody service so methods can be chained.
|
||||
*/
|
||||
append: function(ele) {
|
||||
$document[0].body.appendChild( ele.length ? ele[0] : ele );
|
||||
$document[0].body.appendChild(ele.length ? ele[0] : ele);
|
||||
return this;
|
||||
},
|
||||
/**
|
||||
|
||||
12
js/angular/service/position.js
vendored
12
js/angular/service/position.js
vendored
@@ -11,7 +11,7 @@
|
||||
* ([license](https://github.com/angular-ui/bootstrap/blob/master/LICENSE))
|
||||
*/
|
||||
IonicModule
|
||||
.factory('$ionicPosition', ['$document', '$window', function ($document, $window) {
|
||||
.factory('$ionicPosition', ['$document', '$window', function($document, $window) {
|
||||
|
||||
function getStyle(el, cssprop) {
|
||||
if (el.currentStyle) { //IE
|
||||
@@ -28,17 +28,17 @@ IonicModule
|
||||
* @param element - raw DOM element
|
||||
*/
|
||||
function isStaticPositioned(element) {
|
||||
return (getStyle(element, 'position') || 'static' ) === 'static';
|
||||
return (getStyle(element, 'position') || 'static') === 'static';
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the closest, non-statically positioned parentOffset of a given element
|
||||
* @param element
|
||||
*/
|
||||
var parentOffsetEl = function (element) {
|
||||
var parentOffsetEl = function(element) {
|
||||
var docDomEl = $document[0];
|
||||
var offsetParent = element.offsetParent || docDomEl;
|
||||
while (offsetParent && offsetParent !== docDomEl && isStaticPositioned(offsetParent) ) {
|
||||
while (offsetParent && offsetParent !== docDomEl && isStaticPositioned(offsetParent)) {
|
||||
offsetParent = offsetParent.offsetParent;
|
||||
}
|
||||
return offsetParent || docDomEl;
|
||||
@@ -53,7 +53,7 @@ IonicModule
|
||||
* @param {element} element The element to get the position of.
|
||||
* @returns {object} Returns an object containing the properties top, left, width and height.
|
||||
*/
|
||||
position: function (element) {
|
||||
position: function(element) {
|
||||
var elBCR = this.offset(element);
|
||||
var offsetParentBCR = { top: 0, left: 0 };
|
||||
var offsetParentEl = parentOffsetEl(element[0]);
|
||||
@@ -80,7 +80,7 @@ IonicModule
|
||||
* @param {element} element The element to get the offset of.
|
||||
* @returns {object} Returns an object containing the properties top, left, width and height.
|
||||
*/
|
||||
offset: function (element) {
|
||||
offset: function(element) {
|
||||
var boundingClientRect = element[0].getBoundingClientRect();
|
||||
return {
|
||||
width: boundingClientRect.width || element.prop('offsetWidth'),
|
||||
|
||||
2
js/angular/service/viewService.js
vendored
2
js/angular/service/viewService.js
vendored
@@ -20,7 +20,7 @@ IonicModule
|
||||
clearHistory: 'clearHistory'
|
||||
};
|
||||
|
||||
forEach(methodsMap, function(newMethod, oldMethod){
|
||||
forEach(methodsMap, function(newMethod, oldMethod) {
|
||||
methodsMap[oldMethod] = function() {
|
||||
warn('.' + oldMethod, '.' + newMethod);
|
||||
return $ionicHistory[newMethod].apply(this, arguments);
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
*/
|
||||
ready: function(cb) {
|
||||
// run through tasks to complete now that the device is ready
|
||||
if(this.isReady) {
|
||||
if (this.isReady) {
|
||||
cb();
|
||||
} else {
|
||||
// the platform isn't ready yet, add it to this array
|
||||
@@ -72,9 +72,9 @@
|
||||
detect: function() {
|
||||
ionic.Platform._checkPlatforms();
|
||||
|
||||
ionic.requestAnimationFrame(function(){
|
||||
ionic.requestAnimationFrame(function() {
|
||||
// only add to the body class if we got platform info
|
||||
for(var i = 0; i < ionic.Platform.platforms.length; i++) {
|
||||
for (var i = 0; i < ionic.Platform.platforms.length; i++) {
|
||||
document.body.classList.add('platform-' + ionic.Platform.platforms[i]);
|
||||
}
|
||||
});
|
||||
@@ -113,22 +113,22 @@
|
||||
this.platforms = [];
|
||||
var grade = 'a';
|
||||
|
||||
if(this.isWebView()) {
|
||||
if (this.isWebView()) {
|
||||
this.platforms.push('webview');
|
||||
this.platforms.push('cordova');
|
||||
} else {
|
||||
this.platforms.push('browser');
|
||||
}
|
||||
if(this.isIPad()) this.platforms.push('ipad');
|
||||
if (this.isIPad()) this.platforms.push('ipad');
|
||||
|
||||
var platform = this.platform();
|
||||
if(platform) {
|
||||
if (platform) {
|
||||
this.platforms.push(platform);
|
||||
|
||||
var version = this.version();
|
||||
if(version) {
|
||||
if (version) {
|
||||
var v = version.toString();
|
||||
if(v.indexOf('.') > 0) {
|
||||
if (v.indexOf('.') > 0) {
|
||||
v = v.replace('.', '_');
|
||||
} else {
|
||||
v += '_0';
|
||||
@@ -136,9 +136,9 @@
|
||||
this.platforms.push(platform + v.split('_')[0]);
|
||||
this.platforms.push(platform + v);
|
||||
|
||||
if(this.isAndroid() && version < 4.4) {
|
||||
if (this.isAndroid() && version < 4.4) {
|
||||
grade = (version < 4 ? 'c' : 'b');
|
||||
} else if(this.isWindowsPhone()) {
|
||||
} else if (this.isWindowsPhone()) {
|
||||
grade = 'b';
|
||||
}
|
||||
}
|
||||
@@ -161,7 +161,7 @@
|
||||
* @returns {boolean} Whether we are running on iPad.
|
||||
*/
|
||||
isIPad: function() {
|
||||
if( /iPad/i.test(ionic.Platform.navigator.platform) ) {
|
||||
if (/iPad/i.test(ionic.Platform.navigator.platform)) {
|
||||
return true;
|
||||
}
|
||||
return /iPad/i.test(this.ua);
|
||||
@@ -198,7 +198,7 @@
|
||||
*/
|
||||
platform: function() {
|
||||
// singleton to get the platform name
|
||||
if(platformName === null) this.setPlatform(this.device().platform);
|
||||
if (platformName === null) this.setPlatform(this.device().platform);
|
||||
return platformName;
|
||||
},
|
||||
|
||||
@@ -206,13 +206,13 @@
|
||||
* @private
|
||||
*/
|
||||
setPlatform: function(n) {
|
||||
if(typeof n != 'undefined' && n !== null && n.length) {
|
||||
if (typeof n != 'undefined' && n !== null && n.length) {
|
||||
platformName = n.toLowerCase();
|
||||
} else if(this.ua.indexOf('Android') > 0) {
|
||||
} else if (this.ua.indexOf('Android') > 0) {
|
||||
platformName = ANDROID;
|
||||
} else if(this.ua.indexOf('iPhone') > -1 || this.ua.indexOf('iPad') > -1 || this.ua.indexOf('iPod') > -1) {
|
||||
} else if (this.ua.indexOf('iPhone') > -1 || this.ua.indexOf('iPad') > -1 || this.ua.indexOf('iPod') > -1) {
|
||||
platformName = IOS;
|
||||
} else if(this.ua.indexOf('Windows Phone') > -1) {
|
||||
} else if (this.ua.indexOf('Windows Phone') > -1) {
|
||||
platformName = WINDOWS_PHONE;
|
||||
} else {
|
||||
platformName = ionic.Platform.navigator.platform && navigator.platform.toLowerCase().split(' ')[0] || '';
|
||||
@@ -226,7 +226,7 @@
|
||||
*/
|
||||
version: function() {
|
||||
// singleton to get the platform version
|
||||
if(platformVersion === null) this.setVersion(this.device().version);
|
||||
if (platformVersion === null) this.setVersion(this.device().version);
|
||||
return platformVersion;
|
||||
},
|
||||
|
||||
@@ -234,10 +234,10 @@
|
||||
* @private
|
||||
*/
|
||||
setVersion: function(v) {
|
||||
if(typeof v != 'undefined' && v !== null) {
|
||||
if (typeof v != 'undefined' && v !== null) {
|
||||
v = v.split('.');
|
||||
v = parseFloat(v[0] + '.' + (v.length > 1 ? v[1] : 0));
|
||||
if(!isNaN(v)) {
|
||||
if (!isNaN(v)) {
|
||||
platformVersion = v;
|
||||
return;
|
||||
}
|
||||
@@ -252,10 +252,10 @@
|
||||
'ios': /OS (\d+)_(\d+)?/,
|
||||
'windowsphone': /Windows Phone (\d+).(\d+)?/
|
||||
};
|
||||
if(versionMatch[pName]) {
|
||||
v = this.ua.match( versionMatch[pName] );
|
||||
if(v && v.length > 2) {
|
||||
platformVersion = parseFloat( v[1] + '.' + v[2] );
|
||||
if (versionMatch[pName]) {
|
||||
v = this.ua.match(versionMatch[pName]);
|
||||
if (v && v.length > 2) {
|
||||
platformVersion = parseFloat(v[1] + '.' + v[2]);
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -264,14 +264,14 @@
|
||||
is: function(type) {
|
||||
type = type.toLowerCase();
|
||||
// check if it has an array of platforms
|
||||
if(this.platforms) {
|
||||
for(var x = 0; x < this.platforms.length; x++) {
|
||||
if(this.platforms[x] === type) return true;
|
||||
if (this.platforms) {
|
||||
for (var x = 0; x < this.platforms.length; x++) {
|
||||
if (this.platforms[x] === type) return true;
|
||||
}
|
||||
}
|
||||
// exact match
|
||||
var pName = this.platform();
|
||||
if(pName) {
|
||||
if (pName) {
|
||||
return pName === type.toLowerCase();
|
||||
}
|
||||
|
||||
@@ -285,7 +285,7 @@
|
||||
* @description Exit the app.
|
||||
*/
|
||||
exitApp: function() {
|
||||
this.ready(function(){
|
||||
this.ready(function() {
|
||||
navigator.app && navigator.app.exitApp && navigator.app.exitApp();
|
||||
});
|
||||
},
|
||||
@@ -299,10 +299,10 @@
|
||||
showStatusBar: function(val) {
|
||||
// Only useful when run within cordova
|
||||
this._showStatusBar = val;
|
||||
this.ready(function(){
|
||||
this.ready(function() {
|
||||
// run this only when or if the platform (cordova) is ready
|
||||
ionic.requestAnimationFrame(function(){
|
||||
if(ionic.Platform._showStatusBar) {
|
||||
ionic.requestAnimationFrame(function() {
|
||||
if (ionic.Platform._showStatusBar) {
|
||||
// they do not want it to be full screen
|
||||
window.StatusBar && window.StatusBar.show();
|
||||
document.body.classList.remove('status-bar-hide');
|
||||
@@ -328,22 +328,22 @@
|
||||
this.isFullScreen = (showFullScreen !== false);
|
||||
|
||||
// add/remove the fullscreen classname to the body
|
||||
ionic.DomUtil.ready(function(){
|
||||
ionic.DomUtil.ready(function() {
|
||||
// run this only when or if the DOM is ready
|
||||
ionic.requestAnimationFrame(function(){
|
||||
ionic.requestAnimationFrame(function() {
|
||||
// fixing pane height before we adjust this
|
||||
panes = document.getElementsByClassName('pane');
|
||||
for(var i = 0;i<panes.length;i++){
|
||||
panes[i].style.height = panes[i].offsetHeight+"px";
|
||||
for (var i = 0; i < panes.length; i++) {
|
||||
panes[i].style.height = panes[i].offsetHeight + "px";
|
||||
}
|
||||
if(ionic.Platform.isFullScreen) {
|
||||
if (ionic.Platform.isFullScreen) {
|
||||
document.body.classList.add('fullscreen');
|
||||
} else {
|
||||
document.body.classList.remove('fullscreen');
|
||||
}
|
||||
});
|
||||
// showStatusBar: default is false if no param provided
|
||||
ionic.Platform.showStatusBar( (showStatusBar === true) );
|
||||
ionic.Platform.showStatusBar((showStatusBar === true));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -356,7 +356,7 @@
|
||||
|
||||
// setup listeners to know when the device is ready to go
|
||||
function onWindowLoad() {
|
||||
if(ionic.Platform.isWebView()) {
|
||||
if (ionic.Platform.isWebView()) {
|
||||
// the window and scripts are fully loaded, and a cordova/phonegap
|
||||
// object exists then let's listen for the deviceready
|
||||
document.addEventListener("deviceready", onPlatformReady, false);
|
||||
@@ -365,7 +365,7 @@
|
||||
// cordova/phonegap object, so its just a browser, not a webview wrapped w/ cordova
|
||||
onPlatformReady();
|
||||
}
|
||||
if (windowLoadListenderAttached){
|
||||
if (windowLoadListenderAttached) {
|
||||
window.removeEventListener("load", onWindowLoad, false);
|
||||
}
|
||||
}
|
||||
@@ -375,21 +375,21 @@
|
||||
windowLoadListenderAttached = true;
|
||||
window.addEventListener("load", onWindowLoad, false);
|
||||
}
|
||||
|
||||
|
||||
window.addEventListener("load", onWindowLoad, false);
|
||||
|
||||
function onPlatformReady() {
|
||||
// the device is all set to go, init our own stuff then fire off our event
|
||||
ionic.Platform.isReady = true;
|
||||
ionic.Platform.detect();
|
||||
for(var x=0; x<readyCallbacks.length; x++) {
|
||||
for (var x = 0; x < readyCallbacks.length; x++) {
|
||||
// fire off all the callbacks that were added before the platform was ready
|
||||
readyCallbacks[x]();
|
||||
}
|
||||
readyCallbacks = [];
|
||||
ionic.trigger('platformready', { target: document });
|
||||
|
||||
ionic.requestAnimationFrame(function(){
|
||||
ionic.requestAnimationFrame(function() {
|
||||
document.body.classList.add('platform-ready');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
var i, keys = ['webkitTransform', 'transform', '-webkit-transform', 'webkit-transform',
|
||||
'-moz-transform', 'moz-transform', 'MozTransform', 'mozTransform', 'msTransform'];
|
||||
|
||||
for(i = 0; i < keys.length; i++) {
|
||||
for (i = 0; i < keys.length; i++) {
|
||||
if (document.documentElement.style[keys[i]] !== undefined) {
|
||||
ionic.CSS.TRANSFORM = keys[i];
|
||||
break;
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
// transition
|
||||
keys = ['webkitTransition', 'mozTransition', 'msTransition', 'transition'];
|
||||
for(i = 0; i < keys.length; i++) {
|
||||
for (i = 0; i < keys.length; i++) {
|
||||
if (document.documentElement.style[keys[i]] !== undefined) {
|
||||
ionic.CSS.TRANSITION = keys[i];
|
||||
break;
|
||||
@@ -46,7 +46,7 @@
|
||||
return function() {
|
||||
var x, classes = self.className.split(/\s+/);
|
||||
|
||||
for(x=0; x<arguments.length; x++) {
|
||||
for (x = 0; x < arguments.length; x++) {
|
||||
fn(classes, classes.indexOf(arguments[x]), arguments[x]);
|
||||
}
|
||||
|
||||
|
||||
128
js/utils/tap.js
128
js/utils/tap.js
@@ -117,7 +117,7 @@ ionic.tap = {
|
||||
tapEventListener('mouseup');
|
||||
tapEventListener('mousedown');
|
||||
|
||||
if( window.navigator.pointerEnabled ) {
|
||||
if (window.navigator.pointerEnabled) {
|
||||
tapEventListener('pointerdown');
|
||||
tapEventListener('pointerup');
|
||||
tapEventListener('pointcancel');
|
||||
@@ -139,7 +139,7 @@ ionic.tap = {
|
||||
tapEventListener('focusout');
|
||||
|
||||
return function() {
|
||||
for(var type in tapEventListeners) {
|
||||
for (var type in tapEventListeners) {
|
||||
tapEventListener(type, false);
|
||||
}
|
||||
tapDoc = null;
|
||||
@@ -162,7 +162,7 @@ ionic.tap = {
|
||||
return !!ele &&
|
||||
(ele.tagName == 'TEXTAREA' ||
|
||||
ele.contentEditable === 'true' ||
|
||||
(ele.tagName == 'INPUT' && !(/^(radio|checkbox|range|file|submit|reset)$/i).test(ele.type)) );
|
||||
(ele.tagName == 'INPUT' && !(/^(radio|checkbox|range|file|submit|reset)$/i).test(ele.type)));
|
||||
},
|
||||
|
||||
isDateInput: function(ele) {
|
||||
@@ -174,7 +174,7 @@ ionic.tap = {
|
||||
var container = tapContainingElement(ele, false);
|
||||
|
||||
return !!container &&
|
||||
ionic.tap.isTextInput( tapTargetElement( container ) );
|
||||
ionic.tap.isTextInput(tapTargetElement(container));
|
||||
},
|
||||
|
||||
containsOrIsTextInput: function(ele) {
|
||||
@@ -182,14 +182,14 @@ ionic.tap = {
|
||||
},
|
||||
|
||||
cloneFocusedInput: function(container, scrollIntance) {
|
||||
if(ionic.tap.hasCheckedClone) return;
|
||||
if (ionic.tap.hasCheckedClone) return;
|
||||
ionic.tap.hasCheckedClone = true;
|
||||
|
||||
ionic.requestAnimationFrame(function(){
|
||||
ionic.requestAnimationFrame(function() {
|
||||
var focusInput = container.querySelector(':focus');
|
||||
if( ionic.tap.isTextInput(focusInput) ) {
|
||||
if (ionic.tap.isTextInput(focusInput)) {
|
||||
var clonedInput = focusInput.parentElement.querySelector('.cloned-text-input');
|
||||
if(!clonedInput) {
|
||||
if (!clonedInput) {
|
||||
clonedInput = document.createElement(focusInput.tagName);
|
||||
clonedInput.placeholder = focusInput.placeholder;
|
||||
clonedInput.type = focusInput.type;
|
||||
@@ -215,16 +215,16 @@ ionic.tap = {
|
||||
removeClonedInputs: function(container, scrollIntance) {
|
||||
ionic.tap.hasCheckedClone = false;
|
||||
|
||||
ionic.requestAnimationFrame(function(){
|
||||
ionic.requestAnimationFrame(function() {
|
||||
var clonedInputs = container.querySelectorAll('.cloned-text-input');
|
||||
var previousInputFocus = container.querySelectorAll('.previous-input-focus');
|
||||
var x;
|
||||
|
||||
for(x=0; x<clonedInputs.length; x++) {
|
||||
clonedInputs[x].parentElement.removeChild( clonedInputs[x] );
|
||||
for (x = 0; x < clonedInputs.length; x++) {
|
||||
clonedInputs[x].parentElement.removeChild(clonedInputs[x]);
|
||||
}
|
||||
|
||||
for(x=0; x<previousInputFocus.length; x++) {
|
||||
for (x = 0; x < previousInputFocus.length; x++) {
|
||||
previousInputFocus[x].classList.remove('previous-input-focus');
|
||||
previousInputFocus[x].style.top = '';
|
||||
previousInputFocus[x].focus();
|
||||
@@ -233,7 +233,7 @@ ionic.tap = {
|
||||
},
|
||||
|
||||
requiresNativeClick: function(ele) {
|
||||
if(!ele || ele.disabled || (/^(file|range)$/i).test(ele.type) || (/^(object|video)$/i).test(ele.tagName) || ionic.tap.isLabelContainingFileInput(ele) ) {
|
||||
if (!ele || ele.disabled || (/^(file|range)$/i).test(ele.type) || (/^(object|video)$/i).test(ele.tagName) || ionic.tap.isLabelContainingFileInput(ele)) {
|
||||
return true;
|
||||
}
|
||||
return ionic.tap.isElementTapDisabled(ele);
|
||||
@@ -241,17 +241,17 @@ ionic.tap = {
|
||||
|
||||
isLabelContainingFileInput: function(ele) {
|
||||
var lbl = tapContainingElement(ele);
|
||||
if(lbl.tagName !== 'LABEL') return false;
|
||||
if (lbl.tagName !== 'LABEL') return false;
|
||||
var fileInput = lbl.querySelector('input[type=file]');
|
||||
if(fileInput && fileInput.disabled === false) return true;
|
||||
if (fileInput && fileInput.disabled === false) return true;
|
||||
return false;
|
||||
},
|
||||
|
||||
isElementTapDisabled: function(ele) {
|
||||
if(ele && ele.nodeType === 1) {
|
||||
if (ele && ele.nodeType === 1) {
|
||||
var element = ele;
|
||||
while(element) {
|
||||
if( (element.dataset ? element.dataset.tapDisabled : element.getAttribute('data-tap-disabled')) == 'true' ) {
|
||||
while (element) {
|
||||
if ((element.dataset ? element.dataset.tapDisabled : element.getAttribute('data-tap-disabled')) == 'true') {
|
||||
return true;
|
||||
}
|
||||
element = element.parentElement;
|
||||
@@ -275,10 +275,10 @@ ionic.tap = {
|
||||
// This method can get coordinates for both a mouse click
|
||||
// or a touch depending on the given event
|
||||
var c = { x:0, y:0 };
|
||||
if(event) {
|
||||
if (event) {
|
||||
var touches = event.touches && event.touches.length ? event.touches : [event];
|
||||
var e = (event.changedTouches && event.changedTouches[0]) || touches[0];
|
||||
if(e) {
|
||||
if (e) {
|
||||
c.x = e.clientX || e.pageX || 0;
|
||||
c.y = e.clientY || e.pageY || 0;
|
||||
}
|
||||
@@ -289,7 +289,7 @@ ionic.tap = {
|
||||
};
|
||||
|
||||
function tapEventListener(type, enable, useCapture) {
|
||||
if(enable !== false) {
|
||||
if (enable !== false) {
|
||||
tapDoc.addEventListener(type, tapEventListeners[type], useCapture);
|
||||
} else {
|
||||
tapDoc.removeEventListener(type, tapEventListeners[type]);
|
||||
@@ -301,7 +301,7 @@ function tapClick(e) {
|
||||
var container = tapContainingElement(e.target);
|
||||
var ele = tapTargetElement(container);
|
||||
|
||||
if( ionic.tap.requiresNativeClick(ele) || tapPointerMoved ) return false;
|
||||
if (ionic.tap.requiresNativeClick(ele) || tapPointerMoved) return false;
|
||||
|
||||
var c = ionic.tap.pointerCoord(e);
|
||||
|
||||
@@ -321,18 +321,18 @@ function triggerMouseEvent(type, ele, x, y) {
|
||||
}
|
||||
|
||||
function tapClickGateKeeper(e) {
|
||||
if(e.target.type == 'submit' && e.detail === 0) {
|
||||
if (e.target.type == 'submit' && e.detail === 0) {
|
||||
// do not prevent click if it came from an "Enter" or "Go" keypress submit
|
||||
return;
|
||||
}
|
||||
|
||||
// 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 && !ionic.tap.requiresNativeClick(e.target)) ) {
|
||||
if ((ionic.scroll.isScrolling && ionic.tap.containsOrIsTextInput(e.target)) ||
|
||||
(!e.isIonicTap && !ionic.tap.requiresNativeClick(e.target))) {
|
||||
//console.log('clickPrevent', e.target.tagName);
|
||||
e.stopPropagation();
|
||||
|
||||
if( !ionic.tap.isLabelWithTextInput(e.target) ) {
|
||||
if (!ionic.tap.isLabelWithTextInput(e.target)) {
|
||||
// labels clicks from native should not preventDefault othersize keyboard will not show on input focus
|
||||
e.preventDefault();
|
||||
}
|
||||
@@ -342,13 +342,13 @@ function tapClickGateKeeper(e) {
|
||||
|
||||
// MOUSE
|
||||
function tapMouseDown(e) {
|
||||
if(e.isIonicTap || tapIgnoreEvent(e)) return;
|
||||
if (e.isIonicTap || tapIgnoreEvent(e)) return;
|
||||
|
||||
if(tapEnabledTouchEvents) {
|
||||
if (tapEnabledTouchEvents) {
|
||||
console.log('mousedown', 'stop event');
|
||||
e.stopPropagation();
|
||||
|
||||
if( (!ionic.tap.isTextInput(e.target) || tapLastTouchTarget !== e.target) && !(/^(select|option)$/i).test(e.target.tagName) ) {
|
||||
if ((!ionic.tap.isTextInput(e.target) || tapLastTouchTarget !== e.target) && !(/^(select|option)$/i).test(e.target.tagName)) {
|
||||
// If you preventDefault on a text input then you cannot move its text caret/cursor.
|
||||
// Allow through only the text input default. However, without preventDefault on an
|
||||
// input the 300ms delay can change focus on inputs after the keyboard shows up.
|
||||
@@ -367,15 +367,15 @@ function tapMouseDown(e) {
|
||||
}
|
||||
|
||||
function tapMouseUp(e) {
|
||||
if(tapEnabledTouchEvents) {
|
||||
if (tapEnabledTouchEvents) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
|
||||
if( tapIgnoreEvent(e) || (/^(select|option)$/i).test(e.target.tagName) ) return false;
|
||||
if (tapIgnoreEvent(e) || (/^(select|option)$/i).test(e.target.tagName)) return false;
|
||||
|
||||
if( !tapHasPointerMoved(e) ) {
|
||||
if (!tapHasPointerMoved(e)) {
|
||||
tapClick(e);
|
||||
}
|
||||
tapEventListener('mousemove', false);
|
||||
@@ -384,7 +384,7 @@ function tapMouseUp(e) {
|
||||
}
|
||||
|
||||
function tapMouseMove(e) {
|
||||
if( tapHasPointerMoved(e) ) {
|
||||
if (tapHasPointerMoved(e)) {
|
||||
tapEventListener('mousemove', false);
|
||||
ionic.activator.end();
|
||||
tapPointerMoved = true;
|
||||
@@ -395,7 +395,7 @@ function tapMouseMove(e) {
|
||||
|
||||
// TOUCH
|
||||
function tapTouchStart(e) {
|
||||
if( tapIgnoreEvent(e) ) return;
|
||||
if (tapIgnoreEvent(e)) return;
|
||||
|
||||
tapPointerMoved = false;
|
||||
|
||||
@@ -405,14 +405,14 @@ function tapTouchStart(e) {
|
||||
tapEventListener(tapTouchMoveListener);
|
||||
ionic.activator.start(e);
|
||||
|
||||
if( ionic.Platform.isIOS() && ionic.tap.isLabelWithTextInput(e.target) ) {
|
||||
if (ionic.Platform.isIOS() && ionic.tap.isLabelWithTextInput(e.target)) {
|
||||
// if the tapped element is a label, which has a child input
|
||||
// then preventDefault so iOS doesn't ugly auto scroll to the input
|
||||
// but do not prevent default on Android or else you cannot move the text caret
|
||||
// and do not prevent default on Android or else no virtual keyboard shows up
|
||||
|
||||
var textInput = tapTargetElement( tapContainingElement(e.target) );
|
||||
if( textInput !== tapActiveEle ) {
|
||||
var textInput = tapTargetElement(tapContainingElement(e.target));
|
||||
if (textInput !== tapActiveEle) {
|
||||
// don't preventDefault on an already focused input or else iOS's text caret isn't usable
|
||||
e.preventDefault();
|
||||
}
|
||||
@@ -420,13 +420,13 @@ function tapTouchStart(e) {
|
||||
}
|
||||
|
||||
function tapTouchEnd(e) {
|
||||
if( tapIgnoreEvent(e) ) return;
|
||||
if (tapIgnoreEvent(e)) return;
|
||||
|
||||
tapEnableTouchEvents();
|
||||
if( !tapHasPointerMoved(e) ) {
|
||||
if (!tapHasPointerMoved(e)) {
|
||||
tapClick(e);
|
||||
|
||||
if( (/^(select|option)$/i).test(e.target.tagName) ) {
|
||||
if ((/^(select|option)$/i).test(e.target.tagName)) {
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
@@ -436,7 +436,7 @@ function tapTouchEnd(e) {
|
||||
}
|
||||
|
||||
function tapTouchMove(e) {
|
||||
if( tapHasPointerMoved(e) ) {
|
||||
if (tapHasPointerMoved(e)) {
|
||||
tapPointerMoved = true;
|
||||
tapEventListener(tapTouchMoveListener, false);
|
||||
ionic.activator.end();
|
||||
@@ -453,16 +453,16 @@ function tapTouchCancel(e) {
|
||||
function tapEnableTouchEvents() {
|
||||
tapEnabledTouchEvents = true;
|
||||
clearTimeout(tapMouseResetTimer);
|
||||
tapMouseResetTimer = setTimeout(function(){
|
||||
tapMouseResetTimer = setTimeout(function() {
|
||||
tapEnabledTouchEvents = false;
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
function tapIgnoreEvent(e) {
|
||||
if(e.isTapHandled) return true;
|
||||
if (e.isTapHandled) return true;
|
||||
e.isTapHandled = true;
|
||||
|
||||
if( ionic.scroll.isScrolling && ionic.tap.containsOrIsTextInput(e.target) ) {
|
||||
if (ionic.scroll.isScrolling && ionic.tap.containsOrIsTextInput(e.target)) {
|
||||
e.preventDefault();
|
||||
return true;
|
||||
}
|
||||
@@ -473,21 +473,21 @@ function tapHandleFocus(ele) {
|
||||
|
||||
var triggerFocusIn = false;
|
||||
|
||||
if(ele.tagName == 'SELECT') {
|
||||
if (ele.tagName == 'SELECT') {
|
||||
// trick to force Android options to show up
|
||||
triggerMouseEvent('mousedown', ele, 0, 0);
|
||||
ele.focus && ele.focus();
|
||||
triggerFocusIn = true;
|
||||
|
||||
} else if(tapActiveElement() === ele) {
|
||||
} else if (tapActiveElement() === ele) {
|
||||
// already is the active element and has focus
|
||||
triggerFocusIn = true;
|
||||
|
||||
} else if( (/^(input|textarea)$/i).test(ele.tagName) || ele.isContentEditable ) {
|
||||
} else if ((/^(input|textarea)$/i).test(ele.tagName) || ele.isContentEditable) {
|
||||
triggerFocusIn = true;
|
||||
ele.focus && ele.focus();
|
||||
ele.value = ele.value;
|
||||
if( tapEnabledTouchEvents ) {
|
||||
if (tapEnabledTouchEvents) {
|
||||
tapTouchFocusedInput = ele;
|
||||
}
|
||||
|
||||
@@ -495,7 +495,7 @@ function tapHandleFocus(ele) {
|
||||
tapFocusOutActive();
|
||||
}
|
||||
|
||||
if(triggerFocusIn) {
|
||||
if (triggerFocusIn) {
|
||||
tapActiveElement(ele);
|
||||
ionic.trigger('ionic.focusin', {
|
||||
target: ele
|
||||
@@ -505,7 +505,7 @@ function tapHandleFocus(ele) {
|
||||
|
||||
function tapFocusOutActive() {
|
||||
var ele = tapActiveElement();
|
||||
if(ele && ((/^(input|textarea|select)$/i).test(ele.tagName) || ele.isContentEditable) ) {
|
||||
if (ele && ((/^(input|textarea|select)$/i).test(ele.tagName) || ele.isContentEditable)) {
|
||||
console.log('tapFocusOutActive', ele.tagName);
|
||||
ele.blur();
|
||||
}
|
||||
@@ -517,10 +517,10 @@ function tapFocusIn(e) {
|
||||
// that it's mousedown event 300ms later will change the focus to another element after
|
||||
// the keyboard shows up.
|
||||
|
||||
if( tapEnabledTouchEvents &&
|
||||
ionic.tap.isTextInput( tapActiveElement() ) &&
|
||||
if (tapEnabledTouchEvents &&
|
||||
ionic.tap.isTextInput(tapActiveElement()) &&
|
||||
ionic.tap.isTextInput(tapTouchFocusedInput) &&
|
||||
tapTouchFocusedInput !== e.target ) {
|
||||
tapTouchFocusedInput !== e.target) {
|
||||
|
||||
// 1) The pointer is from touch events
|
||||
// 2) There is an active element which is a text input
|
||||
@@ -538,14 +538,14 @@ function tapFocusOut() {
|
||||
}
|
||||
|
||||
function tapActiveElement(ele) {
|
||||
if(arguments.length) {
|
||||
if (arguments.length) {
|
||||
tapActiveEle = ele;
|
||||
}
|
||||
return tapActiveEle || document.activeElement;
|
||||
}
|
||||
|
||||
function tapHasPointerMoved(endEvent) {
|
||||
if(!endEvent || endEvent.target.nodeType !== 1 || !tapPointerStart || ( tapPointerStart.x === 0 && tapPointerStart.y === 0 )) {
|
||||
if (!endEvent || endEvent.target.nodeType !== 1 || !tapPointerStart || (tapPointerStart.x === 0 && tapPointerStart.y === 0)) {
|
||||
return false;
|
||||
}
|
||||
var endCoordinates = ionic.tap.pointerCoord(endEvent);
|
||||
@@ -562,28 +562,28 @@ function tapHasPointerMoved(endEvent) {
|
||||
|
||||
function tapContainingElement(ele, allowSelf) {
|
||||
var climbEle = ele;
|
||||
for(var x=0; x<6; x++) {
|
||||
if(!climbEle) break;
|
||||
if(climbEle.tagName === 'LABEL') return climbEle;
|
||||
for (var x = 0; x < 6; x++) {
|
||||
if (!climbEle) break;
|
||||
if (climbEle.tagName === 'LABEL') return climbEle;
|
||||
climbEle = climbEle.parentElement;
|
||||
}
|
||||
if(allowSelf !== false) return ele;
|
||||
if (allowSelf !== false) return ele;
|
||||
}
|
||||
|
||||
function tapTargetElement(ele) {
|
||||
if(ele && ele.tagName === 'LABEL') {
|
||||
if(ele.control) return ele.control;
|
||||
if (ele && ele.tagName === 'LABEL') {
|
||||
if (ele.control) return ele.control;
|
||||
|
||||
// older devices do not support the "control" property
|
||||
if(ele.querySelector) {
|
||||
if (ele.querySelector) {
|
||||
var control = ele.querySelector('input,textarea,select');
|
||||
if(control) return control;
|
||||
if (control) return control;
|
||||
}
|
||||
}
|
||||
return ele;
|
||||
}
|
||||
|
||||
ionic.DomUtil.ready(function(){
|
||||
ionic.DomUtil.ready(function() {
|
||||
var ng = typeof angular !== 'undefined' ? angular : null;
|
||||
//do nothing for e2e tests
|
||||
if (!ng || (ng && !ng.scenario)) {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
*/
|
||||
ionic.Utils = {
|
||||
|
||||
arrayMove: function (arr, old_index, new_index) {
|
||||
arrayMove: function(arr, old_index, new_index) {
|
||||
if (new_index >= arr.length) {
|
||||
var k = new_index - arr.length;
|
||||
while ((k--) + 1) {
|
||||
@@ -107,7 +107,7 @@
|
||||
if (protoProps && protoProps.hasOwnProperty('constructor')) {
|
||||
child = protoProps.constructor;
|
||||
} else {
|
||||
child = function(){ return parent.apply(this, arguments); };
|
||||
child = function() { return parent.apply(this, arguments); };
|
||||
}
|
||||
|
||||
// Add static properties to the constructor function, if supplied.
|
||||
@@ -115,7 +115,7 @@
|
||||
|
||||
// Set the prototype chain to inherit from `parent`, without calling
|
||||
// `parent`'s constructor function.
|
||||
var Surrogate = function(){ this.constructor = child; };
|
||||
var Surrogate = function() { this.constructor = child; };
|
||||
Surrogate.prototype = parent.prototype;
|
||||
child.prototype = new Surrogate();
|
||||
|
||||
@@ -133,7 +133,7 @@
|
||||
// Extend adapted from Underscore.js
|
||||
extend: function(obj) {
|
||||
var args = Array.prototype.slice.call(arguments, 1);
|
||||
for(var i = 0; i < args.length; i++) {
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
var source = args[i];
|
||||
if (source) {
|
||||
for (var prop in source) {
|
||||
@@ -156,7 +156,7 @@
|
||||
var index = uid.length;
|
||||
var digit;
|
||||
|
||||
while(index) {
|
||||
while (index) {
|
||||
index--;
|
||||
digit = uid[index].charCodeAt(0);
|
||||
if (digit == 57 /*'9'*/) {
|
||||
|
||||
@@ -14,18 +14,18 @@ ionic.viewport = {
|
||||
function viewportLoadTag() {
|
||||
var x;
|
||||
|
||||
for(x=0; x<document.head.children.length; x++) {
|
||||
if(document.head.children[x].name == 'viewport') {
|
||||
for (x = 0; x < document.head.children.length; x++) {
|
||||
if (document.head.children[x].name == 'viewport') {
|
||||
viewportTag = document.head.children[x];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(viewportTag) {
|
||||
if (viewportTag) {
|
||||
var props = viewportTag.content.toLowerCase().replace(/\s+/g, '').split(',');
|
||||
var keyValue;
|
||||
for(x=0; x<props.length; x++) {
|
||||
if(props[x]) {
|
||||
for (x = 0; x < props.length; x++) {
|
||||
if (props[x]) {
|
||||
keyValue = props[x].split('=');
|
||||
viewportProperties[ keyValue[0] ] = (keyValue.length > 1 ? keyValue[1] : '_');
|
||||
}
|
||||
@@ -50,10 +50,10 @@ function viewportUpdate() {
|
||||
delete viewportProperties.height;
|
||||
viewportProperties.width = DEVICE_WIDTH;
|
||||
|
||||
if( p.isIPad() ) {
|
||||
if (p.isIPad()) {
|
||||
// iPad
|
||||
|
||||
if( version > 7 ) {
|
||||
if (version > 7) {
|
||||
// iPad >= 7.1
|
||||
// https://issues.apache.org/jira/browse/CB-4323
|
||||
delete viewportProperties.width;
|
||||
@@ -61,41 +61,41 @@ function viewportUpdate() {
|
||||
} else {
|
||||
// iPad <= 7.0
|
||||
|
||||
if( p.isWebView() ) {
|
||||
if (p.isWebView()) {
|
||||
// iPad <= 7.0 WebView
|
||||
|
||||
if( orientation == 90 ) {
|
||||
if (orientation == 90) {
|
||||
// iPad <= 7.0 WebView Landscape
|
||||
viewportProperties.height = '0';
|
||||
|
||||
} else if(version == 7) {
|
||||
} else if (version == 7) {
|
||||
// iPad <= 7.0 WebView Portait
|
||||
viewportProperties.height = DEVICE_HEIGHT;
|
||||
}
|
||||
} else {
|
||||
// iPad <= 6.1 Browser
|
||||
if(version < 7) {
|
||||
if (version < 7) {
|
||||
viewportProperties.height = '0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if( p.isIOS() ) {
|
||||
} else if (p.isIOS()) {
|
||||
// iPhone
|
||||
|
||||
if( p.isWebView() ) {
|
||||
if (p.isWebView()) {
|
||||
// iPhone WebView
|
||||
|
||||
if(version > 7) {
|
||||
if (version > 7) {
|
||||
// iPhone >= 7.1 WebView
|
||||
delete viewportProperties.width;
|
||||
|
||||
} else if(version < 7) {
|
||||
} else if (version < 7) {
|
||||
// iPhone <= 6.1 WebView
|
||||
// if height was set it needs to get removed with this hack for <= 6.1
|
||||
if( initHeight ) viewportProperties.height = '0';
|
||||
if (initHeight) viewportProperties.height = '0';
|
||||
|
||||
} else if(version == 7) {
|
||||
} else if (version == 7) {
|
||||
//iPhone == 7.0 WebView
|
||||
viewportProperties.height = DEVICE_HEIGHT;
|
||||
}
|
||||
@@ -106,23 +106,23 @@ function viewportUpdate() {
|
||||
if (version < 7) {
|
||||
// iPhone <= 6.1 Browser
|
||||
// if height was set it needs to get removed with this hack for <= 6.1
|
||||
if( initHeight ) viewportProperties.height = '0';
|
||||
if (initHeight) viewportProperties.height = '0';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// only update the viewport tag if there was a change
|
||||
if(initWidth !== viewportProperties.width || initHeight !== viewportProperties.height) {
|
||||
if (initWidth !== viewportProperties.width || initHeight !== viewportProperties.height) {
|
||||
viewportTagUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
function viewportTagUpdate() {
|
||||
var key, props = [];
|
||||
for(key in viewportProperties) {
|
||||
if( viewportProperties[key] ) {
|
||||
props.push(key + (viewportProperties[key] == '_' ? '' : '=' + viewportProperties[key]) );
|
||||
for (key in viewportProperties) {
|
||||
if (viewportProperties[key]) {
|
||||
props.push(key + (viewportProperties[key] == '_' ? '' : '=' + viewportProperties[key]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ function viewportTagUpdate() {
|
||||
ionic.Platform.ready(function() {
|
||||
viewportLoadTag();
|
||||
|
||||
window.addEventListener("orientationchange", function(){
|
||||
window.addEventListener("orientationchange", function() {
|
||||
setTimeout(viewportUpdate, 1000);
|
||||
}, false);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user