Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest sNews - sNews 1.7 - with its own forums - for discussion and user mods.

Author Topic: Link title in text editor  (Read 2763 times)

mattonik

  • Full Member
  • ***
  • Karma: 7
  • Posts: 123
    • http://www.mattonik.sk
Link title in text editor
« on: April 11, 2007, 08:22:20 AM »

If u are using IE, there is a bug when you wnat to make a link in new article. If no text is selected and u make a new link, the link title wouldn't be used as a link text.
Quote from: piXelatedEmpire
Quote from: keyrocks
Here is what I mean. Right now, the link is generated in the textarea as:
Quote
... and it would be great if there was a way to generate the text-link within the string when we click on the link from the link list, so it would look like:
Quote
Install sNews 1.5
Actually, this occurs in a default installation of sNews without any MODs when inserting a link - the text for the link is not added.  Possible sNews bug?
Not sNews but IE bug. Here is a solution:
in
Code: [Select]
// basic html textarea editor
function tag(tag) {
find this
Code: [Select]
if(!src.setSelectionRange) {
var selected = document.selection.createRange().text;
if(selected.length <= 0) { src.value += start + end;
        } else {
            var codetext = start + selected + end;
            document.selection.createRange().text = codetext;
        }
} else {
        var pretext = src.value.substring(0, src.selectionStart);
        var codetext = start + src.value.substring(src.selectionStart, src.selectionEnd) + end;
        var posttext = src.value.substring(src.selectionEnd, src.value.length)
        if(codetext == start + end)
            codetext = start + end;
            src.value = pretext + codetext + posttext;
    }
src.focus();
}
and change it to this:
Code: [Select]
if(!src.setSelectionRange) {
var selected = document.selection.createRange().text;
if(selected.length <= 0) { src.value += start + title + end;
        } else {
            var codetext = start + selected + end;
            document.selection.createRange().text = codetext;
        }
} else {
        var pretext = src.value.substring(0, src.selectionStart);
        var codetext = start + src.value.substring(src.selectionStart, src.selectionEnd) + end;
        var posttext = src.value.substring(src.selectionEnd, src.value.length)
        if(codetext == start + end)
            codetext = start + title + end;
            src.value = pretext + codetext + posttext;
    }
src.focus();
}
thats all
Logged

piXelatedEmpire

  • MIA
  • ULTIMATE member
  • ******
  • Karma: 37
  • Posts: 1401
  • currently MIA
Link title in text editor
« Reply #1 on: April 11, 2007, 09:08:07 AM »

cheers matt!  :D
Logged
my apologies to the sNews crew, but I will be MIA for the forseeable future