1: <?php
2: 3: 4: 5: 6: 7: 8: 9:
10: class QDraggable_CreateEvent extends QJqUiEvent {
11: const EventName = 'dragcreate';
12: }
13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30:
31: class QDraggable_DragEvent extends QJqUiEvent {
32: const EventName = 'drag';
33: }
34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48:
49: class QDraggable_StartEvent extends QJqUiEvent {
50: const EventName = 'dragstart';
51: }
52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66:
67: class QDraggable_StopEvent extends QJqUiEvent {
68: const EventName = 'dragstop';
69: }
70:
71:
72:
73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257:
258:
259: abstract class QDraggableGen extends QControl {
260: protected $strJavaScripts = __JQUERY_EFFECTS__;
261: protected $strStyleSheets = __JQUERY_CSS__;
262:
263: protected $blnAddClasses = null;
264:
265: protected $mixAppendTo = null;
266:
267: protected $strAxis = null;
268:
269: protected $mixCancel = null;
270:
271: protected $mixConnectToSortable = null;
272:
273: protected $mixContainment = null;
274:
275: protected $strCursor = null;
276:
277: protected $mixCursorAt = null;
278:
279: protected $intDelay;
280:
281: protected $blnDisabled = null;
282:
283: protected $intDistance = null;
284:
285: protected $arrGrid = null;
286:
287: protected $mixHandle = null;
288:
289: protected $mixHelper = null;
290:
291: protected $mixIframeFix = null;
292:
293: protected $intOpacity = null;
294:
295: protected $blnRefreshPositions = null;
296:
297: protected $mixRevert = null;
298:
299: protected $intRevertDuration = null;
300:
301: protected $strScope = null;
302:
303: protected $blnScroll = null;
304:
305: protected $intScrollSensitivity = null;
306:
307: protected $intScrollSpeed = null;
308:
309: protected $mixSnap = null;
310:
311: protected $strSnapMode = null;
312:
313: protected $intSnapTolerance = null;
314:
315: protected $mixStack = null;
316:
317: protected $intZIndex = null;
318:
319: 320: 321: 322: 323:
324: protected function MakeJqOptions() {
325: $jqOptions = null;
326: if (!is_null($val = $this->AddClasses)) {$jqOptions['addClasses'] = $val;}
327: if (!is_null($val = $this->AppendTo)) {$jqOptions['appendTo'] = $val;}
328: if (!is_null($val = $this->Axis)) {$jqOptions['axis'] = $val;}
329: if (!is_null($val = $this->Cancel)) {$jqOptions['cancel'] = $val;}
330: if (!is_null($val = $this->ConnectToSortable)) {$jqOptions['connectToSortable'] = $val;}
331: if (!is_null($val = $this->Containment)) {$jqOptions['containment'] = $val;}
332: if (!is_null($val = $this->Cursor)) {$jqOptions['cursor'] = $val;}
333: if (!is_null($val = $this->CursorAt)) {$jqOptions['cursorAt'] = $val;}
334: if (!is_null($val = $this->Delay)) {$jqOptions['delay'] = $val;}
335: if (!is_null($val = $this->Disabled)) {$jqOptions['disabled'] = $val;}
336: if (!is_null($val = $this->Distance)) {$jqOptions['distance'] = $val;}
337: if (!is_null($val = $this->Grid)) {$jqOptions['grid'] = $val;}
338: if (!is_null($val = $this->Handle)) {$jqOptions['handle'] = $val;}
339: if (!is_null($val = $this->Helper)) {$jqOptions['helper'] = $val;}
340: if (!is_null($val = $this->IframeFix)) {$jqOptions['iframeFix'] = $val;}
341: if (!is_null($val = $this->Opacity)) {$jqOptions['opacity'] = $val;}
342: if (!is_null($val = $this->RefreshPositions)) {$jqOptions['refreshPositions'] = $val;}
343: if (!is_null($val = $this->Revert)) {$jqOptions['revert'] = $val;}
344: if (!is_null($val = $this->RevertDuration)) {$jqOptions['revertDuration'] = $val;}
345: if (!is_null($val = $this->Scope)) {$jqOptions['scope'] = $val;}
346: if (!is_null($val = $this->Scroll)) {$jqOptions['scroll'] = $val;}
347: if (!is_null($val = $this->ScrollSensitivity)) {$jqOptions['scrollSensitivity'] = $val;}
348: if (!is_null($val = $this->ScrollSpeed)) {$jqOptions['scrollSpeed'] = $val;}
349: if (!is_null($val = $this->Snap)) {$jqOptions['snap'] = $val;}
350: if (!is_null($val = $this->SnapMode)) {$jqOptions['snapMode'] = $val;}
351: if (!is_null($val = $this->SnapTolerance)) {$jqOptions['snapTolerance'] = $val;}
352: if (!is_null($val = $this->Stack)) {$jqOptions['stack'] = $val;}
353: if (!is_null($val = $this->ZIndex)) {$jqOptions['zIndex'] = $val;}
354: return $jqOptions;
355: }
356:
357: 358: 359: 360: 361:
362: public function GetJqSetupFunction() {
363: return 'draggable';
364: }
365:
366: 367: 368: 369: 370:
371: public function GetEndScript() {
372: $strId = $this->GetJqControlId();
373: $jqOptions = $this->makeJqOptions();
374: $strFunc = $this->getJqSetupFunction();
375:
376: if ($strId !== $this->ControlId && QApplication::$RequestMode == QRequestMode::Ajax) {
377:
378:
379: QApplication::ExecuteControlCommand($strId, 'off', QJsPriority::High);
380: }
381:
382:
383: if (empty($jqOptions)) {
384: QApplication::ExecuteControlCommand($strId, $strFunc, QJsPriority::High);
385: } else {
386: QApplication::ExecuteControlCommand($strId, $strFunc, $jqOptions, QJsPriority::High);
387: }
388:
389: return parent::GetEndScript();
390: }
391:
392: 393: 394: 395: 396: 397:
398: public function Destroy() {
399: QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "destroy", QJsPriority::Low);
400: }
401: 402: 403: 404: 405:
406: public function Disable() {
407: QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "disable", QJsPriority::Low);
408: }
409: 410: 411: 412: 413:
414: public function Enable() {
415: QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "enable", QJsPriority::Low);
416: }
417: 418: 419: 420: 421: 422: 423: 424: 425:
426: public function Instance() {
427: QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "instance", QJsPriority::Low);
428: }
429: 430: 431: 432: 433: 434: 435: 436: 437: 438:
439: public function Option($optionName) {
440: QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "option", $optionName, QJsPriority::Low);
441: }
442: 443: 444: 445: 446: 447:
448: public function Option1() {
449: QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "option", QJsPriority::Low);
450: }
451: 452: 453: 454: 455: 456: 457: 458: 459: 460: 461: 462: 463: 464:
465: public function Option2($optionName, $value) {
466: QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "option", $optionName, $value, QJsPriority::Low);
467: }
468: 469: 470: 471: 472: 473:
474: public function Option3($options) {
475: QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "option", $options, QJsPriority::Low);
476: }
477:
478:
479: public function __get($strName) {
480: switch ($strName) {
481: case 'AddClasses': return $this->blnAddClasses;
482: case 'AppendTo': return $this->mixAppendTo;
483: case 'Axis': return $this->strAxis;
484: case 'Cancel': return $this->mixCancel;
485: case 'ConnectToSortable': return $this->mixConnectToSortable;
486: case 'Containment': return $this->mixContainment;
487: case 'Cursor': return $this->strCursor;
488: case 'CursorAt': return $this->mixCursorAt;
489: case 'Delay': return $this->intDelay;
490: case 'Disabled': return $this->blnDisabled;
491: case 'Distance': return $this->intDistance;
492: case 'Grid': return $this->arrGrid;
493: case 'Handle': return $this->mixHandle;
494: case 'Helper': return $this->mixHelper;
495: case 'IframeFix': return $this->mixIframeFix;
496: case 'Opacity': return $this->intOpacity;
497: case 'RefreshPositions': return $this->blnRefreshPositions;
498: case 'Revert': return $this->mixRevert;
499: case 'RevertDuration': return $this->intRevertDuration;
500: case 'Scope': return $this->strScope;
501: case 'Scroll': return $this->blnScroll;
502: case 'ScrollSensitivity': return $this->intScrollSensitivity;
503: case 'ScrollSpeed': return $this->intScrollSpeed;
504: case 'Snap': return $this->mixSnap;
505: case 'SnapMode': return $this->strSnapMode;
506: case 'SnapTolerance': return $this->intSnapTolerance;
507: case 'Stack': return $this->mixStack;
508: case 'ZIndex': return $this->intZIndex;
509: default:
510: try {
511: return parent::__get($strName);
512: } catch (QCallerException $objExc) {
513: $objExc->IncrementOffset();
514: throw $objExc;
515: }
516: }
517: }
518:
519: public function __set($strName, $mixValue) {
520: switch ($strName) {
521: case 'AddClasses':
522: try {
523: $this->blnAddClasses = QType::Cast($mixValue, QType::Boolean);
524: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'addClasses', $this->blnAddClasses);
525: break;
526: } catch (QInvalidCastException $objExc) {
527: $objExc->IncrementOffset();
528: throw $objExc;
529: }
530:
531: case 'AppendTo':
532: $this->mixAppendTo = $mixValue;
533: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'appendTo', $mixValue);
534: break;
535:
536: case 'Axis':
537: try {
538: $this->strAxis = QType::Cast($mixValue, QType::String);
539: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'axis', $this->strAxis);
540: break;
541: } catch (QInvalidCastException $objExc) {
542: $objExc->IncrementOffset();
543: throw $objExc;
544: }
545:
546: case 'Cancel':
547: $this->mixCancel = $mixValue;
548: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'cancel', $mixValue);
549: break;
550:
551: case 'ConnectToSortable':
552: $this->mixConnectToSortable = $mixValue;
553: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'connectToSortable', $mixValue);
554: break;
555:
556: case 'Containment':
557: $this->mixContainment = $mixValue;
558: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'containment', $mixValue);
559: break;
560:
561: case 'Cursor':
562: try {
563: $this->strCursor = QType::Cast($mixValue, QType::String);
564: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'cursor', $this->strCursor);
565: break;
566: } catch (QInvalidCastException $objExc) {
567: $objExc->IncrementOffset();
568: throw $objExc;
569: }
570:
571: case 'CursorAt':
572: $this->mixCursorAt = $mixValue;
573: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'cursorAt', $mixValue);
574: break;
575:
576: case 'Delay':
577: try {
578: $this->intDelay = QType::Cast($mixValue, QType::Integer);
579: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'delay', $this->intDelay);
580: break;
581: } catch (QInvalidCastException $objExc) {
582: $objExc->IncrementOffset();
583: throw $objExc;
584: }
585:
586: case 'Disabled':
587: try {
588: $this->blnDisabled = QType::Cast($mixValue, QType::Boolean);
589: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'disabled', $this->blnDisabled);
590: break;
591: } catch (QInvalidCastException $objExc) {
592: $objExc->IncrementOffset();
593: throw $objExc;
594: }
595:
596: case 'Distance':
597: try {
598: $this->intDistance = QType::Cast($mixValue, QType::Integer);
599: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'distance', $this->intDistance);
600: break;
601: } catch (QInvalidCastException $objExc) {
602: $objExc->IncrementOffset();
603: throw $objExc;
604: }
605:
606: case 'Grid':
607: try {
608: $this->arrGrid = QType::Cast($mixValue, QType::ArrayType);
609: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'grid', $this->arrGrid);
610: break;
611: } catch (QInvalidCastException $objExc) {
612: $objExc->IncrementOffset();
613: throw $objExc;
614: }
615:
616: case 'Handle':
617: $this->mixHandle = $mixValue;
618: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'handle', $mixValue);
619: break;
620:
621: case 'Helper':
622: $this->mixHelper = $mixValue;
623: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'helper', $mixValue);
624: break;
625:
626: case 'IframeFix':
627: $this->mixIframeFix = $mixValue;
628: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'iframeFix', $mixValue);
629: break;
630:
631: case 'Opacity':
632: try {
633: $this->intOpacity = QType::Cast($mixValue, QType::Integer);
634: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'opacity', $this->intOpacity);
635: break;
636: } catch (QInvalidCastException $objExc) {
637: $objExc->IncrementOffset();
638: throw $objExc;
639: }
640:
641: case 'RefreshPositions':
642: try {
643: $this->blnRefreshPositions = QType::Cast($mixValue, QType::Boolean);
644: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'refreshPositions', $this->blnRefreshPositions);
645: break;
646: } catch (QInvalidCastException $objExc) {
647: $objExc->IncrementOffset();
648: throw $objExc;
649: }
650:
651: case 'Revert':
652: $this->mixRevert = $mixValue;
653: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'revert', $mixValue);
654: break;
655:
656: case 'RevertDuration':
657: try {
658: $this->intRevertDuration = QType::Cast($mixValue, QType::Integer);
659: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'revertDuration', $this->intRevertDuration);
660: break;
661: } catch (QInvalidCastException $objExc) {
662: $objExc->IncrementOffset();
663: throw $objExc;
664: }
665:
666: case 'Scope':
667: try {
668: $this->strScope = QType::Cast($mixValue, QType::String);
669: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'scope', $this->strScope);
670: break;
671: } catch (QInvalidCastException $objExc) {
672: $objExc->IncrementOffset();
673: throw $objExc;
674: }
675:
676: case 'Scroll':
677: try {
678: $this->blnScroll = QType::Cast($mixValue, QType::Boolean);
679: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'scroll', $this->blnScroll);
680: break;
681: } catch (QInvalidCastException $objExc) {
682: $objExc->IncrementOffset();
683: throw $objExc;
684: }
685:
686: case 'ScrollSensitivity':
687: try {
688: $this->intScrollSensitivity = QType::Cast($mixValue, QType::Integer);
689: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'scrollSensitivity', $this->intScrollSensitivity);
690: break;
691: } catch (QInvalidCastException $objExc) {
692: $objExc->IncrementOffset();
693: throw $objExc;
694: }
695:
696: case 'ScrollSpeed':
697: try {
698: $this->intScrollSpeed = QType::Cast($mixValue, QType::Integer);
699: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'scrollSpeed', $this->intScrollSpeed);
700: break;
701: } catch (QInvalidCastException $objExc) {
702: $objExc->IncrementOffset();
703: throw $objExc;
704: }
705:
706: case 'Snap':
707: $this->mixSnap = $mixValue;
708: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'snap', $mixValue);
709: break;
710:
711: case 'SnapMode':
712: try {
713: $this->strSnapMode = QType::Cast($mixValue, QType::String);
714: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'snapMode', $this->strSnapMode);
715: break;
716: } catch (QInvalidCastException $objExc) {
717: $objExc->IncrementOffset();
718: throw $objExc;
719: }
720:
721: case 'SnapTolerance':
722: try {
723: $this->intSnapTolerance = QType::Cast($mixValue, QType::Integer);
724: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'snapTolerance', $this->intSnapTolerance);
725: break;
726: } catch (QInvalidCastException $objExc) {
727: $objExc->IncrementOffset();
728: throw $objExc;
729: }
730:
731: case 'Stack':
732: $this->mixStack = $mixValue;
733: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'stack', $mixValue);
734: break;
735:
736: case 'ZIndex':
737: try {
738: $this->intZIndex = QType::Cast($mixValue, QType::Integer);
739: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'zIndex', $this->intZIndex);
740: break;
741: } catch (QInvalidCastException $objExc) {
742: $objExc->IncrementOffset();
743: throw $objExc;
744: }
745:
746:
747: case 'Enabled':
748: $this->Disabled = !$mixValue;
749: parent::__set($strName, $mixValue);
750: break;
751:
752: default:
753: try {
754: parent::__set($strName, $mixValue);
755: break;
756: } catch (QCallerException $objExc) {
757: $objExc->IncrementOffset();
758: throw $objExc;
759: }
760: }
761: }
762:
763: 764: 765: 766: 767:
768: public static function GetModelConnectorParams() {
769: return array_merge(parent::GetModelConnectorParams(), array(
770: new QModelConnectorParam (get_called_class(), 'AddClasses', 'If set to false, will prevent the ui-draggable class from being added.This may be desired as a performance optimization when calling.draggable() on hundreds of elements.', QType::Boolean),
771: new QModelConnectorParam (get_called_class(), 'Axis', 'Constrains dragging to either the horizontal (x) or vertical (y) axis.Possible values: \"x\", \"y\".', QType::String),
772: new QModelConnectorParam (get_called_class(), 'Cursor', 'The CSS cursor during the drag operation.', QType::String),
773: new QModelConnectorParam (get_called_class(), 'Delay', 'Time in milliseconds after mousedown until dragging should start. Thisoption can be used to prevent unwanted drags when clicking on anelement.', QType::Integer),
774: new QModelConnectorParam (get_called_class(), 'Disabled', 'Disables the draggable if set to true.', QType::Boolean),
775: new QModelConnectorParam (get_called_class(), 'Distance', 'Distance in pixels after mousedown the mouse must move before draggingshould start. This option can be used to prevent unwanted drags whenclicking on an element.', QType::Integer),
776: new QModelConnectorParam (get_called_class(), 'Grid', 'Snaps the dragging helper to a grid, every x and y pixels. The arraymust be of the form [ x, y ].', QType::ArrayType),
777: new QModelConnectorParam (get_called_class(), 'Opacity', 'Opacity for the helper while being dragged.', QType::Integer),
778: new QModelConnectorParam (get_called_class(), 'RefreshPositions', 'If set to true, all droppable positions are calculated on everymousemove. _Caution: This solves issues on highly dynamic pages, butdramatically decreases performance._', QType::Boolean),
779: new QModelConnectorParam (get_called_class(), 'RevertDuration', 'The duration of the revert animation, in milliseconds. Ignored if therevert option is false.', QType::Integer),
780: new QModelConnectorParam (get_called_class(), 'Scope', 'Used to group sets of draggable and droppable items, in addition todroppables accept option. A draggable with the same scope value as adroppable will be accepted by the droppable.', QType::String),
781: new QModelConnectorParam (get_called_class(), 'Scroll', 'If set to true, container auto-scrolls while dragging.', QType::Boolean),
782: new QModelConnectorParam (get_called_class(), 'ScrollSensitivity', 'Distance in pixels from the edge of the viewport after which theviewport should scroll. Distance is relative to pointer, not thedraggable. Ignored if the scroll option is false.', QType::Integer),
783: new QModelConnectorParam (get_called_class(), 'ScrollSpeed', 'The speed at which the window should scroll once the mouse pointergets within the scrollSensitivity distance. Ignored if the scrolloption is false.', QType::Integer),
784: new QModelConnectorParam (get_called_class(), 'SnapMode', 'Determines which edges of snap elements the draggable will snap to.Ignored if the snap option is false. Possible values: \"inner\",\"outer\", \"both\".', QType::String),
785: new QModelConnectorParam (get_called_class(), 'SnapTolerance', 'The distance in pixels from the snap element edges at which snappingshould occur. Ignored if the snap option is false.', QType::Integer),
786: new QModelConnectorParam (get_called_class(), 'ZIndex', 'Z-index for the helper while being dragged.', QType::Integer),
787: ));
788: }
789: }