diff options
author | prashantsinalkar | 2016-09-06 15:56:53 +0530 |
---|---|---|
committer | prashantsinalkar | 2016-09-06 15:56:53 +0530 |
commit | 99b0fe340368e306679060c44979aca5154b52be (patch) | |
tree | d7fefb8b9bc4194af8c251fe9e360dea6fde49b5 /js | |
parent | 13d4d92ccbcde4067a649e644e1f08fbf12f8489 (diff) | |
download | textbook_companion_fixer-99b0fe340368e306679060c44979aca5154b52be.tar.gz textbook_companion_fixer-99b0fe340368e306679060c44979aca5154b52be.tar.bz2 textbook_companion_fixer-99b0fe340368e306679060c44979aca5154b52be.zip |
formated the code
Diffstat (limited to 'js')
-rwxr-xr-x | js/selection.js | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/js/selection.js b/js/selection.js index 6834aca..639afe5 100755 --- a/js/selection.js +++ b/js/selection.js @@ -1,26 +1,27 @@ function getSelectionText(divID) { - var selectedText = ""; - if (window.getSelection) { - var sel = window.getSelection(); - var div = document.getElementById(divID); - - if (sel.rangeCount) { - // Get the selected range - var range = sel.getRangeAt(0); - // Check that the selection is wholly contained within the div text - // if (range.commonAncestorContainer == div.firstChild) { - var selectedText = range.toString(); - // } - } - } - return selectedText; + var selectedText = ""; + if (window.getSelection) { + var sel = window.getSelection(); + var div = document.getElementById(divID); + if (sel.rangeCount) { + // Get the selected range + var range = sel.getRangeAt(0); + // Check that the selection is wholly contained within the div text + // if (range.commonAncestorContainer == div.firstChild) { + var selectedText = range.toString(); + // } + } + } + return selectedText; } -$(document).ready(function() { - $(".fix-caption-code").mousedown(function() { - $("#edit-caption").val(""); - }); - $(".fix-caption-code").mouseup(function() { - quotedText = getSelectionText("#fix-caption-code"); - $("#edit-caption").val(quotedText); - }); -}); +(function($) { + $(document).ready(function() { + $(".fix-caption-code").mousedown(function() { + $("#edit-caption").val(""); + }); + $(".fix-caption-code").mouseup(function() { + quotedText = getSelectionText("#fix-caption-code"); + $("#edit-caption").val(quotedText); + }); + }); +})(jQuery); |