Skip to content

Commit

Permalink
chore(ionList): clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
ajoslin committed May 15, 2014
1 parent 09d1197 commit 462ef38
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
36 changes: 20 additions & 16 deletions js/angular/directive/itemOptionButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,25 @@ var ITEM_TPL_OPTION_BUTTONS =
*/
IonicModule
.directive('ionOptionButton', ['$compile', function($compile) {
return {
restrict: 'E',
require: '^ionItem',
priority: Number.MAX_VALUE,
compile: function($element, $attr) {
$attr.$set('class', ($attr['class'] || '') + ' button', true);
return function($scope, $element, $attr, itemCtrl) {
if (!itemCtrl.optionsContainer) {
itemCtrl.optionsContainer = jqLite(ITEM_TPL_OPTION_BUTTONS);
itemCtrl.$element.append(itemCtrl.optionsContainer);
}
itemCtrl.optionsContainer.append($element);

$element.on('click', eventStopPropagation);
};
function stopPropagation(e) {
e.stopPropagation();
}
};
return {
restrict: 'E',
require: '^ionItem',
priority: Number.MAX_VALUE,
compile: function($element, $attr) {
$attr.$set('class', ($attr['class'] || '') + ' button', true);
return function($scope, $element, $attr, itemCtrl) {
if (!itemCtrl.optionsContainer) {
itemCtrl.optionsContainer = jqLite(ITEM_TPL_OPTION_BUTTONS);
itemCtrl.$element.append(itemCtrl.optionsContainer);
}
itemCtrl.optionsContainer.append($element);

//Don't bubble click up to main .item
$element.on('click', stopPropagation);
};
}
};
}]);
4 changes: 2 additions & 2 deletions js/angular/directive/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@
*/
IonicModule
.directive('ionList', [
'$animate',
'$timeout',
'$animate',
'$timeout',
function($animate, $timeout) {
return {
restrict: 'E',
Expand Down

0 comments on commit 462ef38

Please sign in to comment.