Skip to content

Commit

Permalink
Expose the closest item or container in afterMove
Browse files Browse the repository at this point in the history
closes #48
  • Loading branch information
Jonas von Andrian authored and Jonas von Andrian committed Jan 8, 2014
1 parent c2b39e1 commit 34c28dc
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 90 deletions.
3 changes: 2 additions & 1 deletion Gemfile
Expand Up @@ -2,8 +2,9 @@ source "http://rubygems.org"


gem 'thin' gem 'thin'


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


gem 'compass'
gem 'middleman', '>= 3' gem 'middleman', '>= 3'


gem 'guard-livereload' gem 'guard-livereload'
Expand Down
137 changes: 56 additions & 81 deletions Gemfile.lock
Expand Up @@ -5,26 +5,20 @@ GIT
specs: specs:
sass-twitter-bootstrap (2.0.4) sass-twitter-bootstrap (2.0.4)


GIT
remote: https://github.com/nex3/sass.git
revision: 1edbe5841971a4cdab0ac63de360973289e700ec
specs:
sass (3.2.0.alpha.0)

GEM GEM
remote: http://rubygems.org/ remote: http://rubygems.org/
specs: specs:
activesupport (3.2.6) activesupport (3.2.16)
i18n (~> 0.6) i18n (~> 0.6, >= 0.6.4)
multi_json (~> 1.0) multi_json (~> 1.0)
addressable (2.2.8) addressable (2.2.8)
chunky_png (1.2.5) chunky_png (1.2.9)
closure-compiler (1.1.6) closure-compiler (1.1.6)
coderay (1.0.7) coderay (1.0.7)
coffee-script (2.2.0) coffee-script (2.2.0)
coffee-script-source coffee-script-source
execjs execjs
coffee-script-source (1.3.3) coffee-script-source (1.6.3)
compass (0.12.2) compass (0.12.2)
chunky_png (~> 1.2) chunky_png (~> 1.2)
fssm (>= 0.2.7) fssm (>= 0.2.7)
Expand All @@ -36,122 +30,103 @@ GEM
eventmachine (0.12.10) eventmachine (0.12.10)
execjs (1.4.0) execjs (1.4.0)
multi_json (~> 1.0) multi_json (~> 1.0)
ffi (1.0.11) ffi (1.9.3)
fssm (0.2.9) fssm (0.2.10)
guard (1.2.3) guard (1.2.3)
listen (>= 0.4.2) listen (>= 0.4.2)
thor (>= 0.14.6) thor (>= 0.14.6)
guard-livereload (1.0.0) guard-livereload (1.0.0)
em-websocket (>= 0.2.0) em-websocket (>= 0.2.0)
guard (>= 1.1.0) guard (>= 1.1.0)
multi_json (~> 1.0) multi_json (~> 1.0)
haml (3.1.6) haml (4.0.5)
hike (1.2.1) tilt
hike (1.2.3)
hpricot (0.8.6) hpricot (0.8.6)
http_router (0.10.2) i18n (0.6.9)
rack (>= 1.0.0) kramdown (1.3.1)
url_mount (~> 0.2.1) libv8 (3.16.14.3)
i18n (0.6.0) listen (1.1.6)
libv8 (3.3.10.4) rb-fsevent (>= 0.9.3)
listen (0.4.7) rb-inotify (>= 0.9)
rb-fchange (~> 0.0.5) rb-kqueue (>= 0.2)
rb-fsevent (~> 0.9.1) middleman (3.2.1)
rb-inotify (~> 0.8.8)
maruku (0.6.0)
syntax (>= 1.0.0)
middleman (3.0.0)
middleman-core (= 3.0.0)
middleman-more (= 3.0.0)
middleman-sprockets (= 3.0.0)
middleman-core (3.0.0)
activesupport (~> 3.2.6)
bundler (~> 1.1)
listen (~> 0.4.7)
rack (~> 1.4.1)
rack-test (~> 0.6.1)
thor (~> 0.15.4)
tilt (~> 1.3.1)
middleman-more (3.0.0)
coffee-script (~> 2.2.0) coffee-script (~> 2.2.0)
coffee-script-source (~> 1.3.3)
compass (>= 0.12.2) compass (>= 0.12.2)
execjs (~> 1.4.0) execjs (~> 1.4.0)
haml (>= 3.1.6) haml (>= 3.1.6)
i18n (~> 0.6.0) kramdown (~> 1.2)
maruku (~> 0.6.0) middleman-core (= 3.2.1)
middleman-core (= 3.0.0) middleman-sprockets (>= 3.1.2)
padrino-helpers (= 0.10.7)
sass (>= 3.1.20) sass (>= 3.1.20)
uglifier (~> 1.2.6) uglifier (~> 2.1.0)
middleman-sprockets (3.0.0) middleman-core (3.2.1)
middleman-more (= 3.0.0) activesupport (~> 3.2.6)
bundler (~> 1.1)
i18n (~> 0.6.1)
listen (~> 1.1)
rack (>= 1.4.5)
rack-test (~> 0.6.1)
thor (>= 0.15.2, < 2.0)
tilt (~> 1.4.1)
middleman-sprockets (3.2.0)
middleman-core (~> 3.2)
sprockets (~> 2.1) sprockets (~> 2.1)
sprockets-sass (~> 0.8.0) sprockets-helpers (~> 1.0.0)
multi_json (1.3.6) sprockets-sass (~> 1.0.0)
padrino-core (0.10.7) multi_json (1.8.2)
activesupport (~> 3.2.0) rack (1.5.2)
http_router (~> 0.10.2)
sinatra (~> 1.3.1)
thor (~> 0.15.2)
tilt (~> 1.3.0)
padrino-helpers (0.10.7)
i18n (~> 0.6)
padrino-core (= 0.10.7)
rack (1.4.1)
rack-coderay (0.2.0) rack-coderay (0.2.0)
coderay (>= 0.8.312) coderay (>= 0.8.312)
hpricot (>= 0.8.1) hpricot (>= 0.8.1)
rack (>= 1.0.0) rack (>= 1.0.0)
rack-livereload (0.3.6) rack-livereload (0.3.6)
rack rack
rack-protection (1.2.0) rack-test (0.6.2)
rack
rack-test (0.6.1)
rack (>= 1.0) rack (>= 1.0)
rb-fchange (0.0.5) rb-fsevent (0.9.4)
ffi rb-inotify (0.9.3)
rb-fsevent (0.9.1) ffi (>= 0.5.0)
rb-inotify (0.8.8) rb-kqueue (0.2.0)
ffi (>= 0.5.0) ffi (>= 0.5.0)
rdiscount (1.6.8) rdiscount (1.6.8)
sinatra (1.3.2) ref (1.0.5)
rack (~> 1.3, >= 1.3.6) sass (3.1.21)
rack-protection (~> 1.2) sprockets (2.10.1)
tilt (~> 1.3, >= 1.3.3)
sprockets (2.4.5)
hike (~> 1.2) hike (~> 1.2)
multi_json (~> 1.0) multi_json (~> 1.0)
rack (~> 1.0) rack (~> 1.0)
tilt (~> 1.1, != 1.3.0) tilt (~> 1.1, != 1.3.0)
sprockets-sass (0.8.0) sprockets-helpers (1.0.1)
sprockets (~> 2.0)
sprockets-sass (1.0.2)
sprockets (~> 2.0) sprockets (~> 2.0)
tilt (~> 1.1) tilt (~> 1.1)
syntax (1.0.0) therubyracer (0.12.0)
therubyracer (0.10.1) libv8 (~> 3.16.14.0)
libv8 (~> 3.3.10) ref
thin (1.4.1) thin (1.4.1)
daemons (>= 1.0.9) daemons (>= 1.0.9)
eventmachine (>= 0.12.6) eventmachine (>= 0.12.6)
rack (>= 1.0.0) rack (>= 1.0.0)
thor (0.15.4) thor (0.18.1)
tilt (1.3.3) tilt (1.4.1)
uglifier (1.2.6) uglifier (2.1.2)
execjs (>= 0.3.0) execjs (>= 0.3.0)
multi_json (~> 1.3) multi_json (~> 1.0, >= 1.0.2)
url_mount (0.2.1)
rack


