Skip to content

Commit 34c28dc

Browse files
Jonas von AndrianJonas von Andrian
authored andcommitted
Expose the closest item or container in afterMove
closes johnny#48
1 parent c2b39e1 commit 34c28dc

File tree

3 files changed

+69
-90
lines changed

3 files changed

+69
-90
lines changed

Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ source "http://rubygems.org"
22

33
gem 'thin'
44

5-
gem 'sass', :git => 'https://github.com/nex3/sass.git'
5+
gem 'sass', '~> 3.1.0'
66

7+
gem 'compass'
78
gem 'middleman', '>= 3'
89

910
gem 'guard-livereload'

Gemfile.lock

Lines changed: 56 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,20 @@ GIT
55
specs:
66
sass-twitter-bootstrap (2.0.4)
77

8-
GIT
9-
remote: https://github.com/nex3/sass.git
10-
revision: 1edbe5841971a4cdab0ac63de360973289e700ec
11-
specs:
12-
sass (3.2.0.alpha.0)
13-
148
GEM
159
remote: http://rubygems.org/
1610
specs:
17-
activesupport (3.2.6)
18-
i18n (~> 0.6)
11+
activesupport (3.2.16)
12+
i18n (~> 0.6, >= 0.6.4)
1913
multi_json (~> 1.0)
2014
addressable (2.2.8)
21-
chunky_png (1.2.5)
15+
chunky_png (1.2.9)
2216
closure-compiler (1.1.6)
2317
coderay (1.0.7)
2418
coffee-script (2.2.0)
2519
coffee-script-source
2620
execjs
27-
coffee-script-source (1.3.3)
21+
coffee-script-source (1.6.3)
2822
compass (0.12.2)
2923
chunky_png (~> 1.2)
3024
fssm (>= 0.2.7)
@@ -36,122 +30,103 @@ GEM
3630
eventmachine (0.12.10)
3731
execjs (1.4.0)
3832
multi_json (~> 1.0)
39-
ffi (1.0.11)
40-
fssm (0.2.9)
33+
ffi (1.9.3)
34+
fssm (0.2.10)
4135
guard (1.2.3)
4236
listen (>= 0.4.2)
4337
thor (>= 0.14.6)
4438
guard-livereload (1.0.0)
4539
em-websocket (>= 0.2.0)
4640
guard (>= 1.1.0)
4741
multi_json (~> 1.0)
48-
haml (3.1.6)
49-
hike (1.2.1)
42+
haml (4.0.5)
43+
tilt
44+
hike (1.2.3)
5045
hpricot (0.8.6)
51-
http_router (0.10.2)
52-
rack (>= 1.0.0)
53-
url_mount (~> 0.2.1)
54-
i18n (0.6.0)
55-
libv8 (3.3.10.4)
56-
listen (0.4.7)
57-
rb-fchange (~> 0.0.5)
58-
rb-fsevent (~> 0.9.1)
59-
rb-inotify (~> 0.8.8)
60-
maruku (0.6.0)
61-
syntax (>= 1.0.0)
62-
middleman (3.0.0)
63-
middleman-core (= 3.0.0)
64-
middleman-more (= 3.0.0)
65-
middleman-sprockets (= 3.0.0)
66-
middleman-core (3.0.0)
67-
activesupport (~> 3.2.6)
68-
bundler (~> 1.1)
69-
listen (~> 0.4.7)
70-
rack (~> 1.4.1)
71-
rack-test (~> 0.6.1)
72-
thor (~> 0.15.4)
73-
tilt (~> 1.3.1)
74-
middleman-more (3.0.0)
46+
i18n (0.6.9)
47+
kramdown (1.3.1)
48+
libv8 (3.16.14.3)
49+
listen (1.1.6)
50+
rb-fsevent (>= 0.9.3)
51+
rb-inotify (>= 0.9)
52+
rb-kqueue (>= 0.2)
53+
middleman (3.2.1)
7554
coffee-script (~> 2.2.0)
76-
coffee-script-source (~> 1.3.3)
7755
compass (>= 0.12.2)
7856
execjs (~> 1.4.0)
7957
haml (>= 3.1.6)
80-
i18n (~> 0.6.0)
81-
maruku (~> 0.6.0)
82-
middleman-core (= 3.0.0)
83-
padrino-helpers (= 0.10.7)
58+
kramdown (~> 1.2)
59+
middleman-core (= 3.2.1)
60+
middleman-sprockets (>= 3.1.2)
8461
sass (>= 3.1.20)
85-
uglifier (~> 1.2.6)
86-
middleman-sprockets (3.0.0)
87-
middleman-more (= 3.0.0)
62+
uglifier (~> 2.1.0)
63+
middleman-core (3.2.1)
64+
activesupport (~> 3.2.6)
65+
bundler (~> 1.1)
66+
i18n (~> 0.6.1)
67+
listen (~> 1.1)
68+
rack (>= 1.4.5)
69+
rack-test (~> 0.6.1)
70+
thor (>= 0.15.2, < 2.0)
71+
tilt (~> 1.4.1)
72+
middleman-sprockets (3.2.0)
73+
middleman-core (~> 3.2)
8874
sprockets (~> 2.1)
89-
sprockets-sass (~> 0.8.0)
90-
multi_json (1.3.6)
91-
padrino-core (0.10.7)
92-
activesupport (~> 3.2.0)
93-
http_router (~> 0.10.2)
94-
sinatra (~> 1.3.1)
95-
thor (~> 0.15.2)
96-
tilt (~> 1.3.0)
97-
padrino-helpers (0.10.7)
98-
i18n (~> 0.6)
99-
padrino-core (= 0.10.7)
100-
rack (1.4.1)
75+
sprockets-helpers (~> 1.0.0)
76+
sprockets-sass (~> 1.0.0)
77+
multi_json (1.8.2)
78+
rack (1.5.2)
10179
rack-coderay (0.2.0)
10280
coderay (>= 0.8.312)
10381
hpricot (>= 0.8.1)
10482
rack (>= 1.0.0)
10583
rack-livereload (0.3.6)
10684
rack
107-
rack-protection (1.2.0)
108-
rack
109-
rack-test (0.6.1)
85+
rack-test (0.6.2)
11086
rack (>= 1.0)
111-
rb-fchange (0.0.5)
112-
ffi
113-
rb-fsevent (0.9.1)
114-
rb-inotify (0.8.8)
87+
rb-fsevent (0.9.4)
88+
rb-inotify (0.9.3)
89+
ffi (>= 0.5.0)
90+
rb-kqueue (0.2.0)
11591
ffi (>= 0.5.0)
11692
rdiscount (1.6.8)
117-
sinatra (1.3.2)
118-
rack (~> 1.3, >= 1.3.6)
119-
rack-protection (~> 1.2)
120-
tilt (~> 1.3, >= 1.3.3)
121-
sprockets (2.4.5)
93+
ref (1.0.5)
94+
sass (3.1.21)
95+
sprockets (2.10.1)
12296
hike (~> 1.2)
12397
multi_json (~> 1.0)
12498
rack (~> 1.0)
12599
tilt (~> 1.1, != 1.3.0)
126-
sprockets-sass (0.8.0)
100+
sprockets-helpers (1.0.1)
101+
sprockets (~> 2.0)
102+
sprockets-sass (1.0.2)
127103
sprockets (~> 2.0)
128104
tilt (~> 1.1)
129-
syntax (1.0.0)
130-
therubyracer (0.10.1)
131-
libv8 (~> 3.3.10)
105+
therubyracer (0.12.0)
106+
libv8 (~> 3.16.14.0)
107+
ref
132108
thin (1.4.1)
133109
daemons (>= 1.0.9)
134110
eventmachine (>= 0.12.6)
135111
rack (>= 1.0.0)
136-
thor (0.15.4)
137-
tilt (1.3.3)
138-
uglifier (1.2.6)
112+
thor (0.18.1)
113+
tilt (1.4.1)
114+
uglifier (2.1.2)
139115
execjs (>= 0.3.0)
140-
multi_json (~> 1.3)
141-
url_mount (0.2.1)
142-
rack
116+
multi_json (~> 1.0, >= 1.0.2)
143117

