diff --git a/CHANGE.md b/CHANGE.md index 318eb35..14fa139 100755 --- a/CHANGE.md +++ b/CHANGE.md @@ -5,6 +5,7 @@ Change Log: `yii2-tree-manager` **Date:** _under development_ +- (enh #240): Rename events triggered via jquery to start with `treeview:`. - (enh #239): Allow CSS class to hide elements to be configurable (for BS 3.x / 4.x). New property `hideCssClass`. - (enh #238): Add Chinese Translations. diff --git a/src/assets/js/kv-tree-input.js b/src/assets/js/kv-tree-input.js index 563b4f2..22a8289 100644 --- a/src/assets/js/kv-tree-input.js +++ b/src/assets/js/kv-tree-input.js @@ -73,7 +73,7 @@ self.$dropdown.on('click', function (e) { e.stopPropagation(); }); - self.$element.on('treeview.change', function (event, keys, desc) { + self.$element.on('treeview:change', function (event, keys, desc) { self.setInput(desc.split(',')); if (self.autoCloseOnSelect) { self.$input.closest('.kv-tree-dropdown-container').removeClass('open'); diff --git a/src/assets/js/kv-tree-input.min.js b/src/assets/js/kv-tree-input.min.js index fc5d9a8..4c437f9 100644 --- a/src/assets/js/kv-tree-input.min.js +++ b/src/assets/js/kv-tree-input.min.js @@ -10,4 +10,4 @@ * For more JQuery plugins visit http://plugins.krajee.com * For more Yii related demos visit http://demos.krajee.com */ -!function(t){"use strict";var e,n;e=function(e,n){return null==e||0===e.length||n&&""===t.trim(e)},(n=function(e,n){this.$element=t(e),this.init(n),this.listen()}).prototype={constructor:n,init:function(n){var i,l,o,r=this,s=[];if(t.each(n,function(t,e){r[t]=e}),r.$tree=t("#"+r.treeId),r.$input=t("#"+r.inputId),r.$dropdown=t("#"+r.dropdownId),e(r.placeholder)&&(r.placeholder=" "),e(r.value))r.$input.html(r.caret+r.placeholder);else{for(o=r.value.toString().split(","),i=0;i.kv-tree-list .kv-node-label").text(),s.push(l);r.setInput(s)}},setInput:function(t){var n="";this.$input.removeClass("has-multi"),e(t)||e(t[0])?n=this.placeholder:1===t.length?n=t[0]:(n='
',this.$input.addClass("has-multi")),this.$input.html(this.caret+n)},listen:function(){var t=this;t.$dropdown.on("click",function(t){t.stopPropagation()}),t.$element.on("treeview.change",function(e,n,i){t.setInput(i.split(",")),t.autoCloseOnSelect&&t.$input.closest(".kv-tree-dropdown-container").removeClass("open")})}},t.fn.treeinput=function(e){var i,l,o,r=Array.apply(null,arguments);return r.shift(),this.each(function(){i=t(this),l=i.data("treeinput"),o="object"==typeof e&&e,l||(l=new n(this,t.extend({},t.fn.treeinput.defaults,o,t(this).data())),i.data("treeinput",l)),"string"==typeof e&&l[e].apply(l,r)})},t.fn.treeinput.defaults={treeId:"",inputId:"",dropdownId:"",placeholder:"",value:"",caret:"",autoCloseOnSelect:!0},t.fn.treeinput.Constructor=n}(window.jQuery); \ No newline at end of file +!function(t){"use strict";var e,n;e=function(e,n){return null===e||void 0===e||0===e.length||n&&""===t.trim(e)},n=function(e,n){var i=this;i.$element=t(e),i.init(n),i.listen()},n.prototype={constructor:n,init:function(n){var i,l,r,o,u=this,a=[];if(t.each(n,function(t,e){u[t]=e}),u.$tree=t("#"+u.treeId),u.$input=t("#"+u.inputId),u.$dropdown=t("#"+u.dropdownId),e(u.placeholder)&&(u.placeholder=" "),e(u.value))return void u.$input.html(u.caret+u.placeholder);for(o=u.value.toString().split(","),i=0;i.kv-tree-list .kv-node-label").text(),a.push(r);u.setInput(a)},setInput:function(t){var n=this,i="";n.$input.removeClass("has-multi"),e(t)||e(t[0])?i=n.placeholder:1===t.length?i=t[0]:(i='
',n.$input.addClass("has-multi")),n.$input.html(n.caret+i)},listen:function(){var t=this;t.$dropdown.on("click",function(t){t.stopPropagation()}),t.$element.on("treeview:change",function(e,n,i){t.setInput(i.split(",")),t.autoCloseOnSelect&&t.$input.closest(".kv-tree-dropdown-container").removeClass("open")})}},t.fn.treeinput=function(e){var i,l,r,o=Array.apply(null,arguments);return o.shift(),this.each(function(){i=t(this),l=i.data("treeinput"),r="object"==typeof e&&e,l||(l=new n(this,t.extend({},t.fn.treeinput.defaults,r,t(this).data())),i.data("treeinput",l)),"string"==typeof e&&l[e].apply(l,o)})},t.fn.treeinput.defaults={treeId:"",inputId:"",dropdownId:"",placeholder:"",value:"",caret:"",autoCloseOnSelect:!0},t.fn.treeinput.Constructor=n}(window.jQuery); \ No newline at end of file diff --git a/src/assets/js/kv-tree.js b/src/assets/js/kv-tree.js index 34fd582..d47a332 100644 --- a/src/assets/js/kv-tree.js +++ b/src/assets/js/kv-tree.js @@ -231,7 +231,7 @@ url: vUrl, cache: true, beforeSend: function (jqXHR, settings) { - if (!self.raise('treeview.beforeselect', [key, jqXHR, settings])) { + if (!self.raise('treeview:beforeselect', [key, jqXHR, settings])) { return; } if ($form.length) { @@ -242,11 +242,11 @@ }, success: function (data, textStatus, jqXHR) { $detail.removeClass('kv-loading'); - if (!self.raise('treeview.selected', [key, data, textStatus, jqXHR])) { + if (!self.raise('treeview:selected', [key, data, textStatus, jqXHR])) { return; } if (data.status === 'error') { - if (self.raise('treeview.selecterror', [key, data, textStatus, jqXHR])) { + if (self.raise('treeview:selecterror', [key, data, textStatus, jqXHR])) { $detail.html('
' + data.out + '
'); } return; @@ -262,10 +262,10 @@ } }, error: function (jqXHR, textStatus, errorThrown) { - self.raise('treeview.selectajaxerror', [key, jqXHR, textStatus, errorThrown]); + self.raise('treeview:selectajaxerror', [key, jqXHR, textStatus, errorThrown]); }, complete: function (jqXHR) { - if (self.raise('treeview.selectajaxcomplete', [key, jqXHR])) { + if (self.raise('treeview:selectajaxcomplete', [key, jqXHR])) { self.validateTooltips(); } } @@ -384,7 +384,7 @@ }), url: self.actions.remove, beforeSend: function (jqXHR, settings) { - if (!self.raise('treeview.beforeremove', [key, jqXHR, settings])) { + if (!self.raise('treeview:beforeremove', [key, jqXHR, settings])) { return; } $form.hide(); @@ -394,7 +394,7 @@ success: function (data, textStatus, jqXHR) { $detail.removeClass('kv-loading'); if (data.status === 'success') { - if (!self.raise('treeview.remove', [key, data, textStatus, jqXHR])) { + if (!self.raise('treeview:remove', [key, data, textStatus, jqXHR])) { return; } if ((self.isAdmin || self.showInactive) && self.softDelete) { @@ -416,7 +416,7 @@ self.disableToolbar(); } } else { - if (!self.raise('treeview.removeerror', [key, data, textStatus, jqXHR])) { + if (!self.raise('treeview:removeerror', [key, data, textStatus, jqXHR])) { return; } self.showAlert(data.out, 'danger'); @@ -424,10 +424,10 @@ } }, error: function (jqXHR, textStatus, errorThrown) { - self.raise('treeview.removeajaxerror', [key, jqXHR, textStatus, errorThrown]); + self.raise('treeview:removeajaxerror', [key, jqXHR, textStatus, errorThrown]); }, complete: function (jqXHR) { - self.raise('treeview.removeajaxcomplete', [jqXHR]); + self.raise('treeview:removeajaxcomplete', [jqXHR]); } }); }); @@ -517,7 +517,7 @@ }), url: self.actions.move, beforeSend: function (jqXHR, settings) { - if (!self.raise('treeview.beforemove', [dir, keyFrom, keyTo, jqXHR, settings])) { + if (!self.raise('treeview:beforemove', [dir, keyFrom, keyTo, jqXHR, settings])) { return; } $h.addCss(self.$treeContainer, 'kv-loading-search'); @@ -528,7 +528,7 @@ } self.$treeContainer.removeClass('kv-loading-search'); if (data.status === 'success') { - if (!self.raise('treeview.move', [dir, keyFrom, keyTo, data, textStatus, jqXHR])) { + if (!self.raise('treeview:move', [dir, keyFrom, keyTo, data, textStatus, jqXHR])) { return; } fnMove(); @@ -552,7 +552,7 @@ } }); } else { - if ($detail.length > 0 && self.raise('treeview.moveerror', + if ($detail.length > 0 && self.raise('treeview:moveerror', [dir, keyFrom, keyTo, data, textStatus, jqXHR])) { self.showAlert(data.out, 'danger'); } @@ -560,7 +560,7 @@ }, error: function (jqXHR, textStatus, errorThrown) { self.$treeContainer.removeClass('kv-loading-search'); - if (!self.raise('treeview.moveajaxerror', [dir, keyFrom, keyTo, jqXHR, textStatus, errorThrown])) { + if (!self.raise('treeview:moveajaxerror', [dir, keyFrom, keyTo, jqXHR, textStatus, errorThrown])) { return; } if ($detail.length > 0) { @@ -569,7 +569,7 @@ } }, complete: function (jqXHR) { - self.raise('treeview.moveajaxcomplete', [jqXHR]); + self.raise('treeview:moveajaxcomplete', [jqXHR]); } }); }, @@ -580,7 +580,7 @@ keys += sep + $node.data('key'); desc += sep + $node.find('>.kv-tree-list .kv-node-label').text(); }); - if (!self.raise('treeview.change', [keys, desc])) { + if (!self.raise('treeview:change', [keys, desc])) { return; } self.$element.val(keys); @@ -620,7 +620,7 @@ $h.addCss($newNode.find('.kv-node-detail'), 'kv-focussed'); return; } - if (!self.raise('treeview.create', [key])) { + if (!self.raise('treeview:create', [key])) { return; } $newNode = $(document.createElement('li')).attr({ @@ -653,7 +653,7 @@ createRoot: function () { var self = this, $treeRoot = self.$tree.find('.kv-tree'), $root = $treeRoot.children('li.kv-empty'); - if (!self.raise('treeview.createroot')) { + if (!self.raise('treeview:createroot')) { return; } self.$tree.find('.kv-node-detail').removeClass('kv-focussed'); @@ -680,11 +680,11 @@ toggle: function ($tog) { var self = this, $node = $tog.closest('li.kv-parent'), nodeKey = $node.data('key'); if ($node.hasClass('kv-collapsed')) { - if (self.raise('treeview.expand', [nodeKey])) { + if (self.raise('treeview:expand', [nodeKey])) { $node.removeClass('kv-collapsed'); } } else { - if (self.raise('treeview.collapse', [nodeKey])) { + if (self.raise('treeview:collapse', [nodeKey])) { $h.addCss($node, 'kv-collapsed'); } } @@ -692,14 +692,14 @@ toggleAll: function (action, trig) { var self = this; if (action === 'expand') { - if (trig && !self.raise('treeview.expandall')) { + if (trig && !self.raise('treeview:expandall')) { return; } self.$treeContainer.removeClass('kv-collapsed'); self.$treeContainer.find('.kv-collapsed').removeClass('kv-collapsed'); return; } - if (trig && !self.raise('treeview.collapseall')) { + if (trig && !self.raise('treeview:collapseall')) { return; } $h.addCss(self.$treeContainer.find('li.kv-parent'), 'kv-collapsed'); @@ -713,12 +713,12 @@ return; } if ($node.hasClass('kv-selected')) { - if (!self.raise('treeview.unchecked', [nodeKey])) { + if (!self.raise('treeview:unchecked', [nodeKey])) { return; } $node.removeClass('kv-selected'); if (!isMultiple) { - if (!self.raise('treeview.change', ['', ''])) { + if (!self.raise('treeview:change', ['', ''])) { return; } self.$tree.find('li:not(.kv-disabled)').removeClass('kv-selected'); @@ -730,12 +730,12 @@ } } } else { - if (!self.raise('treeview.checked', [nodeKey])) { + if (!self.raise('treeview:checked', [nodeKey])) { return; } if (!isMultiple) { desc = $node.find('>.kv-tree-list .kv-node-label').text(); - if (!self.raise('treeview.change', [nodeKey, desc])) { + if (!self.raise('treeview:change', [nodeKey, desc])) { return; } self.$tree.find('li:not(.kv-disabled)').removeClass('kv-selected'); @@ -879,7 +879,7 @@ }); self.$treeContainer.removeClass('kv-loading-search'); self.$treeContainer.find('.kv-tree-container').removeClass('kv-collapsed'); - self.raise('treeview.search'); + self.raise('treeview:search'); if (filter.length === 0) { self.blurFilter(); } @@ -901,7 +901,7 @@ self.$tree.find('.kv-node-detail').each(function () { $(this).on('click', function () { var $el = $(this), $node = $el.closest('li'), key = $node.data('key'); - if (!self.raise('treeview.select', [key])) { + if (!self.raise('treeview:select', [key])) { return; } if (self.$tree.hasClass('kv-tree-input-widget')) { diff --git a/src/assets/js/kv-tree.min.js b/src/assets/js/kv-tree.min.js index d46c18e..55872f5 100644 --- a/src/assets/js/kv-tree.min.js +++ b/src/assets/js/kv-tree.min.js @@ -10,4 +10,4 @@ * For more JQuery plugins visit http://plugins.krajee.com * For more Yii related demos visit http://demos.krajee.com */ -!function(e){"use strict";var t,a;t={QUERY_PARAM:"kvtree",DEFAULT_BUTTONS:{create:"create",createR:"create-root",trash:"remove",moveU:"move-up",moveD:"move-down",moveL:"move-left",moveR:"move-right",refresh:"refresh"},isEmpty:function(t,a){return null===t||void 0===t||0===t.length||a&&""===e.trim(t)},escapeRegExp:function(e){return e.replace(/[\-\[\]\/\{}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},addCss:function(e,t){e.removeClass(t).addClass(t)},hashString:function(e){return e.split("").reduce(function(e,t){return e=(e<<5)-e+t.charCodeAt(0),e&e},0)},delay:function(){var e=0;return function(t,a){clearTimeout(e),e=setTimeout(t,a)}}()},a=function(t,a){var i=this;i.$element=e(t),i.init(a),i.listen()},a.prototype={constructor:a,init:function(a){var i,s=this;s.initCache(),e.each(a,function(e,t){s[e]=t}),s.dialogLib=window[s.dialogLib]||"",s.btns=e.extend({},t.DEFAULT_BUTTONS,s.btns),s.$tree=e("#"+s.treeId),s.$treeContainer=s.$tree.closest(".kv-tree-wrapper"),s.$detail=e("#"+s.detailId),s.$toolbar=e("#"+s.toolbarId),s.$wrapper=e("#"+s.wrapperId),s.$searchContainer=s.$wrapper.find(".kv-search-container"),s.$search=s.$wrapper.find(".kv-search-input"),s.$clear=s.$wrapper.find(".kv-search-clear"),i=s.$detail.find("form"),s.treeManageHash=i.find('input[name="treeManageHash"]').val(),s.treeRemoveHash=i.find('input[name="treeRemoveHash"]').val(),s.treeMoveHash=i.find('input[name="treeMoveHash"]').val(),s.select(s.$element.data("key"),!0),s.treeCache.timeout=s.cacheTimeout,s.hasActiveFilter=!1,s.selectNodes(),s.validateTooltips()},initCache:function(){var t=this;t.treeCache={timeout:3e5,data:{},remove:function(e){delete t.treeCache.data[e]},exist:function(e){var a=t.treeCache;return!!a.data[e]&&(new Date).getTime()-a.data[e]._"+e+"").fadeIn(i.alertFadeDuration,function(){i.trigAlert(r,a)})},removeAlert:function(){var e=this;e.$detail.find(".alert").addClass(e.hideCssClass)},renderForm:function(a,i,s){var r=this,n=r.$detail,o=i||"",l=s||!1,d=t.hashString(a+r.modelClass+r.isAdmin+o),c=n.find("form"),v=r.actions.manage,f=v&&-1!==v.indexOf("?")?"&":"?";v+=encodeURI(f+t.QUERY_PARAM+"="+d),r.formViewBegin=!0,r.parseCache(),r.removeAlert(),e.ajax({type:"post",dataType:"json",data:r.getAjaxData({id:a,modelClass:r.modelClass,hideCssClass:r.hideCssClass,defaultBtnCss:r.defaultBtnCss,isAdmin:r.isAdmin,formAction:r.formAction,formOptions:r.formOptions,parentKey:o,iconsList:r.iconsList,currUrl:r.currUrl,softDelete:r.softDelete,showFormButtons:r.showFormButtons,showIDAttribute:r.showIDAttribute,showNameAttribute:r.showNameAttribute,multiple:r.multiple,nodeView:r.nodeView,nodeAddlViews:r.nodeAddlViews,nodeViewButtonLabels:r.nodeViewButtonLabels,nodeViewParams:r.nodeViewParams,nodeSelected:r.nodeSelected,noNodesMessage:r.noNodesMessage,breadcrumbs:r.breadcrumbs,allowNewRoots:r.allowNewRoots,treeManageHash:r.treeManageHash,treeRemoveHash:r.treeRemoveHash,treeMoveHash:r.treeMoveHash}),url:v,cache:!0,beforeSend:function(e,i){r.raise("treeview.beforeselect",[a,e,i])&&(c.length&&c.off().yiiActiveForm("destroy").remove(),n.html(""),t.addCss(n,"kv-loading"))},success:function(e,i,s){if(n.removeClass("kv-loading"),r.raise("treeview.selected",[a,e,i,s])){if("error"===e.status)return void(r.raise("treeview.selecterror",[a,e,i,s])&&n.html('
'+e.out+"
"));n.html(e.out),n.find('button[type="reset"]').on("click",function(){r.removeAlert()}),r.removeAlert(),l===!1||t.isEmpty(l.out)||r.showAlert(l.out,l.type)}},error:function(e,t,i){r.raise("treeview.selectajaxerror",[a,e,t,i])},complete:function(e){r.raise("treeview.selectajaxcomplete",[a,e])&&r.validateTooltips()}})},select:function(a,i,s){if(!t.isEmpty(a)){var r,n=this,o=i||!1,l=s||!1,d=n.$tree.find('li[data-key="'+a+'"]>.kv-tree-list .kv-node-detail');0!==d.length&&(n.$tree.find(".kv-node-detail").removeClass("kv-focussed"),t.addCss(d,"kv-focussed"),o?n.$tree.find("li.kv-parent").each(function(){var t=e(this);t.has(d).length>0&&t.removeClass("kv-collapsed")}):n.renderForm(a,null,l),r=d.closest("li"),r.data("disabled")?n.disableToolbar():n.enableToolbar(),(!r.data("removable")||r.hasClass("kv-inactive")&&n.softDelete||!r.data("removableAll")&&r.hasClass("kv-parent"))&&n.disable("trash"),r.data("movable-u")||n.disable("moveU"),r.data("movable-d")||n.disable("moveD"),r.data("movable-l")||n.disable("moveL"),r.data("movable-r")||n.disable("moveR"),r.data("child-allowed")||n.disable("create"),n.parseParentFlag(a))}},parseParentFlag:function(t){var a,i=this,s=i.$detail.find('input[class="kv-parent-flag"]'),r=i.$tree.find('li[data-key="'+t+'"]');s.each(function(){var t=e(this);a=t.closest("div.checkbox"),a.removeClass("disabled"),r.hasClass("kv-parent")?t.removeAttr("disabled"):(t.attr("disabled","disabled"),a.addClass("disabled"))})},remove:function(){var a,i,s=this,r=s.$tree.find("li .kv-node-detail.kv-focussed"),n=r.closest("li"),o=s.messages,l=s.$detail,d=l.find("form");0===r.length&&!n.hasClass("kv-empty")||n.hasClass("kv-disabled")||(i=function(e){var t=e?o.emptyNodeRemoved:o.nodeRemoved,i=n.closest("li.kv-parent");n.remove(),a=l.find(".alert"),s.formViewBegin=!1,l.find(".kv-select-node-msg").remove(),a.length&&l.before(a).html("").append(a),i.find("li").length||i.removeClass("kv-parent"),s.showAlert(t,"info",function(){l.append('"),setTimeout(function(){s.formViewBegin||l.find(".kv-select-node-msg").fadeIn(s.alertFadeDuration)},s.alertFadeDuration)})},s.dialogLib.confirm(o.removeNode,function(a){if(a){if(n.hasClass("kv-empty"))return void i(!0);var r=n.data("key");e.ajax({type:"post",dataType:"json",data:s.getAjaxData({id:r,modelClass:s.modelClass,softDelete:s.softDelete,treeRemoveHash:s.treeRemoveHash}),url:s.actions.remove,beforeSend:function(e,a){s.raise("treeview.beforeremove",[r,e,a])&&(d.hide(),s.removeAlert(),t.addCss(l,"kv-loading"))},success:function(e,a,o){if(l.removeClass("kv-loading"),"success"===e.status){if(!s.raise("treeview.remove",[r,e,a,o]))return;if((s.isAdmin||s.showInactive)&&s.softDelete){s.showAlert(e.out,"info"),d.show();var c=s.modelClass.split("\\").pop(),v=d.find('input[name="'+c+'[active]"]');v.val(!1),v.prop("checked",!1),t.addCss(n,"kv-inactive"),n.data("removableAll")&&t.addCss(n.find("li"),"kv-inactive"),t.addCss(n,"kv-inactive")}else i();s.softDelete||s.disableToolbar()}else{if(!s.raise("treeview.removeerror",[r,e,a,o]))return;s.showAlert(e.out,"danger"),d.show()}},error:function(e,t,a){s.raise("treeview.removeajaxerror",[r,e,t,a])},complete:function(e){s.raise("treeview.removeajaxcomplete",[e])}})}}))},move:function(a){var i,s,r,n,o=this,l=o.$tree.find("li .kv-node-detail.kv-focussed"),d=l.closest("li"),c=o.messages,v=o.$detail,f=null,h=!1,u=function(){};if(0!==l.length&&!d.hasClass("kv-disabled")){if(d.hasClass("kv-empty"))return void o.dialogLib.alert(c.nodeNewMove);switch(a){case"u":if(f=d.prev(),0===f.length)return void o.dialogLib.alert(c.nodeTop);u=function(){f.before(d)};break;case"d":if(f=d.next(),0===f.length)return void o.dialogLib.alert(c.nodeBottom);u=function(){f.after(d)};break;case"l":if(f=d.parent("ul").closest("li.kv-parent"),0===f.length)return void o.dialogLib.alert(c.nodeLeft);n=f.parent("ul"),h=n.hasClass("kv-tree"),h&&(f=n.children("li:last-child")),u=function(){f.after(d),0===f.find("li").length&&(f.removeClass("kv-parent"),f.find("ul").remove())};break;case"r":if(f=d.prev(),0===f.length)return void o.dialogLib.alert(c.nodeRight);u=function(){f.find("li").length>0?f.children("ul").append(d):(t.addCss(f,"kv-parent"),e(document.createElement("ul")).appendTo(f).append(d))};break;default:throw"Invalid move direction '"+a+"'"}i=d.data("key"),s=f.data("key"),e.ajax({type:"post",dataType:"json",data:o.getAjaxData({idFrom:i,idTo:s,modelClass:o.modelClass,dir:a,allowNewRoots:o.allowNewRoots,treeMoveHash:o.treeMoveHash}),url:o.actions.move,beforeSend:function(e,r){o.raise("treeview.beforemove",[a,i,s,e,r])&&t.addCss(o.$treeContainer,"kv-loading-search")},success:function(t,n,l){if(v.length>0&&o.removeAlert(),o.$treeContainer.removeClass("kv-loading-search"),"success"===t.status){if(!o.raise("treeview.move",[a,i,s,t,n,l]))return;u(),"l"===a||"r"===a?(o.treeCache.timeout=0,r=v.length>0?{out:t.out,type:"success"}:!1,o.select(i,!1,r),o.treeCache.timeout=o.cacheTimeout):v.length>0&&o.showAlert(t.out,"success"),o.$tree.find("li.kv-collapsed").each(function(){e(this).has(d).length>0&&e(this).removeClass("kv-collapsed")})}else v.length>0&&o.raise("treeview.moveerror",[a,i,s,t,n,l])&&o.showAlert(t.out,"danger")},error:function(e,t,r){o.$treeContainer.removeClass("kv-loading-search"),o.raise("treeview.moveajaxerror",[a,i,s,e,t,r])&&v.length>0&&(o.removeAlert(),o.showAlert(r,"danger"))},complete:function(e){o.raise("treeview.moveajaxcomplete",[e])}})}},setSelected:function(){var a=this,i="",s="";a.$tree.find(".kv-selected").each(function(){var a=e(this),r=t.isEmpty(i)?"":",";i+=r+a.data("key"),s+=r+a.find(">.kv-tree-list .kv-node-label").text()}),a.raise("treeview.change",[i,s])&&(a.$element.val(i),a.raise("change"))},getNewNode:function(){var e=this;return'
\n
 
\n
\n '+e.messages.emptyNode+"\n
\n
"},create:function(){var a,i,s,r,n,o=this,l=o.$tree.find("li .kv-node-detail.kv-focussed"),d=l.closest("li"),c=o.messages;return d.hasClass("kv-disabled")?void o.dialogLib.alert(c.nodeDisabled):0===l.length||d.hasClass("kv-empty")?void o.dialogLib.alert(c.invalidCreateNode):d.attr("data-child-allowed")?(o.$toolbar.find(".kv-"+o.btns.trash).removeAttr("disabled"),n=d.find("> ul > li.kv-empty"),n.length>0?(i=n.data("key").replace("empty-",""),o.renderForm(null,i),l.removeClass("kv-focussed"),void t.addCss(n.find(".kv-node-detail"),"kv-focussed")):void(o.raise("treeview.create",[i])&&(n=e(document.createElement("li")).attr({"data-key":"empty-"+d.data("key"),"class":"kv-empty"}),s=o.getNewNode(),l.removeClass("kv-focussed"),n.append(s),d.hasClass("kv-parent")?d.children("ul").append(n):(t.addCss(d,"kv-parent"),a=e(document.createElement("ul")).append(n),d.append(a)),o.renderForm(null,d.data("key")),r=n.find(".kv-node-detail"),d.removeClass("kv-collapsed"),n.children(".kv-tree-list").focus(),r.on("click",function(){o.$tree.find(".kv-node-detail").removeClass("kv-focussed"),t.addCss(r,"kv-focussed"),i=n.data("key").replace("empty-",""),o.renderForm(null,i),o.$toolbar.find(".kv-"+o.btns.trash).removeAttr("disabled")})))):void o.dialogLib.alert(c.noChildAllowed)},createRoot:function(){var a=this,i=a.$tree.find(".kv-tree"),s=i.children("li.kv-empty");if(a.raise("treeview.createroot")){if(a.$tree.find(".kv-node-detail").removeClass("kv-focussed"),s.length>0)return t.addCss(s.find(".kv-node-detail"),"kv-focussed"),void a.renderForm(null,a.rootKey);var r=a.getNewNode(),n=e(document.createElement("li")).attr({"data-key":"empty-root","class":"kv-empty"});n.html(r),i.append(n),a.renderForm(null,a.rootKey);var o=n.find(".kv-node-detail");t.addCss(o,"kv-focussed"),a.$toolbar.find(".kv-"+a.btns.trash).removeAttr("disabled"),o.on("click",function(){a.$tree.find(".kv-node-detail").removeClass("kv-focussed"),t.addCss(o,"kv-focussed"),a.renderForm(null,a.rootKey),a.$toolbar.find(".kv-"+a.btns.trash).removeAttr("disabled")})}},toggle:function(e){var a=this,i=e.closest("li.kv-parent"),s=i.data("key");i.hasClass("kv-collapsed")?a.raise("treeview.expand",[s])&&i.removeClass("kv-collapsed"):a.raise("treeview.collapse",[s])&&t.addCss(i,"kv-collapsed")},toggleAll:function(e,a){var i=this;if("expand"===e){if(a&&!i.raise("treeview.expandall"))return;return i.$treeContainer.removeClass("kv-collapsed"),void i.$treeContainer.find(".kv-collapsed").removeClass("kv-collapsed")}a&&!i.raise("treeview.collapseall")||(t.addCss(i.$treeContainer.find("li.kv-parent"),"kv-collapsed"),t.addCss(i.$treeContainer,"kv-collapsed"))},check:function(e){var a,i=this,s=e===!0,r=s?i.$tree:e.closest("li"),n=s?"":r.data("key"),o=i.multiple&&0!=i.multiple;if(!(r.hasClass("kv-disabled")||s&&!o)){if(r.hasClass("kv-selected")){if(!i.raise("treeview.unchecked",[n]))return;if(r.removeClass("kv-selected"),o)i.cascadeSelectChildren&&r.find("li:not(.kv-disabled)").removeClass("kv-selected");else{if(!i.raise("treeview.change",["",""]))return;i.$tree.find("li:not(.kv-disabled)").removeClass("kv-selected"),i.$element.val(""),i.raise("change")}}else{if(!i.raise("treeview.checked",[n]))return;if(o)i.cascadeSelectChildren&&t.addCss(r.find("li:not(.kv-disabled)"),"kv-selected");else{if(a=r.find(">.kv-tree-list .kv-node-label").text(),!i.raise("treeview.change",[n,a]))return;i.$tree.find("li:not(.kv-disabled)").removeClass("kv-selected"),i.$element.val(n),i.raise("change")}t.addCss(r,"kv-selected")}o&&i.setSelected()}},clear:function(){var e=this;e.$treeContainer.removeClass("kv-loading-search"),e.$tree.find(".kv-highlight").removeClass("kv-highlight"),e.blurFilter()},parseCache:function(){var t=this;return t.enableCache?void e.ajaxPrefilter(function(a,i){if(a.cache){var s=i.beforeSend||e.noop,r=i.success||e.noop,n=i.url;a.cache=!1,a.beforeSend=function(){return s(),t.treeCache.exist(n)?(r(t.treeCache.get(n)),!1):!0},a.success=function(e){t.treeCache.set(n,e,r)}}}):!1},focusFilter:function(){var e=this;e.hideUnmatchedSearchItems&&(e.hasActiveFilter||(e.hasActiveFilter=!0),e.$search.val().length>0&&t.addCss(e.$treeContainer,"kv-active-filter"))},blurFilter:function(){var e=this;e.clearSearchResults(),e.hideUnmatchedSearchItems&&(e.hasActiveFilter&&(e.hasActiveFilter=!1),e.$treeContainer.removeClass("kv-active-filter"),e.$treeContainer.find(".kv-highlight").removeClass("kv-highlight"),e.$treeContainer.find(".kv-tree-container li.kv-filter-match").removeClass("kv-filter-match"))},clearSearchResults:function(){var t=this;t.$tree.find(".kv-node-label .kv-search-found").each(function(){var t=e(this),a=e(document.createElement("span")).appendTo(t);a.unwrap().remove()})},listen:function(){var a=this;a.$tree.find(".kv-node-toggle").each(function(){var t=e(this);t.on("click",function(){a.toggle(t)})}),a.$tree.find(".kv-node-checkbox:not(.kv-disabled)").each(function(){var t=e(this);t.on("click",function(){a.check(t)})}),a.$treeContainer.find(".kv-root-node-toggle").on("click",function(){a.$treeContainer.hasClass("kv-collapsed")?a.toggleAll("expand",!0):a.toggleAll("collapse",!0)}),a.$treeContainer.find(".kv-root-node-checkbox").on("click",function(){a.check(!0)}),a.$search.on("keyup",function(){var i=e(this).val();a.clear(),a.clearSearchResults(),t.addCss(a.$treeContainer,"kv-loading-search"),t.delay(function(){a.focusFilter(),a.$tree.find("li.kv-filter-match").removeClass("kv-filter-match"),a.toggleAll("collapse",!1),i=t.escapeRegExp(i),a.$tree.find(".kv-node-label").each(function(){var s,r,n=e(this),o=n.text(),l=o.search(new RegExp(i,"i"));0>l?n.removeClass("kv-highlight"):(t.addCss(n,"kv-highlight"),s=new RegExp(i,"ig"),r=o.replace(s,function(e){return''+e+""}),n.html(r),a.$tree.find("li.kv-parent").each(function(){var t=e(this);t.has(n).length>0&&t.removeClass("kv-collapsed")}))}),a.$tree.find(".kv-highlight").parentsUntil(a.$tree.selector,"li").each(function(){t.addCss(e(this),"kv-filter-match")}),a.$treeContainer.removeClass("kv-loading-search"),a.$treeContainer.find(".kv-tree-container").removeClass("kv-collapsed"),a.raise("treeview.search"),0===i.length&&a.blurFilter()},250)}).on("focus",function(){a.focusFilter()}).on("blur",function(){var t=e(this).val();null!==t&&""!==t||a.blurFilter()}),a.$clear.on("click",function(){a.$search.val(""),a.clear()}),a.$tree.find(".kv-node-detail").each(function(){e(this).on("click",function(){var t=e(this),i=t.closest("li"),s=i.data("key");if(a.raise("treeview.select",[s]))return a.$tree.hasClass("kv-tree-input-widget")?(t.removeClass("kv-focussed"),void a.check(i)):void(t.hasClass("kv-focussed")||(a.select(s),a.removeAlert()))})}),a.$toolbar.find(".kv-"+a.btns.create).on("click",function(){a.create()}),a.$toolbar.find(".kv-"+a.btns.createR).on("click",function(){a.createRoot()}),a.$toolbar.find(".kv-"+a.btns.trash).on("click",function(){a.remove()}),a.$toolbar.find(".kv-"+a.btns.moveU).on("click",function(){a.move("u")}),a.$toolbar.find(".kv-"+a.btns.moveD).on("click",function(){a.move("d")}),a.$toolbar.find(".kv-"+a.btns.moveL).on("click",function(){a.move("l")}),a.$toolbar.find(".kv-"+a.btns.moveR).on("click",function(){a.move("r")}),a.$detail.find(".alert").each(function(){var t=e(this);t.hasClass(a.hideCssClass)||(t.hide().fadeIn(1500),a.trigAlert(t))})},expandAll:function(){this.toggleAll("expand")},collapseAll:function(){this.toggleAll("collapse")},checkAll:function(){var e=this;e.$tree.removeClass("kv-selected"),e.check(!0)},uncheckAll:function(){var e=this;t.addCss(e.$tree,"kv-selected"),e.check(!0)},checkNode:function(e){var t=this,a=t.$tree.find('li[data-key="'+e+'"]');a.length&&(a.removeClass("kv-selected"),t.check(a))},uncheckNode:function(e){var a=this,i=a.$tree.find('li[data-key="'+e+'"]');i.length&&(t.addCss(i,"kv-selected"),a.check(i))}},e.fn.treeview=function(t){var i,s,r,n=Array.apply(null,arguments);return n.shift(),this.each(function(){i=e(this),s=i.data("treeview"),r="object"==typeof t&&t,s||(s=new a(this,e.extend({},e.fn.treeview.defaults,r,e(this).data())),i.data("treeview",s)),"string"==typeof t&&s[t].apply(s,n)})},e.fn.treeview.defaults={btns:{},treeId:"",detailId:"",toolbarId:"",wrapperId:"",showTooltips:!0,alertFadeDuration:1e3,cacheTimeout:3e5,showInactive:!1,actions:{manage:"",move:"","delete":""},messages:{emptyNode:"",nodeDisabled:"",invalidCreateNode:"",removeNode:"",nodeRemoved:"",emptyNodeRemoved:"",nodeNewMove:"",nodeTop:"",nodeBottom:"",nodeLeft:"",nodeRight:"",nodeTitle:"",nodeTitlePlural:""},breadcrumbs:{},cascadeSelectChildren:!0,rootKey:"",hideUnmatchedSearchItems:!0},e.fn.treeview.Constructor=a}(window.jQuery); \ No newline at end of file +!function(e){"use strict";var t,a;t={QUERY_PARAM:"kvtree",DEFAULT_BUTTONS:{create:"create",createR:"create-root",trash:"remove",moveU:"move-up",moveD:"move-down",moveL:"move-left",moveR:"move-right",refresh:"refresh"},isEmpty:function(t,a){return null===t||void 0===t||0===t.length||a&&""===e.trim(t)},escapeRegExp:function(e){return e.replace(/[\-\[\]\/\{}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},addCss:function(e,t){e.removeClass(t).addClass(t)},hashString:function(e){return e.split("").reduce(function(e,t){return e=(e<<5)-e+t.charCodeAt(0),e&e},0)},delay:function(){var e=0;return function(t,a){clearTimeout(e),e=setTimeout(t,a)}}()},a=function(t,a){var i=this;i.$element=e(t),i.init(a),i.listen()},a.prototype={constructor:a,init:function(a){var i,s=this;s.initCache(),e.each(a,function(e,t){s[e]=t}),s.dialogLib=window[s.dialogLib]||"",s.btns=e.extend({},t.DEFAULT_BUTTONS,s.btns),s.$tree=e("#"+s.treeId),s.$treeContainer=s.$tree.closest(".kv-tree-wrapper"),s.$detail=e("#"+s.detailId),s.$toolbar=e("#"+s.toolbarId),s.$wrapper=e("#"+s.wrapperId),s.$searchContainer=s.$wrapper.find(".kv-search-container"),s.$search=s.$wrapper.find(".kv-search-input"),s.$clear=s.$wrapper.find(".kv-search-clear"),i=s.$detail.find("form"),s.treeManageHash=i.find('input[name="treeManageHash"]').val(),s.treeRemoveHash=i.find('input[name="treeRemoveHash"]').val(),s.treeMoveHash=i.find('input[name="treeMoveHash"]').val(),s.select(s.$element.data("key"),!0),s.treeCache.timeout=s.cacheTimeout,s.hasActiveFilter=!1,s.selectNodes(),s.validateTooltips()},initCache:function(){var t=this;t.treeCache={timeout:3e5,data:{},remove:function(e){delete t.treeCache.data[e]},exist:function(e){var a=t.treeCache;return!!a.data[e]&&(new Date).getTime()-a.data[e]._"+e+"").fadeIn(i.alertFadeDuration,function(){i.trigAlert(r,a)})},removeAlert:function(){var e=this;e.$detail.find(".alert").addClass(e.hideCssClass)},renderForm:function(a,i,s){var r=this,n=r.$detail,o=i||"",l=s||!1,d=t.hashString(a+r.modelClass+r.isAdmin+o),c=n.find("form"),v=r.actions.manage,f=v&&-1!==v.indexOf("?")?"&":"?";v+=encodeURI(f+t.QUERY_PARAM+"="+d),r.formViewBegin=!0,r.parseCache(),r.removeAlert(),e.ajax({type:"post",dataType:"json",data:r.getAjaxData({id:a,modelClass:r.modelClass,hideCssClass:r.hideCssClass,defaultBtnCss:r.defaultBtnCss,isAdmin:r.isAdmin,formAction:r.formAction,formOptions:r.formOptions,parentKey:o,iconsList:r.iconsList,currUrl:r.currUrl,softDelete:r.softDelete,showFormButtons:r.showFormButtons,showIDAttribute:r.showIDAttribute,showNameAttribute:r.showNameAttribute,multiple:r.multiple,nodeView:r.nodeView,nodeAddlViews:r.nodeAddlViews,nodeViewButtonLabels:r.nodeViewButtonLabels,nodeViewParams:r.nodeViewParams,nodeSelected:r.nodeSelected,noNodesMessage:r.noNodesMessage,breadcrumbs:r.breadcrumbs,allowNewRoots:r.allowNewRoots,treeManageHash:r.treeManageHash,treeRemoveHash:r.treeRemoveHash,treeMoveHash:r.treeMoveHash}),url:v,cache:!0,beforeSend:function(e,i){r.raise("treeview:beforeselect",[a,e,i])&&(c.length&&c.off().yiiActiveForm("destroy").remove(),n.html(""),t.addCss(n,"kv-loading"))},success:function(e,i,s){if(n.removeClass("kv-loading"),r.raise("treeview:selected",[a,e,i,s])){if("error"===e.status)return void(r.raise("treeview:selecterror",[a,e,i,s])&&n.html('
'+e.out+"
"));n.html(e.out),n.find('button[type="reset"]').on("click",function(){r.removeAlert()}),r.removeAlert(),l===!1||t.isEmpty(l.out)||r.showAlert(l.out,l.type)}},error:function(e,t,i){r.raise("treeview:selectajaxerror",[a,e,t,i])},complete:function(e){r.raise("treeview:selectajaxcomplete",[a,e])&&r.validateTooltips()}})},select:function(a,i,s){if(!t.isEmpty(a)){var r,n=this,o=i||!1,l=s||!1,d=n.$tree.find('li[data-key="'+a+'"]>.kv-tree-list .kv-node-detail');0!==d.length&&(n.$tree.find(".kv-node-detail").removeClass("kv-focussed"),t.addCss(d,"kv-focussed"),o?n.$tree.find("li.kv-parent").each(function(){var t=e(this);t.has(d).length>0&&t.removeClass("kv-collapsed")}):n.renderForm(a,null,l),r=d.closest("li"),r.data("disabled")?n.disableToolbar():n.enableToolbar(),(!r.data("removable")||r.hasClass("kv-inactive")&&n.softDelete||!r.data("removableAll")&&r.hasClass("kv-parent"))&&n.disable("trash"),r.data("movable-u")||n.disable("moveU"),r.data("movable-d")||n.disable("moveD"),r.data("movable-l")||n.disable("moveL"),r.data("movable-r")||n.disable("moveR"),r.data("child-allowed")||n.disable("create"),n.parseParentFlag(a))}},parseParentFlag:function(t){var a,i=this,s=i.$detail.find('input[class="kv-parent-flag"]'),r=i.$tree.find('li[data-key="'+t+'"]');s.each(function(){var t=e(this);a=t.closest("div.checkbox"),a.removeClass("disabled"),r.hasClass("kv-parent")?t.removeAttr("disabled"):(t.attr("disabled","disabled"),a.addClass("disabled"))})},remove:function(){var a,i,s=this,r=s.$tree.find("li .kv-node-detail.kv-focussed"),n=r.closest("li"),o=s.messages,l=s.$detail,d=l.find("form");0===r.length&&!n.hasClass("kv-empty")||n.hasClass("kv-disabled")||(i=function(e){var t=e?o.emptyNodeRemoved:o.nodeRemoved,i=n.closest("li.kv-parent");n.remove(),a=l.find(".alert"),s.formViewBegin=!1,l.find(".kv-select-node-msg").remove(),a.length&&l.before(a).html("").append(a),i.find("li").length||i.removeClass("kv-parent"),s.showAlert(t,"info",function(){l.append('"),setTimeout(function(){s.formViewBegin||l.find(".kv-select-node-msg").fadeIn(s.alertFadeDuration)},s.alertFadeDuration)})},s.dialogLib.confirm(o.removeNode,function(a){if(a){if(n.hasClass("kv-empty"))return void i(!0);var r=n.data("key");e.ajax({type:"post",dataType:"json",data:s.getAjaxData({id:r,modelClass:s.modelClass,softDelete:s.softDelete,treeRemoveHash:s.treeRemoveHash}),url:s.actions.remove,beforeSend:function(e,a){s.raise("treeview:beforeremove",[r,e,a])&&(d.hide(),s.removeAlert(),t.addCss(l,"kv-loading"))},success:function(e,a,o){if(l.removeClass("kv-loading"),"success"===e.status){if(!s.raise("treeview:remove",[r,e,a,o]))return;if((s.isAdmin||s.showInactive)&&s.softDelete){s.showAlert(e.out,"info"),d.show();var c=s.modelClass.split("\\").pop(),v=d.find('input[name="'+c+'[active]"]');v.val(!1),v.prop("checked",!1),t.addCss(n,"kv-inactive"),n.data("removableAll")&&t.addCss(n.find("li"),"kv-inactive"),t.addCss(n,"kv-inactive")}else i();s.softDelete||s.disableToolbar()}else{if(!s.raise("treeview:removeerror",[r,e,a,o]))return;s.showAlert(e.out,"danger"),d.show()}},error:function(e,t,a){s.raise("treeview:removeajaxerror",[r,e,t,a])},complete:function(e){s.raise("treeview:removeajaxcomplete",[e])}})}}))},move:function(a){var i,s,r,n,o=this,l=o.$tree.find("li .kv-node-detail.kv-focussed"),d=l.closest("li"),c=o.messages,v=o.$detail,f=null,h=!1,u=function(){};if(0!==l.length&&!d.hasClass("kv-disabled")){if(d.hasClass("kv-empty"))return void o.dialogLib.alert(c.nodeNewMove);switch(a){case"u":if(f=d.prev(),0===f.length)return void o.dialogLib.alert(c.nodeTop);u=function(){f.before(d)};break;case"d":if(f=d.next(),0===f.length)return void o.dialogLib.alert(c.nodeBottom);u=function(){f.after(d)};break;case"l":if(f=d.parent("ul").closest("li.kv-parent"),0===f.length)return void o.dialogLib.alert(c.nodeLeft);n=f.parent("ul"),h=n.hasClass("kv-tree"),h&&(f=n.children("li:last-child")),u=function(){f.after(d),0===f.find("li").length&&(f.removeClass("kv-parent"),f.find("ul").remove())};break;case"r":if(f=d.prev(),0===f.length)return void o.dialogLib.alert(c.nodeRight);u=function(){f.find("li").length>0?f.children("ul").append(d):(t.addCss(f,"kv-parent"),e(document.createElement("ul")).appendTo(f).append(d))};break;default:throw"Invalid move direction '"+a+"'"}i=d.data("key"),s=f.data("key"),e.ajax({type:"post",dataType:"json",data:o.getAjaxData({idFrom:i,idTo:s,modelClass:o.modelClass,dir:a,allowNewRoots:o.allowNewRoots,treeMoveHash:o.treeMoveHash}),url:o.actions.move,beforeSend:function(e,r){o.raise("treeview:beforemove",[a,i,s,e,r])&&t.addCss(o.$treeContainer,"kv-loading-search")},success:function(t,n,l){if(v.length>0&&o.removeAlert(),o.$treeContainer.removeClass("kv-loading-search"),"success"===t.status){if(!o.raise("treeview:move",[a,i,s,t,n,l]))return;u(),"l"===a||"r"===a?(o.treeCache.timeout=0,r=v.length>0?{out:t.out,type:"success"}:!1,o.select(i,!1,r),o.treeCache.timeout=o.cacheTimeout):v.length>0&&o.showAlert(t.out,"success"),o.$tree.find("li.kv-collapsed").each(function(){e(this).has(d).length>0&&e(this).removeClass("kv-collapsed")})}else v.length>0&&o.raise("treeview:moveerror",[a,i,s,t,n,l])&&o.showAlert(t.out,"danger")},error:function(e,t,r){o.$treeContainer.removeClass("kv-loading-search"),o.raise("treeview:moveajaxerror",[a,i,s,e,t,r])&&v.length>0&&(o.removeAlert(),o.showAlert(r,"danger"))},complete:function(e){o.raise("treeview:moveajaxcomplete",[e])}})}},setSelected:function(){var a=this,i="",s="";a.$tree.find(".kv-selected").each(function(){var a=e(this),r=t.isEmpty(i)?"":",";i+=r+a.data("key"),s+=r+a.find(">.kv-tree-list .kv-node-label").text()}),a.raise("treeview:change",[i,s])&&(a.$element.val(i),a.raise("change"))},getNewNode:function(){var e=this;return'
\n
 
\n
\n '+e.messages.emptyNode+"\n
\n
"},create:function(){var a,i,s,r,n,o=this,l=o.$tree.find("li .kv-node-detail.kv-focussed"),d=l.closest("li"),c=o.messages;return d.hasClass("kv-disabled")?void o.dialogLib.alert(c.nodeDisabled):0===l.length||d.hasClass("kv-empty")?void o.dialogLib.alert(c.invalidCreateNode):d.attr("data-child-allowed")?(o.$toolbar.find(".kv-"+o.btns.trash).removeAttr("disabled"),n=d.find("> ul > li.kv-empty"),n.length>0?(i=n.data("key").replace("empty-",""),o.renderForm(null,i),l.removeClass("kv-focussed"),void t.addCss(n.find(".kv-node-detail"),"kv-focussed")):void(o.raise("treeview:create",[i])&&(n=e(document.createElement("li")).attr({"data-key":"empty-"+d.data("key"),"class":"kv-empty"}),s=o.getNewNode(),l.removeClass("kv-focussed"),n.append(s),d.hasClass("kv-parent")?d.children("ul").append(n):(t.addCss(d,"kv-parent"),a=e(document.createElement("ul")).append(n),d.append(a)),o.renderForm(null,d.data("key")),r=n.find(".kv-node-detail"),d.removeClass("kv-collapsed"),n.children(".kv-tree-list").focus(),r.on("click",function(){o.$tree.find(".kv-node-detail").removeClass("kv-focussed"),t.addCss(r,"kv-focussed"),i=n.data("key").replace("empty-",""),o.renderForm(null,i),o.$toolbar.find(".kv-"+o.btns.trash).removeAttr("disabled")})))):void o.dialogLib.alert(c.noChildAllowed)},createRoot:function(){var a=this,i=a.$tree.find(".kv-tree"),s=i.children("li.kv-empty");if(a.raise("treeview:createroot")){if(a.$tree.find(".kv-node-detail").removeClass("kv-focussed"),s.length>0)return t.addCss(s.find(".kv-node-detail"),"kv-focussed"),void a.renderForm(null,a.rootKey);var r=a.getNewNode(),n=e(document.createElement("li")).attr({"data-key":"empty-root","class":"kv-empty"});n.html(r),i.append(n),a.renderForm(null,a.rootKey);var o=n.find(".kv-node-detail");t.addCss(o,"kv-focussed"),a.$toolbar.find(".kv-"+a.btns.trash).removeAttr("disabled"),o.on("click",function(){a.$tree.find(".kv-node-detail").removeClass("kv-focussed"),t.addCss(o,"kv-focussed"),a.renderForm(null,a.rootKey),a.$toolbar.find(".kv-"+a.btns.trash).removeAttr("disabled")})}},toggle:function(e){var a=this,i=e.closest("li.kv-parent"),s=i.data("key");i.hasClass("kv-collapsed")?a.raise("treeview:expand",[s])&&i.removeClass("kv-collapsed"):a.raise("treeview:collapse",[s])&&t.addCss(i,"kv-collapsed")},toggleAll:function(e,a){var i=this;if("expand"===e){if(a&&!i.raise("treeview:expandall"))return;return i.$treeContainer.removeClass("kv-collapsed"),void i.$treeContainer.find(".kv-collapsed").removeClass("kv-collapsed")}a&&!i.raise("treeview:collapseall")||(t.addCss(i.$treeContainer.find("li.kv-parent"),"kv-collapsed"),t.addCss(i.$treeContainer,"kv-collapsed"))},check:function(e){var a,i=this,s=e===!0,r=s?i.$tree:e.closest("li"),n=s?"":r.data("key"),o=i.multiple&&0!=i.multiple;if(!(r.hasClass("kv-disabled")||s&&!o)){if(r.hasClass("kv-selected")){if(!i.raise("treeview:unchecked",[n]))return;if(r.removeClass("kv-selected"),o)i.cascadeSelectChildren&&r.find("li:not(.kv-disabled)").removeClass("kv-selected");else{if(!i.raise("treeview:change",["",""]))return;i.$tree.find("li:not(.kv-disabled)").removeClass("kv-selected"),i.$element.val(""),i.raise("change")}}else{if(!i.raise("treeview:checked",[n]))return;if(o)i.cascadeSelectChildren&&t.addCss(r.find("li:not(.kv-disabled)"),"kv-selected");else{if(a=r.find(">.kv-tree-list .kv-node-label").text(),!i.raise("treeview:change",[n,a]))return;i.$tree.find("li:not(.kv-disabled)").removeClass("kv-selected"),i.$element.val(n),i.raise("change")}t.addCss(r,"kv-selected")}o&&i.setSelected()}},clear:function(){var e=this;e.$treeContainer.removeClass("kv-loading-search"),e.$tree.find(".kv-highlight").removeClass("kv-highlight"),e.blurFilter()},parseCache:function(){var t=this;return t.enableCache?void e.ajaxPrefilter(function(a,i){if(a.cache){var s=i.beforeSend||e.noop,r=i.success||e.noop,n=i.url;a.cache=!1,a.beforeSend=function(){return s(),t.treeCache.exist(n)?(r(t.treeCache.get(n)),!1):!0},a.success=function(e){t.treeCache.set(n,e,r)}}}):!1},focusFilter:function(){var e=this;e.hideUnmatchedSearchItems&&(e.hasActiveFilter||(e.hasActiveFilter=!0),e.$search.val().length>0&&t.addCss(e.$treeContainer,"kv-active-filter"))},blurFilter:function(){var e=this;e.clearSearchResults(),e.hideUnmatchedSearchItems&&(e.hasActiveFilter&&(e.hasActiveFilter=!1),e.$treeContainer.removeClass("kv-active-filter"),e.$treeContainer.find(".kv-highlight").removeClass("kv-highlight"),e.$treeContainer.find(".kv-tree-container li.kv-filter-match").removeClass("kv-filter-match"))},clearSearchResults:function(){var t=this;t.$tree.find(".kv-node-label .kv-search-found").each(function(){var t=e(this),a=e(document.createElement("span")).appendTo(t);a.unwrap().remove()})},listen:function(){var a=this;a.$tree.find(".kv-node-toggle").each(function(){var t=e(this);t.on("click",function(){a.toggle(t)})}),a.$tree.find(".kv-node-checkbox:not(.kv-disabled)").each(function(){var t=e(this);t.on("click",function(){a.check(t)})}),a.$treeContainer.find(".kv-root-node-toggle").on("click",function(){a.$treeContainer.hasClass("kv-collapsed")?a.toggleAll("expand",!0):a.toggleAll("collapse",!0)}),a.$treeContainer.find(".kv-root-node-checkbox").on("click",function(){a.check(!0)}),a.$search.on("keyup",function(){var i=e(this).val();a.clear(),a.clearSearchResults(),t.addCss(a.$treeContainer,"kv-loading-search"),t.delay(function(){a.focusFilter(),a.$tree.find("li.kv-filter-match").removeClass("kv-filter-match"),a.toggleAll("collapse",!1),i=t.escapeRegExp(i),a.$tree.find(".kv-node-label").each(function(){var s,r,n=e(this),o=n.text(),l=o.search(new RegExp(i,"i"));0>l?n.removeClass("kv-highlight"):(t.addCss(n,"kv-highlight"),s=new RegExp(i,"ig"),r=o.replace(s,function(e){return''+e+""}),n.html(r),a.$tree.find("li.kv-parent").each(function(){var t=e(this);t.has(n).length>0&&t.removeClass("kv-collapsed")}))}),a.$tree.find(".kv-highlight").parentsUntil(a.$tree.selector,"li").each(function(){t.addCss(e(this),"kv-filter-match")}),a.$treeContainer.removeClass("kv-loading-search"),a.$treeContainer.find(".kv-tree-container").removeClass("kv-collapsed"),a.raise("treeview:search"),0===i.length&&a.blurFilter()},250)}).on("focus",function(){a.focusFilter()}).on("blur",function(){var t=e(this).val();null!==t&&""!==t||a.blurFilter()}),a.$clear.on("click",function(){a.$search.val(""),a.clear()}),a.$tree.find(".kv-node-detail").each(function(){e(this).on("click",function(){var t=e(this),i=t.closest("li"),s=i.data("key");if(a.raise("treeview:select",[s]))return a.$tree.hasClass("kv-tree-input-widget")?(t.removeClass("kv-focussed"),void a.check(i)):void(t.hasClass("kv-focussed")||(a.select(s),a.removeAlert()))})}),a.$toolbar.find(".kv-"+a.btns.create).on("click",function(){a.create()}),a.$toolbar.find(".kv-"+a.btns.createR).on("click",function(){a.createRoot()}),a.$toolbar.find(".kv-"+a.btns.trash).on("click",function(){a.remove()}),a.$toolbar.find(".kv-"+a.btns.moveU).on("click",function(){a.move("u")}),a.$toolbar.find(".kv-"+a.btns.moveD).on("click",function(){a.move("d")}),a.$toolbar.find(".kv-"+a.btns.moveL).on("click",function(){a.move("l")}),a.$toolbar.find(".kv-"+a.btns.moveR).on("click",function(){a.move("r")}),a.$detail.find(".alert").each(function(){var t=e(this);t.hasClass(a.hideCssClass)||(t.hide().fadeIn(1500),a.trigAlert(t))})},expandAll:function(){this.toggleAll("expand")},collapseAll:function(){this.toggleAll("collapse")},checkAll:function(){var e=this;e.$tree.removeClass("kv-selected"),e.check(!0)},uncheckAll:function(){var e=this;t.addCss(e.$tree,"kv-selected"),e.check(!0)},checkNode:function(e){var t=this,a=t.$tree.find('li[data-key="'+e+'"]');a.length&&(a.removeClass("kv-selected"),t.check(a))},uncheckNode:function(e){var a=this,i=a.$tree.find('li[data-key="'+e+'"]');i.length&&(t.addCss(i,"kv-selected"),a.check(i))}},e.fn.treeview=function(t){var i,s,r,n=Array.apply(null,arguments);return n.shift(),this.each(function(){i=e(this),s=i.data("treeview"),r="object"==typeof t&&t,s||(s=new a(this,e.extend({},e.fn.treeview.defaults,r,e(this).data())),i.data("treeview",s)),"string"==typeof t&&s[t].apply(s,n)})},e.fn.treeview.defaults={btns:{},treeId:"",detailId:"",toolbarId:"",wrapperId:"",showTooltips:!0,alertFadeDuration:1e3,cacheTimeout:3e5,showInactive:!1,actions:{manage:"",move:"","delete":""},messages:{emptyNode:"",nodeDisabled:"",invalidCreateNode:"",removeNode:"",nodeRemoved:"",emptyNodeRemoved:"",nodeNewMove:"",nodeTop:"",nodeBottom:"",nodeLeft:"",nodeRight:"",nodeTitle:"",nodeTitlePlural:""},breadcrumbs:{},cascadeSelectChildren:!0,rootKey:"",hideUnmatchedSearchItems:!0},e.fn.treeview.Constructor=a}(window.jQuery); \ No newline at end of file