Advertisement:

Author Topic: Fonts drop down selection & URL in post screen  (Read 126040 times)

Offline codenaught

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 14,653
  • Gender: Male
  • Formerly Known As akabugeyes
Fonts drop down selection & URL in post screen
« on: October 09, 2004, 12:37:49 PM »
Am I the only one who thinks that the way the size, font, and url method should to be changed? I think instead of by hitting the size button and have it enter the post screen as
Code: [Select]
[size=10pt][/size] have a drop down menu where you to pick the available sizes on the forum. Same goes with font. When you click the font button it enters
Code: [Select]
[font=Verdana][/font] but wouldn't you want users to know all of the font types available and so he wouldn't have to type the font type themself? So I suggest a drop down thing for that, perhaps how the color thing works. Wouldn't it be annoying if the color thing worked the same way, by hitting a color button it would pop up as
Code: [Select]
[color=Black][/color] and you would have to manually change it. I think the same things goes with the others.

Also I think the URL method should be changed. While you could manually type in
Code: [Select]
[URL=http://www.simplemachines.com]test[/URL] it would be easier if when clicking the URL button for it to ask, 'enter the text to display for the link (optional)' and then it would ask for the URL of the link. 
« Last Edit: October 10, 2004, 08:55:14 AM by A.M.A »
Dev Consultant
Former SMF Doc Coordinator

Offline andrea

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 4,324
  • Gender: Female
  • I'm a smiley.
    • Smiley Sets
Re: Drop Down Selection in post screen
« Reply #1 on: October 09, 2004, 01:27:30 PM »
You can achieve all this by themeing: modifying "Post.template.php" and eventually the .js file.
Andrea Hubacher
Ex Lead Support Specialist
www.simplemachines.org

Personal Signature:
Most recent work:
10 Aqua Themes for SMF



Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: Drop Down Selection in post screen
« Reply #2 on: October 09, 2004, 06:46:27 PM »
Some people do like this, others don't...

-[Unknown]

Offline codenaught

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 14,653
  • Gender: Male
  • Formerly Known As akabugeyes
Re: Drop Down Selection in post screen
« Reply #3 on: October 09, 2004, 07:18:09 PM »
Well if that is the case, maybe in a future version of SMF you can have an option for admins to set as the default what method they want to have it. And then users could perhaps edit the default method to what they prefer. Also a mod of this would be okay if it won't be placed in as a feature.
Dev Consultant
Former SMF Doc Coordinator

Offline A.M.A

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 2,133
  • Gender: Male
  • ..
Re: Drop Down Selection in post screen
« Reply #4 on: October 09, 2004, 07:37:56 PM »
open Post.template.php and look for:
Code: [Select]
// Print a drop down list for all the colors we allow!add before it:
Code: [Select]
// Print a drop down list for font size!
echo ' <select onchange="surroundText(\'[size=\'+this.options[this.selectedIndex].value+\']\', \'[/size]\', document.', $context['post_form'], '.', $context['post_box_name'], '); this.selectedIndex = 0;" style="margin-bottom: 1ex;">
<option value="" selected="selected">Font Size</option>
<option value="10pt">10pt</option>
<option value="14pt">14pt</option>
<option value="18pt">18pt</option>
</select>';
echo '<br />';
and you have your own font size dropdown list .. the same method can be used for fonts name.
Really sorry .. real life is demanding my full attention .. will be back soon hopefully :)

Offline codenaught

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 14,653
  • Gender: Male
  • Formerly Known As akabugeyes
Re: Drop Down Selection in post screen
« Reply #5 on: October 09, 2004, 07:55:52 PM »
Thank you very much! :D Now do you know how I could do something for the url thing so when you click on the url button it first asks for a name to the link and then it asks for the url of the link instead of just entering
Code: [Select]
[url][/url]
Dev Consultant
Former SMF Doc Coordinator

Offline A.M.A

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 2,133
  • Gender: Male
  • ..
Re: Drop Down Selection in post screen
« Reply #6 on: October 10, 2004, 08:53:28 AM »
1- Font Size & Name drop down list
open Post.template.php and look for:
Code: [Select]
<option value="LimeGreen">', $txt[275], '</option>
</select>';
echo '<br />';
Delete the last line, and Add belew it:
Code: [Select]
  // Begin Print a drop down list for font face . . . . . . .
    echo ' <select onchange="surroundText(\'[font=\'+this.options[this.selectedIndex].value+\']\', \'[/font]\', document.', $context['post_form'], '.', $context['post_box_name'], '); this.selectedIndex = 0;" style="margin-bottom: 1ex;">
            <option value="" selected="selected">Font Face</option>
            <option value="Arial">Arial</option>
            <option value="Times New Roman">Times New Roman</option>
            <option value="Tahoma">Tahoma</option>
            <option value="Verdana">Verdana</option>
            </select>';
  // End Print a drop down list for font face . . . . . . . .

  // Begin Print a drop down list for font size . . . . . . .
    echo ' <select onchange="surroundText(\'[size=\'+this.options[this.selectedIndex].value+\']\', \'[/size]\', document.', $context['post_form'], '.', $context['post_box_name'], '); this.selectedIndex = 0;" style="margin-bottom: 1ex;">
            <option value="" selected="selected">Font Size</option>
            <option value="10pt">10pt</option>
            <option value="14pt">14pt</option>
            <option value="18pt">18pt</option>
            </select>';
    echo '<br />';
  // End Print a drop down list for font size . . . . . . . .

