Skip to content
This repository has been archived by the owner on Oct 26, 2022. It is now read-only.

Commit

Permalink
Improve JS event handling (#21)
Browse files Browse the repository at this point in the history
* Improve JS event handling

- Highlight elements on `NEW_CONTENT_ADDED` conditionally
- Highlight all on `ViewIssueTabs.onTabReady`, fixes #20
  • Loading branch information
siavashs authored May 6, 2019
1 parent ba0c02f commit 76e9b5a
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/main/resources/js/prism-init.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
AJS.toInit(function(){
Prism.highlightAll();
// Highlight new content
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context, reason) {
switch(reason) {
case "pageLoad":
case "panelRefreshed":
Prism.highlightAllUnder(e.target);
break;
default:
// console.log("Prism: ignored content,", reason)
}
});

JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context, reason) {
// Highlight content in issue tabs
JIRA.ViewIssueTabs.onTabReady(function() {
Prism.highlightAll();
});

0 comments on commit 76e9b5a

Please sign in to comment.