Poly stuff working better

This commit is contained in:
Max Lynch
2013-11-14 21:29:02 -06:00
parent df1d9c4d75
commit 37be253f60
7 changed files with 48 additions and 59 deletions

10
dist/css/ionic.css vendored
View File

@ -1,5 +1,5 @@
@charset "UTF-8";
/*!
/*
Ionicons, v1.3.4
Created by Ben Sperry for the Ionic Framework, http://ionicons.com/
https://twitter.com/helloimben https://twitter.com/ionicframework
@ -2045,7 +2045,7 @@ sub {
fieldset {
margin: 0 2px;
padding: 0.35em 0.625em 0.75em;
border: 1px solid #c0c0c0; }
border: 1px solid silver; }
/**
* 1. Correct `color` not being inherited in IE 8/9.
@ -4152,7 +4152,7 @@ input[type="checkbox"][readonly] {
border-radius: 50%;
background: white;
content: ' ';
transition: background-color .1s ease-in-out; }
transition: background-color 0.1s ease-in-out; }
/* the checkmark within the box */
.checkbox input:after {
@ -4167,7 +4167,7 @@ input[type="checkbox"][readonly] {
border-right: 0;
content: ' ';
opacity: 0;
transition: opacity .05s ease-in-out;
transition: opacity 0.05s ease-in-out;
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg); }
@ -4652,7 +4652,7 @@ input[type="range"] {
.button-icon:active, .button-icon.active {
background: none;
box-shadow: none;
text-shadow: 0px 0px 10px #fff; }
text-shadow: 0px 0px 10px white; }
.padding > .button.block:first-child {
margin-top: 0; }

View File

@ -1,3 +1,4 @@
@charset "UTF-8";
/**
* Nav controllers and header bar animations
*/
@ -118,7 +119,7 @@
right: 20px;
transition: 0.2s ease;
transition-property: left, right;
transition-delay: 0s, .05s; }
transition-delay: 0s, 0.05s; }
.toggle :checked + .track {
/* When the toggle is "on" */
@ -133,4 +134,4 @@
right: 0;
left: 20px;
-webkit-transform: none;
transition-delay: .05s, 0s; }
transition-delay: 0.05s, 0s; }

View File