Note:
* you can modify the red text: <option value="10pt">10pt</option> to your own needs.
* to remove the default tag buttons, look for and delete:
Code: [Select]
array(),
'size' => array('code' => 'size', 'before' => '[size=10pt]', 'after' => '[/size]', 'description' => $txt[532]),
'face' => array('code' => 'font', 'before' => '[font=Verdana]', 'after' => '[/font]', 'description' => $txt[533]),


2- URL input boxes
look for:
Code: [Select]
// Print a drop down list for all the colors we allow!add above:
Code: [Select]
    // Java script to handle URL input boxes ...
    echo '<script language="JavaScript" type="text/javascript">
          <!--
          function urlINPT(){
          // Enter URL .........................................
          var urlLINK = prompt("Please enter URL address:","http://");
          if (urlLINK == null ){ //cancel pressed . . .
          }
          else if (urlLINK == "" || urlLINK == " "){ //ok pressed but with Notext . . .
                  alert("Sorry no text entered!");
          }
          else
          { //ok pressed and there is something :)
          // Enter Description ...................................
          var urlNAME = prompt("Please enter URL name:","");
          if (urlNAME == null ){ //cancel pressed . . .
          }
          else if (urlNAME == "" || urlNAME == " "){  //ok pressed but with notext so use URL only!
                    surroundText(\'[url]\'+urlLINK+\'\', \'[/url]\', document.', $context['post_form'], '.', $context['post_box_name'], ');
          }
          else //ok pressed with text so use URL and Name!
                    surroundText(\'[url=\'+urlLINK+\']\'+urlNAME+\'\', \'[/url]\', document.', $context['post_form'], '.', $context['post_box_name'], ');
          }
          }
          // -->
          </script>';
look for:
Code: [Select]
// Print the buttom row of buttons!
foreach ($context['bbc_tags'][1] as $image => $tag)
{
add after:
Code: [Select]
      // only replace the URL tag! . . . . . . . . . . .
      if ($tag['code'] == 'url')
          echo '<a href="javascript:void(0);" onclick="urlINPT(); return false;"><img onmouseover="bbc_highlight(this, true);" onmouseout="if (window.bbc_highlight) bbc_highlight(this, false);" src="', $settings['images_url'], '/bbc/', $image, '.gif" align="bottom" width="23" height="22" alt="', $tag['description'], '" title="', $tag['description'], '" border="0" style="background-image: url(', $settings['images_url'], '/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a>';
      else
Really sorry .. real life is demanding my full attention .. will be back soon hopefully :)

Offline codenaught

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 14,653
  • Gender: Male
  • Formerly Known As akabugeyes
Re: Fonts drop down selection & URL in post screen
« Reply #7 on: October 10, 2004, 10:31:25 AM »
Thank you very much! This is a big help!
Dev Consultant
Former SMF Doc Coordinator

Offline codenaught

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 14,653
  • Gender: Male
  • Formerly Known As akabugeyes
Re: Fonts drop down selection & URL in post screen
« Reply #8 on: November 21, 2004, 10:11:31 AM »
Okay, but could someone tell me how to do a small change to the url one.

Here is what I want to do. When you highlight code and hit the url button, it asks for the address and then it asks you for the name of the link. How about when you highlight text it will just ask you for the url and it will use the highlighted text as the name of the link.

Any help would be nice.
Dev Consultant
Former SMF Doc Coordinator

Offline damo1065

  • Semi-Newbie
  • *
  • Posts: 69
  • Gender: Male
    • TheGaff
Re: Fonts drop down selection & URL in post screen
« Reply #9 on: December 04, 2004, 01:05:50 PM »
Works like a dream thanks.

Does anyone know what colours you can add to the drop down colour menu, I know HotPink works - it gives you a nice deep pink colour, what other ones can you add?
Wy not visit my site... The Gaff'll be bored to be honest, unless you're from Cork in Ireland

Offline helenbpd

  • Jr. Member
  • **
  • Posts: 181
    • The Nook at BPDCentral
Re: Fonts drop down selection & URL in post screen
« Reply #10 on: December 05, 2004, 05:43:18 PM »
I'd imagine you can use any of the "named" colors - they may not work for every single browser (only 16 "names" are web-safe), but what the hey:

http://webdesign.about.com/od/colorcharts/l/bl_namedcolors.htm

Ditto for fonts:

http://www.i4image.com/resources_wsfont.shtml


Offline Peter Duggan

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 4,663
  • Gender: Male
    • Peat Stack or Pete's Tack?
Re: Fonts drop down selection & URL in post screen
« Reply #11 on: January 15, 2005, 06:35:15 AM »
Does anyone know what colours you can add to the drop down colour menu, I know HotPink works - it gives you a nice deep pink colour, what other ones can you add?

Perhaps I'm a bit late with this response but, since you can specify both option value and option, the answer (with one small reservation explained below) is anything you like because you can specify hex codes for the values and descriptive text for the options. So, for an English language forum, all of these are basically equivalent:

<option value="Red">', $txt[263], '</option>
<option value="Red">Red</option>
<option value="Red">Any name you like</option>
<option value="#ff0000">', $txt[263], '</option>
<option value="#ff0000">Red</option>
<option value="#ff0000">Any name you like</option>


Which means that, so long as you're happy to see 'any name you like' translated into #****** in the text area, your choice of colours for the drop-down amounts to > 16 million!

Offline Peter Duggan

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 4,663
  • Gender: Male
    • Peat Stack or Pete's Tack?
Re: Fonts drop down selection & URL in post screen
« Reply #12 on: January 15, 2005, 06:39:15 AM »
Same goes with font. When you click the font button it enters
Code: [Select]
[font=Verdana][/font] but wouldn't you want users to know all of the font types available and so he wouldn't have to type the font type themself? So I suggest a drop down thing for that, perhaps how the color thing works. 

But remember that the 'font types available' are the fonts installed on the user's computer, so one user's choice (and/or yours as admin) may not display for another user at all.
« Last Edit: January 15, 2005, 06:41:39 AM by Peter Duggan »

Offline rojamaia

  • Semi-Newbie
  • *
  • Posts: 83
Re: Fonts drop down selection & URL in post screen
« Reply #13 on: August 27, 2005, 11:50:57 AM »
thanks to everyone for sharing this trick!  it would really make things simpler for my users who are mostly beginners in using boards.

but hey, how do i code it, so that the actual font face and size would appear (as a preview) on the drop-down menu?
« Last Edit: August 27, 2005, 04:04:53 PM by malinaobenny »

Offline Snickers

  • Jr. Member
  • **
  • Posts: 127
Re: Fonts drop down selection & URL in post screen
« Reply #14 on: September 08, 2005, 11:01:33 AM »
Can anyone make this compitable with version 1.1 beta 3?

Offline JohnnyVW

  • Semi-Newbie
  • *
  • Posts: 11
Re: Fonts drop down selection & URL in post screen
« Reply #15 on: September 25, 2005, 01:22:48 AM »
Okay, but could someone tell me how to do a small change to the url one.

Here is what I want to do. When you highlight code and hit the url button, it asks for the address and then it asks you for the name of the link. How about when you highlight text it will just ask you for the url and it will use the highlighted text as the name of the link.

Any help would be nice.

I would love to do this too!  I will be doing nightly posts with links; this will make things go so much quicker!

Thanks!

Offline nokonium

  • Full Member
  • ***
  • Posts: 680
  • Gender: Male
  • TinyPortal Support Team
    • Our-Local
Re: Fonts drop down selection & URL in post screen
« Reply #16 on: December 28, 2005, 09:51:09 AM »
I've been playing with this today and it is great, working OK except for one small thing with RC2 (yes it is legit, co-admin is a CM) The javascript for the URL is asking for the URL twice, it doesn't ask for the description on the second box.

And a supplimentary question, is there a way to put a border around the drop down box, like there is with input, text areas or radio buttons? The drop down list has a border but not the 'inactive' box.

In case this is a browser issue I'm using Opera 8.51.

 



Offline SleePy

  • Site Team Lead
  • SMF Master
  • *
  • Posts: 29,931
  • Gender: Male
  • Thats his happy face.
    • jdarwood007 on GitHub
    • @jdarwood on Twitter
    • SleePy Code - My personal site
Re: Drop Down Selection in post screen
« Reply #17 on: December 28, 2005, 04:19:29 PM »
After i added the code A.M.A showed us i get these to errors in my error log

8: Undefined index: description
File: /home/***/public_html/forums/Themes/helios/languages/Post.english.php (eval?)
Line: 874

8: Undefined index: code
File: /home/***/public_html/forums/Themes/helios/languages/Post.english.php (eval?)
Line: 871


edit. there is no line 874 or 871 in that file...  :(

edit 2: i was able to get rid of the description one by changing the thing a little
changed
Quote
if ($tag['code'] == 'url')
          echo '<a href="javascript:void(0);" onclick="urlINPT(); return false;"><img onmouseover="bbc_highlight(this, true);" onmouseout="if (window.bbc_highlight) bbc_highlight(this, false);" src="', $settings['images_url'], '/bbc/', $image, '.gif" align="bottom" width="23" height="22" alt="', $tag['description'], '" title="', $tag['description'], '" border="0" style="background-image: url(', $settings['images_url'], '/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a>';
To
Quote
      if ($tag['code'] == 'url')
      {
      global $tag;
          echo '<a href="javascript:void(0);" onclick="urlINPT(); return false;"><img onmouseover="bbc_highlight(this, true);" onmouseout="if (window.bbc_highlight) bbc_highlight(this, false);" src="', $settings['images_url'], '/bbc/', $image, '.gif" align="bottom" width="23" height="22" alt="', $tag['description'], '" title="', $tag['description'], '" border="0" style="background-image: url(', $settings['images_url'], '/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a>';
      }

but i can't seem to get the other one to stop.
« Last Edit: December 28, 2005, 04:43:28 PM by SleePy »
Jeremy D — Site Team / SMF Developer
Support the SMF Support team!
Profiles:
GitHub

Offline nokonium

  • Full Member
  • ***
  • Posts: 680
  • Gender: Male
  • TinyPortal Support Team
    • Our-Local
Re: Fonts drop down selection & URL in post screen
« Reply #18 on: December 28, 2005, 05:13:08 PM »
I get it, according to the error log on line 866. As the changes were made in Post.template I had a look there and line 866 is     if ($tag['code'] == 'url')

Code: [Select]
// only replace the URL tag! . . . . . . . . . . .
      if ($tag['code'] == 'url')
          echo '<a href="javascript:void(0);" onclick="urlINPT(); return false;"><img onmouseover="bbc_highlight(this, true);" onmouseout="if (window.bbc_highlight) bbc_highlight(this, false);" src="', $settings['images_url'], '/bbc/', $image, '.gif" align="bottom" width="23" height="22" alt="', $tag['description'], '" title="', $tag['description'], '" border="0" style="background-image: url(', $settings['images_url'], '/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a>';

That may need changing to work without errors.



Offline SleePy

  • Site Team Lead
  • SMF Master
  • *
  • Posts: 29,931
  • Gender: Male
  • Thats his happy face.
    • jdarwood007 on GitHub
    • @jdarwood on Twitter
    • SleePy Code - My personal site
Re: Fonts drop down selection & URL in post screen
« Reply #19 on: December 29, 2005, 11:24:07 PM »
i was able to fix it by moving the if statement around

Code: [Select]
// Print the buttom row of buttons!
foreach ($context['bbc_tags'][1] as $image => $tag)
{
  if (isset($tag['before']))
{
// Is this tag disabled?
if (!empty($context['disabled_tags'][$tag['code']]))
continue;

// only replace the URL tag! . . . . . . . . . . .
      if ($tag['code'] == 'url')
   {
global $tag;
echo '<a href="javascript:void(0);" onclick="urlINPT(); return false;"><img onmouseover="bbc_highlight(this, true);" onmouseout="if (window.bbc_highlight) bbc_highlight(this, false);" src="', $settings['images_url'], '/bbc/', $image, '.gif" align="bottom" width="23" height="22" alt="', $tag['description'], '" title="', $tag['description'], '" border="0" style="background-image: url(', $settings['images_url'], '/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a>';
}
else{
// If there's no after, we're just replacing the entire selection in the post box.
if (!isset($tag['after']))
echo '<a href="javascript:void(0);" onclick="replaceText(\'', $tag['before'], '\', document.forms.', $context['post_form'], '.', $context['post_box_name'], '); return false;">';
// On the other hand, if there is one we are surrounding the selection ;).
else
echo '<a href="javascript:void(0);" onclick="surroundText(\'', $tag['before'], '\', \'', $tag['after'], '\', document.forms.', $context['post_form'], '.', $context['post_box_name'], '); return false;">';

// Okay... we have the link.  Now for the image and the closing </a>!
echo '<img onmouseover="bbc_highlight(this, true);" onmouseout="if (window.bbc_highlight) bbc_highlight(this, false);" src="', $settings['images_url'], '/bbc/', $image, '.gif" align="bottom" width="23" height="22" alt="', $tag['description'], '" title="', $tag['description'], '" border="0" style="background-image: url(', $settings['images_url'], '/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a>';
}
}
// I guess it's a divider...
else
echo '<img src="', $settings['images_url'], '/bbc/divider.gif" alt="|" style="margin: 0 3px 0 3px;" />';
}

echo '
</td>
</tr>';
}
Jeremy D — Site Team / SMF Developer
Support the SMF Support team!
Profiles:
GitHub