effective_assets 0.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +1 -1
- data/README.md +341 -72
- data/app/assets/javascripts/effective/snippets/effective_asset.js.coffee +53 -0
- data/app/assets/javascripts/effective_assets.js +4 -0
- data/app/assets/javascripts/effective_assets/asset_box.js.coffee +36 -0
- data/app/assets/javascripts/effective_assets/asset_box_dialog.js.coffee +49 -0
- data/app/assets/javascripts/effective_assets/asset_box_drag_and_drop.js.coffee +2 -0
- data/app/assets/javascripts/effective_assets/asset_box_filtering.js.coffee +16 -0
- data/app/assets/javascripts/effective_assets/asset_box_sorting.js.coffee +8 -0
- data/app/assets/javascripts/effective_assets/jquery_ui_sortable.js +813 -585
- data/app/assets/javascripts/effective_assets/s3_uploader.js.coffee +268 -0
- data/app/assets/javascripts/effective_assets_iframe.js.coffee +28 -0
- data/app/assets/stylesheets/active_admin/effective_assets.css.scss +57 -0
- data/app/assets/stylesheets/effective_assets/_asset_box_input.scss +54 -175
- data/app/assets/stylesheets/effective_assets/_iframe_bootstrap.scss +1714 -0
- data/app/assets/stylesheets/effective_assets/_input_bootstrap.scss +508 -0
- data/app/assets/stylesheets/effective_assets_iframe.css.scss +23 -0
- data/app/controllers/effective/assets_controller.rb +41 -0
- data/app/controllers/effective/s3_uploads_controller.rb +58 -74
- data/app/helpers/effective_assets_helper.rb +30 -14
- data/app/helpers/effective_assets_s3_helper.rb +69 -0
- data/app/models/concerns/acts_as_asset_box.rb +75 -11
- data/app/models/effective/access_denied.rb +17 -0
- data/app/models/effective/asset.rb +130 -93
- data/app/models/effective/attachment.rb +2 -7
- data/app/models/effective/delayed_job.rb +33 -78
- data/app/models/effective/snippets/effective_asset.rb +19 -0
- data/app/models/effective/user_uploads.rb +19 -0
- data/app/models/inputs/asset_box.rb +154 -0
- data/app/models/inputs/asset_box_form_input.rb +7 -0
- data/app/models/inputs/asset_box_formtastic_input.rb +9 -0
- data/app/models/inputs/asset_box_input.rb +13 -82
- data/app/models/inputs/asset_box_simple_form_input.rb +7 -0
- data/app/uploaders/effective_assets_uploader.rb +14 -2
- data/app/uploaders/{asset_uploader.rb → test_asset_uploader.rb} +1 -1
- data/app/views/active_admin/effective_assets/_edit.html.haml +3 -3
- data/app/views/active_admin/effective_assets/_new.html.haml +2 -1
- data/app/views/asset_box_input/_attachment_as_list.html.haml +17 -0
- data/app/views/asset_box_input/_attachment_as_table.html.haml +32 -0
- data/app/views/asset_box_input/_attachment_as_thumbnail.html.haml +20 -0
- data/app/views/asset_box_input/_dialog.html.haml +18 -0
- data/app/views/asset_box_input/_progress_bar_template.html.haml +8 -0
- data/app/views/asset_box_input/_uploader.html.haml +21 -115
- data/app/views/effective/assets/iframe.html.haml +17 -0
- data/app/views/effective/snippets/_effective_asset.html.haml +8 -0
- data/config/routes.rb +8 -2
- data/db/migrate/01_create_effective_assets.rb.erb +3 -0
- data/lib/effective_assets.rb +34 -3
- data/lib/effective_assets/engine.rb +11 -8
- data/lib/effective_assets/version.rb +1 -1
- data/lib/generators/templates/asset_uploader.rb +35 -0
- data/lib/generators/templates/effective_assets.rb +31 -4
- data/lib/tasks/effective_assets_tasks.rake +115 -4
- data/spec/internal/config/database.yml +3 -0
- data/spec/internal/config/initializers/effective_assets.rb +18 -0
- data/spec/internal/config/routes.rb +3 -0
- data/spec/internal/db/combustion_test.sqlite +0 -0
- data/spec/internal/db/schema.rb +52 -0
- data/spec/internal/log/test.log +793 -0
- data/spec/{dummy → internal}/public/favicon.ico +0 -0
- data/spec/internal/public/sprites.png +0 -0
- data/spec/models/asset_spec.rb +119 -35
- data/spec/spec_helper.rb +9 -3
- metadata +95 -234
- data/app/assets/images/effective_assets/s3_down_button.gif +0 -0
- data/app/assets/images/effective_assets/s3_over_button.gif +0 -0
- data/app/assets/images/effective_assets/s3_up_button.gif +0 -0
- data/app/assets/images/effective_assets/s3_upload.swf +0 -0
- data/app/assets/javascripts/effective_assets/asset_box_input.js.coffee +0 -71
- data/app/assets/javascripts/effective_assets/asset_box_uploader.js +0 -122
- data/app/assets/javascripts/effective_assets/asset_box_uploader_customization.js +0 -166
- data/app/controllers/effective/attachments_controller.rb +0 -14
- data/app/views/asset_box_input/_attachment_fields.html.haml +0 -14
- data/spec/dummy/README.rdoc +0 -261
- data/spec/dummy/Rakefile +0 -7
- data/spec/dummy/app/assets/javascripts/application.js +0 -15
- data/spec/dummy/app/assets/stylesheets/application.css +0 -13
- data/spec/dummy/app/controllers/application_controller.rb +0 -3
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/app/views/layouts/application.html.erb +0 -14
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/config/application.rb +0 -65
- data/spec/dummy/config/boot.rb +0 -10
- data/spec/dummy/config/database.yml +0 -25
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -37
- data/spec/dummy/config/environments/production.rb +0 -67
- data/spec/dummy/config/environments/test.rb +0 -37
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/inflections.rb +0 -15
- data/spec/dummy/config/initializers/mime_types.rb +0 -5
- data/spec/dummy/config/initializers/secret_token.rb +0 -7
- data/spec/dummy/config/initializers/session_store.rb +0 -8
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/en.yml +0 -5
- data/spec/dummy/config/routes.rb +0 -58
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/schema.rb +0 -16
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +0 -71
- data/spec/dummy/log/test.log +0 -33
- data/spec/dummy/public/404.html +0 -26
- data/spec/dummy/public/422.html +0 -26
- data/spec/dummy/public/500.html +0 -25
- data/spec/dummy/script/rails +0 -6
- data/spec/dummy/spec_link +0 -3
@@ -0,0 +1,53 @@
|
|
1
|
+
CKEDITOR.dialog.add 'effective_asset', (editor) ->
|
2
|
+
title: 'Insert File'
|
3
|
+
minWidth: 650,
|
4
|
+
minHeight: 500,
|
5
|
+
contents: [
|
6
|
+
{
|
7
|
+
id: 'tab1',
|
8
|
+
label: 'File',
|
9
|
+
title: 'File',
|
10
|
+
elements: [
|
11
|
+
{
|
12
|
+
type: 'html',
|
13
|
+
html: "<p>* NOTE: This screen is for non-image files only. Please select 'Image' from the toolbar to work with images."
|
14
|
+
},
|
15
|
+
{
|
16
|
+
id: 'asset_id',
|
17
|
+
type: 'text',
|
18
|
+
label: 'File',
|
19
|
+
setup: (widget) -> this.setValue(widget.data.asset_id)
|
20
|
+
commit: (widget) -> widget.setData('asset_id', this.getValue()) if widget
|
21
|
+
},
|
22
|
+
{
|
23
|
+
id: 'html_class',
|
24
|
+
type: 'text',
|
25
|
+
label: 'HTML Class',
|
26
|
+
setup: (widget) -> this.setValue(widget.data.html_class)
|
27
|
+
commit: (widget) -> widget.setData('html_class', this.getValue()) if widget
|
28
|
+
}
|
29
|
+
] # /tab1 elements
|
30
|
+
}, # /tab1
|
31
|
+
{
|
32
|
+
id: 'tab2',
|
33
|
+
label: 'Insert / Upload',
|
34
|
+
title: 'Insert / Upload',
|
35
|
+
elements: [
|
36
|
+
{
|
37
|
+
id: 'iframe-insert',
|
38
|
+
type: 'html',
|
39
|
+
html: "<div><iframe class='effective_assets_iframe' style='width: 100%; height: 100%; min-height: 500px;' src='/effective/assets?only=nonimages'></iframe></div>"
|
40
|
+
onLoad: (evt) ->
|
41
|
+
dialog = evt.sender # This is the CKEditor.dialog
|
42
|
+
iframe = $('#' + dialog.getContentElement('tab2', 'iframe-insert').domId).children('iframe').first()
|
43
|
+
iframe.on 'load', ->
|
44
|
+
$(this).contents().on 'click', 'a.attachment-insert', (event) ->
|
45
|
+
event.preventDefault()
|
46
|
+
dialog.setValueOf('tab1', 'asset_id', $(event.currentTarget).data('asset-id'))
|
47
|
+
dialog.commitContent()
|
48
|
+
dialog.click('ok')
|
49
|
+
}
|
50
|
+
] # /tab2 elements
|
51
|
+
} # /tab2
|
52
|
+
] # /contents
|
53
|
+
|
@@ -0,0 +1,36 @@
|
|
1
|
+
$(document).on 's3_file_added', (event, file) ->
|
2
|
+
obj = $(event.target)
|
3
|
+
obj.closest('.error').removeClass('error')
|
4
|
+
obj.parent().siblings('.help-inline,.inline-errors').remove()
|
5
|
+
|
6
|
+
$(document).on 's3_uploads_complete', (_, uploader) ->
|
7
|
+
uploader.closest('.asset-box-input').find('.filter-attachments').val('')
|
8
|
+
|
9
|
+
$(document).on 's3_upload_failed', (_, uploader, content) ->
|
10
|
+
uploader.closest('.asset-box-input').find('.filter-attachments').val('')
|
11
|
+
alert("An error occurred while uploading #{content.filename}.\n\nThe returned error message is: '#{content.error_thrown}'\n\nPlease try again.")
|
12
|
+
|
13
|
+
$(document).on 'click', 'a.attachment-remove', (event) ->
|
14
|
+
event.preventDefault()
|
15
|
+
attachment_div = $(event.target).closest('.attachment')
|
16
|
+
|
17
|
+
attachment_div.find('input.asset-box-remove').first().val(1)
|
18
|
+
attachment_div.hide()
|
19
|
+
|
20
|
+
# Show the first 'limit' attachments, hide the rest
|
21
|
+
asset_box_input = attachment_div.closest('div.asset-box-input')
|
22
|
+
limit = asset_box_input.data('limit')
|
23
|
+
|
24
|
+
asset_box_input.find("input.asset-box-remove").each (index) ->
|
25
|
+
if "#{$(this).val()}" == '1' # If we're going to delete it...
|
26
|
+
$(this).closest('.attachment').hide()
|
27
|
+
limit = limit + 1
|
28
|
+
return
|
29
|
+
|
30
|
+
if index >= limit
|
31
|
+
$(this).closest('.attachment').hide()
|
32
|
+
else
|
33
|
+
$(this).closest('.attachment').show()
|
34
|
+
|
35
|
+
|
36
|
+
|
@@ -0,0 +1,49 @@
|
|
1
|
+
$(document).on 'click', '.asset-box-dialog', (event) ->
|
2
|
+
event.preventDefault()
|
3
|
+
|
4
|
+
obj = $(event.currentTarget)
|
5
|
+
asset_box = obj.closest('.asset-box-input')
|
6
|
+
modal = obj.siblings('.asset-box-modal')
|
7
|
+
|
8
|
+
return false unless modal
|
9
|
+
|
10
|
+
iframe = modal.find('iframe')
|
11
|
+
iframe.attr('height', $(window).height() * 0.75)
|
12
|
+
|
13
|
+
unless asset_box.data('dialog-initialized')
|
14
|
+
iframe.contents().on 'click', '.attachment-insert', (event) ->
|
15
|
+
event.preventDefault()
|
16
|
+
|
17
|
+
$.ajax
|
18
|
+
url: "/s3_uploads/#{$(this).data('asset-id')}"
|
19
|
+
type: 'PUT'
|
20
|
+
data:
|
21
|
+
skip_update: true
|
22
|
+
attachable_type: asset_box.data('attachable-type')
|
23
|
+
attachable_id: asset_box.data('attachable-id')
|
24
|
+
attachable_object_name: asset_box.data('attachable-object-name')
|
25
|
+
attachment_style: asset_box.data('attachment-style')
|
26
|
+
attachment_actions: asset_box.data('attachment-actions')
|
27
|
+
aws_acl: asset_box.data('aws-acl')
|
28
|
+
box: asset_box.data('box')
|
29
|
+
async: true
|
30
|
+
success: (data) ->
|
31
|
+
asset_box.find('.attachments').prepend($(data))
|
32
|
+
|
33
|
+
limit = asset_box.data('limit')
|
34
|
+
|
35
|
+
asset_box.find("input.asset-box-remove").each (index) ->
|
36
|
+
if "#{$(this).val()}" == '1' # If we're going to delete it...
|
37
|
+
$(this).closest('.attachment').hide()
|
38
|
+
limit = limit + 1
|
39
|
+
return
|
40
|
+
|
41
|
+
if index >= limit
|
42
|
+
$(this).closest('.attachment').hide()
|
43
|
+
else
|
44
|
+
$(this).closest('.attachment').show()
|
45
|
+
|
46
|
+
if asset_box.data('limit') == 1 then modal.modal('hide')
|
47
|
+
|
48
|
+
asset_box.data('dialog-initialized', true)
|
49
|
+
modal.modal()
|
@@ -0,0 +1,16 @@
|
|
1
|
+
filter = (search, asset_box_input) ->
|
2
|
+
term = (search || '').toLowerCase()
|
3
|
+
|
4
|
+
asset_box_input.find('.attachments').first().find('.attachment').each (index) ->
|
5
|
+
attachment = $(this)
|
6
|
+
|
7
|
+
return if "#{attachment.find("input.asset-box-remove").first().val()}" == '1'
|
8
|
+
|
9
|
+
if term == '' || attachment.find('.attachment-title').text().toLowerCase().indexOf(term) > -1
|
10
|
+
attachment.show()
|
11
|
+
else
|
12
|
+
attachment.hide()
|
13
|
+
|
14
|
+
$(document).on 'keyup', '.filter-attachments', (event) ->
|
15
|
+
obj = $(event.currentTarget)
|
16
|
+
filter(obj.val(), obj.closest('.asset-box-input'))
|
@@ -1,23 +1,36 @@
|
|
1
|
-
/*! jQuery UI - v1.
|
1
|
+
/*! jQuery UI - v1.11.2 - 2014-10-24
|
2
2
|
* http://jqueryui.com
|
3
|
-
* Includes:
|
4
|
-
* Copyright
|
3
|
+
* Includes: core.js, widget.js, mouse.js, sortable.js
|
4
|
+
* Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
|
5
5
|
|
6
|
-
(function(
|
6
|
+
(function( factory ) {
|
7
|
+
if ( typeof define === "function" && define.amd ) {
|
7
8
|
|
8
|
-
|
9
|
-
|
9
|
+
// AMD. Register as an anonymous module.
|
10
|
+
define([ "jquery" ], factory );
|
11
|
+
} else {
|
10
12
|
|
11
|
-
//
|
12
|
-
|
13
|
-
|
13
|
+
// Browser globals
|
14
|
+
factory( jQuery );
|
15
|
+
}
|
16
|
+
}(function( $ ) {
|
17
|
+
/*!
|
18
|
+
* jQuery UI Core 1.11.2
|
19
|
+
* http://jqueryui.com
|
20
|
+
*
|
21
|
+
* Copyright 2014 jQuery Foundation and other contributors
|
22
|
+
* Released under the MIT license.
|
23
|
+
* http://jquery.org/license
|
24
|
+
*
|
25
|
+
* http://api.jqueryui.com/category/ui-core/
|
26
|
+
*/
|
27
|
+
|
28
|
+
|
29
|
+
// $.ui might exist from components with no dependencies, e.g., $.ui.position
|
14
30
|
$.ui = $.ui || {};
|
15
|
-
if ( $.ui.version ) {
|
16
|
-
return;
|
17
|
-
}
|
18
31
|
|
19
32
|
$.extend( $.ui, {
|
20
|
-
version: "1.
|
33
|
+
version: "1.11.2",
|
21
34
|
|
22
35
|
keyCode: {
|
23
36
|
BACKSPACE: 8,
|
@@ -29,12 +42,6 @@ $.extend( $.ui, {
|
|
29
42
|
ESCAPE: 27,
|
30
43
|
HOME: 36,
|
31
44
|
LEFT: 37,
|
32
|
-
NUMPAD_ADD: 107,
|
33
|
-
NUMPAD_DECIMAL: 110,
|
34
|
-
NUMPAD_DIVIDE: 111,
|
35
|
-
NUMPAD_ENTER: 108,
|
36
|
-
NUMPAD_MULTIPLY: 106,
|
37
|
-
NUMPAD_SUBTRACT: 109,
|
38
45
|
PAGE_DOWN: 34,
|
39
46
|
PAGE_UP: 33,
|
40
47
|
PERIOD: 190,
|
@@ -47,76 +54,36 @@ $.extend( $.ui, {
|
|
47
54
|
|
48
55
|
// plugins
|
49
56
|
$.fn.extend({
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
}) :
|
62
|
-
this._focus.apply( this, arguments );
|
63
|
-
},
|
64
|
-
|
65
|
-
scrollParent: function() {
|
66
|
-
var scrollParent;
|
67
|
-
if (($.ui.ie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) {
|
68
|
-
scrollParent = this.parents().filter(function() {
|
69
|
-
return (/(relative|absolute|fixed)/).test($.css(this,'position')) && (/(auto|scroll)/).test($.css(this,'overflow')+$.css(this,'overflow-y')+$.css(this,'overflow-x'));
|
70
|
-
}).eq(0);
|
71
|
-
} else {
|
72
|
-
scrollParent = this.parents().filter(function() {
|
73
|
-
return (/(auto|scroll)/).test($.css(this,'overflow')+$.css(this,'overflow-y')+$.css(this,'overflow-x'));
|
74
|
-
}).eq(0);
|
75
|
-
}
|
57
|
+
scrollParent: function( includeHidden ) {
|
58
|
+
var position = this.css( "position" ),
|
59
|
+
excludeStaticParent = position === "absolute",
|
60
|
+
overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/,
|
61
|
+
scrollParent = this.parents().filter( function() {
|
62
|
+
var parent = $( this );
|
63
|
+
if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
|
64
|
+
return false;
|
65
|
+
}
|
66
|
+
return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) + parent.css( "overflow-x" ) );
|
67
|
+
}).eq( 0 );
|
76
68
|
|
77
|
-
return
|
69
|
+
return position === "fixed" || !scrollParent.length ? $( this[ 0 ].ownerDocument || document ) : scrollParent;
|
78
70
|
},
|
79
71
|
|
80
|
-
|
81
|
-
|
82
|
-
return this.css( "zIndex", zIndex );
|
83
|
-
}
|
72
|
+
uniqueId: (function() {
|
73
|
+
var uuid = 0;
|
84
74
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
// This makes behavior of this function consistent across browsers
|
90
|
-
// WebKit always returns auto if the element is positioned
|
91
|
-
position = elem.css( "position" );
|
92
|
-
if ( position === "absolute" || position === "relative" || position === "fixed" ) {
|
93
|
-
// IE returns 0 when zIndex is not specified
|
94
|
-
// other browsers return a string
|
95
|
-
// we ignore the case of nested elements with an explicit value of 0
|
96
|
-
// <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
|
97
|
-
value = parseInt( elem.css( "zIndex" ), 10 );
|
98
|
-
if ( !isNaN( value ) && value !== 0 ) {
|
99
|
-
return value;
|
100
|
-
}
|
75
|
+
return function() {
|
76
|
+
return this.each(function() {
|
77
|
+
if ( !this.id ) {
|
78
|
+
this.id = "ui-id-" + ( ++uuid );
|
101
79
|
}
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
return 0;
|
107
|
-
},
|
108
|
-
|
109
|
-
uniqueId: function() {
|
110
|
-
return this.each(function() {
|
111
|
-
if ( !this.id ) {
|
112
|
-
this.id = "ui-id-" + (++uuid);
|
113
|
-
}
|
114
|
-
});
|
115
|
-
},
|
80
|
+
});
|
81
|
+
};
|
82
|
+
})(),
|
116
83
|
|
117
84
|
removeUniqueId: function() {
|
118
85
|
return this.each(function() {
|
119
|
-
if (
|
86
|
+
if ( /^ui-id-\d+$/.test( this.id ) ) {
|
120
87
|
$( this ).removeAttr( "id" );
|
121
88
|
}
|
122
89
|
});
|
@@ -133,7 +100,7 @@ function focusable( element, isTabIndexNotNaN ) {
|
|
133
100
|
if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
|
134
101
|
return false;
|
135
102
|
}
|
136
|
-
img = $( "img[usemap
|
103
|
+
img = $( "img[usemap='#" + mapName + "']" )[ 0 ];
|
137
104
|
return !!img && visible( img );
|
138
105
|
}
|
139
106
|
return ( /input|select|textarea|button|object/.test( nodeName ) ?
|
@@ -147,7 +114,7 @@ function focusable( element, isTabIndexNotNaN ) {
|
|
147
114
|
|
148
115
|
function visible( element ) {
|
149
116
|
return $.expr.filters.visible( element ) &&
|
150
|
-
!$( element ).parents().
|
117
|
+
!$( element ).parents().addBack().filter(function() {
|
151
118
|
return $.css( this, "visibility" ) === "hidden";
|
152
119
|
}).length;
|
153
120
|
}
|
@@ -175,31 +142,6 @@ $.extend( $.expr[ ":" ], {
|
|
175
142
|
}
|
176
143
|
});
|
177
144
|
|
178
|
-
// support
|
179
|
-
$(function() {
|
180
|
-
var body = document.body,
|
181
|
-
div = body.appendChild( div = document.createElement( "div" ) );
|
182
|
-
|
183
|
-
// access offsetHeight before setting the style to prevent a layout bug
|
184
|
-
// in IE 9 which causes the element to continue to take up space even
|
185
|
-
// after it is removed from the DOM (#8026)
|
186
|
-
div.offsetHeight;
|
187
|
-
|
188
|
-
$.extend( div.style, {
|
189
|
-
minHeight: "100px",
|
190
|
-
height: "auto",
|
191
|
-
padding: 0,
|
192
|
-
borderWidth: 0
|
193
|
-
});
|
194
|
-
|
195
|
-
$.support.minHeight = div.offsetHeight === 100;
|
196
|
-
$.support.selectstart = "onselectstart" in div;
|
197
|
-
|
198
|
-
// set display to none to avoid a layout bug in IE
|
199
|
-
// http://dev.jquery.com/ticket/4014
|
200
|
-
body.removeChild( div ).style.display = "none";
|
201
|
-
});
|
202
|
-
|
203
145
|
// support: jQuery <1.8
|
204
146
|
if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
|
205
147
|
$.each( [ "Width", "Height" ], function( i, name ) {
|
@@ -247,6 +189,15 @@ if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
|
|
247
189
|
});
|
248
190
|
}
|
249
191
|
|
192
|
+
// support: jQuery <1.8
|
193
|
+
if ( !$.fn.addBack ) {
|
194
|
+
$.fn.addBack = function( selector ) {
|
195
|
+
return this.add( selector == null ?
|
196
|
+
this.prevObject : this.prevObject.filter( selector )
|
197
|
+
);
|
198
|
+
};
|
199
|
+
}
|
200
|
+
|
250
201
|
// support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
|
251
202
|
if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
|
252
203
|
$.fn.removeData = (function( removeData ) {
|
@@ -260,112 +211,142 @@ if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
|
|
260
211
|
})( $.fn.removeData );
|
261
212
|
}
|
262
213
|
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
214
|
// deprecated
|
268
|
-
|
269
|
-
(function() {
|
270
|
-
var uaMatch = /msie ([\w.]+)/.exec( navigator.userAgent.toLowerCase() ) || [];
|
271
|
-
$.ui.ie = uaMatch.length ? true : false;
|
272
|
-
$.ui.ie6 = parseFloat( uaMatch[ 1 ], 10 ) === 6;
|
273
|
-
})();
|
215
|
+
$.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
|
274
216
|
|
275
217
|
$.fn.extend({
|
276
|
-
|
277
|
-
return
|
278
|
-
|
218
|
+
focus: (function( orig ) {
|
219
|
+
return function( delay, fn ) {
|
220
|
+
return typeof delay === "number" ?
|
221
|
+
this.each(function() {
|
222
|
+
var elem = this;
|
223
|
+
setTimeout(function() {
|
224
|
+
$( elem ).focus();
|
225
|
+
if ( fn ) {
|
226
|
+
fn.call( elem );
|
227
|
+
}
|
228
|
+
}, delay );
|
229
|
+
}) :
|
230
|
+
orig.apply( this, arguments );
|
231
|
+
};
|
232
|
+
})( $.fn.focus ),
|
233
|
+
|
234
|
+
disableSelection: (function() {
|
235
|
+
var eventType = "onselectstart" in document.createElement( "div" ) ?
|
236
|
+
"selectstart" :
|
237
|
+
"mousedown";
|
238
|
+
|
239
|
+
return function() {
|
240
|
+
return this.bind( eventType + ".ui-disableSelection", function( event ) {
|
279
241
|
event.preventDefault();
|
280
242
|
});
|
281
|
-
|
243
|
+
};
|
244
|
+
})(),
|
282
245
|
|
283
246
|
enableSelection: function() {
|
284
247
|
return this.unbind( ".ui-disableSelection" );
|
285
|
-
}
|
286
|
-
});
|
248
|
+
},
|
287
249
|
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
var i,
|
293
|
-
proto = $.ui[ module ].prototype;
|
294
|
-
for ( i in set ) {
|
295
|
-
proto.plugins[ i ] = proto.plugins[ i ] || [];
|
296
|
-
proto.plugins[ i ].push( [ option, set[ i ] ] );
|
297
|
-
}
|
298
|
-
},
|
299
|
-
call: function( instance, name, args ) {
|
300
|
-
var i,
|
301
|
-
set = instance.plugins[ name ];
|
302
|
-
if ( !set || !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) {
|
303
|
-
return;
|
304
|
-
}
|
250
|
+
zIndex: function( zIndex ) {
|
251
|
+
if ( zIndex !== undefined ) {
|
252
|
+
return this.css( "zIndex", zIndex );
|
253
|
+
}
|
305
254
|
|
306
|
-
|
307
|
-
|
308
|
-
|
255
|
+
if ( this.length ) {
|
256
|
+
var elem = $( this[ 0 ] ), position, value;
|
257
|
+
while ( elem.length && elem[ 0 ] !== document ) {
|
258
|
+
// Ignore z-index if position is set to a value where z-index is ignored by the browser
|
259
|
+
// This makes behavior of this function consistent across browsers
|
260
|
+
// WebKit always returns auto if the element is positioned
|
261
|
+
position = elem.css( "position" );
|
262
|
+
if ( position === "absolute" || position === "relative" || position === "fixed" ) {
|
263
|
+
// IE returns 0 when zIndex is not specified
|
264
|
+
// other browsers return a string
|
265
|
+
// we ignore the case of nested elements with an explicit value of 0
|
266
|
+
// <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
|
267
|
+
value = parseInt( elem.css( "zIndex" ), 10 );
|
268
|
+
if ( !isNaN( value ) && value !== 0 ) {
|
269
|
+
return value;
|
270
|
+
}
|
309
271
|
}
|
272
|
+
elem = elem.parent();
|
310
273
|
}
|
311
274
|
}
|
312
|
-
},
|
313
275
|
|
314
|
-
|
276
|
+
return 0;
|
277
|
+
}
|
278
|
+
});
|
315
279
|
|
316
|
-
|
317
|
-
|
280
|
+
// $.ui.plugin is deprecated. Use $.widget() extensions instead.
|
281
|
+
$.ui.plugin = {
|
282
|
+
add: function( module, option, set ) {
|
283
|
+
var i,
|
284
|
+
proto = $.ui[ module ].prototype;
|
285
|
+
for ( i in set ) {
|
286
|
+
proto.plugins[ i ] = proto.plugins[ i ] || [];
|
287
|
+
proto.plugins[ i ].push( [ option, set[ i ] ] );
|
288
|
+
}
|
289
|
+
},
|
290
|
+
call: function( instance, name, args, allowDisconnected ) {
|
291
|
+
var i,
|
292
|
+
set = instance.plugins[ name ];
|
318
293
|
|
319
|
-
|
320
|
-
|
321
|
-
return false;
|
294
|
+
if ( !set ) {
|
295
|
+
return;
|
322
296
|
}
|
323
297
|
|
324
|
-
|
325
|
-
|
298
|
+
if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) ) {
|
299
|
+
return;
|
300
|
+
}
|
326
301
|
|
327
|
-
|
328
|
-
|
302
|
+
for ( i = 0; i < set.length; i++ ) {
|
303
|
+
if ( instance.options[ set[ i ][ 0 ] ] ) {
|
304
|
+
set[ i ][ 1 ].apply( instance.element, args );
|
305
|
+
}
|
329
306
|
}
|
307
|
+
}
|
308
|
+
};
|
330
309
|
|
331
|
-
// TODO: determine which cases actually cause this to happen
|
332
|
-
// if the element doesn't have the scroll set, see if it's possible to
|
333
|
-
// set the scroll
|
334
|
-
el[ scroll ] = 1;
|
335
|
-
has = ( el[ scroll ] > 0 );
|
336
|
-
el[ scroll ] = 0;
|
337
|
-
return has;
|
338
|
-
},
|
339
310
|
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
311
|
+
/*!
|
312
|
+
* jQuery UI Widget 1.11.2
|
313
|
+
* http://jqueryui.com
|
314
|
+
*
|
315
|
+
* Copyright 2014 jQuery Foundation and other contributors
|
316
|
+
* Released under the MIT license.
|
317
|
+
* http://jquery.org/license
|
318
|
+
*
|
319
|
+
* http://api.jqueryui.com/jQuery.widget/
|
320
|
+
*/
|
350
321
|
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
}
|
322
|
+
|
323
|
+
var widget_uuid = 0,
|
324
|
+
widget_slice = Array.prototype.slice;
|
325
|
+
|
326
|
+
$.cleanData = (function( orig ) {
|
327
|
+
return function( elems ) {
|
328
|
+
var events, elem, i;
|
329
|
+
for ( i = 0; (elem = elems[i]) != null; i++ ) {
|
330
|
+
try {
|
331
|
+
|
332
|
+
// Only trigger remove when necessary to save time
|
333
|
+
events = $._data( elem, "events" );
|
334
|
+
if ( events && events.remove ) {
|
335
|
+
$( elem ).triggerHandler( "remove" );
|
336
|
+
}
|
337
|
+
|
338
|
+
// http://bugs.jquery.com/ticket/8235
|
339
|
+
} catch ( e ) {}
|
340
|
+
}
|
341
|
+
orig( elems );
|
342
|
+
};
|
343
|
+
})( $.cleanData );
|
366
344
|
|
367
345
|
$.widget = function( name, base, prototype ) {
|
368
346
|
var fullName, existingConstructor, constructor, basePrototype,
|
347
|
+
// proxiedPrototype allows the provided prototype to remain unmodified
|
348
|
+
// so that it can be used as a mixin for multiple widgets (#8876)
|
349
|
+
proxiedPrototype = {},
|
369
350
|
namespace = name.split( "." )[ 0 ];
|
370
351
|
|
371
352
|
name = name.split( "." )[ 1 ];
|
@@ -412,43 +393,43 @@ $.widget = function( name, base, prototype ) {
|
|
412
393
|
// inheriting from
|
413
394
|
basePrototype.options = $.widget.extend( {}, basePrototype.options );
|
414
395
|
$.each( prototype, function( prop, value ) {
|
415
|
-
if (
|
416
|
-
|
417
|
-
|
418
|
-
return base.prototype[ prop ].apply( this, arguments );
|
419
|
-
},
|
420
|
-
_superApply = function( args ) {
|
421
|
-
return base.prototype[ prop ].apply( this, args );
|
422
|
-
};
|
423
|
-
return function() {
|
424
|
-
var __super = this._super,
|
425
|
-
__superApply = this._superApply,
|
426
|
-
returnValue;
|
427
|
-
|
428
|
-
this._super = _super;
|
429
|
-
this._superApply = _superApply;
|
430
|
-
|
431
|
-
returnValue = value.apply( this, arguments );
|
432
|
-
|
433
|
-
this._super = __super;
|
434
|
-
this._superApply = __superApply;
|
435
|
-
|
436
|
-
return returnValue;
|
437
|
-
};
|
438
|
-
})();
|
396
|
+
if ( !$.isFunction( value ) ) {
|
397
|
+
proxiedPrototype[ prop ] = value;
|
398
|
+
return;
|
439
399
|
}
|
400
|
+
proxiedPrototype[ prop ] = (function() {
|
401
|
+
var _super = function() {
|
402
|
+
return base.prototype[ prop ].apply( this, arguments );
|
403
|
+
},
|
404
|
+
_superApply = function( args ) {
|
405
|
+
return base.prototype[ prop ].apply( this, args );
|
406
|
+
};
|
407
|
+
return function() {
|
408
|
+
var __super = this._super,
|
409
|
+
__superApply = this._superApply,
|
410
|
+
returnValue;
|
411
|
+
|
412
|
+
this._super = _super;
|
413
|
+
this._superApply = _superApply;
|
414
|
+
|
415
|
+
returnValue = value.apply( this, arguments );
|
416
|
+
|
417
|
+
this._super = __super;
|
418
|
+
this._superApply = __superApply;
|
419
|
+
|
420
|
+
return returnValue;
|
421
|
+
};
|
422
|
+
})();
|
440
423
|
});
|
441
424
|
constructor.prototype = $.widget.extend( basePrototype, {
|
442
425
|
// TODO: remove support for widgetEventPrefix
|
443
426
|
// always use the name + a colon as the prefix, e.g., draggable:start
|
444
427
|
// don't prefix for widgets that aren't DOM-based
|
445
|
-
widgetEventPrefix: existingConstructor ? basePrototype.widgetEventPrefix : name
|
446
|
-
},
|
428
|
+
widgetEventPrefix: existingConstructor ? (basePrototype.widgetEventPrefix || name) : name
|
429
|
+
}, proxiedPrototype, {
|
447
430
|
constructor: constructor,
|
448
431
|
namespace: namespace,
|
449
432
|
widgetName: name,
|
450
|
-
// TODO remove widgetBaseClass, see #8155
|
451
|
-
widgetBaseClass: fullName,
|
452
433
|
widgetFullName: fullName
|
453
434
|
});
|
454
435
|
|
@@ -472,10 +453,12 @@ $.widget = function( name, base, prototype ) {
|
|
472
453
|
}
|
473
454
|
|
474
455
|
$.widget.bridge( name, constructor );
|
456
|
+
|
457
|
+
return constructor;
|
475
458
|
};
|
476
459
|
|
477
460
|
$.widget.extend = function( target ) {
|
478
|
-
var input =
|
461
|
+
var input = widget_slice.call( arguments, 1 ),
|
479
462
|
inputIndex = 0,
|
480
463
|
inputLength = input.length,
|
481
464
|
key,
|
@@ -504,7 +487,7 @@ $.widget.bridge = function( name, object ) {
|
|
504
487
|
var fullName = object.prototype.widgetFullName || name;
|
505
488
|
$.fn[ name ] = function( options ) {
|
506
489
|
var isMethodCall = typeof options === "string",
|
507
|
-
args =
|
490
|
+
args = widget_slice.call( arguments, 1 ),
|
508
491
|
returnValue = this;
|
509
492
|
|
510
493
|
// allow multiple hashes to be passed on init
|
@@ -516,6 +499,10 @@ $.widget.bridge = function( name, object ) {
|
|
516
499
|
this.each(function() {
|
517
500
|
var methodValue,
|
518
501
|
instance = $.data( this, fullName );
|
502
|
+
if ( options === "instance" ) {
|
503
|
+
returnValue = instance;
|
504
|
+
return false;
|
505
|
+
}
|
519
506
|
if ( !instance ) {
|
520
507
|
return $.error( "cannot call methods on " + name + " prior to initialization; " +
|
521
508
|
"attempted to call method '" + options + "'" );
|
@@ -535,7 +522,10 @@ $.widget.bridge = function( name, object ) {
|
|
535
522
|
this.each(function() {
|
536
523
|
var instance = $.data( this, fullName );
|
537
524
|
if ( instance ) {
|
538
|
-
instance.option( options || {} )
|
525
|
+
instance.option( options || {} );
|
526
|
+
if ( instance._init ) {
|
527
|
+
instance._init();
|
528
|
+
}
|
539
529
|
} else {
|
540
530
|
$.data( this, fullName, new object( options, this ) );
|
541
531
|
}
|
@@ -562,21 +552,14 @@ $.Widget.prototype = {
|
|
562
552
|
_createWidget: function( options, element ) {
|
563
553
|
element = $( element || this.defaultElement || this )[ 0 ];
|
564
554
|
this.element = $( element );
|
565
|
-
this.uuid =
|
555
|
+
this.uuid = widget_uuid++;
|
566
556
|
this.eventNamespace = "." + this.widgetName + this.uuid;
|
567
|
-
this.options = $.widget.extend( {},
|
568
|
-
this.options,
|
569
|
-
this._getCreateOptions(),
|
570
|
-
options );
|
571
557
|
|
572
558
|
this.bindings = $();
|
573
559
|
this.hoverable = $();
|
574
560
|
this.focusable = $();
|
575
561
|
|
576
562
|
if ( element !== this ) {
|
577
|
-
// 1.9 BC for #7810
|
578
|
-
// TODO remove dual storage
|
579
|
-
$.data( element, this.widgetName, this );
|
580
563
|
$.data( element, this.widgetFullName, this );
|
581
564
|
this._on( true, this.element, {
|
582
565
|
remove: function( event ) {
|
@@ -593,6 +576,11 @@ $.Widget.prototype = {
|
|
593
576
|
this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
|
594
577
|
}
|
595
578
|
|
579
|
+
this.options = $.widget.extend( {},
|
580
|
+
this.options,
|
581
|
+
this._getCreateOptions(),
|
582
|
+
options );
|
583
|
+
|
596
584
|
this._create();
|
597
585
|
this._trigger( "create", null, this._getCreateEventData() );
|
598
586
|
this._init();
|
@@ -608,9 +596,6 @@ $.Widget.prototype = {
|
|
608
596
|
// all event bindings should go through this._on()
|
609
597
|
this.element
|
610
598
|
.unbind( this.eventNamespace )
|
611
|
-
// 1.9 BC for #7810
|
612
|
-
// TODO remove dual storage
|
613
|
-
.removeData( this.widgetName )
|
614
599
|
.removeData( this.widgetFullName )
|
615
600
|
// support: jquery <1.6.3
|
616
601
|
// http://bugs.jquery.com/ticket/9413
|
@@ -656,12 +641,12 @@ $.Widget.prototype = {
|
|
656
641
|
curOption = curOption[ parts[ i ] ];
|
657
642
|
}
|
658
643
|
key = parts.pop();
|
659
|
-
if (
|
644
|
+
if ( arguments.length === 1 ) {
|
660
645
|
return curOption[ key ] === undefined ? null : curOption[ key ];
|
661
646
|
}
|
662
647
|
curOption[ key ] = value;
|
663
648
|
} else {
|
664
|
-
if (
|
649
|
+
if ( arguments.length === 1 ) {
|
665
650
|
return this.options[ key ] === undefined ? null : this.options[ key ];
|
666
651
|
}
|
667
652
|
options[ key ] = value;
|
@@ -686,20 +671,23 @@ $.Widget.prototype = {
|
|
686
671
|
|
687
672
|
if ( key === "disabled" ) {
|
688
673
|
this.widget()
|
689
|
-
.toggleClass( this.widgetFullName + "-disabled
|
690
|
-
|
691
|
-
|
692
|
-
|
674
|
+
.toggleClass( this.widgetFullName + "-disabled", !!value );
|
675
|
+
|
676
|
+
// If the widget is becoming disabled, then nothing is interactive
|
677
|
+
if ( value ) {
|
678
|
+
this.hoverable.removeClass( "ui-state-hover" );
|
679
|
+
this.focusable.removeClass( "ui-state-focus" );
|
680
|
+
}
|
693
681
|
}
|
694
682
|
|
695
683
|
return this;
|
696
684
|
},
|
697
685
|
|
698
686
|
enable: function() {
|
699
|
-
return this.
|
687
|
+
return this._setOptions({ disabled: false });
|
700
688
|
},
|
701
689
|
disable: function() {
|
702
|
-
return this.
|
690
|
+
return this._setOptions({ disabled: true });
|
703
691
|
},
|
704
692
|
|
705
693
|
_on: function( suppressDisabledCheck, element, handlers ) {
|
@@ -719,7 +707,6 @@ $.Widget.prototype = {
|
|
719
707
|
element = this.element;
|
720
708
|
delegateElement = this.widget();
|
721
709
|
} else {
|
722
|
-
// accept selectors, DOM elements
|
723
710
|
element = delegateElement = $( element );
|
724
711
|
this.bindings = this.bindings.add( element );
|
725
712
|
}
|
@@ -744,7 +731,7 @@ $.Widget.prototype = {
|
|
744
731
|
handler.guid || handlerProxy.guid || $.guid++;
|
745
732
|
}
|
746
733
|
|
747
|
-
var match = event.match( /^(\w
|
734
|
+
var match = event.match( /^([\w:-]*)\s*(.*)$/ ),
|
748
735
|
eventName = match[1] + instance.eventNamespace,
|
749
736
|
selector = match[2];
|
750
737
|
if ( selector ) {
|
@@ -756,8 +743,14 @@ $.Widget.prototype = {
|
|
756
743
|
},
|
757
744
|
|
758
745
|
_off: function( element, eventName ) {
|
759
|
-
eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) +
|
746
|
+
eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) +
|
747
|
+
this.eventNamespace;
|
760
748
|
element.unbind( eventName ).undelegate( eventName );
|
749
|
+
|
750
|
+
// Clear the stack to avoid memory leaks (#10056)
|
751
|
+
this.bindings = $( this.bindings.not( element ).get() );
|
752
|
+
this.focusable = $( this.focusable.not( element ).get() );
|
753
|
+
this.hoverable = $( this.hoverable.not( element ).get() );
|
761
754
|
},
|
762
755
|
|
763
756
|
_delay: function( handler, delay ) {
|
@@ -843,7 +836,7 @@ $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
|
|
843
836
|
if ( options.delay ) {
|
844
837
|
element.delay( options.delay );
|
845
838
|
}
|
846
|
-
if ( hasOptions && $.effects &&
|
839
|
+
if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
|
847
840
|
element[ method ]( options );
|
848
841
|
} else if ( effectName !== method && element[ effectName ] ) {
|
849
842
|
element[ effectName ]( options.duration, options.easing, callback );
|
@@ -859,25 +852,30 @@ $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
|
|
859
852
|
};
|
860
853
|
});
|
861
854
|
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
855
|
+
var widget = $.widget;
|
856
|
+
|
857
|
+
|
858
|
+
/*!
|
859
|
+
* jQuery UI Mouse 1.11.2
|
860
|
+
* http://jqueryui.com
|
861
|
+
*
|
862
|
+
* Copyright 2014 jQuery Foundation and other contributors
|
863
|
+
* Released under the MIT license.
|
864
|
+
* http://jquery.org/license
|
865
|
+
*
|
866
|
+
* http://api.jqueryui.com/mouse/
|
867
|
+
*/
|
868
868
|
|
869
|
-
})( jQuery );
|
870
|
-
(function( $, undefined ) {
|
871
869
|
|
872
870
|
var mouseHandled = false;
|
873
|
-
$( document ).mouseup( function(
|
871
|
+
$( document ).mouseup( function() {
|
874
872
|
mouseHandled = false;
|
875
873
|
});
|
876
874
|
|
877
|
-
$.widget("ui.mouse", {
|
878
|
-
version: "1.
|
875
|
+
var mouse = $.widget("ui.mouse", {
|
876
|
+
version: "1.11.2",
|
879
877
|
options: {
|
880
|
-
cancel:
|
878
|
+
cancel: "input,textarea,button,select,option",
|
881
879
|
distance: 1,
|
882
880
|
delay: 0
|
883
881
|
},
|
@@ -885,12 +883,12 @@ $.widget("ui.mouse", {
|
|
885
883
|
var that = this;
|
886
884
|
|
887
885
|
this.element
|
888
|
-
.bind(
|
886
|
+
.bind("mousedown." + this.widgetName, function(event) {
|
889
887
|
return that._mouseDown(event);
|
890
888
|
})
|
891
|
-
.bind(
|
892
|
-
if (true === $.data(event.target, that.widgetName +
|
893
|
-
$.removeData(event.target, that.widgetName +
|
889
|
+
.bind("click." + this.widgetName, function(event) {
|
890
|
+
if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) {
|
891
|
+
$.removeData(event.target, that.widgetName + ".preventClickEvent");
|
894
892
|
event.stopImmediatePropagation();
|
895
893
|
return false;
|
896
894
|
}
|
@@ -902,17 +900,21 @@ $.widget("ui.mouse", {
|
|
902
900
|
// TODO: make sure destroying one instance of mouse doesn't mess with
|
903
901
|
// other instances of mouse
|
904
902
|
_mouseDestroy: function() {
|
905
|
-
this.element.unbind(
|
903
|
+
this.element.unbind("." + this.widgetName);
|
906
904
|
if ( this._mouseMoveDelegate ) {
|
907
|
-
|
908
|
-
.unbind(
|
909
|
-
.unbind(
|
905
|
+
this.document
|
906
|
+
.unbind("mousemove." + this.widgetName, this._mouseMoveDelegate)
|
907
|
+
.unbind("mouseup." + this.widgetName, this._mouseUpDelegate);
|
910
908
|
}
|
911
909
|
},
|
912
910
|
|
913
911
|
_mouseDown: function(event) {
|
914
912
|
// don't let more than one widget handle mouseStart
|
915
|
-
if( mouseHandled ) {
|
913
|
+
if ( mouseHandled ) {
|
914
|
+
return;
|
915
|
+
}
|
916
|
+
|
917
|
+
this._mouseMoved = false;
|
916
918
|
|
917
919
|
// we may have missed mouseup (out of window)
|
918
920
|
(this._mouseStarted && this._mouseUp(event));
|
@@ -944,8 +946,8 @@ $.widget("ui.mouse", {
|
|
944
946
|
}
|
945
947
|
|
946
948
|
// Click event may never have fired (Gecko & Opera)
|
947
|
-
if (true === $.data(event.target, this.widgetName +
|
948
|
-
$.removeData(event.target, this.widgetName +
|
949
|
+
if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) {
|
950
|
+
$.removeData(event.target, this.widgetName + ".preventClickEvent");
|
949
951
|
}
|
950
952
|
|
951
953
|
// these delegates are required to keep context
|
@@ -955,9 +957,10 @@ $.widget("ui.mouse", {
|
|
955
957
|
this._mouseUpDelegate = function(event) {
|
956
958
|
return that._mouseUp(event);
|
957
959
|
};
|
958
|
-
|
959
|
-
|
960
|
-
.bind(
|
960
|
+
|
961
|
+
this.document
|
962
|
+
.bind( "mousemove." + this.widgetName, this._mouseMoveDelegate )
|
963
|
+
.bind( "mouseup." + this.widgetName, this._mouseUpDelegate );
|
961
964
|
|
962
965
|
event.preventDefault();
|
963
966
|
|
@@ -966,9 +969,23 @@ $.widget("ui.mouse", {
|
|
966
969
|
},
|
967
970
|
|
968
971
|
_mouseMove: function(event) {
|
969
|
-
//
|
970
|
-
|
971
|
-
|
972
|
+
// Only check for mouseups outside the document if you've moved inside the document
|
973
|
+
// at least once. This prevents the firing of mouseup in the case of IE<9, which will
|
974
|
+
// fire a mousemove event if content is placed under the cursor. See #7778
|
975
|
+
// Support: IE <9
|
976
|
+
if ( this._mouseMoved ) {
|
977
|
+
// IE mouseup check - mouseup happened when mouse was out of window
|
978
|
+
if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) {
|
979
|
+
return this._mouseUp(event);
|
980
|
+
|
981
|
+
// Iframe mouseup check - mouseup occurred in another document
|
982
|
+
} else if ( !event.which ) {
|
983
|
+
return this._mouseUp( event );
|
984
|
+
}
|
985
|
+
}
|
986
|
+
|
987
|
+
if ( event.which || event.button ) {
|
988
|
+
this._mouseMoved = true;
|
972
989
|
}
|
973
990
|
|
974
991
|
if (this._mouseStarted) {
|
@@ -986,20 +1003,21 @@ $.widget("ui.mouse", {
|
|
986
1003
|
},
|
987
1004
|
|
988
1005
|
_mouseUp: function(event) {
|
989
|
-
|
990
|
-
.unbind(
|
991
|
-
.unbind(
|
1006
|
+
this.document
|
1007
|
+
.unbind( "mousemove." + this.widgetName, this._mouseMoveDelegate )
|
1008
|
+
.unbind( "mouseup." + this.widgetName, this._mouseUpDelegate );
|
992
1009
|
|
993
1010
|
if (this._mouseStarted) {
|
994
1011
|
this._mouseStarted = false;
|
995
1012
|
|
996
1013
|
if (event.target === this._mouseDownEvent.target) {
|
997
|
-
$.data(event.target, this.widgetName +
|
1014
|
+
$.data(event.target, this.widgetName + ".preventClickEvent", true);
|
998
1015
|
}
|
999
1016
|
|
1000
1017
|
this._mouseStop(event);
|
1001
1018
|
}
|
1002
1019
|
|
1020
|
+
mouseHandled = false;
|
1003
1021
|
return false;
|
1004
1022
|
},
|
1005
1023
|
|
@@ -1011,22 +1029,32 @@ $.widget("ui.mouse", {
|
|
1011
1029
|
);
|
1012
1030
|
},
|
1013
1031
|
|
1014
|
-
_mouseDelayMet: function(event) {
|
1032
|
+
_mouseDelayMet: function(/* event */) {
|
1015
1033
|
return this.mouseDelayMet;
|
1016
1034
|
},
|
1017
1035
|
|
1018
1036
|
// These are placeholder methods, to be overriden by extending plugin
|
1019
|
-
_mouseStart: function(event) {},
|
1020
|
-
_mouseDrag: function(event) {},
|
1021
|
-
_mouseStop: function(event) {},
|
1022
|
-
_mouseCapture: function(event) { return true; }
|
1037
|
+
_mouseStart: function(/* event */) {},
|
1038
|
+
_mouseDrag: function(/* event */) {},
|
1039
|
+
_mouseStop: function(/* event */) {},
|
1040
|
+
_mouseCapture: function(/* event */) { return true; }
|
1023
1041
|
});
|
1024
1042
|
|
1025
|
-
})(jQuery);
|
1026
|
-
(function( $, undefined ) {
|
1027
1043
|
|
1028
|
-
|
1029
|
-
|
1044
|
+
/*!
|
1045
|
+
* jQuery UI Sortable 1.11.2
|
1046
|
+
* http://jqueryui.com
|
1047
|
+
*
|
1048
|
+
* Copyright 2014 jQuery Foundation and other contributors
|
1049
|
+
* Released under the MIT license.
|
1050
|
+
* http://jquery.org/license
|
1051
|
+
*
|
1052
|
+
* http://api.jqueryui.com/sortable/
|
1053
|
+
*/
|
1054
|
+
|
1055
|
+
|
1056
|
+
var sortable = $.widget("ui.sortable", $.ui.mouse, {
|
1057
|
+
version: "1.11.2",
|
1030
1058
|
widgetEventPrefix: "sort",
|
1031
1059
|
ready: false,
|
1032
1060
|
options: {
|
@@ -1034,7 +1062,7 @@ $.widget("ui.sortable", $.ui.mouse, {
|
|
1034
1062
|
axis: false,
|
1035
1063
|
connectWith: false,
|
1036
1064
|
containment: false,
|
1037
|
-
cursor:
|
1065
|
+
cursor: "auto",
|
1038
1066
|
cursorAt: false,
|
1039
1067
|
dropOnEmpty: true,
|
1040
1068
|
forcePlaceholderSize: false,
|
@@ -1042,7 +1070,7 @@ $.widget("ui.sortable", $.ui.mouse, {
|
|
1042
1070
|
grid: false,
|
1043
1071
|
handle: false,
|
1044
1072
|
helper: "original",
|
1045
|
-
items:
|
1073
|
+
items: "> *",
|
1046
1074
|
opacity: false,
|
1047
1075
|
placeholder: false,
|
1048
1076
|
revert: false,
|
@@ -1051,8 +1079,31 @@ $.widget("ui.sortable", $.ui.mouse, {
|
|
1051
1079
|
scrollSpeed: 20,
|
1052
1080
|
scope: "default",
|
1053
1081
|
tolerance: "intersect",
|
1054
|
-
zIndex: 1000
|
1082
|
+
zIndex: 1000,
|
1083
|
+
|
1084
|
+
// callbacks
|
1085
|
+
activate: null,
|
1086
|
+
beforeStop: null,
|
1087
|
+
change: null,
|
1088
|
+
deactivate: null,
|
1089
|
+
out: null,
|
1090
|
+
over: null,
|
1091
|
+
receive: null,
|
1092
|
+
remove: null,
|
1093
|
+
sort: null,
|
1094
|
+
start: null,
|
1095
|
+
stop: null,
|
1096
|
+
update: null
|
1097
|
+
},
|
1098
|
+
|
1099
|
+
_isOverAxis: function( x, reference, size ) {
|
1100
|
+
return ( x >= reference ) && ( x < ( reference + size ) );
|
1055
1101
|
},
|
1102
|
+
|
1103
|
+
_isFloating: function( item ) {
|
1104
|
+
return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display"));
|
1105
|
+
},
|
1106
|
+
|
1056
1107
|
_create: function() {
|
1057
1108
|
|
1058
1109
|
var o = this.options;
|
@@ -1063,7 +1114,7 @@ $.widget("ui.sortable", $.ui.mouse, {
|
|
1063
1114
|
this.refresh();
|
1064
1115
|
|
1065
1116
|
//Let's determine if the items are being displayed horizontally
|
1066
|
-
this.floating = this.items.length ? o.axis ===
|
1117
|
+
this.floating = this.items.length ? o.axis === "x" || this._isFloating(this.items[0].item) : false;
|
1067
1118
|
|
1068
1119
|
//Let's determine the parent's offset
|
1069
1120
|
this.offset = this.element.offset();
|
@@ -1071,60 +1122,83 @@ $.widget("ui.sortable", $.ui.mouse, {
|
|
1071
1122
|
//Initialize mouse events for interaction
|
1072
1123
|
this._mouseInit();
|
1073
1124
|
|
1125
|
+
this._setHandleClassName();
|
1126
|
+
|
1074
1127
|
//We're ready to go
|
1075
|
-
this.ready = true
|
1128
|
+
this.ready = true;
|
1129
|
+
|
1130
|
+
},
|
1131
|
+
|
1132
|
+
_setOption: function( key, value ) {
|
1133
|
+
this._super( key, value );
|
1134
|
+
|
1135
|
+
if ( key === "handle" ) {
|
1136
|
+
this._setHandleClassName();
|
1137
|
+
}
|
1138
|
+
},
|
1076
1139
|
|
1140
|
+
_setHandleClassName: function() {
|
1141
|
+
this.element.find( ".ui-sortable-handle" ).removeClass( "ui-sortable-handle" );
|
1142
|
+
$.each( this.items, function() {
|
1143
|
+
( this.instance.options.handle ?
|
1144
|
+
this.item.find( this.instance.options.handle ) : this.item )
|
1145
|
+
.addClass( "ui-sortable-handle" );
|
1146
|
+
});
|
1077
1147
|
},
|
1078
1148
|
|
1079
1149
|
_destroy: function() {
|
1080
1150
|
this.element
|
1081
|
-
.removeClass("ui-sortable ui-sortable-disabled")
|
1151
|
+
.removeClass( "ui-sortable ui-sortable-disabled" )
|
1152
|
+
.find( ".ui-sortable-handle" )
|
1153
|
+
.removeClass( "ui-sortable-handle" );
|
1082
1154
|
this._mouseDestroy();
|
1083
1155
|
|
1084
|
-
for ( var i = this.items.length - 1; i >= 0; i-- )
|
1156
|
+
for ( var i = this.items.length - 1; i >= 0; i-- ) {
|
1085
1157
|
this.items[i].item.removeData(this.widgetName + "-item");
|
1158
|
+
}
|
1086
1159
|
|
1087
1160
|
return this;
|
1088
1161
|
},
|
1089
1162
|
|
1090
|
-
_setOption: function(key, value){
|
1091
|
-
if ( key === "disabled" ) {
|
1092
|
-
this.options[ key ] = value;
|
1093
|
-
|
1094
|
-
this.widget().toggleClass( "ui-sortable-disabled", !!value );
|
1095
|
-
} else {
|
1096
|
-
// Don't call widget base _setOption for disable as it adds ui-state-disabled class
|
1097
|
-
$.Widget.prototype._setOption.apply(this, arguments);
|
1098
|
-
}
|
1099
|
-
},
|
1100
|
-
|
1101
1163
|
_mouseCapture: function(event, overrideHandle) {
|
1102
|
-
var
|
1164
|
+
var currentItem = null,
|
1165
|
+
validHandle = false,
|
1166
|
+
that = this;
|
1103
1167
|
|
1104
1168
|
if (this.reverting) {
|
1105
1169
|
return false;
|
1106
1170
|
}
|
1107
1171
|
|
1108
|
-
if(this.options.disabled || this.options.type
|
1172
|
+
if(this.options.disabled || this.options.type === "static") {
|
1173
|
+
return false;
|
1174
|
+
}
|
1109
1175
|
|
1110
1176
|
//We have to refresh the items data once first
|
1111
1177
|
this._refreshItems(event);
|
1112
1178
|
|
1113
1179
|
//Find out if the clicked node (or one of its parents) is a actual item in this.items
|
1114
|
-
|
1115
|
-
if($.data(this, that.widgetName +
|
1180
|
+
$(event.target).parents().each(function() {
|
1181
|
+
if($.data(this, that.widgetName + "-item") === that) {
|
1116
1182
|
currentItem = $(this);
|
1117
1183
|
return false;
|
1118
1184
|
}
|
1119
1185
|
});
|
1120
|
-
if($.data(event.target, that.widgetName +
|
1186
|
+
if($.data(event.target, that.widgetName + "-item") === that) {
|
1187
|
+
currentItem = $(event.target);
|
1188
|
+
}
|
1121
1189
|
|
1122
|
-
if(!currentItem)
|
1190
|
+
if(!currentItem) {
|
1191
|
+
return false;
|
1192
|
+
}
|
1123
1193
|
if(this.options.handle && !overrideHandle) {
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1194
|
+
$(this.options.handle, currentItem).find("*").addBack().each(function() {
|
1195
|
+
if(this === event.target) {
|
1196
|
+
validHandle = true;
|
1197
|
+
}
|
1198
|
+
});
|
1199
|
+
if(!validHandle) {
|
1200
|
+
return false;
|
1201
|
+
}
|
1128
1202
|
}
|
1129
1203
|
|
1130
1204
|
this.currentItem = currentItem;
|
@@ -1135,7 +1209,9 @@ $.widget("ui.sortable", $.ui.mouse, {
|
|
1135
1209
|
|
1136
1210
|
_mouseStart: function(event, overrideHandle, noActivation) {
|
1137
1211
|
|
1138
|
-
var
|
1212
|
+
var i, body,
|
1213
|
+
o = this.options;
|
1214
|
+
|
1139
1215
|
this.currentContainer = this;
|
1140
1216
|
|
1141
1217
|
//We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
|
@@ -1184,14 +1260,14 @@ $.widget("ui.sortable", $.ui.mouse, {
|
|
1184
1260
|
this.originalPageX = event.pageX;
|
1185
1261
|
this.originalPageY = event.pageY;
|
1186
1262
|
|
1187
|
-
//Adjust the mouse offset relative to the helper if
|
1263
|
+
//Adjust the mouse offset relative to the helper if "cursorAt" is supplied
|
1188
1264
|
(o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
|
1189
1265
|
|
1190
1266
|
//Cache the former DOM position
|
1191
1267
|
this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
|
1192
1268
|
|
1193
1269
|
//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
|
1194
|
-
if(this.helper[0]
|
1270
|
+
if(this.helper[0] !== this.currentItem[0]) {
|
1195
1271
|
this.currentItem.hide();
|
1196
1272
|
}
|
1197
1273
|
|
@@ -1199,47 +1275,63 @@ $.widget("ui.sortable", $.ui.mouse, {
|
|
1199
1275
|
this._createPlaceholder();
|
1200
1276
|
|
1201
1277
|
//Set a containment if given in the options
|
1202
|
-
if(o.containment)
|
1278
|
+
if(o.containment) {
|
1203
1279
|
this._setContainment();
|
1280
|
+
}
|
1281
|
+
|
1282
|
+
if( o.cursor && o.cursor !== "auto" ) { // cursor option
|
1283
|
+
body = this.document.find( "body" );
|
1284
|
+
|
1285
|
+
// support: IE
|
1286
|
+
this.storedCursor = body.css( "cursor" );
|
1287
|
+
body.css( "cursor", o.cursor );
|
1204
1288
|
|
1205
|
-
|
1206
|
-
if ($('body').css("cursor")) this._storedCursor = $('body').css("cursor");
|
1207
|
-
$('body').css("cursor", o.cursor);
|
1289
|
+
this.storedStylesheet = $( "<style>*{ cursor: "+o.cursor+" !important; }</style>" ).appendTo( body );
|
1208
1290
|
}
|
1209
1291
|
|
1210
1292
|
if(o.opacity) { // opacity option
|
1211
|
-
if (this.helper.css("opacity"))
|
1293
|
+
if (this.helper.css("opacity")) {
|
1294
|
+
this._storedOpacity = this.helper.css("opacity");
|
1295
|
+
}
|
1212
1296
|
this.helper.css("opacity", o.opacity);
|
1213
1297
|
}
|
1214
1298
|
|
1215
1299
|
if(o.zIndex) { // zIndex option
|
1216
|
-
if (this.helper.css("zIndex"))
|
1300
|
+
if (this.helper.css("zIndex")) {
|
1301
|
+
this._storedZIndex = this.helper.css("zIndex");
|
1302
|
+
}
|
1217
1303
|
this.helper.css("zIndex", o.zIndex);
|
1218
1304
|
}
|
1219
1305
|
|
1220
1306
|
//Prepare scrolling
|
1221
|
-
if(this.scrollParent[0]
|
1307
|
+
if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
|
1222
1308
|
this.overflowOffset = this.scrollParent.offset();
|
1309
|
+
}
|
1223
1310
|
|
1224
1311
|
//Call callbacks
|
1225
1312
|
this._trigger("start", event, this._uiHash());
|
1226
1313
|
|
1227
1314
|
//Recache the helper size
|
1228
|
-
if(!this._preserveHelperProportions)
|
1315
|
+
if(!this._preserveHelperProportions) {
|
1229
1316
|
this._cacheHelperProportions();
|
1317
|
+
}
|
1230
1318
|
|
1231
1319
|
|
1232
|
-
//Post
|
1233
|
-
if(!noActivation) {
|
1234
|
-
|
1320
|
+
//Post "activate" events to possible containers
|
1321
|
+
if( !noActivation ) {
|
1322
|
+
for ( i = this.containers.length - 1; i >= 0; i-- ) {
|
1323
|
+
this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
|
1324
|
+
}
|
1235
1325
|
}
|
1236
1326
|
|
1237
1327
|
//Prepare possible droppables
|
1238
|
-
if($.ui.ddmanager)
|
1328
|
+
if($.ui.ddmanager) {
|
1239
1329
|
$.ui.ddmanager.current = this;
|
1330
|
+
}
|
1240
1331
|
|
1241
|
-
if ($.ui.ddmanager && !o.dropBehaviour)
|
1332
|
+
if ($.ui.ddmanager && !o.dropBehaviour) {
|
1242
1333
|
$.ui.ddmanager.prepareOffsets(this, event);
|
1334
|
+
}
|
1243
1335
|
|
1244
1336
|
this.dragging = true;
|
1245
1337
|
|
@@ -1250,6 +1342,9 @@ $.widget("ui.sortable", $.ui.mouse, {
|
|
1250
1342
|
},
|
1251
1343
|
|
1252
1344
|
_mouseDrag: function(event) {
|
1345
|
+
var i, item, itemElement, intersection,
|
1346
|
+
o = this.options,
|
1347
|
+
scrolled = false;
|
1253
1348
|
|
1254
1349
|
//Compute the helpers position
|
1255
1350
|
this.position = this._generatePosition(event);
|
@@ -1261,70 +1356,86 @@ $.widget("ui.sortable", $.ui.mouse, {
|
|
1261
1356
|
|
1262
1357
|
//Do scrolling
|
1263
1358
|
if(this.options.scroll) {
|
1264
|
-
|
1265
|
-
if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML') {
|
1359
|
+
if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
|
1266
1360
|
|
1267
|
-
if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
|
1361
|
+
if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
|
1268
1362
|
this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
|
1269
|
-
else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity)
|
1363
|
+
} else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) {
|
1270
1364
|
this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
|
1365
|
+
}
|
1271
1366
|
|
1272
|
-
if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
|
1367
|
+
if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
|
1273
1368
|
this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
|
1274
|
-
else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity)
|
1369
|
+
} else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) {
|
1275
1370
|
this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
|
1371
|
+
}
|
1276
1372
|
|
1277
1373
|
} else {
|
1278
1374
|
|
1279
|
-
if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
|
1375
|
+
if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
|
1280
1376
|
scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
|
1281
|
-
else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
|
1377
|
+
} else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
|
1282
1378
|
scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
|
1379
|
+
}
|
1283
1380
|
|
1284
|
-
if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
|
1381
|
+
if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
|
1285
1382
|
scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
|
1286
|
-
else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
|
1383
|
+
} else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
|
1287
1384
|
scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
|
1385
|
+
}
|
1288
1386
|
|
1289
1387
|
}
|
1290
1388
|
|
1291
|
-
if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
|
1389
|
+
if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
|
1292
1390
|
$.ui.ddmanager.prepareOffsets(this, event);
|
1391
|
+
}
|
1293
1392
|
}
|
1294
1393
|
|
1295
1394
|
//Regenerate the absolute position used for position checks
|
1296
1395
|
this.positionAbs = this._convertPositionTo("absolute");
|
1297
1396
|
|
1298
1397
|
//Set the helper position
|
1299
|
-
if(!this.options.axis || this.options.axis
|
1300
|
-
|
1398
|
+
if(!this.options.axis || this.options.axis !== "y") {
|
1399
|
+
this.helper[0].style.left = this.position.left+"px";
|
1400
|
+
}
|
1401
|
+
if(!this.options.axis || this.options.axis !== "x") {
|
1402
|
+
this.helper[0].style.top = this.position.top+"px";
|
1403
|
+
}
|
1301
1404
|
|
1302
1405
|
//Rearrange
|
1303
|
-
for (
|
1406
|
+
for (i = this.items.length - 1; i >= 0; i--) {
|
1304
1407
|
|
1305
1408
|
//Cache variables and intersection, continue if no intersection
|
1306
|
-
|
1307
|
-
|
1409
|
+
item = this.items[i];
|
1410
|
+
itemElement = item.item[0];
|
1411
|
+
intersection = this._intersectsWithPointer(item);
|
1412
|
+
if (!intersection) {
|
1413
|
+
continue;
|
1414
|
+
}
|
1308
1415
|
|
1309
1416
|
// Only put the placeholder inside the current Container, skip all
|
1310
|
-
// items
|
1417
|
+
// items from other containers. This works because when moving
|
1311
1418
|
// an item from one container to another the
|
1312
1419
|
// currentContainer is switched before the placeholder is moved.
|
1313
1420
|
//
|
1314
|
-
// Without this moving items in "sub-sortables" can cause
|
1315
|
-
//
|
1316
|
-
if (item.instance !== this.currentContainer)
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1421
|
+
// Without this, moving items in "sub-sortables" can cause
|
1422
|
+
// the placeholder to jitter between the outer and inner container.
|
1423
|
+
if (item.instance !== this.currentContainer) {
|
1424
|
+
continue;
|
1425
|
+
}
|
1426
|
+
|
1427
|
+
// cannot intersect with itself
|
1428
|
+
// no useless actions that have been done before
|
1429
|
+
// no action if the item moved is the parent of the item checked
|
1430
|
+
if (itemElement !== this.currentItem[0] &&
|
1431
|
+
this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement &&
|
1432
|
+
!$.contains(this.placeholder[0], itemElement) &&
|
1433
|
+
(this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true)
|
1323
1434
|
) {
|
1324
1435
|
|
1325
|
-
this.direction = intersection
|
1436
|
+
this.direction = intersection === 1 ? "down" : "up";
|
1326
1437
|
|
1327
|
-
if (this.options.tolerance
|
1438
|
+
if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) {
|
1328
1439
|
this._rearrange(event, item);
|
1329
1440
|
} else {
|
1330
1441
|
break;
|
@@ -1339,10 +1450,12 @@ $.widget("ui.sortable", $.ui.mouse, {
|
|
1339
1450
|
this._contactContainers(event);
|
1340
1451
|
|
1341
1452
|
//Interconnect with droppables
|
1342
|
-
if($.ui.ddmanager)
|
1453
|
+
if($.ui.ddmanager) {
|
1454
|
+
$.ui.ddmanager.drag(this, event);
|
1455
|
+
}
|
1343
1456
|
|
1344
1457
|
//Call callbacks
|
1345
|
-
this._trigger(
|
1458
|
+
this._trigger("sort", event, this._uiHash());
|
1346
1459
|
|
1347
1460
|
this.lastPositionAbs = this.positionAbs;
|
1348
1461
|
return false;
|
@@ -1351,22 +1464,29 @@ $.widget("ui.sortable", $.ui.mouse, {
|
|
1351
1464
|
|
1352
1465
|
_mouseStop: function(event, noPropagation) {
|
1353
1466
|
|
1354
|
-
if(!event)
|
1467
|
+
if(!event) {
|
1468
|
+
return;
|
1469
|
+
}
|
1355
1470
|
|
1356
1471
|
//If we are using droppables, inform the manager about the drop
|
1357
|
-
if ($.ui.ddmanager && !this.options.dropBehaviour)
|
1472
|
+
if ($.ui.ddmanager && !this.options.dropBehaviour) {
|
1358
1473
|
$.ui.ddmanager.drop(this, event);
|
1474
|
+
}
|
1359
1475
|
|
1360
1476
|
if(this.options.revert) {
|
1361
|
-
var that = this
|
1362
|
-
|
1477
|
+
var that = this,
|
1478
|
+
cur = this.placeholder.offset(),
|
1479
|
+
axis = this.options.axis,
|
1480
|
+
animation = {};
|
1363
1481
|
|
1482
|
+
if ( !axis || axis === "x" ) {
|
1483
|
+
animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft);
|
1484
|
+
}
|
1485
|
+
if ( !axis || axis === "y" ) {
|
1486
|
+
animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop);
|
1487
|
+
}
|
1364
1488
|
this.reverting = true;
|
1365
|
-
|
1366
|
-
$(this.helper).animate({
|
1367
|
-
left: cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft),
|
1368
|
-
top: cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop)
|
1369
|
-
}, parseInt(this.options.revert, 10) || 500, function() {
|
1489
|
+
$(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() {
|
1370
1490
|
that._clear(event);
|
1371
1491
|
});
|
1372
1492
|
} else {
|
@@ -1383,10 +1503,11 @@ $.widget("ui.sortable", $.ui.mouse, {
|
|
1383
1503
|
|
1384
1504
|
this._mouseUp({ target: null });
|
1385
1505
|
|
1386
|
-
if(this.options.helper
|
1506
|
+
if(this.options.helper === "original") {
|
1387
1507
|
this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
|
1388
|
-
else
|
1508
|
+
} else {
|
1389
1509
|
this.currentItem.show();
|
1510
|
+
}
|
1390
1511
|
|
1391
1512
|
//Post deactivating events to containers
|
1392
1513
|
for (var i = this.containers.length - 1; i >= 0; i--){
|
@@ -1401,8 +1522,12 @@ $.widget("ui.sortable", $.ui.mouse, {
|
|
1401
1522
|
|
1402
1523
|
if (this.placeholder) {
|
1403
1524
|
//$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
|
1404
|
-
if(this.placeholder[0].parentNode)
|
1405
|
-
|
1525
|
+
if(this.placeholder[0].parentNode) {
|
1526
|
+
this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
|
1527
|
+
}
|
1528
|
+
if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) {
|
1529
|
+
this.helper.remove();
|
1530
|
+
}
|
1406
1531
|
|
1407
1532
|
$.extend(this, {
|
1408
1533
|
helper: null,
|
@@ -1424,28 +1549,33 @@ $.widget("ui.sortable", $.ui.mouse, {
|
|
1424
1549
|
|
1425
1550
|
serialize: function(o) {
|
1426
1551
|
|
1427
|
-
var items = this._getItemsAsjQuery(o && o.connected)
|
1428
|
-
|
1552
|
+
var items = this._getItemsAsjQuery(o && o.connected),
|
1553
|
+
str = [];
|
1554
|
+
o = o || {};
|
1429
1555
|
|
1430
1556
|
$(items).each(function() {
|
1431
|
-
var res = ($(o.item || this).attr(o.attribute ||
|
1432
|
-
if
|
1557
|
+
var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/));
|
1558
|
+
if (res) {
|
1559
|
+
str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2]));
|
1560
|
+
}
|
1433
1561
|
});
|
1434
1562
|
|
1435
1563
|
if(!str.length && o.key) {
|
1436
|
-
str.push(o.key +
|
1564
|
+
str.push(o.key + "=");
|
1437
1565
|
}
|
1438
1566
|
|
1439
|
-
return str.join(
|
1567
|
+
return str.join("&");
|
1440
1568
|
|
1441
1569
|
},
|
1442
1570
|
|
1443
1571
|
toArray: function(o) {
|
1444
1572
|
|
1445
|
-
var items = this._getItemsAsjQuery(o && o.connected)
|
1446
|
-
|
1573
|
+
var items = this._getItemsAsjQuery(o && o.connected),
|
1574
|
+
ret = [];
|
1447
1575
|
|
1448
|
-
|
1576
|
+
o = o || {};
|
1577
|
+
|
1578
|
+
items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); });
|
1449
1579
|
return ret;
|
1450
1580
|
|
1451
1581
|
},
|
@@ -1456,113 +1586,114 @@ $.widget("ui.sortable", $.ui.mouse, {
|
|
1456
1586
|
var x1 = this.positionAbs.left,
|
1457
1587
|
x2 = x1 + this.helperProportions.width,
|
1458
1588
|
y1 = this.positionAbs.top,
|
1459
|
-
y2 = y1 + this.helperProportions.height
|
1460
|
-
|
1461
|
-
var l = item.left,
|
1589
|
+
y2 = y1 + this.helperProportions.height,
|
1590
|
+
l = item.left,
|
1462
1591
|
r = l + item.width,
|
1463
1592
|
t = item.top,
|
1464
|
-
b = t + item.height
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
if(
|
1472
|
-
|
1473
|
-
|
1593
|
+
b = t + item.height,
|
1594
|
+
dyClick = this.offset.click.top,
|
1595
|
+
dxClick = this.offset.click.left,
|
1596
|
+
isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ),
|
1597
|
+
isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ),
|
1598
|
+
isOverElement = isOverElementHeight && isOverElementWidth;
|
1599
|
+
|
1600
|
+
if ( this.options.tolerance === "pointer" ||
|
1601
|
+
this.options.forcePointerForContainers ||
|
1602
|
+
(this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"])
|
1474
1603
|
) {
|
1475
1604
|
return isOverElement;
|
1476
1605
|
} else {
|
1477
1606
|
|
1478
|
-
return (l < x1 + (this.helperProportions.width / 2) // Right Half
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
1607
|
+
return (l < x1 + (this.helperProportions.width / 2) && // Right Half
|
1608
|
+
x2 - (this.helperProportions.width / 2) < r && // Left Half
|
1609
|
+
t < y1 + (this.helperProportions.height / 2) && // Bottom Half
|
1610
|
+
y2 - (this.helperProportions.height / 2) < b ); // Top Half
|
1482
1611
|
|
1483
1612
|
}
|
1484
1613
|
},
|
1485
1614
|
|
1486
1615
|
_intersectsWithPointer: function(item) {
|
1487
1616
|
|
1488
|
-
var isOverElementHeight = (this.options.axis ===
|
1489
|
-
isOverElementWidth = (this.options.axis ===
|
1617
|
+
var isOverElementHeight = (this.options.axis === "x") || this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
|
1618
|
+
isOverElementWidth = (this.options.axis === "y") || this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
|
1490
1619
|
isOverElement = isOverElementHeight && isOverElementWidth,
|
1491
1620
|
verticalDirection = this._getDragVerticalDirection(),
|
1492
1621
|
horizontalDirection = this._getDragHorizontalDirection();
|
1493
1622
|
|
1494
|
-
if (!isOverElement)
|
1623
|
+
if (!isOverElement) {
|
1495
1624
|
return false;
|
1625
|
+
}
|
1496
1626
|
|
1497
1627
|
return this.floating ?
|
1498
|
-
( ((horizontalDirection && horizontalDirection
|
1499
|
-
: ( verticalDirection && (verticalDirection
|
1628
|
+
( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 )
|
1629
|
+
: ( verticalDirection && (verticalDirection === "down" ? 2 : 1) );
|
1500
1630
|
|
1501
1631
|
},
|
1502
1632
|
|
1503
1633
|
_intersectsWithSides: function(item) {
|
1504
1634
|
|
1505
|
-
var isOverBottomHalf =
|
1506
|
-
isOverRightHalf =
|
1635
|
+
var isOverBottomHalf = this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
|
1636
|
+
isOverRightHalf = this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
|
1507
1637
|
verticalDirection = this._getDragVerticalDirection(),
|
1508
1638
|
horizontalDirection = this._getDragHorizontalDirection();
|
1509
1639
|
|
1510
1640
|
if (this.floating && horizontalDirection) {
|
1511
|
-
return ((horizontalDirection
|
1641
|
+
return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf));
|
1512
1642
|
} else {
|
1513
|
-
return verticalDirection && ((verticalDirection
|
1643
|
+
return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf));
|
1514
1644
|
}
|
1515
1645
|
|
1516
1646
|
},
|
1517
1647
|
|
1518
1648
|
_getDragVerticalDirection: function() {
|
1519
1649
|
var delta = this.positionAbs.top - this.lastPositionAbs.top;
|
1520
|
-
return delta
|
1650
|
+
return delta !== 0 && (delta > 0 ? "down" : "up");
|
1521
1651
|
},
|
1522
1652
|
|
1523
1653
|
_getDragHorizontalDirection: function() {
|
1524
1654
|
var delta = this.positionAbs.left - this.lastPositionAbs.left;
|
1525
|
-
return delta
|
1655
|
+
return delta !== 0 && (delta > 0 ? "right" : "left");
|
1526
1656
|
},
|
1527
1657
|
|
1528
1658
|
refresh: function(event) {
|
1529
1659
|
this._refreshItems(event);
|
1660
|
+
this._setHandleClassName();
|
1530
1661
|
this.refreshPositions();
|
1531
1662
|
return this;
|
1532
1663
|
},
|
1533
1664
|
|
1534
1665
|
_connectWith: function() {
|
1535
1666
|
var options = this.options;
|
1536
|
-
return options.connectWith.constructor
|
1537
|
-
? [options.connectWith]
|
1538
|
-
: options.connectWith;
|
1667
|
+
return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith;
|
1539
1668
|
},
|
1540
1669
|
|
1541
1670
|
_getItemsAsjQuery: function(connected) {
|
1542
1671
|
|
1543
|
-
var
|
1544
|
-
|
1545
|
-
|
1672
|
+
var i, j, cur, inst,
|
1673
|
+
items = [],
|
1674
|
+
queries = [],
|
1675
|
+
connectWith = this._connectWith();
|
1546
1676
|
|
1547
1677
|
if(connectWith && connected) {
|
1548
|
-
for (
|
1549
|
-
|
1550
|
-
for (
|
1551
|
-
|
1552
|
-
if(inst && inst
|
1553
|
-
queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not(".ui-sortable-helper").not(
|
1678
|
+
for (i = connectWith.length - 1; i >= 0; i--){
|
1679
|
+
cur = $(connectWith[i]);
|
1680
|
+
for ( j = cur.length - 1; j >= 0; j--){
|
1681
|
+
inst = $.data(cur[j], this.widgetFullName);
|
1682
|
+
if(inst && inst !== this && !inst.options.disabled) {
|
1683
|
+
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]);
|
1554
1684
|
}
|
1555
|
-
}
|
1556
|
-
}
|
1685
|
+
}
|
1686
|
+
}
|
1557
1687
|
}
|
1558
1688
|
|
1559
|
-
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(
|
1689
|
+
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]);
|
1560
1690
|
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1565
|
-
|
1691
|
+
function addItems() {
|
1692
|
+
items.push( this );
|
1693
|
+
}
|
1694
|
+
for (i = queries.length - 1; i >= 0; i--){
|
1695
|
+
queries[i][0].each( addItems );
|
1696
|
+
}
|
1566
1697
|
|
1567
1698
|
return $(items);
|
1568
1699
|
|
@@ -1574,9 +1705,10 @@ $.widget("ui.sortable", $.ui.mouse, {
|
|
1574
1705
|
|
1575
1706
|
this.items = $.grep(this.items, function (item) {
|
1576
1707
|
for (var j=0; j < list.length; j++) {
|
1577
|
-
if(list[j]
|
1708
|
+
if(list[j] === item.item[0]) {
|
1578
1709
|
return false;
|
1579
|
-
|
1710
|
+
}
|
1711
|
+
}
|
1580
1712
|
return true;
|
1581
1713
|
});
|
1582
1714
|
|
@@ -1586,31 +1718,33 @@ $.widget("ui.sortable", $.ui.mouse, {
|
|
1586
1718
|
|
1587
1719
|
this.items = [];
|
1588
1720
|
this.containers = [this];
|
1589
|
-
|
1590
|
-
var
|
1591
|
-
|
1721
|
+
|
1722
|
+
var i, j, cur, inst, targetData, _queries, item, queriesLength,
|
1723
|
+
items = this.items,
|
1724
|
+
queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]],
|
1725
|
+
connectWith = this._connectWith();
|
1592
1726
|
|
1593
1727
|
if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
|
1594
|
-
for (
|
1595
|
-
|
1596
|
-
for (
|
1597
|
-
|
1598
|
-
if(inst && inst
|
1728
|
+
for (i = connectWith.length - 1; i >= 0; i--){
|
1729
|
+
cur = $(connectWith[i]);
|
1730
|
+
for (j = cur.length - 1; j >= 0; j--){
|
1731
|
+
inst = $.data(cur[j], this.widgetFullName);
|
1732
|
+
if(inst && inst !== this && !inst.options.disabled) {
|
1599
1733
|
queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
|
1600
1734
|
this.containers.push(inst);
|
1601
1735
|
}
|
1602
|
-
}
|
1603
|
-
}
|
1736
|
+
}
|
1737
|
+
}
|
1604
1738
|
}
|
1605
1739
|
|
1606
|
-
for (
|
1607
|
-
|
1608
|
-
|
1740
|
+
for (i = queries.length - 1; i >= 0; i--) {
|
1741
|
+
targetData = queries[i][1];
|
1742
|
+
_queries = queries[i][0];
|
1609
1743
|
|
1610
|
-
for (
|
1611
|
-
|
1744
|
+
for (j=0, queriesLength = _queries.length; j < queriesLength; j++) {
|
1745
|
+
item = $(_queries[j]);
|
1612
1746
|
|
1613
|
-
item.data(this.widgetName +
|
1747
|
+
item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager)
|
1614
1748
|
|
1615
1749
|
items.push({
|
1616
1750
|
item: item,
|
@@ -1618,8 +1752,8 @@ $.widget("ui.sortable", $.ui.mouse, {
|
|
1618
1752
|
width: 0, height: 0,
|
1619
1753
|
left: 0, top: 0
|
1620
1754
|
});
|
1621
|
-
}
|
1622
|
-
}
|
1755
|
+
}
|
1756
|
+
}
|
1623
1757
|
|
1624
1758
|
},
|
1625
1759
|
|
@@ -1630,35 +1764,38 @@ $.widget("ui.sortable", $.ui.mouse, {
|
|
1630
1764
|
this.offset.parent = this._getParentOffset();
|
1631
1765
|
}
|
1632
1766
|
|
1633
|
-
|
1634
|
-
|
1767
|
+
var i, item, t, p;
|
1768
|
+
|
1769
|
+
for (i = this.items.length - 1; i >= 0; i--){
|
1770
|
+
item = this.items[i];
|
1635
1771
|
|
1636
1772
|
//We ignore calculating positions of all connected containers when we're not over them
|
1637
|
-
if(item.instance
|
1773
|
+
if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) {
|
1638
1774
|
continue;
|
1775
|
+
}
|
1639
1776
|
|
1640
|
-
|
1777
|
+
t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
|
1641
1778
|
|
1642
1779
|
if (!fast) {
|
1643
1780
|
item.width = t.outerWidth();
|
1644
1781
|
item.height = t.outerHeight();
|
1645
1782
|
}
|
1646
1783
|
|
1647
|
-
|
1784
|
+
p = t.offset();
|
1648
1785
|
item.left = p.left;
|
1649
1786
|
item.top = p.top;
|
1650
|
-
}
|
1787
|
+
}
|
1651
1788
|
|
1652
1789
|
if(this.options.custom && this.options.custom.refreshContainers) {
|
1653
1790
|
this.options.custom.refreshContainers.call(this);
|
1654
1791
|
} else {
|
1655
|
-
for (
|
1656
|
-
|
1792
|
+
for (i = this.containers.length - 1; i >= 0; i--){
|
1793
|
+
p = this.containers[i].element.offset();
|
1657
1794
|
this.containers[i].containerCache.left = p.left;
|
1658
1795
|
this.containers[i].containerCache.top = p.top;
|
1659
|
-
this.containers[i].containerCache.width
|
1796
|
+
this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
|
1660
1797
|
this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
|
1661
|
-
}
|
1798
|
+
}
|
1662
1799
|
}
|
1663
1800
|
|
1664
1801
|
return this;
|
@@ -1666,31 +1803,46 @@ $.widget("ui.sortable", $.ui.mouse, {
|
|
1666
1803
|
|
1667
1804
|
_createPlaceholder: function(that) {
|
1668
1805
|
that = that || this;
|
1669
|
-
var
|
1806
|
+
var className,
|
1807
|
+
o = that.options;
|
1670
1808
|
|
1671
|
-
if(!o.placeholder || o.placeholder.constructor
|
1672
|
-
|
1809
|
+
if(!o.placeholder || o.placeholder.constructor === String) {
|
1810
|
+
className = o.placeholder;
|
1673
1811
|
o.placeholder = {
|
1674
1812
|
element: function() {
|
1675
1813
|
|
1676
|
-
var
|
1677
|
-
|
1678
|
-
|
1814
|
+
var nodeName = that.currentItem[0].nodeName.toLowerCase(),
|
1815
|
+
element = $( "<" + nodeName + ">", that.document[0] )
|
1816
|
+
.addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
|
1817
|
+
.removeClass("ui-sortable-helper");
|
1818
|
+
|
1819
|
+
if ( nodeName === "tr" ) {
|
1820
|
+
that.currentItem.children().each(function() {
|
1821
|
+
$( "<td> </td>", that.document[0] )
|
1822
|
+
.attr( "colspan", $( this ).attr( "colspan" ) || 1 )
|
1823
|
+
.appendTo( element );
|
1824
|
+
});
|
1825
|
+
} else if ( nodeName === "img" ) {
|
1826
|
+
element.attr( "src", that.currentItem.attr( "src" ) );
|
1827
|
+
}
|
1679
1828
|
|
1680
|
-
if(!className)
|
1681
|
-
|
1829
|
+
if ( !className ) {
|
1830
|
+
element.css( "visibility", "hidden" );
|
1831
|
+
}
|
1682
1832
|
|
1683
|
-
return
|
1833
|
+
return element;
|
1684
1834
|
},
|
1685
1835
|
update: function(container, p) {
|
1686
1836
|
|
1687
1837
|
// 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
|
1688
1838
|
// 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
|
1689
|
-
if(className && !o.forcePlaceholderSize)
|
1839
|
+
if(className && !o.forcePlaceholderSize) {
|
1840
|
+
return;
|
1841
|
+
}
|
1690
1842
|
|
1691
1843
|
//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
|
1692
|
-
if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css(
|
1693
|
-
if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css(
|
1844
|
+
if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); }
|
1845
|
+
if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); }
|
1694
1846
|
}
|
1695
1847
|
};
|
1696
1848
|
}
|
@@ -1707,22 +1859,24 @@ $.widget("ui.sortable", $.ui.mouse, {
|
|
1707
1859
|
},
|
1708
1860
|
|
1709
1861
|
_contactContainers: function(event) {
|
1862
|
+
var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom, floating, axis,
|
1863
|
+
innermostContainer = null,
|
1864
|
+
innermostIndex = null;
|
1710
1865
|
|
1711
1866
|
// get innermost container that intersects with item
|
1712
|
-
|
1713
|
-
|
1714
|
-
|
1715
|
-
for (var i = this.containers.length - 1; i >= 0; i--){
|
1867
|
+
for (i = this.containers.length - 1; i >= 0; i--) {
|
1716
1868
|
|
1717
1869
|
// never consider a container that's located within the item itself
|
1718
|
-
if($.contains(this.currentItem[0], this.containers[i].element[0]))
|
1870
|
+
if($.contains(this.currentItem[0], this.containers[i].element[0])) {
|
1719
1871
|
continue;
|
1872
|
+
}
|
1720
1873
|
|
1721
1874
|
if(this._intersectsWith(this.containers[i].containerCache)) {
|
1722
1875
|
|
1723
1876
|
// if we've already found a container and it's more "inner" than this, then continue
|
1724
|
-
if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0]))
|
1877
|
+
if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) {
|
1725
1878
|
continue;
|
1879
|
+
}
|
1726
1880
|
|
1727
1881
|
innermostContainer = this.containers[i];
|
1728
1882
|
innermostIndex = i;
|
@@ -1738,42 +1892,64 @@ $.widget("ui.sortable", $.ui.mouse, {
|
|
1738
1892
|
}
|
1739
1893
|
|
1740
1894
|
// if no intersecting containers found, return
|
1741
|
-
if(!innermostContainer)
|
1895
|
+
if(!innermostContainer) {
|
1896
|
+
return;
|
1897
|
+
}
|
1742
1898
|
|
1743
1899
|
// move the item into the container if it's not there already
|
1744
1900
|
if(this.containers.length === 1) {
|
1745
|
-
this.containers[innermostIndex].
|
1746
|
-
|
1901
|
+
if (!this.containers[innermostIndex].containerCache.over) {
|
1902
|
+
this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
|
1903
|
+
this.containers[innermostIndex].containerCache.over = 1;
|
1904
|
+
}
|
1747
1905
|
} else {
|
1748
1906
|
|
1749
1907
|
//When entering a new container, we will find the item with the least distance and append our item near it
|
1750
|
-
|
1751
|
-
|
1752
|
-
|
1753
|
-
|
1754
|
-
|
1755
|
-
|
1756
|
-
|
1757
|
-
|
1758
|
-
|
1759
|
-
|
1908
|
+
dist = 10000;
|
1909
|
+
itemWithLeastDistance = null;
|
1910
|
+
floating = innermostContainer.floating || this._isFloating(this.currentItem);
|
1911
|
+
posProperty = floating ? "left" : "top";
|
1912
|
+
sizeProperty = floating ? "width" : "height";
|
1913
|
+
axis = floating ? "clientX" : "clientY";
|
1914
|
+
|
1915
|
+
for (j = this.items.length - 1; j >= 0; j--) {
|
1916
|
+
if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) {
|
1917
|
+
continue;
|
1918
|
+
}
|
1919
|
+
if(this.items[j].item[0] === this.currentItem[0]) {
|
1920
|
+
continue;
|
1921
|
+
}
|
1922
|
+
|
1923
|
+
cur = this.items[j].item.offset()[posProperty];
|
1924
|
+
nearBottom = false;
|
1925
|
+
if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) {
|
1760
1926
|
nearBottom = true;
|
1761
|
-
cur += this.items[j][sizeProperty];
|
1762
1927
|
}
|
1763
1928
|
|
1764
|
-
if(Math.abs(
|
1765
|
-
dist = Math.abs(
|
1929
|
+
if ( Math.abs( event[ axis ] - cur ) < dist ) {
|
1930
|
+
dist = Math.abs( event[ axis ] - cur );
|
1931
|
+
itemWithLeastDistance = this.items[ j ];
|
1766
1932
|
this.direction = nearBottom ? "up": "down";
|
1767
1933
|
}
|
1768
1934
|
}
|
1769
1935
|
|
1770
|
-
|
1936
|
+
//Check if dropOnEmpty is enabled
|
1937
|
+
if(!itemWithLeastDistance && !this.options.dropOnEmpty) {
|
1938
|
+
return;
|
1939
|
+
}
|
1940
|
+
|
1941
|
+
if(this.currentContainer === this.containers[innermostIndex]) {
|
1942
|
+
if ( !this.currentContainer.containerCache.over ) {
|
1943
|
+
this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash() );
|
1944
|
+
this.currentContainer.containerCache.over = 1;
|
1945
|
+
}
|
1771
1946
|
return;
|
1947
|
+
}
|
1772
1948
|
|
1773
|
-
this.currentContainer = this.containers[innermostIndex];
|
1774
1949
|
itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
|
1775
1950
|
this._trigger("change", event, this._uiHash());
|
1776
1951
|
this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
|
1952
|
+
this.currentContainer = this.containers[innermostIndex];
|
1777
1953
|
|
1778
1954
|
//Update the placeholder
|
1779
1955
|
this.options.placeholder.update(this.currentContainer, this.placeholder);
|
@@ -1787,39 +1963,46 @@ $.widget("ui.sortable", $.ui.mouse, {
|
|
1787
1963
|
|
1788
1964
|
_createHelper: function(event) {
|
1789
1965
|
|
1790
|
-
var o = this.options
|
1791
|
-
|
1966
|
+
var o = this.options,
|
1967
|
+
helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem);
|
1792
1968
|
|
1793
|
-
|
1794
|
-
|
1969
|
+
//Add the helper to the DOM if that didn't happen already
|
1970
|
+
if(!helper.parents("body").length) {
|
1971
|
+
$(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
|
1972
|
+
}
|
1795
1973
|
|
1796
|
-
if(helper[0]
|
1974
|
+
if(helper[0] === this.currentItem[0]) {
|
1797
1975
|
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") };
|
1976
|
+
}
|
1798
1977
|
|
1799
|
-
if(helper[0].style.width
|
1800
|
-
|
1978
|
+
if(!helper[0].style.width || o.forceHelperSize) {
|
1979
|
+
helper.width(this.currentItem.width());
|
1980
|
+
}
|
1981
|
+
if(!helper[0].style.height || o.forceHelperSize) {
|
1982
|
+
helper.height(this.currentItem.height());
|
1983
|
+
}
|
1801
1984
|
|
1802
1985
|
return helper;
|
1803
1986
|
|
1804
1987
|
},
|
1805
1988
|
|
1806
1989
|
_adjustOffsetFromHelper: function(obj) {
|
1807
|
-
if (typeof obj
|
1808
|
-
obj = obj.split(
|
1990
|
+
if (typeof obj === "string") {
|
1991
|
+
obj = obj.split(" ");
|
1809
1992
|
}
|
1810
1993
|
if ($.isArray(obj)) {
|
1811
1994
|
obj = {left: +obj[0], top: +obj[1] || 0};
|
1812
1995
|
}
|
1813
|
-
if (
|
1996
|
+
if ("left" in obj) {
|
1814
1997
|
this.offset.click.left = obj.left + this.margins.left;
|
1815
1998
|
}
|
1816
|
-
if (
|
1999
|
+
if ("right" in obj) {
|
1817
2000
|
this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
|
1818
2001
|
}
|
1819
|
-
if (
|
2002
|
+
if ("top" in obj) {
|
1820
2003
|
this.offset.click.top = obj.top + this.margins.top;
|
1821
2004
|
}
|
1822
|
-
if (
|
2005
|
+
if ("bottom" in obj) {
|
1823
2006
|
this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
|
1824
2007
|
}
|
1825
2008
|
},
|
@@ -1835,14 +2018,16 @@ $.widget("ui.sortable", $.ui.mouse, {
|
|
1835
2018
|
// 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
|
1836
2019
|
// 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
|
1837
2020
|
// the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
|
1838
|
-
if(this.cssPosition
|
2021
|
+
if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
|
1839
2022
|
po.left += this.scrollParent.scrollLeft();
|
1840
2023
|
po.top += this.scrollParent.scrollTop();
|
1841
2024
|
}
|
1842
2025
|
|
1843
|
-
|
1844
|
-
|
2026
|
+
// This needs to be actually done for all browsers, since pageX/pageY includes this information
|
2027
|
+
// with an ugly IE fix
|
2028
|
+
if( this.offsetParent[0] === document.body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
|
1845
2029
|
po = { top: 0, left: 0 };
|
2030
|
+
}
|
1846
2031
|
|
1847
2032
|
return {
|
1848
2033
|
top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
|
@@ -1853,7 +2038,7 @@ $.widget("ui.sortable", $.ui.mouse, {
|
|
1853
2038
|
|
1854
2039
|
_getRelativeOffset: function() {
|
1855
2040
|
|
1856
|
-
if(this.cssPosition
|
2041
|
+
if(this.cssPosition === "relative") {
|
1857
2042
|
var p = this.currentItem.position();
|
1858
2043
|
return {
|
1859
2044
|
top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
|
@@ -1881,19 +2066,24 @@ $.widget("ui.sortable", $.ui.mouse, {
|
|
1881
2066
|
|
1882
2067
|
_setContainment: function() {
|
1883
2068
|
|
1884
|
-
var
|
1885
|
-
|
1886
|
-
if(o.containment
|
1887
|
-
|
1888
|
-
|
1889
|
-
|
1890
|
-
|
1891
|
-
|
2069
|
+
var ce, co, over,
|
2070
|
+
o = this.options;
|
2071
|
+
if(o.containment === "parent") {
|
2072
|
+
o.containment = this.helper[0].parentNode;
|
2073
|
+
}
|
2074
|
+
if(o.containment === "document" || o.containment === "window") {
|
2075
|
+
this.containment = [
|
2076
|
+
0 - this.offset.relative.left - this.offset.parent.left,
|
2077
|
+
0 - this.offset.relative.top - this.offset.parent.top,
|
2078
|
+
$(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left,
|
2079
|
+
($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
|
2080
|
+
];
|
2081
|
+
}
|
1892
2082
|
|
1893
2083
|
if(!(/^(document|window|parent)$/).test(o.containment)) {
|
1894
|
-
|
1895
|
-
|
1896
|
-
|
2084
|
+
ce = $(o.containment)[0];
|
2085
|
+
co = $(o.containment).offset();
|
2086
|
+
over = ($(ce).css("overflow") !== "hidden");
|
1897
2087
|
|
1898
2088
|
this.containment = [
|
1899
2089
|
co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
|
@@ -1907,22 +2097,25 @@ $.widget("ui.sortable", $.ui.mouse, {
|
|
1907
2097
|
|
1908
2098
|
_convertPositionTo: function(d, pos) {
|
1909
2099
|
|
1910
|
-
if(!pos)
|
1911
|
-
|
1912
|
-
|
2100
|
+
if(!pos) {
|
2101
|
+
pos = this.position;
|
2102
|
+
}
|
2103
|
+
var mod = d === "absolute" ? 1 : -1,
|
2104
|
+
scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
|
2105
|
+
scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
|
1913
2106
|
|
1914
2107
|
return {
|
1915
2108
|
top: (
|
1916
|
-
pos.top
|
1917
|
-
|
1918
|
-
|
1919
|
-
|
2109
|
+
pos.top + // The absolute mouse position
|
2110
|
+
this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
|
2111
|
+
this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
|
2112
|
+
( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
|
1920
2113
|
),
|
1921
2114
|
left: (
|
1922
|
-
pos.left // The absolute mouse position
|
1923
|
-
|
1924
|
-
|
1925
|
-
|
2115
|
+
pos.left + // The absolute mouse position
|
2116
|
+
this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
|
2117
|
+
this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
|
2118
|
+
( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
|
1926
2119
|
)
|
1927
2120
|
};
|
1928
2121
|
|
@@ -1930,19 +2123,20 @@ $.widget("ui.sortable", $.ui.mouse, {
|
|
1930
2123
|
|
1931
2124
|
_generatePosition: function(event) {
|
1932
2125
|
|
1933
|
-
var
|
2126
|
+
var top, left,
|
2127
|
+
o = this.options,
|
2128
|
+
pageX = event.pageX,
|
2129
|
+
pageY = event.pageY,
|
2130
|
+
scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
|
1934
2131
|
|
1935
2132
|
// This is another very weird special case that only happens for relative elements:
|
1936
2133
|
// 1. If the css position is relative
|
1937
2134
|
// 2. and the scroll parent is the document or similar to the offset parent
|
1938
2135
|
// we have to refresh the relative offset during the scroll so there are no jumps
|
1939
|
-
if(this.cssPosition
|
2136
|
+
if(this.cssPosition === "relative" && !(this.scrollParent[0] !== document && this.scrollParent[0] !== this.offsetParent[0])) {
|
1940
2137
|
this.offset.relative = this._getRelativeOffset();
|
1941
2138
|
}
|
1942
2139
|
|
1943
|
-
var pageX = event.pageX;
|
1944
|
-
var pageY = event.pageY;
|
1945
|
-
|
1946
2140
|
/*
|
1947
2141
|
* - Position constraining -
|
1948
2142
|
* Constrain the position to a mix of grid, containment.
|
@@ -1951,36 +2145,44 @@ $.widget("ui.sortable", $.ui.mouse, {
|
|
1951
2145
|
if(this.originalPosition) { //If we are not dragging yet, we won't check for options
|
1952
2146
|
|
1953
2147
|
if(this.containment) {
|
1954
|
-
if(event.pageX - this.offset.click.left < this.containment[0])
|
1955
|
-
|
1956
|
-
|
1957
|
-
if(event.pageY - this.offset.click.top
|
2148
|
+
if(event.pageX - this.offset.click.left < this.containment[0]) {
|
2149
|
+
pageX = this.containment[0] + this.offset.click.left;
|
2150
|
+
}
|
2151
|
+
if(event.pageY - this.offset.click.top < this.containment[1]) {
|
2152
|
+
pageY = this.containment[1] + this.offset.click.top;
|
2153
|
+
}
|
2154
|
+
if(event.pageX - this.offset.click.left > this.containment[2]) {
|
2155
|
+
pageX = this.containment[2] + this.offset.click.left;
|
2156
|
+
}
|
2157
|
+
if(event.pageY - this.offset.click.top > this.containment[3]) {
|
2158
|
+
pageY = this.containment[3] + this.offset.click.top;
|
2159
|
+
}
|
1958
2160
|
}
|
1959
2161
|
|
1960
2162
|
if(o.grid) {
|
1961
|
-
|
1962
|
-
pageY = this.containment ? (
|
2163
|
+
top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
|
2164
|
+
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;
|
1963
2165
|
|
1964
|
-
|
1965
|
-
pageX = this.containment ? (
|
2166
|
+
left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
|
2167
|
+
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;
|
1966
2168
|
}
|
1967
2169
|
|
1968
2170
|
}
|
1969
2171
|
|
1970
2172
|
return {
|
1971
2173
|
top: (
|
1972
|
-
pageY // The absolute mouse position
|
1973
|
-
|
1974
|
-
|
1975
|
-
|
1976
|
-
|
2174
|
+
pageY - // The absolute mouse position
|
2175
|
+
this.offset.click.top - // Click offset (relative to the element)
|
2176
|
+
this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
|
2177
|
+
this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
|
2178
|
+
( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
|
1977
2179
|
),
|
1978
2180
|
left: (
|
1979
|
-
pageX // The absolute mouse position
|
1980
|
-
|
1981
|
-
|
1982
|
-
|
1983
|
-
|
2181
|
+
pageX - // The absolute mouse position
|
2182
|
+
this.offset.click.left - // Click offset (relative to the element)
|
2183
|
+
this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
|
2184
|
+
this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
|
2185
|
+
( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
|
1984
2186
|
)
|
1985
2187
|
};
|
1986
2188
|
|
@@ -1988,7 +2190,7 @@ $.widget("ui.sortable", $.ui.mouse, {
|
|
1988
2190
|
|
1989
2191
|
_rearrange: function(event, i, a, hardRefresh) {
|
1990
2192
|
|
1991
|
-
a ? a[0].appendChild(this.placeholder[0]) : i.item[0].parentNode.insertBefore(this.placeholder[0], (this.direction
|
2193
|
+
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));
|
1992
2194
|
|
1993
2195
|
//Various things done here to improve the performance:
|
1994
2196
|
// 1. we create a setTimeout, that calls refreshPositions
|
@@ -1999,7 +2201,9 @@ $.widget("ui.sortable", $.ui.mouse, {
|
|
1999
2201
|
var counter = this.counter;
|
2000
2202
|
|
2001
2203
|
this._delay(function() {
|
2002
|
-
if(counter
|
2204
|
+
if(counter === this.counter) {
|
2205
|
+
this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
|
2206
|
+
}
|
2003
2207
|
});
|
2004
2208
|
|
2005
2209
|
},
|
@@ -2009,24 +2213,33 @@ $.widget("ui.sortable", $.ui.mouse, {
|
|
2009
2213
|
this.reverting = false;
|
2010
2214
|
// We delay all events that have to be triggered to after the point where the placeholder has been removed and
|
2011
2215
|
// everything else normalized again
|
2012
|
-
var
|
2216
|
+
var i,
|
2217
|
+
delayedTriggers = [];
|
2013
2218
|
|
2014
2219
|
// We first have to update the dom position of the actual currentItem
|
2015
2220
|
// Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
|
2016
|
-
if(!this._noFinalSort && this.currentItem.parent().length)
|
2221
|
+
if(!this._noFinalSort && this.currentItem.parent().length) {
|
2222
|
+
this.placeholder.before(this.currentItem);
|
2223
|
+
}
|
2017
2224
|
this._noFinalSort = null;
|
2018
2225
|
|
2019
|
-
if(this.helper[0]
|
2020
|
-
for(
|
2021
|
-
if(this._storedCSS[i]
|
2226
|
+
if(this.helper[0] === this.currentItem[0]) {
|
2227
|
+
for(i in this._storedCSS) {
|
2228
|
+
if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") {
|
2229
|
+
this._storedCSS[i] = "";
|
2230
|
+
}
|
2022
2231
|
}
|
2023
2232
|
this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
|
2024
2233
|
} else {
|
2025
2234
|
this.currentItem.show();
|
2026
2235
|
}
|
2027
2236
|
|
2028
|
-
if(this.fromOutside && !noPropagation)
|
2029
|
-
|
2237
|
+
if(this.fromOutside && !noPropagation) {
|
2238
|
+
delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
|
2239
|
+
}
|
2240
|
+
if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) {
|
2241
|
+
delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
|
2242
|
+
}
|
2030
2243
|
|
2031
2244
|
// Check if the items Container has Changed and trigger appropriate
|
2032
2245
|
// events.
|
@@ -2040,45 +2253,58 @@ $.widget("ui.sortable", $.ui.mouse, {
|
|
2040
2253
|
|
2041
2254
|
|
2042
2255
|
//Post events to containers
|
2043
|
-
|
2044
|
-
|
2256
|
+
function delayEvent( type, instance, container ) {
|
2257
|
+
return function( event ) {
|
2258
|
+
container._trigger( type, event, instance._uiHash( instance ) );
|
2259
|
+
};
|
2260
|
+
}
|
2261
|
+
for (i = this.containers.length - 1; i >= 0; i--){
|
2262
|
+
if (!noPropagation) {
|
2263
|
+
delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) );
|
2264
|
+
}
|
2045
2265
|
if(this.containers[i].containerCache.over) {
|
2046
|
-
delayedTriggers.push(
|
2266
|
+
delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) );
|
2047
2267
|
this.containers[i].containerCache.over = 0;
|
2048
2268
|
}
|
2049
2269
|
}
|
2050
2270
|
|
2051
2271
|
//Do what was originally in plugins
|
2052
|
-
if
|
2053
|
-
|
2054
|
-
|
2272
|
+
if ( this.storedCursor ) {
|
2273
|
+
this.document.find( "body" ).css( "cursor", this.storedCursor );
|
2274
|
+
this.storedStylesheet.remove();
|
2275
|
+
}
|
2276
|
+
if(this._storedOpacity) {
|
2277
|
+
this.helper.css("opacity", this._storedOpacity);
|
2278
|
+
}
|
2279
|
+
if(this._storedZIndex) {
|
2280
|
+
this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex);
|
2281
|
+
}
|
2055
2282
|
|
2056
2283
|
this.dragging = false;
|
2057
|
-
if(this.cancelHelperRemoval) {
|
2058
|
-
if(!noPropagation) {
|
2059
|
-
this._trigger("beforeStop", event, this._uiHash());
|
2060
|
-
for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events
|
2061
|
-
this._trigger("stop", event, this._uiHash());
|
2062
|
-
}
|
2063
2284
|
|
2064
|
-
|
2065
|
-
|
2285
|
+
if(!noPropagation) {
|
2286
|
+
this._trigger("beforeStop", event, this._uiHash());
|
2066
2287
|
}
|
2067
2288
|
|
2068
|
-
if(!noPropagation) this._trigger("beforeStop", event, this._uiHash());
|
2069
|
-
|
2070
2289
|
//$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
|
2071
2290
|
this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
|
2072
2291
|
|
2073
|
-
if(
|
2292
|
+
if ( !this.cancelHelperRemoval ) {
|
2293
|
+
if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
|
2294
|
+
this.helper.remove();
|
2295
|
+
}
|
2296
|
+
this.helper = null;
|
2297
|
+
}
|
2074
2298
|
|
2075
2299
|
if(!noPropagation) {
|
2076
|
-
for (
|
2300
|
+
for (i=0; i < delayedTriggers.length; i++) {
|
2301
|
+
delayedTriggers[i].call(this, event);
|
2302
|
+
} //Trigger all delayed events
|
2077
2303
|
this._trigger("stop", event, this._uiHash());
|
2078
2304
|
}
|
2079
2305
|
|
2080
2306
|
this.fromOutside = false;
|
2081
|
-
return
|
2307
|
+
return !this.cancelHelperRemoval;
|
2082
2308
|
|
2083
2309
|
},
|
2084
2310
|
|
@@ -2103,4 +2329,6 @@ $.widget("ui.sortable", $.ui.mouse, {
|
|
2103
2329
|
|
2104
2330
|
});
|
2105
2331
|
|
2106
|
-
|
2332
|
+
|
2333
|
+
|
2334
|
+
}));
|