summaryrefslogtreecommitdiffstats
path: root/admin/survey/classes/objects/obj.PopUpButton.php
blob: bb39d83634d16e34071464309616800b118267f2 (plain) (blame)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php 
/**
 * 
 * @author veselicg
 *
 * Večina funkcij vrača sam klass da omogočamo chaining
 * 
 * Primer uporabe:
 * 	
 *		$popUp = new PopUp();
 *
 *		# določimo naslovno vrstico popupa. če ni podano je ne prikazuje
 *		$popUp -> setHeaderText('Moj PopUp:')
 *				
 *				# določimo id diva (..<div id="nek_id_diva"...)
 *			   -> setId('nek_id_diva')
 *				
 *				# po potrebi dodamo css je (..<div class="css1 css2"...)
 *			   -> addCss('css1')
 *			   -> addCss('css2')
 *
 *				#dodamo vsebino (osrednji del) popupa
 *			   -> setContent($content);
 *		
 *		# dodamo gumb Prekliči - je standarden gumb
 *		$popUp->addButton(new PopUpCancelButton());
 *
 *	
 *		#dodamo gumb izberi profil
 *		$button = new PopUpButton($lang['srv_save_profile']);
 *		$button -> setFloat('right')
 *				-> setButtonColor('orange')
 *				-> addAction('onClick','changeColectDataStatus(); return false;');
 *		$popUp->addButton($button);
 *
 *		# izrišemo div
 *		echo $popUp; # lahko tudi $popUp->display();
 * 
 */

/** Gumbi
 * 
 * 
 */
class PopUpButton
{
	# tekst gumba
	private $_caption = null;
	#mouse over title gumba, privzeto je enak caption
	private $_title = null;
	private $_float = 'floatLeft';
	private $_space = 'spaceLeft';
	
	private $_buttonColor = 'white-blue';
	private $_actions = array();
	
	public function __construct($caption = null)
	{
		$this->setCaption($caption);
		
		# for chaining
		return $this;
	}
	
	public function setCaption($caption)
	{
		$this->_caption = $caption;
		# če title ni nastavljen ga nastavimo enako kot caption
		if ($this->_title === null)
		{
			$this->setTitle($caption);
		}
		
		# for chaining
		return $this;
		
	}

	public function setTitle($title)
	{
		$this->_title = $title;
		
		# for chaining
		return $this;
		
	}
	
	public function setFloat($float = 'Left')
	{
		$this->_float = 'float'.ucfirst($float); 
		$this->_space = 'space'.ucfirst($float);
		
		# for chaining
		return $this;
		
	}
	
	public function setButtonColor($buttonColor)
	{
		switch ($buttonColor) {
			case 'orange':
				$this->_buttonColor = 'blue';
			break;
			
			case 'white-black':
				$this->_buttonColor = 'white-black';
			break;

			default:
				$this->_buttonColor = 'white-blue';
			break;
		}
		
		
		# for chaining
		return $this;
	}
	
	public function addAction($actionTriger, $action)
	{
		$this->_actions[] = $actionTriger.'="'.$action.'"';
		
		# for chaining
		return $this;
	}
	
	public function __toString() {
		$str  = '<button class="medium '.$this->_buttonColor.'" title="'.$this->_title.'" '.implode(' ', $this->_actions).'>';
		$str .=     $this->_caption;
		$str .= '</button>';

		return $str;
	}
}