144118
PLATFORMS
145119
ruby
146120

147121
DEPENDENCIES
148122
closure-compiler
123+
compass
149124
guard-livereload
150125
middleman (>= 3)
151126
rack-coderay
152127
rack-livereload
153128
rdiscount
154-
sass!
129+
sass (~> 3.1.0)
155130
sass-twitter-bootstrap (= 2.0.4)!
156131
therubyracer
157132
thin

source/js/jquery-sortable.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@
4545
}, // end container defaults
4646
groupDefaults = {
4747
// This is executed after the placeholder has been moved.
48-
afterMove: function ($placeholder, container) {
48+
// $closestItemOrContainer contains the closest item, the placeholder
49+
// has been put at or the closest empty Container, the placeholder has
50+
// been appended to.
51+
afterMove: function ($placeholder, container, $closestItemOrContainer) {
4952
},
5053
// The exact css path between the container and its items, e.g. "> tbody"
5154
containerPath: "",
@@ -112,7 +115,7 @@
112115
// Note that this default method only works, if every item only has one subcontainer
113116
serialize: function ($parent, $children, parentIsContainer) {
114117
var result = $.extend({}, $parent.data())
115-
118+
116119
if(parentIsContainer)
117120
return $children
118121
else if ($children[0]){
@@ -210,7 +213,7 @@
210213
this.dragProxy = $.proxy(this.drag, this)
211214
this.dropProxy = $.proxy(this.drop, this)
212215
this.placeholder = $(this.options.placeholder)
213-
216+
214217
if(!options.isValidTarget)
215218
this.options.isValidTarget = undefined
216219
}
@@ -331,7 +334,7 @@
331334
item[method](this.placeholder)
332335
this.lastAppendedItem = item
333336
this.sameResultBox = sameResultBox
334-
this.options.afterMove(this.placeholder, container)
337+
this.options.afterMove(this.placeholder, container, item)
335338
},
336339
getContainerDimensions: function () {
337340
if(!this.containerDimensions)
@@ -358,7 +361,7 @@
358361
}
359362
}
360363
}
361-
364+
362365
this.offsetParent = offsetParent
363366
}
364367
return this.offsetParent
@@ -562,11 +565,11 @@
562565
_serialize: function (parent, isContainer) {
563566
var that = this,
564567
childType = isContainer ? "item" : "container",
565-
568+
566569
children = this.$getChildren(parent, childType).not(this.options.exclude).map(function () {
567570
return that._serialize($(this), !isContainer)
568571
}).get()
569-
572+
570573
return this.rootGroup.options.serialize(parent, children, isContainer)
571574
},
572575
clearDimensions: function () {
@@ -598,7 +601,7 @@
598601
}
599602

600603
$.extend(Container.prototype, API)
601-
604+
602605
/**
603606
* jQuery API
604607
*

0 commit comments

Comments
 (0)