removed link-item and onSelect

This commit is contained in:
Adam Bradley
2013-12-13 09:52:09 -06:00
parent 04d2d65d86
commit 48a58d9278
6 changed files with 22 additions and 211 deletions

5
dist/css/ionic.css vendored
View File

@@ -3857,6 +3857,11 @@ button.item.item-complex {
border: none;
background-color: white; }
a.item-content {
display: block;
text-decoration: none;
color: inherit; }
.item-text-wrap,
.item-text-wrap h1,
.item-text-wrap h2,

View File

@@ -814,18 +814,17 @@ angular.module('ionic.ui.list', ['ngAnimate'])
canDelete: '@',
canReorder: '@',
canSwipe: '@',
onSelect: '&',
onDelete: '&',
optionButtons: '&',
deleteIcon: '@',
reorderIcon: '@'
},
template: '<div class="item item-complex" ng-class="itemClass" ng-click="selectClick()">\
template: '<div class="item item-complex" ng-class="itemClass">\
<div class="item-edit" ng-if="deleteClick !== undefined">\
<button class="button button-icon icon" ng-class="deleteIconClass" ng-click="deleteClick()"></button>\
</div>\
<div class="item-content" ng-transclude></div>\
<a class="item-content" ng-href="{{ href }}" ng-transclude></a>\
<div class="item-drag" ng-if="reorderIconClass !== undefined">\
<button data-ionic-action="reorder" class="button button-icon icon" ng-class="reorderIconClass"></button>\
</div>\
@@ -840,104 +839,6 @@ angular.module('ionic.ui.list', ['ngAnimate'])
var $parentScope = list.scope;
var $parentAttrs = list.attrs;
// Set this item's class, first from the item directive attr, and then the list attr if item not set
$scope.itemClass = $scope.itemType || $parentScope.itemType;
// Decide if this item can do stuff, and follow a certain priority
// depending on where the value comes from
if(($attr.canDelete ? $scope.canDelete : $parentScope.canDelete) !== "false") {
if($attr.onDelete || $parentAttrs.onDelete) {
// only assign this method when we need to
// and use its existence to decide if the delete should show or not
$scope.deleteClick = function() {
if($attr.onDelete) {
// this item has an on-delete attribute
$scope.onDelete($scope.item);
} else if($parentAttrs.onDelete) {
// run the parent list's onDelete method
// if it doesn't exist nothing will happen
$parentScope.onDelete($scope.item);
}
};
// Set which icons to use for deleting
$scope.deleteIconClass = $scope.deleteIcon || $parentScope.deleteIcon || 'ion-minus-circled';
}
}
if($attr.onSelect || $parentAttrs.onSelect) {
// only assign this method when we need to
$scope.selectClick = function() {
if($attr.onSelect) {
// this item has an on-delete attribute
$scope.onSelect($scope.item);
} else if($parentAttrs.onSelect) {
// run the parent list's onDelete method
// if it doesn't exist nothing will happen
$parentScope.onSelect($scope.item);
}
};
}
// set the reorder Icon Class only if the item or list set can-reorder="true"
if(($attr.canReorder ? $scope.canReorder : $parentScope.canReorder) === "true") {
$scope.reorderIconClass = $scope.reorderIcon || $parentScope.reorderIcon || 'ion-navicon';
}
// Set the option buttons which can be revealed by swiping to the left
// if canSwipe was set to false don't even bother
if(($attr.canSwipe ? $scope.canSwipe : $parentScope.canSwipe) !== "false") {
$scope.itemOptionButtons = $scope.optionButtons();
if(typeof $scope.itemOptionButtons === "undefined") {
$scope.itemOptionButtons = $parentScope.optionButtons();
}
}
}
};
}])
.directive('linkItem', [function() {
return {
restrict: 'E',
require: '?^list',
replace: true,
transclude: true,
scope: {
item: '=',
itemType: '@',
canDelete: '@',
canReorder: '@',
canSwipe: '@',
onSelect: '&',
onDelete: '&',
optionButtons: '&',
deleteIcon: '@',
reorderIcon: '@',
href: '@'
},
template: '<a class="item item-complex" ng-class="itemClass" ng-href="{{ href }}" ng-click="onSelect()">\
<div class="item-edit" ng-if="deleteClick !== undefined">\
<button class="button button-icon icon" ng-class="deleteIconClass" ng-click="deleteClick()"></button>\
</div>\
<div class="item-content" ng-transclude></div>\
<div class="item-drag" ng-if="reorderIconClass !== undefined">\
<button data-ionic-action="reorder" class="button button-icon icon" ng-class="reorderIconClass"></button>\
</div>\
<div class="item-options" ng-if="itemOptionButtons">\
<button ng-click="b.onClick(item, b)" class="button" ng-class="b.type" ng-repeat="b in itemOptionButtons" ng-bind="b.text"></button>\
</div>\
</a>',
link: function($scope, $element, $attr, list) {
if(!list) return;
var $parentScope = list.scope;
var $parentAttrs = list.attrs;
$attr.$observe('href', function(value) {
if(value) $scope.href = value.trim();
});
@@ -955,11 +856,11 @@ angular.module('ionic.ui.list', ['ngAnimate'])
$scope.deleteClick = function() {
if($attr.onDelete) {
// this item has an on-delete attribute
$scope.onDelete($scope.item);
$scope.onDelete({ item: $scope.item });
} else if($parentAttrs.onDelete) {
// run the parent list's onDelete method
// if it doesn't exist nothing will happen
$parentScope.onDelete($scope.item);
$parentScope.onDelete({ item: $scope.item });
}
};
@@ -1003,7 +904,6 @@ angular.module('ionic.ui.list', ['ngAnimate'])
onRefresh: '&',
onRefreshOpening: '&',
refreshComplete: '=',
onSelect: '&',
onDelete: '&',
onReorder: '&',
optionButtons: '&',

View File

@@ -55,7 +55,7 @@
<content has-header="true">
<list>
<link-item ng-repeat="movie in movies" href="#/movie/{{movie.id}}" type="item-link">
<item ng-repeat="movie in movies" href="#/movie/{{movie.id}}" type="item-link">
{{ movie.title }}
</item>
</list>

View File

@@ -16,18 +16,17 @@ angular.module('ionic.ui.list', ['ngAnimate'])
canDelete: '@',
canReorder: '@',
canSwipe: '@',
onSelect: '&',
onDelete: '&',
optionButtons: '&',
deleteIcon: '@',
reorderIcon: '@'
},
template: '<div class="item item-complex" ng-class="itemClass" ng-click="selectClick()">\
template: '<div class="item item-complex" ng-class="itemClass">\
<div class="item-edit" ng-if="deleteClick !== undefined">\
<button class="button button-icon icon" ng-class="deleteIconClass" ng-click="deleteClick()"></button>\
</div>\
<div class="item-content" ng-transclude></div>\
<a class="item-content" ng-href="{{ href }}" ng-transclude></a>\
<div class="item-drag" ng-if="reorderIconClass !== undefined">\
<button data-ionic-action="reorder" class="button button-icon icon" ng-class="reorderIconClass"></button>\
</div>\
@@ -42,104 +41,6 @@ angular.module('ionic.ui.list', ['ngAnimate'])
var $parentScope = list.scope;
var $parentAttrs = list.attrs;
// Set this item's class, first from the item directive attr, and then the list attr if item not set
$scope.itemClass = $scope.itemType || $parentScope.itemType;
// Decide if this item can do stuff, and follow a certain priority
// depending on where the value comes from
if(($attr.canDelete ? $scope.canDelete : $parentScope.canDelete) !== "false") {
if($attr.onDelete || $parentAttrs.onDelete) {
// only assign this method when we need to
// and use its existence to decide if the delete should show or not
$scope.deleteClick = function() {
if($attr.onDelete) {
// this item has an on-delete attribute
$scope.onDelete($scope.item);
} else if($parentAttrs.onDelete) {
// run the parent list's onDelete method
// if it doesn't exist nothing will happen
$parentScope.onDelete($scope.item);
}
};
// Set which icons to use for deleting
$scope.deleteIconClass = $scope.deleteIcon || $parentScope.deleteIcon || 'ion-minus-circled';
}
}
if($attr.onSelect || $parentAttrs.onSelect) {
// only assign this method when we need to
$scope.selectClick = function() {
if($attr.onSelect) {
// this item has an on-delete attribute
$scope.onSelect($scope.item);
} else if($parentAttrs.onSelect) {
// run the parent list's onDelete method
// if it doesn't exist nothing will happen
$parentScope.onSelect($scope.item);
}
};
}
// set the reorder Icon Class only if the item or list set can-reorder="true"
if(($attr.canReorder ? $scope.canReorder : $parentScope.canReorder) === "true") {
$scope.reorderIconClass = $scope.reorderIcon || $parentScope.reorderIcon || 'ion-navicon';
}
// Set the option buttons which can be revealed by swiping to the left
// if canSwipe was set to false don't even bother
if(($attr.canSwipe ? $scope.canSwipe : $parentScope.canSwipe) !== "false") {
$scope.itemOptionButtons = $scope.optionButtons();
if(typeof $scope.itemOptionButtons === "undefined") {
$scope.itemOptionButtons = $parentScope.optionButtons();
}
}
}
};
}])
.directive('linkItem', [function() {
return {
restrict: 'E',
require: '?^list',
replace: true,
transclude: true,
scope: {
item: '=',
itemType: '@',
canDelete: '@',
canReorder: '@',
canSwipe: '@',
onSelect: '&',
onDelete: '&',
optionButtons: '&',
deleteIcon: '@',
reorderIcon: '@',
href: '@'
},
template: '<a class="item item-complex" ng-class="itemClass" ng-href="{{ href }}" ng-click="onSelect()">\
<div class="item-edit" ng-if="deleteClick !== undefined">\
<button class="button button-icon icon" ng-class="deleteIconClass" ng-click="deleteClick()"></button>\
</div>\
<div class="item-content" ng-transclude></div>\
<div class="item-drag" ng-if="reorderIconClass !== undefined">\
<button data-ionic-action="reorder" class="button button-icon icon" ng-class="reorderIconClass"></button>\
</div>\
<div class="item-options" ng-if="itemOptionButtons">\
<button ng-click="b.onClick(item, b)" class="button" ng-class="b.type" ng-repeat="b in itemOptionButtons" ng-bind="b.text"></button>\
</div>\
</a>',
link: function($scope, $element, $attr, list) {
if(!list) return;
var $parentScope = list.scope;
var $parentAttrs = list.attrs;
$attr.$observe('href', function(value) {
if(value) $scope.href = value.trim();
});
@@ -157,11 +58,11 @@ angular.module('ionic.ui.list', ['ngAnimate'])
$scope.deleteClick = function() {
if($attr.onDelete) {
// this item has an on-delete attribute
$scope.onDelete($scope.item);
$scope.onDelete({ item: $scope.item });
} else if($parentAttrs.onDelete) {
// run the parent list's onDelete method
// if it doesn't exist nothing will happen
$parentScope.onDelete($scope.item);
$parentScope.onDelete({ item: $scope.item });
}
};
@@ -205,7 +106,6 @@ angular.module('ionic.ui.list', ['ngAnimate'])
onRefresh: '&',
onRefreshOpening: '&',
refreshComplete: '=',
onSelect: '&',
onDelete: '&',
onReorder: '&',
optionButtons: '&',

View File

@@ -65,7 +65,7 @@
on-refresh-opening="refreshOpening(ratio)"
on-refresh="refreshItems()"
refresh-complete="refreshComplete"
on-delete="deleteListItem()"
on-delete="deleteListItem(item)"
delete-icon="ion-minus-circled"
reorder-icon="ion-navicon"
animation="my-repeat-animation"
@@ -98,7 +98,7 @@
</item>
<!-- shows that the item directive can receive many attributes and overrides the list attributes -->
<item on-delete="deleteItem()"
<item on-delete="deleteItem(item)"
delete-icon="ion-trash-a"
reorder-icon="ion-navicon-round"
can-delete="true"

View File

@@ -189,6 +189,12 @@ button.item.item-complex {
background-color: white;
}
a.item-content {
display: block;
text-decoration: none;
color: inherit;
}
.item-text-wrap,
.item-text-wrap h1,
.item-text-wrap h2,