0
Welcome Guest! Login
0 items Join Now

custom javascripts

    • Ali Samii's Avatar
    • Ali Samii
    • Elite Rocketeer
    • Posts: 629
    • Thanks: 2

    custom javascripts

    Posted 12 years 3 months ago
    • Hi:

      What is the procedure to add a custom JavaScript file to Gantry 4?

      Let's say I have a script file called "myScript.js" and all it does is bring up a pop-up window that says "Hello World" when the page loads and I want to have this script automatically load always.

      Do I just create the file called myScript.js and place it in the template's js folder?
    • Last Edit: 12 years 3 months ago by Ali Samii.
    • Thank you.

      Ali Samii
    • Henning's Avatar
    • Henning
    • Preeminent Rocketeer
    • Posts: 29362
    • Thanks: 954
    • Volunteer

    Re: custom javascripts

    Posted 12 years 3 months ago
    • use

      <?php $gantry->addScript('yourstuff.js'); ?>

      in the head-tag.

      js needs to be in the js folder of the template ...
    • Ali Samii's Avatar
    • Ali Samii
    • Elite Rocketeer
    • Posts: 629
    • Thanks: 2

    Re: custom javascripts

    Posted 12 years 3 months ago
    • OK. So I would put the javascript file in the template js folder.

      I would add the code you provided to the index.php file?

      What would I do to add that to the template admin with an on-off toggle and an input field where I could pass a code into the script.

      What I am trying to do is implement a field, similar to the google analytics, but for typekit.

      If I turn the field on, then I can input the typekit code and have the script (with the code) added to the head.

      But, if I don't want to use typekit, I can turn it off.
    • Thank you.

      Ali Samii
    • Ali Samii's Avatar
    • Ali Samii
    • Elite Rocketeer
    • Posts: 629
    • Thanks: 2

    Re: custom javascripts

    Posted 12 years 3 months ago
    • What I would really wish for would be if Rocket Theme could implement a TypeKit enable/disable feature into the template.

      The Zen Grid Framework from Joomla Bamboo has that feature, but I am not a big fan. There are some nice features to that framework, but Gantry is far more mature and stable.

      docs.joomlabamboo.com/zen-grid-framework-v2/fonts
    • Thank you.

      Ali Samii
    • Henning's Avatar
    • Henning
    • Preeminent Rocketeer
    • Posts: 29362
    • Thanks: 954
    • Volunteer

    Re: custom javascripts

    Posted 12 years 3 months ago
    • Ali Samii's Avatar
    • Ali Samii
    • Elite Rocketeer
    • Posts: 629
    • Thanks: 2

    Re: custom javascripts

    Posted 12 years 3 months ago
    • Vielen Dank Henning!

      If you could perhaps try to see if there is any plans to incorporate a typekit option in Gantry, or raise that as a possible future enhancement, I would appreciate it, and I am sure others would too.
    • Thank you.

      Ali Samii
    • Henning's Avatar
    • Henning
    • Preeminent Rocketeer
    • Posts: 29362
    • Thanks: 954
    • Volunteer

    Re: custom javascripts

    Posted 12 years 3 months ago
    • I already suggested that ... but you can also post that under "requests"
    • Ali Samii's Avatar
    • Ali Samii
    • Elite Rocketeer
    • Posts: 629
    • Thanks: 2

    Re: custom javascripts

    Posted 12 years 3 months ago
    • Henning, would I be able to get support for implementing the custom code if I purchased premium support? What I mean is, could I effectively purchase development time ? :twisted:
    • Thank you.

      Ali Samii
    • Ali Samii's Avatar
    • Ali Samii
    • Elite Rocketeer
    • Posts: 629
    • Thanks: 2

    Re: custom javascripts

    Posted 12 years 3 months ago
    • The easy part I have done already (adding the labels in the language files
      TYPEKIT="Adobe TypeKit"
      TYPEKIT_DESC="Enable or disable Adobe TypeKit logic"
      TYPEKIT_ENABLE="Enable"
      TYPEKIT_CODE="TypeKit Code"

      and the fieldset in the template-options.xml file
      <fields name="typekit" type="chain" label="TYPEKIT" description="TYPEKIT_DESC">
           <field name="enabled" type="toggle" default="0" label="TYPEKIT_ENABLE"/>
           <field name="code" type="text" default="" label="TYPEKIT_CODE" class="text-long"/>
           <field name="position" type="hidden" default="typekit" />
      </fields>

      Now comes the more complicated part of adding the supporting processes and functions
    • Thank you.

      Ali Samii

Time to create page: 0.059 seconds