TableAjax.php.generateFunctionNode.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. // @require p5Utils__format
  2. // @require variables:
  3. // if ('undefined' === typeof UNIQ_HASH) throw "Missing UNIQ_HASH"; // $this->_htmlID
  4. var p5UI_TableAjax_generateFunctionNode = function(funObj, rowPK, props) {
  5. var defaultsProps = {
  6. ico: true,
  7. label: false
  8. };
  9. var props = jQuery.extend({}, defaultsProps, props);
  10. var funcNode = $('<a href="#" style="margin:0 2px;"></a>');
  11. if ('href' in funObj) funcNode.attr('href', p5Utils__format(funObj.href, [rowPK]));
  12. if (props.ico) {
  13. if ('ico' in funObj) funcNode.append('<span class="' + funObj.ico + '"></span>');
  14. }
  15. if ('onclick' in funObj) funcNode.attr('onclick', p5Utils__format(funObj.onclick, [rowPK]));
  16. if ('title' in funObj) funcNode.attr('title', funObj.title);
  17. if ('target' in funObj) funcNode.attr('target', funObj.target);
  18. if (props.label) {
  19. if ('label' in funObj) {
  20. funcNode.append(' ' + funObj.label);
  21. } else if ('title' in funObj) {
  22. funcNode.append(' ' + funObj.title);
  23. }
  24. }
  25. return funcNode;
  26. };
  27. global['p5UI_TableAjax_generateFunctionNode'] = p5UI_TableAjax_generateFunctionNode