Passed
Push — master ( 0da08b...5a8334 )
by Jean-Christophe
01:41
created
Ajax/semantic/html/modules/checkbox/AbstractCheckbox.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
 
8 8
 abstract class AbstractCheckbox extends HtmlSemDoubleElement {
9 9
 
10
-	protected $_params = [];
10
+	protected $_params=[];
11 11
 
12
-	public function __construct($identifier, $name = NULL, $label = NULL, $value = NULL, $inputType = "checkbox", $type = "checkbox") {
13
-		parent::__construct("ck-" . $identifier, "div", "ui " . $type);
14
-		$this->_identifier = $identifier;
15
-		$field = new \Ajax\common\html\html5\HtmlInput($identifier, $inputType, $value);
12
+	public function __construct($identifier, $name=NULL, $label=NULL, $value=NULL, $inputType="checkbox", $type="checkbox") {
13
+		parent::__construct("ck-".$identifier, "div", "ui ".$type);
14
+		$this->_identifier=$identifier;
15
+		$field=new \Ajax\common\html\html5\HtmlInput($identifier, $inputType, $value);
16 16
 		$field->setProperty("name", $name);
17 17
 		$this->setField($field);
18 18
 		if (isset($label))
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
 		$this->setLibraryId($identifier);
21 21
 	}
22 22
 
23
-	public function setChecked($value = true) {
24
-		if ($value === true) {
23
+	public function setChecked($value=true) {
24
+		if ($value===true) {
25 25
 			$this->getField()->setProperty("checked", "checked");
26 26
 		} else {
27 27
 			$this->getField()->removeProperty("checked");
@@ -33,21 +33,21 @@  discard block
 block discarded – undo
33 33
 		return $this->addToPropertyCtrl("class", $checkboxType, CheckboxType::getConstants());
34 34
 	}
35 35
 
36
-	public function setLabel($label, $value = null) {
37
-		$labelO = $label;
36
+	public function setLabel($label, $value=null) {
37
+		$labelO=$label;
38 38
 		if (\is_string($label)) {
39
-			$labelO = new HtmlSemDoubleElement("", "label", "");
39
+			$labelO=new HtmlSemDoubleElement("", "label", "");
40 40
 			$labelO->setContent($label);
41 41
 			$labelO->setProperty("for", $this->getField()
42 42
 				->getIdentifier());
43 43
 			if (isset($value))
44 44
 				$labelO->setProperty("data-value", $value);
45 45
 		}
46
-		$this->content["label"] = $labelO;
46
+		$this->content["label"]=$labelO;
47 47
 	}
48 48
 
49 49
 	public function setField($field) {
50
-		$this->content["field"] = $field;
50
+		$this->content["field"]=$field;
51 51
 	}
52 52
 
53 53
 	/**
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
 	 * puts the label before or behind
74 74
 	 */
75 75
 	public function swapLabel() {
76
-		$label = $this->getLabel();
76
+		$label=$this->getLabel();
77 77
 		unset($this->content["label"]);
78
-		$this->content["label"] = $label;
78
+		$this->content["label"]=$label;
79 79
 	}
80 80
 
81 81
 	public function setReadonly() {
@@ -92,13 +92,13 @@  discard block
 block discarded – undo
92 92
 	 *        	action to execute : check, uncheck or NULL for toggle
93 93
 	 * @return AbstractCheckbox
94 94
 	 */
95
-	public function attachEvent($selector, $action = NULL) {
96
-		if (isset($action) || \is_numeric($action) === true) {
97
-			$js = '$("#%identifier%").checkbox("attach events", "' . $selector . '", "' . $action . '");';
95
+	public function attachEvent($selector, $action=NULL) {
96
+		if (isset($action) || \is_numeric($action)===true) {
97
+			$js='$("#%identifier%").checkbox("attach events", "'.$selector.'", "'.$action.'");';
98 98
 		} else {
99
-			$js = '$("#%identifier%").checkbox("attach events", "' . $selector . '");';
99
+			$js='$("#%identifier%").checkbox("attach events", "'.$selector.'");';
100 100
 		}
101
-		$js = \str_replace("%identifier%", $this->identifier, $js);
101
+		$js=\str_replace("%identifier%", $this->identifier, $js);
102 102
 		return $this->executeOnRun($js);
103 103
 	}
104 104
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	 *        	associative array of events to attach ex : ["#bt-toggle","check"=>"#bt-check","uncheck"=>"#bt-uncheck"]
110 110
 	 * @return AbstractCheckbox
111 111
 	 */
112
-	public function attachEvents($events = array()) {
112
+	public function attachEvents($events=array()) {
113 113
 		if (\is_array($events)) {
114 114
 			foreach ($events as $action => $selector) {
115 115
 				$this->attachEvent($selector, $action);
@@ -123,23 +123,23 @@  discard block
 block discarded – undo
123 123
 	}
124 124
 
125 125
 	public function setOnChecked($jsCode) {
126
-		$this->_params["onChecked"] = $jsCode;
126
+		$this->_params["onChecked"]=$jsCode;
127 127
 		return $this;
128 128
 	}
129 129
 
130 130
 	public function setOnUnchecked($jsCode) {
131
-		$this->_params["onUnchecked"] = $jsCode;
131
+		$this->_params["onUnchecked"]=$jsCode;
132 132
 		return $this;
133 133
 	}
134 134
 
135 135
 	public function setOnChange($jsCode) {
136
-		$this->_params["onChange"] = $jsCode;
136
+		$this->_params["onChange"]=$jsCode;
137 137
 		return $this;
138 138
 	}
139 139
 
140 140
 	public function run(JsUtils $js) {
141
-		if (! isset($this->_bsComponent))
142
-			$this->_bsComponent = $js->semantic()->checkbox("#" . $this->identifier, $this->_params);
141
+		if (!isset($this->_bsComponent))
142
+			$this->_bsComponent=$js->semantic()->checkbox("#".$this->identifier, $this->_params);
143 143
 		return parent::run($js);
144 144
 	}
145 145
 }
Please login to merge, or discard this patch.