1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
<script>
$(function(){
/**************************************************
* Custom Command Handler
**************************************************/
$.contextMenu.types.label = function(item, opt, root) {
// this === item.$node
$('<span>Codes couleur</span><ul>'
<?php
$nblabel = 1;
while($r = mysql_fetch_array($req))
{
?>
+ '<li class="label<?php echo $nblabel; ?>" id="<?php echo $r['id']; ?>" title="<?php echo $r['code']; ?>"><?php echo $r['code']; ?></li>'
<?php
$nblabel = $nblabel+1;
}
?>
+ '</ul>')
.appendTo(this)
.on('click', 'li', function() {
// do some funky stuff
//console.log('Clicked on ' + $(this).text());
var idcode = $(this).closest('li').attr("id");
var idinter = $(root).closest('tr').attr("id");
alert(idinter);
// hide the menu
root.$menu.trigger('contextmenu:hide');
});
this.addClass('labels').on('contextmenu:focus', function(e) {
// setup some awesome stuff
}).on('contextmenu:blur', function(e) {
// tear down whatever you did
}).on('keydown', function(e) {
// some funky key handling, maybe?
});
};
/**************************************************
* Context-Menu with custom command "label"
**************************************************/
$.contextMenu({
selector: '.context-menu-intervention',
callback: function(key, options) {
var id = $(this).closest('tr').attr("id");
var triecode = $(this).closest('tr').attr("data-triecode");alert(code);
var affichage_interventions = $(this).closest('tr').attr("data-affichage_interventions");
var m = "clicked: " + key;
//window.console && console.log(m) || alert(m);
},
items: {
open: {name: "Open", callback: $.noop},
label: {type: "label", customName: "Label", opt: "test"},
edit: {name: "Edit", callback: $.noop}
}
});
});
</script> |
Partager