vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   Placeholder for Text Areas ? (https://vborg.vbsupport.ru/showthread.php?t=322120)

dimebag.d 03-15-2016 11:28 AM

Placeholder for Text Areas ?
 
Hi guys.
I am trying add a default text to quick reply and post area but i cant.

http://i.imgur.com/fmiPOmC.jpg
and
http://i.imgur.com/8dqHF94.jpg

So how can i do these? Thanks.

*i am using vb 4.2.1

MarkFL 03-15-2016 02:24 PM

Are you trying to add a field where your users can enter text, or do you want some default text to already appear in the post message area when the form is loaded?

dimebag.d 03-15-2016 09:42 PM

Quote:

Originally Posted by MarkFL (Post 2567272)
do you want some default text to already appear in the post message area when the form is loaded?

Yes.Like this;
http://www.w3schools.com/tags/tryit....ut_placeholder

How can i do that?

MarkFL 03-15-2016 10:11 PM

Ah, okay now I know exactly what you mean. :)

It is likely possible for the standard editor, but it may not be possible for the WYSIWYG editor. I will look into it very soon, and post back what I find. ;)

--------------- Added [DATE]1458100198[/DATE] at [TIME]1458100198[/TIME] ---------------

As I suspected, it won't work with the WYSIWYG editor (it is an inline document), but for the Standard editor you can use the following plugin:

Product: vBulletin

Hook Location: parse_templates

Title: Give Standard Editor Textarea A Placeholder

Execution Order: 5

Plugin PHP Code:

PHP Code:

if (in_array(THIS_SCRIPT, array('showthread''newreply''newthread')))
$template_hook['footer_javascript'] .= '<script>
window.onload = function(){
    var el = document.getElementsByClassName("cke_source");
    el[el.length - 1].placeholder = "Enter Post Here...";
};
</script>'


Plugin is Active: Yes

Click "Save".

dimebag.d 03-16-2016 12:29 PM

Hey Mark! Thanks man, its working perfectly :)

https://vborg.vbsupport.ru/external/2016/03/7.jpg

Stratis 03-17-2016 05:38 PM

Mark, can you please tell if I can include color code and image code
in the above Hook? if I can how?

Thank you in advanced.

MarkFL 03-17-2016 06:25 PM

Hey Stratis,

What do you mean by including color/image code?

Stratis 03-17-2016 06:40 PM

Lets say that i want to change the color of the text "Enter Post Here..."
or place an image to show instead of text.


:)

MarkFL 03-17-2016 06:48 PM

It is possible to use (browser-specific) CSS to change the color of the placeholder text, but I don't think you can use an image as a placeholder. :)

Stratis 03-17-2016 06:54 PM

Ok thanks for the answer Mark.

MarkFL 03-17-2016 06:57 PM

Quote:

Originally Posted by Stratis (Post 2567484)
Ok thanks for the answer Mark.

I will look into turning this into a product tonight where you can set the color, and other attributes of the placeholder, from the settings. :)

Stratis 03-17-2016 07:18 PM

I only want the color code to insert to the hook, after that I will find the css to play around :)
because this does not works to WYSIWYG editor.

But you know better if this can be done as product :D

MarkFL 03-17-2016 10:28 PM

Quote:

Originally Posted by Stratis (Post 2567490)
I only want the color code to insert to the hook, after that I will find the css to play around :)
because this does not works to WYSIWYG editor.

But you know better if this can be done as product :D

Yes, the WYSIWYG editor is an inline document, not a textarea, and so cannot be assigned a placeholder attribute.

In order to change the CSS of the placeholder text, it is best to have CSS selectors loaded so that the code for all the different browsers can be included, and a class name can be assigned to the textarea element.

MarkFL 03-18-2016 03:14 AM

1 Attachment(s)
Okay, here is a beta version...I have rrewritten the javascript so that it won't interfere with any other onload functions (like the toolbar tooltips I recently did), use a vbphrase for the placeholder text, and give in the settings an HTML colorpicker for the text color, and allow for any additional CSS to be added:

https://vborg.vbsupport.ru/attachmen...1&d=1458274341

With those settings, my quick editor looks like:

https://vborg.vbsupport.ru/attachmen...1&d=1458274341

Let me know what you think...:)

RichieBoy67 03-18-2016 03:31 AM

This is a great plug in Mark!

OP: I can see this being useful but if not used correctly I could also see it displaying the same text with every post which would be terrible for seo.

MarkFL 03-18-2016 03:39 AM

Quote:

Originally Posted by RichieBoy67 (Post 2567529)
This is a great plug in Mark!

OP: I can see this being useful but if not used correctly I could also see it displaying the same text with every post which would be terrible for seo.

It only displays in the empty editor textarea, as soon as you begin typing text in the editor, it disappears. :)

RichieBoy67 03-18-2016 03:49 AM

Ah in that case PERFECT!!!! I think I may use this! Thanks Mark!:up::up:

Stratis 03-18-2016 04:07 AM

Ok Mark i will test it, thanks you.

--------------- Added 18 Mar 2016 at 08:56 ---------------

Well, it seems i have some issues.
* it does not work in IE11 & Edge
* it works with Firefox & Chrome
* even if change phrase "Enter Post Here..." in $vbphrase[markfl_editorplaceholder_text] does not take effect, it shows the default text.

* CSS change works.

EDIT:
*Have in my mind, as default, quick reply is open, users don't need to press to see.
*The first hook test before this modification, did not work in all browsers either.


Thanks...

Stratis 03-18-2016 07:44 AM

1 Attachment(s)
I found what is causing the half issue.

Attachment 154527

Plugin "Add Placeholder To Editor" is disabled.


As i saw in xml file "<plugin active="0" executionorder="5">" active is to "0"
is this how its supposed to be? Any way when i activate the specific plugin
changes to phrase works fine.

Still only works with Firefox & Chrome ;)

EDIT:
One more, in "Text Formatting" option, works only what i put first.
Example
font-size: 1.3em;
background: #FFFF1A;

Only first "font-size works", if i change order, than only "background" works.

Trim? :p

Thanks

MarkFL 03-18-2016 12:31 PM

1 Attachment(s)
Here is an update...and I'm not surprised IE fails...it marches to the beat of a different and deranged drummer. ;)

Stratis 03-18-2016 12:43 PM

Works fine now.

Don't say that kind of words for my lovely browser :p

I must live with this ,lol


Thanks Mark

MarkFL 03-18-2016 12:48 PM

I will make some effort for wide browser support, but if in the end IE fails I simply advise users to upgrade to a modern browser like Firefox or Chrome, rather than bloat my code with workarounds for a broken browser. :)

Stratis 03-18-2016 01:06 PM

Quote:

Originally Posted by MarkFL (Post 2567568)
I will make some effort for wide browser support, but if in the end IE fails I simply advise users to upgrade to a modern browser like Firefox or Chrome, rather than bloat my code with workarounds for a broken browser. :)

This is can begin a big discussion which is better or not from technical eye.

As you see I have all browsers, i am not a coder but i am technician on pc for 30 years and I know all facts for all browsers. Modern browser like Firefox you say, and all times problems until today :D lol. Or Chrome, double slower and heavy, that does not support many css tricks (shade, etc) ;)

Any way..

Mark I tested some more css to modification and its very nice. Love it


All times are GMT. The time now is 04:29 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01236 seconds
  • Memory Usage 1,769KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (23)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete