Class ::xowiki::includelet::yui-carousel
::xowiki::includelet::yui-carousel
create ... \
[ -parameter_declaration (default "
{-title ""}
{-item_size 600x400}
{-image_size}
{-num_visible 1}
{-play_interval 0}
{-auto_size 0}
{-folder}
{-glob ""}
{-form ""}
") ]
Include YUI carousel showing the pages of the specified or
current folder.
Defined in /var/www/openacs/packages/xowiki/tcl/includelet-procs.tclClass Relations
- class: ::xowiki::IncludeletClass
![[i]](/resources/acs-subsite/ZoomIn16.gif)
- superclass: ::xowiki::Includelet
![[i]](/resources/acs-subsite/ZoomIn16.gif)
::xowiki::IncludeletClass create ::xowiki::includelet::yui-carousel \
-superclass ::xowiki::Includelet
Methods (to be applied on instances)
form_images (scripted)
set form_item_ids [::$package_id instantiate_forms -parent_id $parent_id -forms $form]
if {$form_item_ids eq ""} {error "could not find en:photo.form"}
set form_item_id [lindex $form_item_ids 0]
set items [::xowiki::FormPage get_form_entries -base_item_ids $form_item_ids -form_fields "" -publish_status all -always_queried_attributes * -parent_id $parent_id -package_id $package_id]
foreach entry [$items children] {
set image_name [$entry property image]
if {$glob ne "" && ![string match $glob $image_name]} {
$items delete $entry
continue
}
if {![info exists entry_field_names]} {
set entry_field_names [$entry field_names]
set entry_form_fields [::xowiki::FormPage get_table_form_fields -base_item $form_item_id -field_names $entry_field_names -form_constraints [::$form_item_id set form_constraints]]
foreach fn $entry_field_names f $entry_form_fields {set ff($fn) $f}
}
$entry load_values_into_form_fields $entry_form_fields
foreach f $entry_form_fields {$f object $entry}
if {[info exists ff(image)]} {
if {$width ne ""} {$ff(image) width $width}
if {$height ne ""} {$ff(image) height $height}
if {$width ne "" && $height ne ""} {
$ff(image) set geometry "${width}x${height}"
}
$ff(image) label [$entry property _title]
}
$entry set html [$entry render_content]
}
return $itemsimages (scripted)
set size_info ""
if {$width ne ""} {append size_info " width='[ns_quotehtml $width]'"}
if {$height ne ""} {append size_info " height='[ns_quotehtml $height]'"}
if {$width ne "" && $height ne ""} {
set geometry "?geometry=${width}x${height}"
} else {
set geometry ""
}
set listing [::xowiki::Includelet listing -package_id $package_id -parent_id $parent_id -use_package_path false -extra_where_clause " and mime_type like 'image/%'" -orderby "name asc" -glob $glob]
foreach entry [$listing children] {
$entry class ::xowiki::Page
$entry set html "<img src='[$entry pretty_link -download true]$geometry' $size_info> <h2>[$entry title]</h2>"
}
return $listingparameter_declaration (setter)
render (scripted)
:get_parameters
set ajaxhelper 1
::xowiki::Includelet require_YUI_CSS -ajaxhelper $ajaxhelper carousel/assets/skins/sam/carousel.css
::xowiki::Includelet require_YUI_JS -ajaxhelper $ajaxhelper "yahoo-dom-event/yahoo-dom-event.js"
::xowiki::Includelet require_YUI_JS -ajaxhelper $ajaxhelper "connection/connection-min.js"
::xowiki::Includelet require_YUI_JS -ajaxhelper $ajaxhelper "animation/animation-min.js"
::xowiki::Includelet require_YUI_JS -ajaxhelper $ajaxhelper "element/element-min.js"
::xowiki::Includelet require_YUI_JS -ajaxhelper $ajaxhelper "carousel/carousel-min.js"
::xo::Page set_property body class "yui-skin-sam "
if {![regexp {^(.*)x(.*)$} $item_size _ item_width item_height]} {
error "invalid item size '$item_size'; use e.g. 300x240"
}
if {[info exists image_size]} {
if {![regexp {^(.*)x(.*)$} $image_size _ width height]} {
error "invalid image size '$image_size'; use e.g. 300x240"
}
} elseif {$auto_size} {
set width $item_width
set height $item_height
} else {
set width ""
set height ""
}
set ID container_[::xowiki::Includelet html_id [self]]
set play_interval [expr {int($play_interval * 1000)}]
::xo::Page requireJS [subst {
YAHOO.util.Event.onDOMReady(function (ev) {
var carousel = new YAHOO.widget.Carousel("$ID",{
isCircular: true, numVisible: $num_visible,
autoPlayInterval: $play_interval, animation: {speed: 1.0}
});
carousel.render(); // get ready for rendering the widget
carousel.show(); // display the widget
});
}]
::xo::Page requireStyle [subst {
\#$ID {
margin: 0 auto;
}
.yui-carousel-element .yui-carousel-item-selected {
opacity: 1;
}
.yui-carousel-element li {
height: ${item_height}px;
width: ${item_width}px;
}
.yui-skin-sam .yui-carousel-nav ul li {
margin: 0;
}}]
set parent_id [${:__including_page} parent_id]
if {[info exists folder]} {
set folder_page [::$package_id get_page_from_item_ref -parent_id $parent_id $folder]
if {$folder_page eq ""} {
error "no such folder '$folder'"
} else {
set parent_id [$folder_page item_id]
}
}
set content "<div id='[ns_quotehtml $ID]'><ol>\n"
if {$form ne ""} {
set images [:form_images -package_id $package_id -parent_id $parent_id -form $form -glob $glob -width $width -height $height]
} else {
set images [:images -package_id $package_id -parent_id $parent_id -glob $glob -width $width -height $height]
}
foreach entry [$images children] {
append content "<li class='item'> [$entry set html] </li>\n"
}
append content "</ol></div>\n<div id='spotlight'></div>\n"
return $content