Skip to content

Commit

Permalink
Release version 2.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Tsai committed Nov 2, 2017
1 parent af815a8 commit a0d40c3
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dist/jquery.tree-multiselect.css
@@ -1,4 +1,4 @@
/* jQuery Tree Multiselect v2.4.1 | (c) Patrick Tsai | MIT Licensed */
/* jQuery Tree Multiselect v2.4.2 | (c) Patrick Tsai | MIT Licensed */
div.tree-multiselect {
border: 2px solid #D8D8D8;
border-radius: 5px;
Expand Down
26 changes: 24 additions & 2 deletions dist/jquery.tree-multiselect.js
@@ -1,4 +1,4 @@
/* jQuery Tree Multiselect v2.4.1 | (c) Patrick Tsai | MIT Licensed */
/* jQuery Tree Multiselect v2.4.2 | (c) Patrick Tsai | MIT Licensed */
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
'use strict';

Expand Down Expand Up @@ -410,6 +410,8 @@ Tree.prototype.createAst = function (options) {
var self = this;
var itemId = 0;
var sectionId = 0;

var initialIndexItems = [];
var keysToAddAtEnd = [];
options.each(function () {
var option = this;
Expand All @@ -428,7 +430,8 @@ Tree.prototype.createAst = function (options) {
});

if (item.initialIndex) {
self.keysToAdd[item.initialIndex] = itemId;
initialIndexItems[item.initialIndex] = initialIndexItems[item.initialIndex] || [];
initialIndexItems[item.initialIndex].push(itemId);
} else if (item.selected) {
keysToAddAtEnd.push(itemId);
}
Expand Down Expand Up @@ -459,6 +462,7 @@ Tree.prototype.createAst = function (options) {
}
lookupPosition.arr.push(item);
});
this.keysToAdd = Util.array.flatten(initialIndexItems);
Util.array.removeFalseyExceptZero(this.keysToAdd);
(_keysToAdd = this.keysToAdd).push.apply(_keysToAdd, keysToAddAtEnd);
Util.array.uniq(this.keysToAdd);
Expand Down Expand Up @@ -837,6 +841,24 @@ function filterInPlace(arr, pred) {
//arr.slice(0, idx);
}

exports.flatten = function (arr, r) {
if (!Array.isArray(arr)) {
return arr;
}

r = r || [];

for (var ii = 0; ii < arr.length; ++ii) {
if (Array.isArray(arr[ii])) {
r.concat(exports.flatten(arr[ii], r));
} else {
r.push(arr[ii]);
}
}

return r;
};

exports.uniq = function (arr) {
var hash = {};

Expand Down
2 changes: 1 addition & 1 deletion dist/jquery.tree-multiselect.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a0d40c3

Please sign in to comment.