mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-13 21:13:26 +00:00
118 lines
4.0 KiB
HTML
118 lines
4.0 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
|
<html>
|
|
<head>
|
|
|
|
|
|
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
|
<title>Context Menu Integration</title>
|
|
|
|
<style type="text/css">
|
|
/*margin and padding on body element
|
|
can introduce errors in determining
|
|
element position and are not recommended;
|
|
we turn them off as a foundation for YUI
|
|
CSS treatments. */
|
|
body {
|
|
margin:0;
|
|
padding:0;
|
|
}
|
|
</style>
|
|
|
|
<link rel="stylesheet" type="text/css" href="../../build/fonts/fonts-min.css" />
|
|
<link rel="stylesheet" type="text/css" href="../../build/menu/assets/skins/sam/menu.css" />
|
|
<link rel="stylesheet" type="text/css" href="../../build/datatable/assets/skins/sam/datatable.css" />
|
|
<script type="text/javascript" src="../../build/yahoo-dom-event/yahoo-dom-event.js"></script>
|
|
<script type="text/javascript" src="../../build/container/container_core-min.js"></script>
|
|
<script type="text/javascript" src="../../build/menu/menu-min.js"></script>
|
|
<script type="text/javascript" src="../../build/element/element-min.js"></script>
|
|
<script type="text/javascript" src="../../build/datasource/datasource-min.js"></script>
|
|
<script type="text/javascript" src="../../build/datatable/datatable-min.js"></script>
|
|
|
|
|
|
<!--begin custom header content for this example-->
|
|
<style type="text/css">
|
|
div.yuimenu .bd {
|
|
zoom: normal;
|
|
}
|
|
</style>
|
|
|
|
<!--end custom header content for this example-->
|
|
|
|
</head>
|
|
|
|
<body class="yui-skin-sam">
|
|
|
|
|
|
<h1>Context Menu Integration</h1>
|
|
|
|
<div class="exampleIntro">
|
|
<p>Right-click on a row to see the ContextMenu integration in action. For more
|
|
information on using the ContextMenu class please refer to the
|
|
<a href="http://developer.yahoo.com/yui/menu/">documentation for the Menu control.</a></p>
|
|
|
|
</div>
|
|
|
|
<!--BEGIN SOURCE CODE FOR EXAMPLE =============================== -->
|
|
|
|
<div id="myContainer"></div>
|
|
|
|
<script type="text/javascript" src="assets/js/data.js"></script>
|
|
<script type="text/javascript">
|
|
YAHOO.util.Event.addListener(window, "load", function() {
|
|
YAHOO.example.ContextMenu = function() {
|
|
var myColumnDefs = [
|
|
{key:"SKU", sortable:true},
|
|
{key:"Quantity", sortable:true},
|
|
{key:"Item", sortable:true},
|
|
{key:"Description"}
|
|
];
|
|
|
|
var myDataSource = new YAHOO.util.DataSource(YAHOO.example.Data.inventory);
|
|
myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
|
|
myDataSource.responseSchema = {
|
|
fields: ["SKU","Quantity","Item","Description"]
|
|
};
|
|
|
|
var myDataTable = new YAHOO.widget.DataTable("myContainer", myColumnDefs, myDataSource);
|
|
|
|
var onContextMenuClick = function(p_sType, p_aArgs, p_myDataTable) {
|
|
var task = p_aArgs[1];
|
|
if(task) {
|
|
// Extract which TR element triggered the context menu
|
|
var elRow = this.contextEventTarget;
|
|
elRow = p_myDataTable.getTrEl(elRow);
|
|
|
|
if(elRow) {
|
|
switch(task.index) {
|
|
case 0: // Delete row upon confirmation
|
|
var oRecord = p_myDataTable.getRecord(elRow);
|
|
if(confirm("Are you sure you want to delete SKU " +
|
|
oRecord.getData("SKU") + " (" +
|
|
oRecord.getData("Description") + ")?")) {
|
|
p_myDataTable.deleteRow(elRow);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
var myContextMenu = new YAHOO.widget.ContextMenu("mycontextmenu",
|
|
{trigger:myDataTable.getTbodyEl()});
|
|
myContextMenu.addItem("Delete Item");
|
|
// Render the ContextMenu instance to the parent container of the DataTable
|
|
myContextMenu.render("myContainer");
|
|
myContextMenu.clickEvent.subscribe(onContextMenuClick, myDataTable);
|
|
|
|
return {
|
|
oDS: myDataSource,
|
|
oDT: myDataTable
|
|
};
|
|
}();
|
|
});
|
|
</script>
|
|
|
|
<!--END SOURCE CODE FOR EXAMPLE =============================== -->
|
|
|
|
</body>
|
|
</html>
|