| 1 | <?php |
|---|
| 2 | /** |
|---|
| 3 | * The abstract QSelectableGen class defined here is |
|---|
| 4 | * code-generated and contains options, events and methods scraped from the |
|---|
| 5 | * JQuery UI documentation Web site. It is not generated by the typical |
|---|
| 6 | * codegen process, but rather is generated periodically by the core QCubed |
|---|
| 7 | * team and checked in. However, the code to generate this file is |
|---|
| 8 | * in the assets/_core/php/_devetools/jquery_ui_gen/jq_control_gen.php file |
|---|
| 9 | * and you can regenerate the files if you need to. |
|---|
| 10 | * |
|---|
| 11 | * The comments in this file are taken from the JQuery UI site, so they do |
|---|
| 12 | * not always make sense with regard to QCubed. They are simply provided |
|---|
| 13 | * as reference. Note that this is very low-level code, and does not always |
|---|
| 14 | * update QCubed state variables. See the QSelectableBase |
|---|
| 15 | * file, which contains code to interface between this generated file and QCubed. |
|---|
| 16 | * |
|---|
| 17 | * Because subsequent re-code generations will overwrite any changes to this |
|---|
| 18 | * file, you should leave this file unaltered to prevent yourself from losing |
|---|
| 19 | * any information or code changes. All customizations should be done by |
|---|
| 20 | * overriding existing or implementing new methods, properties and variables |
|---|
| 21 | * in the QSelectable class file. |
|---|
| 22 | * |
|---|
| 23 | */ |
|---|
| 24 | |
|---|
| 25 | /* Custom event classes for this control */ |
|---|
| 26 | |
|---|
| 27 | |
|---|
| 28 | /** |
|---|
| 29 | * This event is triggered when selectable is created. |
|---|
| 30 | */ |
|---|
| 31 | class QSelectable_CreateEvent extends QJqUiEvent { |
|---|
| 32 | const EventName = 'selectablecreate'; |
|---|
| 33 | } |
|---|
| 34 | /** |
|---|
| 35 | * This event is triggered at the end of the select operation, on each element |
|---|
| 36 | * added to the selection. |
|---|
| 37 | */ |
|---|
| 38 | class QSelectable_SelectedEvent extends QJqUiEvent { |
|---|
| 39 | const EventName = 'selectableselected'; |
|---|
| 40 | } |
|---|
| 41 | /** |
|---|
| 42 | * This event is triggered during the select operation, on each element added |
|---|
| 43 | * to the selection. |
|---|
| 44 | */ |
|---|
| 45 | class QSelectable_SelectingEvent extends QJqUiEvent { |
|---|
| 46 | const EventName = 'selectableselecting'; |
|---|
| 47 | } |
|---|
| 48 | /** |
|---|
| 49 | * This event is triggered at the beginning of the select operation. |
|---|
| 50 | */ |
|---|
| 51 | class QSelectable_StartEvent extends QJqUiEvent { |
|---|
| 52 | const EventName = 'selectablestart'; |
|---|
| 53 | } |
|---|
| 54 | /** |
|---|
| 55 | * This event is triggered at the end of the select operation. |
|---|
| 56 | */ |
|---|
| 57 | class QSelectable_StopEvent extends QJqUiEvent { |
|---|
| 58 | const EventName = 'selectablestop'; |
|---|
| 59 | } |
|---|
| 60 | /** |
|---|
| 61 | * This event is triggered at the end of the select operation, on each element |
|---|
| 62 | * removed from the selection. |
|---|
| 63 | */ |
|---|
| 64 | class QSelectable_UnselectedEvent extends QJqUiEvent { |
|---|
| 65 | const EventName = 'selectableunselected'; |
|---|
| 66 | } |
|---|
| 67 | /** |
|---|
| 68 | * This event is triggered during the select operation, on each element |
|---|
| 69 | * removed from the selection. |
|---|
| 70 | */ |
|---|
| 71 | class QSelectable_UnselectingEvent extends QJqUiEvent { |
|---|
| 72 | const EventName = 'selectableunselecting'; |
|---|
| 73 | } |
|---|
| 74 | |
|---|
| 75 | /* Custom "property" event classes for this control */ |
|---|
| 76 | |
|---|
| 77 | /** |
|---|
| 78 | * @property boolean $Disabled Disables (true) or enables (false) the selectable. Can be set when |
|---|
| 79 | * initialising (first creating) the selectable. |
|---|
| 80 | * @property boolean $AutoRefresh This determines whether to refresh (recalculate) the position and size of |
|---|
| 81 | * each selectee at the beginning of each select operation. If you have many |
|---|
| 82 | * many items, you may want to set this to false and call the refresh method |
|---|
| 83 | * manually. |
|---|
| 84 | * @property mixed $Cancel Prevents selecting if you start on elements matching the selector. |
|---|
| 85 | * @property integer $Delay Time in milliseconds to define when the selecting should start. It helps |
|---|
| 86 | * preventing unwanted selections when clicking on an element. |
|---|
| 87 | * @property integer $Distance Tolerance, in pixels, for when selecting should start. If specified, |
|---|
| 88 | * selecting will not start until after mouse is dragged beyond distance. |
|---|
| 89 | * @property mixed $Filter The matching child elements will be made selectees (able to be selected). |
|---|
| 90 | * @property string $Tolerance Possible values: 'touch', 'fit'. |
|---|
| 91 | * |
|---|
| 92 | * |
|---|
| 93 | * fit: draggable overlaps the droppable |
|---|
| 94 | * entirely |
|---|
| 95 | * touch: draggable overlaps the droppable any amount |
|---|
| 96 | */ |
|---|
| 97 | |
|---|
| 98 | class QSelectableGen extends QPanel { |
|---|
| 99 | protected $strJavaScripts = __JQUERY_EFFECTS__; |
|---|
| 100 | protected $strStyleSheets = __JQUERY_CSS__; |
|---|
| 101 | /** @var boolean */ |
|---|
| 102 | protected $blnDisabled = null; |
|---|
| 103 | /** @var boolean */ |
|---|
| 104 | protected $blnAutoRefresh = null; |
|---|
| 105 | /** @var mixed */ |
|---|
| 106 | protected $mixCancel = null; |
|---|
| 107 | /** @var integer */ |
|---|
| 108 | protected $intDelay; |
|---|
| 109 | /** @var integer */ |
|---|
| 110 | protected $intDistance; |
|---|
| 111 | /** @var mixed */ |
|---|
| 112 | protected $mixFilter = null; |
|---|
| 113 | /** @var string */ |
|---|
| 114 | protected $strTolerance = null; |
|---|
| 115 | |
|---|
| 116 | protected function makeJsProperty($strProp, $strKey) { |
|---|
| 117 | $objValue = $this->$strProp; |
|---|
| 118 | if (null === $objValue) { |
|---|
| 119 | return ''; |
|---|
| 120 | } |
|---|
| 121 | |
|---|
| 122 | return $strKey . ': ' . JavaScriptHelper::toJsObject($objValue) . ', '; |
|---|
| 123 | } |
|---|
| 124 | |
|---|
| 125 | protected function makeJqOptions() { |
|---|
| 126 | $strJqOptions = ''; |
|---|
| 127 | $strJqOptions .= $this->makeJsProperty('Disabled', 'disabled'); |
|---|
| 128 | $strJqOptions .= $this->makeJsProperty('AutoRefresh', 'autoRefresh'); |
|---|
| 129 | $strJqOptions .= $this->makeJsProperty('Cancel', 'cancel'); |
|---|
| 130 | $strJqOptions .= $this->makeJsProperty('Delay', 'delay'); |
|---|
| 131 | $strJqOptions .= $this->makeJsProperty('Distance', 'distance'); |
|---|
| 132 | $strJqOptions .= $this->makeJsProperty('Filter', 'filter'); |
|---|
| 133 | $strJqOptions .= $this->makeJsProperty('Tolerance', 'tolerance'); |
|---|
| 134 | if ($strJqOptions) $strJqOptions = substr($strJqOptions, 0, -2); |
|---|
| 135 | return $strJqOptions; |
|---|
| 136 | } |
|---|
| 137 | |
|---|
| 138 | public function getJqControlId() { |
|---|
| 139 | return $this->ControlId; |
|---|
| 140 | } |
|---|
| 141 | |
|---|
| 142 | public function getJqSetupFunction() { |
|---|
| 143 | return 'selectable'; |
|---|
| 144 | } |
|---|
| 145 | |
|---|
| 146 | public function GetControlJavaScript() { |
|---|
| 147 | return sprintf('jQuery("#%s").%s({%s})', $this->getJqControlId(), $this->getJqSetupFunction(), $this->makeJqOptions()); |
|---|
| 148 | } |
|---|
| 149 | |
|---|
| 150 | public function GetEndScript() { |
|---|
| 151 | return $this->GetControlJavaScript() . '; ' . parent::GetEndScript(); |
|---|
| 152 | } |
|---|
| 153 | |
|---|
| 154 | /** |
|---|
| 155 | * Call a JQuery UI Method on the object. Takes variable number of arguments. |
|---|
| 156 | * |
|---|
| 157 | * @param string $strMethodName the method name to call |
|---|
| 158 | * @internal param $mixed [optional] $mixParam1 |
|---|
| 159 | * @internal param $mixed [optional] $mixParam2 |
|---|
| 160 | */ |
|---|
| 161 | protected function CallJqUiMethod($strMethodName /*, ... */) { |
|---|
| 162 | $args = array(); |
|---|
| 163 | $args = func_get_args(); |
|---|
| 164 | |
|---|
| 165 | $strArgs = JavaScriptHelper::toJsObject($args); |
|---|
| 166 | $strJs = sprintf('jQuery("#%s").%s(%s)', |
|---|
| 167 | $this->getJqControlId(), |
|---|
| 168 | $this->getJqSetupFunction(), |
|---|
| 169 | substr($strArgs, 1, strlen($strArgs)-2)); // params without brackets |
|---|
| 170 | QApplication::ExecuteJavaScript($strJs); |
|---|
| 171 | } |
|---|
| 172 | |
|---|
| 173 | |
|---|
| 174 | /** |
|---|
| 175 | * Remove the selectable functionality completely. This will return the |
|---|
| 176 | * element back to its pre-init state. |
|---|
| 177 | */ |
|---|
| 178 | public function Destroy() { |
|---|
| 179 | $this->CallJqUiMethod("destroy"); |
|---|
| 180 | } |
|---|
| 181 | /** |
|---|
| 182 | * Disable the selectable. |
|---|
| 183 | */ |
|---|
| 184 | public function Disable() { |
|---|
| 185 | $this->CallJqUiMethod("disable"); |
|---|
| 186 | } |
|---|
| 187 | /** |
|---|
| 188 | * Enable the selectable. |
|---|
| 189 | */ |
|---|
| 190 | public function Enable() { |
|---|
| 191 | $this->CallJqUiMethod("enable"); |
|---|
| 192 | } |
|---|
| 193 | /** |
|---|
| 194 | * Get or set any selectable option. If no value is specified, will act as a |
|---|
| 195 | * getter. |
|---|
| 196 | * @param $optionName |
|---|
| 197 | * @param $value |
|---|
| 198 | */ |
|---|
| 199 | public function Option($optionName, $value = null) { |
|---|
| 200 | $this->CallJqUiMethod("option", $optionName, $value); |
|---|
| 201 | } |
|---|
| 202 | /** |
|---|
| 203 | * Set multiple selectable options at once by providing an options object. |
|---|
| 204 | * @param $options |
|---|
| 205 | */ |
|---|
| 206 | public function Option1($options) { |
|---|
| 207 | $this->CallJqUiMethod("option", $options); |
|---|
| 208 | } |
|---|
| 209 | /** |
|---|
| 210 | * Refresh the position and size of each selectee element. This method can be |
|---|
| 211 | * used to manually recalculate the position and size of each selectee |
|---|
| 212 | * element. Very useful if autoRefresh is set to false. |
|---|
| 213 | */ |
|---|
| 214 | public function Refresh() { |
|---|
| 215 | $this->CallJqUiMethod("refresh"); |
|---|
| 216 | } |
|---|
| 217 | |
|---|
| 218 | |
|---|
| 219 | public function __get($strName) { |
|---|
| 220 | switch ($strName) { |
|---|
| 221 | case 'Disabled': return $this->blnDisabled; |
|---|
| 222 | case 'AutoRefresh': return $this->blnAutoRefresh; |
|---|
| 223 | case 'Cancel': return $this->mixCancel; |
|---|
| 224 | case 'Delay': return $this->intDelay; |
|---|
| 225 | case 'Distance': return $this->intDistance; |
|---|
| 226 | case 'Filter': return $this->mixFilter; |
|---|
| 227 | case 'Tolerance': return $this->strTolerance; |
|---|
| 228 | default: |
|---|
| 229 | try { |
|---|
| 230 | return parent::__get($strName); |
|---|
| 231 | } catch (QCallerException $objExc) { |
|---|
| 232 | $objExc->IncrementOffset(); |
|---|
| 233 | throw $objExc; |
|---|
| 234 | } |
|---|
| 235 | } |
|---|
| 236 | } |
|---|
| 237 | |
|---|
| 238 | public function __set($strName, $mixValue) { |
|---|
| 239 | $this->blnModified = true; |
|---|
| 240 | |
|---|
| 241 | switch ($strName) { |
|---|
| 242 | case 'Disabled': |
|---|
| 243 | try { |
|---|
| 244 | $this->blnDisabled = QType::Cast($mixValue, QType::Boolean); |
|---|
| 245 | if ($this->Rendered) { |
|---|
| 246 | $this->CallJqUiMethod("option", $strName, $mixValue); |
|---|
| 247 | } |
|---|
| 248 | break; |
|---|
| 249 | } catch (QInvalidCastException $objExc) { |
|---|
| 250 | $objExc->IncrementOffset(); |
|---|
| 251 | throw $objExc; |
|---|
| 252 | } |
|---|
| 253 | |
|---|
| 254 | case 'AutoRefresh': |
|---|
| 255 | try { |
|---|
| 256 | $this->blnAutoRefresh = QType::Cast($mixValue, QType::Boolean); |
|---|
| 257 | if ($this->Rendered) { |
|---|
| 258 | $this->CallJqUiMethod("option", $strName, $mixValue); |
|---|
| 259 | } |
|---|
| 260 | break; |
|---|
| 261 | } catch (QInvalidCastException $objExc) { |
|---|
| 262 | $objExc->IncrementOffset(); |
|---|
| 263 | throw $objExc; |
|---|
| 264 | } |
|---|
| 265 | |
|---|
| 266 | case 'Cancel': |
|---|
| 267 | $this->mixCancel = $mixValue; |
|---|
| 268 | |
|---|
| 269 | if ($this->Rendered) { |
|---|
| 270 | $this->CallJqUiMethod("option", $strName, $mixValue); |
|---|
| 271 | } |
|---|
| 272 | break; |
|---|
| 273 | |
|---|
| 274 | case 'Delay': |
|---|
| 275 | try { |
|---|
| 276 | $this->intDelay = QType::Cast($mixValue, QType::Integer); |
|---|
| 277 | if ($this->Rendered) { |
|---|
| 278 | $this->CallJqUiMethod("option", $strName, $mixValue); |
|---|
| 279 | } |
|---|
| 280 | break; |
|---|
| 281 | } catch (QInvalidCastException $objExc) { |
|---|
| 282 | $objExc->IncrementOffset(); |
|---|
| 283 | throw $objExc; |
|---|
| 284 | } |
|---|
| 285 | |
|---|
| 286 | case 'Distance': |
|---|
| 287 | try { |
|---|
| 288 | $this->intDistance = QType::Cast($mixValue, QType::Integer); |
|---|
| 289 | if ($this->Rendered) { |
|---|
| 290 | $this->CallJqUiMethod("option", $strName, $mixValue); |
|---|
| 291 | } |
|---|
| 292 | break; |
|---|
| 293 | } catch (QInvalidCastException $objExc) { |
|---|
| 294 | $objExc->IncrementOffset(); |
|---|
| 295 | throw $objExc; |
|---|
| 296 | } |
|---|
| 297 | |
|---|
| 298 | case 'Filter': |
|---|
| 299 | $this->mixFilter = $mixValue; |
|---|
| 300 | |
|---|
| 301 | if ($this->Rendered) { |
|---|
| 302 | $this->CallJqUiMethod("option", $strName, $mixValue); |
|---|
| 303 | } |
|---|
| 304 | break; |
|---|
| 305 | |
|---|
| 306 | case 'Tolerance': |
|---|
| 307 | try { |
|---|
| 308 | $this->strTolerance = QType::Cast($mixValue, QType::String); |
|---|
| 309 | if ($this->Rendered) { |
|---|
| 310 | $this->CallJqUiMethod("option", $strName, $mixValue); |
|---|
| 311 | } |
|---|
| 312 | break; |
|---|
| 313 | } catch (QInvalidCastException $objExc) { |
|---|
| 314 | $objExc->IncrementOffset(); |
|---|
| 315 | throw $objExc; |
|---|
| 316 | } |
|---|
| 317 | |
|---|
| 318 | |
|---|
| 319 | case 'Enabled': |
|---|
| 320 | $this->Disabled = !$mixValue; // Tie in standard QCubed functionality |
|---|
| 321 | parent::__set($strName, $mixValue); |
|---|
| 322 | break; |
|---|
| 323 | |
|---|
| 324 | default: |
|---|
| 325 | try { |
|---|
| 326 | parent::__set($strName, $mixValue); |
|---|
| 327 | break; |
|---|
| 328 | } catch (QCallerException $objExc) { |
|---|
| 329 | $objExc->IncrementOffset(); |
|---|
| 330 | throw $objExc; |
|---|
| 331 | } |
|---|
| 332 | } |
|---|
| 333 | } |
|---|
| 334 | } |
|---|
| 335 | |
|---|
| 336 | ?> |
|---|