# HG changeset patch # User neko259 # Date 2015-04-09 15:01:51 # Node ID 66eb05a40b58b0fbcb0350b7050069bd8cb53661 # Parent 6ec3505c119a4394e020d34792869372ee56ab7a Additinal JS refactoring diff --git a/boards/static/js/image.js b/boards/static/js/image.js --- a/boards/static/js/image.js +++ b/boards/static/js/image.js @@ -37,7 +37,8 @@ function addImgPreview() { var el = $(this); var thumb_id = 'full' + el.find('img').attr('alt'); - if(!$('#'+thumb_id).length) { + var existingPopups = $('#' + thumb_id); + if(!existingPopups.length) { var imgElement= el.find('img'); var img_w = imgElement.attr('data-width'); @@ -88,12 +89,13 @@ function addImgPreview() { return false; } - ).draggable({ - addClasses: false, - stack: '.img-full' - }) + ) + .draggable({ + addClasses: false, + stack: '.img-full' + }); } else { - $('#'+thumb_id).remove(); + existingPopups.remove(); } //prevent default return false; diff --git a/boards/static/js/panel.js b/boards/static/js/panel.js --- a/boards/static/js/panel.js +++ b/boards/static/js/panel.js @@ -30,10 +30,6 @@ * @param end End (right) text */ function addMarkToMsg(start, end) { - if (end.length == 0) { - return addTextToEachLineOfSelection(start); - } - var textareas = $('textarea'); for (var i = 0; i < textareas.length; i++) { @@ -62,41 +58,3 @@ function addMarkToMsg(start, end) { return false; } -/** - * Add text to the beginning of each selected line. Partially selected lines - * are included - * - * @param textToAdd Text to add to the each line - */ -function addTextToEachLineOfSelection(textToAdd) { - var textareas = $('textarea'); - - for (var i = 0; i < textareas.length; i++) { - var textarea = textareas[i]; - - if (document.selection) { - textarea.focus(); - - var sel = document.selection.createRange(); - sel.text = start + sel.text + end; - } else if (textarea.selectionStart || textarea.selectionStart == '0') { - textarea.focus(); - - var startPos = textarea.selectionStart; - var endPos = textarea.selectionEnd; - - var oldValue = textarea.value; - - var textBeforeSelection = oldValue.substring(0, startPos); - var selectionText = oldValue.substring(startPos, endPos) - .replace(/\n/g, '\n' + textToAdd); - textarea.value = textBeforeSelection + textToAdd + - selectionText + - oldValue.substring(endPos, oldValue.length); - } else { - textarea.value += textToAdd; - } - } - - return false; -}