From 82ba734a73d4e6d286b87afd41d6284ffd046541 Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Thu, 10 Oct 2013 16:29:35 -0500 Subject: [PATCH] Delete item works --- dist/ionic-angular.js | 8 +++++++- dist/ionic.js | 25 ++++++++--------------- js/ext/angular/src/directive/ionicList.js | 8 +++++++- js/ext/angular/test/list.html | 4 ++++ js/views/listView.js | 25 ++++++++--------------- 5 files changed, 34 insertions(+), 36 deletions(-) diff --git a/dist/ionic-angular.js b/dist/ionic-angular.js index 4c931ec782..97cd69c23c 100644 --- a/dist/ionic-angular.js +++ b/dist/ionic-angular.js @@ -189,7 +189,7 @@ angular.module('ionic.ui.list', ['ionic.service', 'ngAnimate']) transclude: true, template: '
  • ' + '
    ' + - ' ' + + ' ' + '
    ' + '
    ' + '
    ' + @@ -198,9 +198,15 @@ angular.module('ionic.ui.list', ['ionic.service', 'ngAnimate']) ' ' + '
  • ', link: function($scope, $element, $attr) { + // Triggered when a button is clicked $scope.buttonClicked = function(button) { button.buttonClicked && button.buttonClicked($scope.item); } + + // Triggered when the delete item is clicked + $scope.deleteClicked = function() { + $scope.item.deleteItem && $scope.item.deleteItem(); + } } } }) diff --git a/dist/ionic.js b/dist/ionic.js index 80a2fa309f..dcdb2905fa 100644 --- a/dist/ionic.js +++ b/dist/ionic.js @@ -1780,41 +1780,32 @@ window.ionic = { ; (function(ionic) { + /** + * The ListView handles a list of items. It will process drag animations, edit mode, + * and other operations that are common on mobile lists or table views. + */ ionic.views.List = function(opts) { var _this = this; this.el = opts.el; - this.dragThresholdX = 10; + // The amount of dragging required to start sliding the element over (in pixels) + this.dragThresholdX = opts.dragThresholdX || 10; + // Start the drag states this._initDrag(); + // Listen for drag and release events window.ionic.onGesture('drag', function(e) { _this._handleDrag(e); }, this.el); window.ionic.onGesture('release', function(e) { _this._handleEndDrag(e); }, this.el); - - /* - window.ionic.onGesture('swipeleft', function(e) { - _this._handleSwipeLeft(e); - e.gesture.stopDetect(); - return false; - }, this.el); - - window.ionic.onGesture('swiperight', function(e) { - _this._handleSwipeRight(e); - e.gesture.stopDetect(); - return false; - }, this.el); - */ }; ionic.views.List.prototype = { _initDrag: function() { - this._offsetX = 0; - this._deltaSlowX = null; this._isDragging = false; this._currentDrag = null; }, diff --git a/js/ext/angular/src/directive/ionicList.js b/js/ext/angular/src/directive/ionicList.js index bbc780579d..4f7667e635 100644 --- a/js/ext/angular/src/directive/ionicList.js +++ b/js/ext/angular/src/directive/ionicList.js @@ -7,7 +7,7 @@ angular.module('ionic.ui.list', ['ionic.service', 'ngAnimate']) transclude: true, template: '
  • ' + '
    ' + - ' ' + + ' ' + '
    ' + '
    ' + '
    ' + @@ -16,9 +16,15 @@ angular.module('ionic.ui.list', ['ionic.service', 'ngAnimate']) ' ' + '
  • ', link: function($scope, $element, $attr) { + // Triggered when a button is clicked $scope.buttonClicked = function(button) { button.buttonClicked && button.buttonClicked($scope.item); } + + // Triggered when the delete item is clicked + $scope.deleteClicked = function() { + $scope.item.deleteItem && $scope.item.deleteItem(); + } } } }) diff --git a/js/ext/angular/test/list.html b/js/ext/angular/test/list.html index 6586e6d36d..f5a3d1aad6 100644 --- a/js/ext/angular/test/list.html +++ b/js/ext/angular/test/list.html @@ -104,6 +104,7 @@ canSwipe: true, icon: 'icon-chevron-right', hide: false, + deleteItem: removeItem, buttons: [{ text: 'Kill', type: 'button-danger', @@ -115,6 +116,7 @@ canDelete: true, canSwipe: true, icon: 'icon-chevron-right', + deleteItem: removeItem, buttons: [{ text: 'Kill', type: 'button-danger', @@ -126,6 +128,7 @@ canDelete: true, canSwipe: true, icon: 'icon-chevron-right', + deleteItem: removeItem, buttons: [{ text: 'Kill', type: 'button-danger', @@ -137,6 +140,7 @@ canDelete: true, canSwipe: true, icon: 'icon-chevron-right', + deleteItem: removeItem, buttons: [{ text: 'Kill', type: 'button-danger', diff --git a/js/views/listView.js b/js/views/listView.js index 0ec7e13cd4..e8ce24cfb7 100644 --- a/js/views/listView.js +++ b/js/views/listView.js @@ -1,40 +1,31 @@ (function(ionic) { + /** + * The ListView handles a list of items. It will process drag animations, edit mode, + * and other operations that are common on mobile lists or table views. + */ ionic.views.List = function(opts) { var _this = this; this.el = opts.el; - this.dragThresholdX = 10; + // The amount of dragging required to start sliding the element over (in pixels) + this.dragThresholdX = opts.dragThresholdX || 10; + // Start the drag states this._initDrag(); + // Listen for drag and release events window.ionic.onGesture('drag', function(e) { _this._handleDrag(e); }, this.el); window.ionic.onGesture('release', function(e) { _this._handleEndDrag(e); }, this.el); - - /* - window.ionic.onGesture('swipeleft', function(e) { - _this._handleSwipeLeft(e); - e.gesture.stopDetect(); - return false; - }, this.el); - - window.ionic.onGesture('swiperight', function(e) { - _this._handleSwipeRight(e); - e.gesture.stopDetect(); - return false; - }, this.el); - */ }; ionic.views.List.prototype = { _initDrag: function() { - this._offsetX = 0; - this._deltaSlowX = null; this._isDragging = false; this._currentDrag = null; },