芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/public_html/cepali/blocks/myoverview/amd/build/view.min.js
define(["jquery","block_myoverview/repository","core/paged_content_factory","core/pubsub","core/custom_interaction_events","core/notification","core/templates","core_course/events","block_myoverview/selectors","core/paged_content_events"],function(a,b,c,d,e,f,g,h,i,j){var k={COURSE_REGION:'[data-region="course-view-content"]',ACTION_HIDE_COURSE:'[data-action="hide-course"]',ACTION_SHOW_COURSE:'[data-action="show-course"]',ACTION_ADD_FAVOURITE:'[data-action="add-favourite"]',ACTION_REMOVE_FAVOURITE:'[data-action="remove-favourite"]',FAVOURITE_ICON:'[data-region="favourite-icon"]',ICON_IS_FAVOURITE:'[data-region="is-favourite"]',ICON_NOT_FAVOURITE:'[data-region="not-favourite"]',PAGED_CONTENT_CONTAINER:'[data-region="page-container"]'},l={COURSES_CARDS:"block_myoverview/view-cards",COURSES_LIST:"block_myoverview/view-list",COURSES_SUMMARY:"block_myoverview/view-summary",NOCOURSES:"core_course/no-courses"},m=[12,24,48],n=[],o=0,p=0,q=0,r=null,s=function(a){var b=a.find(i.courseView.region);return{display:b.attr("data-display"),grouping:b.attr("data-grouping"),sort:b.attr("data-sort"),displaycategories:b.attr("data-displaycategories")}},t={ignoreControlWhileLoading:!0,controlPlacementBottom:!0,persistentLimitKey:"block_myoverview_user_paging_preference"},u=function(a,c){return b.getEnrolledCoursesByTimeline({offset:o,limit:c,classification:a.grouping,sort:a.sort})},v=function(a,b){return a.find(k.FAVOURITE_ICON+'[data-course-id="'+b+'"]')},w=function(a,b){return a.find('[data-region="paged-content-page"][data-page="'+b+'"]')},x=function(a){return a.attr("data-course-id")},y=function(a,b){var c=v(a,b),d=c.find(k.ICON_IS_FAVOURITE);d.addClass("hidden"),d.attr("aria-hidden",!0);var e=c.find(k.ICON_NOT_FAVOURITE);e.removeClass("hidden"),e.attr("aria-hidden",!1)},z=function(a,b){var c=v(a,b),d=c.find(k.ICON_IS_FAVOURITE);d.removeClass("hidden"),d.attr("aria-hidden",!1);var e=c.find(k.ICON_NOT_FAVOURITE);e.addClass("hidden"),e.attr("aria-hidden",!0)},A=function(a,b){return a.find('[data-action="add-favourite"][data-course-id="'+b+'"]')},B=function(a,b){return a.find('[data-action="remove-favourite"][data-course-id="'+b+'"]')},C=function(a,b){var c=B(a,b),e=A(a,b);F(b,!0).then(function(g){g?(d.publish(h.favourited,b),c.removeClass("hidden"),e.addClass("hidden"),z(a,b)):f.alert("Starring course failed","Could not change favourite state")})["catch"](f.exception)},D=function(a,b){var c=B(a,b),e=A(a,b);F(b,!1).then(function(g){g?(d.publish(h.unfavorited,b),c.addClass("hidden"),e.removeClass("hidden"),y(a,b)):f.alert("Starring course failed","Could not change favourite state")})["catch"](f.exception)},E=function(b,d){var e=x(d),h=b.find('[data-region="paging-bar"]'),i=parseInt(h.attr("data-active-page-number")),j=n[i],k=j.courses.reduce(function(a,b){return e!=b.id&&a.push(b),a},[]);if(void 0!=n[i+1]){var l=n[i+1].courses.slice(0,1);n.forEach(function(b,c){if(c>i){var d=[];void 0!=n[c+1]&&(d=n[c+1].courses.slice(0,1)),n[c].courses=a.merge(n[c].courses.slice(1),d)}}),k=a.merge(k,l)}if(p==i+1&&0==n[i+1].courses.length){var m=b.find('[data-region="paged-content-container"]');c.resetLastPageNumber(a(m).attr("id"),i)}n[i].courses=k,o--;var q=w(b,i);G(b,n[i]).then(function(a,b){return g.replaceNodeContents(q,a,b)})["catch"](f.exception),n.forEach(function(a,c){if(c>i){var d=w(b,c);d.remove()}})},F=function(a,c){return b.setFavouriteCourses({courses:[{id:a,favourite:c}]}).then(function(b){return 0==b.warnings.length&&(n.forEach(function(b){b.courses.forEach(function(d,e){d.id==a&&(b.courses[e].isfavourite=c)})}),!0)})["catch"](f.exception)},G=function(a,b){var c=s(a),d="";if(d="cards"==c.display?l.COURSES_CARDS:"list"==c.display?l.COURSES_LIST:l.COURSES_SUMMARY,"on"!=c.displaycategories&&(b.courses=b.courses.map(function(a){return delete a.coursecategory,a})),b.courses.length)return g.render(d,{courses:b.courses});var e=a.find(i.courseView.region).attr("data-nocoursesimg");return g.render(l.NOCOURSES,{nocoursesimg:e})},H=function(a){this.find(i.courseView.region).attr("data-paging",a)},I=function(a,b){var c=b+j.SET_ITEMS_PER_PAGE_LIMIT;d.subscribe(c,H.bind(a))},J=function(b){r="block_myoverview_"+b.attr("id")+"_"+Math.random();var d=m,e=parseInt(b.find(i.courseView.region).attr("data-paging"),10);e&&(d=m.map(function(a){var b=!1;return a==e&&(b=!0),{value:a,active:b}}));var h=s(b),j=a.extend({},t);j.eventNamespace=r;var k=c.createWithLimit(d,function(c,d){var e=[];return c.forEach(function(c){var g=c.pageNumber,i=c.limit;if(q!=i&&(n=[],o=0,p=0),p==g)return d.allItemsLoaded(p),void e.push(G(b,n[g]));q=i,void 0==n[g+1]&&void 0==n[g]&&(i*=2);var j=u(h,i).then(function(e){var f=e.courses,h=0,i=[];if(void 0!=n[g]){i=n[g].courses;var j=i.length;j
0?n.forEach(function(b,c){var d=w(a,c);G(a,b).then(function(a,b){return g.replaceNodeContents(d,a,b)})["catch"](f.exception)}):L(a)};return{init:L,reset:M}});