PLATFORMS PLATFORMS
ruby ruby


DEPENDENCIES DEPENDENCIES
closure-compiler closure-compiler
compass
guard-livereload guard-livereload
middleman (>= 3) middleman (>= 3)
rack-coderay rack-coderay
rack-livereload rack-livereload
rdiscount rdiscount
sass! sass (~> 3.1.0)
sass-twitter-bootstrap (= 2.0.4)! sass-twitter-bootstrap (= 2.0.4)!
therubyracer therubyracer
thin thin
19 changes: 11 additions & 8 deletions source/js/jquery-sortable.js
Expand Up @@ -45,7 +45,10 @@
}, // end container defaults }, // end container defaults
groupDefaults = { groupDefaults = {
// This is executed after the placeholder has been moved. // This is executed after the placeholder has been moved.
afterMove: function ($placeholder, container) { // $closestItemOrContainer contains the closest item, the placeholder
// has been put at or the closest empty Container, the placeholder has
// been appended to.
afterMove: function ($placeholder, container, $closestItemOrContainer) {
}, },
// The exact css path between the container and its items, e.g. "> tbody" // The exact css path between the container and its items, e.g. "> tbody"
containerPath: "", containerPath: "",
Expand Down Expand Up @@ -112,7 +115,7 @@
// Note that this default method only works, if every item only has one subcontainer // Note that this default method only works, if every item only has one subcontainer
serialize: function ($parent, $children, parentIsContainer) { serialize: function ($parent, $children, parentIsContainer) {
var result = $.extend({}, $parent.data()) var result = $.extend({}, $parent.data())

if(parentIsContainer) if(parentIsContainer)
return $children return $children
else if ($children[0]){ else if ($children[0]){
Expand Down Expand Up @@ -210,7 +213,7 @@
this.dragProxy = $.proxy(this.drag, this) this.dragProxy = $.proxy(this.drag, this)
this.dropProxy = $.proxy(this.drop, this) this.dropProxy = $.proxy(this.drop, this)
this.placeholder = $(this.options.placeholder) this.placeholder = $(this.options.placeholder)

if(!options.isValidTarget) if(!options.isValidTarget)
this.options.isValidTarget = undefined this.options.isValidTarget = undefined
} }
Expand Down Expand Up @@ -331,7 +334,7 @@
item[method](this.placeholder) item[method](this.placeholder)
this.lastAppendedItem = item this.lastAppendedItem = item
this.sameResultBox = sameResultBox this.sameResultBox = sameResultBox
this.options.afterMove(this.placeholder, container) this.options.afterMove(this.placeholder, container, item)
}, },
getContainerDimensions: function () { getContainerDimensions: function () {
if(!this.containerDimensions) if(!this.containerDimensions)
Expand All @@ -358,7 +361,7 @@
} }
} }
} }

this.offsetParent = offsetParent this.offsetParent = offsetParent
} }
return this.offsetParent return this.offsetParent
Expand Down Expand Up @@ -562,11 +565,11 @@
_serialize: function (parent, isContainer) { _serialize: function (parent, isContainer) {
var that = this, var that = this,
childType = isContainer ? "item" : "container", childType = isContainer ? "item" : "container",

children = this.$getChildren(parent, childType).not(this.options.exclude).map(function () { children = this.$getChildren(parent, childType).not(this.options.exclude).map(function () {
return that._serialize($(this), !isContainer) return that._serialize($(this), !isContainer)
}).get() }).get()

return this.rootGroup.options.serialize(parent, children, isContainer) return this.rootGroup.options.serialize(parent, children, isContainer)
}, },
clearDimensions: function () { clearDimensions: function () {
Expand Down Expand Up @@ -598,7 +601,7 @@
} }


$.extend(Container.prototype, API) $.extend(Container.prototype, API)

/** /**
* jQuery API * jQuery API
* *
Expand Down

0 comments on commit 34c28dc

Please sign in to comment.