From 2ffb925a97c0473598cab9b4e64961d068e61014 Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Mon, 11 Nov 2013 16:09:46 -0600 Subject: [PATCH] Add list item type to directive --- dist/js/ionic-angular.js | 28 +++++++++-------------- js/ext/angular/src/directive/ionicList.js | 28 +++++++++-------------- js/ext/angular/test/list.html | 6 +++-- js/ext/angular/test/tabs.html | 4 ++-- test/lists.html | 4 +++- 5 files changed, 31 insertions(+), 39 deletions(-) diff --git a/dist/js/ionic-angular.js b/dist/js/ionic-angular.js index 5a9635369a..2b3ebcfe71 100644 --- a/dist/js/ionic-angular.js +++ b/dist/js/ionic-angular.js @@ -560,10 +560,10 @@ angular.module('ionic.ui.content', []) angular.module('ionic.ui.list', ['ngAnimate']) -.directive('listItem', ['$timeout', function($timeout) { +.directive('item', ['$timeout', function($timeout) { return { restrict: 'E', - require: ['?^list', '?^virtualList'], + require: ['?^list'], replace: true, transclude: true, scope: { @@ -574,8 +574,9 @@ angular.module('ionic.ui.list', ['ngAnimate']) canReorder: '@', canSwipe: '@', buttons: '=', + type: '@' }, - template: '\ + template: '\
\ \
\ @@ -589,20 +590,6 @@ angular.module('ionic.ui.list', ['ngAnimate']) \
', - /* - template: '
  • \ -
    \ - \ -
    \ -
    \ -
    \ -
    \ - \ -
    \ -
    \ - \ -
    \ -
  • ',*/ link: function($scope, $element, $attr, list) { // Grab the parent list controller if(list[0]) { @@ -611,6 +598,13 @@ angular.module('ionic.ui.list', ['ngAnimate']) list = list[1]; } + // Add the list item type class + $element.addClass($attr.type || 'item-slider'); + + if($attr.type !== 'item-slider') { + $scope.canSwipe = false; + } + $scope.isEditing = false; $scope.deleteIcon = list.scope.deleteIcon; $scope.reorderIcon = list.scope.reorderIcon; diff --git a/js/ext/angular/src/directive/ionicList.js b/js/ext/angular/src/directive/ionicList.js index c5fd09d2ec..2dbbf3bbfe 100644 --- a/js/ext/angular/src/directive/ionicList.js +++ b/js/ext/angular/src/directive/ionicList.js @@ -3,10 +3,10 @@ angular.module('ionic.ui.list', ['ngAnimate']) -.directive('listItem', ['$timeout', function($timeout) { +.directive('item', ['$timeout', function($timeout) { return { restrict: 'E', - require: ['?^list', '?^virtualList'], + require: ['?^list'], replace: true, transclude: true, scope: { @@ -17,8 +17,9 @@ angular.module('ionic.ui.list', ['ngAnimate']) canReorder: '@', canSwipe: '@', buttons: '=', + type: '@' }, - template: '\ + template: '\
    \ \
    \ @@ -32,20 +33,6 @@ angular.module('ionic.ui.list', ['ngAnimate']) \
    ', - /* - template: '
  • \ -
    \ - \ -
    \ -
    \ -
    \ -
    \ - \ -
    \ -
    \ - \ -
    \ -
  • ',*/ link: function($scope, $element, $attr, list) { // Grab the parent list controller if(list[0]) { @@ -54,6 +41,13 @@ angular.module('ionic.ui.list', ['ngAnimate']) list = list[1]; } + // Add the list item type class + $element.addClass($attr.type || 'item-slider'); + + if($attr.type !== 'item-slider') { + $scope.canSwipe = false; + } + $scope.isEditing = false; $scope.deleteIcon = list.scope.deleteIcon; $scope.reorderIcon = list.scope.reorderIcon; diff --git a/js/ext/angular/test/list.html b/js/ext/angular/test/list.html index acf6b55c85..4ba5bb714a 100644 --- a/js/ext/angular/test/list.html +++ b/js/ext/angular/test/list.html @@ -67,16 +67,18 @@ - + {{item.text}} - + diff --git a/js/ext/angular/test/tabs.html b/js/ext/angular/test/tabs.html index f7fde31dc3..1e726f0e24 100644 --- a/js/ext/angular/test/tabs.html +++ b/js/ext/angular/test/tabs.html @@ -60,7 +60,7 @@

    Tasks

    - +
    @@ -68,7 +68,7 @@
    -
    -
    +
    @@ -500,6 +500,8 @@ return false; }); + +