You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
11 KiB

define(["jquery","core/templates","core/ajax","format_tiles/browser_storage","core/notification","core/str","format_tiles/tile_fitter"],function(a,b,c,d,e,f,g){"use strict";var h,i,j,k,l,m=a("body"),n=a("body, html"),o=[],p=!1,q=!1,r=60,s=!1,t=0,u=!1,v=0,w={PAGE:"#page",TILE:".tile",TILEID:"#tile-",MOVEABLE_SECTION:".moveablesection",FILTER_BUTTON:".filterbutton",TILE_LOADING_ICON:".tile-loading-icon",TILE_LOADING_ICON_ID:"#loading-icon-",TILE_COLLAPSED:".tile-collapsed",TILE_CLICKABLE:".tile-clickable",TILES:"ul.tiles",ACTIVITY:".activity",SPACER:".spacer",SECTION_MOVEABLE:".moveablesection",SECTION_ID:"#section-",SECTION_TITLE:".sectiontitle",SECTION_MAIN:".section.main",SECTION_BUTTONS:"#sectionbuttons",CLOSE_SEC_BTN:".closesectionbtn",HIDE_SEC0_BTN:"#buttonhidesec0",SECTION_ZERO:"#section-0",MOODLE_VIDEO:".mediaplugin.mediaplugin_videojs",LAUNCH_STANDARD:'[data-action="launch-tiles-standard"]',TOOLTIP:"[data-toggle=tooltip]",HEADER_BAR:["header.navbar","nav.fixed-top.navbar","#essentialnavbar.navbar","#navwrap","nav.navbar-fixed-top"]},x={SELECTED:"selected",HEADER_OVERLAY:"header-overlay",OPEN:"open",CLOSED:"closed",LAUNCH_CM_MODAL:"launch-tiles-cm-modal",STATE_VISIBLE:"state-visible"},y={CLICK:"click",KEYDOWN:"keydown",SCROLL:"scroll"},z={DISPLAY:"display",Z_INDEX:"z-index",HEIGHT:"height",BG_COLOUR:"background-color"},A={ESCAPE:27,TAB:9,RETURN:13},B=function(a){return void 0!==k&&(a===!0?k.fadeIn(300):k.fadeOut(300),!0)},C=function(b){var c=a(w.SECTION_ID+b);c.find("iframe").each(function(b,c){c=a(c),c.attr("src",c.attr("src"))});var d=c.find(w.MOODLE_VIDEO);d.length>0&&c.html("")},D=function(b){a(w.MOVEABLE_SECTION).each(function(b,c){c=a(c),c.is(":visible")&&(C(c.attr("data-section")),c.slideUp().removeClass(x.STATE_VISIBLE))}),a(w.TILE).removeClass(x.SELECTED).css(z.Z_INDEX,"").css(z.BG_COLOUR,""),a(".section "+x.SELECTED).removeClass(x.SELECTED).css(z.Z_INDEX,""),j.fadeOut(300),B(!1),void 0!==b&&0!==b&&a(w.TILEID+b).focus(),a(w.TILE_LOADING_ICON).fadeOut(300,function(){a(w.TILE_LOADING_ICON).html("")}),q=!1,v=0},E=function(b,c){if(c){if(b.html(c),a(w.TILE_LOADING_ICON).fadeOut(300,function(){a(w.TILE_LOADING_ICON).html("")}),b.attr("id")!==w.SECTION_ZERO){var e=b.find(w.ACTIVITY).not(w.SPACER);b.on(y.KEYDOWN,function(c){c.keyCode===A.ESCAPE&&(d.setLastVisitedSection(0),D(0),a(w.TILEID+b.attr("data-section")).focus())}),e.on(y.KEYDOWN,function(b){if(b.keyCode===A.RETURN){var c=a(b.currentTarget).find("a");c.hasClass(x.LAUNCH_CM_MODAL)?c.click():void 0!==c.attr("href")&&(window.location=c.attr("href"))}}),h||(e.last().on(y.KEYDOWN,function(c){c.keyCode!==A.TAB||c.shiftKey||a(c.relatedTarget).closest(w.SECTION_MAIN).attr("id")===b.attr("id")||setTimeout(function(){b.find(w.SECTION_TITLE).focus(),n.animate({scrollTop:b.offset().top-r},"slow"),b.find("#sectionbuttons").css("top","")},200)}),b.find(w.SECTION_TITLE).on(y.KEYDOWN,function(c){c.keyCode===A.TAB&&c.shiftKey&&a(c.relatedTarget).closest(w.SECTION_MAIN).attr("id")!==b.attr("id")&&setTimeout(function(){e.last().focus()},200)}))}return h||setTimeout(function(){try{b.find(".togglecompletion, .completioncheckbox, .tag-info").tooltip()}catch(a){require(["core/log"],function(b){b.debug(a)})}},500),0!==b.find(w.MOODLE_VIDEO).length&&require(["media_videojs/loader"],function(a){a.setUp()}),!0}return!1},F=function(b,c){var d=function(){var d=a("#tileText-"+c).offset().top-r;d===a(window).scrollTop&&(d+=1),b.find(w.SECTION_TITLE).focus();var e="scroll mousedown wheel DOMMouseScroll mousewheel keyup touchmove";m.on(e,function(){m.stop()}),n.animate({scrollTop:d},"slow",function(){n.off(e,function(){n.stop()})}),q=!0,v=c,b.find(w.ACTIVITY).first().focus()},e=function(){var c=b.find(w.SECTION_BUTTONS);a(window).on(y.SCROLL,function(){!p&&q&&(p=!0,c.fadeOut(300),setTimeout(function(){var d=a(window).scrollTop(),e=d-b.offset().top+50;e>0&&e<b.outerHeight()-100?(e=d-b.offset().top+50,c.css("top",e),"none"===j.css(z.DISPLAY)&&j.fadeIn(300)):e<0&&c.css("top",0),d>b.offset().top+b.outerHeight()-50?("block"===j.css(z.DISPLAY)&&(j.fadeOut(300),B(!1)),c.css("top",0)):b.offset()