public
Created

Implementation of Agile Slides: http://agiletech.ie/

  • Download Gist
gistfile1.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
<?php
class AgileSlides extends View {
/*
This class implements multiple slides and ajax buttons for next/prev
*/
public $step,$data;
 
function init(){
parent::init();
$this->step=$_GET[$this->name];
$this->js('mouseenter')->_selector('#'.$this->name.'_thumb')->find('i b')->fadeIn('fast');
$this->js('mouseleave')->_selector('#'.$this->name.'_thumb')->find('i b')->fadeOut('fast');
/*
$this->js('click')->_selector('#'.$this->name.'_thumb')->find('i b')->hide()
->univ()->dialogURL('Hi',$this->js()->_selectorThis()->attr('href'));
*/
 
$this->js('click',
$this->js()->atk4_loader(array('cut_object'=>$this->name))->atk4_loader('loadURL',$this->js()->_selectorThis()->attr('href'))
)->_selector('.slides-nav a');
 
if(isset($_GET[$this->name])){
$this->js(true)->_selector('#'.$this->name.'_thumb')->find('img')->hide()->fadeIn('slow');
}
}
 
function getNext(){
$s=$this->step+1;
if($s>=count($this->data))$s-=count($this->data);
 
return $this->api->getDestinationURL(null,array($this->name=>$s));
}
function getPrev(){
$s=$this->step-1;
if($s<0)$s+=count($this->data);
 
return $this->api->getDestinationURL(null,array($this->name=>$s));
}
function render(){
$this->template->set('prev',$this->getPrev());
$this->template->set('next',$this->getNext());
 
$d=$this->data[$this->step];
$this->template->set($d);
$this->template->set('thumb',$x=$this->api->locateURL('template',$d['thumb']));
$this->template->set('link',$this->api->getDestinationURL($d['page']));
 
parent::render();
}
function setSource($data){
$this->data=$data;
 
$this->step=$this->step% count($this->data);
 
foreach($this->data as $k=>$d){
// add bullet
$el=$this->add('View_HtmlElement',$k,'bullet')
->setElement('a')
->set('')
->setAttr('href',$this->api->getDestinationURL(null,array($this->name=>$k)))
;
if($_GET[$this->name]==$k)$el->addClass('current');
}
return $this;
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.