%PDF- %PDF-
| Direktori : /opt/bitnami/apps/moodle/htdocs/course__d9c9c01/format/tiles/amd/build/ |
| Current File : /opt/bitnami/apps/moodle/htdocs/course__d9c9c01/format/tiles/amd/build/tile_fitter.min.js |
define ("format_tiles/tile_fitter",["jquery","core/ajax"],function(a,b){"use strict";var c=!1,d,e={PAGE:"#page",TILE:".tile",TILEID:"#tile-",TILE_COLLAPSED:".tile-collapsed",TILES:".format-tiles.jsenabled ul.tiles",ACTIVITY:".activity",SPACER:".spacer",SECTION_ID:"#section-",OPEN_SECTION:".moveablesection:visible",SECTION_ZERO:"#section-0",CONTENT_SECTIONS:".moveablesection"},f=null,g=function resizeTilesDivWidth(){var c=a(window).width(),g=new a.Deferred,h=a(e.TILES),i={standard:260,min:225,mobileMin:160};try{var j=h.parent().innerWidth(),k=a(h.find(e.TILE)[0]),l=k.width()?k.width():i.standard,m=14;l=l+m;var n="inherit",o=Math.floor(j/i.min),p=a(e.TILE).not(e.SPACER).length;if(j<2*i.mobileMin){g.reject("Too narrow to resize")}else if(3>=p&&j>p*i.mobileMin){n=4*i.standard}else if(j<3*i.min){n=2*(i.standard-m)}else if(4>o){n=i.standard*o}else{var q=function(a,b){var c=[];for(a;a<=b;a+=1){c.push(a)}return c},r=Math.min(Math.floor(j/l),p);if(p<=r&&5<p){n=(Math.floor(p/2)+1)*l}else if(3<r&&3>=p/r){var s=Math.floor(j/l),t=q(s,r).reverse(),u=t.map(function(a){return p%a});if(-1!==u.indexOf(0)){n=l*t[u.indexOf(0)]}else if(p<s){n=p*l}else{n=l*t[u.indexOf(Math.max.apply(null,u))]}}else{n=r*l}}var v=parseInt(h.css("max-width").replace("px",""));if(100>Math.abs(n-v)){g.resolve()}else{h.css("max-width",c).animate({"max-width":n},500,"swing",function(){setTimeout(function(){g.resolve()},600);a(e.CONTENT_SECTIONS).animate({"max-width":n},500,"swing")})}if(f){clearTimeout(f)}f=setTimeout(function(){b.call([{methodname:"format_tiles_set_session_width",args:{courseid:d,width:Math.floor(n)}}])},3e3)}catch(a){h.css("max-width",c).animate({"max-width":"100%"},500,"swing");b.call([{methodname:"format_tiles_set_session_width",args:{courseid:d,width:0}}]);g.reject("Failed to resize")}return g.promise()},h={getContentSectionPositions:function getContentSectionPositions(){var b=[],c,d,f=a(e.OPEN_SECTION);f.css("display","none");var g=1,h=0,i=a(e.TILES).children(e.TILE).not(e.TILE_COLLAPSED).not(".spacer");if(0===i.length){return[]}i.each(function(b,e){c=a(e).attr("data-section");if(c){if(0===b){h=1}else if(Math.abs(a(e).position().top-a(d).position().top)<=100){h+=1}else{h=0}if(h>g){g=h}d=e}});f.css("display","block");i.each(function(d,e){c=a(e).attr("data-section");if(0===b.length||b[b.length-1].sections.length>=g){if(1<=b.length){b[b.length-1].displayAfterTile=b[b.length-1].sections[b[b.length-1].sections.length-1]}b.push({displayAfterTile:"",sections:[c]})}else{b[b.length-1].sections.push(c)}});b[b.length-1].displayAfterTile=b[b.length-1].sections[b[b.length-1].sections.length-1];return b},moveContentSectionsToPlaces:function moveContentSectionsToPlaces(b,c){b.forEach(function(c){c.sections.forEach(function(d){if(c.displayAfterTile===b[b.length-1].displayAfterTile){a(e.SECTION_ID+d).detach().insertAfter(a("ul.tiles .tile").last())}else{a(e.SECTION_ID+d).detach().insertAfter(a("#tile-"+c.displayAfterTile))}})});c.forEach(function(a){if("function"==typeof a){a()}})},runReOrg:function runReOrg(b){var d=new a.Deferred;if(!0===c){d.reject("Re-org locked")}c=!0;var e=function(){h.moveContentSectionsToPlaces(h.getContentSectionPositions(),[function(){a("body").removeClass("modal-open");d.resolve("Finished organising tiles");c=!1}])};if(!0===b){setTimeout(function(){e();d.resolve("Re-org complete")},1e3)}else{e();d.resolve("Re-org complete")}return d.promise()}},i=function(){a(".block-hider-hide").click(function(){h.runReOrg(!0)});a(".block-hider-show").click(function(){h.runReOrg(!0)});a(".navbar button[data-action=\"toggle-drawer\"]").click(function(){setTimeout(function(){h.runReOrg(!0);g()},600)})},j=function(){a(e.TILES).animate({opacity:1},"fast");a(e.SECTION_ZERO).animate({opacity:1},"fast");a("#page-loading-icon").fadeOut(500).remove()};return{init:function init(b,c,f,k){d=b;a(document).ready(function(){i();if("1"===a(e.TILES).css("opacity")){h.runReOrg().done(function(){if(0!==c){a(e.TILEID+c).click()}})}var b=function(){h.runReOrg().done(function(){if(0!==c&&0===a(e.OPEN_SECTION).length){a(e.TILEID+c).click()}j()})};if(f&&!k){g().done(function(){b()}).fail(function(){b()})}else{b()}})},resizeTilesDivWidth:function resizeTilesDivWidth(){return g()},runReOrg:function runReOrg(a){return h.runReOrg(a)}}});
//# sourceMappingURL=tile_fitter.min.js.map