/*
* HGrid - v0.2.10
* A Javascript-based hierarchical grid that can be used to manage and organize files and folders
*/
this.HGrid=function(a){"use strict";function b(){}function c(){return v++}function d(a){void 0===a?(this.data={},this.id=s,this.depth=0,this.dataView=new Slick.Data.DataView({inlineFilters:!0})):(this.data=a,this.id=a.id?a.id:c(),this.depth=null,this.dataView=null),this.children=[],this.parentID=null}function e(a,b,c){for(var d=a.length;d--;)if(a[d]&&a[d].hasOwnProperty(b)&&arguments.length>2&&a[d][b]===c)return a.splice(d,1),!0;return!1}function f(a,b){var c=b.getItemById(a.parentID);return c?b.getIdxById(c.id)+1:0}function g(a){this.data=a,this.id=a.id?a.id:c(),this.parentID=null,this.depth=null,this.children=[],this.dataView=null}function h(){this.queue=[],this.offset=0}function i(a){return a.replace(/&/g,"&").replace(//g,">")}function j(a){return''}function k(a,b,c){c=c||r;var d=(a.depth-1)*c,e=j(d);return e+b}function l(a,b){var c=a.kind===u?p.Html.folderNameClass:p.Html.itemNameClass,d='',e="";return[d,b,e].join("")}function m(a){var b,c=a.tag||"button";b=a.cssClass?p.Html.buttonClass+" "+a.cssClass:p.Html.buttonClass;var d=a.action||"noop",e=a.attributes||"",f={action:d,cssClass:b,tag:c,text:a.text,attributes:e},g=x('<{{tag}} data-hg-action="{{action}}" class="{{cssClass}}" {{attributes}} >{{text}}{{tag}}>',f);return g}function n(a){var b=a.map(function(a){var b=m(a);return b}).join("");return b}function o(a){return a._node._load_status===p.LOADING_STARTED}function p(b,c){var d=this;if(d.selector=b,d.element=a(b),d.options=a.extend({},y,c),d.grid=null,d.dropzone=null,d.plugins=[],d.options.searchInput){var e=a(d.options.searchInput);if(!e.length)throw new p.Error("Invalid selector for searchInput.");d.searchInput=e}else d.searchInput=null;"string"==typeof d.options.data?d.getFromServer(d.options.data,function(a){d._initData(a),d.init()}):(d._initData(d.options.data),d.init())}function q(a,b){var c;return b.grid&&b.grid._searchText?(a.depth=0,c=b.searchFilter.call(b.grid,a,b.grid._searchText)):(a.depth=a._node.depth,c=!a._hidden),c}var r=20,s="root",t="item",u="folder",v=0;d.fromObject=function(a,b,c){c=c||{};var e,f,h,i;Array.isArray(a)?(e=new d,f=a):(f=a.children||[],e=new d(a),e.depth=b.depth+1,e.dataView=b.dataView,c.collapse&&(e.data._collapsed=!0));for(var j=0,k=f.length;k>j;j++){var l=f[j];l.kind===t?(h=g.fromObject(l,e,c),e.add(h)):(i=d.fromObject(l,e,c),e.add(i))}return e},d.resetIDCounter=function(){v=0},d._getCurrentID=function(){return v},d.prototype.add=function(a,b){return a.parentID=this.id,a.depth=this.depth+1,a.dataView=this.dataView,this.children.push(a),b&&this.insertIntoDataView(a),this},d.prototype.empty=function(a){if(a){var b=this.getItem();this.dataView.deleteItem(b.id)}for(var c,d=0;c=this.children[d];d++)c.empty(!0),c.children=[];return this.children=[],this},d.prototype.remove=function(a){var b="object"==typeof a?a.id:a,c=e(this.children,"id",a);if(c)this.dataView.deleteItem(b);else for(var d,f=0;d=this.children[f];f++)c=d.remove(a)},d.prototype.getItem=function(){return this.dataView.getItemById(this.id)},d.prototype.sort=function(a,b){this.children.sort(function(c,d){var e=c.data[a],f=d.data[a],g=b?1:-1,h=(e===f?0:e>f?1:-1)*g;return 0!==h?h:0});for(var c,d=0;c=this.children[d];d++)c.sort(a,b);return this},d.prototype.sortCmp=function(a){this.children.sort(a);for(var b,c=0;b=this.children[c];c++)b.sortCmp(key);return this},d.prototype.insertIntoDataView=function(a){var b,c=a.toData();if(Array.isArray(c))for(var d=0,e=c.length;e>d;d++){var g=c[d];b=f(g,this.dataView),this.dataView.insertItem(b,g)}else b=f(c,this.dataView),this.dataView.insertItem(b,c);return this},d.prototype.ensureDataView=function(a){a||(a=this.dataView),this.dataView=a;for(var b,c=0;b=this.children[c];c++)b.ensureDataView(a);return this},d.prototype.updateDataView=function(a){if(!this.dataView)throw new p.Error("Tree does not have a DataView. updateDataView must be called on a root node.");return a||this.ensureDataView(),this.dataView.beginUpdate(),this.dataView.setItems(this.toData()),this.dataView.endUpdate(),this},d.prototype.toData=function(b){var c=b||[];if(0!==this.depth){var d=a.extend({},{id:this.id,parentID:this.parentID,_node:this,depth:this.depth},this.data);c.push(d)}for(var e=0,f=this.children.length;f>e;e++){var g=this.children[e];g.toData(c)}return c},d.prototype.collapse=function(a,b){var c;this.isRoot()||(c=this.getItem(),a?c._hidden=!0:(c._collapsed=!0,c._hidden=!1));for(var d,e=0;d=this.children[e];e++)d.collapse(!0);return!this.isRoot()&&b&&this.dataView.updateItem(c.id,c),this},d.prototype.bfTraverse=function(a,b){for(var c=new h,d=this;d&&!(b&&d.depth>b);){if(a.call(this,d),d.children.length)for(var e,f=0;e=d.children[f];f++)c.enq(e);d=c.deq()}return this},d.prototype.collapseAt=function(a,b){return 0===a?this.collapse(!1,b):(this.bfTraverse(function(b){b.depth===a&&b instanceof d&&b.collapse(!1,!0)},a),b&&this.dataView.refresh(),this)},d.prototype.expandAt=function(a,b){return 0===a?this.expand(!1,b):(this.bfTraverse(function(b){!b.isRoot()&&b.depth=this.queue.length&&(this.queue=this.queue.slice(this.offset),this.offset=0),a},h.prototype.isEmpty=function(){return 0===this.queue.length};var w={},x=function(a,b){return a?(w[a]=w[a]||new Function("_","return '"+a.replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/'/g,"\\'").replace(/\{\{\s*(\w+)\s*\}\}/g,"'+(_.$1?(_.$1+''):(_.$1===0?0:''))+'")+"'"),w[a](b)):""};p.Html={expandElem:'',collapseElem:'',folderIcon:'',fileIcon:'',errorElem:' ',buttonClass:"hg-btn",nameClass:"hg-name",folderNameClass:"hg-folder-name",itemNameClass:"hg-item-name",toggleClass:"hg-toggle"},p.HtmlFactories={expandElem:function(a){return o(a)?'':''},collapseElem:function(a){return o(a)?'':''}},p.Fmt=p.Format={withIndent:k,asName:l,makeIndentElem:j,sanitized:i,button:m,buttons:n,tpl:x},p.Actions={download:{on:"click",callback:function(a,b){this.options.onClickDownload.call(this,a,b)}},"delete":{on:"click",callback:function(a,b){this.options.onClickDelete.call(this,a,b)}},upload:{on:"click",callback:function(a,b){this.options.onClickUpload.call(this,a,b)}},noop:{on:"click",callback:b}},p.Col=p.Columns={Name:{id:"name",name:"Name",sortkey:"name",folderView:p.Html.folderIcon+" {{name}}",itemView:p.Html.fileIcon+" {{name}}",sortable:!0,indent:r,isName:!0,showExpander:function(a,b){return a.kind===p.FOLDER&&(a._node.children.length&&a.depth||b.lazyLoad)&&!a._processing}},ActionButtons:{id:"actions",name:"Actions",width:50,sortable:!1,folderView:function(){var a=[];return this.options.uploads&&a.push({text:"Upload",action:"upload"}),a?n(a):""},itemView:function(){var a=[{text:"Download",action:"download"},{text:"Delete",action:"delete"}];return n(a)}}};var y={data:null,ajaxOptions:{},fetchUrl:null,fetchSuccess:function(){},fetchError:function(){},fetchStart:function(){},uploads:!1,columns:[p.Columns.Name],width:600,height:300,highlightClass:"hg-row-highlight",indent:r,slickgridOptions:{},uploadUrl:null,acceptedFiles:null,maxFilesize:256,uploadMethod:"POST",uploadHeaders:{},dropzoneOptions:{},onClick:function(){},onClickDownload:function(a,b,c){this.downloadItem(b,c)},onClickDelete:function(a,b,c){this.deleteFile(b,c)},onClickUpload:function(a,b){this.uploadToFolder(b)},onExpand:function(){},onCollapse:function(){},onItemAdded:function(){},onDragover:function(){},onDragenter:function(){},onDragleave:function(){},onDrop:function(){},onSort:function(){},uploadAdded:function(){},uploadProcessing:function(){},uploadError:function(b,c){var d,e=a(b.gridElement);return d="string"!=typeof c&&c.error?c.error:c,e.find("[data-upload-errormessage]").each(function(){this.textContent=d}),this},uploadProgress:function(b,c){var d=a(b.gridElement);d.width(c+"%")},uploadSuccess:function(){},uploadComplete:function(){},uploadAccept:function(a,b,c){return c()},uploadSending:function(){},downloadUrl:function(){},deleteUrl:function(){},deleteMethod:function(){},listeners:[],init:function(){},searchInput:null,searchFilter:function(a,b){return-1!==a.name.toLowerCase().indexOf(b.toLowerCase())},canUpload:function(){return!0},uploadDenied:function(){},getExpandState:null,preprocessFilename:function(a){return a}};p._defaults=y,p.Tree=d,p.Leaf=g,p.Queue=h,p.DEFAULT_INDENT=r,p.ROOT_ID=s,p.FOLDER=u,p.ITEM=t,p.Error=function(a){Error.call(this,a),this.name="HGrid.Error",this.message=a||""},p.Error.prototype=Object.create(Error.prototype),p.prototype.collapseAll=function(){return this.tree.collapseAt(1,!0),this},p.prototype.emptyFolder=function(a,b){return a="object"==typeof a?a:this.getByID(a),a._node.empty(b),b||this.getDataView().updateItem(a.id,a),this},p.prototype.getFromServer=function(b,c){var d=this,e=a.extend({},{url:b,contentType:"application/json",dataType:"json",success:function(a){c&&c.call(d,a)},error:function(a,b,e){c&&c.call(d,null,e,b)}},d.options.ajaxOptions);return a.ajax(e)},p.prototype._initData=function(a){var b=this;return a?(b.tree=d.fromObject(Array.isArray(a)?a:a.data),b.tree.updateDataView()):b.tree=new d,b};var z;p.prototype.init=function(){if(this.setHeight(this.options.height).setWidth(this.options.width)._initSlickGrid()._initDataView(),this.options.uploads){if(z="object"==typeof module?require("dropzone"):window.Dropzone,"undefined"==typeof z)throw new p.Error("uploads=true requires DropZone to be loaded");this._initDropzone()}return this._initListeners(),this.isLazy()&&this.collapseAll(),this.refreshExpandState(),this.options.init.call(this),this},p.prototype.refreshExpandState=function(){var a=this;if(a.options.getExpandState)for(var b,c=a.getData(),d=0;b=c[d];d++)a.options.getExpandState.call(a,b)&&a.reloadFolder(b)},p.prototype.setHeight=function(a){return"auto"===a?this.options.slickgridOptions.autoHeight=!0:this.element.css("height",a),this},p.prototype.setWidth=function(a){return this.element.css("width",a),this},p.prototype.makeFormatter=function(a){var b,c,d=this,e=a.folderView,f=a.itemView,g=a.showExpander,h="number"==typeof a.indent?a.indent:r,i=function(i,j,m,n,o){var q={colDef:n,row:i,cell:j,indent:a.indent,lazyLoad:d.isLazy()};if(b=o.kind===u?e:f,c="function"==typeof b?b.call(d,o,q):p.Format.tpl(b,o),a.isName&&(c=l(o,c)),g){var r;r="function"==typeof g&&g(o,q)?o._collapsed?p.HtmlFactories.expandElem(o):p.HtmlFactories.collapseElem(o):'',c=[r,c].join("")}return a.indent&&(c=k(o,c,h)),c};return i},p.prototype._makeSlickgridColumns=function(a){var b=this,c=a.map(function(a){return"formatter"in a||(a.formatter=b.makeFormatter.call(b,a)),"text"in a&&(a.name=a.text),a.cssClass="cssClass"in a?a.cssClass+" hg-cell":"hg-cell",a});return c};var A={editable:!1,asyncEditorLoading:!1,enableCellNavigation:!1,enableColumnReorder:!1,forceFitColumns:!0,fullWidthRows:!0};p.prototype._initSlickGrid=function(){var b=this,c=b._makeSlickgridColumns(b.options.columns),d=a.extend({},A,b.options.slickgridOptions);return b.grid=new Slick.Grid(b.element.selector,b.tree.dataView,c,d),b},p.prototype.removeHighlight=function(a){var b=a||this.options.highlightClass;return this.element.find("."+b).removeClass(b),this},p.prototype.getRowElement=function(a){"object"==typeof a&&(a=a.id);try{return this.grid.getCellNode(this.getDataView().getRowById(a),0).parentNode}catch(b){throw new p.Error("Row element is not rendered in the DOM.")}},p.prototype.getPathToRoot=function(a){var b=this.getNodeByID(a);return b.getPathToRoot()},p.prototype.addHighlight=function(b,c){var d=c||this.options.highlightClass;this.removeHighlight();var e;e=b&&b.kind===u?b.id:b.parentID;var f;try{f=a(this.getRowElement(e))}catch(g){return this}return f&&f.addClass(d),this},p.prototype.folderContains=function(a,b){return this.getPathToRoot(b).indexOf(a)>=0},p.prototype.slickEvents={onClick:function(a,b){var c=this.getDataView().getItem(b.row);return this.canToggle(a.target)&&this.toggleCollapse(c,a),this.options.onClick.call(this,a,c),this},onCellChange:function(a,b){return this.getDataView().updateItem(b.item.id,b.item),this},onMouseLeave:function(){this.removeHighlight()},onSort:function(a,b){var c=b.sortCol,d=c.field||c.sortkey;if(!d)throw new p.Error("Sortable column does not define a `sortkey` to sort on.");this.tree.sort(d,b.sortAsc),this.tree.updateDataView(!0),this.options.onSort.call(this,a,c,b)}},p.prototype.getItemFromEvent=function(a){var b=this.grid.getCellFromEvent(a);return b?this.getDataView().getItem(b.row):null},p.prototype.uploadToFolder=function(a){this.currentTarget=a,this.setUploadTarget(a),this.dropzone.hiddenFileInput.click()},p.prototype.downloadItem=function(a){var b;return b="function"==typeof this.options.downloadUrl?this.options.downloadUrl(a):this.options.downloadUrl,b&&(window.location=b),this},p.prototype.deleteFile=function(b,c){var d,e,f=this;d="function"==typeof this.options.deleteUrl?this.options.deleteUrl(b):this.options.deleteUrl,e="function"==typeof this.options.deleteMethod?this.options.deleteMethod(b):this.options.deleteMethod;var g=a.extend({},{url:d,type:e,success:function(){f.updateItem(f.getByID(b.parentID)),f.removeItem(b.id)}},f.options.ajaxOptions,c),h=null;return d&&(h=a.ajax(g)),h},p.prototype.currentTarget=null,p.prototype.setUploadTarget=function(b){function c(a){return"function"==typeof a?a.call(d,b):a}var d=this;d.currentTarget&&a.when(c(d.options.uploadHeaders),c(d.options.uploadUrl),c(d.options.uploadMethod),c(d.options.maxFilesize),c(d.options.acceptedFiles)).done(function(a,c,e,f,g){d.dropzone.options.headers=a,d.dropzone.options.url=c,d.dropzone.options.method=e,d.dropzone.options.maxFilesize=f,d.setAcceptedFiles(g),d.options.uploadAccept&&(d.dropzone.options.accept=function(a,c){return d.options.uploadAccept.call(d,a,b,c)})})},p.prototype.canUpload=function(a){return Boolean(a&&this.options.canUpload(a))},p.prototype.denyUpload=function(a){throw this.options.uploadDenied.call(this,a),new p.Error("Upload permission denied.")},p.prototype.validateTarget=function(a){return this.canUpload(a)?a:this.denyUpload(a)},p.prototype.dropzoneEvents={drop:function(a){this.removeHighlight(),this.validateTarget(this.currentTarget),this.setUploadTarget(this.currentTarget),this.options.onDrop.call(this,a,this.currentTarget)},dragleave:function(a){this.removeHighlight();var b=this.getItemFromEvent(a);this.options.onDragleave.call(this,a,b)},dragenter:function(a){var b=this.getItemFromEvent(a);b&&(this.currentTarget=b.kind===u?b:this.getByID(b.parentID)),this.options.onDragenter.call(this,a,b)},dragover:function(a){var b=this.currentTarget,c=this.getItemFromEvent(a);this.canUpload(b)&&b&&this.addHighlight(b),this.options.onDragover.call(this,a,c)},dragend:function(){this.removeHighlight()},addedfile:function(b){var c=this.currentTarget;this.validateTarget(c);var d;if(this.canUpload(c)){d=this.addItem({name:this.options.preprocessFilename.call(this,b.name),kind:p.ITEM,parentID:c.id});var e=this.getRowElement(d.id),f=a(e);b.gridItem=d,b.gridElement=e,f.addClass("hg-upload-started")}return this.options.uploadAdded.call(this,b,b.gridItem,c),d},thumbnail:b,error:function(b,c){var d=a(b.gridElement);d.addClass("hg-upload-error").removeClass("hg-upload-processing");var e=a.extend({},b.gridItem);return this.removeItem(b.gridItem.id),this.options.uploadError.call(this,b,c,e,this.currentTarget)},processing:function(b){return a(b.gridElement).addClass("hg-upload-processing"),this.currentTarget._processing=!0,this.updateItem(this.currentTarget),this.options.uploadProcessing.call(this,b,b.gridItem,this.currentTarget),this},uploadprogress:function(a,b,c){return this.options.uploadProgress.call(this,a,b,c,a.gridItem)},success:function(b,c){return a(b.gridElement).addClass("hg-upload-success"),this.options.uploadSuccess.call(this,b,b.gridItem,c)},complete:function(b){return a(b.gridElement).removeClass("hg-upload-processing"),this.currentTarget._processing=!1,this.updateItem(this.currentTarget),this.options.uploadComplete.call(this,b,b.gridItem)},sending:function(a,b,c){return this.options.uploadSending(a,a.gridItem,b,c)}},p.prototype._initListeners=function(){var a,b,c=this;for(a in c.slickEvents)b=c.slickEvents[a].bind(c),c.grid[a].subscribe(b);if(this.options.uploads)for(a in c.dropzoneEvents)b=c.dropzoneEvents[a].bind(c),c.dropzone.on(a,b);for(var d,e=function(a){var b=c.getItemFromEvent(a);return a.data.listenerObj.callback(a,b,a.data.grid)},f=0;d=this.options.listeners[f];f++)c.element.on(d.on,d.selector,{listenerObj:d,grid:c},e);this.attachActionListeners(),c.searchInput&&c.searchInput.keyup(function(){c._searchText=this.value,c.getDataView().refresh(),c.grid.invalidate(),c.grid.render()})},p.prototype.attachActionListeners=function(){var b=this;a.extend(p.Actions,b.options.actions);var c=function(a){var c=b.getItemFromEvent(a);a.data.actionObj.callback.call(b,a,c)};for(var d in p.Actions){var e=p.Actions[d];this.element.on(e.on,'[data-hg-action="'+d+'"]',{actionObj:e},c)}return this},p._hgFilter=q,p.prototype._initDataView=function(){var a=this,b=this.getDataView();return b.beginUpdate(),b.setFilterArgs({grid:a,searchFilter:a.options.searchFilter}),b.setFilter(q),b.endUpdate(),b.onRowCountChanged.subscribe(function(){a.grid.updateRowCount(),a.grid.render()}),b.onRowsChanged.subscribe(function(b,c){a.grid.invalidateRows(c.rows),a.grid.render()}),this};var B={addRemoveLinks:!1,previewTemplate:""};p.prototype.setAcceptedFiles=function(a){var b;return b=Array.isArray(a)?a.join(","):a,this.dropzone.options.acceptedFiles=b,this},p.prototype._initDropzone=function(){function b(a,b){return"function"==typeof a||null==a?b:a}var c,d,e,f=null;c=b(this.options.uploadUrl,"/"),d=b(this.options.uploadMethod,"POST"),e=b(this.options.uploadHeaders,{}),f=b(this.options.acceptedFiles,null),Array.isArray(f)&&(f=f.join(","));var g=a.extend({},{url:c,acceptedFiles:f,maxFilesize:this.options.maxFilesize,method:d,headers:e},B,this.options.dropzoneOptions);return this.dropzone=new z(this.selector,g),this},p.prototype.destroy=function(){this.element.html(""),this.grid.destroy(),this.dropzone&&this.dropzone.destroy()},p.prototype.getData=function(){return this.getDataView().getItems()},p.prototype.getByID=function(a){var b=this.getDataView();return b.getItemById(a)},p.prototype.getDataView=function(){return this.grid.getData()},p.prototype.getRefreshHints=function(a){var b=this.getDataView().getRowById(a.id),c={expand:{isFilterNarrowing:!1,isFilterExpanding:!0,ignoreDiffsBefore:b},collapse:{isFilterNarrowing:!0,isFilterExpanding:!1,ignoreDiffsBefore:b}};return c},p.prototype.isLazy=function(){return Boolean(this.options.fetchUrl)};var C=p.LOADING_UNFINISHED="lu",D=p.LOADING_STARTED="ls",E=p.LOADING_FINISHED="lf";return p.prototype.setLoadingStatus=function(a,b){a._node._load_status=b,this.updateItem(a)},p.prototype._lazyLoad=function(a){var b=this,c=b.options.fetchUrl(a);return null!==c?(b.options.fetchStart.call(b,a),b.setLoadingStatus(a,D),b.getFromServer(c,function(d,e){if(e)throw b.setLoadingStatus(a,C),b.options.fetchError.call(b,e,a),new p.Error('Could not fetch data from url: "'+c+'". Error: '+e);b.addData(d,a.id),b.setLoadingStatus(a,E),b.refreshExpandState(),b.options.fetchSuccess.call(b,d,a)})):!1},p.prototype.expandItem=function(a,b){var c=this;a="object"==typeof a?a:c.getByID(a);var d=c.getNodeByID(a.id);a._node.expand();var e=c.getDataView(),f=c.getRefreshHints(a).expand;return e.setRefreshHints(f),c.getDataView().updateItem(a.id,a),!c.isLazy()||void 0!==d._load_status&&d._load_status!==C||this._lazyLoad(a),c.options.onExpand.call(c,b,a),c},p.prototype.collapseItem=function(a,b){a="object"==typeof a?a:this.getByID(a),a._node.collapse();var c=this.getDataView(),d=this.getRefreshHints(a).collapse;return c.setRefreshHints(d),c.updateItem(a.id,a),this.options.onCollapse.call(this,b,a),this},p.prototype.updateItem=function(a){return this.getDataView().updateItem(a.id,a)},p.prototype.isCollapsed=function(a){return Boolean(a._collapsed)},p.prototype.canToggle=function(b){return a(b).hasClass(p.Html.toggleClass)},p.prototype.addItem=function(a){var b,c;b=a.kind===p.FOLDER?new p.Tree(a):new p.Leaf(a),c=null==a.parentID?this.tree:this.getNodeByID(a.parentID),c.add(b,!0);var d=this.getByID(b.id);return this.options.onItemAdded.call(this,d),d},p.prototype.addItems=function(a){var b=this;return this.batchUpdate(function(){for(var c=0,d=a.length;d>c;c++){var e=a[c];b.addItem(e)}}),this},p.prototype.batchUpdate=function(a){this.getDataView().beginUpdate(),a.call(this),this.getDataView().endUpdate()},p.prototype.addColumn=function(a){var b=this.grid.getColumns();return b.push(a),this.grid.setColumns(b),this},p.prototype.removeItem=function(a){return this.tree.remove(a)},p.prototype.getNodeByID=function(a){if(a===p.ROOT_ID||null==a)return this.tree;var b=this.getByID(a);return b._node},p.prototype.toggleCollapse=function(a,b){return a&&(this.isCollapsed(a)?this.expandItem(a,b):this.collapseItem(a,b)),this},p.prototype.addData=function(a,b){{var c,e=this,f=this.getNodeByID(b);this.getDataView()}return c=Array.isArray(a)?a:a.data,e.batchUpdate(function(){for(var a=c.length-1;a>=0;a--){var b,h=c[a];if(h.kind===p.FOLDER){var i=e.isLazy(),j={collapse:i};b=d.fromObject(h,f,j)}else b=g.fromObject(h,f);f.add(b,!0)}}),this},p.prototype.resetLoadedState=function(a,b){var c=this;return b?c.setLoadingStatus(a,b):c.setLoadingStatus(a,C),this},p.prototype.reloadFolder=function(a){return this.resetLoadedState(a),this.emptyFolder(a),this.collapseItem(a),this.expandItem(a),this},p.prototype.render=function(){return this.grid.render(),this},p.prototype.invalidate=function(){return this.grid.invalidate(),this},p.prototype.refreshData=function(){this.getDataView().refresh()},p.prototype.registerPlugin=function(a){this.plugins.unshift(a),a.init(this)},p.prototype.unregisterPlugin=function(a){for(var b=this.plugins,c=b.length;c>=0;c--)if(b[c]===a){b[c].destroy&&b[c].destroy(),b.splice(c,1);break}},a.fn.hgrid=function(a){this.each(function(){if(!this.id)throw new p.Error("Element must have an ID if initializing HGrid with jQuery");var b="#"+this.id;return new p(b,a)})},p}.call(this,jQuery);