phpMv -UI toolkit 2.4.12
jQuery, jQuery UI, Twitter Bootstrap and Semantic-UI library for php & php MVC Frameworks
Loading...
Searching...
No Matches
HtmlInputgroup.php
Go to the documentation of this file.
1<?php
2
3namespace Ajax\bootstrap\html;
4
8
15 protected $addonLeft=null;
16 protected $addonRight=null;
17 protected $mClass="input-group";
18
19 public function __construct($identifier) {
20 parent::__construct($identifier);
21 $this->_template=include 'templates/tplInputgroup.php';
22 }
23
24 public function createSpan($text, $position="left") {
25 $id=$position."-".$this->identifier;
26 $span=new HtmlBsDoubleElement($id);
27 $span->setTagName("span");
28 $this->setProperty("aria-describedby", $id);
29 $span->setContent($text);
30 $span->setClass("input-group-addon");
31 if (strtolower($position)==="left")
32 $this->addonLeft=$span;
33 else
34 $this->addonRight=$span;
35 return $span;
36 }
37
38 protected function addInput_($input, $label="", $position="left") {
39 $span=$this->createSpan("", $position);
40 $span->setClass("input-group-addon");
41 $input->setProperty("aria-label", $label);
42 $span->setContent($input);
43 return $span;
44 }
45
46 protected function addButton_($button, $value="", $position="left") {
47 $span=$this->createSpan("", $position);
48 $span->setClass("input-group-btn");
49 $span->setTagName("div");
50 $button->setValue($value);
51 $span->setContent($button);
52 return $span;
53 }
54
55 public function createRadio($identifier, $label="", $position="left") {
56 return $this->addInput_(new HtmlInputRadio($identifier), $label, $position);
57 }
58
59 public function createCheckbox($identifier, $label="", $position="left") {
60 return $this->addInput_(new HtmlInputCheckbox($identifier), $label, $position);
61 }
62
63 public function createButton($identifier, $value="", $position="left") {
64 return $this->addButton_(new HtmlButton($identifier), $value, $position);
65 }
66
67 public function createButtons($items, $position="left") {
68 $span=$this->createSpan("", $position);
69 $span->setClass("input-group-btn");
70 $span->setTagName("div");
71 $buttons=array();
72 $i=1;
73 foreach ($items as $item){
74 $bt=NULL;
75 if(is_string($item)){
76 $bt=new HtmlButton($this->identifier."-bt-".$i++,$item);
77 }elseif ($item instanceof HtmlButton){
78 $bt=$item;
79 }
80 if(isset($bt)){
81 $buttons[]=$bt;
82 }
83 }
84 $span->setContent($buttons);
85 return $span;
86 }
87 protected function addDropdown_(HtmlDropdown $dropdown, $caption="", $position="left", $items=array()) {
88 $dropdown->setBtnCaption($caption);
89 $dropdown->fromArray($items);
90
91 if (strtolower($position)==="left")
92 $this->addonLeft=$dropdown;
93 else
94 $this->addonRight=$dropdown;
95 return $dropdown;
96 }
97
98 public function createDropdown($identifier, $caption="", $position="left", $items=array()) {
99 $dropdown=new HtmlDropdown($identifier);
100 $dropdown->setMTagName("div");
101 $dropdown->setTagName("button");
102 $dropdown->setMClass("input-group-btn");
103 return $this->addDropdown_($dropdown, $caption, $position, $items);
104 }
105
106 public function createSplitButton($identifier, $caption="", $position="left", $items=array()) {
107 $dropdown=new HtmlSplitbutton($identifier);
108 $dropdown->setTagName("button");
109 $dropdown->setMClass("input-group-btn");
110 $dropdown->setMTagName("div");
111 return $this->addDropdown_($dropdown, $caption, $position, $items);
112 }
113
120 public function setSize($size) {
121 if (is_int($size)) {
122 return $this->addToMemberCtrl($this->mClass, CssRef::sizes("input-group")[$size],CssRef::sizes("input-group"));
123 }
124 return $this->addToMemberCtrl($this->mClass, $size, CssRef::sizes("input-group"));
125 }
126
127 public function run(JsUtils $js) {
128 parent::run($js);
129 if (isset($this->addonLeft))
130 $this->addonLeft->run($js);
131 if (isset($this->addonRight))
132 $this->addonRight->run($js);
133 }
134
135}
JQuery PHP library.
Definition JsUtils.php:23
Twitter Bootstrap Button component.
Twitter Bootstrap HTML Dropdown component.
setMTagName($value)
Define the tagName of the main element.
setTagName($tagName)
Sets the tagName's dropdown.
Twitter Bootstrap HTML Input checkbox component.
Twitter Bootstrap simple Input component.
Definition HtmlInput.php:13
Twitter Bootstrap HTML Input radio component.
Twitter Bootstrap HTML Inputgroup component.
addButton_($button, $value="", $position="left")
run(JsUtils $js)
SimpleExtComponent\Ajax\common\html\BaseHtmlrun()\Ajax\common\html\BaseHtmlrun()
addInput_($input, $label="", $position="left")
createButton($identifier, $value="", $position="left")
createSplitButton($identifier, $caption="", $position="left", $items=array())
createButtons($items, $position="left")
createCheckbox($identifier, $label="", $position="left")
createRadio($identifier, $label="", $position="left")
createSpan($text, $position="left")
setSize($size)
define the elements size available values : "input-group-lg","","input-group-sm","input-group-xs"
addDropdown_(HtmlDropdown $dropdown, $caption="", $position="left", $items=array())
createDropdown($identifier, $caption="", $position="left", $items=array())
Twitter Bootstrap HTML Splitbutton component.
Default HTML values for Twitter Bootstrap HTML components.
Definition CssRef.php:12
addToMemberCtrl(&$name, $value, $typeCtrl, $separator=" ")
Definition BaseHtml.php:89