globiws

pf_js_app_dash_card_clickable

Sep 16th, 2020
786
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // JavaScript runs whenever data is rendered
  2. // NB: this is JavaScript and NOT ProcScript
  3. // my_variables = {foo:"bar",etc} - cannot be changed here
  4.  
  5. // config: {card title:url,...}
  6. // note that card title must match each card title perfectly!!!
  7. // eg: {"Tasks Overdue":"/myurl?pf-context=screen_4"}
  8. var cards_to_click = {
  9.   "Card Title 1":"/urltogoto?pf-context=screen_x",
  10.   "Card Title 2":"/urltogoto?pf-context=screen_y",
  11. };
  12. // end config
  13.  
  14. var styles = ".zui-card-inner.card_clickable { cursor: pointer; background: white; } .zui-card-inner.card_clickable:hover { border: 1px solid #ddd; filter: invert(0.1); }";
  15. $("body").append("<style>"+styles+"</style>");
  16. $(".zui-card-inner").each(function(){
  17.   var title = $(this).find(".zui-title").text();
  18.   for ( key in cards_to_click ) {
  19.     if ( title != key ) continue;
  20.     var url = cards_to_click[key];
  21.     $(this).addClass("card_clickable");
  22.     console.log(key, title, url);
  23.     $(this).on("click", function(){
  24.       document.location.href = url;
  25.     });
  26.   }
  27. });
  28.  
RAW Paste Data