Merge branch '272-checkboxes'

This commit is contained in:
Max Lynch
2013-12-07 18:01:37 -06:00
10 changed files with 98 additions and 84 deletions

View File

@@ -11,32 +11,29 @@ angular.module('ionic.ui.checkbox', [])
require: '?ngModel',
scope: {},
transclude: true,
template: '<label ng-click="tapHandler($event)" class="checkbox"><input type="checkbox"><div ng-transclude></div></label>',
template: '<li class="item item-checkbox">\
<label class="checkbox">\
<input type="checkbox">\
</label>\
<div class="item-content" ng-transclude>\
</div>\
</li>',
link: function($scope, $element, $attr, ngModel) {
var checkbox;
if(!ngModel) { return; }
checkbox = $element.children().eq(0);
checkbox = angular.element($element[0].querySelector('input[type="checkbox"]'));
if(!checkbox.length) { return; }
$scope.tapHandler = function(e) {
if(e.type != 'click') {
checkbox[0].checked = !checkbox[0].checked;
}
checkbox.bind('change', function(e) {
ngModel.$setViewValue(checkbox[0].checked);
e.alreadyHandled = true;
};
var clickHandler = function(e) {
checkbox[0].checked = !checkbox[0].checked;
$scope.$apply(function() {
ngModel.$setViewValue(checkbox[0].checked);
e.alreadyHandled = true;
});
};
});
if(ngModel) {
ngModel.$render = function() {

View File

@@ -40,7 +40,7 @@ angular.module('ionic.ui.navRouter', ['ionic.service.gesture'])
};
}],
link: function($scope, $element, $attr) {
link: function($scope, $element, $attr, ctrl) {
if(!$element.length) return;
$scope.animation = $attr.animation;
@@ -99,6 +99,10 @@ angular.module('ionic.ui.navRouter', ['ionic.service.gesture'])
}
});
$scope.$on('navRouter.goBack', function(e) {
ctrl.goBack();
});
// Keep track of location changes and update a stack pointer that tracks whether we are
// going forwards or back
@@ -370,7 +374,6 @@ angular.module('ionic.ui.navRouter', ['ionic.service.gesture'])
.directive('navBack', ['$window', '$rootScope', 'Gesture', function($window, $rootScope, Gesture) {
return {
restrict: 'AC',
require: '^?navRouter',
link: function($scope, $element, $attr, navCtrl) {
var goBack = function(e) {
// Only trigger back if the stack is greater than zero
@@ -378,7 +381,7 @@ angular.module('ionic.ui.navRouter', ['ionic.service.gesture'])
$window.history.back();
// Fallback for bad history supporting devices
navCtrl.goBack();
$scope.$emit('navRouter.goBack');
}
e.alreadyHandled = true;
return false;

View File

@@ -14,8 +14,8 @@ angular.module('ionic.ui.radio', [])
value: '@'
},
transclude: true,
template: '<label ng-click="tapHandler($event)" class="item item-radio">\
<input type="radio" name="group">\
template: '<label class="item item-radio">\
<input type="radio" name="radio-group">\
<div class="item-content" ng-transclude>\
</div>\
<i class="radio-icon icon ion-checkmark"></i>\
@@ -30,19 +30,14 @@ angular.module('ionic.ui.radio', [])
if(!radio.length) { return; }
$scope.tapHandler = function(e) {
radio[0].checked = true;
ngModel.$setViewValue($scope.$eval($attr.ngValue));
e.alreadyHandled = true;
};
var clickHandler = function(e) {
ngModel.$setViewValue($scope.$eval($attr.ngValue));
};
if(ngModel) {
//$element.bind('tap', tapHandler);
$element.bind('click', clickHandler);
radio.bind('click', function(e) {
console.log('RADIO CLICK');
$scope.$apply(function() {
ngModel.$setViewValue($scope.$eval($attr.ngValue));
});
e.alreadyHandled = true;
});
ngModel.$render = function() {
var val = $scope.$eval($attr.ngValue);
@@ -112,18 +107,15 @@ angular.module('ionic.ui.radio', [])
if(!ngModel || !radioButtons) { return; }
var setIt = function() {
console.log('SET');
$element.addClass('active');
ngModel.$setViewValue($scope.$eval($attr.ngValue));
radioButtons.select($element);
};
$scope.tapHandler = function(e) {
setIt();
e.alreadyHandled = true;
};
var clickHandler = function(e) {
console.log('CLICK');
setIt();
};

View File

@@ -11,7 +11,7 @@ angular.module('ionic.ui.toggle', [])
replace: true,
require: '?ngModel',
scope: {},
template: '<div ng-click="toggleIt($event)" class="toggle"><input type="checkbox"><div class="track"><div class="handle"></div></div></div>',
template: '<div ng-click="toggleIt($event)" class="toggle" skip-tap-poly><input type="checkbox"><div class="track"><div class="handle"></div></div></div>',
link: function($scope, $element, $attr, ngModel) {
var checkbox, handle;

View File

@@ -35,6 +35,9 @@ angular.module('ionic.service.platform', [])
}
}, 10);
return {
setPlatform: function(p) {
platform = p;