From ff9b3be7047267dcc5e8afb7da5e33d78c9a5d39 Mon Sep 17 00:00:00 2001 From: Nytrm Date: Thu, 3 Oct 2013 12:05:29 +0200 Subject: [PATCH 01/57] Forgot ; in $.each() --- jquery.mjs.nestedSortable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.mjs.nestedSortable.js b/jquery.mjs.nestedSortable.js index 72ed56b..db1a1c5 100644 --- a/jquery.mjs.nestedSortable.js +++ b/jquery.mjs.nestedSortable.js @@ -68,7 +68,7 @@ } else { $li.addClass(self.options.leafClass); } - }) + }); } }, From a56e305c2e455301892cd27c6fa7beaa75f6a90f Mon Sep 17 00:00:00 2001 From: Oscar Perez Date: Fri, 17 Jan 2014 01:04:06 -0500 Subject: [PATCH 02/57] Added ability to skip items with disabledClass. Useful when sorting over hidden/non-visible items. --- jquery.mjs.nestedSortable.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/jquery.mjs.nestedSortable.js b/jquery.mjs.nestedSortable.js index 72ed56b..4aea721 100644 --- a/jquery.mjs.nestedSortable.js +++ b/jquery.mjs.nestedSortable.js @@ -38,7 +38,8 @@ errorClass: 'mjs-nestedSortable-error', expandedClass: 'mjs-nestedSortable-expanded', hoveringClass: 'mjs-nestedSortable-hovering', - leafClass: 'mjs-nestedSortable-leaf' + leafClass: 'mjs-nestedSortable-leaf', + disabledClass: 'mjs-nestedSortable-disabled' }, _create: function() { @@ -257,7 +258,7 @@ // mjs - to find the previous sibling in the list, keep backtracking until we hit a valid list item. var previousItem = this.placeholder[0].previousSibling ? $(this.placeholder[0].previousSibling) : null; if (previousItem != null) { - while (previousItem[0].nodeName.toLowerCase() != 'li' || previousItem[0] == this.currentItem[0] || previousItem[0] == this.helper[0]) { + while (previousItem[0].nodeName.toLowerCase() != 'li' || previousItem[0].className.indexOf(o.disabledClass) !== -1 || previousItem[0] == this.currentItem[0] || previousItem[0] == this.helper[0]) { if (previousItem[0].previousSibling) { previousItem = $(previousItem[0].previousSibling); } else { @@ -270,7 +271,7 @@ // mjs - to find the next sibling in the list, keep stepping forward until we hit a valid list item. var nextItem = this.placeholder[0].nextSibling ? $(this.placeholder[0].nextSibling) : null; if (nextItem != null) { - while (nextItem[0].nodeName.toLowerCase() != 'li' || nextItem[0] == this.currentItem[0] || nextItem[0] == this.helper[0]) { + while (nextItem[0].nodeName.toLowerCase() != 'li' || nextItem[0].className.indexOf(o.disabledClass) !== -1 || nextItem[0] == this.currentItem[0] || nextItem[0] == this.helper[0]) { if (nextItem[0].nextSibling) { nextItem = $(nextItem[0].nextSibling); } else { From 3b0313266a6c64a5968e009ca96b4130f0317fc3 Mon Sep 17 00:00:00 2001 From: Oscar Perez Date: Fri, 17 Jan 2014 10:08:59 -0500 Subject: [PATCH 03/57] Added disabledClass option to README. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 57fab08..91cd8fe 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,8 @@ Also, the default list type is `
    `.
    Given to collapsed branches when dragging an item over them. Default: mjs-nestedSortable-hovering
    leafClass (2.0)
    Given to items that do not have children. Default: mjs-nestedSortable-leaf
    +
    disabledClass (2.0)
    +
    Given to items that should be skipped when sorting over them. For example, non-visible items that are still part of the list. Default: mjs-nestedSortable-disabled
    ## Custom Methods From 4fa262d1cba457f074882056e1aff9d0a7c1b8cf Mon Sep 17 00:00:00 2001 From: Oscar Perez Date: Fri, 17 Jan 2014 12:25:42 -0500 Subject: [PATCH 04/57] Fixed skipping over disabled elements when they are visible. --- jquery.mjs.nestedSortable.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/jquery.mjs.nestedSortable.js b/jquery.mjs.nestedSortable.js index 4aea721..5524936 100644 --- a/jquery.mjs.nestedSortable.js +++ b/jquery.mjs.nestedSortable.js @@ -179,6 +179,27 @@ continue; } + // No action if intersected item is disabled + // and the element above or below in the direction we're going is also disabled + if (itemElement.className.indexOf(o.disabledClass) !== -1) { + // Note: intersection hardcoded direction values from jquery.ui.sortable.js:_intersectsWithPointer + if (intersection === 2) { + // Going down + var itemAfter = this.items[i + 1]; + if (itemAfter && itemAfter.item[0].className.indexOf(o.disabledClass) !== -1){ + continue; + } + + } + else if (intersection === 1) { + // Going up + var itemBefore = this.items[i - 1]; + if (itemBefore && itemBefore.item[0].className.indexOf(o.disabledClass) !== -1){ + continue; + } + } + } + // cannot intersect with itself // no useless actions that have been done before // no action if the item moved is the parent of the item checked From f36d0744e7b48a9c7ba7bd2e647f60f6a41dd8d2 Mon Sep 17 00:00:00 2001 From: Dustin Bolton Date: Tue, 21 Jan 2014 19:10:31 -0600 Subject: [PATCH 05/57] Allows starting individual branches expanded or collapsed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This update allows you to preset the expanded or collapsed class on individual branches to give finer grain control over individual branch status on start. This allows overriding the default startCollapsed option on a per-branch level as needed. I needed this so that I could ‘remember’ the state of individual branches and restore them on page load. --- jquery.mjs.nestedSortable.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/jquery.mjs.nestedSortable.js b/jquery.mjs.nestedSortable.js index 72ed56b..01ec792 100644 --- a/jquery.mjs.nestedSortable.js +++ b/jquery.mjs.nestedSortable.js @@ -63,8 +63,10 @@ if ($li.children(self.options.listType).length) { $li.addClass(self.options.branchClass); // expand/collapse class only if they have children - if (self.options.startCollapsed) $li.addClass(self.options.collapsedClass); - else $li.addClass(self.options.expandedClass); + if ( ! $li.hasClass( self.options.collapsedClass ) && ( ! $li.hasClass( self.options.expandedClass ) ) ) { + if (self.options.startCollapsed) $li.addClass(self.options.collapsedClass); + else $li.addClass(self.options.expandedClass); + } } else { $li.addClass(self.options.leafClass); } From 163a1dbb6f9063513cfc3fd05b342b6bc51d53db Mon Sep 17 00:00:00 2001 From: Matt Parnell Date: Mon, 19 May 2014 11:32:41 -0500 Subject: [PATCH 06/57] add relocate event per https://github.com/mjsarfatti/nestedSortable/pull/97/files#diff-b881c68d9a23598b5e5179ffe4509436R216 --- README.md | 12 ++++++++++++ jquery.mjs.nestedSortable.js | 8 ++++++++ 2 files changed, 20 insertions(+) diff --git a/README.md b/README.md index 91cd8fe..182658a 100644 --- a/README.md +++ b/README.md @@ -148,6 +148,18 @@ Also, the default list type is `
      `. Similarly to toArray, it accepts attribute and expression options. +## Events +
      +
      change
      +
      Fires when the item is dragged to a new location. This triggers for each location it is dragged into not just the ending location. +
      sort
      +
      Fires when the item is dragged.
      +
      revert
      +
      Fires once the object has moved if the new location is invalid.
      +
      relocate
      +
      Only fires once when the item is done bing moved at its final location.
      +
      + ## Known Bugs *nestedSortable* doesn't work properly with connected draggables, because of the way Draggable simulates Sortable `mouseStart` and `mouseStop` events. This bug might or might not be fixed some time in the future (it's not specific to this plugin). diff --git a/jquery.mjs.nestedSortable.js b/jquery.mjs.nestedSortable.js index 1f4f8e7..0942432 100644 --- a/jquery.mjs.nestedSortable.js +++ b/jquery.mjs.nestedSortable.js @@ -398,6 +398,14 @@ this.hovering = null; $.ui.sortable.prototype._mouseStop.apply(this, arguments); + + var pid = $(this.domPosition.parent).parent().attr("id"); + var sort = this.domPosition.prev ? $(this.domPosition.prev).next().index() : 0; + + if(!(pid == this._uiHash().item.parent().parent().attr("id") && + sort == this._uiHash().item.index())) { + this._trigger("relocate", event, this._uiHash()); + } }, From fa0b9a2cea06f689cea352cf4efd88db0fdd4b16 Mon Sep 17 00:00:00 2001 From: Matt Parnell Date: Wed, 21 May 2014 16:10:23 -0500 Subject: [PATCH 07/57] add an example page based on the original, with 4 levels deep, custom styling, ui icons, expand/contract, and inner content --- example.html | 454 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 454 insertions(+) create mode 100644 example.html diff --git a/example.html b/example.html new file mode 100644 index 0000000..c9c317b --- /dev/null +++ b/example.html @@ -0,0 +1,454 @@ + + + + + nestedSortable jQuery Plugin + + + + + + + + + + + + +
      +

      nestedSortable jQuery Plugin

      + +

      2.0

      +
      + +
      +

      This is the demo page for the nestedSortable jQuery plugin.

      + +

      Follow the development, read the docs and download the + latest version directly from the GitHub + page.

      +
      + +
      +
        + +
          +
        + + +
      + +

      Try the custom methods:

      + +


      +

      +
      +		
      + +

      +
      +		
      + +

      +
      +		
      + +

      Note: This demo has the maxLevels option set to '4'.

      +
      + +
      +

      License

      + +

      This work is licensed under the MIT License.
      + Which means you can do pretty much whatever you want with it.

      + +

      © 2010‐2014 Manuele J Sarfatti

      +
      + + \ No newline at end of file From ef4d379417404f07ca54fee26ed11f6478816d74 Mon Sep 17 00:00:00 2001 From: Matt Parnell Date: Wed, 21 May 2014 16:14:31 -0500 Subject: [PATCH 08/57] update link in README for new example and remove paypal begging since original dev doesn't work on this anymore --- README.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/README.md b/README.md index 182658a..b717712 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ ## What's new in version 2.0 -The biggest change is that your nested list can now behave as a tree with expand/collapse funcionality. Simply set `isTree` to **true** in the options and you are good to go! Check the [demo](http://mjsarfatti.com/sandbox/nestedSortable) out to see what can be done with nestedSortable and a little CSS. (Note that all **nestedSortable** does is to assign/remove classes on the fly) +The biggest change is that your nested list can now behave as a tree with expand/collapse funcionality. Simply set `isTree` to **true** in the options and you are good to go! Check the [demo](http://htmlpreview.github.io/?https://raw.githubusercontent.com/ilikenwf/nestedSortable/2.0alpha/example.html) out to see what can be done with nestedSortable and a little CSS. (Note that all **nestedSortable** does is to assign/remove classes on the fly) Also: - **isAllowed** function finally works as expected, see the docs below - Fixed: a small bug in the **protectRoot** function @@ -177,8 +177,3 @@ Tested with: Firefox, Chrome This work is licensed under the MIT License. Which means you can do pretty much whatever you want with it. - -Nonetheless if this plugin saved you money, saved you time or saved your life please take a moment to think about the work I've been doing for you and consider sharing a bit of your joy with me. Your donation, however small, will be greatly appreciated. -Thank you. - -[Donate with PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=RSJEW3N9PRMYY&lc=IT&item_name=Manuele%20Sarfatti¤cy_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted) From 2a376eca4f75cd18458b49803b7b4ae9795dd22c Mon Sep 17 00:00:00 2001 From: Matt Parnell Date: Wed, 21 May 2014 16:15:32 -0500 Subject: [PATCH 09/57] forgot to update a link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b717712..fe28fa8 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ Please note: every `
    1. ` must have either one or two direct children, the first Also, the default list type is `
        `. -*This is the bare minimum to have a working nestedSortable. Check the [demo](http://mjsarfatti.com/sandbox/nestedSortable) out to see what can be accomplished with a little more.* +*This is the bare minimum to have a working nestedSortable. Check the [demo](http://htmlpreview.github.io/?https://raw.githubusercontent.com/ilikenwf/nestedSortable/2.0alpha/example.html) out to see what can be accomplished with a little more.* ## Custom Options From 2d26c23af038314fd5e810b187afe1b0816ab4b8 Mon Sep 17 00:00:00 2001 From: Matt Parnell Date: Wed, 21 May 2014 16:16:30 -0500 Subject: [PATCH 10/57] remove maintainer needed notice...the community can pick this up --- README.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/README.md b/README.md index fe28fa8..93d6db6 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,3 @@ -**ANNOUNCEMENT** - -**I'm sorry to say that I am not able to keep up the pace in developing this project anymore. I know how much nestedSortable is important for web applications, and I still can't understand why it's not part of jQuery-UI. I also think the base of the plugin is very strong, and deserves much more attention and involvement.** -**If anybody is willing to take this project, please say so [here](https://github.com/mjsarfatti/nestedSortable/issues/95).** -**Thank you.** - # nestedSortable jQuery plugin **nestedSortable** is a jQuery plugin that extends jQuery Sortable UI functionalities to nested lists. From 7e88e6283f060c588a473382638e4906e6b671bc Mon Sep 17 00:00:00 2001 From: Matt Parnell Date: Wed, 21 May 2014 16:17:42 -0500 Subject: [PATCH 11/57] whoops, remove relative path for the js file --- example.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example.html b/example.html index c9c317b..c2071c1 100644 --- a/example.html +++ b/example.html @@ -176,7 +176,7 @@ - + - + - + This snippet gets https://code.jquery.com/ui/1.10.4/jquery-ui.min.js on a https enabled site. On a http site http://code.jquery.com/ui/1.10.4/jquery-ui.min.js is pulled. --- example.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/example.html b/example.html index ba4f66a..fe3aecb 100644 --- a/example.html +++ b/example.html @@ -173,9 +173,9 @@ color: #c33; } - - - + + +