From 0b375d4eb933edb1248d5baaa3621de5dff6ec08 Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Fri, 11 Oct 2013 12:09:19 -0500 Subject: [PATCH] Toggle sjhit --- example/toderp2/index.html | 6 +++- js/ext/angular/src/directive/ionicList.js | 3 ++ js/ext/angular/src/directive/ionicToggle.js | 35 +++++++++++++++++++++ js/views/toggleView.js | 2 ++ 4 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 js/ext/angular/src/directive/ionicToggle.js diff --git a/example/toderp2/index.html b/example/toderp2/index.html index a0390333c6..a6d8388a1d 100644 --- a/example/toderp2/index.html +++ b/example/toderp2/index.html @@ -166,7 +166,11 @@
- Log out + Account details + Account details + + + Log out
diff --git a/js/ext/angular/src/directive/ionicList.js b/js/ext/angular/src/directive/ionicList.js index 4f7667e635..4e3bd9fe29 100644 --- a/js/ext/angular/src/directive/ionicList.js +++ b/js/ext/angular/src/directive/ionicList.js @@ -33,6 +33,7 @@ angular.module('ionic.ui.list', ['ionic.service', 'ngAnimate']) return { restrict: 'E', replace: true, + transclude: true, scope: { isEditing: '=', items: '=', @@ -52,6 +53,8 @@ angular.module('ionic.ui.list', ['ionic.service', 'ngAnimate']) if(attr.animation) { $element.addClass(attr.animation); } + + $element.append(transclude($scope)); } } } diff --git a/js/ext/angular/src/directive/ionicToggle.js b/js/ext/angular/src/directive/ionicToggle.js new file mode 100644 index 0000000000..1fc093279c --- /dev/null +++ b/js/ext/angular/src/directive/ionicToggle.js @@ -0,0 +1,35 @@ +angular.module('ionic.ui.content', []) + +// The content directive is a core scrollable content area +// that is part of many View hierarchies +.directive('toggle', function() { + return { + restrict: 'E', + replace: true, + scope: {}, + require: '?ngModel', + template: '
' + + ' '+ + '
' + + '
' + + '
', + + link: function($scope, $element, $attr, ngModel) { + var checkbox; + + $scope.toggle = new ionic.views.Toggle({ el: $element[0] }); + + if(!ngModel) { return; } + + checkbox = $element.children()[0]; + + if(!checkbox) { return; } + + ngModel.$render = function() { + checkbox.checked = ngModel.$viewValue; + }; + + + } + } +}) diff --git a/js/views/toggleView.js b/js/views/toggleView.js index 5c3c27c8e0..fab00d6907 100644 --- a/js/views/toggleView.js +++ b/js/views/toggleView.js @@ -8,6 +8,7 @@ this.handle = opts.handle; this.openPercent = -1; + /* // remember that this element, and all its children are apart of a component // and assign the component instance to each element so the lookups // only has to go through this process just once @@ -16,6 +17,7 @@ this.track.isComponent = true; this.handle.component = this; this.handle.isComponent = true; + */ }; ionic.views.Toggle.prototype = {