1: <?php
2: /**
3: * This event is triggered when using connected lists, every connected
4: * list on drag start receives it.
5: *
6: * * event Type: Event
7: *
8: * * ui Type: Object
9: *
10: * * helper Type: jQuery The jQuery object representing the helper being
11: * sorted.
12: * * item Type: jQuery The jQuery object representing the current
13: * dragged element.
14: * * offset Type: Object The current absolute position of the helper
15: * represented as { top, left }.
16: * * position Type: Object The current position of the helper
17: * represented as { top, left }.
18: * * originalPosition Type: Object The original position of the element
19: * represented as { top, left }.
20: * * sender Type: jQuery The sortable that the item comes from if
21: * moving from one sortable to another.
22: * * placeholder Type: jQuery The jQuery object representing the
23: * element being used as a placeholder.
24: *
25: */
26: class QSortable_ActivateEvent extends QJqUiEvent {
27: const EventName = 'sortactivate';
28: }
29: /**
30: * This event is triggered when sorting stops, but when the
31: * placeholder/helper is still available.
32: *
33: * * event Type: Event
34: *
35: * * ui Type: Object
36: *
37: * * helper Type: jQuery The jQuery object representing the helper being
38: * sorted.
39: * * item Type: jQuery The jQuery object representing the current
40: * dragged element.
41: * * offset Type: Object The current absolute position of the helper
42: * represented as { top, left }.
43: * * position Type: Object The current position of the helper
44: * represented as { top, left }.
45: * * originalPosition Type: Object The original position of the element
46: * represented as { top, left }.
47: * * sender Type: jQuery The sortable that the item comes from if
48: * moving from one sortable to another.
49: * * placeholder Type: jQuery The jQuery object representing the
50: * element being used as a placeholder.
51: *
52: */
53: class QSortable_BeforeStopEvent extends QJqUiEvent {
54: const EventName = 'sortbeforestop';
55: }
56: /**
57: * This event is triggered during sorting, but only when the DOM position
58: * has changed.
59: *
60: * * event Type: Event
61: *
62: * * ui Type: Object
63: *
64: * * helper Type: jQuery The jQuery object representing the helper being
65: * sorted.
66: * * item Type: jQuery The jQuery object representing the current
67: * dragged element.
68: * * offset Type: Object The current absolute position of the helper
69: * represented as { top, left }.
70: * * position Type: Object The current position of the helper
71: * represented as { top, left }.
72: * * originalPosition Type: Object The original position of the element
73: * represented as { top, left }.
74: * * sender Type: jQuery The sortable that the item comes from if
75: * moving from one sortable to another.
76: * * placeholder Type: jQuery The jQuery object representing the
77: * element being used as a placeholder.
78: *
79: */
80: class QSortable_ChangeEvent extends QJqUiEvent {
81: const EventName = 'sortchange';
82: }
83: /**
84: * Triggered when the sortable is created.
85: *
86: * * event Type: Event
87: * * ui Type: Object
88: *
89: * _Note: The ui object is empty but included for consistency with other
90: * events._ */
91: class QSortable_CreateEvent extends QJqUiEvent {
92: const EventName = 'sortcreate';
93: }
94: /**
95: * This event is triggered when sorting was stopped, is propagated to all
96: * possible connected lists.
97: *
98: * * event Type: Event
99: *
100: * * ui Type: Object
101: *
102: * * helper Type: jQuery The jQuery object representing the helper being
103: * sorted.
104: * * item Type: jQuery The jQuery object representing the current
105: * dragged element.
106: * * offset Type: Object The current absolute position of the helper
107: * represented as { top, left }.
108: * * position Type: Object The current position of the helper
109: * represented as { top, left }.
110: * * originalPosition Type: Object The original position of the element
111: * represented as { top, left }.
112: * * sender Type: jQuery The sortable that the item comes from if
113: * moving from one sortable to another.
114: * * placeholder Type: jQuery The jQuery object representing the
115: * element being used as a placeholder.
116: *
117: */
118: class QSortable_DeactivateEvent extends QJqUiEvent {
119: const EventName = 'sortdeactivate';
120: }
121: /**
122: * This event is triggered when a sortable item is moved away from a
123: * sortable list.
124: *
125: * _Note: This event is also triggered when a sortable item is dropped._
126: *
127: * * event Type: Event
128: *
129: * * ui Type: Object
130: *
131: * * helper Type: jQuery The jQuery object representing the helper being
132: * sorted.
133: * * item Type: jQuery The jQuery object representing the current
134: * dragged element.
135: * * offset Type: Object The current absolute position of the helper
136: * represented as { top, left }.
137: * * position Type: Object The current position of the helper
138: * represented as { top, left }.
139: * * originalPosition Type: Object The original position of the element
140: * represented as { top, left }.
141: * * sender Type: jQuery The sortable that the item comes from if
142: * moving from one sortable to another.
143: * * placeholder Type: jQuery The jQuery object representing the
144: * element being used as a placeholder.
145: *
146: */
147: class QSortable_OutEvent extends QJqUiEvent {
148: const EventName = 'sortout';
149: }
150: /**
151: * This event is triggered when a sortable item is moved into a sortable
152: * list.
153: *
154: * * event Type: Event
155: *
156: * * ui Type: Object
157: *
158: * * helper Type: jQuery The jQuery object representing the helper being
159: * sorted.
160: * * item Type: jQuery The jQuery object representing the current
161: * dragged element.
162: * * offset Type: Object The current absolute position of the helper
163: * represented as { top, left }.
164: * * position Type: Object The current position of the helper
165: * represented as { top, left }.
166: * * originalPosition Type: Object The original position of the element
167: * represented as { top, left }.
168: * * sender Type: jQuery The sortable that the item comes from if
169: * moving from one sortable to another.
170: * * placeholder Type: jQuery The jQuery object representing the
171: * element being used as a placeholder.
172: *
173: */
174: class QSortable_OverEvent extends QJqUiEvent {
175: const EventName = 'sortover';
176: }
177: /**
178: * This event is triggered when an item from a connected sortable list
179: * has been dropped into another list. The latter is the event target.
180: *
181: * * event Type: Event
182: *
183: * * ui Type: Object
184: *
185: * * helper Type: jQuery The jQuery object representing the helper being
186: * sorted.
187: * * item Type: jQuery The jQuery object representing the current
188: * dragged element.
189: * * offset Type: Object The current absolute position of the helper
190: * represented as { top, left }.
191: * * position Type: Object The current position of the helper
192: * represented as { top, left }.
193: * * originalPosition Type: Object The original position of the element
194: * represented as { top, left }.
195: * * sender Type: jQuery The sortable that the item comes from if
196: * moving from one sortable to another.
197: * * placeholder Type: jQuery The jQuery object representing the
198: * element being used as a placeholder.
199: *
200: */
201: class QSortable_ReceiveEvent extends QJqUiEvent {
202: const EventName = 'sortreceive';
203: }
204: /**
205: * This event is triggered when a sortable item from the list has been
206: * dropped into another. The former is the event target.
207: *
208: * * event Type: Event
209: *
210: * * ui Type: Object
211: *
212: * * helper Type: jQuery The jQuery object representing the helper being
213: * sorted.
214: * * item Type: jQuery The jQuery object representing the current
215: * dragged element.
216: * * offset Type: Object The current absolute position of the helper
217: * represented as { top, left }.
218: * * position Type: Object The current position of the helper
219: * represented as { top, left }.
220: * * originalPosition Type: Object The original position of the element
221: * represented as { top, left }.
222: * * placeholder Type: jQuery The jQuery object representing the
223: * element being used as a placeholder.
224: *
225: */
226: class QSortable_RemoveEvent extends QJqUiEvent {
227: const EventName = 'sortremove';
228: }
229: /**
230: * This event is triggered during sorting.
231: *
232: * * event Type: Event
233: *
234: * * ui Type: Object
235: *
236: * * helper Type: jQuery The jQuery object representing the helper being
237: * sorted.
238: * * item Type: jQuery The jQuery object representing the current
239: * dragged element.
240: * * offset Type: Object The current absolute position of the helper
241: * represented as { top, left }.
242: * * position Type: Object The current position of the helper
243: * represented as { top, left }.
244: * * originalPosition Type: Object The original position of the element
245: * represented as { top, left }.
246: * * sender Type: jQuery The sortable that the item comes from if
247: * moving from one sortable to another.
248: * * placeholder Type: jQuery The jQuery object representing the
249: * element being used as a placeholder.
250: *
251: */
252: class QSortable_SortEvent extends QJqUiEvent {
253: const EventName = 'sort';
254: }
255: /**
256: * This event is triggered when sorting starts.
257: *
258: * * event Type: Event
259: *
260: * * ui Type: Object
261: *
262: * * helper Type: jQuery The jQuery object representing the helper being
263: * sorted.
264: * * item Type: jQuery The jQuery object representing the current
265: * dragged element.
266: * * offset Type: Object The current absolute position of the helper
267: * represented as { top, left }.
268: * * position Type: Object The current position of the helper
269: * represented as { top, left }.
270: * * originalPosition Type: Object The original position of the element
271: * represented as { top, left }.
272: * * sender Type: jQuery The sortable that the item comes from if
273: * moving from one sortable to another.
274: * * placeholder Type: jQuery The jQuery object representing the
275: * element being used as a placeholder.
276: *
277: */
278: class QSortable_StartEvent extends QJqUiEvent {
279: const EventName = 'sortstart';
280: }
281: /**
282: * This event is triggered when sorting has stopped.
283: *
284: * * event Type: Event
285: *
286: * * ui Type: Object
287: *
288: * * helper Type: jQuery The jQuery object representing the helper being
289: * sorted.
290: * * item Type: jQuery The jQuery object representing the current
291: * dragged element.
292: * * offset Type: Object The current absolute position of the helper
293: * represented as { top, left }.
294: * * position Type: Object The current position of the helper
295: * represented as { top, left }.
296: * * originalPosition Type: Object The original position of the element
297: * represented as { top, left }.
298: * * sender Type: jQuery The sortable that the item comes from if
299: * moving from one sortable to another.
300: * * placeholder Type: jQuery The jQuery object representing the
301: * element being used as a placeholder.
302: *
303: */
304: class QSortable_StopEvent extends QJqUiEvent {
305: const EventName = 'sortstop';
306: }
307: /**
308: * This event is triggered when the user stopped sorting and the DOM
309: * position has changed.
310: *
311: * * event Type: Event
312: *
313: * * ui Type: Object
314: *
315: * * helper Type: jQuery The jQuery object representing the helper being
316: * sorted.
317: * * item Type: jQuery The jQuery object representing the current
318: * dragged element.
319: * * offset Type: Object The current absolute position of the helper
320: * represented as { top, left }.
321: * * position Type: Object The current position of the helper
322: * represented as { top, left }.
323: * * originalPosition Type: Object The original position of the element
324: * represented as { top, left }.
325: * * sender Type: jQuery The sortable that the item comes from if
326: * moving from one sortable to another.
327: * * placeholder Type: jQuery The jQuery object representing the
328: * element being used as a placeholder.
329: *
330: */
331: class QSortable_UpdateEvent extends QJqUiEvent {
332: const EventName = 'sortupdate';
333: }
334:
335: /* Custom "property" event classes for this control */
336:
337: /**
338: * Generated QSortableGen class.
339: *
340: * This is the QSortableGen class which is automatically generated
341: * by scraping the JQuery UI documentation website. As such, it includes all the options
342: * as listed by the JQuery UI website, which may or may not be appropriate for QCubed. See
343: * the QSortableBase class for any glue code to make this class more
344: * usable in QCubed.
345: *
346: * @see QSortableBase
347: * @package Controls\Base
348: * @property mixed $AppendTo
349: * Defines where the helper that moves with the mouse is being appended
350: * to during the drag (for example, to resolve overlap/zIndex
351: * issues).Multiple types supported:
352: *
353: * * jQuery: A jQuery object containing the element to append the helper
354: * to.
355: * * Element: The element to append the helper to.
356: * * Selector: A selector specifying which element to append the helper
357: * to.
358: * * String: The string "parent" will cause the helper to be a sibling
359: * of the sortable item.
360: *
361:
362: *
363: * @property string $Axis
364: * If defined, the items can be dragged only horizontally or vertically.
365: * Possible values: "x", "y".
366: *
367: * @property mixed $Cancel
368: * Prevents sorting if you start on elements matching the selector.
369: *
370: * @property mixed $ConnectWith
371: * A selector of other sortable elements that the items from this list
372: * should be connected to. This is a one-way relationship, if you want
373: * the items to be connected in both directions, the connectWith option
374: * must be set on both sortable elements.
375: *
376: * @property mixed $Containment
377: * Defines a bounding box that the sortable items are constrained to
378: * while dragging.
379: *
380: * Note: The element specified for containment must have a calculated
381: * width and height (though it need not be explicit). For example, if you
382: * have float: left sortable children and specify containment: "parent"
383: * be sure to have float: left on the sortable/parent container as well
384: * or it will have height: 0, causing undefined behavior.Multiple types
385: * supported:
386: *
387: * * Element: An element to use as the container.
388: * * Selector: A selector specifying an element to use as the
389: * container.
390: * * String: A string identifying an element to use as the container.
391: * Possible values: "parent", "document", "window".
392: *
393:
394: *
395: * @property string $Cursor
396: * Defines the cursor that is being shown while sorting.
397: *
398: * @property mixed $CursorAt
399: * Moves the sorting element or helper so the cursor always appears to
400: * drag from the same position. Coordinates can be given as a hash using
401: * a combination of one or two keys: { top, left, right, bottom }.
402: *
403: * @property integer $Delay
404: * Time in milliseconds to define when the sorting should start. Adding a
405: * delay helps preventing unwanted drags when clicking on an element.
406: *
407: * @property boolean $Disabled
408: * Disables the sortable if set to true.
409: *
410: * @property integer $Distance
411: * Tolerance, in pixels, for when sorting should start. If specified,
412: * sorting will not start until after mouse is dragged beyond distance.
413: * Can be used to allow for clicks on elements within a handle.
414: *
415: * @property boolean $DropOnEmpty
416: * If false, items from this sortable cant be dropped on an empty connect
417: * sortable (see the connectWith option.
418: *
419: * @property boolean $ForceHelperSize
420: * If true, forces the helper to have a size.
421: *
422: * @property boolean $ForcePlaceholderSize
423: * If true, forces the placeholder to have a size.
424: *
425: * @property array $Grid
426: * Snaps the sorting element or helper to a grid, every x and y pixels.
427: * Array values: [ x, y ].
428: *
429: * @property mixed $Handle
430: * Restricts sort start click to the specified element.
431: *
432: * @property mixed $Helper
433: * Allows for a helper element to be used for dragging display.Multiple
434: * types supported:
435: *
436: * * String: If set to "clone", then the element will be cloned and the
437: * clone will be dragged.
438: * * Function: A function that will return a DOMElement to use while
439: * dragging. The function receives the event and the element being
440: * sorted.
441: *
442:
443: *
444: * @property mixed $Items
445: * Specifies which items inside the element should be sortable.
446: *
447: * @property integer $Opacity
448: * Defines the opacity of the helper while sorting. From 0.01 to 1.
449: *
450: * @property string $Placeholder
451: * A class name that gets applied to the otherwise white space.
452: *
453: * @property mixed $Revert
454: * Whether the sortable items should revert to their new positions using
455: * a smooth animation.Multiple types supported:
456: *
457: * * Boolean: When set to true, the items will animate with the default
458: * duration.
459: * * Number: The duration for the animation, in milliseconds.
460: *
461:
462: *
463: * @property boolean $Scroll
464: * If set to true, the page scrolls when coming to an edge.
465: *
466: * @property integer $ScrollSensitivity
467: * Defines how near the mouse must be to an edge to start scrolling.
468: *
469: * @property integer $ScrollSpeed
470: * The speed at which the window should scroll once the mouse pointer
471: * gets within the scrollSensitivity distance.
472: *
473: * @property string $Tolerance
474: * Specifies which mode to use for testing whether the item being moved
475: * is hovering over another item. Possible values:
476: *
477: * * "intersect": The item overlaps the other item by at least 50%.
478: * * "pointer": The mouse pointer overlaps the other item.
479: *
480:
481: *
482: * @property integer $ZIndex
483: * Z-index for element/helper while being sorted.
484: *
485: */
486:
487: class QSortableGen extends QPanel {
488: protected $strJavaScripts = __JQUERY_EFFECTS__;
489: protected $strStyleSheets = __JQUERY_CSS__;
490: /** @var mixed */
491: protected $mixAppendTo = null;
492: /** @var string */
493: protected $strAxis = null;
494: /** @var mixed */
495: protected $mixCancel = null;
496: /** @var mixed */
497: protected $mixConnectWith = null;
498: /** @var mixed */
499: protected $mixContainment = null;
500: /** @var string */
501: protected $strCursor = null;
502: /** @var mixed */
503: protected $mixCursorAt = null;
504: /** @var integer */
505: protected $intDelay;
506: /** @var boolean */
507: protected $blnDisabled = null;
508: /** @var integer */
509: protected $intDistance = null;
510: /** @var boolean */
511: protected $blnDropOnEmpty = null;
512: /** @var boolean */
513: protected $blnForceHelperSize = null;
514: /** @var boolean */
515: protected $blnForcePlaceholderSize = null;
516: /** @var array */
517: protected $arrGrid = null;
518: /** @var mixed */
519: protected $mixHandle = null;
520: /** @var mixed */
521: protected $mixHelper = null;
522: /** @var mixed */
523: protected $mixItems = null;
524: /** @var integer */
525: protected $intOpacity = null;
526: /** @var string */
527: protected $strPlaceholder = null;
528: /** @var mixed */
529: protected $mixRevert = null;
530: /** @var boolean */
531: protected $blnScroll = null;
532: /** @var integer */
533: protected $intScrollSensitivity = null;
534: /** @var integer */
535: protected $intScrollSpeed = null;
536: /** @var string */
537: protected $strTolerance = null;
538: /** @var integer */
539: protected $intZIndex = null;
540:
541: /**
542: * Builds the option array to be sent to the widget constructor.
543: *
544: * @return array key=>value array of options
545: */
546: protected function MakeJqOptions() {
547: $jqOptions = null;
548: if (!is_null($val = $this->AppendTo)) {$jqOptions['appendTo'] = $val;}
549: if (!is_null($val = $this->Axis)) {$jqOptions['axis'] = $val;}
550: if (!is_null($val = $this->Cancel)) {$jqOptions['cancel'] = $val;}
551: if (!is_null($val = $this->ConnectWith)) {$jqOptions['connectWith'] = $val;}
552: if (!is_null($val = $this->Containment)) {$jqOptions['containment'] = $val;}
553: if (!is_null($val = $this->Cursor)) {$jqOptions['cursor'] = $val;}
554: if (!is_null($val = $this->CursorAt)) {$jqOptions['cursorAt'] = $val;}
555: if (!is_null($val = $this->Delay)) {$jqOptions['delay'] = $val;}
556: if (!is_null($val = $this->Disabled)) {$jqOptions['disabled'] = $val;}
557: if (!is_null($val = $this->Distance)) {$jqOptions['distance'] = $val;}
558: if (!is_null($val = $this->DropOnEmpty)) {$jqOptions['dropOnEmpty'] = $val;}
559: if (!is_null($val = $this->ForceHelperSize)) {$jqOptions['forceHelperSize'] = $val;}
560: if (!is_null($val = $this->ForcePlaceholderSize)) {$jqOptions['forcePlaceholderSize'] = $val;}
561: if (!is_null($val = $this->Grid)) {$jqOptions['grid'] = $val;}
562: if (!is_null($val = $this->Handle)) {$jqOptions['handle'] = $val;}
563: if (!is_null($val = $this->Helper)) {$jqOptions['helper'] = $val;}
564: if (!is_null($val = $this->Items)) {$jqOptions['items'] = $val;}
565: if (!is_null($val = $this->Opacity)) {$jqOptions['opacity'] = $val;}
566: if (!is_null($val = $this->Placeholder)) {$jqOptions['placeholder'] = $val;}
567: if (!is_null($val = $this->Revert)) {$jqOptions['revert'] = $val;}
568: if (!is_null($val = $this->Scroll)) {$jqOptions['scroll'] = $val;}
569: if (!is_null($val = $this->ScrollSensitivity)) {$jqOptions['scrollSensitivity'] = $val;}
570: if (!is_null($val = $this->ScrollSpeed)) {$jqOptions['scrollSpeed'] = $val;}
571: if (!is_null($val = $this->Tolerance)) {$jqOptions['tolerance'] = $val;}
572: if (!is_null($val = $this->ZIndex)) {$jqOptions['zIndex'] = $val;}
573: return $jqOptions;
574: }
575:
576: /**
577: * Return the JavaScript function to call to associate the widget with the control.
578: *
579: * @return string
580: */
581: public function GetJqSetupFunction() {
582: return 'sortable';
583: }
584:
585: /**
586: * Returns the script that attaches the JQueryUI widget to the html object.
587: *
588: * @return string
589: */
590: public function GetEndScript() {
591: $strId = $this->GetJqControlId();
592: $jqOptions = $this->makeJqOptions();
593: $strFunc = $this->getJqSetupFunction();
594:
595: if ($strId !== $this->ControlId && QApplication::$RequestMode == QRequestMode::Ajax) {
596: // If events are not attached to the actual object being drawn, then the old events will not get
597: // deleted during redraw. We delete the old events here. This must happen before any other event processing code.
598: QApplication::ExecuteControlCommand($strId, 'off', QJsPriority::High);
599: }
600:
601: // Attach the javascript widget to the html object
602: if (empty($jqOptions)) {
603: QApplication::ExecuteControlCommand($strId, $strFunc, QJsPriority::High);
604: } else {
605: QApplication::ExecuteControlCommand($strId, $strFunc, $jqOptions, QJsPriority::High);
606: }
607:
608: return parent::GetEndScript();
609: }
610:
611: /**
612: * Cancels a change in the current sortable and reverts it to the state
613: * prior to when the current sort was started. Useful in the stop and
614: * receive callback functions.
615: *
616: * * This method does not accept any arguments.
617: */
618: public function Cancel() {
619: QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "cancel", QJsPriority::Low);
620: }
621: /**
622: * Removes the sortable functionality completely. This will return the
623: * element back to its pre-init state.
624: *
625: * * This method does not accept any arguments.
626: */
627: public function Destroy() {
628: QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "destroy", QJsPriority::Low);
629: }
630: /**
631: * Disables the sortable.
632: *
633: * * This method does not accept any arguments.
634: */
635: public function Disable() {
636: QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "disable", QJsPriority::Low);
637: }
638: /**
639: * Enables the sortable.
640: *
641: * * This method does not accept any arguments.
642: */
643: public function Enable() {
644: QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "enable", QJsPriority::Low);
645: }
646: /**
647: * Retrieves the sortables instance object. If the element does not have
648: * an associated instance, undefined is returned.
649: *
650: * Unlike other widget methods, instance() is safe to call on any element
651: * after the sortable plugin has loaded.
652: *
653: * * This method does not accept any arguments.
654: */
655: public function Instance() {
656: QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "instance", QJsPriority::Low);
657: }
658: /**
659: * Gets the value currently associated with the specified optionName.
660: *
661: * Note: For options that have objects as their value, you can get the
662: * value of a specific key by using dot notation. For example, "foo.bar"
663: * would get the value of the bar property on the foo option.
664: *
665: * * optionName Type: String The name of the option to get.
666: * @param $optionName
667: */
668: public function Option($optionName) {
669: QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "option", $optionName, QJsPriority::Low);
670: }
671: /**
672: * Gets an object containing key/value pairs representing the current
673: * sortable options hash.
674: *
675: * * This signature does not accept any arguments.
676: */
677: public function Option1() {
678: QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "option", QJsPriority::Low);
679: }
680: /**
681: * Sets the value of the sortable option associated with the specified
682: * optionName.
683: *
684: * Note: For options that have objects as their value, you can set the
685: * value of just one property by using dot notation for optionName. For
686: * example, "foo.bar" would update only the bar property of the foo
687: * option.
688: *
689: * * optionName Type: String The name of the option to set.
690: * * value Type: Object A value to set for the option.
691: * @param $optionName
692: * @param $value
693: */
694: public function Option2($optionName, $value) {
695: QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "option", $optionName, $value, QJsPriority::Low);
696: }
697: /**
698: * Sets one or more options for the sortable.
699: *
700: * * options Type: Object A map of option-value pairs to set.
701: * @param $options
702: */
703: public function Option3($options) {
704: QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "option", $options, QJsPriority::Low);
705: }
706: /**
707: * Refresh the sortable items. Triggers the reloading of all sortable
708: * items, causing new items to be recognized.
709: *
710: * * This method does not accept any arguments.
711: */
712: public function Refresh() {
713: QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "refresh", QJsPriority::Low);
714: }
715: /**
716: * Refresh the cached positions of the sortable items. Calling this
717: * method refreshes the cached item positions of all sortables.
718: *
719: * * This method does not accept any arguments.
720: */
721: public function RefreshPositions() {
722: QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "refreshPositions", QJsPriority::Low);
723: }
724: /**
725: * Serializes the sortables item ids into a form/ajax submittable string.
726: * Calling this method produces a hash that can be appended to any url to
727: * easily submit a new item order back to the server.
728: *
729: * It works by default by looking at the id of each item in the format
730: * "setname_number", and it spits out a hash like
731: * "setname[]=number&setname[]=number".
732: *
733: * _Note: If serialize returns an empty string, make sure the id
734: * attributes include an underscore. They must be in the form:
735: * "set_number" For example, a 3 element list with id attributes "foo_1",
736: * "foo_5", "foo_2" will serialize to "foo[]=1&foo[]=5&foo[]=2". You can
737: * use an underscore, equal sign or hyphen to separate the set and
738: * number. For example "foo=1", "foo-1", and "foo_1" all serialize to
739: * "foo[]=1"._
740: *
741: * * options Type: Object Options to customize the serialization.
742: *
743: * * key (default: the part of the attribute in front of the separator)
744: * Type: String Replaces part1[] with the specified value.
745: * * attribute (default: "id") Type: String The name of the attribute
746: * to use for the values.
747: * * expression (default: /(.+)[-=_](.+)/) Type: RegExp A regular
748: * expression used to split the attribute value into key and value parts.
749: * @param $options
750: */
751: public function Serialize($options) {
752: QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "serialize", $options, QJsPriority::Low);
753: }
754: /**
755: * Serializes the sortables item ids into an array of string.
756: *
757: * * options Type: Object Options to customize the serialization.
758: *
759: * * attribute (default: "id") Type: String The name of the attribute to
760: * use for the values.
761: * @param $options
762: */
763: public function ToArray($options) {
764: QApplication::ExecuteControlCommand($this->getJqControlId(), $this->getJqSetupFunction(), "toArray", $options, QJsPriority::Low);
765: }
766:
767:
768: public function __get($strName) {
769: switch ($strName) {
770: case 'AppendTo': return $this->mixAppendTo;
771: case 'Axis': return $this->strAxis;
772: case 'Cancel': return $this->mixCancel;
773: case 'ConnectWith': return $this->mixConnectWith;
774: case 'Containment': return $this->mixContainment;
775: case 'Cursor': return $this->strCursor;
776: case 'CursorAt': return $this->mixCursorAt;
777: case 'Delay': return $this->intDelay;
778: case 'Disabled': return $this->blnDisabled;
779: case 'Distance': return $this->intDistance;
780: case 'DropOnEmpty': return $this->blnDropOnEmpty;
781: case 'ForceHelperSize': return $this->blnForceHelperSize;
782: case 'ForcePlaceholderSize': return $this->blnForcePlaceholderSize;
783: case 'Grid': return $this->arrGrid;
784: case 'Handle': return $this->mixHandle;
785: case 'Helper': return $this->mixHelper;
786: case 'Items': return $this->mixItems;
787: case 'Opacity': return $this->intOpacity;
788: case 'Placeholder': return $this->strPlaceholder;
789: case 'Revert': return $this->mixRevert;
790: case 'Scroll': return $this->blnScroll;
791: case 'ScrollSensitivity': return $this->intScrollSensitivity;
792: case 'ScrollSpeed': return $this->intScrollSpeed;
793: case 'Tolerance': return $this->strTolerance;
794: case 'ZIndex': return $this->intZIndex;
795: default:
796: try {
797: return parent::__get($strName);
798: } catch (QCallerException $objExc) {
799: $objExc->IncrementOffset();
800: throw $objExc;
801: }
802: }
803: }
804:
805: public function __set($strName, $mixValue) {
806: switch ($strName) {
807: case 'AppendTo':
808: $this->mixAppendTo = $mixValue;
809: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'appendTo', $mixValue);
810: break;
811:
812: case 'Axis':
813: try {
814: $this->strAxis = QType::Cast($mixValue, QType::String);
815: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'axis', $this->strAxis);
816: break;
817: } catch (QInvalidCastException $objExc) {
818: $objExc->IncrementOffset();
819: throw $objExc;
820: }
821:
822: case 'Cancel':
823: $this->mixCancel = $mixValue;
824: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'cancel', $mixValue);
825: break;
826:
827: case 'ConnectWith':
828: $this->mixConnectWith = $mixValue;
829: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'connectWith', $mixValue);
830: break;
831:
832: case 'Containment':
833: $this->mixContainment = $mixValue;
834: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'containment', $mixValue);
835: break;
836:
837: case 'Cursor':
838: try {
839: $this->strCursor = QType::Cast($mixValue, QType::String);
840: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'cursor', $this->strCursor);
841: break;
842: } catch (QInvalidCastException $objExc) {
843: $objExc->IncrementOffset();
844: throw $objExc;
845: }
846:
847: case 'CursorAt':
848: $this->mixCursorAt = $mixValue;
849: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'cursorAt', $mixValue);
850: break;
851:
852: case 'Delay':
853: try {
854: $this->intDelay = QType::Cast($mixValue, QType::Integer);
855: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'delay', $this->intDelay);
856: break;
857: } catch (QInvalidCastException $objExc) {
858: $objExc->IncrementOffset();
859: throw $objExc;
860: }
861:
862: case 'Disabled':
863: try {
864: $this->blnDisabled = QType::Cast($mixValue, QType::Boolean);
865: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'disabled', $this->blnDisabled);
866: break;
867: } catch (QInvalidCastException $objExc) {
868: $objExc->IncrementOffset();
869: throw $objExc;
870: }
871:
872: case 'Distance':
873: try {
874: $this->intDistance = QType::Cast($mixValue, QType::Integer);
875: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'distance', $this->intDistance);
876: break;
877: } catch (QInvalidCastException $objExc) {
878: $objExc->IncrementOffset();
879: throw $objExc;
880: }
881:
882: case 'DropOnEmpty':
883: try {
884: $this->blnDropOnEmpty = QType::Cast($mixValue, QType::Boolean);
885: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'dropOnEmpty', $this->blnDropOnEmpty);
886: break;
887: } catch (QInvalidCastException $objExc) {
888: $objExc->IncrementOffset();
889: throw $objExc;
890: }
891:
892: case 'ForceHelperSize':
893: try {
894: $this->blnForceHelperSize = QType::Cast($mixValue, QType::Boolean);
895: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'forceHelperSize', $this->blnForceHelperSize);
896: break;
897: } catch (QInvalidCastException $objExc) {
898: $objExc->IncrementOffset();
899: throw $objExc;
900: }
901:
902: case 'ForcePlaceholderSize':
903: try {
904: $this->blnForcePlaceholderSize = QType::Cast($mixValue, QType::Boolean);
905: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'forcePlaceholderSize', $this->blnForcePlaceholderSize);
906: break;
907: } catch (QInvalidCastException $objExc) {
908: $objExc->IncrementOffset();
909: throw $objExc;
910: }
911:
912: case 'Grid':
913: try {
914: $this->arrGrid = QType::Cast($mixValue, QType::ArrayType);
915: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'grid', $this->arrGrid);
916: break;
917: } catch (QInvalidCastException $objExc) {
918: $objExc->IncrementOffset();
919: throw $objExc;
920: }
921:
922: case 'Handle':
923: $this->mixHandle = $mixValue;
924: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'handle', $mixValue);
925: break;
926:
927: case 'Helper':
928: $this->mixHelper = $mixValue;
929: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'helper', $mixValue);
930: break;
931:
932: case 'Items':
933: $this->mixItems = $mixValue;
934: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'items', $mixValue);
935: break;
936:
937: case 'Opacity':
938: try {
939: $this->intOpacity = QType::Cast($mixValue, QType::Integer);
940: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'opacity', $this->intOpacity);
941: break;
942: } catch (QInvalidCastException $objExc) {
943: $objExc->IncrementOffset();
944: throw $objExc;
945: }
946:
947: case 'Placeholder':
948: try {
949: $this->strPlaceholder = QType::Cast($mixValue, QType::String);
950: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'placeholder', $this->strPlaceholder);
951: break;
952: } catch (QInvalidCastException $objExc) {
953: $objExc->IncrementOffset();
954: throw $objExc;
955: }
956:
957: case 'Revert':
958: $this->mixRevert = $mixValue;
959: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'revert', $mixValue);
960: break;
961:
962: case 'Scroll':
963: try {
964: $this->blnScroll = QType::Cast($mixValue, QType::Boolean);
965: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'scroll', $this->blnScroll);
966: break;
967: } catch (QInvalidCastException $objExc) {
968: $objExc->IncrementOffset();
969: throw $objExc;
970: }
971:
972: case 'ScrollSensitivity':
973: try {
974: $this->intScrollSensitivity = QType::Cast($mixValue, QType::Integer);
975: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'scrollSensitivity', $this->intScrollSensitivity);
976: break;
977: } catch (QInvalidCastException $objExc) {
978: $objExc->IncrementOffset();
979: throw $objExc;
980: }
981:
982: case 'ScrollSpeed':
983: try {
984: $this->intScrollSpeed = QType::Cast($mixValue, QType::Integer);
985: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'scrollSpeed', $this->intScrollSpeed);
986: break;
987: } catch (QInvalidCastException $objExc) {
988: $objExc->IncrementOffset();
989: throw $objExc;
990: }
991:
992: case 'Tolerance':
993: try {
994: $this->strTolerance = QType::Cast($mixValue, QType::String);
995: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'tolerance', $this->strTolerance);
996: break;
997: } catch (QInvalidCastException $objExc) {
998: $objExc->IncrementOffset();
999: throw $objExc;
1000: }
1001:
1002: case 'ZIndex':
1003: try {
1004: $this->intZIndex = QType::Cast($mixValue, QType::Integer);
1005: $this->AddAttributeScript($this->getJqSetupFunction(), 'option', 'zIndex', $this->intZIndex);
1006: break;
1007: } catch (QInvalidCastException $objExc) {
1008: $objExc->IncrementOffset();
1009: throw $objExc;
1010: }
1011:
1012:
1013: case 'Enabled':
1014: $this->Disabled = !$mixValue; // Tie in standard QCubed functionality
1015: parent::__set($strName, $mixValue);
1016: break;
1017:
1018: default:
1019: try {
1020: parent::__set($strName, $mixValue);
1021: break;
1022: } catch (QCallerException $objExc) {
1023: $objExc->IncrementOffset();
1024: throw $objExc;
1025: }
1026: }
1027: }
1028:
1029: /**
1030: * If this control is attachable to a codegenerated control in a ModelConnector, this function will be
1031: * used by the ModelConnector designer dialog to display a list of options for the control.
1032: * @return QModelConnectorParam[]
1033: **/
1034: public static function GetModelConnectorParams() {
1035: return array_merge(parent::GetModelConnectorParams(), array(
1036: new QModelConnectorParam (get_called_class(), 'Axis', 'If defined, the items can be dragged only horizontally or vertically.Possible values: \"x\", \"y\".', QType::String),
1037: new QModelConnectorParam (get_called_class(), 'Cursor', 'Defines the cursor that is being shown while sorting.', QType::String),
1038: new QModelConnectorParam (get_called_class(), 'Delay', 'Time in milliseconds to define when the sorting should start. Adding adelay helps preventing unwanted drags when clicking on an element.', QType::Integer),
1039: new QModelConnectorParam (get_called_class(), 'Disabled', 'Disables the sortable if set to true.', QType::Boolean),
1040: new QModelConnectorParam (get_called_class(), 'Distance', 'Tolerance, in pixels, for when sorting should start. If specified,sorting will not start until after mouse is dragged beyond distance.Can be used to allow for clicks on elements within a handle.', QType::Integer),
1041: new QModelConnectorParam (get_called_class(), 'DropOnEmpty', 'If false, items from this sortable cant be dropped on an empty connectsortable (see the connectWith option.', QType::Boolean),
1042: new QModelConnectorParam (get_called_class(), 'ForceHelperSize', 'If true, forces the helper to have a size.', QType::Boolean),
1043: new QModelConnectorParam (get_called_class(), 'ForcePlaceholderSize', 'If true, forces the placeholder to have a size.', QType::Boolean),
1044: new QModelConnectorParam (get_called_class(), 'Grid', 'Snaps the sorting element or helper to a grid, every x and y pixels.Array values: [ x, y ].', QType::ArrayType),
1045: new QModelConnectorParam (get_called_class(), 'Opacity', 'Defines the opacity of the helper while sorting. From 0.01 to 1.', QType::Integer),
1046: new QModelConnectorParam (get_called_class(), 'Placeholder', 'A class name that gets applied to the otherwise white space.', QType::String),
1047: new QModelConnectorParam (get_called_class(), 'Scroll', 'If set to true, the page scrolls when coming to an edge.', QType::Boolean),
1048: new QModelConnectorParam (get_called_class(), 'ScrollSensitivity', 'Defines how near the mouse must be to an edge to start scrolling.', QType::Integer),
1049: new QModelConnectorParam (get_called_class(), 'ScrollSpeed', 'The speed at which the window should scroll once the mouse pointergets within the scrollSensitivity distance.', QType::Integer),
1050: new QModelConnectorParam (get_called_class(), 'Tolerance', 'Specifies which mode to use for testing whether the item being movedis hovering over another item. Possible values: * \"intersect\": The item overlaps the other item by at least 50%. * \"pointer\": The mouse pointer overlaps the other item.', QType::String),
1051: new QModelConnectorParam (get_called_class(), 'ZIndex', 'Z-index for element/helper while being sorted.', QType::Integer),
1052: ));
1053: }
1054: }