Link to Mod (http://custom.simplemachines.org/mods/index.php?mod=3832)
When posting in the editor, the URL bbcode is often considered unfriendly. This mod modifies it so that instead of just adding [url][/url] tags in the editor area, it prompts the user for a website address and optional name and then inserts the relevant bbcode for it.
It does not attempt to modify the WYSIWYG behaviour (but then again, the WYSIWYG behaviour is intentionally different; you're supposed to write the text, then highlight it before pressing the button to make it a link anyway)
Released under the CC0 licence (http://creativecommons.org/publicdomain/zero/1.0/)
Life saver :)
The really odd thing is I wrote this almost 4 years ago just never published it here...
heh heh. Funny!
I don't get this working nicely.
I don't know what you mean.
When I click on the URL button, I don't get the pop-up. And I don't get the description thing.
Using WYSIWYG?
No. But when I use it, it only give me the normal pop up and not for the description .
That sounds like you're using WYSIWYG...
I see. Well, maybe I might try to install this mod again.
Or you could turn off WYSIWYG. Here's the thing: the little arrow on the far right, blue arrow inside red [] symbols, is that on or off? If it's on, you're in WYSIWYG and the mod does not touch WYSIWYG for good reason (because you're supposed to highlight text and press URL in WYSIWYG mode)
Nice mod, Sir Cumber....
Been looking for a way to get this fixed in my forum.....thanks alot! :D
Finally there it is - thank you !
I like it ! :D
Awesome, thanks!
GREAT!! One of the little things I missed now I'm using SMF.
Just one question: can anyone tell me what "Prevent this page from creating additional dialogues" means in practice, and if there's a best choice?
Cheers :)
That's a Firefox thing, totally unrelated to this MOD. I think it detects a certain number of JS messages and asks you if you want to now show them anymore.
But this MOD (or SMF itself, for the same reason) have nothing to do with it.
Not *totally* unrelated because the URL prompt itself is one of those 'additional dialogues' it talks about. There are people out there who thought it would be funny to lock a browser up with infinite loops of such prompts.
Just don't prevent the page while you're posting to SMF, because you should not need to do so.
I am not able to get it to work. I checked to see if I was doing it right. Not using WYSIWYG. Trying to select text and click the url button. And trying to click the url button and write text. No pop up appears. The only time a box appears is when I am in WYSIWYG mode which has nothing to do with your mod. I checked by uninstalling.
Is there a trick?
Sass
Simple and powerful, thank you Arantor!
Quote from: Arantor on February 03, 2014, 09:04:37 PM
The really odd thing is I wrote this almost 4 years ago just never published it here...
I just saw this on here and wanted to thank Arantor for this mod. I have been using it for years and it has always worked flawlessly.
Hi @‽ Arantor, your mod is awesome, but i have a problem, in the body post without WYSIWYG the mod write this:
[url=http://myurl.com]titleofmyurl[/url][url][/url]
i have to delete manually this: [url][/url]
for the mod works, please help
What other mods are you using? This does not happen when this is the only mod installed.
Quote from: ‽ on July 30, 2014, 01:24:06 PM
What other mods are you using? This does not happen when this is the only mod installed.
Hi Arantor @‽ my mods:
1. QR Code BBcode 1.0.1
2. IMG Popup 1.0.2
3. Separated Birthdays from Events 1.1.7
4. SMF 2.0.8 Update 1.0
5. Enhanced PM System 1.1
6. Countdown BBCode 2.0.2
7. Reason For Editing Mod 2.3.2
8. Enhanced Dropdown 1.3
9. Post_Board_Select 1.3
10. Tabbed smileys 0.3.99c
11. URL Popup 1.0.2
thanks
Does it behave if you uninstall img popup?
Quote from: ‽ on August 01, 2014, 10:59:37 AM
Does it behave if you uninstall img popup?
yes, but a new problem emerged in the second pop-up window that appears:
(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fi39.servimg.com%2Fu%2Ff39%2F18%2F92%2F31%2F95%2Fudef10.jpg&hash=096858da1664b13aece9829437b2dc55f7ae5dfb)
help please (i uninstall img popup)
o.O I have no idea what's hapened there. I'll see if I can find some time to investigate but I am pretty swamped with paid mod work right now.
Quote from: ‽ on August 01, 2014, 03:25:58 PM
o.O I have no idea what's hapened there. I'll see if I can find some time to investigate but I am pretty swamped with paid mod work right now.
i uninstall your mod, url popup, and I installed again, an now work perfect!!!!!!
but now I'm afraid to install the mod img popup :(
Backup your database and try it. If it doesn't work, uninstall it and live without one or the other until he gets time to look at the problem. :P
Quote from: Steve on August 01, 2014, 04:03:33 PM
Backup your database and try it. If it doesn't work, uninstall it and live without one or the other until he gets time to look at the problem. :P
I tested several modifications to the code until I came to the solution, it is important and mandatory to have installed both mods, both url popup as img popup when installing the second mod installation error which should ignore appear, then open the file called editor.js found in the Themes/default/scripts/editor.js route or in your forum theme, I leave the solution:
if you installed first URL POPUP and then IMG POPUP
in editor.js
search:
// URL popup?
if (oButtonProperties.sCode == 'url')
{
// Ask them where to link to.
var sText = prompt(oEditorStrings['prompt_text_url'], 'http://');
if (!sText)
return;
var sDesc = prompt(oEditorStrings['prompt_text_desc']);
if (!sDesc || sDesc == '')
sDesc = sText;
var bbcode = '[url=' + sText + ']' + sDesc + '[/url]';
replaceText(bbcode.replace(/\\n/g, '\n'), this.oTextHandle);
}
// Replace?
else if (!('sAfter' in oButtonProperties) || oButtonProperties.sAfter == null)
replace:
// URL popup?
if (oButtonProperties.sCode == 'url')
{
// Ask them where to link to.
var sText = prompt(oEditorStrings['prompt_text_url'], 'http://');
if (!sText)
return;
var sDesc = prompt(oEditorStrings['prompt_text_desc']);
if (!sDesc || sDesc == '')
sDesc = sText;
var bbcode = '[url=' + sText + ']' + sDesc + '[/url]';
replaceText(bbcode.replace(/\\n/g, '\n'), this.oTextHandle);
}
// IMG popup?
else if (oButtonProperties.sCode == 'img')
{
// Ask them where to link to.
var sText = prompt(oEditorStrings['prompt_text_url'], 'http://');
if (!sText)
return;
var bbcode = '[img]' + sText + '[/img]';
replaceText(bbcode.replace(/\\n/g, '\n'), this.oTextHandle);
}
// Replace?
else if (!('sAfter' in oButtonProperties) || oButtonProperties.sAfter == null)
if you installed first IMG POPUP and then URL POPUP
in editor.js
search:
// IMG popup?
if (oButtonProperties.sCode == 'img')
{
// Ask them where to link to.
var sText = prompt(oEditorStrings['prompt_text_url'], 'http://');
if (!sText)
return;
var bbcode = '[img]' + sText + '[/img]';
replaceText(bbcode.replace(/\\n/g, '\n'), this.oTextHandle);
}
// Replace?
else if (!('sAfter' in oButtonProperties) || oButtonProperties.sAfter == null)
replace:
// IMG popup?
if (oButtonProperties.sCode == 'img')
{
// Ask them where to link to.
var sText = prompt(oEditorStrings['prompt_text_url'], 'http://');
if (!sText)
return;
var bbcode = '[img]' + sText + '[/img]';
replaceText(bbcode.replace(/\\n/g, '\n'), this.oTextHandle);
}
// URL popup?
else if (oButtonProperties.sCode == 'url')
{
// Ask them where to link to.
var sText = prompt(oEditorStrings['prompt_text_url'], 'http://');
if (!sText)
return;
var sDesc = prompt(oEditorStrings['prompt_text_desc']);
if (!sDesc || sDesc == '')
sDesc = sText;
var bbcode = '[url=' + sText + ']' + sDesc + '[/url]';
replaceText(bbcode.replace(/\\n/g, '\n'), this.oTextHandle);
}
// Replace?
else if (!('sAfter' in oButtonProperties) || oButtonProperties.sAfter == null)
thats all, best regards
Thank you very much for creating this mod. I like it a lot.
Anyway to modify this to automatically input selected text to the URL name input box?
I mean this:
1. Write something.
2. Highlight a word/words.
3. Press URL button.
4. URL popup appears and you input the URL you want.
5. You press OK and in the URL name input box, you already have the word/words you have highlighted on step 2.
6. You press OK and you get the proper url bbcode.
IIRC it would need a rewrite to do that and I don't have time at present, sorry.
Thank you very much for this mod. I used one before and now after moving to 2.08 I have installed this one. It works perfectly and the users are happy. Thank you again.
Quote from: Taifuuni on August 18, 2014, 10:09:08 AM
Anyway to modify this to automatically input selected text to the URL name input box?
I mean this:
1. Write something.
2. Highlight a word/words.
3. Press URL button.
4. URL popup appears and you input the URL you want.
5. You press OK and in the URL name input box, you already have the word/words you have highlighted on step 2.
6. You press OK and you get the proper url bbcode.
You can do it by self. Here are how I did this:
1. Open editor.js and add to beginning this code:
/* Here we get selected text for URL popup when RichText is in Disabled mode */
function getSelectionText() {
var text = "";
if (window.getSelection) {
text = window.getSelection().toString();
} else if (document.selection && document.selection.type != "Control") {
text = document.selection.createRange().text;
}
return text;
}
2. Find string "URL popup?" and replace the code below on this one:
// URL popup?
if (oButtonProperties.sCode == 'url')
{
// Ask them where to link to.
var sText = prompt(oEditorStrings['prompt_text_url'], 'http://');
if (!sText)
return;
var sDesc = getSelectionText();
if (!sDesc || sDesc == '')
var sDesc = prompt(oEditorStrings['prompt_text_desc']);
if (!sDesc || sDesc == '')
sDesc = sText;
var bbcode = '[url=' + sText + ']' + sDesc + '[/url]';
replaceText(bbcode.replace(/\\n/g, '\n'), this.oTextHandle);
}
How it works.
Initially, the script checks to see if the selected text. If it is, it takes it as a description. If no text has been selected, the dialog box appears in which the user is prompted to enter a description. If the user does not enter a description and click OK, script insert raw URL as link anchor.
P.S. Code of function getSelectionText I took from stackoverflow.com (http://stackoverflow.com/questions/5379120/get-the-highlighted-selected-text)
Hey, Arantor.... I was wondering if I could get permission from you to use a variation of this mod in order to add a URL prompt to my Sports bbcode mod. I need it to get the URL from the user, then the mod would go to that URL and get the video ID cause it's just a world of pain to try to find it manually for that particular website....
Thanks in advance for your time!
Go nuts :)
Cool! Thanks!
The code from unseenua doesn't seem to work in Firefox and IE. I found this alternative[/url] (in the answer) that works also in IE and Firefox:
function getSelectionText() {
if (window.getSelection) {
try {
var ta = $('textarea').get(0);
return ta.value.substring(ta.selectionStart, ta.selectionEnd);
} catch (e) {
console.log('Cant get selection text')
}
}
// For IE
if (document.selection && document.selection.type != "Control") {
return document.selection.createRange().text;
}
}
P.S. I would like to link to my source but am not allowed to post external links..
Quote from: bjornforum on January 26, 2015, 06:17:31 AM
P.S. I would like to link to my source but am not allowed to post external links..
You can now that you've made a post.
Just been alerted to and proved that this mod causes the Safari Browser on and iPad to close when the button is clicked. Using it in Chrome on an iPad just freezes Chrome with the popup window visible, can't click OK or Cancel.
Am just installing Safari on a Win 8.1 box to test and will report.
My and my friend's iPads both show the same issue, we're both on iOS 8.3
Just tested on Safari on iPhone running iOS 8.3 and it crashed.
Thanks, just installed it. Works great for our not-internet savvy target group ;D
Hi Arantor,
Any way to remove the "http://" from the input box? We have many users with tablets that do not automatically overwrite it when pasting in a URL. Works OK on a PC as it's pre highlighted but with iPad and some other devices the highlighting is cancelled when pasting in the URL so you get two "http://"s and have to edit the box. Seems a bit superfluous anyway when copying and pasting a URL, as they always have the http:// included even if it does not show in the address bar.
I tried changing this:
var sText = prompt(oEditorStrings['prompt_text_url'], 'http://');
to this
var sText = prompt(oEditorStrings['prompt_text_url'], '');
but it made no difference, the http:// was still there.
I uninstalled the mod and edited the editor j script file to remove all hard coded 'http://' s but still there so gave up.
I don't use the WYSIWYG editor at all. I checked the BBC code too for the button but editing that to failed to remove the http:// from the box so reinstalled your mod and told folk to edit the dialog but it would be nice to be able to remove it.
If it's simply, no, can't be done then fair enough but had to ask.
Thanks
Chas.
That should generally do it for non WYSIWYG but if you only edited the file, you might still be using an old cache version, so edit it then do a hard refresh or clear your cache manually.
Quote from: Arantor on April 30, 2016, 02:15:11 PM
That should generally do it for non WYSIWYG but if you only edited the file, you might still be using an old cache version, so edit it then do a hard refresh or clear your cache manually.
Arghhh, the dreaded cache. I did clear the browser cache but not the forum cache. Doing both and reloading did indeed do the job.
Thanks.
@Arantor It looks little but here I leave the translation to the Latin Spanish ... I'll use it without hesitation to something I have in mind!
Modifications.spanish_latin-utf8.php and Modifications.spanish_latin.php
$txt['prompt_text_desc'] = 'Por favor, introduzca el texto de lo que debe decir el enlace.';
Regards!
Hmm I've installed this but I can't get it to work. I've got WYSIWYG disabled across the board because people paste some weird stuff and it is a disaster so I know it's not that. I don't have any other BBC mods installed either. Any tips? I can't find any settings either. Using Chrome if that makes a difference (but I sure hope not) :).
Hi,
just installed it on 2.0.12. Unfortunately it simply overwrites any selected text and asks for a new description. Is there an updated version of this mod that already contains the "GetSelectedText" feature?
This uses the selected text to create a link. It only prompts for linktext if no text was selected before.
Tested in Firefox, Chrome and IE 11.
@ Kolya: I tested the version listed on the Mod-page and was pretty happy with it.
Luckily I checked this thread as well, because this version is even better, thank you very, very much! ;D
Just gave the 1.0.3 and don't see any change... Using WYSIWG. Any ideas how to debug?
Uninstall the previous version, install 1.0.3.
Select some text in the editor, click the link button. Enter a URL.
The text you selected is used as link-text.
Luckily I found it again I had lost it from my bookmarks :'(
Regards!