Skip to content

Commit 4d793fd

Browse files
committed
demo(ionList): add demos
1 parent 7059b81 commit 4d793fd

File tree

1 file changed

+148
-0
lines changed

1 file changed

+148
-0
lines changed

js/angular/directive/list.js

+148
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,154 @@
7272
* @param can-swipe {boolean=} Whether the items in the list are allowed to be swiped to reveal
7373
* option buttons. Default: true.
7474
*/
75+
/**
76+
* @ngdoc demo
77+
* @name ionList#everything
78+
* @module listEverything
79+
* @javascript
80+
* angular.module('listEverything', ['ionic'])
81+
* .controller('ListCtrl', function($scope, $ionicPopup) {
82+
* $scope.data = {
83+
* showReorder: false,
84+
* showDelete: false
85+
* };
86+
*
87+
* $scope.items = [];
88+
* for (var i = 0; i < 20; i++) {
89+
* $scope.items.push(i);
90+
* }
91+
*
92+
* $scope.toggleDelete = function() {
93+
* $scope.data.showReorder = false;
94+
* $scope.data.showDelete = !$scope.data.showDelete;
95+
* };
96+
* $scope.toggleReorder = function() {
97+
* $scope.data.showDelete = false;
98+
* $scope.data.showReorder = !$scope.data.showReorder;
99+
* };
100+
*
101+
* $scope.share = function(item) {
102+
* alert('Sharing ' + item);
103+
* };
104+
* $scope.edit = function(item) {
105+
* alert('Editing ' + item);
106+
* };
107+
*
108+
* $scope.reorderItem = function(item, fromIndex, toIndex) {
109+
* $scope.items.splice(fromIndex, 1)
110+
* $scope.items.splice(toIndex, 0, item)
111+
* };
112+
* });
113+
*
114+
* @html
115+
* <div ng-controller="ListCtrl">
116+
* <ion-header-bar class="bar-positive">
117+
* <a class="button" ng-click="toggleDelete()">
118+
* Delete
119+
* </a>
120+
* <h1 class="title">List</h1>
121+
* <a class="button" ng-click="toggleReorder()">
122+
* Reorder
123+
* </a>
124+
* </ion-header-bar>
125+
* <ion-content>
126+
* <ion-list show-delete="data.showDelete"
127+
* show-reorder="data.showReorder">
128+
* <ion-item ng-repeat="item in items"
129+
* class="item-thumbnail-left">
130+
*
131+
* <img ng-src="http://placekitten.com/{{60+$index}}/{{61+2*$index}}">
132+
* <h2>Item {{item}}</h2>
133+
* <p>Here's an item description.</p>
134+
* <ion-option-button class="button-positive"
135+
* ng-click="share(item)">
136+
* Share
137+
* </ion-option-button>
138+
* <ion-option-button class="button-info"
139+
* ng-click="edit(item)">
140+
* Edit
141+
* </ion-option-button>
142+
* <ion-delete-button class="ion-minus-circled"
143+
* ng-click="items.splice($index, 1)">
144+
* </ion-delete-button>
145+
* <ion-reorder-button class="ion-navicon"
146+
* on-reorder="reorderItem(item, $fromIndex, $toIndex)">
147+
* </ion-reorder-button>
148+
*
149+
* </ion-item>
150+
* </ion-list>
151+
* </ion-content>
152+
* </div>
153+
*/
154+
/**
155+
* @ngdoc demo
156+
* @name ionList#animated
157+
* @module listAnimated
158+
* @javascript
159+
* angular.module('listAnimated', ['ionic'])
160+
* .controller('AnimatedListCtrl', function($scope, $timeout) {
161+
* var nextItem = 0;
162+
* $scope.items = [];
163+
* for (var i=0; i < 5; i++) {
164+
* $scope.items.push('Item ' + (nextItem++));
165+
* }
166+
*
167+
* $scope.addItem = function(atIndex) {
168+
* $scope.items.splice(atIndex + 1, 0, 'Item ' + nextItem);
169+
* nextItem++;
170+
* };
171+
* });
172+
*
173+
* @html
174+
* <div ng-controller="AnimatedListCtrl">
175+
* <ion-header-bar class="bar-positive">
176+
* <h1 class="title">Animated List</h1>
177+
* </ion-header-bar>
178+
* <ion-content>
179+
* <ion-list show-delete="showDelete">
180+
*
181+
* <ion-item class="animated-item"
182+
* ng-repeat="item in items">
183+
* {{item}}
184+
* <div class="item-note">
185+
* <a class="button button-small"
186+
* ng-click="addItem($index)">
187+
* Add
188+
* </a>
189+
* <a class="button button-small"
190+
* ng-click="items.splice($index, 1)">
191+
* Remove
192+
* </a>
193+
* </div>
194+
* </ion-item>
195+
*
196+
* </ion-list>
197+
* </ion-content>
198+
* </div>
199+
*
200+
* @css
201+
* .animated-item .item-note .button {
202+
* margin-top: 10px;
203+
* }
204+
* .animated-item {
205+
* line-height: 52px;
206+
* padding-top: 0;
207+
* padding-bottom: 0;
208+
* -webkit-transition: all 0.15s linear;
209+
* -moz-transition: all 0.15s linear;
210+
* transition: all 0.15s linear;
211+
* }
212+
* .animated-item.ng-leave.ng-leave-active,
213+
* .animated-item.ng-enter {
214+
* opacity: 0;
215+
* max-height: 0;
216+
* }
217+
* .animated-item.ng-leave,
218+
* .animated-item.ng-enter.ng-enter-active {
219+
* opacity: 1;
220+
* max-height: 52px;
221+
* }
222+
*/
75223
IonicModule
76224
.directive('ionList', [
77225
'$animate',

0 commit comments

Comments
 (0)