1
1
angular . module ( 'ui.bootstrap.contextMenu' , [ ] )
2
2
3
3
. directive ( 'contextMenu' , [ "$parse" , function ( $parse ) {
4
- var renderContextMenu = function ( $scope , event , options , tag ) {
4
+ var renderContextMenu = function ( $scope , event , options , model ) {
5
5
if ( ! $ ) { var $ = angular . element ; }
6
6
$ ( event . currentTarget ) . addClass ( 'context' ) ;
7
7
var $contextMenu = $ ( '<div>' ) ;
@@ -25,18 +25,18 @@ angular.module('ui.bootstrap.contextMenu', [])
25
25
var text = typeof item [ 0 ] == 'string' ? item [ 0 ] : item [ 0 ] . call ( $scope , $scope , event ) ;
26
26
$a . text ( text ) ;
27
27
$li . append ( $a ) ;
28
- var enabled = angular . isDefined ( item [ 2 ] ) ? item [ 2 ] . call ( $scope , $scope , event , text , tag ) : true ;
29
- if ( enabled ) {
30
- $li . on ( 'click' , function ( $event ) {
28
+ var enabled = angular . isDefined ( item [ 2 ] ) ? item [ 2 ] . call ( $scope , $scope , event , text , model ) : true ;
29
+ if ( enabled ) {
30
+ $li . on ( 'click' , function ( $event ) {
31
31
$event . preventDefault ( ) ;
32
- $scope . $apply ( function ( ) {
33
- $ ( event . currentTarget ) . removeClass ( 'context' ) ;
32
+ $scope . $apply ( function ( ) {
33
+ $ ( event . currentTarget ) . removeClass ( 'context' ) ;
34
34
$contextMenu . remove ( ) ;
35
- item [ 1 ] . call ( $scope , $scope , event , tag ) ;
36
- } ) ;
37
- } ) ;
35
+ item [ 1 ] . call ( $scope , $scope , event , model ) ;
36
+ } ) ;
37
+ } ) ;
38
38
} else {
39
- $li . on ( 'click' , function ( $event ) {
39
+ $li . on ( 'click' , function ( $event ) {
40
40
$event . preventDefault ( ) ;
41
41
} ) ;
42
42
$li . addClass ( 'disabled' ) ;
@@ -75,10 +75,10 @@ angular.module('ui.bootstrap.contextMenu', [])
75
75
$scope . $apply ( function ( ) {
76
76
event . preventDefault ( ) ;
77
77
var options = $scope . $eval ( attrs . contextMenu ) ;
78
- var tag = $scope . $eval ( attrs . contextMenuTag ) ;
78
+ var model = $scope . $eval ( attrs . model ) ;
79
79
if ( options instanceof Array ) {
80
80
if ( options . length === 0 ) { return ; }
81
- renderContextMenu ( $scope , event , options , tag ) ;
81
+ renderContextMenu ( $scope , event , options , model ) ;
82
82
} else {
83
83
throw '"' + attrs . contextMenu + '" not an array' ;
84
84
}
0 commit comments