started checkbox

This commit is contained in:
Adam Bradley
2013-10-11 16:41:43 -05:00
parent 5f34979f4b
commit 17ae340b13
10 changed files with 221 additions and 10 deletions

View File

@ -7,6 +7,7 @@ angular.module('ionic.ui', ['ionic.ui.content',
'ionic.ui.nav',
'ionic.ui.sideMenu',
'ionic.ui.list',
'ionic.ui.checkbox',
'ionic.ui.toggle'
]);
@ -154,6 +155,46 @@ angular.module('ionic.ui.actionSheet', [])
}
});
;
angular.module('ionic.ui.checkbox', [])
.directive('checkbox', function() {
return {
restrict: 'E',
replace: true,
require: '?ngModel',
scope: true,
template: '<div class="checkbox"><input type="checkbox"><div class="handle"></div></div>',
link: function($scope, $element, $attr, ngModel) {
var checkbox, handle;
if(!ngModel) { return; }
checkbox = $element.children().eq(0);
handle = $element.children().eq(1);
if(!checkbox.length || !handle.length) { return; }
$scope.checkbox = new ionic.views.Checkbox({
el: $element[0],
checkbox: checkbox[0],
handle: handle[0]
});
$element.bind('click', function(e) {
$scope.checkbox.tap(e);
$scope.$apply(function() {
ngModel.$setViewValue(checkbox[0].checked);
});
});
ngModel.$render = function() {
$scope.checkbox.val(ngModel.$viewValue);
};
}
}
});
angular.module('ionic.ui.content', [])
// The content directive is a core scrollable content area