Roundcube Community Forum

News and Announcements => General Discussion => Topic started by: xyr123 on September 15, 2012, 03:20:00 PM

Title: Placeholder for login form
Post by: xyr123 on September 15, 2012, 03:20:00 PM
Hi,
I'd like to use a placeholder for the login form. Can anyone point me in the right direction?
Title: Re: Placeholder for login form
Post by: SKaero on September 15, 2012, 05:51:30 PM
What do you mean by placeholder?
Title: Re: Placeholder for login form
Post by: xyr123 on September 15, 2012, 07:35:27 PM
Like this:

<td class="input">
<input id="rcmloginuser" type="text" autocapitalize="off" size="40" name="_user" placeholder="Your email">
</td>
Title: Re: Placeholder for login form
Post by: SKaero on September 16, 2012, 02:44:58 PM
Probably the simplest way is to make a plugin to include a javascript file and add it that way.
Title: Re: Placeholder for login form
Post by: xyr123 on September 16, 2012, 07:21:11 PM
oh, I have no experience with js or php, so that would be a bit difficult for me.. Anyone here that would try to make such a plugin?
Title: Re: Placeholder for login form
Post by: SKaero on September 17, 2012, 09:20:13 AM
This is just a shot in the dark, completely untested.

Plugin file:

<?php
class placeholder extends rcube_plugin {
    public function 
init() {
        
$this->include_script("placeholder.js");
    }
}


JS file:

$('input[name="_user"]').attr('placeholder', '<username>');
$('input[name="_pass"]').attr('placeholder', '<password>');


Replace the <username> and <password> in the JS file with the placeholders you want.
Title: Re: Placeholder for login form
Post by: xyr123 on September 18, 2012, 09:57:23 AM
Thanks SKaero.

Just tested the code, but it didn't work
Title: Re: Placeholder for login form
Post by: SKaero on September 18, 2012, 12:47:31 PM
Did it load the js file?
Title: Re: Placeholder for login form
Post by: xyr123 on September 18, 2012, 07:46:06 PM
No, I do not think so..
Title: Re: Placeholder for login form
Post by: SKaero on September 19, 2012, 08:06:42 AM
Did you make the placeholder.php and placeholder.js files in a folder named placeholder in the plugins directory and activate the plugin in the main.inc.php?
Title: Re: Placeholder for login form
Post by: xyr123 on September 19, 2012, 01:08:43 PM
Yes, or I use plugin manager from myroundcube so I activate it from the config in plugin_manager. I can try to activate it from the main.inc.php instead.
Title: Re: Placeholder for login form
Post by: xyr123 on September 19, 2012, 01:54:33 PM
I just added placeholder to main.inc.php, and it loads the js, but its still not working.
Title: Re: Placeholder for login form
Post by: SKaero on September 19, 2012, 02:15:03 PM
Any error messages in the browser js console?
Title: Re: Placeholder for login form
Post by: xyr123 on September 19, 2012, 02:22:44 PM
No, none..
Title: Re: Placeholder for login form
Post by: SKaero on September 19, 2012, 02:40:51 PM
Try changing the JS file to the following:

$(function() {
  $('input[name="_user"]').attr('placeholder', '<username>');
  $('input[name="_pass"]').attr('placeholder', '<password>');
});
Title: Re: Placeholder for login form
Post by: xyr123 on September 19, 2012, 02:46:02 PM
Thanks SKaero, works perfect! :D