mercury-rails 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.rdoc +152 -0
- data/VERSION +1 -0
- data/app/assets/images/mercury/button.png +0 -0
- data/app/assets/images/mercury/clippy.png +0 -0
- data/app/assets/images/mercury/default-snippet.png +0 -0
- data/app/assets/images/mercury/loading-dark.gif +0 -0
- data/app/assets/images/mercury/loading-light.gif +0 -0
- data/app/assets/images/mercury/search-icon.png +0 -0
- data/app/assets/images/mercury/toolbar/editable/buttons.png +0 -0
- data/app/assets/images/mercury/toolbar/markupable/buttons.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/_expander.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/_pressed.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/historypanel.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/insertcharacter.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/insertlink.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/insertmedia.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/inserttable.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/inspectorpanel.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/notespanel.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/objectspanel.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/preview.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/redo.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/save.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/todospanel.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/undo.png +0 -0
- data/app/assets/images/mercury/toolbar/snippetable/buttons.png +0 -0
- data/app/assets/javascripts/mercury.js +30 -0
- data/app/assets/javascripts/mercury/dialog.js.coffee +75 -0
- data/app/assets/javascripts/mercury/dialogs/backcolor.js.coffee +6 -0
- data/app/assets/javascripts/mercury/dialogs/forecolor.js.coffee +6 -0
- data/app/assets/javascripts/mercury/dialogs/formatblock.js.coffee +4 -0
- data/app/assets/javascripts/mercury/dialogs/objectspanel.js.coffee +10 -0
- data/app/assets/javascripts/mercury/dialogs/style.js.coffee +4 -0
- data/app/assets/javascripts/mercury/history_buffer.js.coffee +30 -0
- data/app/assets/javascripts/mercury/mercury.js.coffee +293 -0
- data/app/assets/javascripts/mercury/modal.js.coffee +177 -0
- data/app/assets/javascripts/mercury/modals/htmleditor.js.coffee +10 -0
- data/app/assets/javascripts/mercury/modals/insertcharacter.js.coffee +4 -0
- data/app/assets/javascripts/mercury/modals/insertlink.js.coffee +92 -0
- data/app/assets/javascripts/mercury/modals/insertmedia.js.coffee +72 -0
- data/app/assets/javascripts/mercury/modals/insertsnippet.js.coffee +11 -0
- data/app/assets/javascripts/mercury/modals/inserttable.js.coffee +56 -0
- data/app/assets/javascripts/mercury/native_extensions.js.coffee +47 -0
- data/app/assets/javascripts/mercury/page_editor.js.coffee +139 -0
- data/app/assets/javascripts/mercury/palette.js.coffee +29 -0
- data/app/assets/javascripts/mercury/panel.js.coffee +97 -0
- data/app/assets/javascripts/mercury/region.js.coffee +103 -0
- data/app/assets/javascripts/mercury/regions/editable.js.coffee +546 -0
- data/app/assets/javascripts/mercury/regions/markupable.js.coffee +380 -0
- data/app/assets/javascripts/mercury/regions/snippetable.js.coffee +127 -0
- data/app/assets/javascripts/mercury/select.js.coffee +40 -0
- data/app/assets/javascripts/mercury/snippet.js.coffee +92 -0
- data/app/assets/javascripts/mercury/snippet_toolbar.js.coffee +69 -0
- data/app/assets/javascripts/mercury/statusbar.js.coffee +25 -0
- data/app/assets/javascripts/mercury/table_editor.js.coffee +266 -0
- data/app/assets/javascripts/mercury/toolbar.button.js.coffee +152 -0
- data/app/assets/javascripts/mercury/toolbar.button_group.js.coffee +42 -0
- data/app/assets/javascripts/mercury/toolbar.expander.js.coffee +56 -0
- data/app/assets/javascripts/mercury/toolbar.js.coffee +72 -0
- data/app/assets/javascripts/mercury/tooltip.js.coffee +67 -0
- data/app/assets/javascripts/mercury/uploader.js.coffee +213 -0
- data/app/assets/javascripts/mercury/websocket.js.coffee +34 -0
- data/app/assets/stylesheets/mercury.css +31 -0
- data/app/assets/stylesheets/mercury/dialog.scss +178 -0
- data/app/assets/stylesheets/mercury/mercury.scss +119 -0
- data/app/assets/stylesheets/mercury/modal.scss +192 -0
- data/app/assets/stylesheets/mercury/statusbar.scss +23 -0
- data/app/assets/stylesheets/mercury/toolbar.scss +417 -0
- data/app/assets/stylesheets/mercury/tooltip.scss +26 -0
- data/app/assets/stylesheets/mercury/uploader.scss +109 -0
- data/app/controllers/images_controller.rb +19 -0
- data/app/controllers/mercury_controller.rb +20 -0
- data/app/models/image.rb +14 -0
- data/app/views/layouts/mercury.html.haml +12 -0
- data/app/views/mercury/modals/character.html.haml +252 -0
- data/app/views/mercury/modals/htmleditor.html.haml +8 -0
- data/app/views/mercury/modals/link.html.haml +31 -0
- data/app/views/mercury/modals/media.html.haml +33 -0
- data/app/views/mercury/modals/sanitizer.html.haml +4 -0
- data/app/views/mercury/modals/table.html.haml +49 -0
- data/app/views/mercury/palettes/backcolor.html.haml +79 -0
- data/app/views/mercury/palettes/forecolor.html.haml +79 -0
- data/app/views/mercury/panels/history.html.haml +0 -0
- data/app/views/mercury/panels/notes.html.haml +0 -0
- data/app/views/mercury/panels/snippets.html.haml +10 -0
- data/app/views/mercury/selects/formatblock.html.haml +10 -0
- data/app/views/mercury/selects/style.html.haml +4 -0
- data/app/views/mercury/snippets/example.html.haml +2 -0
- data/app/views/mercury/snippets/example_options.html.haml +16 -0
- data/config/engine.rb +6 -0
- data/config/routes.rb +15 -0
- data/db/migrate/20110526035601_create_images.rb +11 -0
- data/features/editing/basic.feature +11 -0
- data/features/step_definitions/debug_steps.rb +14 -0
- data/features/step_definitions/web_steps.rb +211 -0
- data/features/support/env.rb +46 -0
- data/features/support/paths.rb +35 -0
- data/features/support/selectors.rb +42 -0
- data/lib/mercury-rails.rb +4 -0
- data/log/.gitkeep +0 -0
- data/mercury-rails.gemspec +230 -0
- data/spec/javascripts/mercury/dialog_spec.js.coffee +258 -0
- data/spec/javascripts/mercury/history_buffer_spec.js.coffee +79 -0
- data/spec/javascripts/mercury/mercury_spec.js.coffee +52 -0
- data/spec/javascripts/mercury/native_extensions_spec.js.coffee +66 -0
- data/spec/javascripts/mercury/page_editor_spec.js.coffee +435 -0
- data/spec/javascripts/mercury/palette_spec.js.coffee +51 -0
- data/spec/javascripts/mercury/panel_spec.js.coffee +147 -0
- data/spec/javascripts/mercury/region_spec.js.coffee +261 -0
- data/spec/javascripts/mercury/regions/_editable_.js.coffee +0 -0
- data/spec/javascripts/mercury/regions/_markupable_.js.coffee +0 -0
- data/spec/javascripts/mercury/regions/snippetable_spec.js.coffee +368 -0
- data/spec/javascripts/mercury/select_spec.js.coffee +51 -0
- data/spec/javascripts/mercury/snippet_spec.js.coffee +246 -0
- data/spec/javascripts/mercury/snippet_toolbar_spec.js.coffee +186 -0
- data/spec/javascripts/mercury/statusbar_spec.js.coffee +78 -0
- data/spec/javascripts/mercury/table_editor_spec.js.coffee +192 -0
- data/spec/javascripts/mercury/toolbar.button_group_spec.js.coffee +92 -0
- data/spec/javascripts/mercury/toolbar.button_spec.js.coffee +341 -0
- data/spec/javascripts/mercury/toolbar.expander_spec.js.coffee +120 -0
- data/spec/javascripts/mercury/toolbar_spec.js.coffee +152 -0
- data/spec/javascripts/mercury/tooltip_spec.js.coffee +188 -0
- data/spec/javascripts/mercury/uploader_spec.js.coffee +512 -0
- data/spec/javascripts/responses/blank.html +1 -0
- data/spec/javascripts/spec_helper.js +513 -0
- data/spec/javascripts/templates/mercury/dialog.html +2 -0
- data/spec/javascripts/templates/mercury/page_editor.html +24 -0
- data/spec/javascripts/templates/mercury/palette.html +16 -0
- data/spec/javascripts/templates/mercury/panel.html +16 -0
- data/spec/javascripts/templates/mercury/region.html +2 -0
- data/spec/javascripts/templates/mercury/regions/snippetable.html +4 -0
- data/spec/javascripts/templates/mercury/select.html +16 -0
- data/spec/javascripts/templates/mercury/snippet.html +1 -0
- data/spec/javascripts/templates/mercury/snippet_toolbar.html +16 -0
- data/spec/javascripts/templates/mercury/statusbar.html +7 -0
- data/spec/javascripts/templates/mercury/table_editor.html +65 -0
- data/spec/javascripts/templates/mercury/toolbar.button.html +64 -0
- data/spec/javascripts/templates/mercury/toolbar.button_group.html +9 -0
- data/spec/javascripts/templates/mercury/toolbar.expander.html +18 -0
- data/spec/javascripts/templates/mercury/toolbar.html +10 -0
- data/spec/javascripts/templates/mercury/tooltip.html +12 -0
- data/spec/javascripts/templates/mercury/uploader.html +11 -0
- data/vendor/assets/javascripts/jquery-1.6.js +8865 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.13.custom.min.js +249 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.13.sortable.custom.js +1078 -0
- data/vendor/assets/javascripts/jquery.easing.js +173 -0
- data/vendor/assets/javascripts/jquery.json2.js +178 -0
- data/vendor/assets/javascripts/jquery.serialize_object.js +16 -0
- data/vendor/assets/javascripts/jquery.ujs.js +289 -0
- data/vendor/assets/javascripts/liquidmetal.js +88 -0
- data/vendor/assets/javascripts/showdown.js +1362 -0
- metadata +364 -0
@@ -0,0 +1,249 @@
|
|
1
|
+
/*!
|
2
|
+
* jQuery UI 1.8.13
|
3
|
+
*
|
4
|
+
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
5
|
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
6
|
+
* http://jquery.org/license
|
7
|
+
*
|
8
|
+
* http://docs.jquery.com/UI
|
9
|
+
*/
|
10
|
+
(function(c,j){function k(a,b){var d=a.nodeName.toLowerCase();if("area"===d){b=a.parentNode;d=b.name;if(!a.href||!d||b.nodeName.toLowerCase()!=="map")return false;a=c("img[usemap=#"+d+"]")[0];return!!a&&l(a)}return(/input|select|textarea|button|object/.test(d)?!a.disabled:"a"==d?a.href||b:b)&&l(a)}function l(a){return!c(a).parents().andSelf().filter(function(){return c.curCSS(this,"visibility")==="hidden"||c.expr.filters.hidden(this)}).length}c.ui=c.ui||{};if(!c.ui.version){c.extend(c.ui,{version:"1.8.13",
|
11
|
+
keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}});c.fn.extend({_focus:c.fn.focus,focus:function(a,b){return typeof a==="number"?this.each(function(){var d=this;setTimeout(function(){c(d).focus();
|
12
|
+
b&&b.call(d)},a)}):this._focus.apply(this,arguments)},scrollParent:function(){var a;a=c.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(c.curCSS(this,"position",1))&&/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,
|
13
|
+
"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0);return/fixed/.test(this.css("position"))||!a.length?c(document):a},zIndex:function(a){if(a!==j)return this.css("zIndex",a);if(this.length){a=c(this[0]);for(var b;a.length&&a[0]!==document;){b=a.css("position");if(b==="absolute"||b==="relative"||b==="fixed"){b=parseInt(a.css("zIndex"),10);if(!isNaN(b)&&b!==0)return b}a=a.parent()}}return 0},disableSelection:function(){return this.bind((c.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",
|
14
|
+
function(a){a.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}});c.each(["Width","Height"],function(a,b){function d(f,g,m,n){c.each(e,function(){g-=parseFloat(c.curCSS(f,"padding"+this,true))||0;if(m)g-=parseFloat(c.curCSS(f,"border"+this+"Width",true))||0;if(n)g-=parseFloat(c.curCSS(f,"margin"+this,true))||0});return g}var e=b==="Width"?["Left","Right"]:["Top","Bottom"],h=b.toLowerCase(),i={innerWidth:c.fn.innerWidth,innerHeight:c.fn.innerHeight,outerWidth:c.fn.outerWidth,
|
15
|
+
outerHeight:c.fn.outerHeight};c.fn["inner"+b]=function(f){if(f===j)return i["inner"+b].call(this);return this.each(function(){c(this).css(h,d(this,f)+"px")})};c.fn["outer"+b]=function(f,g){if(typeof f!=="number")return i["outer"+b].call(this,f);return this.each(function(){c(this).css(h,d(this,f,true,g)+"px")})}});c.extend(c.expr[":"],{data:function(a,b,d){return!!c.data(a,d[3])},focusable:function(a){return k(a,!isNaN(c.attr(a,"tabindex")))},tabbable:function(a){var b=c.attr(a,"tabindex"),d=isNaN(b);
|
16
|
+
return(d||b>=0)&&k(a,!d)}});c(function(){var a=document.body,b=a.appendChild(b=document.createElement("div"));c.extend(b.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});c.support.minHeight=b.offsetHeight===100;c.support.selectstart="onselectstart"in b;a.removeChild(b).style.display="none"});c.extend(c.ui,{plugin:{add:function(a,b,d){a=c.ui[a].prototype;for(var e in d){a.plugins[e]=a.plugins[e]||[];a.plugins[e].push([b,d[e]])}},call:function(a,b,d){if((b=a.plugins[b])&&a.element[0].parentNode)for(var e=
|
17
|
+
0;e<b.length;e++)a.options[b[e][0]]&&b[e][1].apply(a.element,d)}},contains:function(a,b){return document.compareDocumentPosition?a.compareDocumentPosition(b)&16:a!==b&&a.contains(b)},hasScroll:function(a,b){if(c(a).css("overflow")==="hidden")return false;b=b&&b==="left"?"scrollLeft":"scrollTop";var d=false;if(a[b]>0)return true;a[b]=1;d=a[b]>0;a[b]=0;return d},isOverAxis:function(a,b,d){return a>b&&a<b+d},isOver:function(a,b,d,e,h,i){return c.ui.isOverAxis(a,d,h)&&c.ui.isOverAxis(b,e,i)}})}})(jQuery);
|
18
|
+
;/*!
|
19
|
+
* jQuery UI Widget 1.8.13
|
20
|
+
*
|
21
|
+
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
22
|
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
23
|
+
* http://jquery.org/license
|
24
|
+
*
|
25
|
+
* http://docs.jquery.com/UI/Widget
|
26
|
+
*/
|
27
|
+
(function(b,j){if(b.cleanData){var k=b.cleanData;b.cleanData=function(a){for(var c=0,d;(d=a[c])!=null;c++)b(d).triggerHandler("remove");k(a)}}else{var l=b.fn.remove;b.fn.remove=function(a,c){return this.each(function(){if(!c)if(!a||b.filter(a,[this]).length)b("*",this).add([this]).each(function(){b(this).triggerHandler("remove")});return l.call(b(this),a,c)})}}b.widget=function(a,c,d){var e=a.split(".")[0],f;a=a.split(".")[1];f=e+"-"+a;if(!d){d=c;c=b.Widget}b.expr[":"][f]=function(h){return!!b.data(h,
|
28
|
+
a)};b[e]=b[e]||{};b[e][a]=function(h,g){arguments.length&&this._createWidget(h,g)};c=new c;c.options=b.extend(true,{},c.options);b[e][a].prototype=b.extend(true,c,{namespace:e,widgetName:a,widgetEventPrefix:b[e][a].prototype.widgetEventPrefix||a,widgetBaseClass:f},d);b.widget.bridge(a,b[e][a])};b.widget.bridge=function(a,c){b.fn[a]=function(d){var e=typeof d==="string",f=Array.prototype.slice.call(arguments,1),h=this;d=!e&&f.length?b.extend.apply(null,[true,d].concat(f)):d;if(e&&d.charAt(0)==="_")return h;
|
29
|
+
e?this.each(function(){var g=b.data(this,a),i=g&&b.isFunction(g[d])?g[d].apply(g,f):g;if(i!==g&&i!==j){h=i;return false}}):this.each(function(){var g=b.data(this,a);g?g.option(d||{})._init():b.data(this,a,new c(d,this))});return h}};b.Widget=function(a,c){arguments.length&&this._createWidget(a,c)};b.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:false},_createWidget:function(a,c){b.data(c,this.widgetName,this);this.element=b(c);this.options=b.extend(true,{},this.options,
|
30
|
+
this._getCreateOptions(),a);var d=this;this.element.bind("remove."+this.widgetName,function(){d.destroy()});this._create();this._trigger("create");this._init()},_getCreateOptions:function(){return b.metadata&&b.metadata.get(this.element[0])[this.widgetName]},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName);this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled ui-state-disabled")},
|
31
|
+
widget:function(){return this.element},option:function(a,c){var d=a;if(arguments.length===0)return b.extend({},this.options);if(typeof a==="string"){if(c===j)return this.options[a];d={};d[a]=c}this._setOptions(d);return this},_setOptions:function(a){var c=this;b.each(a,function(d,e){c._setOption(d,e)});return this},_setOption:function(a,c){this.options[a]=c;if(a==="disabled")this.widget()[c?"addClass":"removeClass"](this.widgetBaseClass+"-disabled ui-state-disabled").attr("aria-disabled",c);return this},
|
32
|
+
enable:function(){return this._setOption("disabled",false)},disable:function(){return this._setOption("disabled",true)},_trigger:function(a,c,d){var e=this.options[a];c=b.Event(c);c.type=(a===this.widgetEventPrefix?a:this.widgetEventPrefix+a).toLowerCase();d=d||{};if(c.originalEvent){a=b.event.props.length;for(var f;a;){f=b.event.props[--a];c[f]=c.originalEvent[f]}}this.element.trigger(c,d);return!(b.isFunction(e)&&e.call(this.element[0],c,d)===false||c.isDefaultPrevented())}}})(jQuery);
|
33
|
+
;
|
34
|
+
|
35
|
+
/*!
|
36
|
+
* jQuery UI Mouse 1.8.13
|
37
|
+
*
|
38
|
+
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
39
|
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
40
|
+
* http://jquery.org/license
|
41
|
+
*
|
42
|
+
* http://docs.jquery.com/UI/Mouse
|
43
|
+
*
|
44
|
+
* Depends:
|
45
|
+
* jquery.ui.widget.js
|
46
|
+
*/
|
47
|
+
(function( $, undefined ) {
|
48
|
+
|
49
|
+
var mouseHandled = false;
|
50
|
+
$(document).mousedown(function(e) {
|
51
|
+
mouseHandled = false;
|
52
|
+
});
|
53
|
+
|
54
|
+
$.widget("ui.mouse", {
|
55
|
+
options: {
|
56
|
+
cancel: ':input,option',
|
57
|
+
distance: 1,
|
58
|
+
delay: 0
|
59
|
+
},
|
60
|
+
_mouseInit: function() {
|
61
|
+
var self = this;
|
62
|
+
|
63
|
+
this.element
|
64
|
+
.bind('mousedown.'+this.widgetName, function(event) {
|
65
|
+
return self._mouseDown(event);
|
66
|
+
})
|
67
|
+
.bind('click.'+this.widgetName, function(event) {
|
68
|
+
if (true === $.data(event.target, self.widgetName + '.preventClickEvent')) {
|
69
|
+
$.removeData(event.target, self.widgetName + '.preventClickEvent');
|
70
|
+
event.stopImmediatePropagation();
|
71
|
+
return false;
|
72
|
+
}
|
73
|
+
});
|
74
|
+
|
75
|
+
this.started = false;
|
76
|
+
},
|
77
|
+
|
78
|
+
// TODO: make sure destroying one instance of mouse doesn't mess with
|
79
|
+
// other instances of mouse
|
80
|
+
_mouseDestroy: function() {
|
81
|
+
this.element.unbind('.'+this.widgetName);
|
82
|
+
},
|
83
|
+
|
84
|
+
_mouseDown: function(event) {
|
85
|
+
// don't let more than one widget handle mouseStart
|
86
|
+
$(this.document || document).mousedown(function(e) {
|
87
|
+
mouseHandled = false;
|
88
|
+
});
|
89
|
+
if(mouseHandled) {return};
|
90
|
+
|
91
|
+
// we may have missed mouseup (out of window)
|
92
|
+
(this._mouseStarted && this._mouseUp(event));
|
93
|
+
|
94
|
+
this._mouseDownEvent = event;
|
95
|
+
|
96
|
+
var self = this,
|
97
|
+
btnIsLeft = (event.which == 1),
|
98
|
+
elIsCancel = (typeof this.options.cancel == "string" ? $(event.target).parents().add(event.target).filter(this.options.cancel).length : false);
|
99
|
+
if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
|
100
|
+
return true;
|
101
|
+
}
|
102
|
+
|
103
|
+
this.mouseDelayMet = !this.options.delay;
|
104
|
+
if (!this.mouseDelayMet) {
|
105
|
+
this._mouseDelayTimer = setTimeout(function() {
|
106
|
+
self.mouseDelayMet = true;
|
107
|
+
}, this.options.delay);
|
108
|
+
}
|
109
|
+
|
110
|
+
if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
|
111
|
+
this._mouseStarted = (this._mouseStart(event) !== false);
|
112
|
+
if (!this._mouseStarted) {
|
113
|
+
event.preventDefault();
|
114
|
+
return true;
|
115
|
+
}
|
116
|
+
}
|
117
|
+
|
118
|
+
// Click event may never have fired (Gecko & Opera)
|
119
|
+
if (true === $.data(event.target, this.widgetName + '.preventClickEvent')) {
|
120
|
+
$.removeData(event.target, this.widgetName + '.preventClickEvent');
|
121
|
+
}
|
122
|
+
|
123
|
+
// these delegates are required to keep context
|
124
|
+
this._mouseMoveDelegate = function(event) {
|
125
|
+
return self._mouseMove(event);
|
126
|
+
};
|
127
|
+
this._mouseUpDelegate = function(event) {
|
128
|
+
return self._mouseUp(event);
|
129
|
+
};
|
130
|
+
$(this.document || document)
|
131
|
+
.bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
|
132
|
+
.bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
|
133
|
+
|
134
|
+
event.preventDefault();
|
135
|
+
|
136
|
+
mouseHandled = true;
|
137
|
+
return true;
|
138
|
+
},
|
139
|
+
|
140
|
+
_mouseMove: function(event) {
|
141
|
+
// IE mouseup check - mouseup happened when mouse was out of window
|
142
|
+
if ($.browser.msie && !((this.document || document).documentMode >= 9) && !event.button) {
|
143
|
+
return this._mouseUp(event);
|
144
|
+
}
|
145
|
+
|
146
|
+
if (this._mouseStarted) {
|
147
|
+
this._mouseDrag(event);
|
148
|
+
return event.preventDefault();
|
149
|
+
}
|
150
|
+
|
151
|
+
if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
|
152
|
+
this._mouseStarted =
|
153
|
+
(this._mouseStart(this._mouseDownEvent, event) !== false);
|
154
|
+
(this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
|
155
|
+
}
|
156
|
+
|
157
|
+
return !this._mouseStarted;
|
158
|
+
},
|
159
|
+
|
160
|
+
_mouseUp: function(event) {
|
161
|
+
$(this.document || document)
|
162
|
+
.unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
|
163
|
+
.unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
|
164
|
+
|
165
|
+
if (this._mouseStarted) {
|
166
|
+
this._mouseStarted = false;
|
167
|
+
|
168
|
+
if (event.target == this._mouseDownEvent.target) {
|
169
|
+
$.data(event.target, this.widgetName + '.preventClickEvent', true);
|
170
|
+
}
|
171
|
+
|
172
|
+
this._mouseStop(event);
|
173
|
+
}
|
174
|
+
|
175
|
+
return false;
|
176
|
+
},
|
177
|
+
|
178
|
+
_mouseDistanceMet: function(event) {
|
179
|
+
return (Math.max(
|
180
|
+
Math.abs(this._mouseDownEvent.pageX - event.pageX),
|
181
|
+
Math.abs(this._mouseDownEvent.pageY - event.pageY)
|
182
|
+
) >= this.options.distance
|
183
|
+
);
|
184
|
+
},
|
185
|
+
|
186
|
+
_mouseDelayMet: function(event) {
|
187
|
+
return this.mouseDelayMet;
|
188
|
+
},
|
189
|
+
|
190
|
+
// These are placeholder methods, to be overriden by extending plugin
|
191
|
+
_mouseStart: function(event) {},
|
192
|
+
_mouseDrag: function(event) {},
|
193
|
+
_mouseStop: function(event) {},
|
194
|
+
_mouseCapture: function(event) { return true; }
|
195
|
+
});
|
196
|
+
|
197
|
+
})(jQuery);
|
198
|
+
|
199
|
+
/*
|
200
|
+
* jQuery UI Draggable 1.8.13
|
201
|
+
*
|
202
|
+
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
203
|
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
204
|
+
* http://jquery.org/license
|
205
|
+
*
|
206
|
+
* http://docs.jquery.com/UI/Draggables
|
207
|
+
*
|
208
|
+
* Depends:
|
209
|
+
* jquery.ui.core.js
|
210
|
+
* jquery.ui.mouse.js
|
211
|
+
* jquery.ui.widget.js
|
212
|
+
*/
|
213
|
+
(function(d){d.widget("ui.draggable",d.ui.mouse,{widgetEventPrefix:"drag",options:{addClasses:true,appendTo:"parent",axis:false,connectToSortable:false,containment:false,cursor:"auto",cursorAt:false,grid:false,handle:false,helper:"original",iframeFix:false,opacity:false,refreshPositions:false,revert:false,revertDuration:500,scope:"default",scroll:true,scrollSensitivity:20,scrollSpeed:20,snap:false,snapMode:"both",snapTolerance:20,stack:false,zIndex:false},_create:function(){if(this.options.helper==
|
214
|
+
"original"&&!/^(?:r|a|f)/.test(this.element.css("position")))this.element[0].style.position="relative";this.options.addClasses&&this.element.addClass("ui-draggable");this.options.disabled&&this.element.addClass("ui-draggable-disabled");this._mouseInit()},destroy:function(){if(this.element.data("draggable")){this.element.removeData("draggable").unbind(".draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled");this._mouseDestroy();return this}},_mouseCapture:function(a){var b=
|
215
|
+
this.options;if(this.helper||b.disabled||d(a.target).is(".ui-resizable-handle"))return false;this.handle=this._getHandle(a);if(!this.handle)return false;d(b.iframeFix===true?"iframe":b.iframeFix).each(function(){d('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1E3}).css(d(this).offset()).appendTo("body")});return true},_mouseStart:function(a){var b=this.options;this.helper=
|
216
|
+
this._createHelper(a);this._cacheHelperProportions();if(d.ui.ddmanager)d.ui.ddmanager.current=this;this._cacheMargins();this.cssPosition=this.helper.css("position");this.scrollParent=this.helper.scrollParent();this.offset=this.positionAbs=this.element.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};d.extend(this.offset,{click:{left:a.pageX-this.offset.left,top:a.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});
|
217
|
+
this.originalPosition=this.position=this._generatePosition(a);this.originalPageX=a.pageX;this.originalPageY=a.pageY;b.cursorAt&&this._adjustOffsetFromHelper(b.cursorAt);b.containment&&this._setContainment();if(this._trigger("start",a)===false){this._clear();return false}this._cacheHelperProportions();d.ui.ddmanager&&!b.dropBehaviour&&d.ui.ddmanager.prepareOffsets(this,a);this.helper.addClass("ui-draggable-dragging");this._mouseDrag(a,true);return true},_mouseDrag:function(a,b){this.position=this._generatePosition(a);
|
218
|
+
this.positionAbs=this._convertPositionTo("absolute");if(!b){b=this._uiHash();if(this._trigger("drag",a,b)===false){this._mouseUp({});return false}this.position=b.position}if(!this.options.axis||this.options.axis!="y")this.helper[0].style.left=this.position.left+"px";if(!this.options.axis||this.options.axis!="x")this.helper[0].style.top=this.position.top+"px";d.ui.ddmanager&&d.ui.ddmanager.drag(this,a);return false},_mouseStop:function(a){var b=false;if(d.ui.ddmanager&&!this.options.dropBehaviour)b=
|
219
|
+
d.ui.ddmanager.drop(this,a);if(this.dropped){b=this.dropped;this.dropped=false}if((!this.element[0]||!this.element[0].parentNode)&&this.options.helper=="original")return false;if(this.options.revert=="invalid"&&!b||this.options.revert=="valid"&&b||this.options.revert===true||d.isFunction(this.options.revert)&&this.options.revert.call(this.element,b)){var c=this;d(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){c._trigger("stop",a)!==false&&c._clear()})}else this._trigger("stop",
|
220
|
+
a)!==false&&this._clear();return false},_mouseUp:function(a){this.options.iframeFix===true&&d("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)});return d.ui.mouse.prototype._mouseUp.call(this,a)},cancel:function(){this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear();return this},_getHandle:function(a){var b=!this.options.handle||!d(this.options.handle,this.element).length?true:false;d(this.options.handle,this.element).find("*").andSelf().each(function(){if(this==
|
221
|
+
a.target)b=true});return b},_createHelper:function(a){var b=this.options;a=d.isFunction(b.helper)?d(b.helper.apply(this.element[0],[a])):b.helper=="clone"?this.element.clone().removeAttr("id"):this.element;a.parents("body").length||a.appendTo(b.appendTo=="parent"?this.element[0].parentNode:b.appendTo);a[0]!=this.element[0]&&!/(fixed|absolute)/.test(a.css("position"))&&a.css("position","absolute");return a},_adjustOffsetFromHelper:function(a){if(typeof a=="string")a=a.split(" ");if(d.isArray(a))a=
|
222
|
+
{left:+a[0],top:+a[1]||0};if("left"in a)this.offset.click.left=a.left+this.margins.left;if("right"in a)this.offset.click.left=this.helperProportions.width-a.right+this.margins.left;if("top"in a)this.offset.click.top=a.top+this.margins.top;if("bottom"in a)this.offset.click.top=this.helperProportions.height-a.bottom+this.margins.top},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var a=this.offsetParent.offset();if(this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&
|
223
|
+
d.ui.contains(this.scrollParent[0],this.offsetParent[0])){a.left+=this.scrollParent.scrollLeft();a.top+=this.scrollParent.scrollTop()}if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&d.browser.msie)a={top:0,left:0};return{top:a.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:a.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var a=
|
224
|
+
this.element.position();return{top:a.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:a.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}else return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),10)||0}},_cacheHelperProportions:function(){this.helperProportions=
|
225
|
+
{width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var a=this.options;if(a.containment=="parent")a.containment=this.helper[0].parentNode;if(a.containment=="document"||a.containment=="window")this.containment=[(a.containment=="document"?0:d(window).scrollLeft())-this.offset.relative.left-this.offset.parent.left,(a.containment=="document"?0:d(window).scrollTop())-this.offset.relative.top-this.offset.parent.top,(a.containment=="document"?0:d(window).scrollLeft())+
|
226
|
+
d(a.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(a.containment=="document"?0:d(window).scrollTop())+(d(a.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!/^(document|window|parent)$/.test(a.containment)&&a.containment.constructor!=Array){a=d(a.containment);var b=a[0];if(b){a.offset();var c=d(b).css("overflow")!="hidden";this.containment=[(parseInt(d(b).css("borderLeftWidth"),
|
227
|
+
10)||0)+(parseInt(d(b).css("paddingLeft"),10)||0),(parseInt(d(b).css("borderTopWidth"),10)||0)+(parseInt(d(b).css("paddingTop"),10)||0),(c?Math.max(b.scrollWidth,b.offsetWidth):b.offsetWidth)-(parseInt(d(b).css("borderLeftWidth"),10)||0)-(parseInt(d(b).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(c?Math.max(b.scrollHeight,b.offsetHeight):b.offsetHeight)-(parseInt(d(b).css("borderTopWidth"),10)||0)-(parseInt(d(b).css("paddingBottom"),10)||0)-this.helperProportions.height-
|
228
|
+
this.margins.top-this.margins.bottom];this.relative_container=a}}else if(a.containment.constructor==Array)this.containment=a.containment},_convertPositionTo:function(a,b){if(!b)b=this.position;a=a=="absolute"?1:-1;var c=this.cssPosition=="absolute"&&!(this.scrollParent[0]!=document&&d.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,f=/(html|body)/i.test(c[0].tagName);return{top:b.top+this.offset.relative.top*a+this.offset.parent.top*a-(d.browser.safari&&
|
229
|
+
d.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():f?0:c.scrollTop())*a),left:b.left+this.offset.relative.left*a+this.offset.parent.left*a-(d.browser.safari&&d.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():f?0:c.scrollLeft())*a)}},_generatePosition:function(a){var b=this.options,c=this.cssPosition=="absolute"&&!(this.scrollParent[0]!=document&&d.ui.contains(this.scrollParent[0],
|
230
|
+
this.offsetParent[0]))?this.offsetParent:this.scrollParent,f=/(html|body)/i.test(c[0].tagName),e=a.pageX,h=a.pageY;if(this.originalPosition){var g;if(this.containment){if(this.relative_container){g=this.relative_container.offset();g=[this.containment[0]+g.left,this.containment[1]+g.top,this.containment[2]+g.left,this.containment[3]+g.top]}else g=this.containment;if(a.pageX-this.offset.click.left<g[0])e=g[0]+this.offset.click.left;if(a.pageY-this.offset.click.top<g[1])h=g[1]+this.offset.click.top;
|
231
|
+
if(a.pageX-this.offset.click.left>g[2])e=g[2]+this.offset.click.left;if(a.pageY-this.offset.click.top>g[3])h=g[3]+this.offset.click.top}if(b.grid){h=this.originalPageY+Math.round((h-this.originalPageY)/b.grid[1])*b.grid[1];h=g?!(h-this.offset.click.top<g[1]||h-this.offset.click.top>g[3])?h:!(h-this.offset.click.top<g[1])?h-b.grid[1]:h+b.grid[1]:h;e=this.originalPageX+Math.round((e-this.originalPageX)/b.grid[0])*b.grid[0];e=g?!(e-this.offset.click.left<g[0]||e-this.offset.click.left>g[2])?e:!(e-this.offset.click.left<
|
232
|
+
g[0])?e-b.grid[0]:e+b.grid[0]:e}}return{top:h-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(d.browser.safari&&d.browser.version<526&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollTop():f?0:c.scrollTop()),left:e-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(d.browser.safari&&d.browser.version<526&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():f?0:c.scrollLeft())}},_clear:function(){this.helper.removeClass("ui-draggable-dragging");
|
233
|
+
this.helper[0]!=this.element[0]&&!this.cancelHelperRemoval&&this.helper.remove();this.helper=null;this.cancelHelperRemoval=false},_trigger:function(a,b,c){c=c||this._uiHash();d.ui.plugin.call(this,a,[b,c]);if(a=="drag")this.positionAbs=this._convertPositionTo("absolute");return d.Widget.prototype._trigger.call(this,a,b,c)},plugins:{},_uiHash:function(){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}});d.extend(d.ui.draggable,{version:"1.8.13"});
|
234
|
+
d.ui.plugin.add("draggable","connectToSortable",{start:function(a,b){var c=d(this).data("draggable"),f=c.options,e=d.extend({},b,{item:c.element});c.sortables=[];d(f.connectToSortable).each(function(){var h=d.data(this,"sortable");if(h&&!h.options.disabled){c.sortables.push({instance:h,shouldRevert:h.options.revert});h.refreshPositions();h._trigger("activate",a,e)}})},stop:function(a,b){var c=d(this).data("draggable"),f=d.extend({},b,{item:c.element});d.each(c.sortables,function(){if(this.instance.isOver){this.instance.isOver=
|
235
|
+
0;c.cancelHelperRemoval=true;this.instance.cancelHelperRemoval=false;if(this.shouldRevert)this.instance.options.revert=true;this.instance._mouseStop(a);this.instance.options.helper=this.instance.options._helper;c.options.helper=="original"&&this.instance.currentItem.css({top:"auto",left:"auto"})}else{this.instance.cancelHelperRemoval=false;this.instance._trigger("deactivate",a,f)}})},drag:function(a,b){var c=d(this).data("draggable"),f=this;d.each(c.sortables,function(){this.instance.positionAbs=
|
236
|
+
c.positionAbs;this.instance.helperProportions=c.helperProportions;this.instance.offset.click=c.offset.click;if(this.instance._intersectsWith(this.instance.containerCache)){if(!this.instance.isOver){this.instance.isOver=1;this.instance.currentItem=d(f).clone().removeAttr("id").appendTo(this.instance.element).data("sortable-item",true);this.instance.options._helper=this.instance.options.helper;this.instance.options.helper=function(){return b.helper[0]};a.target=this.instance.currentItem[0];this.instance._mouseCapture(a,
|
237
|
+
true);this.instance._mouseStart(a,true,true);this.instance.offset.click.top=c.offset.click.top;this.instance.offset.click.left=c.offset.click.left;this.instance.offset.parent.left-=c.offset.parent.left-this.instance.offset.parent.left;this.instance.offset.parent.top-=c.offset.parent.top-this.instance.offset.parent.top;c._trigger("toSortable",a);c.dropped=this.instance.element;c.currentItem=c.element;this.instance.fromOutside=c}this.instance.currentItem&&this.instance._mouseDrag(a)}else if(this.instance.isOver){this.instance.isOver=
|
238
|
+
0;this.instance.cancelHelperRemoval=true;this.instance.options.revert=false;this.instance._trigger("out",a,this.instance._uiHash(this.instance));this.instance._mouseStop(a,true);this.instance.options.helper=this.instance.options._helper;this.instance.currentItem.remove();this.instance.placeholder&&this.instance.placeholder.remove();c._trigger("fromSortable",a);c.dropped=false}})}});d.ui.plugin.add("draggable","cursor",{start:function(){var a=d("body"),b=d(this).data("draggable").options;if(a.css("cursor"))b._cursor=
|
239
|
+
a.css("cursor");a.css("cursor",b.cursor)},stop:function(){var a=d(this).data("draggable").options;a._cursor&&d("body").css("cursor",a._cursor)}});d.ui.plugin.add("draggable","opacity",{start:function(a,b){a=d(b.helper);b=d(this).data("draggable").options;if(a.css("opacity"))b._opacity=a.css("opacity");a.css("opacity",b.opacity)},stop:function(a,b){a=d(this).data("draggable").options;a._opacity&&d(b.helper).css("opacity",a._opacity)}});d.ui.plugin.add("draggable","scroll",{start:function(){var a=d(this).data("draggable");
|
240
|
+
if(a.scrollParent[0]!=document&&a.scrollParent[0].tagName!="HTML")a.overflowOffset=a.scrollParent.offset()},drag:function(a){var b=d(this).data("draggable"),c=b.options,f=false;if(b.scrollParent[0]!=document&&b.scrollParent[0].tagName!="HTML"){if(!c.axis||c.axis!="x")if(b.overflowOffset.top+b.scrollParent[0].offsetHeight-a.pageY<c.scrollSensitivity)b.scrollParent[0].scrollTop=f=b.scrollParent[0].scrollTop+c.scrollSpeed;else if(a.pageY-b.overflowOffset.top<c.scrollSensitivity)b.scrollParent[0].scrollTop=
|
241
|
+
f=b.scrollParent[0].scrollTop-c.scrollSpeed;if(!c.axis||c.axis!="y")if(b.overflowOffset.left+b.scrollParent[0].offsetWidth-a.pageX<c.scrollSensitivity)b.scrollParent[0].scrollLeft=f=b.scrollParent[0].scrollLeft+c.scrollSpeed;else if(a.pageX-b.overflowOffset.left<c.scrollSensitivity)b.scrollParent[0].scrollLeft=f=b.scrollParent[0].scrollLeft-c.scrollSpeed}else{if(!c.axis||c.axis!="x")if(a.pageY-d(document).scrollTop()<c.scrollSensitivity)f=d(document).scrollTop(d(document).scrollTop()-c.scrollSpeed);
|
242
|
+
else if(d(window).height()-(a.pageY-d(document).scrollTop())<c.scrollSensitivity)f=d(document).scrollTop(d(document).scrollTop()+c.scrollSpeed);if(!c.axis||c.axis!="y")if(a.pageX-d(document).scrollLeft()<c.scrollSensitivity)f=d(document).scrollLeft(d(document).scrollLeft()-c.scrollSpeed);else if(d(window).width()-(a.pageX-d(document).scrollLeft())<c.scrollSensitivity)f=d(document).scrollLeft(d(document).scrollLeft()+c.scrollSpeed)}f!==false&&d.ui.ddmanager&&!c.dropBehaviour&&d.ui.ddmanager.prepareOffsets(b,
|
243
|
+
a)}});d.ui.plugin.add("draggable","snap",{start:function(){var a=d(this).data("draggable"),b=a.options;a.snapElements=[];d(b.snap.constructor!=String?b.snap.items||":data(draggable)":b.snap).each(function(){var c=d(this),f=c.offset();this!=a.element[0]&&a.snapElements.push({item:this,width:c.outerWidth(),height:c.outerHeight(),top:f.top,left:f.left})})},drag:function(a,b){for(var c=d(this).data("draggable"),f=c.options,e=f.snapTolerance,h=b.offset.left,g=h+c.helperProportions.width,n=b.offset.top,
|
244
|
+
o=n+c.helperProportions.height,i=c.snapElements.length-1;i>=0;i--){var j=c.snapElements[i].left,l=j+c.snapElements[i].width,k=c.snapElements[i].top,m=k+c.snapElements[i].height;if(j-e<h&&h<l+e&&k-e<n&&n<m+e||j-e<h&&h<l+e&&k-e<o&&o<m+e||j-e<g&&g<l+e&&k-e<n&&n<m+e||j-e<g&&g<l+e&&k-e<o&&o<m+e){if(f.snapMode!="inner"){var p=Math.abs(k-o)<=e,q=Math.abs(m-n)<=e,r=Math.abs(j-g)<=e,s=Math.abs(l-h)<=e;if(p)b.position.top=c._convertPositionTo("relative",{top:k-c.helperProportions.height,left:0}).top-c.margins.top;
|
245
|
+
if(q)b.position.top=c._convertPositionTo("relative",{top:m,left:0}).top-c.margins.top;if(r)b.position.left=c._convertPositionTo("relative",{top:0,left:j-c.helperProportions.width}).left-c.margins.left;if(s)b.position.left=c._convertPositionTo("relative",{top:0,left:l}).left-c.margins.left}var t=p||q||r||s;if(f.snapMode!="outer"){p=Math.abs(k-n)<=e;q=Math.abs(m-o)<=e;r=Math.abs(j-h)<=e;s=Math.abs(l-g)<=e;if(p)b.position.top=c._convertPositionTo("relative",{top:k,left:0}).top-c.margins.top;if(q)b.position.top=
|
246
|
+
c._convertPositionTo("relative",{top:m-c.helperProportions.height,left:0}).top-c.margins.top;if(r)b.position.left=c._convertPositionTo("relative",{top:0,left:j}).left-c.margins.left;if(s)b.position.left=c._convertPositionTo("relative",{top:0,left:l-c.helperProportions.width}).left-c.margins.left}if(!c.snapElements[i].snapping&&(p||q||r||s||t))c.options.snap.snap&&c.options.snap.snap.call(c.element,a,d.extend(c._uiHash(),{snapItem:c.snapElements[i].item}));c.snapElements[i].snapping=p||q||r||s||t}else{c.snapElements[i].snapping&&
|
247
|
+
c.options.snap.release&&c.options.snap.release.call(c.element,a,d.extend(c._uiHash(),{snapItem:c.snapElements[i].item}));c.snapElements[i].snapping=false}}}});d.ui.plugin.add("draggable","stack",{start:function(){var a=d(this).data("draggable").options;a=d.makeArray(d(a.stack)).sort(function(c,f){return(parseInt(d(c).css("zIndex"),10)||0)-(parseInt(d(f).css("zIndex"),10)||0)});if(a.length){var b=parseInt(a[0].style.zIndex)||0;d(a).each(function(c){this.style.zIndex=b+c});this[0].style.zIndex=b+a.length}}});
|
248
|
+
d.ui.plugin.add("draggable","zIndex",{start:function(a,b){a=d(b.helper);b=d(this).data("draggable").options;if(a.css("zIndex"))b._zIndex=a.css("zIndex");a.css("zIndex",b.zIndex)},stop:function(a,b){a=d(this).data("draggable").options;a._zIndex&&d(b.helper).css("zIndex",a._zIndex)}})})(jQuery);
|
249
|
+
;
|
@@ -0,0 +1,1078 @@
|
|
1
|
+
/*
|
2
|
+
* jQuery UI Sortable 1.8.13
|
3
|
+
*
|
4
|
+
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
5
|
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
6
|
+
* http://jquery.org/license
|
7
|
+
*
|
8
|
+
* http://docs.jquery.com/UI/Sortables
|
9
|
+
*
|
10
|
+
* Depends:
|
11
|
+
* jquery.ui.core.js
|
12
|
+
* jquery.ui.mouse.js
|
13
|
+
* jquery.ui.widget.js
|
14
|
+
*/
|
15
|
+
(function( $, undefined ) {
|
16
|
+
|
17
|
+
$.widget("ui.sortable", $.ui.mouse, {
|
18
|
+
widgetEventPrefix: "sort",
|
19
|
+
options: {
|
20
|
+
appendTo: "parent",
|
21
|
+
axis: false,
|
22
|
+
connectWith: false,
|
23
|
+
containment: false,
|
24
|
+
cursor: 'auto',
|
25
|
+
cursorAt: false,
|
26
|
+
dropOnEmpty: true,
|
27
|
+
forcePlaceholderSize: false,
|
28
|
+
forceHelperSize: false,
|
29
|
+
grid: false,
|
30
|
+
handle: false,
|
31
|
+
helper: "original",
|
32
|
+
items: '> *',
|
33
|
+
opacity: false,
|
34
|
+
placeholder: false,
|
35
|
+
revert: false,
|
36
|
+
scroll: true,
|
37
|
+
scrollSensitivity: 20,
|
38
|
+
scrollSpeed: 20,
|
39
|
+
scope: "default",
|
40
|
+
tolerance: "intersect",
|
41
|
+
zIndex: 1000
|
42
|
+
},
|
43
|
+
_create: function() {
|
44
|
+
|
45
|
+
var o = this.options;
|
46
|
+
this.document = o.document;
|
47
|
+
|
48
|
+
this.containerCache = {};
|
49
|
+
this.element.addClass("ui-sortable");
|
50
|
+
|
51
|
+
//Get the items
|
52
|
+
this.refresh();
|
53
|
+
|
54
|
+
//Let's determine if the items are being displayed horizontally
|
55
|
+
this.floating = this.items.length ? o.axis === 'x' || (/left|right/).test(this.items[0].item.css('float')) || (/inline|table-cell/).test(this.items[0].item.css('display')) : false;
|
56
|
+
|
57
|
+
//Let's determine the parent's offset
|
58
|
+
this.offset = this.element.offset();
|
59
|
+
|
60
|
+
//Initialize mouse events for interaction
|
61
|
+
this._mouseInit();
|
62
|
+
|
63
|
+
},
|
64
|
+
|
65
|
+
destroy: function() {
|
66
|
+
this.element
|
67
|
+
.removeClass("ui-sortable ui-sortable-disabled")
|
68
|
+
.removeData("sortable")
|
69
|
+
.unbind(".sortable");
|
70
|
+
this._mouseDestroy();
|
71
|
+
|
72
|
+
for ( var i = this.items.length - 1; i >= 0; i-- )
|
73
|
+
this.items[i].item.removeData("sortable-item");
|
74
|
+
|
75
|
+
return this;
|
76
|
+
},
|
77
|
+
|
78
|
+
_setOption: function(key, value){
|
79
|
+
if ( key === "disabled" ) {
|
80
|
+
this.options[ key ] = value;
|
81
|
+
|
82
|
+
this.widget()
|
83
|
+
[ value ? "addClass" : "removeClass"]( "ui-sortable-disabled" );
|
84
|
+
} else {
|
85
|
+
// Don't call widget base _setOption for disable as it adds ui-state-disabled class
|
86
|
+
$.Widget.prototype._setOption.apply(this, arguments);
|
87
|
+
}
|
88
|
+
},
|
89
|
+
|
90
|
+
_mouseCapture: function(event, overrideHandle) {
|
91
|
+
|
92
|
+
if (this.reverting) {
|
93
|
+
return false;
|
94
|
+
}
|
95
|
+
|
96
|
+
if(this.options.disabled || this.options.type == 'static') return false;
|
97
|
+
|
98
|
+
//We have to refresh the items data once first
|
99
|
+
this._refreshItems(event);
|
100
|
+
|
101
|
+
//Find out if the clicked node (or one of its parents) is a actual item in this.items
|
102
|
+
var currentItem = null, self = this, nodes = $(event.target).parents().each(function() {
|
103
|
+
if($.data(this, 'sortable-item') == self) {
|
104
|
+
currentItem = $(this);
|
105
|
+
return false;
|
106
|
+
}
|
107
|
+
});
|
108
|
+
if($.data(event.target, 'sortable-item') == self) currentItem = $(event.target);
|
109
|
+
|
110
|
+
if(!currentItem) return false;
|
111
|
+
if(this.options.handle && !overrideHandle) {
|
112
|
+
var validHandle = false;
|
113
|
+
|
114
|
+
$(this.options.handle, currentItem).find("*").andSelf().each(function() { if(this == event.target) validHandle = true; });
|
115
|
+
if(!validHandle) return false;
|
116
|
+
}
|
117
|
+
|
118
|
+
this.currentItem = currentItem;
|
119
|
+
this._removeCurrentsFromItems();
|
120
|
+
return true;
|
121
|
+
|
122
|
+
},
|
123
|
+
|
124
|
+
_mouseStart: function(event, overrideHandle, noActivation) {
|
125
|
+
var o = this.options, self = this;
|
126
|
+
this.currentContainer = this;
|
127
|
+
|
128
|
+
//We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
|
129
|
+
this.refreshPositions();
|
130
|
+
|
131
|
+
//Create and append the visible helper
|
132
|
+
this.helper = this._createHelper(event);
|
133
|
+
|
134
|
+
//Cache the helper size
|
135
|
+
this._cacheHelperProportions();
|
136
|
+
|
137
|
+
/*
|
138
|
+
* - Position generation -
|
139
|
+
* This block generates everything position related - it's the core of draggables.
|
140
|
+
*/
|
141
|
+
|
142
|
+
//Cache the margins of the original element
|
143
|
+
this._cacheMargins();
|
144
|
+
|
145
|
+
//Get the next scrolling parent
|
146
|
+
this.scrollParent = this.helper.scrollParent();
|
147
|
+
|
148
|
+
//The element's absolute position on the page minus margins
|
149
|
+
this.offset = this.currentItem.offset();
|
150
|
+
this.offset = {
|
151
|
+
top: this.offset.top - this.margins.top,
|
152
|
+
left: this.offset.left - this.margins.left
|
153
|
+
};
|
154
|
+
|
155
|
+
// Only after we got the offset, we can change the helper's position to absolute
|
156
|
+
// TODO: Still need to figure out a way to make relative sorting possible
|
157
|
+
this.helper.css("position", "absolute");
|
158
|
+
this.cssPosition = this.helper.css("position");
|
159
|
+
|
160
|
+
$.extend(this.offset, {
|
161
|
+
click: { //Where the click happened, relative to the element
|
162
|
+
left: event.pageX - this.offset.left,
|
163
|
+
top: event.pageY - this.offset.top
|
164
|
+
},
|
165
|
+
parent: this._getParentOffset(),
|
166
|
+
relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
|
167
|
+
});
|
168
|
+
|
169
|
+
//Generate the original position
|
170
|
+
this.originalPosition = this._generatePosition(event);
|
171
|
+
this.originalPageX = event.pageX;
|
172
|
+
this.originalPageY = event.pageY;
|
173
|
+
|
174
|
+
//Adjust the mouse offset relative to the helper if 'cursorAt' is supplied
|
175
|
+
(o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
|
176
|
+
|
177
|
+
//Cache the former DOM position
|
178
|
+
this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
|
179
|
+
|
180
|
+
//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
|
181
|
+
if(this.helper[0] != this.currentItem[0]) {
|
182
|
+
this.currentItem.hide();
|
183
|
+
}
|
184
|
+
|
185
|
+
//Create the placeholder
|
186
|
+
this._createPlaceholder();
|
187
|
+
|
188
|
+
//Set a containment if given in the options
|
189
|
+
if(o.containment)
|
190
|
+
this._setContainment();
|
191
|
+
|
192
|
+
if(o.cursor) { // cursor option
|
193
|
+
if ($('body').css("cursor")) this._storedCursor = $('body').css("cursor");
|
194
|
+
$('body').css("cursor", o.cursor);
|
195
|
+
}
|
196
|
+
|
197
|
+
if(o.opacity) { // opacity option
|
198
|
+
if (this.helper.css("opacity")) this._storedOpacity = this.helper.css("opacity");
|
199
|
+
this.helper.css("opacity", o.opacity);
|
200
|
+
}
|
201
|
+
|
202
|
+
if(o.zIndex) { // zIndex option
|
203
|
+
if (this.helper.css("zIndex")) this._storedZIndex = this.helper.css("zIndex");
|
204
|
+
this.helper.css("zIndex", o.zIndex);
|
205
|
+
}
|
206
|
+
|
207
|
+
//Prepare scrolling
|
208
|
+
if(this.scrollParent[0] != (this.document || document) && this.scrollParent[0].tagName != 'HTML')
|
209
|
+
this.overflowOffset = this.scrollParent.offset();
|
210
|
+
|
211
|
+
//Call callbacks
|
212
|
+
this._trigger("start", event, this._uiHash());
|
213
|
+
|
214
|
+
//Recache the helper size
|
215
|
+
if(!this._preserveHelperProportions)
|
216
|
+
this._cacheHelperProportions();
|
217
|
+
|
218
|
+
|
219
|
+
//Post 'activate' events to possible containers
|
220
|
+
if(!noActivation) {
|
221
|
+
for (var i = this.containers.length - 1; i >= 0; i--) { this.containers[i]._trigger("activate", event, self._uiHash(this)); }
|
222
|
+
}
|
223
|
+
|
224
|
+
//Prepare possible droppables
|
225
|
+
if($.ui.ddmanager)
|
226
|
+
$.ui.ddmanager.current = this;
|
227
|
+
|
228
|
+
if ($.ui.ddmanager && !o.dropBehaviour)
|
229
|
+
$.ui.ddmanager.prepareOffsets(this, event);
|
230
|
+
|
231
|
+
this.dragging = true;
|
232
|
+
|
233
|
+
this.helper.addClass("ui-sortable-helper");
|
234
|
+
this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
|
235
|
+
return true;
|
236
|
+
|
237
|
+
},
|
238
|
+
|
239
|
+
_mouseDrag: function(event) {
|
240
|
+
|
241
|
+
//Compute the helpers position
|
242
|
+
this.position = this._generatePosition(event);
|
243
|
+
this.positionAbs = this._convertPositionTo("absolute");
|
244
|
+
|
245
|
+
if (!this.lastPositionAbs) {
|
246
|
+
this.lastPositionAbs = this.positionAbs;
|
247
|
+
}
|
248
|
+
|
249
|
+
//Do scrolling
|
250
|
+
if(this.options.scroll) {
|
251
|
+
var o = this.options, scrolled = false;
|
252
|
+
if(this.scrollParent[0] != (this.document || document) && this.scrollParent[0].tagName != 'HTML') {
|
253
|
+
|
254
|
+
if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
|
255
|
+
this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
|
256
|
+
else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity)
|
257
|
+
this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
|
258
|
+
|
259
|
+
if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
|
260
|
+
this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
|
261
|
+
else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity)
|
262
|
+
this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
|
263
|
+
|
264
|
+
} else {
|
265
|
+
|
266
|
+
if(event.pageY - $((this.document || document)).scrollTop() < o.scrollSensitivity)
|
267
|
+
scrolled = $((this.document || document)).scrollTop($((this.document || document)).scrollTop() - o.scrollSpeed);
|
268
|
+
else if($(window).height() - (event.pageY - $((this.document || document)).scrollTop()) < o.scrollSensitivity)
|
269
|
+
scrolled = $((this.document || document)).scrollTop($((this.document || document)).scrollTop() + o.scrollSpeed);
|
270
|
+
|
271
|
+
if(event.pageX - $((this.document || document)).scrollLeft() < o.scrollSensitivity)
|
272
|
+
scrolled = $((this.document || document)).scrollLeft($((this.document || document)).scrollLeft() - o.scrollSpeed);
|
273
|
+
else if($(window).width() - (event.pageX - $((this.document || document)).scrollLeft()) < o.scrollSensitivity)
|
274
|
+
scrolled = $((this.document || document)).scrollLeft($((this.document || document)).scrollLeft() + o.scrollSpeed);
|
275
|
+
|
276
|
+
}
|
277
|
+
|
278
|
+
if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
|
279
|
+
$.ui.ddmanager.prepareOffsets(this, event);
|
280
|
+
}
|
281
|
+
|
282
|
+
//Regenerate the absolute position used for position checks
|
283
|
+
this.positionAbs = this._convertPositionTo("absolute");
|
284
|
+
|
285
|
+
//Set the helper position
|
286
|
+
if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
|
287
|
+
if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
|
288
|
+
|
289
|
+
//Rearrange
|
290
|
+
for (var i = this.items.length - 1; i >= 0; i--) {
|
291
|
+
|
292
|
+
//Cache variables and intersection, continue if no intersection
|
293
|
+
var item = this.items[i], itemElement = item.item[0], intersection = this._intersectsWithPointer(item);
|
294
|
+
if (!intersection) continue;
|
295
|
+
|
296
|
+
if(itemElement != this.currentItem[0] //cannot intersect with itself
|
297
|
+
&& this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != itemElement //no useless actions that have been done before
|
298
|
+
&& !$.ui.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked
|
299
|
+
&& (this.options.type == 'semi-dynamic' ? !$.ui.contains(this.element[0], itemElement) : true)
|
300
|
+
//&& itemElement.parentNode == this.placeholder[0].parentNode // only rearrange items within the same container
|
301
|
+
) {
|
302
|
+
|
303
|
+
this.direction = intersection == 1 ? "down" : "up";
|
304
|
+
|
305
|
+
if (this.options.tolerance == "pointer" || this._intersectsWithSides(item)) {
|
306
|
+
this._rearrange(event, item);
|
307
|
+
} else {
|
308
|
+
break;
|
309
|
+
}
|
310
|
+
|
311
|
+
this._trigger("change", event, this._uiHash());
|
312
|
+
break;
|
313
|
+
}
|
314
|
+
}
|
315
|
+
|
316
|
+
//Post events to containers
|
317
|
+
this._contactContainers(event);
|
318
|
+
|
319
|
+
//Interconnect with droppables
|
320
|
+
if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
|
321
|
+
|
322
|
+
//Call callbacks
|
323
|
+
this._trigger('sort', event, this._uiHash());
|
324
|
+
|
325
|
+
this.lastPositionAbs = this.positionAbs;
|
326
|
+
return false;
|
327
|
+
|
328
|
+
},
|
329
|
+
|
330
|
+
_mouseStop: function(event, noPropagation) {
|
331
|
+
|
332
|
+
if(!event) return;
|
333
|
+
|
334
|
+
//If we are using droppables, inform the manager about the drop
|
335
|
+
if ($.ui.ddmanager && !this.options.dropBehaviour)
|
336
|
+
$.ui.ddmanager.drop(this, event);
|
337
|
+
|
338
|
+
if(this.options.revert) {
|
339
|
+
var self = this;
|
340
|
+
var cur = self.placeholder.offset();
|
341
|
+
|
342
|
+
self.reverting = true;
|
343
|
+
|
344
|
+
$(this.helper).animate({
|
345
|
+
left: cur.left - this.offset.parent.left - self.margins.left + (this.offsetParent[0] == (this.document || document).body ? 0 : this.offsetParent[0].scrollLeft),
|
346
|
+
top: cur.top - this.offset.parent.top - self.margins.top + (this.offsetParent[0] == (this.document || document).body ? 0 : this.offsetParent[0].scrollTop)
|
347
|
+
}, parseInt(this.options.revert, 10) || 500, function() {
|
348
|
+
self._clear(event);
|
349
|
+
});
|
350
|
+
} else {
|
351
|
+
this._clear(event, noPropagation);
|
352
|
+
}
|
353
|
+
|
354
|
+
return false;
|
355
|
+
|
356
|
+
},
|
357
|
+
|
358
|
+
cancel: function() {
|
359
|
+
|
360
|
+
var self = this;
|
361
|
+
|
362
|
+
if(this.dragging) {
|
363
|
+
|
364
|
+
this._mouseUp({ target: null });
|
365
|
+
|
366
|
+
if(this.options.helper == "original")
|
367
|
+
this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
|
368
|
+
else
|
369
|
+
this.currentItem.show();
|
370
|
+
|
371
|
+
//Post deactivating events to containers
|
372
|
+
for (var i = this.containers.length - 1; i >= 0; i--){
|
373
|
+
this.containers[i]._trigger("deactivate", null, self._uiHash(this));
|
374
|
+
if(this.containers[i].containerCache.over) {
|
375
|
+
this.containers[i]._trigger("out", null, self._uiHash(this));
|
376
|
+
this.containers[i].containerCache.over = 0;
|
377
|
+
}
|
378
|
+
}
|
379
|
+
|
380
|
+
}
|
381
|
+
|
382
|
+
if (this.placeholder) {
|
383
|
+
//$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
|
384
|
+
if(this.placeholder[0].parentNode) this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
|
385
|
+
if(this.options.helper != "original" && this.helper && this.helper[0].parentNode) this.helper.remove();
|
386
|
+
|
387
|
+
$.extend(this, {
|
388
|
+
helper: null,
|
389
|
+
dragging: false,
|
390
|
+
reverting: false,
|
391
|
+
_noFinalSort: null
|
392
|
+
});
|
393
|
+
|
394
|
+
if(this.domPosition.prev) {
|
395
|
+
$(this.domPosition.prev).after(this.currentItem);
|
396
|
+
} else {
|
397
|
+
$(this.domPosition.parent).prepend(this.currentItem);
|
398
|
+
}
|
399
|
+
}
|
400
|
+
|
401
|
+
return this;
|
402
|
+
|
403
|
+
},
|
404
|
+
|
405
|
+
serialize: function(o) {
|
406
|
+
|
407
|
+
var items = this._getItemsAsjQuery(o && o.connected);
|
408
|
+
var str = []; o = o || {};
|
409
|
+
|
410
|
+
$(items).each(function() {
|
411
|
+
var res = ($(o.item || this).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));
|
412
|
+
if(res) str.push((o.key || res[1]+'[]')+'='+(o.key && o.expression ? res[1] : res[2]));
|
413
|
+
});
|
414
|
+
|
415
|
+
if(!str.length && o.key) {
|
416
|
+
str.push(o.key + '=');
|
417
|
+
}
|
418
|
+
|
419
|
+
return str.join('&');
|
420
|
+
|
421
|
+
},
|
422
|
+
|
423
|
+
toArray: function(o) {
|
424
|
+
|
425
|
+
var items = this._getItemsAsjQuery(o && o.connected);
|
426
|
+
var ret = []; o = o || {};
|
427
|
+
|
428
|
+
items.each(function() { ret.push($(o.item || this).attr(o.attribute || 'id') || ''); });
|
429
|
+
return ret;
|
430
|
+
|
431
|
+
},
|
432
|
+
|
433
|
+
/* Be careful with the following core functions */
|
434
|
+
_intersectsWith: function(item) {
|
435
|
+
|
436
|
+
var x1 = this.positionAbs.left,
|
437
|
+
x2 = x1 + this.helperProportions.width,
|
438
|
+
y1 = this.positionAbs.top,
|
439
|
+
y2 = y1 + this.helperProportions.height;
|
440
|
+
|
441
|
+
var l = item.left,
|
442
|
+
r = l + item.width,
|
443
|
+
t = item.top,
|
444
|
+
b = t + item.height;
|
445
|
+
|
446
|
+
var dyClick = this.offset.click.top,
|
447
|
+
dxClick = this.offset.click.left;
|
448
|
+
|
449
|
+
var isOverElement = (y1 + dyClick) > t && (y1 + dyClick) < b && (x1 + dxClick) > l && (x1 + dxClick) < r;
|
450
|
+
|
451
|
+
if( this.options.tolerance == "pointer"
|
452
|
+
|| this.options.forcePointerForContainers
|
453
|
+
|| (this.options.tolerance != "pointer" && this.helperProportions[this.floating ? 'width' : 'height'] > item[this.floating ? 'width' : 'height'])
|
454
|
+
) {
|
455
|
+
return isOverElement;
|
456
|
+
} else {
|
457
|
+
|
458
|
+
return (l < x1 + (this.helperProportions.width / 2) // Right Half
|
459
|
+
&& x2 - (this.helperProportions.width / 2) < r // Left Half
|
460
|
+
&& t < y1 + (this.helperProportions.height / 2) // Bottom Half
|
461
|
+
&& y2 - (this.helperProportions.height / 2) < b ); // Top Half
|
462
|
+
|
463
|
+
}
|
464
|
+
},
|
465
|
+
|
466
|
+
_intersectsWithPointer: function(item) {
|
467
|
+
|
468
|
+
var isOverElementHeight = $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
|
469
|
+
isOverElementWidth = $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
|
470
|
+
isOverElement = isOverElementHeight && isOverElementWidth,
|
471
|
+
verticalDirection = this._getDragVerticalDirection(),
|
472
|
+
horizontalDirection = this._getDragHorizontalDirection();
|
473
|
+
|
474
|
+
if (!isOverElement)
|
475
|
+
return false;
|
476
|
+
|
477
|
+
return this.floating ?
|
478
|
+
( ((horizontalDirection && horizontalDirection == "right") || verticalDirection == "down") ? 2 : 1 )
|
479
|
+
: ( verticalDirection && (verticalDirection == "down" ? 2 : 1) );
|
480
|
+
|
481
|
+
},
|
482
|
+
|
483
|
+
_intersectsWithSides: function(item) {
|
484
|
+
|
485
|
+
var isOverBottomHalf = $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
|
486
|
+
isOverRightHalf = $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
|
487
|
+
verticalDirection = this._getDragVerticalDirection(),
|
488
|
+
horizontalDirection = this._getDragHorizontalDirection();
|
489
|
+
|
490
|
+
if (this.floating && horizontalDirection) {
|
491
|
+
return ((horizontalDirection == "right" && isOverRightHalf) || (horizontalDirection == "left" && !isOverRightHalf));
|
492
|
+
} else {
|
493
|
+
return verticalDirection && ((verticalDirection == "down" && isOverBottomHalf) || (verticalDirection == "up" && !isOverBottomHalf));
|
494
|
+
}
|
495
|
+
|
496
|
+
},
|
497
|
+
|
498
|
+
_getDragVerticalDirection: function() {
|
499
|
+
var delta = this.positionAbs.top - this.lastPositionAbs.top;
|
500
|
+
return delta != 0 && (delta > 0 ? "down" : "up");
|
501
|
+
},
|
502
|
+
|
503
|
+
_getDragHorizontalDirection: function() {
|
504
|
+
var delta = this.positionAbs.left - this.lastPositionAbs.left;
|
505
|
+
return delta != 0 && (delta > 0 ? "right" : "left");
|
506
|
+
},
|
507
|
+
|
508
|
+
refresh: function(event) {
|
509
|
+
this._refreshItems(event);
|
510
|
+
this.refreshPositions();
|
511
|
+
return this;
|
512
|
+
},
|
513
|
+
|
514
|
+
_connectWith: function() {
|
515
|
+
var options = this.options;
|
516
|
+
return options.connectWith.constructor == String
|
517
|
+
? [options.connectWith]
|
518
|
+
: options.connectWith;
|
519
|
+
},
|
520
|
+
|
521
|
+
_getItemsAsjQuery: function(connected) {
|
522
|
+
|
523
|
+
var self = this;
|
524
|
+
var items = [];
|
525
|
+
var queries = [];
|
526
|
+
var connectWith = this._connectWith();
|
527
|
+
|
528
|
+
if(connectWith && connected) {
|
529
|
+
for (var i = connectWith.length - 1; i >= 0; i--){
|
530
|
+
var cur = $(connectWith[i]);
|
531
|
+
for (var j = cur.length - 1; j >= 0; j--){
|
532
|
+
var inst = $.data(cur[j], 'sortable');
|
533
|
+
if(inst && inst != this && !inst.options.disabled) {
|
534
|
+
queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not(".ui-sortable-helper").not('.ui-sortable-placeholder'), inst]);
|
535
|
+
}
|
536
|
+
};
|
537
|
+
};
|
538
|
+
}
|
539
|
+
|
540
|
+
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").not('.ui-sortable-placeholder'), this]);
|
541
|
+
|
542
|
+
for (var i = queries.length - 1; i >= 0; i--){
|
543
|
+
queries[i][0].each(function() {
|
544
|
+
items.push(this);
|
545
|
+
});
|
546
|
+
};
|
547
|
+
|
548
|
+
return $(items);
|
549
|
+
|
550
|
+
},
|
551
|
+
|
552
|
+
_removeCurrentsFromItems: function() {
|
553
|
+
|
554
|
+
var list = this.currentItem.find(":data(sortable-item)");
|
555
|
+
|
556
|
+
for (var i=0; i < this.items.length; i++) {
|
557
|
+
|
558
|
+
for (var j=0; j < list.length; j++) {
|
559
|
+
if(list[j] == this.items[i].item[0])
|
560
|
+
this.items.splice(i,1);
|
561
|
+
};
|
562
|
+
|
563
|
+
};
|
564
|
+
|
565
|
+
},
|
566
|
+
|
567
|
+
_refreshItems: function(event) {
|
568
|
+
|
569
|
+
this.items = [];
|
570
|
+
this.containers = [this];
|
571
|
+
var items = this.items;
|
572
|
+
var self = this;
|
573
|
+
var queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]];
|
574
|
+
var connectWith = this._connectWith();
|
575
|
+
|
576
|
+
if(connectWith) {
|
577
|
+
for (var i = connectWith.length - 1; i >= 0; i--){
|
578
|
+
var cur = $(connectWith[i]);
|
579
|
+
for (var j = cur.length - 1; j >= 0; j--){
|
580
|
+
var inst = $.data(cur[j], 'sortable');
|
581
|
+
if(inst && inst != this && !inst.options.disabled) {
|
582
|
+
queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
|
583
|
+
this.containers.push(inst);
|
584
|
+
}
|
585
|
+
};
|
586
|
+
};
|
587
|
+
}
|
588
|
+
|
589
|
+
for (var i = queries.length - 1; i >= 0; i--) {
|
590
|
+
var targetData = queries[i][1];
|
591
|
+
var _queries = queries[i][0];
|
592
|
+
|
593
|
+
for (var j=0, queriesLength = _queries.length; j < queriesLength; j++) {
|
594
|
+
var item = $(_queries[j]);
|
595
|
+
|
596
|
+
item.data('sortable-item', targetData); // Data for target checking (mouse manager)
|
597
|
+
|
598
|
+
items.push({
|
599
|
+
item: item,
|
600
|
+
instance: targetData,
|
601
|
+
width: 0, height: 0,
|
602
|
+
left: 0, top: 0
|
603
|
+
});
|
604
|
+
};
|
605
|
+
};
|
606
|
+
|
607
|
+
},
|
608
|
+
|
609
|
+
refreshPositions: function(fast) {
|
610
|
+
|
611
|
+
//This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
|
612
|
+
if(this.offsetParent && this.helper) {
|
613
|
+
this.offset.parent = this._getParentOffset();
|
614
|
+
}
|
615
|
+
|
616
|
+
for (var i = this.items.length - 1; i >= 0; i--){
|
617
|
+
var item = this.items[i];
|
618
|
+
|
619
|
+
//We ignore calculating positions of all connected containers when we're not over them
|
620
|
+
if(item.instance != this.currentContainer && this.currentContainer && item.item[0] != this.currentItem[0])
|
621
|
+
continue;
|
622
|
+
|
623
|
+
var t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
|
624
|
+
|
625
|
+
if (!fast) {
|
626
|
+
item.width = t.outerWidth();
|
627
|
+
item.height = t.outerHeight();
|
628
|
+
}
|
629
|
+
|
630
|
+
var p = t.offset();
|
631
|
+
item.left = p.left;
|
632
|
+
item.top = p.top;
|
633
|
+
};
|
634
|
+
|
635
|
+
if(this.options.custom && this.options.custom.refreshContainers) {
|
636
|
+
this.options.custom.refreshContainers.call(this);
|
637
|
+
} else {
|
638
|
+
for (var i = this.containers.length - 1; i >= 0; i--){
|
639
|
+
var p = this.containers[i].element.offset();
|
640
|
+
this.containers[i].containerCache.left = p.left;
|
641
|
+
this.containers[i].containerCache.top = p.top;
|
642
|
+
this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
|
643
|
+
this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
|
644
|
+
};
|
645
|
+
}
|
646
|
+
|
647
|
+
return this;
|
648
|
+
},
|
649
|
+
|
650
|
+
_createPlaceholder: function(that) {
|
651
|
+
|
652
|
+
var self = that || this, o = self.options;
|
653
|
+
|
654
|
+
if(!o.placeholder || o.placeholder.constructor == String) {
|
655
|
+
var className = o.placeholder;
|
656
|
+
o.placeholder = {
|
657
|
+
element: function() {
|
658
|
+
|
659
|
+
var el = $((this.document || document).createElement(self.currentItem[0].nodeName))
|
660
|
+
.addClass(className || self.currentItem[0].className+" ui-sortable-placeholder")
|
661
|
+
.removeClass("ui-sortable-helper")[0];
|
662
|
+
|
663
|
+
if(!className)
|
664
|
+
el.style.visibility = "hidden";
|
665
|
+
|
666
|
+
return el;
|
667
|
+
},
|
668
|
+
update: function(container, p) {
|
669
|
+
|
670
|
+
// 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
|
671
|
+
// 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
|
672
|
+
if(className && !o.forcePlaceholderSize) return;
|
673
|
+
|
674
|
+
//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
|
675
|
+
if(!p.height()) { p.height(self.currentItem.innerHeight() - parseInt(self.currentItem.css('paddingTop')||0, 10) - parseInt(self.currentItem.css('paddingBottom')||0, 10)); };
|
676
|
+
if(!p.width()) { p.width(self.currentItem.innerWidth() - parseInt(self.currentItem.css('paddingLeft')||0, 10) - parseInt(self.currentItem.css('paddingRight')||0, 10)); };
|
677
|
+
}
|
678
|
+
};
|
679
|
+
}
|
680
|
+
|
681
|
+
//Create the placeholder
|
682
|
+
self.placeholder = $(o.placeholder.element.call(self.element, self.currentItem));
|
683
|
+
|
684
|
+
//Append it after the actual current item
|
685
|
+
self.currentItem.after(self.placeholder);
|
686
|
+
|
687
|
+
//Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
|
688
|
+
o.placeholder.update(self, self.placeholder);
|
689
|
+
|
690
|
+
},
|
691
|
+
|
692
|
+
_contactContainers: function(event) {
|
693
|
+
|
694
|
+
// get innermost container that intersects with item
|
695
|
+
var innermostContainer = null, innermostIndex = null;
|
696
|
+
|
697
|
+
|
698
|
+
for (var i = this.containers.length - 1; i >= 0; i--){
|
699
|
+
|
700
|
+
// never consider a container that's located within the item itself
|
701
|
+
if($.ui.contains(this.currentItem[0], this.containers[i].element[0]))
|
702
|
+
continue;
|
703
|
+
|
704
|
+
if(this._intersectsWith(this.containers[i].containerCache)) {
|
705
|
+
|
706
|
+
// if we've already found a container and it's more "inner" than this, then continue
|
707
|
+
if(innermostContainer && $.ui.contains(this.containers[i].element[0], innermostContainer.element[0]))
|
708
|
+
continue;
|
709
|
+
|
710
|
+
innermostContainer = this.containers[i];
|
711
|
+
innermostIndex = i;
|
712
|
+
|
713
|
+
} else {
|
714
|
+
// container doesn't intersect. trigger "out" event if necessary
|
715
|
+
if(this.containers[i].containerCache.over) {
|
716
|
+
this.containers[i]._trigger("out", event, this._uiHash(this));
|
717
|
+
this.containers[i].containerCache.over = 0;
|
718
|
+
}
|
719
|
+
}
|
720
|
+
|
721
|
+
}
|
722
|
+
|
723
|
+
// if no intersecting containers found, return
|
724
|
+
if(!innermostContainer) return;
|
725
|
+
|
726
|
+
// move the item into the container if it's not there already
|
727
|
+
if(this.containers.length === 1) {
|
728
|
+
this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
|
729
|
+
this.containers[innermostIndex].containerCache.over = 1;
|
730
|
+
} else if(this.currentContainer != this.containers[innermostIndex]) {
|
731
|
+
|
732
|
+
//When entering a new container, we will find the item with the least distance and append our item near it
|
733
|
+
var dist = 10000; var itemWithLeastDistance = null; var base = this.positionAbs[this.containers[innermostIndex].floating ? 'left' : 'top'];
|
734
|
+
for (var j = this.items.length - 1; j >= 0; j--) {
|
735
|
+
if(!$.ui.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) continue;
|
736
|
+
var cur = this.items[j][this.containers[innermostIndex].floating ? 'left' : 'top'];
|
737
|
+
if(Math.abs(cur - base) < dist) {
|
738
|
+
dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
|
739
|
+
}
|
740
|
+
}
|
741
|
+
|
742
|
+
if(!itemWithLeastDistance && !this.options.dropOnEmpty) //Check if dropOnEmpty is enabled
|
743
|
+
return;
|
744
|
+
|
745
|
+
this.currentContainer = this.containers[innermostIndex];
|
746
|
+
itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
|
747
|
+
this._trigger("change", event, this._uiHash());
|
748
|
+
this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
|
749
|
+
|
750
|
+
//Update the placeholder
|
751
|
+
this.options.placeholder.update(this.currentContainer, this.placeholder);
|
752
|
+
|
753
|
+
this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
|
754
|
+
this.containers[innermostIndex].containerCache.over = 1;
|
755
|
+
}
|
756
|
+
|
757
|
+
|
758
|
+
},
|
759
|
+
|
760
|
+
_createHelper: function(event) {
|
761
|
+
|
762
|
+
var o = this.options;
|
763
|
+
var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper == 'clone' ? this.currentItem.clone() : this.currentItem);
|
764
|
+
|
765
|
+
if(!helper.parents('body').length) //Add the helper to the DOM if that didn't happen already
|
766
|
+
$(o.appendTo != 'parent' ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
|
767
|
+
|
768
|
+
if(helper[0] == this.currentItem[0])
|
769
|
+
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") };
|
770
|
+
|
771
|
+
if(helper[0].style.width == '' || o.forceHelperSize) helper.width(this.currentItem.width());
|
772
|
+
if(helper[0].style.height == '' || o.forceHelperSize) helper.height(this.currentItem.height());
|
773
|
+
|
774
|
+
return helper;
|
775
|
+
|
776
|
+
},
|
777
|
+
|
778
|
+
_adjustOffsetFromHelper: function(obj) {
|
779
|
+
if (typeof obj == 'string') {
|
780
|
+
obj = obj.split(' ');
|
781
|
+
}
|
782
|
+
if ($.isArray(obj)) {
|
783
|
+
obj = {left: +obj[0], top: +obj[1] || 0};
|
784
|
+
}
|
785
|
+
if ('left' in obj) {
|
786
|
+
this.offset.click.left = obj.left + this.margins.left;
|
787
|
+
}
|
788
|
+
if ('right' in obj) {
|
789
|
+
this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
|
790
|
+
}
|
791
|
+
if ('top' in obj) {
|
792
|
+
this.offset.click.top = obj.top + this.margins.top;
|
793
|
+
}
|
794
|
+
if ('bottom' in obj) {
|
795
|
+
this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
|
796
|
+
}
|
797
|
+
},
|
798
|
+
|
799
|
+
_getParentOffset: function() {
|
800
|
+
|
801
|
+
|
802
|
+
//Get the offsetParent and cache its position
|
803
|
+
this.offsetParent = this.helper.offsetParent();
|
804
|
+
var po = this.offsetParent.offset();
|
805
|
+
|
806
|
+
// This is a special case where we need to modify a offset calculated on start, since the following happened:
|
807
|
+
// 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
|
808
|
+
// 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
|
809
|
+
// the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
|
810
|
+
if(this.cssPosition == 'absolute' && this.scrollParent[0] != (this.document || document) && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) {
|
811
|
+
po.left += this.scrollParent.scrollLeft();
|
812
|
+
po.top += this.scrollParent.scrollTop();
|
813
|
+
}
|
814
|
+
|
815
|
+
if((this.offsetParent[0] == (this.document || document).body) //This needs to be actually done for all browsers, since pageX/pageY includes this information
|
816
|
+
|| (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix
|
817
|
+
po = { top: 0, left: 0 };
|
818
|
+
|
819
|
+
return {
|
820
|
+
top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
|
821
|
+
left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
|
822
|
+
};
|
823
|
+
|
824
|
+
},
|
825
|
+
|
826
|
+
_getRelativeOffset: function() {
|
827
|
+
|
828
|
+
if(this.cssPosition == "relative") {
|
829
|
+
var p = this.currentItem.position();
|
830
|
+
return {
|
831
|
+
top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
|
832
|
+
left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
|
833
|
+
};
|
834
|
+
} else {
|
835
|
+
return { top: 0, left: 0 };
|
836
|
+
}
|
837
|
+
|
838
|
+
},
|
839
|
+
|
840
|
+
_cacheMargins: function() {
|
841
|
+
this.margins = {
|
842
|
+
left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
|
843
|
+
top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
|
844
|
+
};
|
845
|
+
},
|
846
|
+
|
847
|
+
_cacheHelperProportions: function() {
|
848
|
+
this.helperProportions = {
|
849
|
+
width: this.helper.outerWidth(),
|
850
|
+
height: this.helper.outerHeight()
|
851
|
+
};
|
852
|
+
},
|
853
|
+
|
854
|
+
_setContainment: function() {
|
855
|
+
|
856
|
+
var o = this.options;
|
857
|
+
if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
|
858
|
+
if(o.containment == 'document' || o.containment == 'window') this.containment = [
|
859
|
+
0 - this.offset.relative.left - this.offset.parent.left,
|
860
|
+
0 - this.offset.relative.top - this.offset.parent.top,
|
861
|
+
$(o.containment == 'document' ? (this.document || document) : window).width() - this.helperProportions.width - this.margins.left,
|
862
|
+
($(o.containment == 'document' ? (this.document || document) : window).height() || (this.document || document).body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
|
863
|
+
];
|
864
|
+
|
865
|
+
if(!(/^(document|window|parent)$/).test(o.containment)) {
|
866
|
+
var ce = $(o.containment)[0];
|
867
|
+
var co = $(o.containment).offset();
|
868
|
+
var over = ($(ce).css("overflow") != 'hidden');
|
869
|
+
|
870
|
+
this.containment = [
|
871
|
+
co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
|
872
|
+
co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
|
873
|
+
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,
|
874
|
+
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
|
875
|
+
];
|
876
|
+
}
|
877
|
+
|
878
|
+
},
|
879
|
+
|
880
|
+
_convertPositionTo: function(d, pos) {
|
881
|
+
|
882
|
+
if(!pos) pos = this.position;
|
883
|
+
var mod = d == "absolute" ? 1 : -1;
|
884
|
+
var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != (this.document || document) && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
|
885
|
+
|
886
|
+
return {
|
887
|
+
top: (
|
888
|
+
pos.top // The absolute mouse position
|
889
|
+
+ this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent
|
890
|
+
+ this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border)
|
891
|
+
- ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
|
892
|
+
),
|
893
|
+
left: (
|
894
|
+
pos.left // The absolute mouse position
|
895
|
+
+ this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent
|
896
|
+
+ this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border)
|
897
|
+
- ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
|
898
|
+
)
|
899
|
+
};
|
900
|
+
|
901
|
+
},
|
902
|
+
|
903
|
+
_generatePosition: function(event) {
|
904
|
+
|
905
|
+
var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != (this.document || document) && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
|
906
|
+
|
907
|
+
// This is another very weird special case that only happens for relative elements:
|
908
|
+
// 1. If the css position is relative
|
909
|
+
// 2. and the scroll parent is the document or similar to the offset parent
|
910
|
+
// we have to refresh the relative offset during the scroll so there are no jumps
|
911
|
+
if(this.cssPosition == 'relative' && !(this.scrollParent[0] != (this.document || document) && this.scrollParent[0] != this.offsetParent[0])) {
|
912
|
+
this.offset.relative = this._getRelativeOffset();
|
913
|
+
}
|
914
|
+
|
915
|
+
var pageX = event.pageX;
|
916
|
+
var pageY = event.pageY;
|
917
|
+
|
918
|
+
/*
|
919
|
+
* - Position constraining -
|
920
|
+
* Constrain the position to a mix of grid, containment.
|
921
|
+
*/
|
922
|
+
|
923
|
+
if(this.originalPosition) { //If we are not dragging yet, we won't check for options
|
924
|
+
|
925
|
+
if(this.containment) {
|
926
|
+
if(event.pageX - this.offset.click.left < this.containment[0]) pageX = this.containment[0] + this.offset.click.left;
|
927
|
+
if(event.pageY - this.offset.click.top < this.containment[1]) pageY = this.containment[1] + this.offset.click.top;
|
928
|
+
if(event.pageX - this.offset.click.left > this.containment[2]) pageX = this.containment[2] + this.offset.click.left;
|
929
|
+
if(event.pageY - this.offset.click.top > this.containment[3]) pageY = this.containment[3] + this.offset.click.top;
|
930
|
+
}
|
931
|
+
|
932
|
+
if(o.grid) {
|
933
|
+
var top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
|
934
|
+
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;
|
935
|
+
|
936
|
+
var left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
|
937
|
+
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;
|
938
|
+
}
|
939
|
+
|
940
|
+
}
|
941
|
+
|
942
|
+
return {
|
943
|
+
top: (
|
944
|
+
pageY // The absolute mouse position
|
945
|
+
- this.offset.click.top // Click offset (relative to the element)
|
946
|
+
- this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent
|
947
|
+
- this.offset.parent.top // The offsetParent's offset without borders (offset + border)
|
948
|
+
+ ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
|
949
|
+
),
|
950
|
+
left: (
|
951
|
+
pageX // The absolute mouse position
|
952
|
+
- this.offset.click.left // Click offset (relative to the element)
|
953
|
+
- this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent
|
954
|
+
- this.offset.parent.left // The offsetParent's offset without borders (offset + border)
|
955
|
+
+ ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
|
956
|
+
)
|
957
|
+
};
|
958
|
+
|
959
|
+
},
|
960
|
+
|
961
|
+
_rearrange: function(event, i, a, hardRefresh) {
|
962
|
+
|
963
|
+
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));
|
964
|
+
|
965
|
+
//Various things done here to improve the performance:
|
966
|
+
// 1. we create a setTimeout, that calls refreshPositions
|
967
|
+
// 2. on the instance, we have a counter variable, that get's higher after every append
|
968
|
+
// 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
|
969
|
+
// 4. this lets only the last addition to the timeout stack through
|
970
|
+
this.counter = this.counter ? ++this.counter : 1;
|
971
|
+
var self = this, counter = this.counter;
|
972
|
+
|
973
|
+
window.setTimeout(function() {
|
974
|
+
if(counter == self.counter) self.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
|
975
|
+
},0);
|
976
|
+
|
977
|
+
},
|
978
|
+
|
979
|
+
_clear: function(event, noPropagation) {
|
980
|
+
|
981
|
+
this.reverting = false;
|
982
|
+
// We delay all events that have to be triggered to after the point where the placeholder has been removed and
|
983
|
+
// everything else normalized again
|
984
|
+
var delayedTriggers = [], self = this;
|
985
|
+
|
986
|
+
// We first have to update the dom position of the actual currentItem
|
987
|
+
// Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
|
988
|
+
if(!this._noFinalSort && this.currentItem[0].parentNode) this.placeholder.before(this.currentItem);
|
989
|
+
this._noFinalSort = null;
|
990
|
+
|
991
|
+
if(this.helper[0] == this.currentItem[0]) {
|
992
|
+
for(var i in this._storedCSS) {
|
993
|
+
if(this._storedCSS[i] == 'auto' || this._storedCSS[i] == 'static') this._storedCSS[i] = '';
|
994
|
+
}
|
995
|
+
this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
|
996
|
+
} else {
|
997
|
+
this.currentItem.show();
|
998
|
+
}
|
999
|
+
|
1000
|
+
if(this.fromOutside && !noPropagation) delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
|
1001
|
+
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
|
1002
|
+
if(!$.ui.contains(this.element[0], this.currentItem[0])) { //Node was moved out of the current element
|
1003
|
+
if(!noPropagation) delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
|
1004
|
+
for (var i = this.containers.length - 1; i >= 0; i--){
|
1005
|
+
if($.ui.contains(this.containers[i].element[0], this.currentItem[0]) && !noPropagation) {
|
1006
|
+
delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
|
1007
|
+
delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
|
1008
|
+
}
|
1009
|
+
};
|
1010
|
+
};
|
1011
|
+
|
1012
|
+
//Post events to containers
|
1013
|
+
for (var i = this.containers.length - 1; i >= 0; i--){
|
1014
|
+
if(!noPropagation) delayedTriggers.push((function(c) { return function(event) { c._trigger("deactivate", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
|
1015
|
+
if(this.containers[i].containerCache.over) {
|
1016
|
+
delayedTriggers.push((function(c) { return function(event) { c._trigger("out", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
|
1017
|
+
this.containers[i].containerCache.over = 0;
|
1018
|
+
}
|
1019
|
+
}
|
1020
|
+
|
1021
|
+
//Do what was originally in plugins
|
1022
|
+
if(this._storedCursor) $('body').css("cursor", this._storedCursor); //Reset cursor
|
1023
|
+
if(this._storedOpacity) this.helper.css("opacity", this._storedOpacity); //Reset opacity
|
1024
|
+
if(this._storedZIndex) this.helper.css("zIndex", this._storedZIndex == 'auto' ? '' : this._storedZIndex); //Reset z-index
|
1025
|
+
|
1026
|
+
this.dragging = false;
|
1027
|
+
if(this.cancelHelperRemoval) {
|
1028
|
+
if(!noPropagation) {
|
1029
|
+
this._trigger("beforeStop", event, this._uiHash());
|
1030
|
+
for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events
|
1031
|
+
this._trigger("stop", event, this._uiHash());
|
1032
|
+
}
|
1033
|
+
return false;
|
1034
|
+
}
|
1035
|
+
|
1036
|
+
if(!noPropagation) this._trigger("beforeStop", event, this._uiHash());
|
1037
|
+
|
1038
|
+
//$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
|
1039
|
+
this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
|
1040
|
+
|
1041
|
+
if(this.helper[0] != this.currentItem[0]) this.helper.remove(); this.helper = null;
|
1042
|
+
|
1043
|
+
if(!noPropagation) {
|
1044
|
+
for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events
|
1045
|
+
this._trigger("stop", event, this._uiHash());
|
1046
|
+
}
|
1047
|
+
|
1048
|
+
this.fromOutside = false;
|
1049
|
+
return true;
|
1050
|
+
|
1051
|
+
},
|
1052
|
+
|
1053
|
+
_trigger: function() {
|
1054
|
+
if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
|
1055
|
+
this.cancel();
|
1056
|
+
}
|
1057
|
+
},
|
1058
|
+
|
1059
|
+
_uiHash: function(inst) {
|
1060
|
+
var self = inst || this;
|
1061
|
+
return {
|
1062
|
+
helper: self.helper,
|
1063
|
+
placeholder: self.placeholder || $([]),
|
1064
|
+
position: self.position,
|
1065
|
+
originalPosition: self.originalPosition,
|
1066
|
+
offset: self.positionAbs,
|
1067
|
+
item: self.currentItem,
|
1068
|
+
sender: inst ? inst.element : null
|
1069
|
+
};
|
1070
|
+
}
|
1071
|
+
|
1072
|
+
});
|
1073
|
+
|
1074
|
+
$.extend($.ui.sortable, {
|
1075
|
+
version: "1.8.13"
|
1076
|
+
});
|
1077
|
+
|
1078
|
+
})(jQuery);
|