88 <script type=
"text/javascript">
89 function <?echo $this->
id?>_toggleDD(elt)
91 elt = document.id(elt);
92 var body = elt.getNext(
"dd");
94 if (elt.hasClass(
"expanded"))
97 elt.removeClass(
"expanded");
102 if ($this->mode ==
"accordion")
105 elt.getParent().getChildren(
"dt.expanded").each(
function(e) { var b = e.getNext(
"dd"); b.dissolve(); e.removeClass(
"expanded"); });
109 if (body.get(
'data-url') && body.get(
'html') ==
'')
111 var cursor = elt.getStyle(
'cursor');
113 elt.setStyle(
'cursor',
'progress');
115 body.reload(
function()
118 elt.addClass(
"expanded");
119 elt.setStyle(
'cursor', cursor);
121 if ($this->scrollOnExpand)
124 window.scrollToElement(elt, <?php echo $this->scrollOffset?>);
133 elt.addClass(
"expanded");
135 if ($this->scrollOnExpand)
138 window.scrollToElement(elt, <?php echo $this->scrollOffset?>);
146 window.addEvent(
'domready',
function()
148 document.getElements(
"dl.expanding_list dd.expanded[data-url!='']").each(
function(panel)
151 panel.removeClass(
'expanded');
156 $script = ob_get_contents();
166 if (!count($this->items))
168 echo
"<p>{$this->emptyMessage}</p>";
179 if ($this->CSSclass) $attrs .=
" class='{$this->CSSclass}'";
180 if ($this->styles) $attrs .=
" style='{$this->styles}'";
182 <dl
id=
"<?echo $this->id?>"<?echo $attrs?>>
186 foreach($this->items as $item)
188 if (is_callable($this->onItemStart))
190 $ret = call_user_func($this->onItemStart, $item);
191 if ($ret ===
false)
continue;
198 if (is_callable($this->isItemExpanded))
200 $expanded = call_user_func($this->isItemExpanded, $item, $idx);
205 $dtState =
"class='expanded {$ret}'";
206 $ddState =
"style='' class='{$ret}'";
210 $dtState =
"class='{$ret}'";
211 $ddState =
"style='display: none' class='{$ret}'";
214 echo
"<dt{$titleID} {$dtState} onclick='return {$this->id}_toggleDD(this);'>";
216 if (is_callable($this->titleFormat))
218 echo call_user_func($this->titleFormat, $item);
220 else echo $item->format($this->titleFormat);
224 if (is_callable($this->bodyFormat))
226 $body = call_user_func($this->bodyFormat, $item);
228 else $body = $item->format($this->bodyFormat);
230 if ($this->dynamicLoad)
232 echo
"<dd{$bodyID} {$dtState} {$ddState} data-url='{$body}'></dd>";
236 echo
"<dd{$bodyID} {$ddState}>{$body}</dd>";
250 if ($this->CSSclass) $attrs .=
" class='{$this->CSSclass}'";
251 if ($this->styles) $attrs .=
" style='{$this->styles}'";
255 foreach($this->items as $group =>
$items)
258 <<?echo $this->groupTag?>
class=
'expanding_list_group'><?echo $group?></<?echo $this->groupTag?>>
259 <dl
id=
"<?echo $this->id?>_<?echo codify($group)?>"<?echo $attrs?>>
265 if (is_callable($this->onItemStart))
267 if (call_user_func($this->onItemStart, $item) ===
false)
continue;
274 if (is_callable($this->isItemExpanded))
276 $expanded = call_user_func($this->isItemExpanded, $item, $idx, $groupIdx);
281 $dtState =
"class='expanded'";
282 $ddState =
"style=''";
287 $ddState =
"style='display: none'";
290 echo
"<dt{$titleID} {$dtState} onclick='return {$this->id}_toggleDD(this);'>";
292 if (is_callable($this->titleFormat))
294 echo call_user_func($this->titleFormat, $item);
296 else echo $item->format($this->titleFormat);
300 if (is_callable($this->bodyFormat))
302 $body = call_user_func($this->bodyFormat, $item);
304 else $body = $item->format($this->bodyFormat);
306 if ($this->dynamicLoad)
308 echo
"<dd{$bodyID} {$dtState} {$ddState} data-url='{$body}'></dd>";
312 echo
"<dd{$bodyID} {$ddState}>{$body}</dd>";
The ExpandingList class provides a simple User Interface control to allow the display of list items b...
$styles
Specific CSS styles to be applied to the list.
drawGroupedList()
Draws a set of grouped expanding lists.
$emptyMessage
Message to display when the list is empty.
$grouped
Flag indicating whether list should be grouped.
$CSSclass
CSS class(es) to be applied to the list.
$bodyFormat
The formatter used to display the list item bodies (either a format string or a callback function or ...
$isItemExpanded
Callback hook to determine if an item should be shown expanded by default. Callback is passed the ite...
$onItemStart
Callback hook called when starting to display each item. Return false to skip the item.
$titleIDFormat
Format template for title ID field.
ExpandingList($items, $id="expanding_list", $titleFormat=null, $bodyFormat=null, $dynamicLoad=false)
Creates a new ExpandingList control.
$titleFormat
The formatter used to display the list item titles (either a format string or a callback function or ...
drawList()
Generates the HTML for the expanding list.
$scrollOnExpand
Flag indicating whether to scroll the expanding item to the top of the screen.
$bodyIDFormat
Format template for body ID field.
$id
The HTML id of the list.
$items
The items to be displayed in the list.
$groupTag
Grouping tag type.
$scrollOffset
Offset from top of element when scrolling (to take into account fixed navigation bars,...
$dynamicLoad
Flag indicating whether list should load content on demand. If set to true, bodyFormat should provide...
writeScript()
Writes the supporting Javascript for an expanding list control.
$mode
The expansion mode for the list - set to "accordion" to have only one item open at a time.