/*
* Kendo UI Beta v2013.2.716 (http://kendoui.com)
* Copyright 2013 Telerik AD. All rights reserved.
*
* Kendo UI Beta license terms available at
* http://www.kendoui.com/purchase/license-agreement/kendo-ui-beta.aspx
*/
("function"==typeof define&&define.amd?define:function(e,t){return t()})(["./kendo.data.min","./kendo.draganddrop.min"],function(){!function(e,t){function n(e){return function(t){var n=t.children(".k-animation-container");return n.length||(n=t),n.children(e)}}function i(e){return p.template(e,{useWithBlock:!1})}function r(e){return e.children("div").find(".k-checkbox:first :checkbox")}function a(e){return function(t,n){n=n.closest(R);var i,r=n.parent();return r.parent().is("li")&&(i=r.parent()),this._dataSourceMove(t,r,i,function(t,i){return this._insert(t.data(),i,n.index()+e)})}}function s(t){var n,i,r=t.children("div"),a=t.children("ul"),s=r.children(".k-icon"),d=t.children(":checkbox"),o=r.children(".k-in");if(!t.hasClass("k-treeview")&&(r.length||(r=e("
").prependTo(t)),!s.length&&a.length?s=e("").prependTo(r):a.length&&a.children().length||(s.remove(),a.remove()),d.length&&e("").appendTo(r).append(d),!o.length))for(o=e("").appendTo(r)[0],n=r[0].nextSibling,o=r.find(".k-in")[0];n&&"ul"!=n.nodeName.toLowerCase();)i=n,n=n.nextSibling,3==i.nodeType&&(i.nodeValue=e.trim(i.nodeValue)),o.appendChild(i)}function d(e){var t=this;t.treeview=e,t.hovered=e.element,t._draggable=new h.Draggable(e.element,{filter:"div:not(.k-state-disabled) .k-in",hint:function(t){return e.templates.dragClue({item:e.dataItem(t),treeview:e.options})},cursorOffset:{left:10,top:p.support.touch||p.support.pointers?-40/p.support.zoomLevel():10},dragstart:b(t.dragstart,t),dragcancel:b(t.dragcancel,t),drag:b(t.drag,t),dragend:b(t.dragend,t)})}var o,l,c,u,p=window.kendo,h=p.ui,f=p.data,g=e.extend,m=p.template,k=e.isArray,v=h.Widget,_=f.HierarchicalDataSource,b=e.proxy,x=p.keys,C=".kendoTreeView",y="select",w="navigate",T="expand",N="change",S="error",I="checked",B="collapse",A="dragstart",U="drag",D="drop",H="dragend",O="dataBound",V="click",L="visibility",E="undefined",q="k-state-hover",F="k-treeview",M=":visible",R=".k-item",j="string",G="aria-selected",P="aria-disabled",W={text:"dataTextField",url:"dataUrlField",spriteCssClass:"dataSpriteCssClassField",imageUrl:"dataImageUrlField"},Q=function(e){return"object"==typeof HTMLElement?e instanceof HTMLElement:e&&"object"==typeof e&&1===e.nodeType&&typeof e.nodeName===j};l=n(".k-group"),c=n(".k-group,.k-content"),u=function(e){return e.children("div").children(".k-icon")},o=v.extend({init:function(e,t){var n,i=this,r=!1;k(t)&&(n=!0,t={dataSource:t}),t&&typeof t.loadOnDemand==E&&k(t.dataSource)&&(t.loadOnDemand=!1),v.prototype.init.call(i,e,t),e=i.element,t=i.options,r=e.is("ul")||e.hasClass(F),r&&(t.dataSource.list=e.is("ul")?e:e.children("ul")),i._animation(),i._accessors(),i._templates(),e.hasClass(F)?(i.wrapper=e,i.root=e.children("ul").eq(0)):(i._wrapper(),r&&(i.root=e,i._group(i.wrapper))),i._tabindex(),i.wrapper.filter("[role=tree]").length||i.wrapper.attr("role","tree"),i._dataSource(r),i._attachEvents(),t.dragAndDrop&&(i.dragging=new d(i)),r?i._attachUids():t.autoBind&&(i._progress(!0),i.dataSource.fetch()),t.checkboxes&&t.checkboxes.checkChildren&&i.updateIndeterminate(),i.element[0].id&&(i._ariaId=p.format("{0}_tv_active",i.element[0].id))},_attachEvents:function(){var t=this,n=".k-in:not(.k-state-selected,.k-state-disabled)",i="mouseenter";t.wrapper.on(i+C,".k-in.k-state-selected",function(e){e.preventDefault()}).on(i+C,n,function(){e(this).addClass(q)}).on("mouseleave"+C,n,function(){e(this).removeClass(q)}).on(V+C,n,b(t._click,t)).on("dblclick"+C,".k-in:not(.k-state-disabled)",b(t._toggleButtonClick,t)).on(V+C,".k-plus,.k-minus",b(t._toggleButtonClick,t)).on("keydown"+C,b(t._keydown,t)).on("focus"+C,b(t._focus,t)).on("blur"+C,b(t._blur,t)).on("mousedown"+C,".k-in,.k-checkbox :checkbox,.k-plus,.k-minus",b(t._mousedown,t)).on("change"+C,".k-checkbox :checkbox",b(t._checkboxChange,t)).on("click"+C,".k-checkbox :checkbox",b(t._checkboxClick,t)).on("click"+C,".k-request-retry",b(t._retryRequest,t)).on("click"+C,function(n){e(n.target).is(":focusable")||t.focus()})},_checkboxClick:function(t){var n=e(t.target);n.data("indeterminate")&&(n.data("indeterminate",!1).prop("indeterminate",!1).prop(I,!0),this._checkboxChange(t))},_attachUids:function(t,n){var i,r=this,a=p.attr("uid");t=t||r.root,n=n||r.dataSource,i=n.view(),t.children("li").each(function(t,n){n=e(n).attr(a,i[t].uid),n.attr("role","treeitem"),r._attachUids(n.children("ul"),i[t].children)})},_animation:function(){var e=this.options,t=e.animation;t===!1?t={expand:{effects:{}},collapse:{hide:!0,effects:{}}}:t.collapse&&"effects"in t.collapse||(t.collapse=g({reverse:!0},t.expand)),g(t.collapse,{hide:!0}),e.animation=t},_templates:function(){var e=this,t=e.options,n=b(e._fieldAccessor,e);t.template&&typeof t.template==j?t.template=m(t.template):t.template||(t.template=i("# var text = "+n("text")+"(data.item); #"+"# if (typeof data.item.encoded != 'undefined' && data.item.encoded === false) {#"+"#= text #"+"# } else { #"+"#: text #"+"# } #")),e._checkboxes(),e.templates={wrapperCssClass:function(e,t){var n="k-item",i=t.index;return e.firstLevel&&0===i&&(n+=" k-first"),i==e.length-1&&(n+=" k-last"),n},cssClass:function(e,t){var n="",i=t.index,r=e.length-1;return e.firstLevel&&0===i&&(n+="k-top "),n+=0===i&&i!=r?"k-top":i==r?"k-bot":"k-mid"},textClass:function(e){var t="k-in";return e.enabled===!1&&(t+=" k-state-disabled"),e.selected===!0&&(t+=" k-state-selected"),t},toggleButtonClass:function(e){var t="k-icon";return t+=e.expanded!==!0?" k-plus":" k-minus",e.enabled===!1&&(t+="-disabled"),t},groupAttributes:function(e){return e.expanded!==!0?" style='display:none'":""},groupCssClass:function(e){var t="k-group";return e.firstLevel&&(t+=" k-treeview-lines"),t},dragClue:i(""),group:i("#= data.renderItems(data) #
"),itemContent:i("# var imageUrl = "+n("imageUrl")+"(data.item); #"+"# var spriteCssClass = "+n("spriteCssClass")+"(data.item); #"+"# if (imageUrl) { #"+""+"# } #"+"# if (spriteCssClass) { #"+""+"# } #"+"#= data.treeview.template(data) #"),itemElement:i("# var item = data.item, r = data.r; ## var url = "+n("url")+"(item); #"+""+"# if (item.hasChildren) { #"+""+"# } #"+"# if (data.treeview.checkboxes) { #"+""+"#= data.treeview.checkboxes.template(data) #"+""+"# } #"+"# var tag = url ? 'a' : 'span'; #"+"# var textAttr = url ? ' href=\\'' + url + '\\'' : ''; #"+"<#=tag# class='#= r.textClass(item) #'#= textAttr #>"+"#= r.itemContent(data) #"+"#=tag#>"+"
"),item:i("# var item = data.item, r = data.r; #"+"#= r.itemElement(data) #"+""),loading:i(" Loading..."),retry:i("Request failed. ")}},items:function(){return this.element.find(".k-item")},setDataSource:function(e){this.options.dataSource=e,this._dataSource(),this.dataSource.fetch()},_dataSource:function(e){function t(e){for(var n=0;n1){for(i=1;n>i;i++)if(t[i].checked!=t[i-1].checked||t[i].indeterminate||t[i-1].indeterminate){s=!1;break}}else s=!t[0].indeterminate;r(e).data("indeterminate",!s).prop("indeterminate",!s).prop(I,s&&t[0].checked)}},updateIndeterminate:function(e){e=e||this.wrapper;var t,n=l(e).children();if(n.length){for(t=0;tn.clientHeight&&(i.push(n),r.push(n.scrollTop));while(n!=a);for(t.focus(),e=0;e=0:a.length&&!a.children().length,n&&t.preventDefault(),r.hasClass(".k-state-selected")||i._trigger(y,r)||i.select(r)},_wrapper:function(){var e,t,n=this,i=n.element,r="k-widget k-treeview";i.is("ul")?(e=i.wrap("").parent(),t=i):(e=i,t=e.children("ul").eq(0)),n.wrapper=e.addClass(r),n.root=t},_group:function(e){var t=this,n=e.hasClass(F),i={firstLevel:n,expanded:n||t._expanded(e)},r=e.children("ul");r.addClass(t.templates.groupCssClass(i)).css("display",i.expanded?"":"none"),t._nodes(r,i)},_nodes:function(t,n){var i,r=this,a=t.children("li");n=g({length:a.length},n),a.each(function(t,a){a=e(a),i={index:t,expanded:r._expanded(a)},s(a),r._updateNodeClasses(a,n,i),r._group(a)})},_checkboxes:function(){var e,t=this.options,n=t.checkboxes;(n||t.checkboxTemplate)&&(t.checkboxTemplate?e=t.checkboxTemplate:(e=""),n=g({template:e},t.checkboxes),typeof n.template==j&&(n.template=m(n.template)),t.checkboxes=n)},_updateNodeClasses:function(e,t,n){var i=e.children("div"),r=e.children("ul"),a=this.templates;e.hasClass("k-treeview")||(n=n||{},n.expanded=typeof n.expanded!=E?n.expanded:this._expanded(e),n.index=typeof n.index!=E?n.index:e.index(),n.enabled=typeof n.enabled!=E?n.enabled:!i.children(".k-in").hasClass("k-state-disabled"),t=t||{},t.firstLevel=typeof t.firstLevel!=E?t.firstLevel:e.parent().parent().hasClass(F),t.length=typeof t.length!=E?t.length:e.parent().children().length,e.removeClass("k-first k-last").addClass(a.wrapperCssClass(t,n)),i.removeClass("k-top k-mid k-bot").addClass(a.cssClass(t,n)),i.children(".k-in").removeClass("k-in k-state-default k-state-disabled").addClass(a.textClass(n)),(r.length||"true"==e.attr("data-hasChildren"))&&(i.children(".k-icon").removeClass("k-plus k-minus k-plus-disabled k-minus-disabled").addClass(a.toggleButtonClass(n)),r.addClass("k-group")))},_processNodes:function(t,n){var i=this;i.element.find(t).each(function(t,r){n.call(i,t,e(r).closest(R))})},dataItem:function(t){var n=e(t).closest(R).attr(p.attr("uid")),i=this.dataSource;return i&&i.getByUid(n)},_insertNode:function(t,n,i,r,a){var d,o,c,u,p=this,h=l(i),f=h.children().length+1,g={firstLevel:i.hasClass(F),expanded:!a,length:f},m="",k=function(e,t){e.appendTo(t)};for(c=0;c=0?h=!0:(p.item=n[0],p.item.bind("get",i),u.templates.itemContent(p),p.item.unbind("set",i)),a=0;adiv>.k-in").html(u.templates.itemContent(p)):t==I?(s=u.findByUid(d.uid),o=d[t],r(s.children("div"),o),u.options.checkboxes.checkChildren&&(r(s.children(".k-group"),o),u._setChecked(d.children,o),u._bubbleIndeterminate(s))):"expanded"==t?u._toggle(u.findByUid(d.uid),d,d[t]):"enabled"==t&&(s=u.findByUid(d.uid),s.find(".k-checkbox :checkbox").prop("disabled",!d[t]),l=!c(s).is(M),s.removeAttr(P),d[t]||(d.selected&&d.set("selected",!1),d.expanded&&d.set("expanded",!1),l=!0,s.removeAttr(G).attr(P,!0)),u._updateNodeClasses(s,{},{enabled:d[t],expanded:!l}))},refresh:function(e){function n(e,t){var n=l(t),i=n.children(),a=!r._expanded(t);typeof u==E&&(u=i.length),r._insertNode(e,u,t,function(e,t){u==i.length?e.appendTo(t):e.insertBefore(i.eq(u))},a),r._expanded(t)&&(r._updateNodeClasses(t),l(t).css("display","block"))}var i,r=this,a=r.wrapper,d=e.node,o=e.action,c=e.items,u=e.index,p=r.options,h=p.loadOnDemand,f=p.checkboxes&&p.checkboxes.checkChildren;if(e.field)return r._updateNode(e.field,c);if(d&&(a=r.findByUid(d.uid),r._progress(a,!1)),f&&"remove"!=o&&d&&d.checked)for(i=0;i0&&n&&n.length?(r&&(r[0].id===s&&r.removeAttr("id"),r.find(".k-in:first").removeClass("k-state-focused")),r=i._current=e(n,a).closest(R),r.find(".k-in:first").addClass("k-state-focused"),s=r[0].id||s,s&&(i.wrapper.removeAttr("aria-activedescendant"),r.attr("id",s),i.wrapper.attr("aria-activedescendant",s)),t):(r||(r=i._nextVisible(e())),r)},select:function(n){var i=this,r=i.element;return arguments.length?(n=e(n,r).closest(R),r.find(".k-state-selected").each(function(){var e=i.dataItem(this);e.set("selected",!1),delete e.selected}),n.length&&i.dataItem(n).set("selected",!0),i.trigger(N),t):r.find(".k-state-selected").closest(R)},_toggle:function(e,t,n){var i,r=this,a=r.options,s=c(e),d=n?"expand":"collapse",o=a.animation[d];if(!s.data("animating")&&!r._trigger(d,e))if(r._expanded(e,n),i=t&&t.loaded(),i&&s.children().length>0){if(r._updateNodeClasses(e,{},{expanded:n}),s.css("display")==(n?"block":"none"))return;n||s.css("height",s.height()).css("height"),s.kendoStop(!0,!0).kendoAnimate(g({reset:!0},o,{complete:function(){n&&s.css("height","")}}))}else n&&(a.loadOnDemand&&r._progress(e,!0),s.remove(),t.load())},toggle:function(t,n){t=e(t),u(t).is(".k-minus,.k-plus,.k-minus-disabled,.k-plus-disabled")&&(1==arguments.length&&(n=!this._expanded(t)),this._expanded(t,n))},destroy:function(){var e=this;v.fn.destroy.call(e),e.element.off(C),e.dragging&&e.dragging.destroy(),p.destroy(e.element)},_expanded:function(e,n){var i=p.attr("expanded"),r=this.dataItem(e);return 1==arguments.length?"true"===e.attr(i)||r&&r.expanded:(c(e).data("animating")||(r&&(r.set("expanded",n),n=r.expanded),n?(e.attr(i,"true"),e.attr("aria-expanded","true")):(e.removeAttr(i),e.attr("aria-expanded","false"))),t)},_progress:function(e,t){var n=this.element;1==arguments.length?(t=e,t?n.html(this.templates.loading):n.empty()):u(e).toggleClass("k-loading",t).removeClass("k-i-refresh")},text:function(e,n){var i=this.dataItem(e),r=this.options[W.text],a=i.level(),s=r.length,d=r[Math.min(a,s-1)];return n?(i.set(d,n),t):i[d]},_objectOrSelf:function(t){return e(t).closest("[data-role=treeview]").data("kendoTreeView")||this},_dataSourceMove:function(e,t,n,i){var r,a=this._objectOrSelf(n||t),s=a.dataSource;return n&&n[0]!=a.element[0]&&(r=a.dataItem(n),r.loaded()||(a._progress(n,!0),r.load()),n!=this.root&&(s=r.children,s&&s instanceof _||(r._initChildren(),r.loaded(!0),s=r.children))),e=this._toObservableData(e),i.call(this,s,e)},_toObservableData:function(t){var n,i,r=t;return(t instanceof window.jQuery||Q(t))&&(n=this._objectOrSelf(t).dataSource,i=e(t).attr(p.attr("uid")),r=n.getByUid(i),r&&(r=n.remove(r))),r},_insert:function(e,t,n){t instanceof p.data.ObservableArray?t=t.toJSON():k(t)||(t=[t]);var i=e.parent();return i&&(i.hasChildren=!0,i._initChildren()),e.splice.apply(e,[n,0].concat(t)),this.findByUid(e[n].uid)},insertAfter:a(1),insertBefore:a(0),append:function(e,t){var n=this,i=n.root;return t&&(i=l(t)),n._dataSourceMove(e,i,t,function(e,i){function r(){t&&n._expanded(t,!0);var r=e.data(),a=Math.max(r.length,0);return n._insert(r,i,a)}return e.data()?r():(e.one(N,r),null)})},_remove:function(t,n){var i,r,a,d=this;return t=e(t,d.element),i=t.parent().parent(),r=t.prev(),a=t.next(),t[n?"detach":"remove"](),i.hasClass("k-item")&&(s(i),d._updateNodeClasses(i)),d._updateNodeClasses(r),d._updateNodeClasses(a),t},remove:function(e){var t=this.dataItem(e);t&&this.dataSource.remove(t)},detach:function(e){return this._remove(e,!0)},findByText:function(t){return e(this.element).find(".k-in").filter(function(n,i){return e(i).text()==t}).closest(R)},findByUid:function(e){return this.element.find(".k-item["+p.attr("uid")+"="+e+"]")},_renderItem:function(e){return e.group||(e.group={}),e.treeview=this.options,e.r=this.templates,this.templates.item(e)},_renderGroup:function(e){var t=this;return e.renderItems=function(e){var n="",i=0,r=e.items,a=r?r.length:0,s=e.group;for(s.length=a;a>i;i++)e.group=s,e.item=r[i],e.item.index=i,n+=t._renderItem(e);return n},e.r=t.templates,t.templates.group(e)}}),d.prototype={_removeTouchHover:function(){var e=this;p.support.touch&&e.hovered&&(e.hovered.find("."+q).removeClass(q),e.hovered=!1)},_hintStatus:function(n){var i=this._draggable.hint.find(".k-drag-status")[0];return n?(i.className="k-icon k-drag-status "+n,t):e.trim(i.className.replace(/k-(icon|drag-status)/g,""))},dragstart:function(t){var n=this,i=n.treeview,r=n.sourceNode=t.currentTarget.closest(R);i.trigger(A,{sourceNode:r[0]})&&t.preventDefault(),n.dropHint=e("").css(L,"hidden").appendTo(i.element)},drag:function(t){var n,i,r,a,s,d,o,l,c,u,h=this,f=h.treeview,g=h.sourceNode,m=h.dropTarget=e(p.eventTarget(t)),k=m.closest(".k-treeview");k.length?e.contains(g[0],m[0])?n="k-denied":(n="k-insert-middle",i=m.closest(".k-top,.k-mid,.k-bot"),i.length?(a=i.outerHeight(),s=p.getOffset(i).top,d=m.closest(".k-in"),o=a/(d.length>0?4:2),l=t.y.location0?"after":"before",e=o.closest(R)):l&&(e=l.closest(R),e.length||(e=l.closest(".k-treeview"))),n="k-denied"!=r._hintStatus(),i=a.trigger(D,{sourceNode:d[0],destinationNode:e[0],valid:n,setValid:function(e){n=e},dropTarget:l[0],dropPosition:s}),o.remove(),r._removeTouchHover(),!n||i?(r._draggable.dropped=n,t):(r._draggable.dropped=!0,"over"==s?d=a.append(d,e):"before"==s?d=a.insertBefore(d,e):"after"==s&&(d=a.insertAfter(d,e)),a.trigger(H,{sourceNode:d&&d[0],destinationNode:e[0],dropPosition:s}),t)},destroy:function(){this._draggable.destroy()}},h.plugin(o)}(window.kendo.jQuery)});