@ -23545,7 +23545,8 @@ angular.module('ionic.ui.checkbox', [])
replace: true,
require: '?ngModel',
scope: {},
template: '<label class="checkbox"><input type="checkbox"></label>',
transclude: true,
template: '<label ng-click="tapHandler($event)" class="checkbox"><input type="checkbox"><div ng-transclude></div></label>',
link: function($scope, $element, $attr, ngModel) {
@ -23557,12 +23558,12 @@ angular.module('ionic.ui.checkbox', [])
if(!checkbox.length) { return; }
var tapHandler = function(e) {
$scope.tapHandler = function(e) {
if(e.type != 'click') {
checkbox[0].checked = !checkbox[0].checked;
$scope.$apply(function() {
}
ngModel.$setViewValue(checkbox[0].checked);
});
e.preventDefault();
e.alreadyHandled = true;
};
var clickHandler = function(e) {
@ -23572,17 +23573,8 @@ angular.module('ionic.ui.checkbox', [])
});
};
$scope.$on('$destroy', function() {
$element.unbind('tap', tapHandler);
$element.unbind('click', clickHandler);
});
if(ngModel) {
$element.bind('tap', tapHandler);
$element.bind('click', clickHandler);
ngModel.$render = function() {
console.log('checkbox redern', ngModel.$viewValue);
checkbox[0].checked = ngModel.$viewValue;
};
}
@ -24185,7 +24177,7 @@ angular.module('ionic.ui.radio', [])
value: '@'
},
transclude: true,
template: '<label class="item item-radio">\
template: '<label ng-click="tapHandler($event)" class="item item-radio">\
<input type="radio" name="group">\
<div class="item-content" ng-transclude>\
</div>\
@ -24201,10 +24193,10 @@ angular.module('ionic.ui.radio', [])
if(!radio.length) { return; }
var tapHandler = function(e) {
$scope.tapHandler = function(e) {
radio[0].checked = true;
ngModel.$setViewValue($scope.$eval($attr.ngValue));
e.preventDefault();
e.alreadyHandled = true;
};
var clickHandler = function(e) {
@ -24217,7 +24209,7 @@ angular.module('ionic.ui.radio', [])
});
if(ngModel) {
$element.bind('tap', tapHandler);
//$element.bind('tap', tapHandler);
$element.bind('click', clickHandler);
ngModel.$render = function() {

14
dist/js/ionic.js vendored
View File

@ -1803,8 +1803,7 @@ window.ionic = {
// polyfill use to simulate native "tap"
function inputTapPolyfill(ele, e) {
if(ele.type === "radio" || ele.type === "checkbox") {
console.log('RADIOPOLY');
ele.checked = !ele.checked;
//ele.checked = !ele.checked;
} else if(ele.type === "submit" || ele.type === "button") {
ele.click();
} else {
@ -1819,10 +1818,13 @@ window.ionic = {
// 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;
if(e.defaultPrevented) {
e.stopPropagation();
e.preventDefault();
return false;
// An internal Ionic indicator for angular directives that contain
// elements that normally need poly behavior, but are already processed
// (like the radio directive that has a radio button in it, but handles
// the tap stuff itself). This is in contrast to preventDefault which will
// mess up other operations like change events and such
if(e.alreadyHandled) {
return;
}
e = e.gesture.srcEvent; // evaluate the actual source event, not the created event by gestures.js

View File

@ -10,7 +10,8 @@ angular.module('ionic.ui.checkbox', [])
replace: true,
require: '?ngModel',
scope: {},
template: '<label class="checkbox"><input type="checkbox"></label>',
transclude: true,
template: '<label ng-click="tapHandler($event)" class="checkbox"><input type="checkbox"><div ng-transclude></div></label>',
link: function($scope, $element, $attr, ngModel) {
@ -22,12 +23,12 @@ angular.module('ionic.ui.checkbox', [])
if(!checkbox.length) { return; }
var tapHandler = function(e) {
$scope.tapHandler = function(e) {
if(e.type != 'click') {
checkbox[0].checked = !checkbox[0].checked;
$scope.$apply(function() {
}
ngModel.$setViewValue(checkbox[0].checked);
});
e.preventDefault();
e.alreadyHandled = true;
};
var clickHandler = function(e) {
@ -37,17 +38,8 @@ angular.module('ionic.ui.checkbox', [])
});
};
$scope.$on('$destroy', function() {
$element.unbind('tap', tapHandler);
$element.unbind('click', clickHandler);
});
if(ngModel) {
$element.bind('tap', tapHandler);
$element.bind('click', clickHandler);
ngModel.$render = function() {
console.log('checkbox redern', ngModel.$viewValue);
checkbox[0].checked = ngModel.$viewValue;
};
}

View File

@ -14,7 +14,7 @@ angular.module('ionic.ui.radio', [])
value: '@'
},
transclude: true,
template: '<label class="item item-radio">\
template: '<label ng-click="tapHandler($event)" class="item item-radio">\
<input type="radio" name="group">\
<div class="item-content" ng-transclude>\
</div>\
@ -30,10 +30,10 @@ angular.module('ionic.ui.radio', [])
if(!radio.length) { return; }
var tapHandler = function(e) {
$scope.tapHandler = function(e) {
radio[0].checked = true;
ngModel.$setViewValue($scope.$eval($attr.ngValue));
e.preventDefault();
e.alreadyHandled = true;
};
var clickHandler = function(e) {
@ -46,7 +46,7 @@ angular.module('ionic.ui.radio', [])
});
if(ngModel) {
$element.bind('tap', tapHandler);
//$element.bind('tap', tapHandler);
$element.bind('click', clickHandler);
ngModel.$render = function() {

View File

@ -32,8 +32,7 @@
// polyfill use to simulate native "tap"
function inputTapPolyfill(ele, e) {
if(ele.type === "radio" || ele.type === "checkbox") {
console.log('RADIOPOLY');
ele.checked = !ele.checked;
//ele.checked = !ele.checked;
} else if(ele.type === "submit" || ele.type === "button") {
ele.click();
} else {
@ -48,10 +47,13 @@
// 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;
if(e.defaultPrevented) {
e.stopPropagation();
e.preventDefault();
return false;
// An internal Ionic indicator for angular directives that contain
// elements that normally need poly behavior, but are already processed
// (like the radio directive that has a radio button in it, but handles
// the tap stuff itself). This is in contrast to preventDefault which will
// mess up other operations like change events and such
if(e.alreadyHandled) {
return;
}
e = e.gesture.srcEvent; // evaluate the actual source event, not the created event by gestures.js