egroupware/phpgwapi/js/egw_action/test/test_grid.html

176 lines
4.1 KiB
HTML
Raw Normal View History

<html>
<head>
<title>Grid Test</title>
<!-- Basic action stuff -->
<script src="../egw_action.js"></script>
<script src="../egw_action_common.js"></script>
<!-- Grid stuff -->
<script src="../egw_grid.js"></script>
<script src="js/jquery.js"></script>
<link rel="stylesheet" href="grid.css"/>
<!-- Popup stuff -->
<link rel="stylesheet" type="text/css" href="skins/dhtmlxmenu_egw.css">
<script src="js/dhtmlxcommon.js"></script>
<script src="js/dhtmlxmenu.js"></script>
<script src="js/dhtmlxmenu_ext.js"></script>
<script src="../egw_action_popup.js"></script>
<script src="../egw_menu.js"></script>
<script src="../egw_menu_dhtmlx.js"></script>
</head>
<body>
<div id="container">
</div>
<script>
var grid = null;
var actionManager = null;
var objectManager = null;
function alertClicked(_action, _senders)
{
var ids = "";
for (var i = 0; i < _senders.length; i++)
ids += _senders[i].id + ((i < _senders.length - 1) ? ", " : "");
alert("Action '" + _action.caption + "' executed on elements '"
+ ids + "'");
}
$(document).ready(function() {
actionManager = new egwActionManager();
actionManager.updateActions(
[
{
"id": "folder_open",
"iconUrl": "imgs/folder.png",
"caption": "Open folder",
"onExecute": alertClicked,
"allowOnMultiple": false,
"type": "popup",
"default": true
},
{
"id": "file_view",
"iconUrl": "imgs/view.png",
"caption": "View",
"onExecute": alertClicked,
"allowOnMultiple": false,
"type": "popup",
"default": true
},
{
"id": "file_preview",
"iconUrl": "imgs/preview.png",
"caption": "Preview",
"onExecute": alertClicked,
"allowOnMultiple": false,
"type": "popup",
"default": true
},
{
"id": "file_delete",
"iconUrl": "imgs/delete.png",
"caption": "Delete",
"onExecute": alertClicked,
"type": "popup",
"group": 2
},
{
"id": "file_edit",
"iconUrl": "imgs/edit.png",
"caption": "Edit file",
"onExecute": alertClicked,
"allowOnMultiple": false,
"type": "popup"
},
{
"id": "file_compress",
"iconUrl": "imgs/compress.png",
"caption": "Create ZIP archive",
"onExecute": alertClicked,
"type": "popup",
"group": 1,
"order": 1
},
{
"id": "file_email",
"iconUrl": "imgs/email.png",
"caption": "E-Mail",
"onExecute": alertClicked,
"allowOnMultiple": false,
"type": "popup",
"group": 1,
"order": 0
},
{
"id": "file_compress_email",
"caption": "Create ZIP and E-Mail",
"onExecute": alertClicked,
"type": "popup",
"group": 1,
"order": 2
}
]
);
objectManager = new egwActionObjectManager("", actionManager);
grid = new egwGrid(document.getElementById("container"),
[
{
"caption": "Name",
"width": "50%"
},
{
"id": "size",
"caption": "Size"
},
{
"id": "rights",
"caption": "<a href=\"http://www.google.de/\">UNIX Filerights</a>",
"default": "---------"
},
{
"id": "mime",
"caption": "File-Type/MIME"
}
]
);
var listboxFolderLinks = [
{"actionId": "folder_open", "enabled": true},
{"actionId": "file_compress_email", "enabled": true},
{"actionId": "file_compress", "enabled": true},
{"actionId": "file_delete", "enabled": true}
];
var info =
{
"size": "16KiB",
"mime": "Directory"
}
grid.beginUpdate();
function recurse_add(item, obj, depth)
{
for (var i = 1; i <= 6; i++)
{
var id = "file" + i;
var it = item.addItem(id, "Test" + i, "imgs/mime16_directory.png", info);
var _obj = obj.addObject(id, it.getAOI());
_obj.updateActionLinks(listboxFolderLinks);
if (depth < 4)
recurse_add(it, _obj, depth + 1);
}
}
recurse_add(grid, objectManager, 0);
grid.endUpdate();
});
</script>
</body>
</html>