Page Content Rotator

When setting up the JavaScript rotator with Page Content we must also include Prototype and Scriptaculous in the layout file (THIS MUST BE LISTED FIRST):

<!--- prototype and scriptaculous --->
<script src="/includes/prototype_1.7/prototype.js"></script>
<script src="/includes/scriptaculous_1.9/scriptaculous.js"></script>

Also include the Perpetua Eventbox Javascript file in the layout file:

<!--- eventbox  --->
<script src="/includes/eventbox/eventbox.js"></script>

If the rotator might contain a video, we also need to include the Flowplayer Javascript file in the layout file:

<script src="/includes/videoplayers/flowplayer/flowplayer.js"></script>
<script src="/includes/videoplayers/flowplayer/flowplayer.ipad.js"></script>

We then need to put the HTML on the page.

Coldfusion Code

<!--- PAGE CONTENT GENERATED EVENTBOX IMAGES --->
<!--- parameters --->
<cfset request.pc_content_id = 1>
<cfset request.pc_image_id = 1>
<cfset request.pc_link_id = 2>
<cfset request.pc_description_id = 3>
<cfset request.pc_video_id = 0>
<cfset request.css_main_class = "rotator">
<!--- end parameters --->

<cfquery name="qry_pc_itm_#request.pc_content_id#" dbtype="query">
select fld_name, fld_value, fld_itemlist_id from qry_pagexml where fld_content_id = #request.pc_content_id# order by fld_itemlist_id
</cfquery>

<cfset request.qry_pc_items=Evaluate( "qry_pc_itm_#request.pc_content_id#")>

<div class="<cfoutput>#request.css_main_class#</cfoutput>">
<div class="<cfoutput>#request.css_main_class#</cfoutput>Window">
<cfset request.pc_count=0>
<cfoutput query="request.qry_pc_items" group="fld_itemlist_id">
<cfset request.pc_count=request.pc_count + 1>
<div>
<!--- if there's a video defined --->
<cfif IsDefined( "pcItem_#request.pc_content_id#_#request.pc_count#_#request.pc_video_id#") and len(Evaluate( "pcItem_#request.pc_content_id#_#request.pc_count#_#request.pc_video_id#"))>

<a id="pcItem_#request.pc_content_id#_#request.pc_count#_#request.pc_video_id#" href="#Evaluate('pcItem_#request.pc_content_id#_#request.pc_count#_#request.pc_video_id#')#" rel="flowplayer[pcItem_#request.pc_content_id#_#request.pc_count#_#request.pc_video_id#]"
style="width: #request.pc_video_width#px; height: #request.pc_video_height#px; display: block;">
<cfif IsDefined( "pcItem_#request.pc_content_id#_#request.pc_count#_#request.pc_image_id#")>
<img src="#Evaluate('pcItem_#request.pc_content_id#_#request.pc_count#_#request.pc_image_id#')#">
<cfset request.video_clip="autoPlay: true, autoBuffering: true">
<cfelse>
<cfset request.video_clip="autoPlay: false, autoBuffering: false">
</cfif>
</a>

<script type="text/javascript">
document.observe("dom:loaded", function() {
flowplayer("pcItem_#request.pc_content_id#_#request.pc_count#_#request.pc_video_id#", "#variables.basehref#includes/videoplayers/flowplayer/flowplayer.swf", {
clip: {#
request.video_clip#
},
plugins: {
controls: {
autoHide: 'always',
hideDelay: 1000
}
},
onBeforeLoad: function() {
$("pcItem_#request.pc_content_id#_#request.pc_count#_#request.pc_video_id#").up("div.#request.css_main_class#").retrieve("eventbox").flowplayer_init(this);
}
}).ipad();
});
</script>

<!--- if the link is defined --->
<cfelseif IsDefined( "pcItem_#request.pc_content_id#_#request.pc_count#_#request.pc_link_id#") and len(Evaluate( "pcItem_#request.pc_content_id#_#request.pc_count#_#request.pc_link_id#")) and IsDefined(
"pcItem_#request.pc_content_id#_#request.pc_count#_#request.pc_image_id#")>
<a href="#Evaluate('pcItem_#request.pc_content_id#_#request.pc_count#_#request.pc_link_id#')#"><img src="#Evaluate('pcItem_#request.pc_content_id#_#request.pc_count#_#request.pc_image_id#')#"></a>

