Skip to content

Commit

Permalink
mini demo conditionalclose plugin added - close #2050
Browse files Browse the repository at this point in the history
  • Loading branch information
vakata committed Aug 23, 2018
1 parent 0c661b8 commit 31537c3
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -626,4 +626,32 @@
};
};

}));

// conditional close
(function (factory) {
"use strict";
if (typeof define === 'function' && define.amd) {
define('jstree.conditionalclose', ['jquery','jstree'], factory);
}
else if(typeof exports === 'object') {
factory(require('jquery'), require('jstree'));
}
else {
factory(jQuery, jQuery.jstree);
}
}(function ($, jstree, undefined) {
"use strict";

if($.jstree.plugins.conditionalclose) { return; }
$.jstree.defaults.conditionalclose = function () { return true; };
$.jstree.plugins.conditionalclose = function (options, parent) {
// own function
this.close_node = function (obj, animation) {
if(this.settings.conditionalclose.close.call(this, this.get_node(obj), e)) {
return parent.deselect_node.call(this, obj, animation);
}
};
};

}));

0 comments on commit 31537c3

Please sign in to comment.