Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Disableing javaScript Libraries?


Reply

6 Posts   1845 Views

Avatar
MKayHavoc

24 July 2008 at 7:49pm Community Member, 33 Posts

How can I disable the the following javaScript libraries:

<script type="text/javascript" src="jsparty/loader.js"></script>
<script type="text/javascript" src="jsparty/prototype.js"></script>
<script type="text/javascript" src="jsparty/behaviour.js"></script>
<script type="text/javascript" src="jsparty/prototype_improvements.js"></script>
<script type="text/javascript" src="jsparty/tabstrip/tabstrip.js"></script>
<script type="text/javascript" src="jsparty/scriptaculous/effects.js"></script>

In my site, but obviously leave them for the CMS backend?

Cheers

Avatar
Willr

24 July 2008 at 10:15pm Forum Moderator, 5511 Posts

You need to use a method called Requirements::block(the file name);. You would put this in your in the init() function Page_Controller class in Page.php.

So you would need

Requirements::block("jsparty/loader.js");
..

for each JS file you want to block on the front end.

Avatar
kudesign

6 December 2008 at 11:54pm (Last edited: 6 December 2008 11:59pm), Community Member, 64 Posts

Hi, so if I want to add a js, or a new css to load, do I just add in a requirement?

I want to load

slider.css
and
slider.js

e.g.

Requirements::themedCSS("slider");
Requirements::("jsparty/slider.js");

Avatar
kudesign

6 December 2008 at 11:57pm (Last edited: 6 December 2008 11:59pm), Community Member, 64 Posts

This is what my page.php looks like at the moment

<?php

class Page extends SiteTree {
   static $db = array(
   );
   static $has_one = array(
);
}

class Page_Controller extends ContentController {
   function init() {
      parent::init();
      
      Requirements::themedCSS("layout");
      Requirements::themedCSS("typography");
      Requirements::themedCSS("form");
   }
}

?>

So can I add to the list

Requirements::themedCSS("slider");
Requirements::("jsparty/slider.js");

thanks!

Avatar
Willr

7 December 2008 at 12:11am Forum Moderator, 5511 Posts

The best way to to keep your own JS in themes/yourthemename/javascript. And you would include it like

Requirements::javascript("themes/yourthemename/javascript/slider.js");

in the function init() just like the rest of the Requirements

Avatar
kudesign

7 December 2008 at 12:26am Community Member, 64 Posts

Thanks for the quick reply! this helps. I tried coding it into the template, and it also works, but I think coding it in page.php sounds like a better way to do it.

Another quick question, any idea why my log-in page login name/openID tabs doesn't hide in Firefox anymore?

http://www.kudesign.co.nz/studio/Security/login

I looked at the tabstrip.js, and tabstrip.css, they seem to be working fine... just won't hide in Firefox. Any tip will be much appreciated!!