Forum: Radiant CMS JavaScript in a Page?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
621080472679266b8e9b81aff4800398?d=identicon&s=25 Saji Njarackalazhikam Hameed (Guest)
on 2007-05-23 06:21
(Received via mailing list)
Hi,

I would like to insert some javascript commands to navigate among a set
of images. I am thinking of constructing an array of image files, for
instance:

<Script>
Panel1=new Array(
"./Plots/cccma_cgcm3_1_run1_pr_clm.png",
"./Plots/cnrm_cm3_run1_pr_clm.png",
"./Plots/csiro_mk3_0_run1_pr_clm.png",
"./Plots/giss_aom_run1_pr_clm.png",
)
thisPlot = 2
plotLen=Panel1.length - 1
</Script>

Later within the body, I would change between images using -

<A Href="javascript:processPrevious()">&laquo;</A> &nbsp;
     <A Href="javascript:processNext()">&raquo;</A>


The array Panel1 is page-specific, so I cannot insert it into a Layout
section.
I am not sure if I can insert this within a Page.

Any help and tips would be much appreciated.

Thanks,
saji


--
Saji N. Hameed

APEC Climate Center                  +82 51 668 7470
National Pension Corporation Busan Building 12F
Yeonsan 2-dong, Yeonje-gu, BUSAN 611705      saji@apcc21.net
KOREA
90ceca5a134a66a99e856c0766093c60?d=identicon&s=25 Chris Parrish (Guest)
on 2007-05-23 14:38
In a site that I am building, I have a similar requirement.  There are
standard, site-wide css and javascript files that are included in my
layout but I also have page specific javascript or css that occasionally
needs added to the <head> section.

I solve it by including the following in my layout:
<html>
  <head>
     ...
    <r:if_content part="css"><r:content part="css"/></r:if_content>
    <r:if_content part="js"><r:content part="js"/></r:if_content>
    ...
  </head>
  ...

Then, in the appropriate pages, I create a new page part named "css" or
"js" and put in my code in there.

The cool thing about this method is that I can declare inline javascript
or css like:
    <style type="text/css" media="screen">
      #mainPic {display:none}
    </style>

or I can include an external file like:
    <script src="/my/special/script.js" type="text/javascript"></script>

-Chris
621080472679266b8e9b81aff4800398?d=identicon&s=25 Saji Hameed (Guest)
on 2007-05-24 04:11
(Received via mailing list)
thanks a lot, Chris. this will allow me to replace images using
buttons in a page i am using, instead of putting one page per image.
saji
9c9ef21b37c2ef38425ed036e34d1658?d=identicon&s=25 Oliver Coningham (Guest)
on 2007-05-28 13:23
Hi -

Thanks for the useful information about how to add JavaScript to a page.

I know it's not quite on the topic of RoR, but I need a little bit of
help with my JavaScript.

My HTML is as follows:


<ul id="nav">
  <li id="nav-welcome"><a href="http://www.spongenewmedia.co.uk/"
title="Return to the home page"Welcome</a></li>
  <li id="nav-blog"><a href="/blog/" title="Read the latest blog
entries">Blog</a></li>
  <li id="nav-contact"><a href="/contact/" title="Contact information
for Oliver Coningham">Contact</a></li>
</ul>

What I want to do is apply the class "selected" to certain links using
JavaScript. The purpose of this is to show waht page you are currently
on.

The JavaScript I currently have is this:

<script type="text/javascript">
    document.getElementById('nav-blog').className='selected';
</script>

However, this only applys the class of "selected" to the <li> item. How
to use the getElementById function to select the actual hyperlink?

Many thanks in advance!
7654a545fdb492994279b8863c73b049?d=identicon&s=25 Matt Parrish (Guest)
on 2007-05-28 16:22
(Received via mailing list)
Hi Oliver,

You have two typical options in this case.  The first is to give your
<a> element an id, just like you did for the <li> element.  Then you
could use that id in your javascript.  The other method, though, is
probably what you want.  You could keep your html and javascript the
way it is, and modify your css (I assume you're using css).  So
instead of your css looking like

.selected {
     #some styles
}

you could have

.selected a {
     # some styles for hyperlink
}

This way your styling the hyperlink inside of an element with
className "selected"

Hope that helps,
Matt
This topic is locked and can not be replied to.