-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Similar change with less user-facing differences
Instead of using a textarea, we make the div containing the citation select on click. Also, fixed some issues with including two copies of jquery and bootstrap, which were causing the modal to fire twice. This commit also introduces a `main.js` file for keeping together miscellaneous JS that is used on multiple pages.
- Loading branch information
Showing
4 changed files
with
87 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Miscellaneous JavaScript used on multiple pages | ||
|
||
/** | ||
* Selects the text in a div so the user can easily copy it to the clipboard. | ||
* @param {Object} div | ||
*/ | ||
function selectdiv(div) { | ||
var doc = document; | ||
var text = doc.getElementById(div) | ||
var range; | ||
|
||
if (doc.body.createTextRange) { | ||
range = doc.body.createTextRange(); | ||
range.moveToElementText(text); | ||
range.select(); | ||
} else if (window.getSelection) { | ||
var selection = window.getSelection(); | ||
range = doc.createRange(); | ||
range.selectNodeContents(text); | ||
selection.removeAllRanges(); | ||
selection.addRange(range); | ||
} | ||
} | ||
|
||
/** | ||
* Shows the modal with the given citekey, and switches to the given tab. | ||
* @param {string} citekey | ||
* @param {string} tab | ||
*/ | ||
function showmodaltab(citekey, tab) { | ||
var m = $("#" + citekey + "cite"); | ||
var t = m.find('a[href="#' + citekey + tab + '"]'); | ||
m.modal('show'); | ||
t.tab('show'); | ||
} | ||
|
||
// Don't reload the page when clicking on an anchor link | ||
(function($) { | ||
$('a[href="#"]').click(function(e) { | ||
e.preventDefault(); | ||
}); | ||
})(jQuery); | ||
|
||
// Hook up all the tooltips | ||
(function($) { | ||
$('[data-tooltip]').tooltip(); | ||
})(jQuery); | ||
|
||
// Use $ for inline math | ||
MathJax.Hub.Config({ | ||
"tex2jax": { inlineMath: [ [ '$', '$' ] ] } | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters