Jira Link Type Set

Do not let the use link the issue until they have set the link type

  1. // ==UserScript==
  2. // @name Jira Link Type Set
  3. // @namespace http://home.comcast.net/~mailerdaemon
  4. // @description Do not let the use link the issue until they have set the link type
  5. // @include */LinkExistingIssue!default.jspa*
  6. // @version 1.2
  7. // ==/UserScript==
  8.  
  9. var select = $X("//select[@id='linkDesc_select']");
  10. var submit = $X("//input[@type='submit' and (@id='Link' or @name='Link')]");
  11. if(select && submit)
  12. {
  13. /* */
  14. select.insertBefore(n = document.createElement("option"), select.options[0]);
  15. submit.disabled = n.selected = true;
  16. var f = function(){submit.disabled = n.selected;};
  17. /*/
  18. submit.disabled = true;
  19. var f = function(){submit.disabled = false;};
  20. /* */
  21. select.addEventListener( "click", f, false );
  22. select.addEventListener( "change", f, false );
  23. GM_addStyle(".fieldLabelArea { width:10%; }");
  24. }
  25.  
  26. function $X(_xpath, node){return document.evaluate(_xpath, node?node:document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null).snapshotItem(0);}
  27. function $Y(_xpath, node){return document.evaluate(_xpath, node?node:document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);}
  28. function $Z(_xpath, func, node, payload){
  29. var res = document.evaluate(_xpath, node?node:document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  30. var i, j;
  31. for (i = j = 0; link = res.snapshotItem(i); ++i)
  32. j += func(link, i, payload);
  33. return j;
  34. }