Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | espaco | 1 | var ComponentsContextMenu = function () { |
| 2 | |||
| 3 | var demo2 = function() { |
||
| 4 | $('#main').contextmenu({ |
||
| 5 | target: '#context-menu2', |
||
| 6 | before: function (e) { |
||
| 7 | // This function is optional. |
||
| 8 | // Here we use it to stop the event if the user clicks a span |
||
| 9 | e.preventDefault(); |
||
| 10 | if (e.target.tagName == 'SPAN') { |
||
| 11 | e.preventDefault(); |
||
| 12 | this.closemenu(); |
||
| 13 | return false; |
||
| 14 | } |
||
| 15 | //this.getMenu().find("li").eq(2).find('a').html("Dynamically changed!"); |
||
| 16 | return true; |
||
| 17 | } |
||
| 18 | }); |
||
| 19 | } |
||
| 20 | |||
| 21 | var demo3 = function() { |
||
| 22 | // Demo 3 |
||
| 23 | $('#context2').contextmenu({ |
||
| 24 | target: '#context-menu2', |
||
| 25 | onItem: function (context, e) { |
||
| 26 | alert($(e.target).text()); |
||
| 27 | } |
||
| 28 | }); |
||
| 29 | |||
| 30 | $('#context-menu2').on('show.bs.context', function (e) { |
||
| 31 | console.log('before show event'); |
||
| 32 | }); |
||
| 33 | |||
| 34 | $('#context-menu2').on('shown.bs.context', function (e) { |
||
| 35 | console.log('after show event'); |
||
| 36 | }); |
||
| 37 | |||
| 38 | $('#context-menu2').on('hide.bs.context', function (e) { |
||
| 39 | console.log('before hide event'); |
||
| 40 | }); |
||
| 41 | |||
| 42 | $('#context-menu2').on('hidden.bs.context', function (e) { |
||
| 43 | console.log('after hide event'); |
||
| 44 | }); |
||
| 45 | } |
||
| 46 | |||
| 47 | return { |
||
| 48 | //main function to initiate the module |
||
| 49 | |||
| 50 | init: function () { |
||
| 51 | demo2(); |
||
| 52 | demo3(); |
||
| 53 | } |
||
| 54 | |||
| 55 | }; |
||
| 56 | |||
| 57 | }(); |