diff --git a/.gitignore b/.gitignore index cbaf437..3cf5132 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ /.sass-cache /build /.bundle +/node_modules # tempfiles diff --git a/CHANGELOG b/CHANGELOG index 3a871ac..bb9c4fd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,18 +1,37 @@ +[0.9.13] fix hovering over empty container (Jonny Gerig Meyer) + allow custom drag classes (Jonny Gerig Meyer) + support text areas inside sortables (Isaac Kearse) + fix drag with placeholder issue (Michael McLaughlin) + user outer dimensions for dragged item (Jared Mellentine) + support npm and bower (Patrick Gunderson, Shaun Dern) + fix issue with legacy jQuery 1.10 + fix for mobile chrome + +[0.9.12] expose mouse events in callbacks + add refresh method + add destroy method + add delay option + falsy return value in onMousedown prevents dragging + fix exclusion of items + fix ignore for select element (abixalmon) + fix touch events (prateekjadhwani) + fix itemPath issues (appending and dragInit) + improve documentation [0.9.11] option tolerance accepts negative values - rewrote enable/disable logic - added (item|container)Path + rewrote enable/disable logic + added (item|container)Path -[0.9.10]Fix Array.indexOf() error in IE < 9 (Dev-Speranza) - serialize() assumes one subcontainer per item - remove call to stopPropagation() - Added onMousedown() +[0.9.10] Fix Array.indexOf() error in IE < 9 (Dev-Speranza) + serialize() assumes one subcontainer per item + remove call to stopPropagation() + Added onMousedown() [0.9.9] Added options tolerance and distance - Do not modify Array.prototype (by Joakin) - serialize respects exclude option + Do not modify Array.prototype (by Joakin) + serialize respects exclude option [0.9.8] Added Serialization - Added onCancel + Added onCancel [0.9.7] Support iFrame and Touch events - Better behavior if the CSS position changes \ No newline at end of file + Better behavior if the CSS position changes diff --git a/Gemfile.lock b/Gemfile.lock index bd11fa4..ed60e39 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,112 +8,124 @@ GIT GEM remote: http://rubygems.org/ specs: - activesupport (3.2.16) + activesupport (3.2.22) i18n (~> 0.6, >= 0.6.4) multi_json (~> 1.0) - addressable (2.2.8) - chunky_png (1.2.9) - closure-compiler (1.1.6) - coderay (1.0.7) + chunky_png (1.3.4) + closure-compiler (1.1.11) + coderay (1.1.0) coffee-script (2.2.0) coffee-script-source execjs - coffee-script-source (1.6.3) + coffee-script-source (1.9.1.1) compass (0.12.2) chunky_png (~> 1.2) fssm (>= 0.2.7) sass (~> 3.1) - daemons (1.1.8) - em-websocket (0.3.8) - addressable (>= 2.1.1) + daemons (1.2.3) + em-websocket (0.5.1) eventmachine (>= 0.12.9) - eventmachine (0.12.10) - execjs (1.4.0) + http_parser.rb (~> 0.6.0) + eventmachine (1.0.7) + execjs (1.4.1) multi_json (~> 1.0) - ffi (1.9.3) + ffi (1.9.9) + formatador (0.2.5) fssm (0.2.10) - guard (1.2.3) - listen (>= 0.4.2) + guard (1.8.3) + formatador (>= 0.2.4) + listen (~> 1.3) + lumberjack (>= 1.0.2) + pry (>= 0.9.10) thor (>= 0.14.6) - guard-livereload (1.0.0) - em-websocket (>= 0.2.0) - guard (>= 1.1.0) - multi_json (~> 1.0) - haml (4.0.5) + guard-livereload (1.4.0) + em-websocket (>= 0.5.0) + guard (>= 1.8.0) + multi_json (~> 1.7) + haml (4.0.6) tilt hike (1.2.3) hpricot (0.8.6) - i18n (0.6.9) - kramdown (1.3.1) - libv8 (3.16.14.3) - listen (1.1.6) + http_parser.rb (0.6.0) + i18n (0.6.11) + json (1.8.3) + kramdown (1.7.0) + libv8 (3.16.14.9) + listen (1.3.1) rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9) rb-kqueue (>= 0.2) - middleman (3.2.1) + lumberjack (1.0.9) + method_source (0.8.2) + middleman (3.2.2) coffee-script (~> 2.2.0) compass (>= 0.12.2) execjs (~> 1.4.0) haml (>= 3.1.6) kramdown (~> 1.2) - middleman-core (= 3.2.1) + middleman-core (= 3.2.2) middleman-sprockets (>= 3.1.2) sass (>= 3.1.20) - uglifier (~> 2.1.0) - middleman-core (3.2.1) + uglifier (~> 2.4.0) + middleman-core (3.2.2) activesupport (~> 3.2.6) bundler (~> 1.1) - i18n (~> 0.6.1) + i18n (~> 0.6.9) 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-helpers (~> 1.0.0) - sprockets-sass (~> 1.0.0) - multi_json (1.8.2) - rack (1.5.2) + middleman-sprockets (3.3.3) + middleman-core (>= 3.2) + sprockets (~> 2.2) + sprockets-helpers (~> 1.1.0) + sprockets-sass (~> 1.1.0) + multi_json (1.11.1) + pry (0.10.1) + coderay (~> 1.1.0) + method_source (~> 0.8.1) + slop (~> 3.4) + rack (1.6.4) rack-coderay (0.2.0) coderay (>= 0.8.312) hpricot (>= 0.8.1) rack (>= 1.0.0) - rack-livereload (0.3.6) + rack-livereload (0.3.15) rack - rack-test (0.6.2) + rack-test (0.6.3) rack (>= 1.0) - rb-fsevent (0.9.4) - rb-inotify (0.9.3) + rb-fsevent (0.9.5) + rb-inotify (0.9.5) ffi (>= 0.5.0) - rb-kqueue (0.2.0) + rb-kqueue (0.2.4) ffi (>= 0.5.0) - rdiscount (1.6.8) + rdiscount (2.1.8) ref (1.0.5) sass (3.1.21) - sprockets (2.10.1) + slop (3.6.0) + sprockets (2.12.4) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sprockets-helpers (1.0.1) + sprockets-helpers (1.1.0) sprockets (~> 2.0) - sprockets-sass (1.0.2) + sprockets-sass (1.1.0) sprockets (~> 2.0) tilt (~> 1.1) - therubyracer (0.12.0) + therubyracer (0.12.2) libv8 (~> 3.16.14.0) ref - thin (1.4.1) - daemons (>= 1.0.9) - eventmachine (>= 0.12.6) - rack (>= 1.0.0) - thor (0.18.1) + thin (1.6.3) + daemons (~> 1.0, >= 1.0.9) + eventmachine (~> 1.0) + rack (~> 1.0) + thor (0.19.1) tilt (1.4.1) - uglifier (2.1.2) + uglifier (2.4.0) execjs (>= 0.3.0) - multi_json (~> 1.0, >= 1.0.2) + json (>= 1.8.0) PLATFORMS ruby diff --git a/TODO b/TODO index b037987..de15ff7 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,10 @@ -- [0/2] bugs +- [0/3] bugs - [ ] last Pointer is NaN in search valid target - [ ] prevent infinite recursion -- [0/5] consider + - [ ] bootstrap example jumps up on drop + - (only sometimes. preventDefault() does not work if called inside drop or on containing element. Look up where the on handler attaches itself) + - only firefox, chrome works +- [0/6] consider - [ ] better name for searchValidTarget - [ ] shortcut on getNearest() - [ ] if items, break if distance is growing again @@ -9,3 +12,4 @@ - [ ] only calculate top/bottom if vertical and left/right if horizontal - [ ] support placeholder with height/width - [ ] calculate item/container dimensions relative to the container => Not all centers have to be recalculated + - [ ] change subContainers handling, so that it becomes easier to remove them diff --git a/VERSION b/VERSION index 8225a4b..62ea259 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.9.11 +0.9.13 diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..5c77614 --- /dev/null +++ b/bower.json @@ -0,0 +1,27 @@ +{ + "name": "jquery-sortable", + "version": "0.9.13", + "homepage": "http://johnny.github.io/jquery-sortable/", + "authors": [ + "Jonas von Andrian" + ], + "main": "./source/js/jquery-sortable.js", + "moduleType": [ + "globals" + ], + "keywords": [ + "sortable", + "sort", + "sorting", + "drag", + "dragging" + ], + "license": "BSD-3", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ] +} diff --git a/build.sh b/build.sh index 0ca19f6..6fd55fa 100755 --- a/build.sh +++ b/build.sh @@ -1,9 +1,11 @@ #!/bin/sh +set -o nounset +set -o errexit VERSION=`cat VERSION` cp README.mkd .. -./bin/middleman build +bundle exec middleman build git commit -am "Release $VERSION" git checkout gh-pages rm -R js css img diff --git a/config.rb b/config.rb index 746fa4a..c301336 100644 --- a/config.rb +++ b/config.rb @@ -1,4 +1,4 @@ -### +### # Compass ### @@ -16,13 +16,13 @@ ### # Per-page layout changes: -# +# # With no layout # page "/path/to/file.html", :layout => false -# +# # With alternative layout page "/debug.html", :layout => 'debug.haml' -# +# # A path which all have the same layout # with_layout :admin do # page "/admin/*" @@ -47,7 +47,7 @@ def escape_file(name) end def example(name) content = escape_file("js/examples/"+ name + ".js") - content.match(/\A\$\(function\s*\(\)\s*\{\s*(.*)\s*\}\s*\)\s*\z/mi)[1].gsub(/^ /, "") + content.match(/\A\$\(function\s*\(\)\s*\{\s*(.*)\s*\}\s*\);\s*\z/mi)[1].gsub(/^ /, "") end def show_code_button content_tag( :div, @@ -84,10 +84,18 @@ def file_kb(name) set :css_dir, 'css' +ignore 'css/jquery-sortable.css.sass' + set :js_dir, 'js' set :images_dir, 'img' +def update_version(file) + content = File.read(file).gsub(/("version": "|blob\/)[\d\.]+/, '\1' + VERSION) + File.open(file, 'w') do |file| + file.puts content + end +end # Build-specific configuration configure :build do filename = 'source/js/jquery-sortable.js' @@ -105,30 +113,29 @@ def file_kb(name) end `gzip -c source/js/jquery-sortable-min.js > source/js/jquery-sortable-min.js.gz` - - manifest = 'sortable.jquery.json' - content = File.read(manifest).gsub(/("version": "|blob\/)[\d\.]+/, '\1' + VERSION) - File.open(manifest, 'w') do |file| - file.puts content - end + + ['sortable.jquery.json', + 'bower.json', + 'package.json' + ].each { |package_file| update_version(package_file) } # For example, change the Compass output style for deployment # activate :minify_css - + # Minify Javascript on build # activate :minify_javascript - + # Enable cache buster # activate :cache_buster - + # Use relative URLs # activate :relative_assets - + # Compress PNGs after build # First: gem install middleman-smusher # require "middleman-smusher" # activate :smusher - + # Or use a different image path # set :http_path, "/Content/images/" set :http_prefix, "/jquery-sortable" diff --git a/package.json b/package.json new file mode 100644 index 0000000..39166ca --- /dev/null +++ b/package.json @@ -0,0 +1,31 @@ +{ + "name": "jquery-sortable", + "version": "0.9.13", + "description": "jquery plugin for sortable, nestable lists", + "main": "./source/js/jquery-sortable.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "https://github.com/johnny/jquery-sortable.git" + }, + "keywords": [ + "sortable", + "sort", + "sorting", + "drag", + "dragging" + ], + "author": [ + "Jonas von Andrian" + ], + "license": "BSD-3", + "bugs": { + "url": "https://github.com/johnny/jquery-sortable/issues" + }, + "homepage": "https://github.com/johnny/jquery-sortable", + "dependencies": { + "jquery": "^2.1.2 || ^3.0.0" + } +} diff --git a/push-tag.sh b/push-tag.sh index 8d135d4..009bc95 100755 --- a/push-tag.sh +++ b/push-tag.sh @@ -1,4 +1,6 @@ #!/bin/sh +set -o nounset +set -o errexit VERSION=`cat VERSION` diff --git a/release.sh b/release.sh new file mode 100755 index 0000000..3bd5c7b --- /dev/null +++ b/release.sh @@ -0,0 +1,6 @@ +#!/bin/sh +set -o nounset +set -o errexit + +./build.sh +./push-tag.sh diff --git a/sortable.jquery.json b/sortable.jquery.json index a564193..425ac93 100644 --- a/sortable.jquery.json +++ b/sortable.jquery.json @@ -9,14 +9,14 @@ "drag", "drop" ], - "version": "0.9.11", + "version": "0.9.13", "author": { "name": "Jonas von Andrian" }, "licenses": [ { "type": "BSD-3", - "url": "https://github.com/johnny/jquery-sortable/blob/0.9.11/LICENSE" + "url": "https://github.com/johnny/jquery-sortable/blob/0.9.13/LICENSE" } ], "bugs": "https://github.com/johnny/jquery-sortable/issues", diff --git a/source/_serialization.html.haml b/source/_serialization.html.haml new file mode 100644 index 0000000..2812aa4 --- /dev/null +++ b/source/_serialization.html.haml @@ -0,0 +1,27 @@ +%h2 Serialization and delay +.row + .span12.example + %pre(lang="js")= example("serialization") + .span4 + %ul + %li + Uses the default + %strong serialize + implementation, that reads out the + %strong data attributes + %p= show_code_button + %h3 Serialize result + %pre#serialize_output2 + .span4 + %ol.serialization.vertical + = iterate(6) do |i,name| + %li(data-id=i data-name=name) + = name + - if i == 3 + %ol + = iterate(6) do |j, name| + %li(data-id="#{i}-#{j}" data-name=name)= name + .span4 + %ol.serialization.vertical + = iterate(6,"Item") do |i,name| + %li(data-id=i data-name=name)= name diff --git a/source/_table.html.haml b/source/_table.html.haml index 2e948ef..1157cb5 100644 --- a/source/_table.html.haml +++ b/source/_table.html.haml @@ -36,8 +36,10 @@ %tr %th A Column %th B Column + %th C Column %tbody = iterate(6) do |i, name| %tr %td A #{name} %td B #{name} + %td C #{name} diff --git a/source/css/application.css.sass b/source/css/application.css.sass index 62ec8e3..5f0c9b5 100644 --- a/source/css/application.css.sass +++ b/source/css/application.css.sass @@ -44,7 +44,7 @@ ol.nested_with_switch, ol.nested_with_switch ol &.active border: 1px solid $grayDark -ol.nested_with_switch, ol.simple_with_animation, ol.default +ol.nested_with_switch, ol.simple_with_animation, ol.serialization, ol.default li cursor: pointer diff --git a/source/index.html.haml b/source/index.html.haml index 48236d7..b2e83ba 100644 --- a/source/index.html.haml +++ b/source/index.html.haml @@ -136,8 +136,17 @@ = partial "limited_drop_targets" #bootstrap = partial "nested_bootstrap" + #serialization + = partial "serialization" #table = partial "table" + #external + %h2 External examples + %ul + %li + %a(href="http://www.catch.jp/program/soramame_block/") SoraMame Block + \- program by drag and drop + #docs .page-header %h1 Documentation @@ -173,6 +182,12 @@ %h3 %code .sortable("disable") %p Disable all instantiated sortables in the set of matched elements + %h3 + %code .sortable("refresh") + %p Reset all cached element dimensions + %h3 + %code .sortable("destroy") + %p Remove the sortable plugin from the set of matched elements %h3 %code .sortable("serialize") %p @@ -216,16 +231,19 @@ %p Listed in alphabetical order %ul %li - %a(href="http://farhadi.ir/projects/html5sortable/") HTML5 Sortable - (uses native dnd events) + %a(href="https://github.com/voidberg/html5sortable") HTML5 Sortable + (uses native dnd events, supports IE5.5+) %li %a(href="http://jqueryui.com/demos/sortable/") jQuery UI sortable %li %a(href="http://dbushell.github.com/Nestable/") Nestable (requires no jQuery UI) %li - %a(href="http://mjsarfatti.com/sandbox/nestedSortable/") nestedSortable + %a(href="https://github.com/ilikenwf/nestedSortable") nestedSortable (an extension of jQuery UI) + %li + %a(href="https://github.com/RubaXa/Sortable") RubaXa's Sortable + (supports touch devices and AngularJS) %li %a(href="http://yuilibrary.com/yui/docs/sortable/") YUI sortable @@ -239,4 +257,3 @@ Built with [Bootstrap](http://twitter.github.com/bootstrap/). Icons from [Glyphicons Free](http://glyphicons.com/). - diff --git a/source/js/application.js b/source/js/application.js index 531d907..c569157 100644 --- a/source/js/application.js +++ b/source/js/application.js @@ -9,9 +9,9 @@ $(function () { if(!/test/.test(window.location.pathname)) - $('body').scrollspy() + $('body').scrollspy(); $('.show-code').on('click', function () { - $(this).closest('.row').children('.example').slideToggle() - }) - $('ol.default').sortable() -}) + $(this).closest('.row').children('.example').slideToggle(); + }); + $('ol.default').sortable(); +}); diff --git a/source/js/debug.js b/source/js/debug.js index dfc3754..e1dc04e 100644 --- a/source/js/debug.js +++ b/source/js/debug.js @@ -7,6 +7,6 @@ $(function () { itemSelector: '.part, .layout', containerSelector: '.region', nested: true, - placeholder: '
| t |