app/jquery/jquery-ui.sortable.js
author Lennard de Rijk <ljvderijk@gmail.com>
Tue, 25 Aug 2009 11:43:14 +0200
changeset 2795 776aae4d0499
parent 2749 4e2789b8e86d
permissions -rw-r--r--
Set new Melange version number to 0-5-20090825 in app.yaml.template.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
     1
/*
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
     2
 * jQuery UI Sortable 1.7.2
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
     3
 *
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
     4
 * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
     5
 * Dual licensed under the MIT (MIT-LICENSE.txt)
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
     6
 * and GPL (GPL-LICENSE.txt) licenses.
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
     7
 *
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
     8
 * http://docs.jquery.com/UI/Sortables
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
     9
 *
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    10
 * Depends:
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    11
 *	ui.core.js
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    12
 */
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    13
(function($) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    14
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    15
$.widget("ui.sortable", $.extend({}, $.ui.mouse, {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    16
	_init: function() {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    17
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    18
		var o = this.options;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    19
		this.containerCache = {};
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    20
		this.element.addClass("ui-sortable");
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    21
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    22
		//Get the items
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    23
		this.refresh();
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    24
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    25
		//Let's determine if the items are floating
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    26
		this.floating = this.items.length ? (/left|right/).test(this.items[0].item.css('float')) : false;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    27
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    28
		//Let's determine the parent's offset
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    29
		this.offset = this.element.offset();
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    30
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    31
		//Initialize mouse events for interaction
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    32
		this._mouseInit();
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    33
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    34
	},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    35
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    36
	destroy: function() {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    37
		this.element
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    38
			.removeClass("ui-sortable ui-sortable-disabled")
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    39
			.removeData("sortable")
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    40
			.unbind(".sortable");
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    41
		this._mouseDestroy();
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    42
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    43
		for ( var i = this.items.length - 1; i >= 0; i-- )
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    44
			this.items[i].item.removeData("sortable-item");
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    45
	},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    46
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    47
	_mouseCapture: function(event, overrideHandle) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    48
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    49
		if (this.reverting) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    50
			return false;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    51
		}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    52
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    53
		if(this.options.disabled || this.options.type == 'static') return false;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    54
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    55
		//We have to refresh the items data once first
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    56
		this._refreshItems(event);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    57
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    58
		//Find out if the clicked node (or one of its parents) is a actual item in this.items
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    59
		var currentItem = null, self = this, nodes = $(event.target).parents().each(function() {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    60
			if($.data(this, 'sortable-item') == self) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    61
				currentItem = $(this);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    62
				return false;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    63
			}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    64
		});
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    65
		if($.data(event.target, 'sortable-item') == self) currentItem = $(event.target);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    66
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    67
		if(!currentItem) return false;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    68
		if(this.options.handle && !overrideHandle) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    69
			var validHandle = false;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    70
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    71
			$(this.options.handle, currentItem).find("*").andSelf().each(function() { if(this == event.target) validHandle = true; });
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    72
			if(!validHandle) return false;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    73
		}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    74
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    75
		this.currentItem = currentItem;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    76
		this._removeCurrentsFromItems();
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    77
		return true;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    78
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    79
	},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    80
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    81
	_mouseStart: function(event, overrideHandle, noActivation) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    82
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
    83
		var o = this.options, self = this;
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    84
		this.currentContainer = this;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    85
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    86
		//We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    87
		this.refreshPositions();
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    88
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    89
		//Create and append the visible helper
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    90
		this.helper = this._createHelper(event);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    91
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    92
		//Cache the helper size
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    93
		this._cacheHelperProportions();
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    94
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    95
		/*
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    96
		 * - Position generation -
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    97
		 * This block generates everything position related - it's the core of draggables.
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    98
		 */
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    99
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   100
		//Cache the margins of the original element
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   101
		this._cacheMargins();
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   102
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   103
		//Get the next scrolling parent
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   104
		this.scrollParent = this.helper.scrollParent();
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   105
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   106
		//The element's absolute position on the page minus margins
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   107
		this.offset = this.currentItem.offset();
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   108
		this.offset = {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   109
			top: this.offset.top - this.margins.top,
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   110
			left: this.offset.left - this.margins.left
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   111
		};
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   112
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   113
		// Only after we got the offset, we can change the helper's position to absolute
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   114
		// TODO: Still need to figure out a way to make relative sorting possible
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   115
		this.helper.css("position", "absolute");
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   116
		this.cssPosition = this.helper.css("position");
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   117
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   118
		$.extend(this.offset, {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   119
			click: { //Where the click happened, relative to the element
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   120
				left: event.pageX - this.offset.left,
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   121
				top: event.pageY - this.offset.top
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   122
			},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   123
			parent: this._getParentOffset(),
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   124
			relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   125
		});
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   126
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   127
		//Generate the original position
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   128
		this.originalPosition = this._generatePosition(event);
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   129
		this.originalPageX = event.pageX;
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   130
		this.originalPageY = event.pageY;
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   131
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   132
		//Adjust the mouse offset relative to the helper if 'cursorAt' is supplied
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   133
		if(o.cursorAt)
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   134
			this._adjustOffsetFromHelper(o.cursorAt);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   135
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   136
		//Cache the former DOM position
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   137
		this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   138
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   139
		//If the helper is not the original, hide the original so it's not playing any role during the drag, won't cause anything bad this way
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   140
		if(this.helper[0] != this.currentItem[0]) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   141
			this.currentItem.hide();
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   142
		}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   143
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   144
		//Create the placeholder
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   145
		this._createPlaceholder();
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   146
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   147
		//Set a containment if given in the options
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   148
		if(o.containment)
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   149
			this._setContainment();
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   150
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   151
		if(o.cursor) { // cursor option
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   152
			if ($('body').css("cursor")) this._storedCursor = $('body').css("cursor");
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   153
			$('body').css("cursor", o.cursor);
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   154
		}
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   155
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   156
		if(o.opacity) { // opacity option
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   157
			if (this.helper.css("opacity")) this._storedOpacity = this.helper.css("opacity");
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   158
			this.helper.css("opacity", o.opacity);
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   159
		}
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   160
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   161
		if(o.zIndex) { // zIndex option
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   162
			if (this.helper.css("zIndex")) this._storedZIndex = this.helper.css("zIndex");
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   163
			this.helper.css("zIndex", o.zIndex);
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   164
		}
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   165
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   166
		//Prepare scrolling
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   167
		if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML')
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   168
			this.overflowOffset = this.scrollParent.offset();
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   169
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   170
		//Call callbacks
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   171
		this._trigger("start", event, this._uiHash());
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   172
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   173
		//Recache the helper size
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   174
		if(!this._preserveHelperProportions)
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   175
			this._cacheHelperProportions();
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   176
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   177
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   178
		//Post 'activate' events to possible containers
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   179
		if(!noActivation) {
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   180
			 for (var i = this.containers.length - 1; i >= 0; i--) { this.containers[i]._trigger("activate", event, self._uiHash(this)); }
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   181
		}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   182
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   183
		//Prepare possible droppables
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   184
		if($.ui.ddmanager)
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   185
			$.ui.ddmanager.current = this;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   186
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   187
		if ($.ui.ddmanager && !o.dropBehaviour)
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   188
			$.ui.ddmanager.prepareOffsets(this, event);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   189
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   190
		this.dragging = true;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   191
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   192
		this.helper.addClass("ui-sortable-helper");
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   193
		this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   194
		return true;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   195
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   196
	},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   197
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   198
	_mouseDrag: function(event) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   199
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   200
		//Compute the helpers position
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   201
		this.position = this._generatePosition(event);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   202
		this.positionAbs = this._convertPositionTo("absolute");
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   203
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   204
		if (!this.lastPositionAbs) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   205
			this.lastPositionAbs = this.positionAbs;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   206
		}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   207
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   208
		//Do scrolling
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   209
		if(this.options.scroll) {
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   210
			var o = this.options, scrolled = false;
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   211
			if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML') {
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   212
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   213
				if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   214
					this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   215
				else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity)
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   216
					this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   217
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   218
				if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   219
					this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   220
				else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity)
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   221
					this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   222
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   223
			} else {
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   224
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   225
				if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   226
					scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   227
				else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   228
					scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   229
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   230
				if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   231
					scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   232
				else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   233
					scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   234
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   235
			}
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   236
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   237
			if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   238
				$.ui.ddmanager.prepareOffsets(this, event);
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   239
		}
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   240
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   241
		//Regenerate the absolute position used for position checks
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   242
		this.positionAbs = this._convertPositionTo("absolute");
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   243
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   244
		//Set the helper position
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   245
		if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   246
		if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   247
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   248
		//Rearrange
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   249
		for (var i = this.items.length - 1; i >= 0; i--) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   250
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   251
			//Cache variables and intersection, continue if no intersection
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   252
			var item = this.items[i], itemElement = item.item[0], intersection = this._intersectsWithPointer(item);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   253
			if (!intersection) continue;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   254
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   255
			if(itemElement != this.currentItem[0] //cannot intersect with itself
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   256
				&&	this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != itemElement //no useless actions that have been done before
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   257
				&&	!$.ui.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   258
				&& (this.options.type == 'semi-dynamic' ? !$.ui.contains(this.element[0], itemElement) : true)
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   259
			) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   260
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   261
				this.direction = intersection == 1 ? "down" : "up";
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   262
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   263
				if (this.options.tolerance == "pointer" || this._intersectsWithSides(item)) {
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   264
					this._rearrange(event, item);
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   265
				} else {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   266
					break;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   267
				}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   268
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   269
				this._trigger("change", event, this._uiHash());
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   270
				break;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   271
			}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   272
		}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   273
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   274
		//Post events to containers
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   275
		this._contactContainers(event);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   276
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   277
		//Interconnect with droppables
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   278
		if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   279
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   280
		//Call callbacks
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   281
		this._trigger('sort', event, this._uiHash());
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   282
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   283
		this.lastPositionAbs = this.positionAbs;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   284
		return false;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   285
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   286
	},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   287
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   288
	_mouseStop: function(event, noPropagation) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   289
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   290
		if(!event) return;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   291
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   292
		//If we are using droppables, inform the manager about the drop
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   293
		if ($.ui.ddmanager && !this.options.dropBehaviour)
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   294
			$.ui.ddmanager.drop(this, event);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   295
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   296
		if(this.options.revert) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   297
			var self = this;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   298
			var cur = self.placeholder.offset();
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   299
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   300
			self.reverting = true;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   301
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   302
			$(this.helper).animate({
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   303
				left: cur.left - this.offset.parent.left - self.margins.left + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft),
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   304
				top: cur.top - this.offset.parent.top - self.margins.top + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop)
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   305
			}, parseInt(this.options.revert, 10) || 500, function() {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   306
				self._clear(event);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   307
			});
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   308
		} else {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   309
			this._clear(event, noPropagation);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   310
		}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   311
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   312
		return false;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   313
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   314
	},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   315
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   316
	cancel: function() {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   317
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   318
		var self = this;
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   319
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   320
		if(this.dragging) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   321
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   322
			this._mouseUp();
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   323
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   324
			if(this.options.helper == "original")
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   325
				this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   326
			else
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   327
				this.currentItem.show();
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   328
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   329
			//Post deactivating events to containers
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   330
			for (var i = this.containers.length - 1; i >= 0; i--){
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   331
				this.containers[i]._trigger("deactivate", null, self._uiHash(this));
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   332
				if(this.containers[i].containerCache.over) {
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   333
					this.containers[i]._trigger("out", null, self._uiHash(this));
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   334
					this.containers[i].containerCache.over = 0;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   335
				}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   336
			}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   337
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   338
		}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   339
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   340
		//$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   341
		if(this.placeholder[0].parentNode) this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   342
		if(this.options.helper != "original" && this.helper && this.helper[0].parentNode) this.helper.remove();
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   343
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   344
		$.extend(this, {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   345
			helper: null,
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   346
			dragging: false,
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   347
			reverting: false,
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   348
			_noFinalSort: null
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   349
		});
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   350
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   351
		if(this.domPosition.prev) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   352
			$(this.domPosition.prev).after(this.currentItem);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   353
		} else {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   354
			$(this.domPosition.parent).prepend(this.currentItem);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   355
		}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   356
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   357
		return true;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   358
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   359
	},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   360
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   361
	serialize: function(o) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   362
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   363
		var items = this._getItemsAsjQuery(o && o.connected);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   364
		var str = []; o = o || {};
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   365
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   366
		$(items).each(function() {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   367
			var res = ($(o.item || this).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   368
			if(res) str.push((o.key || res[1]+'[]')+'='+(o.key && o.expression ? res[1] : res[2]));
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   369
		});
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   370
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   371
		return str.join('&');
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   372
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   373
	},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   374
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   375
	toArray: function(o) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   376
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   377
		var items = this._getItemsAsjQuery(o && o.connected);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   378
		var ret = []; o = o || {};
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   379
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   380
		items.each(function() { ret.push($(o.item || this).attr(o.attribute || 'id') || ''); });
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   381
		return ret;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   382
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   383
	},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   384
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   385
	/* Be careful with the following core functions */
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   386
	_intersectsWith: function(item) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   387
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   388
		var x1 = this.positionAbs.left,
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   389
			x2 = x1 + this.helperProportions.width,
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   390
			y1 = this.positionAbs.top,
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   391
			y2 = y1 + this.helperProportions.height;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   392
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   393
		var l = item.left,
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   394
			r = l + item.width,
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   395
			t = item.top,
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   396
			b = t + item.height;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   397
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   398
		var dyClick = this.offset.click.top,
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   399
			dxClick = this.offset.click.left;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   400
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   401
		var isOverElement = (y1 + dyClick) > t && (y1 + dyClick) < b && (x1 + dxClick) > l && (x1 + dxClick) < r;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   402
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   403
		if(	   this.options.tolerance == "pointer"
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   404
			|| this.options.forcePointerForContainers
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   405
			|| (this.options.tolerance != "pointer" && this.helperProportions[this.floating ? 'width' : 'height'] > item[this.floating ? 'width' : 'height'])
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   406
		) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   407
			return isOverElement;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   408
		} else {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   409
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   410
			return (l < x1 + (this.helperProportions.width / 2) // Right Half
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   411
				&& x2 - (this.helperProportions.width / 2) < r // Left Half
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   412
				&& t < y1 + (this.helperProportions.height / 2) // Bottom Half
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   413
				&& y2 - (this.helperProportions.height / 2) < b ); // Top Half
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   414
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   415
		}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   416
	},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   417
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   418
	_intersectsWithPointer: function(item) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   419
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   420
		var isOverElementHeight = $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   421
			isOverElementWidth = $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   422
			isOverElement = isOverElementHeight && isOverElementWidth,
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   423
			verticalDirection = this._getDragVerticalDirection(),
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   424
			horizontalDirection = this._getDragHorizontalDirection();
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   425
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   426
		if (!isOverElement)
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   427
			return false;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   428
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   429
		return this.floating ?
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   430
			( ((horizontalDirection && horizontalDirection == "right") || verticalDirection == "down") ? 2 : 1 )
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   431
			: ( verticalDirection && (verticalDirection == "down" ? 2 : 1) );
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   432
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   433
	},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   434
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   435
	_intersectsWithSides: function(item) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   436
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   437
		var isOverBottomHalf = $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   438
			isOverRightHalf = $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   439
			verticalDirection = this._getDragVerticalDirection(),
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   440
			horizontalDirection = this._getDragHorizontalDirection();
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   441
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   442
		if (this.floating && horizontalDirection) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   443
			return ((horizontalDirection == "right" && isOverRightHalf) || (horizontalDirection == "left" && !isOverRightHalf));
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   444
		} else {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   445
			return verticalDirection && ((verticalDirection == "down" && isOverBottomHalf) || (verticalDirection == "up" && !isOverBottomHalf));
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   446
		}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   447
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   448
	},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   449
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   450
	_getDragVerticalDirection: function() {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   451
		var delta = this.positionAbs.top - this.lastPositionAbs.top;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   452
		return delta != 0 && (delta > 0 ? "down" : "up");
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   453
	},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   454
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   455
	_getDragHorizontalDirection: function() {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   456
		var delta = this.positionAbs.left - this.lastPositionAbs.left;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   457
		return delta != 0 && (delta > 0 ? "right" : "left");
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   458
	},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   459
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   460
	refresh: function(event) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   461
		this._refreshItems(event);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   462
		this.refreshPositions();
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   463
	},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   464
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   465
	_connectWith: function() {
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   466
		var options = this.options;
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   467
		return options.connectWith.constructor == String
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   468
			? [options.connectWith]
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   469
			: options.connectWith;
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   470
	},
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   471
	
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   472
	_getItemsAsjQuery: function(connected) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   473
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   474
		var self = this;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   475
		var items = [];
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   476
		var queries = [];
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   477
		var connectWith = this._connectWith();
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   478
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   479
		if(connectWith && connected) {
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   480
			for (var i = connectWith.length - 1; i >= 0; i--){
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   481
				var cur = $(connectWith[i]);
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   482
				for (var j = cur.length - 1; j >= 0; j--){
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   483
					var inst = $.data(cur[j], 'sortable');
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   484
					if(inst && inst != this && !inst.options.disabled) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   485
						queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not(".ui-sortable-helper"), inst]);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   486
					}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   487
				};
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   488
			};
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   489
		}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   490
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   491
		queries.push([$.isFunction(this.options.items) ? this.options.items.call(this.element, null, { options: this.options, item: this.currentItem }) : $(this.options.items, this.element).not(".ui-sortable-helper"), this]);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   492
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   493
		for (var i = queries.length - 1; i >= 0; i--){
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   494
			queries[i][0].each(function() {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   495
				items.push(this);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   496
			});
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   497
		};
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   498
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   499
		return $(items);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   500
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   501
	},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   502
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   503
	_removeCurrentsFromItems: function() {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   504
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   505
		var list = this.currentItem.find(":data(sortable-item)");
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   506
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   507
		for (var i=0; i < this.items.length; i++) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   508
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   509
			for (var j=0; j < list.length; j++) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   510
				if(list[j] == this.items[i].item[0])
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   511
					this.items.splice(i,1);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   512
			};
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   513
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   514
		};
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   515
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   516
	},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   517
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   518
	_refreshItems: function(event) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   519
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   520
		this.items = [];
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   521
		this.containers = [this];
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   522
		var items = this.items;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   523
		var self = this;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   524
		var queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]];
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   525
		var connectWith = this._connectWith();
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   526
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   527
		if(connectWith) {
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   528
			for (var i = connectWith.length - 1; i >= 0; i--){
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   529
				var cur = $(connectWith[i]);
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   530
				for (var j = cur.length - 1; j >= 0; j--){
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   531
					var inst = $.data(cur[j], 'sortable');
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   532
					if(inst && inst != this && !inst.options.disabled) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   533
						queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   534
						this.containers.push(inst);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   535
					}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   536
				};
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   537
			};
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   538
		}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   539
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   540
		for (var i = queries.length - 1; i >= 0; i--) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   541
			var targetData = queries[i][1];
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   542
			var _queries = queries[i][0];
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   543
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   544
			for (var j=0, queriesLength = _queries.length; j < queriesLength; j++) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   545
				var item = $(_queries[j]);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   546
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   547
				item.data('sortable-item', targetData); // Data for target checking (mouse manager)
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   548
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   549
				items.push({
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   550
					item: item,
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   551
					instance: targetData,
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   552
					width: 0, height: 0,
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   553
					left: 0, top: 0
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   554
				});
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   555
			};
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   556
		};
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   557
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   558
	},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   559
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   560
	refreshPositions: function(fast) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   561
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   562
		//This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   563
		if(this.offsetParent && this.helper) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   564
			this.offset.parent = this._getParentOffset();
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   565
		}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   566
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   567
		for (var i = this.items.length - 1; i >= 0; i--){
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   568
			var item = this.items[i];
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   569
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   570
			//We ignore calculating positions of all connected containers when we're not over them
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   571
			if(item.instance != this.currentContainer && this.currentContainer && item.item[0] != this.currentItem[0])
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   572
				continue;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   573
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   574
			var t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   575
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   576
			if (!fast) {
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   577
				item.width = t.outerWidth();
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   578
				item.height = t.outerHeight();
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   579
			}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   580
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   581
			var p = t.offset();
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   582
			item.left = p.left;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   583
			item.top = p.top;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   584
		};
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   585
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   586
		if(this.options.custom && this.options.custom.refreshContainers) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   587
			this.options.custom.refreshContainers.call(this);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   588
		} else {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   589
			for (var i = this.containers.length - 1; i >= 0; i--){
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   590
				var p = this.containers[i].element.offset();
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   591
				this.containers[i].containerCache.left = p.left;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   592
				this.containers[i].containerCache.top = p.top;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   593
				this.containers[i].containerCache.width	= this.containers[i].element.outerWidth();
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   594
				this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   595
			};
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   596
		}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   597
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   598
	},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   599
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   600
	_createPlaceholder: function(that) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   601
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   602
		var self = that || this, o = self.options;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   603
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   604
		if(!o.placeholder || o.placeholder.constructor == String) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   605
			var className = o.placeholder;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   606
			o.placeholder = {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   607
				element: function() {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   608
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   609
					var el = $(document.createElement(self.currentItem[0].nodeName))
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   610
						.addClass(className || self.currentItem[0].className+" ui-sortable-placeholder")
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   611
						.removeClass("ui-sortable-helper")[0];
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   612
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   613
					if(!className)
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   614
						el.style.visibility = "hidden";
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   615
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   616
					return el;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   617
				},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   618
				update: function(container, p) {
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   619
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   620
					// 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   621
					// 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   622
					if(className && !o.forcePlaceholderSize) return;
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   623
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   624
					//If the element doesn't have a actual height by itself (without styles coming from a stylesheet), it receives the inline height from the dragged item
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   625
					if(!p.height()) { p.height(self.currentItem.innerHeight() - parseInt(self.currentItem.css('paddingTop')||0, 10) - parseInt(self.currentItem.css('paddingBottom')||0, 10)); };
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   626
					if(!p.width()) { p.width(self.currentItem.innerWidth() - parseInt(self.currentItem.css('paddingLeft')||0, 10) - parseInt(self.currentItem.css('paddingRight')||0, 10)); };
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   627
				}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   628
			};
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   629
		}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   630
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   631
		//Create the placeholder
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   632
		self.placeholder = $(o.placeholder.element.call(self.element, self.currentItem));
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   633
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   634
		//Append it after the actual current item
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   635
		self.currentItem.after(self.placeholder);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   636
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   637
		//Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   638
		o.placeholder.update(self, self.placeholder);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   639
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   640
	},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   641
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   642
	_contactContainers: function(event) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   643
		for (var i = this.containers.length - 1; i >= 0; i--){
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   644
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   645
			if(this._intersectsWith(this.containers[i].containerCache)) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   646
				if(!this.containers[i].containerCache.over) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   647
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   648
					if(this.currentContainer != this.containers[i]) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   649
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   650
						//When entering a new container, we will find the item with the least distance and append our item near it
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   651
						var dist = 10000; var itemWithLeastDistance = null; var base = this.positionAbs[this.containers[i].floating ? 'left' : 'top'];
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   652
						for (var j = this.items.length - 1; j >= 0; j--) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   653
							if(!$.ui.contains(this.containers[i].element[0], this.items[j].item[0])) continue;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   654
							var cur = this.items[j][this.containers[i].floating ? 'left' : 'top'];
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   655
							if(Math.abs(cur - base) < dist) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   656
								dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   657
							}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   658
						}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   659
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   660
						if(!itemWithLeastDistance && !this.options.dropOnEmpty) //Check if dropOnEmpty is enabled
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   661
							continue;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   662
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   663
						this.currentContainer = this.containers[i];
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   664
						itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[i].element, true);
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   665
						this._trigger("change", event, this._uiHash());
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   666
						this.containers[i]._trigger("change", event, this._uiHash(this));
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   667
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   668
						//Update the placeholder
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   669
						this.options.placeholder.update(this.currentContainer, this.placeholder);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   670
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   671
					}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   672
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   673
					this.containers[i]._trigger("over", event, this._uiHash(this));
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   674
					this.containers[i].containerCache.over = 1;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   675
				}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   676
			} else {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   677
				if(this.containers[i].containerCache.over) {
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   678
					this.containers[i]._trigger("out", event, this._uiHash(this));
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   679
					this.containers[i].containerCache.over = 0;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   680
				}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   681
			}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   682
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   683
		};
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   684
	},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   685
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   686
	_createHelper: function(event) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   687
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   688
		var o = this.options;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   689
		var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper == 'clone' ? this.currentItem.clone() : this.currentItem);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   690
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   691
		if(!helper.parents('body').length) //Add the helper to the DOM if that didn't happen already
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   692
			$(o.appendTo != 'parent' ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   693
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   694
		if(helper[0] == this.currentItem[0])
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   695
			this._storedCSS = { width: this.currentItem[0].style.width, height: this.currentItem[0].style.height, position: this.currentItem.css("position"), top: this.currentItem.css("top"), left: this.currentItem.css("left") };
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   696
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   697
		if(helper[0].style.width == '' || o.forceHelperSize) helper.width(this.currentItem.width());
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   698
		if(helper[0].style.height == '' || o.forceHelperSize) helper.height(this.currentItem.height());
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   699
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   700
		return helper;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   701
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   702
	},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   703
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   704
	_adjustOffsetFromHelper: function(obj) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   705
		if(obj.left != undefined) this.offset.click.left = obj.left + this.margins.left;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   706
		if(obj.right != undefined) this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   707
		if(obj.top != undefined) this.offset.click.top = obj.top + this.margins.top;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   708
		if(obj.bottom != undefined) this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   709
	},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   710
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   711
	_getParentOffset: function() {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   712
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   713
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   714
		//Get the offsetParent and cache its position
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   715
		this.offsetParent = this.helper.offsetParent();
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   716
		var po = this.offsetParent.offset();
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   717
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   718
		// This is a special case where we need to modify a offset calculated on start, since the following happened:
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   719
		// 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   720
		// 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   721
		//    the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   722
		if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) {
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   723
			po.left += this.scrollParent.scrollLeft();
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   724
			po.top += this.scrollParent.scrollTop();
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   725
		}
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   726
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   727
		if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   728
		|| (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   729
			po = { top: 0, left: 0 };
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   730
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   731
		return {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   732
			top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   733
			left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   734
		};
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   735
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   736
	},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   737
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   738
	_getRelativeOffset: function() {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   739
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   740
		if(this.cssPosition == "relative") {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   741
			var p = this.currentItem.position();
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   742
			return {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   743
				top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   744
				left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   745
			};
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   746
		} else {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   747
			return { top: 0, left: 0 };
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   748
		}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   749
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   750
	},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   751
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   752
	_cacheMargins: function() {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   753
		this.margins = {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   754
			left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   755
			top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   756
		};
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   757
	},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   758
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   759
	_cacheHelperProportions: function() {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   760
		this.helperProportions = {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   761
			width: this.helper.outerWidth(),
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   762
			height: this.helper.outerHeight()
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   763
		};
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   764
	},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   765
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   766
	_setContainment: function() {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   767
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   768
		var o = this.options;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   769
		if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   770
		if(o.containment == 'document' || o.containment == 'window') this.containment = [
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   771
			0 - this.offset.relative.left - this.offset.parent.left,
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   772
			0 - this.offset.relative.top - this.offset.parent.top,
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   773
			$(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left,
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   774
			($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   775
		];
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   776
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   777
		if(!(/^(document|window|parent)$/).test(o.containment)) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   778
			var ce = $(o.containment)[0];
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   779
			var co = $(o.containment).offset();
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   780
			var over = ($(ce).css("overflow") != 'hidden');
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   781
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   782
			this.containment = [
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   783
				co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   784
				co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   785
				co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left,
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   786
				co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   787
			];
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   788
		}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   789
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   790
	},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   791
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   792
	_convertPositionTo: function(d, pos) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   793
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   794
		if(!pos) pos = this.position;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   795
		var mod = d == "absolute" ? 1 : -1;
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   796
		var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   797
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   798
		return {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   799
			top: (
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   800
				pos.top																	// The absolute mouse position
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   801
				+ this.offset.relative.top * mod										// Only for relative positioned nodes: Relative offset from element to offset parent
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   802
				+ this.offset.parent.top * mod											// The offsetParent's offset without borders (offset + border)
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   803
				- ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   804
			),
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   805
			left: (
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   806
				pos.left																// The absolute mouse position
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   807
				+ this.offset.relative.left * mod										// Only for relative positioned nodes: Relative offset from element to offset parent
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   808
				+ this.offset.parent.left * mod											// The offsetParent's offset without borders (offset + border)
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   809
				- ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   810
			)
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   811
		};
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   812
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   813
	},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   814
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   815
	_generatePosition: function(event) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   816
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   817
		var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   818
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   819
		// This is another very weird special case that only happens for relative elements:
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   820
		// 1. If the css position is relative
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   821
		// 2. and the scroll parent is the document or similar to the offset parent
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   822
		// we have to refresh the relative offset during the scroll so there are no jumps
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   823
		if(this.cssPosition == 'relative' && !(this.scrollParent[0] != document && this.scrollParent[0] != this.offsetParent[0])) {
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   824
			this.offset.relative = this._getRelativeOffset();
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   825
		}
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   826
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   827
		var pageX = event.pageX;
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   828
		var pageY = event.pageY;
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   829
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   830
		/*
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   831
		 * - Position constraining -
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   832
		 * Constrain the position to a mix of grid, containment.
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   833
		 */
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   834
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   835
		if(this.originalPosition) { //If we are not dragging yet, we won't check for options
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   836
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   837
			if(this.containment) {
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   838
				if(event.pageX - this.offset.click.left < this.containment[0]) pageX = this.containment[0] + this.offset.click.left;
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   839
				if(event.pageY - this.offset.click.top < this.containment[1]) pageY = this.containment[1] + this.offset.click.top;
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   840
				if(event.pageX - this.offset.click.left > this.containment[2]) pageX = this.containment[2] + this.offset.click.left;
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   841
				if(event.pageY - this.offset.click.top > this.containment[3]) pageY = this.containment[3] + this.offset.click.top;
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   842
			}
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   843
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   844
			if(o.grid) {
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   845
				var top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   846
				pageY = this.containment ? (!(top - this.offset.click.top < this.containment[1] || top - this.offset.click.top > this.containment[3]) ? top : (!(top - this.offset.click.top < this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   847
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   848
				var left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   849
				pageX = this.containment ? (!(left - this.offset.click.left < this.containment[0] || left - this.offset.click.left > this.containment[2]) ? left : (!(left - this.offset.click.left < this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   850
			}
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   851
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   852
		}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   853
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   854
		return {
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   855
			top: (
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   856
				pageY																// The absolute mouse position
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   857
				- this.offset.click.top													// Click offset (relative to the element)
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   858
				- this.offset.relative.top												// Only for relative positioned nodes: Relative offset from element to offset parent
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   859
				- this.offset.parent.top												// The offsetParent's offset without borders (offset + border)
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   860
				+ ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   861
			),
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   862
			left: (
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   863
				pageX																// The absolute mouse position
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   864
				- this.offset.click.left												// Click offset (relative to the element)
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   865
				- this.offset.relative.left												// Only for relative positioned nodes: Relative offset from element to offset parent
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   866
				- this.offset.parent.left												// The offsetParent's offset without borders (offset + border)
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   867
				+ ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   868
			)
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   869
		};
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   870
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   871
	},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   872
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   873
	_rearrange: function(event, i, a, hardRefresh) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   874
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   875
		a ? a[0].appendChild(this.placeholder[0]) : i.item[0].parentNode.insertBefore(this.placeholder[0], (this.direction == 'down' ? i.item[0] : i.item[0].nextSibling));
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   876
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   877
		//Various things done here to improve the performance:
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   878
		// 1. we create a setTimeout, that calls refreshPositions
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   879
		// 2. on the instance, we have a counter variable, that get's higher after every append
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   880
		// 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   881
		// 4. this lets only the last addition to the timeout stack through
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   882
		this.counter = this.counter ? ++this.counter : 1;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   883
		var self = this, counter = this.counter;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   884
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   885
		window.setTimeout(function() {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   886
			if(counter == self.counter) self.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   887
		},0);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   888
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   889
	},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   890
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   891
	_clear: function(event, noPropagation) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   892
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   893
		this.reverting = false;
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   894
		// We delay all events that have to be triggered to after the point where the placeholder has been removed and
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   895
		// everything else normalized again
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   896
		var delayedTriggers = [], self = this;
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   897
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   898
		// We first have to update the dom position of the actual currentItem
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   899
		// Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   900
		if(!this._noFinalSort && this.currentItem[0].parentNode) this.placeholder.before(this.currentItem);
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   901
		this._noFinalSort = null;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   902
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   903
		if(this.helper[0] == this.currentItem[0]) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   904
			for(var i in this._storedCSS) {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   905
				if(this._storedCSS[i] == 'auto' || this._storedCSS[i] == 'static') this._storedCSS[i] = '';
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   906
			}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   907
			this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   908
		} else {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   909
			this.currentItem.show();
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   910
		}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   911
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   912
		if(this.fromOutside && !noPropagation) delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   913
		if((this.fromOutside || this.domPosition.prev != this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent != this.currentItem.parent()[0]) && !noPropagation) delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   914
		if(!$.ui.contains(this.element[0], this.currentItem[0])) { //Node was moved out of the current element
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   915
			if(!noPropagation) delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   916
			for (var i = this.containers.length - 1; i >= 0; i--){
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   917
				if($.ui.contains(this.containers[i].element[0], this.currentItem[0]) && !noPropagation) {
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   918
					delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); };  }).call(this, this.containers[i]));
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   919
					delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this));  }; }).call(this, this.containers[i]));
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   920
				}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   921
			};
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   922
		};
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   923
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   924
		//Post events to containers
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   925
		for (var i = this.containers.length - 1; i >= 0; i--){
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   926
			if(!noPropagation) delayedTriggers.push((function(c) { return function(event) { c._trigger("deactivate", event, this._uiHash(this)); };  }).call(this, this.containers[i]));
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   927
			if(this.containers[i].containerCache.over) {
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   928
				delayedTriggers.push((function(c) { return function(event) { c._trigger("out", event, this._uiHash(this)); };  }).call(this, this.containers[i]));
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   929
				this.containers[i].containerCache.over = 0;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   930
			}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   931
		}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   932
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   933
		//Do what was originally in plugins
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   934
		if(this._storedCursor) $('body').css("cursor", this._storedCursor); //Reset cursor
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   935
		if(this._storedOpacity) this.helper.css("opacity", this._storedOpacity); //Reset cursor
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   936
		if(this._storedZIndex) this.helper.css("zIndex", this._storedZIndex == 'auto' ? '' : this._storedZIndex); //Reset z-index
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   937
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   938
		this.dragging = false;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   939
		if(this.cancelHelperRemoval) {
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   940
			if(!noPropagation) {
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   941
				this._trigger("beforeStop", event, this._uiHash());
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   942
				for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   943
				this._trigger("stop", event, this._uiHash());
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   944
			}
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   945
			return false;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   946
		}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   947
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   948
		if(!noPropagation) this._trigger("beforeStop", event, this._uiHash());
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   949
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   950
		//$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   951
		this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   952
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   953
		if(this.helper[0] != this.currentItem[0]) this.helper.remove(); this.helper = null;
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   954
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   955
		if(!noPropagation) {
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   956
			for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   957
			this._trigger("stop", event, this._uiHash());
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   958
		}
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   959
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   960
		this.fromOutside = false;
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   961
		return true;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   962
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   963
	},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   964
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   965
	_trigger: function() {
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   966
		if ($.widget.prototype._trigger.apply(this, arguments) === false) {
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   967
			this.cancel();
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   968
		}
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   969
	},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   970
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   971
	_uiHash: function(inst) {
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   972
		var self = inst || this;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   973
		return {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   974
			helper: self.helper,
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   975
			placeholder: self.placeholder || $([]),
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   976
			position: self.position,
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   977
			absolutePosition: self.positionAbs, //deprecated
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   978
			offset: self.positionAbs,
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   979
			item: self.currentItem,
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   980
			sender: inst ? inst.element : null
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   981
		};
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   982
	}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   983
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   984
}));
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   985
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   986
$.extend($.ui.sortable, {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   987
	getter: "serialize toArray",
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   988
	version: "1.7.2",
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   989
	eventPrefix: "sort",
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   990
	defaults: {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   991
		appendTo: "parent",
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   992
		axis: false,
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   993
		cancel: ":input,option",
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   994
		connectWith: false,
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   995
		containment: false,
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   996
		cursor: 'auto',
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
   997
		cursorAt: false,
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   998
		delay: 0,
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   999
		distance: 1,
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
  1000
		dropOnEmpty: true,
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
  1001
		forcePlaceholderSize: false,
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
  1002
		forceHelperSize: false,
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
  1003
		grid: false,
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
  1004
		handle: false,
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
  1005
		helper: "original",
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
  1006
		items: '> *',
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
  1007
		opacity: false,
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
  1008
		placeholder: false,
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
  1009
		revert: false,
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
  1010
		scroll: true,
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
  1011
		scrollSensitivity: 20,
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
  1012
		scrollSpeed: 20,
2749
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
  1013
		scope: "default",
4e2789b8e86d Upgrade jQuery UI to version 1.7.
Mario Ferraro <fadinlight@gmail.com>
parents: 2420
diff changeset
  1014
		tolerance: "intersect",
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
  1015
		zIndex: 1000
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
  1016
	}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
  1017
});
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
  1018
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
  1019
})(jQuery);