1
- ( function ( f ) { if ( typeof exports === "object" && typeof module !== "undefined" ) { module . exports = f ( ) } else if ( typeof define === "function" && define . amd ) { define ( [ ] , f ) } else { var g ; if ( typeof window !== "undefined" ) { g = window } else if ( typeof global !== "undefined" ) { g = global } else if ( typeof self !== "undefined" ) { g = self } else { g = this } g . ngContextmenu = f ( ) } } ) ( function ( ) { var define , module , exports ; return ( function e ( t , n , r ) { function s ( o , u ) { if ( ! n [ o ] ) { if ( ! t [ o ] ) { var a = typeof require == "function" && require ; if ( ! u && a ) return a ( o , ! 0 ) ; if ( i ) return i ( o , ! 0 ) ; var f = new Error ( "Cannot find module '" + o + "'" ) ; throw f . code = "MODULE_NOT_FOUND" , f } var l = n [ o ] = { exports :{ } } ; t [ o ] [ 0 ] . call ( l . exports , function ( e ) { var n = t [ o ] [ 1 ] [ e ] ; return s ( n ?n :e ) } , l , l . exports , e , t , n , r ) } return n [ o ] . exports } var i = typeof require == "function" && require ; for ( var o = 0 ; o < r . length ; o ++ ) s ( r [ o ] ) ; return s } ) ( { 1 :[ function ( _dereq_ , module , exports ) {
1
+ ( function e ( t , n , r ) { function s ( o , u ) { if ( ! n [ o ] ) { if ( ! t [ o ] ) { var a = typeof require == "function" && require ; if ( ! u && a ) return a ( o , ! 0 ) ; if ( i ) return i ( o , ! 0 ) ; var f = new Error ( "Cannot find module '" + o + "'" ) ; throw f . code = "MODULE_NOT_FOUND" , f } var l = n [ o ] = { exports :{ } } ; t [ o ] [ 0 ] . call ( l . exports , function ( e ) { var n = t [ o ] [ 1 ] [ e ] ; return s ( n ?n :e ) } , l , l . exports , e , t , n , r ) } return n [ o ] . exports } var i = typeof require == "function" && require ; for ( var o = 0 ; o < r . length ; o ++ ) s ( r [ o ] ) ; return s } ) ( { 1 :[ function ( require , module , exports ) {
2
2
'use strict' ;
3
3
4
4
angular . module ( 'io.dennis.contextmenu' )
@@ -24,7 +24,7 @@ function ContainerCtrl($scope) {
24
24
}
25
25
}
26
26
27
- } , { } ] , 2 :[ function ( _dereq_ , module , exports ) {
27
+ } , { } ] , 2 :[ function ( require , module , exports ) {
28
28
'use strict' ;
29
29
30
30
angular . module ( 'io.dennis.contextmenu' )
@@ -86,22 +86,20 @@ function Contextmenu($window, $rootScope, $contextmenu) {
86
86
contextmenu : '='
87
87
} ,
88
88
restrict : 'A' ,
89
- controller : [ '$scope' , '$window' , '$rootScope' , CotextmenuCtrl ] ,
89
+ controller : CotextmenuCtrl ,
90
90
link : link ,
91
91
priority : 100
92
92
} ;
93
93
94
-
95
94
function link ( scope , element , attrs , ctrl ) {
96
95
scope . contextmenu = $contextmenu . $get ( ) ;
97
96
scope . contextmenu . setMenu ( ctrl ) ;
98
97
ctrl . setElement ( element ) ;
99
98
}
100
99
}
101
100
102
- function CotextmenuCtrl ( $scope , $window , $rootScope ) {
103
- console . log ( 'init contextmenu ctrl' ) ;
104
-
101
+ CotextmenuCtrl . $inject = [ '$scope' , '$window' , '$rootScope' , '$timeout' ] ;
102
+ function CotextmenuCtrl ( $scope , $window , $rootScope , $timeout ) {
105
103
var pub = this ;
106
104
var $element ;
107
105
$scope . $on ( 'contextmenu.close' , close ) ;
@@ -112,10 +110,25 @@ function CotextmenuCtrl($scope, $window, $rootScope) {
112
110
113
111
function open ( item , x , y ) {
114
112
broadcastClose ( ) ;
115
- $element . css ( { top : y , left : x } )
116
- . toggleClass ( 'dropup' , isDropup ( y ) )
113
+
114
+ $element
117
115
. toggleClass ( 'open' , true )
116
+ . toggleClass ( 'dropup' , isDropup ( y ) )
117
+ . css ( 'visibility' , 'hidden' )
118
118
. toggleClass ( 'ng-hide' , false ) ;
119
+
120
+ $timeout ( function ( ) {
121
+ var width = $element . children ( ) . width ( ) ;
122
+
123
+ x = ( x + width > $window . innerWidth ) ?
124
+ $window . innerWidth - ( width + 5 ) : x ;
125
+
126
+ $element . css ( {
127
+ top : y + 'px' ,
128
+ left : x + 'px' ,
129
+ visibility : 'visible'
130
+ } ) ;
131
+ } ) ;
119
132
}
120
133
121
134
function close ( ) {
@@ -132,7 +145,7 @@ function CotextmenuCtrl($scope, $window, $rootScope) {
132
145
}
133
146
}
134
147
135
- } , { } ] , 3 :[ function ( _dereq_ , module , exports ) {
148
+ } , { } ] , 3 :[ function ( require , module , exports ) {
136
149
'use strict' ;
137
150
138
151
angular . module ( 'io.dennis.contextmenu' )
@@ -204,18 +217,18 @@ function Item() {
204
217
205
218
}
206
219
207
- } , { } ] , 4 :[ function ( _dereq_ , module , exports ) {
220
+ } , { } ] , 4 :[ function ( require , module , exports ) {
208
221
'use strict' ;
209
222
210
223
angular . module ( 'io.dennis.contextmenu' , [ ] ) ;
211
224
212
- _dereq_ ( './service/service' ) ;
225
+ require ( './service/service' ) ;
213
226
214
- _dereq_ ( './directive/contextmenu' ) ;
215
- _dereq_ ( './directive/container' ) ;
216
- _dereq_ ( './directive/item' ) ;
227
+ require ( './directive/contextmenu' ) ;
228
+ require ( './directive/container' ) ;
229
+ require ( './directive/item' ) ;
217
230
218
- } , { "./directive/container" :1 , "./directive/contextmenu" :2 , "./directive/item" :3 , "./service/service" :5 } ] , 5 :[ function ( _dereq_ , module , exports ) {
231
+ } , { "./directive/container" :1 , "./directive/contextmenu" :2 , "./directive/item" :3 , "./service/service" :5 } ] , 5 :[ function ( require , module , exports ) {
219
232
'use strict' ;
220
233
221
234
angular . module ( 'io.dennis.contextmenu' )
@@ -352,5 +365,4 @@ function Contextmenu() {
352
365
}
353
366
}
354
367
355
- } , { } ] } , { } , [ 4 ] ) ( 4 )
356
- } ) ;
368
+ } , { } ] } , { } , [ 4 ] ) ;
0 commit comments