var ITEM_TPL_OPTION_BUTTONS = ''; /** * @ngdoc directive * @name ionOptionButton * @parent ionic.directive:ionItem * @module ionic * @restrict E * Creates an option button inside a list item, that is visible when the item is swiped * to the left by the user. Swiped open option buttons can be hidden with * {@link ionic.service:$ionicListDelegate#closeOptionButtons $ionicListDelegate#closeOptionButtons}. * * Can be assigned any button class. * * See {@link ionic.directive:ionList} for a complete example & explanation. * * @usage * * ```html * * * I love kittens! * Share * Edit * * * ``` */ IonicModule .directive('ionOptionButton', ['$compile', function($compile) { 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); }; } }; }]);