YiiFoundation
  • Namespace
  • Class
  • Tree

Namespaces

  • foundation
    • enum
    • exception
    • helpers
    • widgets
      • base
  • PHP

Classes

  • Alert
  • Breadcrumbs
  • Clearing
  • Dropdown
  • FlexVideo
  • Interchange
  • JoyRide
  • Magellan
  • Orbit
  • Pager
  • Reveal
  • Section
  • SwitchButton
  • Tooltip
  • TopBar
 1 <?php
 2 /**
 3  * @copyright Copyright &copy; 2amigOS! Consulting Group 2013-
 4  * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
 5  * @package foundation.components
 6  * @version 1.0.0
 7  */
 8 namespace foundation\widgets;
 9 
10 /**
11  * InterChange utilizes the data-interchange attribute for specifying your media queries and their respective images.
12  *
13  * @see http://foundation.zurb.com/docs/components/interchange.html
14  *
15  * @author Antonio Ramirez <amigo.cobos@gmail.com>
16  * @package foundation\widgets
17  */
18 class Interchange extends base\Widget
19 {
20     /**
21      * @var string the image source
22      */
23     public $src;
24     /**
25      * @var array interchange rules. The syntax is:
26      *
27      * <pre>
28      *  'iterchange' => array(
29      *      array('pathtoimage', 'rule'),
30      *      array('pathtoimage', 'rule')
31      * )
32      * </pre>
33      */
34     public $rules = array();
35 
36 
37     /**
38      * Initializes the widget
39      */
40     public function init()
41     {
42         $this->assets = array(
43             'js' => YII_DEBUG ? 'foundation/foundation.interchange.js' : 'foundation.min.js'
44         );
45 
46         $this->htmlOptions['src'] = $this->src;
47 
48         parent::init();
49     }
50 
51     /**
52      * Renders the widget
53      */
54     public function run()
55     {
56         echo $this->renderImage();
57     }
58 
59     /**
60      * Renders the interchange image
61      * @return string the resulting img tag
62      */
63     public function renderImage()
64     {
65         $rules = array();
66         foreach ($this->rules as $rule) {
67             $rules[] = '[' . implode(", ", $rule) . ']';
68         }
69         $this->htmlOptions['data-interchange'] = implode(", ", $rules);
70         return \CHtml::tag('img', $this->htmlOptions);
71     }
72 }
YiiFoundation API documentation generated by ApiGen 2.8.0