diff --git a/js/ext/angular/src/directive/ionicList.js b/js/ext/angular/src/directive/ionicList.js index 628dd79334..35d058132d 100644 --- a/js/ext/angular/src/directive/ionicList.js +++ b/js/ext/angular/src/directive/ionicList.js @@ -3,6 +3,82 @@ angular.module('ionic.ui.list', ['ngAnimate']) +.directive('linkItem', ['$timeout', function($timeout) { + return { + restrict: 'E', + require: ['?^list'], + replace: true, + transclude: true, + scope: { + item: '=', + onSelect: '&', + onDelete: '&', + canDelete: '@', + canReorder: '@', + canSwipe: '@', + buttons: '=', + type: '@', + href: '@' + }, + template: '\ +
\ + \ +
\ +
\ +
\ +
\ + \ +
\ +
\ + \ +
\ +
', + + link: function($scope, $element, $attr, list) { + // Grab the parent list controller + if(list[0]) { + list = list[0]; + } else if(list[1]) { + list = list[1]; + } + + $attr.$observe('href', function(value) { + $scope.href = value; + }); + + // Add the list item type class + $element.addClass($attr.type || 'item-complex'); + + if($attr.type !== 'item-complex') { + $scope.canSwipe = false; + } + + $scope.isEditing = false; + $scope.deleteIcon = list.scope.deleteIcon; + $scope.reorderIcon = list.scope.reorderIcon; + $scope.showOptions = true; + + $scope.buttonClicked = function(button) { + button.onButtonClicked && button.onButtonClicked($scope.item, button); + }; + + list.scope.$watch('isEditing', function(v) { + $scope.isEditing = v; + + // Add a delay before we allow the options layer to show, to avoid any odd + // animation issues + if(!v) { + $timeout(function() { + $scope.showOptions = true; + }, 200); + } else { + $scope.showOptions = false; + } + }); + } + }; +}]) + .directive('item', ['$timeout', function($timeout) { return { restrict: 'E', @@ -17,7 +93,7 @@ angular.module('ionic.ui.list', ['ngAnimate']) canReorder: '@', canSwipe: '@', buttons: '=', - type: '@' + type: '@', }, template: '
  • \
    \