Your IP : 192.168.165.1


Current Path : C:/Users/Mahmood/Desktop/moodle/lib/amd/build/
Upload File :
Current File : C:/Users/Mahmood/Desktop/moodle/lib/amd/build/tree.min.js

define ("core/tree",["jquery"],function(a){var b={ITEM:"[role=treeitem]",GROUP:"[role=treeitem]:has([role=group]), [role=treeitem][aria-owns], [role=treeitem][data-requires-ajax=true]",CLOSED_GROUP:"[role=treeitem]:has([role=group])[aria-expanded=false], [role=treeitem][aria-owns][aria-expanded=false], [role=treeitem][data-requires-ajax=true][aria-expanded=false]",FIRST_ITEM:"[role=treeitem]:first",VISIBLE_ITEM:"[role=treeitem]:visible",UNLOADED_AJAX_ITEM:"[role=treeitem][data-requires-ajax=true][data-loaded=false][aria-expanded=true]"},c=function(c,d){this.treeRoot=a(c);this.treeRoot.data("activeItem",null);this.selectCallback=d;this.keys={tab:9,enter:13,space:32,pageup:33,pagedown:34,end:35,home:36,left:37,up:38,right:39,down:40,asterisk:106};this.initialiseNodes(this.treeRoot);this.setActiveItem(this.treeRoot.find(b.FIRST_ITEM));this.refreshVisibleItemsCache();this.bindEventHandlers()};c.prototype.registerEnterCallback=function(a){this.enterCallback=a};c.prototype.refreshVisibleItemsCache=function(){this.treeRoot.data("visibleItems",this.treeRoot.find(b.VISIBLE_ITEM))};c.prototype.getVisibleItems=function(){return this.treeRoot.data("visibleItems")};c.prototype.setActiveItem=function(a){var b=this.treeRoot.data("activeItem");if(a===b){return}if(b){b.attr("tabindex","-1");b.attr("aria-selected","false")}a.attr("tabindex","0");a.attr("aria-selected","true");this.treeRoot.data("activeItem",a);if("function"==typeof this.selectCallback){this.selectCallback(a)}};c.prototype.isGroupItem=function(a){return a.is(b.GROUP)};c.prototype.getGroupFromItem=function(a){var b=this.treeRoot.find("#"+a.attr("aria-owns")),c=a.children("[role=group]");if(b.length>c.length){return b}else{return c}};c.prototype.isGroupCollapsed=function(a){return"false"===a.attr("aria-expanded")};c.prototype.isGroupCollapsible=function(a){return"false"!==a.attr("data-collapsible")};c.prototype.initialiseNodes=function(c){this.removeAllFromTabOrder(c);this.setAriaSelectedFalseOnItems(c);var d=this;c.find(b.UNLOADED_AJAX_ITEM).each(function(){var b=a(this);d.collapseGroup(b);d.expandGroup(b)})};c.prototype.removeAllFromTabOrder=function(b){b.find("*").attr("tabindex","-1");this.getGroupFromItem(a(b)).find("*").attr("tabindex","-1")};c.prototype.setAriaSelectedFalseOnItems=function(a){a.find(b.ITEM).attr("aria-selected","false")};c.prototype.expandAllGroups=function(){var c=this;this.treeRoot.find(b.CLOSED_GROUP).each(function(){var b=a(this);c.expandGroup(a(this)).done(function(){c.expandAllChildGroups(b)})})};c.prototype.expandAllChildGroups=function(c){var d=this;this.getGroupFromItem(c).find(b.CLOSED_GROUP).each(function(){var b=a(this);d.expandGroup(a(this)).done(function(){d.expandAllChildGroups(b)})})};c.prototype.expandGroup=function(b){var c=a.Deferred();if("false"!==b.attr("data-expandable")&&this.isGroupCollapsed(b)){if("true"===b.attr("data-requires-ajax")&&"true"!==b.attr("data-loaded")){b.attr("data-loaded",!1);var d=b.closest("[data-ajax-loader]").attr("data-ajax-loader"),e=this;b.addClass("loading");require([d],function(a){a.load(b).done(function(){b.attr("data-loaded",!0);e.initialiseNodes(b);e.finishExpandingGroup(b);b.removeClass("loading");c.resolve()})})}else{this.finishExpandingGroup(b);c.resolve()}}else{c.resolve()}return c};c.prototype.finishExpandingGroup=function(a){var b=this.getGroupFromItem(a);b.attr("aria-hidden","false");a.attr("aria-expanded","true");this.refreshVisibleItemsCache()};c.prototype.collapseGroup=function(a){if(!this.isGroupCollapsible(a)||this.isGroupCollapsed(a)){return}var b=this.getGroupFromItem(a);b.attr("aria-hidden","true");a.attr("aria-expanded","false");this.refreshVisibleItemsCache()};c.prototype.toggleGroup=function(a){if("true"===a.attr("aria-expanded")){this.collapseGroup(a)}else{this.expandGroup(a)}};c.prototype.handleKeyDown=function(c,d){var e=this.getVisibleItems().index(c);if(d.altKey||d.ctrlKey||d.metaKey||d.shiftKey&&d.keyCode!=this.keys.tab){return!0}switch(d.keyCode){case this.keys.home:{this.getVisibleItems().first().focus();d.stopPropagation();return!1}case this.keys.end:{this.getVisibleItems().last().focus();d.stopPropagation();return!1}case this.keys.enter:{var f=c.children("a").length?c.children("a"):c.children().not(b.GROUP).find("a");if(f.length){if("function"==typeof this.enterCallback){this.enterCallback(c)}else{window.location.href=f.first().attr("href")}}else if(this.isGroupItem(c)){this.toggleGroup(c,!0)}d.stopPropagation();return!1}case this.keys.space:{if(this.isGroupItem(c)){this.toggleGroup(c,!0)}d.stopPropagation();return!1}case this.keys.left:{var g=function(b){b.getVisibleItems().filter(function(){return b.getGroupFromItem(a(this)).has(c).length}).focus()};if(this.isGroupItem(c)){if(this.isGroupCollapsed(c)){g(this)}else{this.collapseGroup(c)}}else{g(this)}d.stopPropagation();return!1}case this.keys.right:{if(this.isGroupItem(c)){if(this.isGroupCollapsed(c)){this.expandGroup(c)}else{this.getGroupFromItem(c).find(b.ITEM).first().focus()}}d.stopPropagation();return!1}case this.keys.up:{if(0<e){var h=this.getVisibleItems().eq(e-1);h.focus()}d.stopPropagation();return!1}case this.keys.down:{if(e<this.getVisibleItems().length-1){var i=this.getVisibleItems().eq(e+1);i.focus()}d.stopPropagation();return!1}case this.keys.asterisk:{this.expandAllGroups();d.stopPropagation();return!1}}return!0};c.prototype.handleClick=function(a,b){if(b.altKey||b.ctrlKey||b.shiftKey||b.metaKey){return!0}a.focus();if(this.isGroupItem(a)){this.toggleGroup(a)}b.stopPropagation();return!0};c.prototype.handleFocus=function(a,b){this.setActiveItem(a);b.stopPropagation();return!0};c.prototype.bindEventHandlers=function(){var c=this;this.treeRoot.on({click:function click(b){return c.handleClick(a(this),b)},keydown:function keydown(b){return c.handleKeyDown(a(this),b)},focus:function focus(b){return c.handleFocus(a(this),b)}},b.ITEM)};return c});
//# sourceMappingURL=tree.min.js.map