Browse Source

publish muk_web_utils - 11.0

pull/122/head
MuK IT GmbH 5 years ago
parent
commit
3c571e2af0
  1. 3
      muk_web_utils/__manifest__.py
  2. 491
      muk_web_utils/static/lib/jsTree/jstree.js
  3. 16
      muk_web_utils/static/lib/jsTree/themes/default/style.css
  4. 8
      muk_web_utils/static/src/js/underscore.js
  5. 2
      muk_web_utils/template/assets.xml

3
muk_web_utils/__manifest__.py

@ -20,7 +20,7 @@
{
"name": "MuK Web Utils",
"summary": """Utility Features""",
"version": "11.0.2.0.17",
"version": "11.0.2.0.19",
"category": "Extra Tools",
"license": "AGPL-3",
"website": "http://www.mukit.at",
@ -28,6 +28,7 @@
"author": "MuK IT",
"contributors": [
"Mathias Markl <mathias.markl@mukit.at>",
"Kerrim Abd El-Hamed <kerrim.abdelhamed@mukit.at>",
],
"depends": [
"web",

491
muk_web_utils/static/lib/jsTree/jstree.js

@ -13,7 +13,7 @@
}(function ($, undefined) {
"use strict";
/*!
* jsTree 3.3.7
* jsTree 3.3.4
* http://jstree.com/
*
* Copyright (c) 2014 Ivan Bozhanov (http://vakata.com)
@ -54,7 +54,7 @@
* specifies the jstree version in use
* @name $.jstree.version
*/
version : '3.3.7',
version : '3.3.4',
/**
* holds all the default options used when creating new instances
* @name $.jstree.defaults
@ -430,90 +430,10 @@
*/
force_text : false,
/**
* Should the node be toggled if the text is double clicked. Defaults to `true`
* Should the node should be toggled if the text is double clicked . Defaults to `true`
* @name $.jstree.defaults.core.dblclick_toggle
*/
dblclick_toggle : true,
/**
* Should the loaded nodes be part of the state. Defaults to `false`
* @name $.jstree.defaults.core.loaded_state
*/
loaded_state : false,
/**
* Should the last active node be focused when the tree container is blurred and the focused again. This helps working with screen readers. Defaults to `true`
* @name $.jstree.defaults.core.restore_focus
*/
restore_focus : true,
/**
* Default keyboard shortcuts (an object where each key is the button name or combo - like 'enter', 'ctrl-space', 'p', etc and the value is the function to execute in the instance's scope)
* @name $.jstree.defaults.core.keyboard
*/
keyboard : {
'ctrl-space': function (e) {
// aria defines space only with Ctrl
e.type = "click";
$(e.currentTarget).trigger(e);
},
'enter': function (e) {
// enter
e.type = "click";
$(e.currentTarget).trigger(e);
},
'left': function (e) {
// left
e.preventDefault();
if(this.is_open(e.currentTarget)) {
this.close_node(e.currentTarget);
}
else {
var o = this.get_parent(e.currentTarget);
if(o && o.id !== $.jstree.root) { this.get_node(o, true).children('.jstree-anchor').focus(); }
}
},
'up': function (e) {
// up
e.preventDefault();
var o = this.get_prev_dom(e.currentTarget);
if(o && o.length) { o.children('.jstree-anchor').focus(); }
},
'right': function (e) {
// right
e.preventDefault();
if(this.is_closed(e.currentTarget)) {
this.open_node(e.currentTarget, function (o) { this.get_node(o, true).children('.jstree-anchor').focus(); });
}
else if (this.is_open(e.currentTarget)) {
var o = this.get_node(e.currentTarget, true).children('.jstree-children')[0];
if(o) { $(this._firstChild(o)).children('.jstree-anchor').focus(); }
}
},
'down': function (e) {
// down
e.preventDefault();
var o = this.get_next_dom(e.currentTarget);
if(o && o.length) { o.children('.jstree-anchor').focus(); }
},
'*': function (e) {
// aria defines * on numpad as open_all - not very common
this.open_all();
},
'home': function (e) {
// home
e.preventDefault();
var o = this._firstChild(this.get_container_ul()[0]);
if(o) { $(o).children('.jstree-anchor').filter(':visible').focus(); }
},
'end': function (e) {
// end
e.preventDefault();
this.element.find('.jstree-anchor').filter(':visible').last().focus();
},
'f2': function (e) {
// f2 - safe to include - if check_callback is false it will fail
e.preventDefault();
this.edit(e.currentTarget);
}
}
dblclick_toggle : true
};
$.jstree.core.prototype = {
/**
@ -628,9 +548,7 @@
this.teardown();
},
/**
* Create a prototype node
* @name _create_prototype_node()
* @return {DOMElement}
* Create prototype node
*/
_create_prototype_node : function () {
var _node = document.createElement('LI'), _temp1, _temp2;
@ -652,48 +570,6 @@
return _node;
},
_kbevent_to_func : function (e) {
var keys = {
8: "Backspace", 9: "Tab", 13: "Return", 19: "Pause", 27: "Esc",
32: "Space", 33: "PageUp", 34: "PageDown", 35: "End", 36: "Home",
37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "Print", 45: "Insert",
46: "Delete", 96: "Numpad0", 97: "Numpad1", 98: "Numpad2", 99 : "Numpad3",
100: "Numpad4", 101: "Numpad5", 102: "Numpad6", 103: "Numpad7",
104: "Numpad8", 105: "Numpad9", '-13': "NumpadEnter", 112: "F1",
113: "F2", 114: "F3", 115: "F4", 116: "F5", 117: "F6", 118: "F7",
119: "F8", 120: "F9", 121: "F10", 122: "F11", 123: "F12", 144: "Numlock",
145: "Scrolllock", 16: 'Shift', 17: 'Ctrl', 18: 'Alt',
48: '0', 49: '1', 50: '2', 51: '3', 52: '4', 53: '5',
54: '6', 55: '7', 56: '8', 57: '9', 59: ';', 61: '=', 65: 'a',
66: 'b', 67: 'c', 68: 'd', 69: 'e', 70: 'f', 71: 'g', 72: 'h',
73: 'i', 74: 'j', 75: 'k', 76: 'l', 77: 'm', 78: 'n', 79: 'o',
80: 'p', 81: 'q', 82: 'r', 83: 's', 84: 't', 85: 'u', 86: 'v',
87: 'w', 88: 'x', 89: 'y', 90: 'z', 107: '+', 109: '-', 110: '.',
186: ';', 187: '=', 188: ',', 189: '-', 190: '.', 191: '/', 192: '`',
219: '[', 220: '\\',221: ']', 222: "'", 111: '/', 106: '*', 173: '-'
};
var parts = [];
if (e.ctrlKey) { parts.push('ctrl'); }
if (e.altKey) { parts.push('alt'); }
if (e.shiftKey) { parts.push('shift'); }
parts.push(keys[e.which] || e.which);
parts = parts.sort().join('-').toLowerCase();
var kb = this.settings.core.keyboard, i, tmp;
for (i in kb) {
if (kb.hasOwnProperty(i)) {
tmp = i;
if (tmp !== '-' && tmp !== '+') {
tmp = tmp.replace('--', '-MINUS').replace('+-', '-MINUS').replace('++', '-PLUS').replace('-+', '-PLUS');
tmp = tmp.split(/-|\+/).sort().join('-').replace('MINUS', '-').replace('PLUS', '+').toLowerCase();
}
if (tmp === parts) {
return kb[i];
}
}
}
return null;
},
/**
* part of the destroying of an instance. Used internally.
* @private
@ -759,16 +635,83 @@
}, this))
.on('keydown.jstree', '.jstree-anchor', $.proxy(function (e) {
if(e.target.tagName && e.target.tagName.toLowerCase() === "input") { return true; }
if(e.which !== 32 && e.which !== 13 && (e.shiftKey || e.ctrlKey || e.altKey || e.metaKey)) { return true; }
var o = null;
if(this._data.core.rtl) {
if(e.which === 37) { e.which = 39; }
else if(e.which === 39) { e.which = 37; }
}
var f = this._kbevent_to_func(e);
if (f) {
var r = f.call(this, e);
if (r === false || r === true) {
return r;
}
switch(e.which) {
case 32: // aria defines space only with Ctrl
if(e.ctrlKey) {
e.type = "click";
$(e.currentTarget).trigger(e);
}
break;
case 13: // enter
e.type = "click";
$(e.currentTarget).trigger(e);
break;
case 37: // left
e.preventDefault();
if(this.is_open(e.currentTarget)) {
this.close_node(e.currentTarget);
}
else {
o = this.get_parent(e.currentTarget);
if(o && o.id !== $.jstree.root) { this.get_node(o, true).children('.jstree-anchor').focus(); }
}
break;
case 38: // up
e.preventDefault();
o = this.get_prev_dom(e.currentTarget);
if(o && o.length) { o.children('.jstree-anchor').focus(); }
break;
case 39: // right
e.preventDefault();
if(this.is_closed(e.currentTarget)) {
this.open_node(e.currentTarget, function (o) { this.get_node(o, true).children('.jstree-anchor').focus(); });
}
else if (this.is_open(e.currentTarget)) {
o = this.get_node(e.currentTarget, true).children('.jstree-children')[0];
if(o) { $(this._firstChild(o)).children('.jstree-anchor').focus(); }
}
break;
case 40: // down
e.preventDefault();
o = this.get_next_dom(e.currentTarget);
if(o && o.length) { o.children('.jstree-anchor').focus(); }
break;
case 106: // aria defines * on numpad as open_all - not very common
this.open_all();
break;
case 36: // home
e.preventDefault();
o = this._firstChild(this.get_container_ul()[0]);
if(o) { $(o).children('.jstree-anchor').filter(':visible').focus(); }
break;
case 35: // end
e.preventDefault();
this.element.find('.jstree-anchor').filter(':visible').last().focus();
break;
case 113: // f2 - safe to include - if check_callback is false it will fail
e.preventDefault();
this.edit(e.currentTarget);
break;
default:
break;
/*!
// delete
case 46:
e.preventDefault();
o = this.get_node(e.currentTarget);
if(o && o.id && o.id !== $.jstree.root) {
o = this.is_selected(o) ? this.get_selected() : o;
this.delete_node(o);
}
break;
*/
}
}, this))
.on("load_node.jstree", $.proxy(function (e, data) {
@ -902,7 +845,7 @@
this.element.attr('tabindex', '-1');
}, this))
.on('focus.jstree', $.proxy(function () {
if(+(new Date()) - was_click > 500 && !this._data.core.focused && this.settings.core.restore_focus) {
if(+(new Date()) - was_click > 500 && !this._data.core.focused) {
was_click = 0;
var act = this.get_node(this.element.attr('aria-activedescendant'), true);
if(act) {
@ -1023,9 +966,6 @@
if(obj && obj.id) {
obj = obj.id;
}
if (obj instanceof $ && obj.length && obj[0].id) {
obj = obj[0].id;
}
var dom;
try {
if(this._model.data[obj]) {
@ -1037,10 +977,10 @@
else if(typeof obj === "string" && (dom = $('#' + obj.replace($.jstree.idregex,'\\$&'), this.element)).length && this._model.data[dom.closest('.jstree-node').attr('id')]) {
obj = this._model.data[dom.closest('.jstree-node').attr('id')];
}
else if((dom = this.element.find(obj)).length && this._model.data[dom.closest('.jstree-node').attr('id')]) {
else if((dom = $(obj, this.element)).length && this._model.data[dom.closest('.jstree-node').attr('id')]) {
obj = this._model.data[dom.closest('.jstree-node').attr('id')];
}
else if((dom = this.element.find(obj)).length && dom.hasClass('jstree')) {
else if((dom = $(obj, this.element)).length && dom.hasClass('jstree')) {
obj = this._model.data[$.jstree.root];
}
else {
@ -1174,7 +1114,7 @@
return obj.parent;
},
/**
* get a jQuery collection of all the children of a node (node must be rendered), returns false on error
* get a jQuery collection of all the children of a node (node must be rendered)
* @name get_children_dom(obj)
* @param {mixed} obj
* @return {jQuery}
@ -1334,7 +1274,7 @@
return true;
},
/**
* load an array of nodes (will also load unavailable nodes as soon as they appear in the structure). Used internally.
* load an array of nodes (will also load unavailable nodes as soon as the appear in the structure). Used internally.
* @private
* @name _load_nodes(nodes [, callback])
* @param {array} nodes
@ -1513,7 +1453,7 @@
*/
_node_changed : function (obj) {
obj = this.get_node(obj);
if (obj && $.inArray(obj.id, this._model.changed) === -1) {
if(obj) {
this._model.changed.push(obj.id);
}
},
@ -1605,7 +1545,6 @@
't_cnt' : this._cnt,
'sel' : this._data.core.selected
},
inst = this,
func = function (data, undefined) {
if(data.data) { data = data.data; }
var dat = data.dat,
@ -1816,21 +1755,10 @@
if(!dat[i].children) {
dat[i].children = [];
}
if(!dat[i].state) {
dat[i].state = {};
}
m[dat[i].id.toString()] = dat[i];
}
// 2) populate children (foreach)
for(i = 0, j = dat.length; i < j; i++) {
if (!m[dat[i].parent.toString()]) {
if (typeof inst !== "undefined") {
inst._data.core.last_error = { 'error' : 'parse', 'plugin' : 'core', 'id' : 'core_07', 'reason' : 'Node with invalid parent', 'data' : JSON.stringify({ 'id' : dat[i].id.toString(), 'parent' : dat[i].parent.toString() }) };
inst.settings.core.error.call(inst, inst._data.core.last_error);
}
continue;
}
m[dat[i].parent.toString()].children.push(dat[i].id.toString());
// populate parent.children_d
p.children_d.push(dat[i].id.toString());
@ -2331,7 +2259,7 @@
this.element.empty().append(f);
//this.get_container_ul()[0].appendChild(f);
}
if(fe !== null && this.settings.core.restore_focus) {
if(fe !== null) {
tmp = this.get_node(fe, true);
if(tmp && tmp.length && tmp.children('.jstree-anchor')[0] !== document.activeElement) {
tmp.children('.jstree-anchor').focus();
@ -2507,9 +2435,6 @@
if(obj.state.hidden) {
c += ' jstree-hidden';
}
if (obj.state.loading) {
c += ' jstree-loading';
}
if(obj.state.loaded && !has_children) {
c += ' jstree-leaf';
}
@ -2614,7 +2539,7 @@
return node;
},
/**
* opens a node, revealing its children. If the node is not loaded it will be loaded and opened once ready.
* opens a node, revaling its children. If the node is not loaded it will be loaded and opened once ready.
* @name open_node(obj [, callback, animation])
* @param {mixed} obj the node to open
* @param {Function} callback a function to execute once the node is opened
@ -2818,7 +2743,7 @@
}
},
/**
* opens all nodes within a node (or the tree), revealing their children. If the node is not loaded it will be loaded and opened once ready.
* opens all nodes within a node (or the tree), revaling their children. If the node is not loaded it will be loaded and opened once ready.
* @name open_all([obj, animation, original_obj])
* @param {mixed} obj the node to open recursively, omit to open all nodes in the tree
* @param {Number} animation the animation duration in milliseconds when opening the nodes, the default is no animation
@ -2859,7 +2784,7 @@
}
},
/**
* closes all nodes within a node (or the tree), revealing their children
* closes all nodes within a node (or the tree), revaling their children
* @name close_all([obj, animation])
* @param {mixed} obj the node to close recursively, omit to close all nodes in the tree
* @param {Number} animation the animation duration in milliseconds when closing the nodes, the default is no animation
@ -3435,7 +3360,6 @@
var state = {
'core' : {
'open' : [],
'loaded' : [],
'scroll' : {
'left' : this.element.scrollLeft(),
'top' : this.element.scrollTop()
@ -3453,9 +3377,6 @@
for(i in this._model.data) {
if(this._model.data.hasOwnProperty(i)) {
if(i !== $.jstree.root) {
if(this._model.data[i].state.loaded && this.settings.core.loaded_state) {
state.core.loaded.push(i);
}
if(this._model.data[i].state.opened) {
state.core.open.push(i);
}
@ -3482,19 +3403,6 @@
}
if(state.core) {
var res, n, t, _this, i;
if(state.core.loaded) {
if(!this.settings.core.loaded_state || !$.isArray(state.core.loaded) || !state.core.loaded.length) {
delete state.core.loaded;
this.set_state(state, callback);
}
else {
this._load_nodes(state.core.loaded, function (nodes) {
delete state.core.loaded;
this.set_state(state, callback);
});
}
return false;
}
if(state.core.open) {
if(!$.isArray(state.core.open) || !state.core.open.length) {
delete state.core.open;
@ -4497,7 +4405,7 @@
w2 = ai.width() * ai.length,
*/
t = default_text;
h1 = $("<"+"div />", { css : { "position" : "absolute", "top" : "-200px", "left" : (rtl ? "0px" : "-1000px"), "visibility" : "hidden" } }).appendTo(document.body);
h1 = $("<"+"div />", { css : { "position" : "absolute", "top" : "-200px", "left" : (rtl ? "0px" : "-1000px"), "visibility" : "hidden" } }).appendTo("body");
h2 = $("<"+"input />", {
"value" : t,
"class" : "jstree-rename-input",
@ -4523,7 +4431,6 @@
s.replaceWith(a);
s.remove();
t = f ? t : $('<div></div>').append($.parseHTML(t)).html();
obj = this.get_node(obj);
this.set_text(obj, t);
nv = !!this.rename_node(obj, f ? $('<div></div>').text(v).text() : $('<div></div>').append($.parseHTML(v)).html());
if(!nv) {
@ -4798,7 +4705,6 @@
obj.icon = icon === true || icon === null || icon === undefined || icon === '' ? true : icon;
dom = this.get_node(obj, true).children(".jstree-anchor").children(".jstree-themeicon");
if(icon === false) {
dom.removeClass('jstree-themeicon-custom ' + old).css("background","").removeAttr("rel");
this.hide_icon(obj);
}
else if(icon === true || icon === null || icon === undefined || icon === '') {
@ -5171,15 +5077,14 @@
if(s.indexOf('down') !== -1) {
//this._data[ t ? 'core' : 'checkbox' ].selected = $.vakata.array_unique(this._data[ t ? 'core' : 'checkbox' ].selected.concat(obj.children_d));
var selectedIds = this._cascade_new_checked_state(obj.id, true);
var temp = obj.children_d.concat(obj.id);
for (i = 0, j = temp.length; i < j; i++) {
if (selectedIds.indexOf(temp[i]) > -1) {
sel[temp[i]] = true;
}
else {
delete sel[temp[i]];
}
}
obj.children_d.concat(obj.id).forEach(function(id) {
if (selectedIds.indexOf(id) > -1) {
sel[id] = true;
}
else {
delete sel[id];
}
});
}
// apply up
@ -5353,18 +5258,16 @@
}, this));
}
};
/**
* get an array of all nodes whose state is "undetermined"
* @name get_undetermined([full])
* @param {boolean} full: if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned
* @return {Array}
* set the undetermined state where and if necessary. Used internally.
* @private
* @name _undetermined()
* @plugin checkbox
*/
this.get_undetermined = function (full) {
if (this.settings.checkbox.cascade.indexOf('undetermined') === -1) {
return [];
}
var i, j, k, l, o = {}, m = this._model.data, t = this.settings.checkbox.tie_selection, s = this._data[ t ? 'core' : 'checkbox' ].selected, p = [], tt = this, r = [];
this._undetermined = function () {
if(this.element === null) { return; }
var i, j, k, l, o = {}, m = this._model.data, t = this.settings.checkbox.tie_selection, s = this._data[ t ? 'core' : 'checkbox' ].selected, p = [], tt = this;
for(i = 0, j = s.length; i < j; i++) {
if(m[s[i]] && m[s[i]].parents) {
for(k = 0, l = m[s[i]].parents.length; k < l; k++) {
@ -5417,28 +5320,14 @@
}
}
});
for (i = 0, j = p.length; i < j; i++) {
if(!m[p[i]].state[ t ? 'selected' : 'checked' ]) {
r.push(full ? m[p[i]] : p[i]);
}
}
return r;
};
/**
* set the undetermined state where and if necessary. Used internally.
* @private
* @name _undetermined()
* @plugin checkbox
*/
this._undetermined = function () {
if(this.element === null) { return; }
var p = this.get_undetermined(false), i, j, s;
this.element.find('.jstree-undetermined').removeClass('jstree-undetermined');
for (i = 0, j = p.length; i < j; i++) {
s = this.get_node(p[i], true);
if(s && s.length) {
s.children('.jstree-anchor').children('.jstree-checkbox').addClass('jstree-undetermined');
for(i = 0, j = p.length; i < j; i++) {
if(!m[p[i]].state[ t ? 'selected' : 'checked' ]) {
s = this.get_node(p[i], true);
if(s && s.length) {
s.children('.jstree-anchor').children('.jstree-checkbox').addClass('jstree-undetermined');
}
}
}
};
@ -5601,65 +5490,63 @@
};
/**
* Cascades checked state to a node and all its descendants. This function does NOT affect hidden and disabled nodes (or their descendants).
* Unchecks a node and all its descendants. This function does NOT affect hidden and disabled nodes (or their descendants).
* However if these unaffected nodes are already selected their ids will be included in the returned array.
* @private
* @param {string} id the node ID
* @param {bool} checkedState should the nodes be checked or not
* @param id
* @param checkedState
* @returns {Array} Array of all node id's (in this tree branch) that are checked.
*/
this._cascade_new_checked_state = function (id, checkedState) {
this._cascade_new_checked_state = function(id, checkedState) {
var self = this;
var t = this.settings.checkbox.tie_selection;
var node = this._model.data[id];
var selectedNodeIds = [];
var selectedChildrenIds = [], i, j, selectedChildIds;
var selectedChildrenIds = [];
if (
(this.settings.checkbox.cascade_to_disabled || !node.state.disabled) &&
(this.settings.checkbox.cascade_to_hidden || !node.state.hidden)
) {
//First try and check/uncheck the children
if (node.children) {
for (i = 0, j = node.children.length; i < j; i++) {
var childId = node.children[i];
selectedChildIds = self._cascade_new_checked_state(childId, checkedState);
//First try and check/uncheck the children
if (node.children) {
node.children.forEach(function(childId) {
var selectedChildIds = self._cascade_new_checked_state(childId, checkedState);
selectedNodeIds = selectedNodeIds.concat(selectedChildIds);
if (selectedChildIds.indexOf(childId) > -1) {
selectedChildrenIds.push(childId);
}
}
});
}
var dom = self.get_node(node, true);
//A node's state is undetermined if some but not all of it's children are checked/selected .
//A node's state is undetermined if some but not all of it's children are checked/selected .
var undetermined = selectedChildrenIds.length > 0 && selectedChildrenIds.length < node.children.length;
if(node.original && node.original.state && node.original.state.undetermined) {
node.original.state.undetermined = undetermined;
}
//If a node is undetermined then remove selected class
//If a node is undetermined then remove selected class
if (undetermined) {
node.state[ t ? 'selected' : 'checked' ] = false;
dom.attr('aria-selected', false).children('.jstree-anchor').removeClass(t ? 'jstree-clicked' : 'jstree-checked');
node.state[ t ? 'selected' : 'checked' ] = false;
dom.attr('aria-selected', false).children('.jstree-anchor').removeClass(t ? 'jstree-clicked' : 'jstree-checked');
}
//Otherwise, if the checkedState === true (i.e. the node is being checked now) and all of the node's children are checked (if it has any children),
//check the node and style it correctly.
//Otherwise, if the checkedState === true (i.e. the node is being checked now) and all of the node's children are checked (if it has any children),
//check the node and style it correctly.
else if (checkedState && selectedChildrenIds.length === node.children.length) {
node.state[ t ? 'selected' : 'checked' ] = checkedState;
node.state[ t ? 'selected' : 'checked' ] = checkedState;
selectedNodeIds.push(node.id);
dom.attr('aria-selected', true).children('.jstree-anchor').addClass(t ? 'jstree-clicked' : 'jstree-checked');
}
else {
node.state[ t ? 'selected' : 'checked' ] = false;
node.state[ t ? 'selected' : 'checked' ] = false;
dom.attr('aria-selected', false).children('.jstree-anchor').removeClass(t ? 'jstree-clicked' : 'jstree-checked');
}
}
else {
selectedChildIds = this.get_checked_descendants(id);
var selectedChildIds = this.get_checked_descendants(id);
if (node.state[ t ? 'selected' : 'checked' ]) {
selectedChildIds.push(node.id);
@ -5673,12 +5560,9 @@
/**
* Gets ids of nodes selected in branch (of tree) specified by id (does not include the node specified by id)
* @name get_checked_descendants(obj)
* @param {string} id the node ID
* @return {Array} array of IDs
* @plugin checkbox
* @param id
*/
this.get_checked_descendants = function (id) {
this.get_checked_descendants = function(id) {
var self = this;
var t = self.settings.checkbox.tie_selection;
var node = self._model.data[id];
@ -5929,7 +5813,7 @@
return res;
};
this.refresh = function (skip_loading, forget_state) {
if(this.settings.checkbox.tie_selection) {
if(!this.settings.checkbox.tie_selection) {
this._data.checkbox.selected = [];
}
return parent.refresh.apply(this, arguments);
@ -5956,7 +5840,7 @@
// own function
this.activate_node = function (obj, e) {
if(this.settings.conditionalselect.call(this, this.get_node(obj), e)) {
return parent.activate_node.call(this, obj, e);
parent.activate_node.call(this, obj, e);
}
};
};
@ -6157,9 +6041,8 @@
}, 750);
})
.on('touchmove.vakata.jstree', function (e) {
if(cto && e.originalEvent && e.originalEvent.changedTouches && e.originalEvent.changedTouches[0] && (Math.abs(ex - e.originalEvent.changedTouches[0].clientX) > 10 || Math.abs(ey - e.originalEvent.changedTouches[0].clientY) > 10)) {
if(cto && e.originalEvent && e.originalEvent.changedTouches && e.originalEvent.changedTouches[0] && (Math.abs(ex - e.originalEvent.changedTouches[0].clientX) > 50 || Math.abs(ey - e.originalEvent.changedTouches[0].clientY) > 50)) {
clearTimeout(cto);
$.vakata.context.hide();
}
})
.on('touchend.vakata.jstree', function (e) {
@ -6431,7 +6314,7 @@
vakata_context.element.html(vakata_context.html);
}
if(vakata_context.items.length) {
vakata_context.element.appendTo(document.body);
vakata_context.element.appendTo("body");
e = vakata_context.element;
x = vakata_context.position_x;
y = vakata_context.position_y;
@ -6487,7 +6370,7 @@
}
};
$(function () {
right_to_left = $(document.body).css("direction") === "rtl";
right_to_left = $("body").css("direction") === "rtl";
var to = false;
vakata_context.element = $("<ul class='vakata-context'></ul>");
@ -6775,23 +6658,11 @@
marker = $('<div id="jstree-marker">&#160;</div>').hide(); //.appendTo('body');
$(document)
.on('dragover.vakata.jstree', function (e) {
if (elm) {
$.vakata.dnd._trigger('move', e, { 'helper': $(), 'element': elm, 'data': drg });
}
})
.on('drop.vakata.jstree', function (e) {
if (elm) {
$.vakata.dnd._trigger('stop', e, { 'helper': $(), 'element': elm, 'data': drg });
elm = null;
drg = null;
}
})
.on('dnd_start.vakata.jstree', function (e, data) {
lastmv = false;
lastev = false;
if(!data || !data.data || !data.data.jstree) { return; }
marker.appendTo(document.body); //.show();
marker.appendTo('body'); //.show();
})
.on('dnd_move.vakata.jstree', function (e, data) {
var isDifferentNode = data.event.target !== lastev.target;
@ -6925,7 +6796,7 @@
lastmv = false;
data.helper.find('.jstree-icon').removeClass('jstree-ok').addClass('jstree-er');
if (data.event.originalEvent && data.event.originalEvent.dataTransfer) {
//data.event.originalEvent.dataTransfer.dropEffect = 'none';
data.event.originalEvent.dataTransfer.dropEffect = 'none';
}
marker.hide();
})
@ -7018,7 +6889,7 @@
helper_left : 5,
helper_top : 10,
threshold : 5,
threshold_touch : 10
threshold_touch : 50
},
_trigger : function (event_name, e, data) {
if (data === undefined) {
@ -7136,7 +7007,7 @@
Math.abs(e.pageY - vakata_dnd.init_y) > (vakata_dnd.is_touch ? $.vakata.dnd.settings.threshold_touch : $.vakata.dnd.settings.threshold)
) {
if(vakata_dnd.helper) {
vakata_dnd.helper.appendTo(document.body);
vakata_dnd.helper.appendTo("body");
vakata_dnd.helper_w = vakata_dnd.helper.outerWidth();
}
vakata_dnd.is_drag = true;
@ -7528,7 +7399,7 @@
}
if(!skip_async && a !== false) {
if($.isFunction(a)) {
return a.call(this, str, $.proxy(function (d) {
return a.call(this, str, inside, $.proxy(function (d) { // CHANGE: added "inside" as argument
if(d && d.d) { d = d.d; }
this._load_nodes(!$.isArray(d) ? [] : $.vakata.array_unique(d), function () {
this.search(str, true, show_only_matches, inside, append, show_only_matches_children);
@ -7883,13 +7754,7 @@
* @name $.jstree.defaults.state.filter
* @plugin state
*/
filter : false,
/**
* Should loaded nodes be restored (setting this to true means that it is possible that the whole tree will be loaded for some users - use with caution). Defaults to `false`
* @name $.jstree.defaults.state.preserve_loaded
* @plugin state
*/
preserve_loaded : false
filter : false
};
$.jstree.plugins.state = function (options, parent) {
this.bind = function () {
@ -7919,11 +7784,7 @@
* @plugin state
*/
this.save_state = function () {
var tm = this.get_state();
if (!this.settings.state.preserve_loaded) {
delete tm.core.loaded;
}
var st = { 'state' : tm, 'ttl' : this.settings.state.ttl, 'sec' : +(new Date()) };
var st = { 'state' : this.get_state(), 'ttl' : this.settings.state.ttl, 'sec' : +(new Date()) };
$.vakata.storage.set(this.settings.state.key, JSON.stringify(st));
};
/**
@ -7938,9 +7799,6 @@
if(!!k && k.state) { k = k.state; }
if(!!k && $.isFunction(this.settings.state.filter)) { k = this.settings.state.filter.call(this, k); }
if(!!k) {
if (!this.settings.state.preserve_loaded) {
delete k.core.loaded;
}
this.element.one("set_state.jstree", function (e, data) { data.instance.trigger('restore_state', { 'state' : $.extend(true, {}, k) }); });
this.set_state(k);
return true;
@ -8344,12 +8202,6 @@
* @plugin unique
*/
case_sensitive : false,
/**
* Indicates if white space should be trimmed before the comparison. Default is `false`.
* @name $.jstree.defaults.unique.trim_whitespace
* @plugin unique
*/
trim_whitespace : false,
/**
* A callback executed in the instance's scope when a new node is created and the name is already taken, the two arguments are the conflicting name and the counter. The default will produce results like `New node (2)`.
* @name $.jstree.defaults.unique.duplicate
@ -8369,32 +8221,16 @@
var n = chk === "rename_node" ? pos : obj.text,
c = [],
s = this.settings.unique.case_sensitive,
w = this.settings.unique.trim_whitespace,
m = this._model.data, i, j, t;
m = this._model.data, i, j;
for(i = 0, j = par.children.length; i < j; i++) {
t = m[par.children[i]].text;
if (!s) {
t = t.toLowerCase();
}
if (w) {
t = t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
}
c.push(t);
c.push(s ? m[par.children[i]].text : m[par.children[i]].text.toLowerCase());
}
if(!s) { n = n.toLowerCase(); }
if (w) { n = n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); }
switch(chk) {
case "delete_node":
return true;
case "rename_node":
t = obj.text || '';
if (!s) {
t = t.toLowerCase();
}
if (w) {
t = t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
}
i = ($.inArray(n, c) === -1 || (obj.text && t === n));
i = ($.inArray(n, c) === -1 || (obj.text && obj.text[ s ? 'toString' : 'toLowerCase']() === n));
if(!i) {
this._data.core.last_error = { 'error' : 'check', 'plugin' : 'unique', 'id' : 'unique_01', 'reason' : 'Child with name ' + n + ' already exists. Preventing: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) };
}
@ -8434,36 +8270,15 @@
return parent.create_node.call(this, par, node, pos, callback, is_loaded);
}
if(!node) { node = {}; }
var tmp, n, dpc, i, j, m = this._model.data, s = this.settings.unique.case_sensitive, w = this.settings.unique.trim_whitespace, cb = this.settings.unique.duplicate, t;
var tmp, n, dpc, i, j, m = this._model.data, s = this.settings.unique.case_sensitive, cb = this.settings.unique.duplicate;
n = tmp = this.get_string('New node');
dpc = [];
for(i = 0, j = par.children.length; i < j; i++) {
t = m[par.children[i]].text;
if (!s) {
t = t.toLowerCase();
}
if (w) {
t = t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
}
dpc.push(t);
dpc.push(s ? m[par.children[i]].text : m[par.children[i]].text.toLowerCase());
}
i = 1;
t = n;
if (!s) {
t = t.toLowerCase();
}
if (w) {
t = t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
}
while($.inArray(t, dpc) !== -1) {
while($.inArray(s ? n : n.toLowerCase(), dpc) !== -1) {
n = cb.call(this, tmp, (++i)).toString();
t = n;
if (!s) {
t = t.toLowerCase();
}
if (w) {
t = t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
}
}
node.text = n;
}
@ -8580,7 +8395,7 @@
};
// include the wholerow plugin by default
// $.jstree.defaults.plugins.push("wholerow");
if(window.customElements && Object && Object.create) {
if(document.registerElement && Object && Object.create) {
var proto = Object.create(HTMLElement.prototype);
proto.createdCallback = function () {
var c = { core : {}, plugins : [] }, i;
@ -8601,8 +8416,8 @@
};
// proto.attributeChangedCallback = function (name, previous, value) { };
try {
window.customElements.define("vakata-jstree", function() {}, { prototype: proto });
} catch (ignore) { }
document.registerElement("vakata-jstree", { prototype: proto });
} catch(ignore) { }
}
}));
}));

16
muk_web_utils/static/lib/jsTree/themes/default/style.css

@ -189,9 +189,6 @@
border: 0;
box-shadow: 0 0 0;
}
.vakata-context .vakata-contextmenu-disabled > a > i {
filter: grayscale(100%);
}
.vakata-context li > a > i {
text-decoration: none;
display: inline-block;
@ -557,6 +554,9 @@
text-overflow: ellipsis;
overflow: hidden;
}
.jstree-default .jstree-ellipsis.jstree-no-icons .jstree-anchor {
width: calc(100% - 5px);
}
.jstree-default.jstree-rtl .jstree-node {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAACAQMAAAB49I5GAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMOBgAAGAAJMwQHdQAAAABJRU5ErkJggg==");
}
@ -738,6 +738,9 @@
text-overflow: ellipsis;
overflow: hidden;
}
.jstree-default-small .jstree-ellipsis.jstree-no-icons .jstree-anchor {
width: calc(100% - 5px);
}
.jstree-default-small.jstree-rtl .jstree-node {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAACAQMAAABv1h6PAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjAAMHBgAAiABBI4gz9AAAAABJRU5ErkJggg==");
}
@ -919,6 +922,9 @@
text-overflow: ellipsis;
overflow: hidden;
}
.jstree-default-large .jstree-ellipsis.jstree-no-icons .jstree-anchor {
width: calc(100% - 5px);
}
.jstree-default-large.jstree-rtl .jstree-node {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAACAQMAAAAD0EyKAAAABlBMVEUAAAAdHRvEkCwcAAAAAXRSTlMAQObYZgAAAAxJREFUCNdjgIIGBgABCgCBvVLXcAAAAABJRU5ErkJggg==");
}
@ -1006,13 +1012,13 @@
background: transparent;
}
.jstree-default-responsive .jstree-open > .jstree-ocl {
background-position: 0 0 !important;
background-position: 0 0px !important;
}
.jstree-default-responsive .jstree-closed > .jstree-ocl {
background-position: 0 -40px !important;
}
.jstree-default-responsive.jstree-rtl .jstree-closed > .jstree-ocl {
background-position: -40px 0 !important;
background-position: -40px 0px !important;
}
.jstree-default-responsive .jstree-themeicon {
background-position: -40px -40px;

8
muk_web_utils/static/src/js/underscore.js

@ -18,9 +18,7 @@
**********************************************************************************/
_.mixin({
memoizeDebounce: function(func, wait, options) {
wait = (typeof wait !== 'undefined') ? wait : 0;
options = (typeof options !== 'undefined') ? options : {};
memoizeDebounce: function(func, wait=0, options={}) {
var mem = _.memoize(function() {
return _.debounce(func, wait, options)
}, options.resolver);
@ -31,9 +29,7 @@ _.mixin({
});
_.mixin({
memoizeThrottle: function(func, wait, options) {
wait = (typeof wait !== 'undefined') ? wait : 0;
options = (typeof options !== 'undefined') ? options : {};
memoizeThrottle: function(func, wait=0, options={}) {
var mem = _.memoize(function() {
return _.throttle(func, wait, options)
}, options.resolver);

2
muk_web_utils/template/assets.xml

@ -60,4 +60,4 @@
<script type="text/javascript" src="/muk_web_utils/static/tests/mimetype.js"/>
</xpath>
</template>
</odoo>
</odoo>
Loading…
Cancel
Save