Users running a non-download version of Vanilla (pulled from github), on branch release/2019.016 or master from the last 2 weeks should upgrade to release/2019.017 or latest master for security reasons. Downloaded official open sources releases are not affected.
Please upgrade here. These earlier versions are no longer being updated and have security issues.

How to add js and css to popup window ?

steamsteam www.planamigo.org - #1 foro planes amigo
edited December 2015 in Vanilla 2.0 - 2.8

Hi,

I have the problem to adding js and css in popup window. I modified plugin contact form to use popup.
In the event PluginController_Contact_Create I had
if($Sender->Head){
$Sender->AddJsFile('jquery.autogrow.js'); // does not add
$Sender->AddCssFile('contact.css','plugins/Contact/contact.css'); // does not add
$Sender->AddJsFile('jquery.gardenhandleajaxform.js');
$Sender->Head->AddString('<script type="text/javascript">jQuery(document).ready(function($){$("textarea.TextBox").autogrow();})</script>');

I have also tried in the popup window add directly on the top like:

$this->AddJsFile('js/library/jquery.autogrow.js'); // does not add
$this->AddJsFile('jquery.autogrow.js'); // does not add
$this->AddCssFile('contact.css', 'plugins/Contact'); // does not add

This form have a Checkbox "Check this if You Are Not a Bot" and I think it will not work without including - jquery.autogrow.js or just to increase textarea ? If so then how it checks if there is a robot with the Checkbox ...?

It seems that has to be another way to add js and styles popup window... Somebody knows?
Thanks

Tagged:

Comments

  • steamsteam www.planamigo.org - #1 foro planes amigo
    edited December 2015

    @R_J dijo:
    Don't add it to the popup, but to the "caller".

    If you have

    public function discussionController_whatEver_handler {
        some code to insert link  to popup;
    }
    

    then also use

    public function discussionController_render_before($sender) {
        $sender->addCssFile('yourStyle.css', 'plugins/YourPlugin');
    }
    

    I have include contact link on the menu by using Base_Render_Before
    if ($Sender->Menu) { AddLink ...

    If I add there, it will be added to all pages ... That is not very good if you only use it on contact form.

    Or maybe before displaying popup invoke another particular event and add there ?

  • In all honesty. as the script is unlikely not very long. It is not more efficient to add it on the fly.

    grep is your friend.

  • steamsteam www.planamigo.org - #1 foro planes amigo
    edited December 2015

    @x00 dijo:
    In all honesty. as the script is unlikely not very long. It is not more efficient to add it on the fly.

    I prefer to add it on the fly because it belong to this form. But if there is no alternative I will add with a link.

    Do you know how this contact plugin validate "if You Are Not a Bot" ?

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    Generally popups work on two different ways:
    a) they are already in the html source (but hidden) and only shown when requested. In such cases you would need to include js and css right from the start.
    b) they load their content with ajax, and that content is only some html code (no valid document, only a fragment).

    The functions addCssFile and addJsFile are adding files to the assets of the page. When the page is rendered, the assets already have been included. So if some html coded is added with an ajax call, the framework doesn't care for adding assets any more. The above functions are not made for your purpose.
    So you have to include css style or js script tags in the html code snippet that is inserted or load the assets when the page is loaded.


  • x00x00 MVP
    edited December 2015

    pupup by definition don't have a head.

    I can tell you from more experience, that there is no benefit from what you want to do.

    grep is your friend.

  • steamsteam www.planamigo.org - #1 foro planes amigo

    Thanks for reply. I will include on the head.

    I guess I have to ask the author of this plugin as validating if it is a bot.

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    @steam said:
    This form have a Checkbox "Check this if You Are Not a Bot" and I think it will not work without including - jquery.autogrow.js or just to increase textarea ? If so then how it checks if there is a robot with the Checkbox ...?

    autogrow is only for adapting textbox sizes. You should include it if you are using a textarea, and you do not need it if not.

    This "I'm not a robot" (Googles new reCAPTCHA) uses its own javascript which sucks every piece of information it can get from your computer and sends it over to Google Inc. Take a look at the plugin and see how it is implemented.

    P.S.: x00 is the author ;)


  • steamsteam www.planamigo.org - #1 foro planes amigo
    edited December 2015

    @R_J dijo:

    @steam said:
    This form have a Checkbox "Check this if You Are Not a Bot" and I think it will not work without including - jquery.autogrow.js or just to increase textarea ? If so then how it checks if there is a robot with the Checkbox ...?

    autogrow is only for adapting textbox sizes. You should include it if you are using a textarea, and you do not need it if not.

    This "I'm not a robot" (Googles new reCAPTCHA) uses its own javascript which sucks every piece of information it can get from your computer and sends it over to Google Inc. Take a look at the plugin and see how it is implemented.

    P.S.: x00 is the author ;)

    And this plugin will work on my vanilla 2.2 version ? I saw last question that is breaks registration of V 2.2

  • @R_J said:
    This "I'm not a robot" (Googles new reCAPTCHA) uses its own javascript which sucks every piece of information it can get from your computer and sends it over to Google Inc. Take a look at the plugin and see how it is implemented.

    P.S.: x00 is the author ;)

    That is a very specific use case where it needs to be inline.

    grep is your friend.

  • x00x00 MVP
    edited December 2015

    @steam said:
    And this plugin will work on my vanilla 2.2 version ? I saw last question that is breaks registration of V 2.2

    It really should be in the core if you want to to do an do a pull request I'm sure V team would accept it.

    The plugin is kind of hacky, it needs to be in the core.

    grep is your friend.

    steam
  • steamsteam www.planamigo.org - #1 foro planes amigo

    @x00 dijo:

    @steam said:
    And this plugin will work on my vanilla 2.2 version ? I saw last question that is breaks registration of V 2.2

    It really should be in the core if you want to to do an do a pull request I'm sure V team would accept it.

    The pluign is kind of hacky, it needs to be in the core.

    Thanks, I will see it implementation.

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    @x00 said:

    @steam said:
    And this plugin will work on my vanilla 2.2 version ? I saw last question that is breaks registration of V 2.2

    It really should be in the core if you want to to do an do a pull request I'm sure V team would accept it.

    The plugin is kind of hacky, it needs to be in the core.

    There is a new event in the captcha() method which should make it way more easy to implement different captchas.

    But I've also seen this issue, which might lead to the Vanilla staff implementing the noCAPTCHA reCAPTCHA. Although they did not state what their reaction would be, I hope it will be using a very basic CAPTCHA and maybe implement one other, more complex CAPTCHA with a plugin based on the new event.


    visenselx
Sign In or Register to comment.