From 5e7a292691951a0fa0a18f06c8b9bcfb509a032d Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Fri, 9 Sep 2011 22:26:16 +0200 Subject: Various JavaScript improvements, JSLint, jQuery --- lib/scripts/textselection.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lib/scripts/textselection.js') diff --git a/lib/scripts/textselection.js b/lib/scripts/textselection.js index 742338785..bd80e9341 100644 --- a/lib/scripts/textselection.js +++ b/lib/scripts/textselection.js @@ -22,8 +22,7 @@ function selection_class(){ }; this.getText = function(){ - if(!this.obj) return ''; - return this.obj.value.substring(this.start,this.end); + return (!this.obj) ? '' : this.obj.value.substring(this.start,this.end); }; } @@ -188,7 +187,7 @@ function pasteText(selection,text,opts){ * @author Andreas Gohr */ function insertTags(textAreaID, tagOpen, tagClose, sampleText){ - var txtarea = $(textAreaID); + var txtarea = jQuery('#' + textAreaID)[0]; var selection = getSelection(txtarea); var text = selection.getText(); @@ -227,7 +226,7 @@ function insertTags(textAreaID, tagOpen, tagClose, sampleText){ * @author Andreas Gohr */ function insertAtCarret(textAreaID, text){ - var txtarea = $(textAreaID); + var txtarea = jQuery('#' + textAreaID)[0]; var selection = getSelection(txtarea); pasteText(selection,text,{nosel: true}); } -- cgit v1.2.3