kiteditor 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +25 -0
- data/app/controllers/mercury/images_controller.rb +5 -0
- data/app/controllers/mercury_controller.rb +34 -0
- data/app/models/mercury/image.rb +17 -0
- data/app/views/layouts/mercury.html.erb +33 -0
- data/app/views/layouts/popup.html.haml +9 -0
- data/app/views/mercury/images/_list.html.haml +22 -0
- data/app/views/mercury/images/index.html.haml +4 -0
- data/app/views/mercury/images/index.js.erb +2 -0
- data/app/views/mercury/lightviews/about.html +11 -0
- data/app/views/mercury/modals/character.html +255 -0
- data/app/views/mercury/modals/htmleditor.html +13 -0
- data/app/views/mercury/modals/link.html +94 -0
- data/app/views/mercury/modals/media.html +1 -0
- data/app/views/mercury/modals/table.html +84 -0
- data/app/views/mercury/palettes/backcolor.html +73 -0
- data/app/views/mercury/palettes/forecolor.html +73 -0
- data/app/views/mercury/panels/history.html +3 -0
- data/app/views/mercury/panels/notes.html +3 -0
- data/app/views/mercury/panels/snippets.html +12 -0
- data/app/views/mercury/selects/formatblock.html +11 -0
- data/app/views/mercury/selects/style.html +5 -0
- data/app/views/mercury/snippets/example/options.html.erb +34 -0
- data/app/views/mercury/snippets/example/preview.html.erb +1 -0
- data/config/engine.rb +44 -0
- data/db/migrate/20110526035601_create_mercury_images.rb +11 -0
- data/features/loading/loading.feature +22 -0
- data/features/loading/navigating.feature +77 -0
- data/features/loading/user_interface.feature +67 -0
- data/features/regions/editable/advanced_editing.feature +0 -0
- data/features/regions/editable/basic_editing.feature +195 -0
- data/features/regions/editable/inserting_links.feature +98 -0
- data/features/regions/editable/inserting_media.feature +110 -0
- data/features/regions/editable/inserting_snippets.feature +102 -0
- data/features/regions/editable/inserting_special_characters.feature +24 -0
- data/features/regions/editable/inserting_tables.feature +109 -0
- data/features/regions/editable/pasting.feature +0 -0
- data/features/regions/editable/uploading_images.feature +0 -0
- data/features/regions/markupable/advanced_editing.feature +0 -0
- data/features/regions/markupable/basic_editing.feature +0 -0
- data/features/regions/markupable/inserting_links.feature +0 -0
- data/features/regions/markupable/inserting_media.feature +0 -0
- data/features/regions/markupable/inserting_snippets.feature +0 -0
- data/features/regions/markupable/inserting_special_characters.feature +0 -0
- data/features/regions/markupable/inserting_tables.feature +0 -0
- data/features/regions/markupable/uploading_images.feature +0 -0
- data/features/regions/snippetable/advanced_editing.feature +0 -0
- data/features/regions/snippetable/basic_editing.feature +0 -0
- data/features/regions/snippetable/inserting_snippets.feature +0 -0
- data/features/saving/saving.feature +33 -0
- data/features/step_definitions/debug_steps.rb +14 -0
- data/features/step_definitions/mercury_steps.rb +438 -0
- data/features/step_definitions/web_steps.rb +211 -0
- data/features/support/env.rb +46 -0
- data/features/support/mercury_contents.rb +25 -0
- data/features/support/mercury_selectors.rb +148 -0
- data/features/support/paths.rb +38 -0
- data/features/support/selectors.rb +44 -0
- data/lib/generators/mercury/install/install_generator.rb +49 -0
- data/lib/generators/mercury/install/templates/mongoid_paperclip_image.rb +17 -0
- data/lib/mercury/authentication.rb +8 -0
- data/lib/mercury-rails.rb +3 -0
- data/spec/javascripts/mercury/dialog_spec.js.coffee +281 -0
- data/spec/javascripts/mercury/dialogs/backcolor_spec.js.coffee +37 -0
- data/spec/javascripts/mercury/dialogs/forecolor_spec.js.coffee +37 -0
- data/spec/javascripts/mercury/dialogs/formatblock_spec.js.coffee +25 -0
- data/spec/javascripts/mercury/dialogs/snippetpanel_spec.js.coffee +30 -0
- data/spec/javascripts/mercury/dialogs/style_spec.js.coffee +25 -0
- data/spec/javascripts/mercury/history_buffer_spec.js.coffee +76 -0
- data/spec/javascripts/mercury/lightview_spec.js.coffee +497 -0
- data/spec/javascripts/mercury/mercury_spec.js.coffee +132 -0
- data/spec/javascripts/mercury/modal_spec.js.coffee +504 -0
- data/spec/javascripts/mercury/modals/htmleditor_spec.js.coffee +30 -0
- data/spec/javascripts/mercury/modals/insertcharacter_spec.js.coffee +29 -0
- data/spec/javascripts/mercury/modals/insertlink_spec.js.coffee +220 -0
- data/spec/javascripts/mercury/modals/insertmedia_spec.js.coffee +167 -0
- data/spec/javascripts/mercury/modals/insertsnippet_spec.js.coffee +52 -0
- data/spec/javascripts/mercury/modals/inserttable_spec.js.coffee +160 -0
- data/spec/javascripts/mercury/native_extensions_spec.js.coffee +60 -0
- data/spec/javascripts/mercury/page_editor_spec.js.coffee +750 -0
- data/spec/javascripts/mercury/palette_spec.js.coffee +49 -0
- data/spec/javascripts/mercury/panel_spec.js.coffee +185 -0
- data/spec/javascripts/mercury/region_spec.js.coffee +298 -0
- data/spec/javascripts/mercury/regions/editable_spec.js.coffee +561 -0
- data/spec/javascripts/mercury/regions/markupable_spec.js.coffee +367 -0
- data/spec/javascripts/mercury/regions/snippetable_spec.js.coffee +370 -0
- data/spec/javascripts/mercury/select_spec.js.coffee +49 -0
- data/spec/javascripts/mercury/snippet_spec.js.coffee +245 -0
- data/spec/javascripts/mercury/snippet_toolbar_spec.js.coffee +184 -0
- data/spec/javascripts/mercury/statusbar_spec.js.coffee +150 -0
- data/spec/javascripts/mercury/table_editor_spec.js.coffee +194 -0
- data/spec/javascripts/mercury/toolbar.button_group_spec.js.coffee +90 -0
- data/spec/javascripts/mercury/toolbar.button_spec.js.coffee +360 -0
- data/spec/javascripts/mercury/toolbar.expander_spec.js.coffee +118 -0
- data/spec/javascripts/mercury/toolbar_spec.js.coffee +222 -0
- data/spec/javascripts/mercury/tooltip_spec.js.coffee +186 -0
- data/spec/javascripts/mercury/uploader_spec.js.coffee +514 -0
- data/spec/javascripts/spec_helper.js +513 -0
- data/spec/javascripts/templates/mercury/dialog.html +2 -0
- data/spec/javascripts/templates/mercury/dialogs/backcolor.html +5 -0
- data/spec/javascripts/templates/mercury/dialogs/forecolor.html +5 -0
- data/spec/javascripts/templates/mercury/dialogs/formatblock.html +3 -0
- data/spec/javascripts/templates/mercury/dialogs/snippetpanel.html +16 -0
- data/spec/javascripts/templates/mercury/dialogs/style.html +3 -0
- data/spec/javascripts/templates/mercury/lightview.html +13 -0
- data/spec/javascripts/templates/mercury/modal.html +13 -0
- data/spec/javascripts/templates/mercury/modals/htmleditor.html +5 -0
- data/spec/javascripts/templates/mercury/modals/insertcharacter.html +5 -0
- data/spec/javascripts/templates/mercury/modals/insertlink.html +30 -0
- data/spec/javascripts/templates/mercury/modals/insertmedia.html +35 -0
- data/spec/javascripts/templates/mercury/modals/insertsnippet.html +6 -0
- data/spec/javascripts/templates/mercury/modals/inserttable.html +27 -0
- data/spec/javascripts/templates/mercury/page_editor.html +35 -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/editable.html +3 -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 +8 -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 +11 -0
- data/spec/javascripts/templates/mercury/tooltip.html +12 -0
- data/spec/javascripts/templates/mercury/uploader.html +11 -0
- data/vendor/assets/images/mercury/button.png +0 -0
- data/vendor/assets/images/mercury/close.png +0 -0
- data/vendor/assets/images/mercury/default-snippet.png +0 -0
- data/vendor/assets/images/mercury/loading-dark.gif +0 -0
- data/vendor/assets/images/mercury/loading-light.gif +0 -0
- data/vendor/assets/images/mercury/missing-image.png +0 -0
- data/vendor/assets/images/mercury/search-icon.png +0 -0
- data/vendor/assets/images/mercury/temp-logo.png +0 -0
- data/vendor/assets/images/mercury/toolbar/editable/buttons.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/_expander.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/_pressed.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/historypanel.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/insertcharacter.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/insertlink.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/insertmedia.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/inserttable.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/inspectorpanel.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/notespanel.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/preview.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/redo.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/save.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/snippetpanel.png +0 -0
- data/vendor/assets/images/mercury/toolbar/primary/undo.png +0 -0
- data/vendor/assets/images/mercury/toolbar/snippetable/buttons.png +0 -0
- data/vendor/assets/javascripts/mercury/dependencies/jquery-1.7.js +9300 -0
- data/vendor/assets/javascripts/mercury/dependencies/jquery-ui-1.8.13.custom.js +1328 -0
- data/vendor/assets/javascripts/mercury/dependencies/jquery-ui-1.8.18.custom.min.js +356 -0
- data/vendor/assets/javascripts/mercury/dependencies/jquery-ui.1.8.13.custom.min.js +356 -0
- data/vendor/assets/javascripts/mercury/dependencies/jquery.additions.js +206 -0
- data/vendor/assets/javascripts/mercury/dependencies/jquery.htmlClean.js +527 -0
- data/vendor/assets/javascripts/mercury/dependencies/liquidmetal.js +88 -0
- data/vendor/assets/javascripts/mercury/dependencies/showdown.js +1340 -0
- data/vendor/assets/javascripts/mercury/dialog.js.coffee +159 -0
- data/vendor/assets/javascripts/mercury/dialogs/backcolor.js.coffee +6 -0
- data/vendor/assets/javascripts/mercury/dialogs/forecolor.js.coffee +6 -0
- data/vendor/assets/javascripts/mercury/dialogs/formatblock.js.coffee +4 -0
- data/vendor/assets/javascripts/mercury/dialogs/snippetpanel.js.coffee +10 -0
- data/vendor/assets/javascripts/mercury/dialogs/style.js.coffee +4 -0
- data/vendor/assets/javascripts/mercury/finalize.js.coffee +3 -0
- data/vendor/assets/javascripts/mercury/history_buffer.js.coffee +30 -0
- data/vendor/assets/javascripts/mercury/lightview.js.coffee +205 -0
- data/vendor/assets/javascripts/mercury/locales/da.locale.js.coffee +0 -0
- data/vendor/assets/javascripts/mercury/locales/de.locale.js.coffee +206 -0
- data/vendor/assets/javascripts/mercury/locales/es.locale.js.coffee +211 -0
- data/vendor/assets/javascripts/mercury/locales/example.local.js.coffee +211 -0
- data/vendor/assets/javascripts/mercury/locales/fr.locale.js.coffee +211 -0
- data/vendor/assets/javascripts/mercury/locales/it.locale.js.coffee +208 -0
- data/vendor/assets/javascripts/mercury/locales/ko.local.js.coffee +206 -0
- data/vendor/assets/javascripts/mercury/locales/nl.locale.js.coffee +206 -0
- data/vendor/assets/javascripts/mercury/locales/pt.locale.js.coffee +211 -0
- data/vendor/assets/javascripts/mercury/locales/sv.local.js.coffee +209 -0
- data/vendor/assets/javascripts/mercury/locales/swedish_chef.locale.js.coffee +213 -0
- data/vendor/assets/javascripts/mercury/mercury.js.coffee +109 -0
- data/vendor/assets/javascripts/mercury/modal.js.coffee +204 -0
- data/vendor/assets/javascripts/mercury/modals/htmleditor.js.coffee +11 -0
- data/vendor/assets/javascripts/mercury/modals/insertcharacter.js.coffee +4 -0
- data/vendor/assets/javascripts/mercury/modals/insertlink.js.coffee +95 -0
- data/vendor/assets/javascripts/mercury/modals/insertmedia.js.coffee +107 -0
- data/vendor/assets/javascripts/mercury/modals/insertsnippet.js.coffee +12 -0
- data/vendor/assets/javascripts/mercury/modals/inserttable.js.coffee +54 -0
- data/vendor/assets/javascripts/mercury/native_extensions.js.coffee +55 -0
- data/vendor/assets/javascripts/mercury/page_editor.js.coffee +241 -0
- data/vendor/assets/javascripts/mercury/palette.js.coffee +29 -0
- data/vendor/assets/javascripts/mercury/panel.js.coffee +115 -0
- data/vendor/assets/javascripts/mercury/plugins/save_as_xml/mercury/page_editor.js.coffee +28 -0
- data/vendor/assets/javascripts/mercury/plugins/save_as_xml/plugin.js +9 -0
- data/vendor/assets/javascripts/mercury/region.js.coffee +107 -0
- data/vendor/assets/javascripts/mercury/regions/editable.js.coffee +600 -0
- data/vendor/assets/javascripts/mercury/regions/markupable.js.coffee +398 -0
- data/vendor/assets/javascripts/mercury/regions/simple.js.coffee +339 -0
- data/vendor/assets/javascripts/mercury/regions/snippetable.js.coffee +124 -0
- data/vendor/assets/javascripts/mercury/select.js.coffee +44 -0
- data/vendor/assets/javascripts/mercury/snippet.js.coffee +104 -0
- data/vendor/assets/javascripts/mercury/snippet_toolbar.js.coffee +72 -0
- data/vendor/assets/javascripts/mercury/statusbar.js.coffee +51 -0
- data/vendor/assets/javascripts/mercury/support/history.js +1 -0
- data/vendor/assets/javascripts/mercury/table_editor.js.coffee +265 -0
- data/vendor/assets/javascripts/mercury/toolbar.button.js.coffee +173 -0
- data/vendor/assets/javascripts/mercury/toolbar.button_group.js.coffee +42 -0
- data/vendor/assets/javascripts/mercury/toolbar.expander.js.coffee +56 -0
- data/vendor/assets/javascripts/mercury/toolbar.js.coffee +86 -0
- data/vendor/assets/javascripts/mercury/tooltip.js.coffee +74 -0
- data/vendor/assets/javascripts/mercury/uploader.js.coffee +227 -0
- data/vendor/assets/javascripts/mercury.js +479 -0
- data/vendor/assets/javascripts/mercury_loader.js +193 -0
- data/vendor/assets/javascripts/mercury_overrides.js +6 -0
- data/vendor/assets/javascripts/popup.js +8 -0
- data/vendor/assets/stylesheets/mercury/all_images.css.erb +89 -0
- data/vendor/assets/stylesheets/mercury/dialog.css +208 -0
- data/vendor/assets/stylesheets/mercury/lightview.css +151 -0
- data/vendor/assets/stylesheets/mercury/mercury.css +151 -0
- data/vendor/assets/stylesheets/mercury/modal.css +183 -0
- data/vendor/assets/stylesheets/mercury/statusbar.css +32 -0
- data/vendor/assets/stylesheets/mercury/toolbar.css +304 -0
- data/vendor/assets/stylesheets/mercury/tooltip.css +26 -0
- data/vendor/assets/stylesheets/mercury/uploader.css +111 -0
- data/vendor/assets/stylesheets/mercury.css +28 -0
- data/vendor/assets/stylesheets/mercury_overrides.css +17 -0
- data/vendor/assets/stylesheets/popup.css.erb +37 -0
- metadata +634 -0
@@ -0,0 +1,1328 @@
|
|
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
|
+
;
|
250
|
+
|
251
|
+
/*
|
252
|
+
* jQuery UI Sortable 1.8.13
|
253
|
+
*
|
254
|
+
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
255
|
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
256
|
+
* http://jquery.org/license
|
257
|
+
*
|
258
|
+
* http://docs.jquery.com/UI/Sortables
|
259
|
+
*
|
260
|
+
* Depends:
|
261
|
+
* jquery.ui.core.js
|
262
|
+
* jquery.ui.mouse.js
|
263
|
+
* jquery.ui.widget.js
|
264
|
+
*/
|
265
|
+
(function( $, undefined ) {
|
266
|
+
|
267
|
+
$.widget("ui.sortable", $.ui.mouse, {
|
268
|
+
widgetEventPrefix: "sort",
|
269
|
+
options: {
|
270
|
+
appendTo: "parent",
|
271
|
+
axis: false,
|
272
|
+
connectWith: false,
|
273
|
+
containment: false,
|
274
|
+
cursor: 'auto',
|
275
|
+
cursorAt: false,
|
276
|
+
dropOnEmpty: true,
|
277
|
+
forcePlaceholderSize: false,
|
278
|
+
forceHelperSize: false,
|
279
|
+
grid: false,
|
280
|
+
handle: false,
|
281
|
+
helper: "original",
|
282
|
+
items: '> *',
|
283
|
+
opacity: false,
|
284
|
+
placeholder: false,
|
285
|
+
revert: false,
|
286
|
+
scroll: true,
|
287
|
+
scrollSensitivity: 20,
|
288
|
+
scrollSpeed: 20,
|
289
|
+
scope: "default",
|
290
|
+
tolerance: "intersect",
|
291
|
+
zIndex: 1000
|
292
|
+
},
|
293
|
+
_create: function() {
|
294
|
+
|
295
|
+
var o = this.options;
|
296
|
+
this.document = o.document;
|
297
|
+
|
298
|
+
this.containerCache = {};
|
299
|
+
this.element.addClass("ui-sortable");
|
300
|
+
|
301
|
+
//Get the items
|
302
|
+
this.refresh();
|
303
|
+
|
304
|
+
//Let's determine if the items are being displayed horizontally
|
305
|
+
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;
|
306
|
+
|
307
|
+
//Let's determine the parent's offset
|
308
|
+
this.offset = this.element.offset();
|
309
|
+
|
310
|
+
//Initialize mouse events for interaction
|
311
|
+
this._mouseInit();
|
312
|
+
|
313
|
+
},
|
314
|
+
|
315
|
+
destroy: function() {
|
316
|
+
this.element
|
317
|
+
.removeClass("ui-sortable ui-sortable-disabled")
|
318
|
+
.removeData("sortable")
|
319
|
+
.unbind(".sortable");
|
320
|
+
this._mouseDestroy();
|
321
|
+
|
322
|
+
for ( var i = this.items.length - 1; i >= 0; i-- )
|
323
|
+
this.items[i].item.removeData("sortable-item");
|
324
|
+
|
325
|
+
return this;
|
326
|
+
},
|
327
|
+
|
328
|
+
_setOption: function(key, value){
|
329
|
+
if ( key === "disabled" ) {
|
330
|
+
this.options[ key ] = value;
|
331
|
+
|
332
|
+
this.widget()
|
333
|
+
[ value ? "addClass" : "removeClass"]( "ui-sortable-disabled" );
|
334
|
+
} else {
|
335
|
+
// Don't call widget base _setOption for disable as it adds ui-state-disabled class
|
336
|
+
$.Widget.prototype._setOption.apply(this, arguments);
|
337
|
+
}
|
338
|
+
},
|
339
|
+
|
340
|
+
_mouseCapture: function(event, overrideHandle) {
|
341
|
+
|
342
|
+
if (this.reverting) {
|
343
|
+
return false;
|
344
|
+
}
|
345
|
+
|
346
|
+
if(this.options.disabled || this.options.type == 'static') return false;
|
347
|
+
|
348
|
+
//We have to refresh the items data once first
|
349
|
+
this._refreshItems(event);
|
350
|
+
|
351
|
+
//Find out if the clicked node (or one of its parents) is a actual item in this.items
|
352
|
+
var currentItem = null, self = this, nodes = $(event.target).parents().each(function() {
|
353
|
+
if($.data(this, 'sortable-item') == self) {
|
354
|
+
currentItem = $(this);
|
355
|
+
return false;
|
356
|
+
}
|
357
|
+
});
|
358
|
+
if($.data(event.target, 'sortable-item') == self) currentItem = $(event.target);
|
359
|
+
|
360
|
+
if(!currentItem) return false;
|
361
|
+
if(this.options.handle && !overrideHandle) {
|
362
|
+
var validHandle = false;
|
363
|
+
|
364
|
+
$(this.options.handle, currentItem).find("*").andSelf().each(function() { if(this == event.target) validHandle = true; });
|
365
|
+
if(!validHandle) return false;
|
366
|
+
}
|
367
|
+
|
368
|
+
this.currentItem = currentItem;
|
369
|
+
this._removeCurrentsFromItems();
|
370
|
+
return true;
|
371
|
+
|
372
|
+
},
|
373
|
+
|
374
|
+
_mouseStart: function(event, overrideHandle, noActivation) {
|
375
|
+
var o = this.options, self = this;
|
376
|
+
this.currentContainer = this;
|
377
|
+
|
378
|
+
//We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
|
379
|
+
this.refreshPositions();
|
380
|
+
|
381
|
+
//Create and append the visible helper
|
382
|
+
this.helper = this._createHelper(event);
|
383
|
+
|
384
|
+
//Cache the helper size
|
385
|
+
this._cacheHelperProportions();
|
386
|
+
|
387
|
+
/*
|
388
|
+
* - Position generation -
|
389
|
+
* This block generates everything position related - it's the core of draggables.
|
390
|
+
*/
|
391
|
+
|
392
|
+
//Cache the margins of the original element
|
393
|
+
this._cacheMargins();
|
394
|
+
|
395
|
+
//Get the next scrolling parent
|
396
|
+
this.scrollParent = this.helper.scrollParent();
|
397
|
+
|
398
|
+
//The element's absolute position on the page minus margins
|
399
|
+
this.offset = this.currentItem.offset();
|
400
|
+
this.offset = {
|
401
|
+
top: this.offset.top - this.margins.top,
|
402
|
+
left: this.offset.left - this.margins.left
|
403
|
+
};
|
404
|
+
|
405
|
+
// Only after we got the offset, we can change the helper's position to absolute
|
406
|
+
// TODO: Still need to figure out a way to make relative sorting possible
|
407
|
+
this.helper.css("position", "absolute");
|
408
|
+
this.cssPosition = this.helper.css("position");
|
409
|
+
|
410
|
+
$.extend(this.offset, {
|
411
|
+
click: { //Where the click happened, relative to the element
|
412
|
+
left: event.pageX - this.offset.left,
|
413
|
+
top: event.pageY - this.offset.top
|
414
|
+
},
|
415
|
+
parent: this._getParentOffset(),
|
416
|
+
relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
|
417
|
+
});
|
418
|
+
|
419
|
+
//Generate the original position
|
420
|
+
this.originalPosition = this._generatePosition(event);
|
421
|
+
this.originalPageX = event.pageX;
|
422
|
+
this.originalPageY = event.pageY;
|
423
|
+
|
424
|
+
//Adjust the mouse offset relative to the helper if 'cursorAt' is supplied
|
425
|
+
(o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
|
426
|
+
|
427
|
+
//Cache the former DOM position
|
428
|
+
this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
|
429
|
+
|
430
|
+
//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
|
431
|
+
if(this.helper[0] != this.currentItem[0]) {
|
432
|
+
this.currentItem.hide();
|
433
|
+
}
|
434
|
+
|
435
|
+
//Create the placeholder
|
436
|
+
this._createPlaceholder();
|
437
|
+
|
438
|
+
//Set a containment if given in the options
|
439
|
+
if(o.containment)
|
440
|
+
this._setContainment();
|
441
|
+
|
442
|
+
if(o.cursor) { // cursor option
|
443
|
+
if ($('body').css("cursor")) this._storedCursor = $('body').css("cursor");
|
444
|
+
$('body').css("cursor", o.cursor);
|
445
|
+
}
|
446
|
+
|
447
|
+
if(o.opacity) { // opacity option
|
448
|
+
if (this.helper.css("opacity")) this._storedOpacity = this.helper.css("opacity");
|
449
|
+
this.helper.css("opacity", o.opacity);
|
450
|
+
}
|
451
|
+
|
452
|
+
if(o.zIndex) { // zIndex option
|
453
|
+
if (this.helper.css("zIndex")) this._storedZIndex = this.helper.css("zIndex");
|
454
|
+
this.helper.css("zIndex", o.zIndex);
|
455
|
+
}
|
456
|
+
|
457
|
+
//Prepare scrolling
|
458
|
+
if(this.scrollParent[0] != (this.document || document) && this.scrollParent[0].tagName != 'HTML')
|
459
|
+
this.overflowOffset = this.scrollParent.offset();
|
460
|
+
|
461
|
+
//Call callbacks
|
462
|
+
this._trigger("start", event, this._uiHash());
|
463
|
+
|
464
|
+
//Recache the helper size
|
465
|
+
if(!this._preserveHelperProportions)
|
466
|
+
this._cacheHelperProportions();
|
467
|
+
|
468
|
+
|
469
|
+
//Post 'activate' events to possible containers
|
470
|
+
if(!noActivation) {
|
471
|
+
for (var i = this.containers.length - 1; i >= 0; i--) { this.containers[i]._trigger("activate", event, self._uiHash(this)); }
|
472
|
+
}
|
473
|
+
|
474
|
+
//Prepare possible droppables
|
475
|
+
if($.ui.ddmanager)
|
476
|
+
$.ui.ddmanager.current = this;
|
477
|
+
|
478
|
+
if ($.ui.ddmanager && !o.dropBehaviour)
|
479
|
+
$.ui.ddmanager.prepareOffsets(this, event);
|
480
|
+
|
481
|
+
this.dragging = true;
|
482
|
+
|
483
|
+
this.helper.addClass("ui-sortable-helper");
|
484
|
+
this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
|
485
|
+
return true;
|
486
|
+
|
487
|
+
},
|
488
|
+
|
489
|
+
_mouseDrag: function(event) {
|
490
|
+
|
491
|
+
//Compute the helpers position
|
492
|
+
this.position = this._generatePosition(event);
|
493
|
+
this.positionAbs = this._convertPositionTo("absolute");
|
494
|
+
|
495
|
+
if (!this.lastPositionAbs) {
|
496
|
+
this.lastPositionAbs = this.positionAbs;
|
497
|
+
}
|
498
|
+
|
499
|
+
//Do scrolling
|
500
|
+
if(this.options.scroll) {
|
501
|
+
var o = this.options, scrolled = false;
|
502
|
+
if(this.scrollParent[0] != (this.document || document) && this.scrollParent[0].tagName != 'HTML') {
|
503
|
+
|
504
|
+
if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
|
505
|
+
this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
|
506
|
+
else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity)
|
507
|
+
this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
|
508
|
+
|
509
|
+
if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
|
510
|
+
this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
|
511
|
+
else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity)
|
512
|
+
this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
|
513
|
+
|
514
|
+
} else {
|
515
|
+
|
516
|
+
if(event.pageY - $((this.document || document)).scrollTop() < o.scrollSensitivity)
|
517
|
+
scrolled = $((this.document || document)).scrollTop($((this.document || document)).scrollTop() - o.scrollSpeed);
|
518
|
+
else if($(window).height() - (event.pageY - $((this.document || document)).scrollTop()) < o.scrollSensitivity)
|
519
|
+
scrolled = $((this.document || document)).scrollTop($((this.document || document)).scrollTop() + o.scrollSpeed);
|
520
|
+
|
521
|
+
if(event.pageX - $((this.document || document)).scrollLeft() < o.scrollSensitivity)
|
522
|
+
scrolled = $((this.document || document)).scrollLeft($((this.document || document)).scrollLeft() - o.scrollSpeed);
|
523
|
+
else if($(window).width() - (event.pageX - $((this.document || document)).scrollLeft()) < o.scrollSensitivity)
|
524
|
+
scrolled = $((this.document || document)).scrollLeft($((this.document || document)).scrollLeft() + o.scrollSpeed);
|
525
|
+
|
526
|
+
}
|
527
|
+
|
528
|
+
if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
|
529
|
+
$.ui.ddmanager.prepareOffsets(this, event);
|
530
|
+
}
|
531
|
+
|
532
|
+
//Regenerate the absolute position used for position checks
|
533
|
+
this.positionAbs = this._convertPositionTo("absolute");
|
534
|
+
|
535
|
+
//Set the helper position
|
536
|
+
if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
|
537
|
+
if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
|
538
|
+
|
539
|
+
//Rearrange
|
540
|
+
for (var i = this.items.length - 1; i >= 0; i--) {
|
541
|
+
|
542
|
+
//Cache variables and intersection, continue if no intersection
|
543
|
+
var item = this.items[i], itemElement = item.item[0], intersection = this._intersectsWithPointer(item);
|
544
|
+
if (!intersection) continue;
|
545
|
+
|
546
|
+
if(itemElement != this.currentItem[0] //cannot intersect with itself
|
547
|
+
&& this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != itemElement //no useless actions that have been done before
|
548
|
+
&& !$.ui.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked
|
549
|
+
&& (this.options.type == 'semi-dynamic' ? !$.ui.contains(this.element[0], itemElement) : true)
|
550
|
+
//&& itemElement.parentNode == this.placeholder[0].parentNode // only rearrange items within the same container
|
551
|
+
) {
|
552
|
+
|
553
|
+
this.direction = intersection == 1 ? "down" : "up";
|
554
|
+
|
555
|
+
if (this.options.tolerance == "pointer" || this._intersectsWithSides(item)) {
|
556
|
+
this._rearrange(event, item);
|
557
|
+
} else {
|
558
|
+
break;
|
559
|
+
}
|
560
|
+
|
561
|
+
this._trigger("change", event, this._uiHash());
|
562
|
+
break;
|
563
|
+
}
|
564
|
+
}
|
565
|
+
|
566
|
+
//Post events to containers
|
567
|
+
this._contactContainers(event);
|
568
|
+
|
569
|
+
//Interconnect with droppables
|
570
|
+
if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
|
571
|
+
|
572
|
+
//Call callbacks
|
573
|
+
this._trigger('sort', event, this._uiHash());
|
574
|
+
|
575
|
+
this.lastPositionAbs = this.positionAbs;
|
576
|
+
return false;
|
577
|
+
|
578
|
+
},
|
579
|
+
|
580
|
+
_mouseStop: function(event, noPropagation) {
|
581
|
+
|
582
|
+
if(!event) return;
|
583
|
+
|
584
|
+
//If we are using droppables, inform the manager about the drop
|
585
|
+
if ($.ui.ddmanager && !this.options.dropBehaviour)
|
586
|
+
$.ui.ddmanager.drop(this, event);
|
587
|
+
|
588
|
+
if(this.options.revert) {
|
589
|
+
var self = this;
|
590
|
+
var cur = self.placeholder.offset();
|
591
|
+
|
592
|
+
self.reverting = true;
|
593
|
+
|
594
|
+
$(this.helper).animate({
|
595
|
+
left: cur.left - this.offset.parent.left - self.margins.left + (this.offsetParent[0] == (this.document || document).body ? 0 : this.offsetParent[0].scrollLeft),
|
596
|
+
top: cur.top - this.offset.parent.top - self.margins.top + (this.offsetParent[0] == (this.document || document).body ? 0 : this.offsetParent[0].scrollTop)
|
597
|
+
}, parseInt(this.options.revert, 10) || 500, function() {
|
598
|
+
self._clear(event);
|
599
|
+
});
|
600
|
+
} else {
|
601
|
+
this._clear(event, noPropagation);
|
602
|
+
}
|
603
|
+
|
604
|
+
return false;
|
605
|
+
|
606
|
+
},
|
607
|
+
|
608
|
+
cancel: function() {
|
609
|
+
|
610
|
+
var self = this;
|
611
|
+
|
612
|
+
if(this.dragging) {
|
613
|
+
|
614
|
+
this._mouseUp({ target: null });
|
615
|
+
|
616
|
+
if(this.options.helper == "original")
|
617
|
+
this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
|
618
|
+
else
|
619
|
+
this.currentItem.show();
|
620
|
+
|
621
|
+
//Post deactivating events to containers
|
622
|
+
for (var i = this.containers.length - 1; i >= 0; i--){
|
623
|
+
this.containers[i]._trigger("deactivate", null, self._uiHash(this));
|
624
|
+
if(this.containers[i].containerCache.over) {
|
625
|
+
this.containers[i]._trigger("out", null, self._uiHash(this));
|
626
|
+
this.containers[i].containerCache.over = 0;
|
627
|
+
}
|
628
|
+
}
|
629
|
+
|
630
|
+
}
|
631
|
+
|
632
|
+
if (this.placeholder) {
|
633
|
+
//$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
|
634
|
+
if(this.placeholder[0].parentNode) this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
|
635
|
+
if(this.options.helper != "original" && this.helper && this.helper[0].parentNode) this.helper.remove();
|
636
|
+
|
637
|
+
$.extend(this, {
|
638
|
+
helper: null,
|
639
|
+
dragging: false,
|
640
|
+
reverting: false,
|
641
|
+
_noFinalSort: null
|
642
|
+
});
|
643
|
+
|
644
|
+
if(this.domPosition.prev) {
|
645
|
+
$(this.domPosition.prev).after(this.currentItem);
|
646
|
+
} else {
|
647
|
+
$(this.domPosition.parent).prepend(this.currentItem);
|
648
|
+
}
|
649
|
+
}
|
650
|
+
|
651
|
+
return this;
|
652
|
+
|
653
|
+
},
|
654
|
+
|
655
|
+
serialize: function(o) {
|
656
|
+
|
657
|
+
var items = this._getItemsAsjQuery(o && o.connected);
|
658
|
+
var str = []; o = o || {};
|
659
|
+
|
660
|
+
$(items).each(function() {
|
661
|
+
var res = ($(o.item || this).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));
|
662
|
+
if(res) str.push((o.key || res[1]+'[]')+'='+(o.key && o.expression ? res[1] : res[2]));
|
663
|
+
});
|
664
|
+
|
665
|
+
if(!str.length && o.key) {
|
666
|
+
str.push(o.key + '=');
|
667
|
+
}
|
668
|
+
|
669
|
+
return str.join('&');
|
670
|
+
|
671
|
+
},
|
672
|
+
|
673
|
+
toArray: function(o) {
|
674
|
+
|
675
|
+
var items = this._getItemsAsjQuery(o && o.connected);
|
676
|
+
var ret = []; o = o || {};
|
677
|
+
|
678
|
+
items.each(function() { ret.push($(o.item || this).attr(o.attribute || 'id') || ''); });
|
679
|
+
return ret;
|
680
|
+
|
681
|
+
},
|
682
|
+
|
683
|
+
/* Be careful with the following core functions */
|
684
|
+
_intersectsWith: function(item) {
|
685
|
+
|
686
|
+
var x1 = this.positionAbs.left,
|
687
|
+
x2 = x1 + this.helperProportions.width,
|
688
|
+
y1 = this.positionAbs.top,
|
689
|
+
y2 = y1 + this.helperProportions.height;
|
690
|
+
|
691
|
+
var l = item.left,
|
692
|
+
r = l + item.width,
|
693
|
+
t = item.top,
|
694
|
+
b = t + item.height;
|
695
|
+
|
696
|
+
var dyClick = this.offset.click.top,
|
697
|
+
dxClick = this.offset.click.left;
|
698
|
+
|
699
|
+
var isOverElement = (y1 + dyClick) > t && (y1 + dyClick) < b && (x1 + dxClick) > l && (x1 + dxClick) < r;
|
700
|
+
|
701
|
+
if( this.options.tolerance == "pointer"
|
702
|
+
|| this.options.forcePointerForContainers
|
703
|
+
|| (this.options.tolerance != "pointer" && this.helperProportions[this.floating ? 'width' : 'height'] > item[this.floating ? 'width' : 'height'])
|
704
|
+
) {
|
705
|
+
return isOverElement;
|
706
|
+
} else {
|
707
|
+
|
708
|
+
return (l < x1 + (this.helperProportions.width / 2) // Right Half
|
709
|
+
&& x2 - (this.helperProportions.width / 2) < r // Left Half
|
710
|
+
&& t < y1 + (this.helperProportions.height / 2) // Bottom Half
|
711
|
+
&& y2 - (this.helperProportions.height / 2) < b ); // Top Half
|
712
|
+
|
713
|
+
}
|
714
|
+
},
|
715
|
+
|
716
|
+
_intersectsWithPointer: function(item) {
|
717
|
+
|
718
|
+
var isOverElementHeight = $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
|
719
|
+
isOverElementWidth = $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
|
720
|
+
isOverElement = isOverElementHeight && isOverElementWidth,
|
721
|
+
verticalDirection = this._getDragVerticalDirection(),
|
722
|
+
horizontalDirection = this._getDragHorizontalDirection();
|
723
|
+
|
724
|
+
if (!isOverElement)
|
725
|
+
return false;
|
726
|
+
|
727
|
+
return this.floating ?
|
728
|
+
( ((horizontalDirection && horizontalDirection == "right") || verticalDirection == "down") ? 2 : 1 )
|
729
|
+
: ( verticalDirection && (verticalDirection == "down" ? 2 : 1) );
|
730
|
+
|
731
|
+
},
|
732
|
+
|
733
|
+
_intersectsWithSides: function(item) {
|
734
|
+
|
735
|
+
var isOverBottomHalf = $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
|
736
|
+
isOverRightHalf = $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
|
737
|
+
verticalDirection = this._getDragVerticalDirection(),
|
738
|
+
horizontalDirection = this._getDragHorizontalDirection();
|
739
|
+
|
740
|
+
if (this.floating && horizontalDirection) {
|
741
|
+
return ((horizontalDirection == "right" && isOverRightHalf) || (horizontalDirection == "left" && !isOverRightHalf));
|
742
|
+
} else {
|
743
|
+
return verticalDirection && ((verticalDirection == "down" && isOverBottomHalf) || (verticalDirection == "up" && !isOverBottomHalf));
|
744
|
+
}
|
745
|
+
|
746
|
+
},
|
747
|
+
|
748
|
+
_getDragVerticalDirection: function() {
|
749
|
+
var delta = this.positionAbs.top - this.lastPositionAbs.top;
|
750
|
+
return delta != 0 && (delta > 0 ? "down" : "up");
|
751
|
+
},
|
752
|
+
|
753
|
+
_getDragHorizontalDirection: function() {
|
754
|
+
var delta = this.positionAbs.left - this.lastPositionAbs.left;
|
755
|
+
return delta != 0 && (delta > 0 ? "right" : "left");
|
756
|
+
},
|
757
|
+
|
758
|
+
refresh: function(event) {
|
759
|
+
this._refreshItems(event);
|
760
|
+
this.refreshPositions();
|
761
|
+
return this;
|
762
|
+
},
|
763
|
+
|
764
|
+
_connectWith: function() {
|
765
|
+
var options = this.options;
|
766
|
+
return options.connectWith.constructor == String
|
767
|
+
? [options.connectWith]
|
768
|
+
: options.connectWith;
|
769
|
+
},
|
770
|
+
|
771
|
+
_getItemsAsjQuery: function(connected) {
|
772
|
+
|
773
|
+
var self = this;
|
774
|
+
var items = [];
|
775
|
+
var queries = [];
|
776
|
+
var connectWith = this._connectWith();
|
777
|
+
|
778
|
+
if(connectWith && connected) {
|
779
|
+
for (var i = connectWith.length - 1; i >= 0; i--){
|
780
|
+
var cur = $(connectWith[i]);
|
781
|
+
for (var j = cur.length - 1; j >= 0; j--){
|
782
|
+
var inst = $.data(cur[j], 'sortable');
|
783
|
+
if(inst && inst != this && !inst.options.disabled) {
|
784
|
+
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]);
|
785
|
+
}
|
786
|
+
};
|
787
|
+
};
|
788
|
+
}
|
789
|
+
|
790
|
+
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]);
|
791
|
+
|
792
|
+
for (var i = queries.length - 1; i >= 0; i--){
|
793
|
+
queries[i][0].each(function() {
|
794
|
+
items.push(this);
|
795
|
+
});
|
796
|
+
};
|
797
|
+
|
798
|
+
return $(items);
|
799
|
+
|
800
|
+
},
|
801
|
+
|
802
|
+
_removeCurrentsFromItems: function() {
|
803
|
+
|
804
|
+
var list = this.currentItem.find(":data(sortable-item)");
|
805
|
+
|
806
|
+
for (var i=0; i < this.items.length; i++) {
|
807
|
+
|
808
|
+
for (var j=0; j < list.length; j++) {
|
809
|
+
if(list[j] == this.items[i].item[0])
|
810
|
+
this.items.splice(i,1);
|
811
|
+
};
|
812
|
+
|
813
|
+
};
|
814
|
+
|
815
|
+
},
|
816
|
+
|
817
|
+
_refreshItems: function(event) {
|
818
|
+
|
819
|
+
this.items = [];
|
820
|
+
this.containers = [this];
|
821
|
+
var items = this.items;
|
822
|
+
var self = this;
|
823
|
+
var queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]];
|
824
|
+
var connectWith = this._connectWith();
|
825
|
+
|
826
|
+
if(connectWith) {
|
827
|
+
for (var i = connectWith.length - 1; i >= 0; i--){
|
828
|
+
var cur = $(connectWith[i]);
|
829
|
+
for (var j = cur.length - 1; j >= 0; j--){
|
830
|
+
var inst = $.data(cur[j], 'sortable');
|
831
|
+
if(inst && inst != this && !inst.options.disabled) {
|
832
|
+
queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
|
833
|
+
this.containers.push(inst);
|
834
|
+
}
|
835
|
+
};
|
836
|
+
};
|
837
|
+
}
|
838
|
+
|
839
|
+
for (var i = queries.length - 1; i >= 0; i--) {
|
840
|
+
var targetData = queries[i][1];
|
841
|
+
var _queries = queries[i][0];
|
842
|
+
|
843
|
+
for (var j=0, queriesLength = _queries.length; j < queriesLength; j++) {
|
844
|
+
var item = $(_queries[j]);
|
845
|
+
|
846
|
+
item.data('sortable-item', targetData); // Data for target checking (mouse manager)
|
847
|
+
|
848
|
+
items.push({
|
849
|
+
item: item,
|
850
|
+
instance: targetData,
|
851
|
+
width: 0, height: 0,
|
852
|
+
left: 0, top: 0
|
853
|
+
});
|
854
|
+
};
|
855
|
+
};
|
856
|
+
|
857
|
+
},
|
858
|
+
|
859
|
+
refreshPositions: function(fast) {
|
860
|
+
|
861
|
+
//This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
|
862
|
+
if(this.offsetParent && this.helper) {
|
863
|
+
this.offset.parent = this._getParentOffset();
|
864
|
+
}
|
865
|
+
|
866
|
+
for (var i = this.items.length - 1; i >= 0; i--){
|
867
|
+
var item = this.items[i];
|
868
|
+
|
869
|
+
//We ignore calculating positions of all connected containers when we're not over them
|
870
|
+
if(item.instance != this.currentContainer && this.currentContainer && item.item[0] != this.currentItem[0])
|
871
|
+
continue;
|
872
|
+
|
873
|
+
var t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
|
874
|
+
|
875
|
+
if (!fast) {
|
876
|
+
item.width = t.outerWidth();
|
877
|
+
item.height = t.outerHeight();
|
878
|
+
}
|
879
|
+
|
880
|
+
var p = t.offset();
|
881
|
+
item.left = p.left;
|
882
|
+
item.top = p.top;
|
883
|
+
};
|
884
|
+
|
885
|
+
if(this.options.custom && this.options.custom.refreshContainers) {
|
886
|
+
this.options.custom.refreshContainers.call(this);
|
887
|
+
} else {
|
888
|
+
for (var i = this.containers.length - 1; i >= 0; i--){
|
889
|
+
var p = this.containers[i].element.offset();
|
890
|
+
this.containers[i].containerCache.left = p.left;
|
891
|
+
this.containers[i].containerCache.top = p.top;
|
892
|
+
this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
|
893
|
+
this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
|
894
|
+
};
|
895
|
+
}
|
896
|
+
|
897
|
+
return this;
|
898
|
+
},
|
899
|
+
|
900
|
+
_createPlaceholder: function(that) {
|
901
|
+
|
902
|
+
var self = that || this, o = self.options;
|
903
|
+
|
904
|
+
if(!o.placeholder || o.placeholder.constructor == String) {
|
905
|
+
var className = o.placeholder;
|
906
|
+
o.placeholder = {
|
907
|
+
element: function() {
|
908
|
+
|
909
|
+
var el = $((this.document || document).createElement(self.currentItem[0].nodeName))
|
910
|
+
.addClass(className || self.currentItem[0].className+" ui-sortable-placeholder")
|
911
|
+
.removeClass("ui-sortable-helper")[0];
|
912
|
+
|
913
|
+
if(!className)
|
914
|
+
el.style.visibility = "hidden";
|
915
|
+
|
916
|
+
return el;
|
917
|
+
},
|
918
|
+
update: function(container, p) {
|
919
|
+
|
920
|
+
// 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
|
921
|
+
// 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
|
922
|
+
if(className && !o.forcePlaceholderSize) return;
|
923
|
+
|
924
|
+
//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
|
925
|
+
if(!p.height()) { p.height(self.currentItem.innerHeight() - parseInt(self.currentItem.css('paddingTop')||0, 10) - parseInt(self.currentItem.css('paddingBottom')||0, 10)); };
|
926
|
+
if(!p.width()) { p.width(self.currentItem.innerWidth() - parseInt(self.currentItem.css('paddingLeft')||0, 10) - parseInt(self.currentItem.css('paddingRight')||0, 10)); };
|
927
|
+
}
|
928
|
+
};
|
929
|
+
}
|
930
|
+
|
931
|
+
//Create the placeholder
|
932
|
+
self.placeholder = $(o.placeholder.element.call(self.element, self.currentItem));
|
933
|
+
|
934
|
+
//Append it after the actual current item
|
935
|
+
self.currentItem.after(self.placeholder);
|
936
|
+
|
937
|
+
//Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
|
938
|
+
o.placeholder.update(self, self.placeholder);
|
939
|
+
|
940
|
+
},
|
941
|
+
|
942
|
+
_contactContainers: function(event) {
|
943
|
+
|
944
|
+
// get innermost container that intersects with item
|
945
|
+
var innermostContainer = null, innermostIndex = null;
|
946
|
+
|
947
|
+
|
948
|
+
for (var i = this.containers.length - 1; i >= 0; i--){
|
949
|
+
|
950
|
+
// never consider a container that's located within the item itself
|
951
|
+
if($.ui.contains(this.currentItem[0], this.containers[i].element[0]))
|
952
|
+
continue;
|
953
|
+
|
954
|
+
if(this._intersectsWith(this.containers[i].containerCache)) {
|
955
|
+
|
956
|
+
// if we've already found a container and it's more "inner" than this, then continue
|
957
|
+
if(innermostContainer && $.ui.contains(this.containers[i].element[0], innermostContainer.element[0]))
|
958
|
+
continue;
|
959
|
+
|
960
|
+
innermostContainer = this.containers[i];
|
961
|
+
innermostIndex = i;
|
962
|
+
|
963
|
+
} else {
|
964
|
+
// container doesn't intersect. trigger "out" event if necessary
|
965
|
+
if(this.containers[i].containerCache.over) {
|
966
|
+
this.containers[i]._trigger("out", event, this._uiHash(this));
|
967
|
+
this.containers[i].containerCache.over = 0;
|
968
|
+
}
|
969
|
+
}
|
970
|
+
|
971
|
+
}
|
972
|
+
|
973
|
+
// if no intersecting containers found, return
|
974
|
+
if(!innermostContainer) return;
|
975
|
+
|
976
|
+
// move the item into the container if it's not there already
|
977
|
+
if(this.containers.length === 1) {
|
978
|
+
this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
|
979
|
+
this.containers[innermostIndex].containerCache.over = 1;
|
980
|
+
} else if(this.currentContainer != this.containers[innermostIndex]) {
|
981
|
+
|
982
|
+
//When entering a new container, we will find the item with the least distance and append our item near it
|
983
|
+
var dist = 10000; var itemWithLeastDistance = null; var base = this.positionAbs[this.containers[innermostIndex].floating ? 'left' : 'top'];
|
984
|
+
for (var j = this.items.length - 1; j >= 0; j--) {
|
985
|
+
if(!$.ui.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) continue;
|
986
|
+
var cur = this.items[j][this.containers[innermostIndex].floating ? 'left' : 'top'];
|
987
|
+
if(Math.abs(cur - base) < dist) {
|
988
|
+
dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
|
989
|
+
}
|
990
|
+
}
|
991
|
+
|
992
|
+
if(!itemWithLeastDistance && !this.options.dropOnEmpty) //Check if dropOnEmpty is enabled
|
993
|
+
return;
|
994
|
+
|
995
|
+
this.currentContainer = this.containers[innermostIndex];
|
996
|
+
itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
|
997
|
+
this._trigger("change", event, this._uiHash());
|
998
|
+
this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
|
999
|
+
|
1000
|
+
//Update the placeholder
|
1001
|
+
this.options.placeholder.update(this.currentContainer, this.placeholder);
|
1002
|
+
|
1003
|
+
this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
|
1004
|
+
this.containers[innermostIndex].containerCache.over = 1;
|
1005
|
+
}
|
1006
|
+
|
1007
|
+
|
1008
|
+
},
|
1009
|
+
|
1010
|
+
_createHelper: function(event) {
|
1011
|
+
|
1012
|
+
var o = this.options;
|
1013
|
+
var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper == 'clone' ? this.currentItem.clone() : this.currentItem);
|
1014
|
+
|
1015
|
+
if(!helper.parents('body').length) //Add the helper to the DOM if that didn't happen already
|
1016
|
+
$(o.appendTo != 'parent' ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
|
1017
|
+
|
1018
|
+
if(helper[0] == this.currentItem[0])
|
1019
|
+
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") };
|
1020
|
+
|
1021
|
+
if(helper[0].style.width == '' || o.forceHelperSize) helper.width(this.currentItem.width());
|
1022
|
+
if(helper[0].style.height == '' || o.forceHelperSize) helper.height(this.currentItem.height());
|
1023
|
+
|
1024
|
+
return helper;
|
1025
|
+
|
1026
|
+
},
|
1027
|
+
|
1028
|
+
_adjustOffsetFromHelper: function(obj) {
|
1029
|
+
if (typeof obj == 'string') {
|
1030
|
+
obj = obj.split(' ');
|
1031
|
+
}
|
1032
|
+
if ($.isArray(obj)) {
|
1033
|
+
obj = {left: +obj[0], top: +obj[1] || 0};
|
1034
|
+
}
|
1035
|
+
if ('left' in obj) {
|
1036
|
+
this.offset.click.left = obj.left + this.margins.left;
|
1037
|
+
}
|
1038
|
+
if ('right' in obj) {
|
1039
|
+
this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
|
1040
|
+
}
|
1041
|
+
if ('top' in obj) {
|
1042
|
+
this.offset.click.top = obj.top + this.margins.top;
|
1043
|
+
}
|
1044
|
+
if ('bottom' in obj) {
|
1045
|
+
this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
|
1046
|
+
}
|
1047
|
+
},
|
1048
|
+
|
1049
|
+
_getParentOffset: function() {
|
1050
|
+
|
1051
|
+
|
1052
|
+
//Get the offsetParent and cache its position
|
1053
|
+
this.offsetParent = this.helper.offsetParent();
|
1054
|
+
var po = this.offsetParent.offset();
|
1055
|
+
|
1056
|
+
// This is a special case where we need to modify a offset calculated on start, since the following happened:
|
1057
|
+
// 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
|
1058
|
+
// 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
|
1059
|
+
// the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
|
1060
|
+
if(this.cssPosition == 'absolute' && this.scrollParent[0] != (this.document || document) && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) {
|
1061
|
+
po.left += this.scrollParent.scrollLeft();
|
1062
|
+
po.top += this.scrollParent.scrollTop();
|
1063
|
+
}
|
1064
|
+
|
1065
|
+
if((this.offsetParent[0] == (this.document || document).body) //This needs to be actually done for all browsers, since pageX/pageY includes this information
|
1066
|
+
|| (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix
|
1067
|
+
po = { top: 0, left: 0 };
|
1068
|
+
|
1069
|
+
return {
|
1070
|
+
top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
|
1071
|
+
left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
|
1072
|
+
};
|
1073
|
+
|
1074
|
+
},
|
1075
|
+
|
1076
|
+
_getRelativeOffset: function() {
|
1077
|
+
|
1078
|
+
if(this.cssPosition == "relative") {
|
1079
|
+
var p = this.currentItem.position();
|
1080
|
+
return {
|
1081
|
+
top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
|
1082
|
+
left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
|
1083
|
+
};
|
1084
|
+
} else {
|
1085
|
+
return { top: 0, left: 0 };
|
1086
|
+
}
|
1087
|
+
|
1088
|
+
},
|
1089
|
+
|
1090
|
+
_cacheMargins: function() {
|
1091
|
+
this.margins = {
|
1092
|
+
left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
|
1093
|
+
top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
|
1094
|
+
};
|
1095
|
+
},
|
1096
|
+
|
1097
|
+
_cacheHelperProportions: function() {
|
1098
|
+
this.helperProportions = {
|
1099
|
+
width: this.helper.outerWidth(),
|
1100
|
+
height: this.helper.outerHeight()
|
1101
|
+
};
|
1102
|
+
},
|
1103
|
+
|
1104
|
+
_setContainment: function() {
|
1105
|
+
|
1106
|
+
var o = this.options;
|
1107
|
+
if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
|
1108
|
+
if(o.containment == 'document' || o.containment == 'window') this.containment = [
|
1109
|
+
0 - this.offset.relative.left - this.offset.parent.left,
|
1110
|
+
0 - this.offset.relative.top - this.offset.parent.top,
|
1111
|
+
$(o.containment == 'document' ? (this.document || document) : window).width() - this.helperProportions.width - this.margins.left,
|
1112
|
+
($(o.containment == 'document' ? (this.document || document) : window).height() || (this.document || document).body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
|
1113
|
+
];
|
1114
|
+
|
1115
|
+
if(!(/^(document|window|parent)$/).test(o.containment)) {
|
1116
|
+
var ce = $(o.containment)[0];
|
1117
|
+
var co = $(o.containment).offset();
|
1118
|
+
var over = ($(ce).css("overflow") != 'hidden');
|
1119
|
+
|
1120
|
+
this.containment = [
|
1121
|
+
co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
|
1122
|
+
co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
|
1123
|
+
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,
|
1124
|
+
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
|
1125
|
+
];
|
1126
|
+
}
|
1127
|
+
|
1128
|
+
},
|
1129
|
+
|
1130
|
+
_convertPositionTo: function(d, pos) {
|
1131
|
+
|
1132
|
+
if(!pos) pos = this.position;
|
1133
|
+
var mod = d == "absolute" ? 1 : -1;
|
1134
|
+
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);
|
1135
|
+
|
1136
|
+
return {
|
1137
|
+
top: (
|
1138
|
+
pos.top // The absolute mouse position
|
1139
|
+
+ this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent
|
1140
|
+
+ this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border)
|
1141
|
+
- ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
|
1142
|
+
),
|
1143
|
+
left: (
|
1144
|
+
pos.left // The absolute mouse position
|
1145
|
+
+ this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent
|
1146
|
+
+ this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border)
|
1147
|
+
- ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
|
1148
|
+
)
|
1149
|
+
};
|
1150
|
+
|
1151
|
+
},
|
1152
|
+
|
1153
|
+
_generatePosition: function(event) {
|
1154
|
+
|
1155
|
+
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);
|
1156
|
+
|
1157
|
+
// This is another very weird special case that only happens for relative elements:
|
1158
|
+
// 1. If the css position is relative
|
1159
|
+
// 2. and the scroll parent is the document or similar to the offset parent
|
1160
|
+
// we have to refresh the relative offset during the scroll so there are no jumps
|
1161
|
+
if(this.cssPosition == 'relative' && !(this.scrollParent[0] != (this.document || document) && this.scrollParent[0] != this.offsetParent[0])) {
|
1162
|
+
this.offset.relative = this._getRelativeOffset();
|
1163
|
+
}
|
1164
|
+
|
1165
|
+
var pageX = event.pageX;
|
1166
|
+
var pageY = event.pageY;
|
1167
|
+
|
1168
|
+
/*
|
1169
|
+
* - Position constraining -
|
1170
|
+
* Constrain the position to a mix of grid, containment.
|
1171
|
+
*/
|
1172
|
+
|
1173
|
+
if(this.originalPosition) { //If we are not dragging yet, we won't check for options
|
1174
|
+
|
1175
|
+
if(this.containment) {
|
1176
|
+
if(event.pageX - this.offset.click.left < this.containment[0]) pageX = this.containment[0] + this.offset.click.left;
|
1177
|
+
if(event.pageY - this.offset.click.top < this.containment[1]) pageY = this.containment[1] + this.offset.click.top;
|
1178
|
+
if(event.pageX - this.offset.click.left > this.containment[2]) pageX = this.containment[2] + this.offset.click.left;
|
1179
|
+
if(event.pageY - this.offset.click.top > this.containment[3]) pageY = this.containment[3] + this.offset.click.top;
|
1180
|
+
}
|
1181
|
+
|
1182
|
+
if(o.grid) {
|
1183
|
+
var top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
|
1184
|
+
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;
|
1185
|
+
|
1186
|
+
var left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
|
1187
|
+
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;
|
1188
|
+
}
|
1189
|
+
|
1190
|
+
}
|
1191
|
+
|
1192
|
+
return {
|
1193
|
+
top: (
|
1194
|
+
pageY // The absolute mouse position
|
1195
|
+
- this.offset.click.top // Click offset (relative to the element)
|
1196
|
+
- this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent
|
1197
|
+
- this.offset.parent.top // The offsetParent's offset without borders (offset + border)
|
1198
|
+
+ ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
|
1199
|
+
),
|
1200
|
+
left: (
|
1201
|
+
pageX // The absolute mouse position
|
1202
|
+
- this.offset.click.left // Click offset (relative to the element)
|
1203
|
+
- this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent
|
1204
|
+
- this.offset.parent.left // The offsetParent's offset without borders (offset + border)
|
1205
|
+
+ ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
|
1206
|
+
)
|
1207
|
+
};
|
1208
|
+
|
1209
|
+
},
|
1210
|
+
|
1211
|
+
_rearrange: function(event, i, a, hardRefresh) {
|
1212
|
+
|
1213
|
+
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));
|
1214
|
+
|
1215
|
+
//Various things done here to improve the performance:
|
1216
|
+
// 1. we create a setTimeout, that calls refreshPositions
|
1217
|
+
// 2. on the instance, we have a counter variable, that get's higher after every append
|
1218
|
+
// 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
|
1219
|
+
// 4. this lets only the last addition to the timeout stack through
|
1220
|
+
this.counter = this.counter ? ++this.counter : 1;
|
1221
|
+
var self = this, counter = this.counter;
|
1222
|
+
|
1223
|
+
window.setTimeout(function() {
|
1224
|
+
if(counter == self.counter) self.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
|
1225
|
+
},0);
|
1226
|
+
|
1227
|
+
},
|
1228
|
+
|
1229
|
+
_clear: function(event, noPropagation) {
|
1230
|
+
|
1231
|
+
this.reverting = false;
|
1232
|
+
// We delay all events that have to be triggered to after the point where the placeholder has been removed and
|
1233
|
+
// everything else normalized again
|
1234
|
+
var delayedTriggers = [], self = this;
|
1235
|
+
|
1236
|
+
// We first have to update the dom position of the actual currentItem
|
1237
|
+
// Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
|
1238
|
+
if(!this._noFinalSort && this.currentItem[0].parentNode) this.placeholder.before(this.currentItem);
|
1239
|
+
this._noFinalSort = null;
|
1240
|
+
|
1241
|
+
if(this.helper[0] == this.currentItem[0]) {
|
1242
|
+
for(var i in this._storedCSS) {
|
1243
|
+
if(this._storedCSS[i] == 'auto' || this._storedCSS[i] == 'static') this._storedCSS[i] = '';
|
1244
|
+
}
|
1245
|
+
this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
|
1246
|
+
} else {
|
1247
|
+
this.currentItem.show();
|
1248
|
+
}
|
1249
|
+
|
1250
|
+
if(this.fromOutside && !noPropagation) delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
|
1251
|
+
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
|
1252
|
+
if(!$.ui.contains(this.element[0], this.currentItem[0])) { //Node was moved out of the current element
|
1253
|
+
if(!noPropagation) delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
|
1254
|
+
for (var i = this.containers.length - 1; i >= 0; i--){
|
1255
|
+
if($.ui.contains(this.containers[i].element[0], this.currentItem[0]) && !noPropagation) {
|
1256
|
+
delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
|
1257
|
+
delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
|
1258
|
+
}
|
1259
|
+
};
|
1260
|
+
};
|
1261
|
+
|
1262
|
+
//Post events to containers
|
1263
|
+
for (var i = this.containers.length - 1; i >= 0; i--){
|
1264
|
+
if(!noPropagation) delayedTriggers.push((function(c) { return function(event) { c._trigger("deactivate", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
|
1265
|
+
if(this.containers[i].containerCache.over) {
|
1266
|
+
delayedTriggers.push((function(c) { return function(event) { c._trigger("out", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
|
1267
|
+
this.containers[i].containerCache.over = 0;
|
1268
|
+
}
|
1269
|
+
}
|
1270
|
+
|
1271
|
+
//Do what was originally in plugins
|
1272
|
+
if(this._storedCursor) $('body').css("cursor", this._storedCursor); //Reset cursor
|
1273
|
+
if(this._storedOpacity) this.helper.css("opacity", this._storedOpacity); //Reset opacity
|
1274
|
+
if(this._storedZIndex) this.helper.css("zIndex", this._storedZIndex == 'auto' ? '' : this._storedZIndex); //Reset z-index
|
1275
|
+
|
1276
|
+
this.dragging = false;
|
1277
|
+
if(this.cancelHelperRemoval) {
|
1278
|
+
if(!noPropagation) {
|
1279
|
+
this._trigger("beforeStop", event, this._uiHash());
|
1280
|
+
for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events
|
1281
|
+
this._trigger("stop", event, this._uiHash());
|
1282
|
+
}
|
1283
|
+
return false;
|
1284
|
+
}
|
1285
|
+
|
1286
|
+
if(!noPropagation) this._trigger("beforeStop", event, this._uiHash());
|
1287
|
+
|
1288
|
+
//$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
|
1289
|
+
this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
|
1290
|
+
|
1291
|
+
if(this.helper[0] != this.currentItem[0]) this.helper.remove(); this.helper = null;
|
1292
|
+
|
1293
|
+
if(!noPropagation) {
|
1294
|
+
for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events
|
1295
|
+
this._trigger("stop", event, this._uiHash());
|
1296
|
+
}
|
1297
|
+
|
1298
|
+
this.fromOutside = false;
|
1299
|
+
return true;
|
1300
|
+
|
1301
|
+
},
|
1302
|
+
|
1303
|
+
_trigger: function() {
|
1304
|
+
if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
|
1305
|
+
this.cancel();
|
1306
|
+
}
|
1307
|
+
},
|
1308
|
+
|
1309
|
+
_uiHash: function(inst) {
|
1310
|
+
var self = inst || this;
|
1311
|
+
return {
|
1312
|
+
helper: self.helper,
|
1313
|
+
placeholder: self.placeholder || $([]),
|
1314
|
+
position: self.position,
|
1315
|
+
originalPosition: self.originalPosition,
|
1316
|
+
offset: self.positionAbs,
|
1317
|
+
item: self.currentItem,
|
1318
|
+
sender: inst ? inst.element : null
|
1319
|
+
};
|
1320
|
+
}
|
1321
|
+
|
1322
|
+
});
|
1323
|
+
|
1324
|
+
$.extend($.ui.sortable, {
|
1325
|
+
version: "1.8.13"
|
1326
|
+
});
|
1327
|
+
|
1328
|
+
})(jQuery);
|