<cfelseif IsDefined( "pcItem_#request.pc_content_id#_#request.pc_count#_#request.pc_image_id#")>
<img src="#Evaluate('pcItem_#request.pc_content_id#_#request.pc_count#_#request.pc_image_id#')#">
</cfif>
</div>
</cfoutput>
</div>
<ul class="<cfoutput>#request.css_main_class#</cfoutput>Navigation">
<cfset request.pc_count=0>
<cfoutput query="request.qry_pc_items" group="fld_itemlist_id">
<cfset request.pc_count=request.pc_count + 1>
<cfif IsDefined("pcItem_#request.pc_content_id#_#request.pc_count#_#request.pc_image_id#")>
<li></li>
</cfif>
</cfoutput>
</ul>
<div class="<cfoutput>#request.css_main_class#</cfoutput>Descriptions">
<cfset request.pc_count=0>
<cfoutput query="request.qry_pc_items" group="fld_itemlist_id">
<cfset request.pc_count=request.pc_count + 1>
<cfif IsDefined( "pcItem_#request.pc_content_id#_#request.pc_count#_#request.pc_image_id#")>
<div>
<cfif IsDefined( "pcItem_#request.pc_content_id#_#request.pc_count#_#request.pc_description_id#")>
#Evaluate("pcItem_#request.pc_content_id#_#request.pc_count#_#request.pc_description_id#")#
</cfif>
</div>
</cfif>
</cfoutput>
</div>
<!-- optional -->
<a href="" class="<cfoutput>#request.css_main_class#</cfoutput>Anchor"></a>
<div class="<cfoutput>#request.css_main_class#</cfoutput>Overlay"></div>
</div>
<!--- END ROTATOR --->

Coldfusion Parameters

The parameters for the code above are based off of the Page Content variables used in the layout file. For this example, we're using the following variables:

The image: pcItem_1_1_1
The link: pcItem_1_1_2
The description: pcItem_1_1_3

For a more in-depth explanation of the "pcItem_1_1_1" variable format, please see the documentation on Page Content.

Variable Description
request.pc_content_id The sequential location of the "content" node. In the above variable format, it is the first number. ie: 1
request.pc_image_id The location of the "image" node. In the above variable format, it is the last number in "pcItem_1_1_1". ie: 1
request.pc_link_id The location of the "link" node. In the above variable format, it is the last number in "pcItem_1_1_2". ie: 2. If not available, set to '0' 
request.pc_description_id The location of the "description" node. In the above variable format, it is the last number in "pcItem_1_1_3". ie: 3. If not available, set to '0'
request.pc_video_id The location of the "video" node. In the above variable format, it is the last number in "pcItem_1_1_4". ie: 4. If not available, set to '0'
request.pc_video_width The width of the video (if applicable)
request.pc_video_height The height of the video (if applicable)
request.css_main_class The name of the CSS class for the Event box. This should be the same name as found in the mod_flashbox.xml file for this style.

Javascript code to initialize the rotator

After the Coldfusion, CSS and Javascript files have been added to the layout file, it's time to add the Javascript code to initialize the Event box to the end of the layout file before the closing </body> tag. Assuming a "css_main_class" of "rotator", the code will look like the following:

 var rotator = (function(){
  $$(".rotator").each(function(e) { 
    var eventbox_parameters = {
      type: "fade",
      duration: 0.5,
      delay: 5000,
      pauseOnMouseOver: false,
      setAsBackground: true
    };
    if (e.select(".rotatorNavigation li").size() == 1) {
      eventbox_parameters.startPaused = true;
    }
    new perpetuacms.eventbox(e, eventbox_parameters);
  });
}());

If there are multiple styles of Event boxes on the same page, add the new "css_main_class" as shown:

