File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 6767 * submenuDirection: "right"
6868 * });
6969 *
70+ * Activation can be triggered from your own code via the API:
71+ *
72+ * $('#menu').menuAim('activate', elem);
73+ * $('#menu').menuAim('deactivateMenu');
74+ *
7075 * https://github.com/kamens/jQuery-menu-aim
7176*/
7277( function ( $ ) {
7378
7479 $ . fn . menuAim = function ( opts ) {
80+ var apiAction , apiArgs ;
81+ if ( typeof arguments [ 0 ] === 'string' ) {
82+ apiAction = arguments [ 0 ] ;
83+ apiArgs = Array . prototype . slice . apply ( arguments , [ 1 ] ) ;
84+ this . each ( function ( ) {
85+ $ ( this ) . data ( 'menuAim' ) [ apiAction ] . apply ( null , apiArgs ) ;
86+ } ) ;
87+ return this ;
88+ }
89+
7590 // Initialize menu-aim for all elements in jQuery collection
7691 this . each ( function ( ) {
7792 init . call ( this , opts ) ;
318333
319334 $ ( document ) . mousemove ( mousemoveDocument ) ;
320335
336+
337+ // API for external activation triggers
338+ $menu . data ( 'menuAim' , {
339+ activate : function ( elem ) {
340+ if ( ! $menu . find ( options . rowSelector ) . filter ( elem ) . length ) return ;
341+ activate ( elem ) ;
342+ } ,
343+ deactivateMenu : function ( ) {
344+ if ( timeoutId ) {
345+ clearTimeout ( timeoutId ) ;
346+ }
347+ if ( activeRow ) {
348+ options . deactivate ( activeRow ) ;
349+ }
350+ activeRow = null ;
351+ }
352+ } ) ;
321353 } ;
322354} ) ( jQuery ) ;
323355
You can’t perform that action at this time.
0 commit comments