phpMv -UI toolkit 2.4.12
jQuery, jQuery UI, Twitter Bootstrap and Semantic-UI library for php & php MVC Frameworks
Loading...
Searching...
No Matches
Dialog.php
Go to the documentation of this file.
1<?php
2namespace Ajax\ui\components;
3
6
13class Dialog extends SimpleComponent {
14
15 protected $attachTo;
16
17 protected $buttons = array();
18
19 public function __construct(JsUtils $js) {
20 parent::__construct($js);
21 $this->params = array(
22 "dialogClass" => "no-close"
23 );
24 $this->addCancelBtn("Annuler");
25 }
26
27 public function getScript() {
28 $allParams = $this->params;
29 $jsonButtons = array();
30 foreach ($this->buttons as $button) {
31 $jsonButtons[] = $button->getParams();
32 }
33 $allParams["buttons"] = $jsonButtons;
34 $this->jquery_code_for_compile[] = "$( '" . $this->attachTo . "' ).dialog(" . $this->getParamsAsJSON($allParams) . ");";
35 $result = implode("", $this->jquery_code_for_compile);
36 $result = str_ireplace("\"%", "", $result);
37 $result = str_ireplace("%\"", "", $result);
38 $result = str_ireplace("\\n", "", $result);
39 $result = str_ireplace("\\t", "", $result);
40 return $result;
41 }
42
48 public function attach($identifier) {
49 $this->attachTo = $identifier;
50 }
51
52 public function addCancelBtn($caption = "Annuler", $position = NULL) {
53 $this->insertBtn(DialogButton::cancelButton($caption), $position);
54 }
55
56 public function addSubmitBtn(JsUtils $js, $url, $form, $responseElement, $caption = "Valider", $position = NULL) {
57 $this->insertBtn(DialogButton::submitButton($js, $url, $form, $responseElement, $caption), $position);
58 }
59
60 public function addButton($caption, $jsCode, $position = NULL) {
61 $this->insertBtn(new DialogButton($caption, $jsCode), $position);
62 }
63
64 private function insertBtn($insert, $position = NULL) {
65 if ($position != NULL) {
66 $this->buttons = array_splice($this->buttons, $position, 0, $insert);
67 } else {
68 $this->buttons[] = $insert;
69 }
70 }
71}
JQuery PHP library.
Definition JsUtils.php:23
Base component for JQuery UI visuals components.
JQuery UI Button for the Dialog Component.
static submitButton(JsUtils $js, $url, $form, $responseElement, $caption="Okay", $parameters=[])
static cancelButton($caption="Annuler")
JQuery UI Dialog Component.
Definition Dialog.php:13
insertBtn($insert, $position=NULL)
Definition Dialog.php:64
attach($identifier)
Definition Dialog.php:48
addButton($caption, $jsCode, $position=NULL)
Definition Dialog.php:60
addCancelBtn($caption="Annuler", $position=NULL)
Definition Dialog.php:52
__construct(JsUtils $js)
Definition Dialog.php:19
addSubmitBtn(JsUtils $js, $url, $form, $responseElement, $caption="Valider", $position=NULL)
Definition Dialog.php:56