var rotator = (function(){
  $$(".rotator").each(function(e) {
    var eventbox_parameters = {
      type: "fade",
      duration: 0.5,
      delay: 5000,
      pauseOnMouseOver: false,
      setAsBackground: true
    };
    if (e.select(".rotatorNavigation li").size() == 1) {
      eventbox_parameters.startPaused = true;
    }
    new perpetuacms.eventbox(e, eventbox_parameters);
  });
  $$(".rotator2").each(function(e) {
    var eventbox_parameters = {
      type: "fade",
      duration: 1,
      pauseOnMouseOver: true,
      setAsBackground: true
    };
    if (e.select(".rotatorNavigation li").size() == 1) {
      eventbox_parameters.startPaused = true;
    }
    new perpetuacms.eventbox(e, eventbox_parameters);
  });
}());

To just use the default settings, you can use the following:

var rotator = (function(){
  $$(".rotator").each(function(e) {
    new perpetuacms.eventbox(e);
  });
}());

To give the client the option of Sequential, Random or Static in Page Content, we can add the following Coldfusion:

var rotator = (function(){
  $$(".rotator").each(function(e) {
    var eventbox_parameters = {
      type: "fade",
      duration: 0.5,
      delay: 5000,
      pauseOnMouseOver: false,
      setAsBackground: true,
      order: "<cfoutput>#request.pcAction_1#</cfoutput>"
      <cfif request.pcAction_1 EQ "static" OR request.pcAction_1 EQ "random">, startPaused: true</cfif>
    };
    if (e.select(".rotatorNavigation li").size() == 1) {
      eventbox_parameters.startPaused = true;
    }
    new perpetuacms.eventbox(e, eventbox_parameters);
  });
}());

Javascript Parameters

The Javascript parameters found in "default_parameters" are as follows:

Parameter Values Description
type fade [default]
slide_vertical
slide_horizontal
fade_delay
none
Type of effect used for the transition between slides
delay number in seconds. default: 3.0 Time in seconds that the slide will stay on the screen before transitioning to next slide
duration number in seconds. default: 0.5 Time in seconds that the transition will take to complete from start to finish
order sequential [default]
random
Order of slides
showEmptyDescriptions true
false [default]
If set to true, the containers of empty descriptions will be shown.
If set to false, the containers of empty descriptions will be hidden. 
pauseOnMouseOver true [default]
false
If set to true, the Event box will not transition to the next slide while the mouse is hovering over it
If set to false, the Event box will continue to transition to the next slide even if the mouse is over it 
effectDelay number in seconds. default: 0 Time in seconds that the second effect will last in multiple effect transitions (fade_delay only)
setAsBackground true
false [default]
Sets the image as the background of it's div container (example: Woodmen Valley homepage)
transitionDescriptions true [default]
false
If set to true, descriptions will transition with their slide
If set to false, descriptions will not transition with their slide
startPaused true
false [default]
If set to true, the eventbox will not auto-rotate until a play button is pressed
If set to false, the eventbox will rotate automatically when the page is loaded
firstSlide number. default: 1 The number of the first slide to display
slider { } See below for the slider parameter options
video { } See below for the video parameter options

 

Slider Parameters
In addition to the above base parameters, there are optional parameters that allow the navigation to be setup as a slider. This can be accomplished by setting these additional parameters within the "slider" parameter mentioned above:

Parameter Values Description
active true
false [default]
If set to true, the eventbox will attempt to make it's navigation into a slider
button_next class name Full classname of the navigation's next button
button_previous class name Full classname of the navigation's previous button
container class name Full classname of the navigation's (ul's) parent
orientation horizontal [default]
vertical
Direction of the slider.
step number. default: 4 Number of navigation places to move at a time
view number. default: 4 Number of navigation items that are shown at a time.
Note that this must be enforced with CSS (ie: overflow: hidden)

 

Video Parameters
When a slide might contain a video, the following additional parameters can be used to control what happens when the video is played. These parameters are set within the "video" parameter mentioned above:

Parameter Values Description
hideOverlay true
false [default]
If set to true, the eventbox will hide the Overlay and Anchor elements when it comes to a slide
which contains a video
If set to false, the eventbox will force the video to play in an inline popup (not implemented)

Note: The latest list of parameters can be found in the source of the developer demo.