| 1 | <?php |
|---|
| 2 | /** |
|---|
| 3 | * The abstract QDroppableGen 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 QDroppableBase |
|---|
| 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 QDroppable class file. |
|---|
| 22 | * |
|---|
| 23 | */ |
|---|
| 24 | |
|---|
| 25 | /* Custom event classes for this control */ |
|---|
| 26 | |
|---|
| 27 | |
|---|
| 28 | /** |
|---|
| 29 | * This event is triggered when droppable is created. |
|---|
| 30 | */ |
|---|
| 31 | class QDroppable_CreateEvent extends QJqUiEvent { |
|---|
| 32 | const EventName = 'dropcreate'; |
|---|
| 33 | } |
|---|
| 34 | /** |
|---|
| 35 | * This event is triggered any time an accepted draggable starts dragging. |
|---|
| 36 | * This can be useful if you want to make the droppable 'light up' when it can |
|---|
| 37 | * be dropped on. |
|---|
| 38 | */ |
|---|
| 39 | class QDroppable_ActivateEvent extends QJqUiEvent { |
|---|
| 40 | const EventName = 'dropactivate'; |
|---|
| 41 | } |
|---|
| 42 | /** |
|---|
| 43 | * This event is triggered any time an accepted draggable stops dragging. |
|---|
| 44 | */ |
|---|
| 45 | class QDroppable_DeactivateEvent extends QJqUiEvent { |
|---|
| 46 | const EventName = 'dropdeactivate'; |
|---|
| 47 | } |
|---|
| 48 | /** |
|---|
| 49 | * This event is triggered as an accepted draggable is dragged 'over' (within |
|---|
| 50 | * the tolerance of) this droppable. |
|---|
| 51 | */ |
|---|
| 52 | class QDroppable_OverEvent extends QJqUiEvent { |
|---|
| 53 | const EventName = 'dropover'; |
|---|
| 54 | } |
|---|
| 55 | /** |
|---|
| 56 | * This event is triggered when an accepted draggable is dragged out (within |
|---|
| 57 | * the tolerance of) this droppable. |
|---|
| 58 | */ |
|---|
| 59 | class QDroppable_OutEvent extends QJqUiEvent { |
|---|
| 60 | const EventName = 'dropout'; |
|---|
| 61 | } |
|---|
| 62 | /** |
|---|
| 63 | * This event is triggered when an accepted draggable is dropped 'over' |
|---|
| 64 | * (within the tolerance of) this droppable. In the callback, $(this) |
|---|
| 65 | * represents the droppable the draggable is dropped on. |
|---|
| 66 | * ui.draggable |
|---|
| 67 | * represents the draggable. |
|---|
| 68 | */ |
|---|
| 69 | class QDroppable_DropEvent extends QJqUiEvent { |
|---|
| 70 | const EventName = 'drop'; |
|---|
| 71 | } |
|---|
| 72 | |
|---|
| 73 | /* Custom "property" event classes for this control */ |
|---|
| 74 | |
|---|
| 75 | /** |
|---|
| 76 | * @property boolean $Disabled Disables (true) or enables (false) the droppable. Can be set when |
|---|
| 77 | * initialising (first creating) the droppable. |
|---|
| 78 | * @property mixed $Accept All draggables that match the selector will be accepted. If a function is |
|---|
| 79 | * specified, the function will be called for each draggable on the page |
|---|
| 80 | * (passed as the first argument to the function), to provide a custom filter. |
|---|
| 81 | * The function should return true if the draggable should be accepted. |
|---|
| 82 | * @property string $ActiveClass If specified, the class will be added to the droppable while an acceptable |
|---|
| 83 | * draggable is being dragged. |
|---|
| 84 | * @property boolean $AddClasses If set to false, will prevent the ui-droppable class from being added. This |
|---|
| 85 | * may be desired as a performance optimization when calling .droppable() init |
|---|
| 86 | * on many hundreds of elements. |
|---|
| 87 | * @property boolean $Greedy If true, will prevent event propagation on nested droppables. |
|---|
| 88 | * @property string $HoverClass If specified, the class will be added to the droppable while an acceptable |
|---|
| 89 | * draggable is being hovered. |
|---|
| 90 | * @property string $Scope Used to group sets of draggable and droppable items, in addition to |
|---|
| 91 | * droppable's accept option. A draggable with the same scope value as a |
|---|
| 92 | * droppable will be accepted. |
|---|
| 93 | * @property string $Tolerance Specifies which mode to use for testing whether a draggable is 'over' a |
|---|
| 94 | * droppable. Possible values: 'fit', 'intersect', 'pointer', 'touch'. |
|---|
| 95 | * |
|---|
| 96 | * |
|---|
| 97 | * fit: |
|---|
| 98 | * draggable overlaps the droppable entirely |
|---|
| 99 | * intersect: draggable overlaps the |
|---|
| 100 | * droppable at least 50% |
|---|
| 101 | * pointer: mouse pointer overlaps the droppable |
|---|
| 102 | * touch: |
|---|
| 103 | * draggable overlaps the droppable any amount |
|---|
| 104 | */ |
|---|
| 105 | |
|---|
| 106 | abstract class QDroppableGen extends QControl { |
|---|
| 107 | protected $strJavaScripts = __JQUERY_EFFECTS__; |
|---|
| 108 | protected $strStyleSheets = __JQUERY_CSS__; |
|---|
| 109 | /** @var boolean */ |
|---|
| 110 | protected $blnDisabled = null; |
|---|
| 111 | /** @var mixed */ |
|---|
| 112 | protected $mixAccept = null; |
|---|
| 113 | /** @var string */ |
|---|
| 114 | protected $strActiveClass = null; |
|---|
| 115 | /** @var boolean */ |
|---|
| 116 | protected $blnAddClasses = null; |
|---|
| 117 | /** @var boolean */ |
|---|
| 118 | protected $blnGreedy = null; |
|---|
| 119 | /** @var string */ |
|---|
| 120 | protected $strHoverClass = null; |
|---|
| 121 | /** @var string */ |
|---|
| 122 | protected $strScope = null; |
|---|
| 123 | /** @var string */ |
|---|
| 124 | protected $strTolerance = null; |
|---|
| 125 | |
|---|
| 126 | protected function makeJsProperty($strProp, $strKey) { |
|---|
| 127 | $objValue = $this->$strProp; |
|---|
| 128 | if (null === $objValue) { |
|---|
| 129 | return ''; |
|---|
| 130 | } |
|---|
| 131 | |
|---|
| 132 | return $strKey . ': ' . JavaScriptHelper::toJsObject($objValue) . ', '; |
|---|
| 133 | } |
|---|
| 134 | |
|---|
| 135 | protected function makeJqOptions() { |
|---|
| 136 | $strJqOptions = ''; |
|---|
| 137 | $strJqOptions .= $this->makeJsProperty('Disabled', 'disabled'); |
|---|
| 138 | $strJqOptions .= $this->makeJsProperty('Accept', 'accept'); |
|---|
| 139 | $strJqOptions .= $this->makeJsProperty('ActiveClass', 'activeClass'); |
|---|
| 140 | $strJqOptions .= $this->makeJsProperty('AddClasses', 'addClasses'); |
|---|
| 141 | $strJqOptions .= $this->makeJsProperty('Greedy', 'greedy'); |
|---|
| 142 | $strJqOptions .= $this->makeJsProperty('HoverClass', 'hoverClass'); |
|---|
| 143 | $strJqOptions .= $this->makeJsProperty('Scope', 'scope'); |
|---|
| 144 | $strJqOptions .= $this->makeJsProperty('Tolerance', 'tolerance'); |
|---|
| 145 | if ($strJqOptions) $strJqOptions = substr($strJqOptions, 0, -2); |
|---|
| 146 | return $strJqOptions; |
|---|
| 147 | } |
|---|
| 148 | |
|---|
| 149 | public function getJqControlId() { |
|---|
| 150 | return $this->ControlId; |
|---|
| 151 | } |
|---|
| 152 | |
|---|
| 153 | public function getJqSetupFunction() { |
|---|
| 154 | return 'droppable'; |
|---|
| 155 | } |
|---|
| 156 | |
|---|
| 157 | public function GetControlJavaScript() { |
|---|
| 158 | return sprintf('jQuery("#%s").%s({%s})', $this->getJqControlId(), $this->getJqSetupFunction(), $this->makeJqOptions()); |
|---|
| 159 | } |
|---|
| 160 | |
|---|
| 161 | public function GetEndScript() { |
|---|
| 162 | return $this->GetControlJavaScript() . '; ' . parent::GetEndScript(); |
|---|
| 163 | } |
|---|
| 164 | |
|---|
| 165 | /** |
|---|
| 166 | * Call a JQuery UI Method on the object. Takes variable number of arguments. |
|---|
| 167 | * |
|---|
| 168 | * @param string $strMethodName the method name to call |
|---|
| 169 | * @internal param $mixed [optional] $mixParam1 |
|---|
| 170 | * @internal param $mixed [optional] $mixParam2 |
|---|
| 171 | */ |
|---|
| 172 | protected function CallJqUiMethod($strMethodName /*, ... */) { |
|---|
| 173 | $args = array(); |
|---|
| 174 | $args = func_get_args(); |
|---|
| 175 | |
|---|
| 176 | $strArgs = JavaScriptHelper::toJsObject($args); |
|---|
| 177 | $strJs = sprintf('jQuery("#%s").%s(%s)', |
|---|
| 178 | $this->getJqControlId(), |
|---|
| 179 | $this->getJqSetupFunction(), |
|---|
| 180 | substr($strArgs, 1, strlen($strArgs)-2)); // params without brackets |
|---|
| 181 | QApplication::ExecuteJavaScript($strJs); |
|---|
| 182 | } |
|---|
| 183 | |
|---|
| 184 | |
|---|
| 185 | /** |
|---|
| 186 | * Remove the droppable functionality completely. This will return the element |
|---|
| 187 | * back to its pre-init state. |
|---|
| 188 | */ |
|---|
| 189 | public function Destroy() { |
|---|
| 190 | $this->CallJqUiMethod("destroy"); |
|---|
| 191 | } |
|---|
| 192 | /** |
|---|
| 193 | * Disable the droppable. |
|---|
| 194 | */ |
|---|
| 195 | public function Disable() { |
|---|
| 196 | $this->CallJqUiMethod("disable"); |
|---|
| 197 | } |
|---|
| 198 | /** |
|---|
| 199 | * Enable the droppable. |
|---|
| 200 | */ |
|---|
| 201 | public function Enable() { |
|---|
| 202 | $this->CallJqUiMethod("enable"); |
|---|
| 203 | } |
|---|
| 204 | /** |
|---|
| 205 | * Get or set any droppable option. If no value is specified, will act as a |
|---|
| 206 | * getter. |
|---|
| 207 | * @param $optionName |
|---|
| 208 | * @param $value |
|---|
| 209 | */ |
|---|
| 210 | public function Option($optionName, $value = null) { |
|---|
| 211 | $this->CallJqUiMethod("option", $optionName, $value); |
|---|
| 212 | } |
|---|
| 213 | /** |
|---|
| 214 | * Set multiple droppable options at once by providing an options object. |
|---|
| 215 | * @param $options |
|---|
| 216 | */ |
|---|
| 217 | public function Option1($options) { |
|---|
| 218 | $this->CallJqUiMethod("option", $options); |
|---|
| 219 | } |
|---|
| 220 | |
|---|
| 221 | |
|---|
| 222 | public function __get($strName) { |
|---|
| 223 | switch ($strName) { |
|---|
| 224 | case 'Disabled': return $this->blnDisabled; |
|---|
| 225 | case 'Accept': return $this->mixAccept; |
|---|
| 226 | case 'ActiveClass': return $this->strActiveClass; |
|---|
| 227 | case 'AddClasses': return $this->blnAddClasses; |
|---|
| 228 | case 'Greedy': return $this->blnGreedy; |
|---|
| 229 | case 'HoverClass': return $this->strHoverClass; |
|---|
| 230 | case 'Scope': return $this->strScope; |
|---|
| 231 | case 'Tolerance': return $this->strTolerance; |
|---|
| 232 | default: |
|---|
| 233 | try { |
|---|
| 234 | return parent::__get($strName); |
|---|
| 235 | } catch (QCallerException $objExc) { |
|---|
| 236 | $objExc->IncrementOffset(); |
|---|
| 237 | throw $objExc; |
|---|
| 238 | } |
|---|
| 239 | } |
|---|
| 240 | } |
|---|
| 241 | |
|---|
| 242 | public function __set($strName, $mixValue) { |
|---|
| 243 | $this->blnModified = true; |
|---|
| 244 | |
|---|
| 245 | switch ($strName) { |
|---|
| 246 | case 'Disabled': |
|---|
| 247 | try { |
|---|
| 248 | $this->blnDisabled = QType::Cast($mixValue, QType::Boolean); |
|---|
| 249 | if ($this->Rendered) { |
|---|
| 250 | $this->CallJqUiMethod("option", $strName, $mixValue); |
|---|
| 251 | } |
|---|
| 252 | break; |
|---|
| 253 | } catch (QInvalidCastException $objExc) { |
|---|
| 254 | $objExc->IncrementOffset(); |
|---|
| 255 | throw $objExc; |
|---|
| 256 | } |
|---|
| 257 | |
|---|
| 258 | case 'Accept': |
|---|
| 259 | $this->mixAccept = $mixValue; |
|---|
| 260 | |
|---|
| 261 | if ($this->Rendered) { |
|---|
| 262 | $this->CallJqUiMethod("option", $strName, $mixValue); |
|---|
| 263 | } |
|---|
| 264 | break; |
|---|
| 265 | |
|---|
| 266 | case 'ActiveClass': |
|---|
| 267 | try { |
|---|
| 268 | $this->strActiveClass = QType::Cast($mixValue, QType::String); |
|---|
| 269 | if ($this->Rendered) { |
|---|
| 270 | $this->CallJqUiMethod("option", $strName, $mixValue); |
|---|
| 271 | } |
|---|
| 272 | break; |
|---|
| 273 | } catch (QInvalidCastException $objExc) { |
|---|
| 274 | $objExc->IncrementOffset(); |
|---|
| 275 | throw $objExc; |
|---|
| 276 | } |
|---|
| 277 | |
|---|
| 278 | case 'AddClasses': |
|---|
| 279 | try { |
|---|
| 280 | $this->blnAddClasses = QType::Cast($mixValue, QType::Boolean); |
|---|
| 281 | if ($this->Rendered) { |
|---|
| 282 | $this->CallJqUiMethod("option", $strName, $mixValue); |
|---|
| 283 | } |
|---|
| 284 | break; |
|---|
| 285 | } catch (QInvalidCastException $objExc) { |
|---|
| 286 | $objExc->IncrementOffset(); |
|---|
| 287 | throw $objExc; |
|---|
| 288 | } |
|---|
| 289 | |
|---|
| 290 | case 'Greedy': |
|---|
| 291 | try { |
|---|
| 292 | $this->blnGreedy = QType::Cast($mixValue, QType::Boolean); |
|---|
| 293 | if ($this->Rendered) { |
|---|
| 294 | $this->CallJqUiMethod("option", $strName, $mixValue); |
|---|
| 295 | } |
|---|
| 296 | break; |
|---|
| 297 | } catch (QInvalidCastException $objExc) { |
|---|
| 298 | $objExc->IncrementOffset(); |
|---|
| 299 | throw $objExc; |
|---|
| 300 | } |
|---|
| 301 | |
|---|
| 302 | case 'HoverClass': |
|---|
| 303 | try { |
|---|
| 304 | $this->strHoverClass = QType::Cast($mixValue, QType::String); |
|---|
| 305 | if ($this->Rendered) { |
|---|
| 306 | $this->CallJqUiMethod("option", $strName, $mixValue); |
|---|
| 307 | } |
|---|
| 308 | break; |
|---|
| 309 | } catch (QInvalidCastException $objExc) { |
|---|
| 310 | $objExc->IncrementOffset(); |
|---|
| 311 | throw $objExc; |
|---|
| 312 | } |
|---|
| 313 | |
|---|
| 314 | case 'Scope': |
|---|
| 315 | try { |
|---|
| 316 | $this->strScope = QType::Cast($mixValue, QType::String); |
|---|
| 317 | if ($this->Rendered) { |
|---|
| 318 | $this->CallJqUiMethod("option", $strName, $mixValue); |
|---|
| 319 | } |
|---|
| 320 | break; |
|---|
| 321 | } catch (QInvalidCastException $objExc) { |
|---|
| 322 | $objExc->IncrementOffset(); |
|---|
| 323 | throw $objExc; |
|---|
| 324 | } |
|---|
| 325 | |
|---|
| 326 | case 'Tolerance': |
|---|
| 327 | try { |
|---|
| 328 | $this->strTolerance = QType::Cast($mixValue, QType::String); |
|---|
| 329 | if ($this->Rendered) { |
|---|
| 330 | $this->CallJqUiMethod("option", $strName, $mixValue); |
|---|
| 331 | } |
|---|
| 332 | break; |
|---|
| 333 | } catch (QInvalidCastException $objExc) { |
|---|
| 334 | $objExc->IncrementOffset(); |
|---|
| 335 | throw $objExc; |
|---|
| 336 | } |
|---|
| 337 | |
|---|
| 338 | |
|---|
| 339 | case 'Enabled': |
|---|
| 340 | $this->Disabled = !$mixValue; // Tie in standard QCubed functionality |
|---|
| 341 | parent::__set($strName, $mixValue); |
|---|
| 342 | break; |
|---|
| 343 | |
|---|
| 344 | default: |
|---|
| 345 | try { |
|---|
| 346 | parent::__set($strName, $mixValue); |
|---|
| 347 | break; |
|---|
| 348 | } catch (QCallerException $objExc) { |
|---|
| 349 | $objExc->IncrementOffset(); |
|---|
| 350 | throw $objExc; |
|---|
| 351 | } |
|---|
| 352 | } |
|---|
| 353 | } |
|---|
| 354 | } |
|---|
| 355 | |
|---|
| 356 | ?> |
|---|