2020-08-14 13:36:36 +02:00
|
|
|
<?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();
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
class PopUp
|
|
|
|
{
|
|
|
|
private $_id = null;
|
|
|
|
private $_css = array('divPopUp');
|
|
|
|
|
|
|
|
private $_headerText = null;
|
|
|
|
private $_content = null;
|
|
|
|
private $_buttons = array();
|
|
|
|
|
|
|
|
protected $_displayed = false;
|
|
|
|
|
|
|
|
public function setId($id)
|
|
|
|
{
|
|
|
|
$this->_id = $id;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function addCss($css)
|
|
|
|
{
|
|
|
|
$this->_css[] = $css;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setHeaderText($headerText)
|
|
|
|
{
|
|
|
|
$this->_headerText = $headerText;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setContent($content)
|
|
|
|
{
|
|
|
|
$this->_content = $content;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function addContent($content)
|
|
|
|
{
|
|
|
|
$this->_content .= $content;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function addButton(PopUpButton $button)
|
|
|
|
{
|
|
|
|
$this->_buttons[] = $button;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2022-02-21 11:23:05 +01:00
|
|
|
public function display(){
|
|
|
|
|
2020-08-14 13:36:36 +02:00
|
|
|
$this->_displayed = true;
|
|
|
|
|
|
|
|
#začnemo osnovni div
|
|
|
|
echo '<div';
|
2022-02-21 11:23:05 +01:00
|
|
|
if ($this->_id != null){
|
2020-08-14 13:36:36 +02:00
|
|
|
echo ' id="'.$this->_id.'"';
|
|
|
|
}
|
2022-02-21 11:23:05 +01:00
|
|
|
if (count($this->_css) > 0){
|
2020-08-14 13:36:36 +02:00
|
|
|
echo ' class="'. implode(' ',$this->_css).'"';
|
|
|
|
}
|
|
|
|
echo '>';
|
2022-02-21 11:23:05 +01:00
|
|
|
|
2020-08-14 13:36:36 +02:00
|
|
|
|
|
|
|
#dodamo header
|
2022-02-21 11:23:05 +01:00
|
|
|
if ($this->_headerText != null){
|
2020-08-14 13:36:36 +02:00
|
|
|
echo '<div class="divPopUp_top">';
|
|
|
|
echo $this->_headerText;
|
|
|
|
echo '</div>'; #PM_top
|
2022-05-05 22:16:40 +02:00
|
|
|
|
|
|
|
echo '<div class="popup_close"><a href="#" onClick="$(\'#fade\').fadeOut(\'slow\');$(\'#fullscreen\').fadeOut(\'slow\').html(\'\'); return false;">✕</a></div>';
|
2020-08-14 13:36:36 +02:00
|
|
|
}
|
|
|
|
|
2022-02-21 11:23:05 +01:00
|
|
|
|
2020-08-14 13:36:36 +02:00
|
|
|
#dodamo vsebino - content
|
2022-02-21 11:23:05 +01:00
|
|
|
echo '<div class="popup_main">';
|
2020-08-14 13:36:36 +02:00
|
|
|
echo $this->_content;
|
2022-02-21 11:23:05 +01:00
|
|
|
echo '</div>';
|
2020-08-14 13:36:36 +02:00
|
|
|
|
2022-02-21 11:23:05 +01:00
|
|
|
|
|
|
|
# div z gumbi
|
|
|
|
echo '<div class="button_holder">';
|
2020-08-14 13:36:36 +02:00
|
|
|
if (count($this->_buttons) > 0) {
|
2022-02-21 11:23:05 +01:00
|
|
|
foreach ($this->_buttons AS $button){
|
2020-08-14 13:36:36 +02:00
|
|
|
echo $button;
|
|
|
|
}
|
|
|
|
}
|
2022-02-21 11:23:05 +01:00
|
|
|
echo '</div>';
|
2020-08-14 13:36:36 +02:00
|
|
|
|
2022-02-21 11:23:05 +01:00
|
|
|
|
|
|
|
#zaključimo osnovni div
|
2020-08-14 13:36:36 +02:00
|
|
|
echo '</div>';
|
2022-02-21 11:23:05 +01:00
|
|
|
|
2020-08-14 13:36:36 +02:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function __toString() {
|
|
|
|
ob_start();
|
|
|
|
$this->display();
|
|
|
|
$content = ob_get_clean();
|
|
|
|
return $content;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function __destruct() {
|
|
|
|
if ($this->_displayed == false)
|
|
|
|
{
|
|
|
|
$this->display();
|
|
|
|
}
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
}
|