TableAjax.php.generateFunctionNode.js 1.1 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. props = jQuery.extend({}, defaultsProps, props);
  10. funcNode = $('<a href="#" style="margin:0 2px;"></a>')
  11. ;
  12. if ('href' in funObj) funcNode.attr('href', p5Utils__format(funObj.href, [rowPK]));
  13. if (props.ico) {
  14. if ('ico' in funObj) funcNode.append('<span class="' + funObj.ico + '"></span>');
  15. }
  16. if ('onclick' in funObj) funcNode.attr('onclick', p5Utils__format(funObj.onclick, [rowPK]));
  17. if ('title' in funObj) funcNode.attr('title', funObj.title);
  18. if ('target' in funObj) funcNode.attr('target', funObj.target);
  19. if (props.label) {
  20. if ('label' in funObj) {
  21. funcNode.append(' ' + funObj.label);
  22. } else if ('title' in funObj) {
  23. funcNode.append(' ' + funObj.title);
  24. }
  25. }
  26. return funcNode;
  27. };
  28. global['p5UI_TableAjax_generateFunctionNode'] = p5UI_TableAjax_generateFunctionNode