{"version":3,"file":"homepage_frontpage.min.js","sources":["https:\/\/www.learnifs.com\/local\/edwiserpagebuilder\/amd\/src\/homepage_frontpage.js"],"sourcesContent":["\/* eslint-disable require-jsdoc *\/\n\/* eslint-disable jsdoc\/require-jsdoc *\/\n\/* eslint-disable no-unused-vars *\/\n\/* eslint-disable no-undef *\/\n\/* eslint-disable max-len *\/\n\/* eslint-disable no-console *\/\n\/\/ This file is part of Moodle - http:\/\/moodle.org\/\n\/\/\n\/\/ Moodle is free software: you can redistribute it and\/or modify\n\/\/ it under the terms of the GNU General Public License as published by\n\/\/ the Free Software Foundation, either version 3 of the License, or\n\/\/ (at your option) any later version.\n\/\/\n\/\/ Moodle is distributed in the hope that it will be useful,\n\/\/ but WITHOUT ANY WARRANTY; without even the implied warranty of\n\/\/ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\/\/ GNU General Public License for more details.\n\/\/\n\/\/ You should have received a copy of the GNU General Public License\n\/\/ along with Moodle. If not, see .\n\n\/\/ Section manager class\n\/\/\n\/\/ @module local_remuihomepage\/frontpage\n\/\/ @copyright (c) 2018 WisdmLabs (https:\/\/wisdmlabs.com\/)\n\/\/ @license http:\/\/www.gnu.org\/copyleft\/gpl.html GNU GPL v3 or later.\n\ndefine([\n 'jquery',\n 'core\/modal_factory',\n 'core\/templates',\n 'core\/str', 'core\/modal_events',\n 'core\/fragment',\n 'core\/ajax',\n 'core\/notification',\n 'theme_remui\/slick'\n], function (\n $,\n ModalFactory,\n Templates,\n Str,\n ModalEvents,\n Fragment,\n Ajax,\n Notification\n) {\n var instanceid = '';\n var categoryid = '';\n let SECTIONSELECTOR = \"\";\n var COURSESECTIONCATEGORY = \" .section-courses .category-list .category-item\";\n \/**\n * Generate courses slick slider\n * @param {Number} instanceid Instance id of section\n * @param {Number} categoryid Category id\n * @param {Function} callback Callback function\n *\/\n function generateCourses(instanceid, categoryid, callback) {\n var section = getSectionElement(instanceid);\n section.find('.courses-slider').removeClass('show');\n Ajax.call([{\n methodname: 'local_edwiserpagebuilder_get_frontpage_section_courses_in_category',\n args: {\n instanceid: instanceid,\n categoryid: categoryid\n },\n done: function (response) {\n response = JSON.parse(response);\n response.shadowless = response.sectionproperties.shadowless;\n response.shadowcolor = response.sectionproperties.shadowcolor;\n section.find('.courses-slider.slick-initialized.slick-slider').slick('unslick');\n section.find('.courses-slider').empty();\n section.data('totalcourses', response.totalcourse);\n section.data('current', 0);\n Templates.render('local_edwiserpagebuilder\/courses_cards', response)\n .done(function (html, js) {\n Templates.appendNodeContents(section.find('.courses-slider'), html, js);\n applySlickToCourses(instanceid, {\n slidesToShow: 3,\n slidesToScroll: 3\n });\n if (typeof callback == 'function') {\n callback();\n }\n })\n .fail(Notification.exception);\n },\n fail: function (ex) {\n Notification.exception(ex);\n }\n }]);\n }\n\n function setcategoryInstanceid(id) {\n this.instanceid = id;\n SECTIONSELECTOR = 'section[data-instance=\"' + id + '\"]';\n return SECTIONSELECTOR;\n };\n\n function getSectionElement(instanceid) {\n if (instanceid !== false) {\n setcategoryInstanceid(instanceid);\n }\n return $('body').find(SECTIONSELECTOR);\n };\n \/**\n * Polyfill method for Object.assign\n * @param {Object} target Target Object\n * @return {Object} Merged object\n *\/\n var assign = Object.assign || function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n return target;\n };\n\n var initializeEvents = function () {\n \/\/ Load courses on course category selection.\n $('body').on('click', COURSESECTIONCATEGORY, function () {\n var instanceid = $(this).parents('section[data-instance]').data('instance');\n $(this).parents('section[data-instance]').find('.courses-slider').removeClass('show');\n var categoryid = $(this).data('id');\n generateCourses(instanceid, categoryid, (function () {\n $(this).siblings().removeClass('active');\n $(this).addClass('active');\n $(this).parents('.category-list').removeClass('show');\n }).bind(this));\n });\n\n };\n \/**\n * Apply slick to courses list\n * @param {Number} instanceid Section instance id\n * @param {Object} options Options of slick slider\n *\/\n function applySlickToCourses(instanceid, options) {\n var defaults = {\n dots: false,\n arrows: true,\n infinite: false,\n speed: 500,\n prevArrow: $(\"section[data-instance='\" + instanceid + \"'] .button-container .btn-prev\"),\n nextArrow: $(\"section[data-instance='\" + instanceid + \"'] .button-container .btn-next\"),\n rtl: ($(\"html\").attr(\"dir\") == \"rtl\") ? true : false,\n slidesToShow: 4,\n slidesToScroll: 4,\n responsive: [{\n breakpoint: 1024,\n settings: {\n slidesToShow: 3,\n slidesToScroll: 3\n }\n }, {\n breakpoint: 800,\n settings: {\n slidesToShow: 2,\n slidesToScroll: 2\n }\n }, {\n breakpoint: 480,\n settings: {\n slidesToShow: 1,\n slidesToScroll: 1\n }\n }]\n };\n if (options !== null && typeof options == 'object') {\n assign(defaults, options);\n }\n var section =\n getSectionElement(instanceid);\n section.find('.available-courses').addClass('d-none');\n if (section.find('.courses-slider .empty-courses-container').length != 0) {\n return;\n }\n section.find('.courses-slider').slick(defaults)\n .on('setPosition', function (event, slick) {\n $(section).find('.slick-slide > div').css('height', '100%');\n slick.$slides.css('height', slick.$slideTrack.height() + 'px');\n });\n section.find('.available-courses').removeClass('d-none');\n }\n\n return {\n init: function () {\n $(document).ready(function () {\n initializeEvents();\n var instanceid = $(COURSESECTIONCATEGORY).parents('section[data-instance]').data('instance');\n $(this).parents(COURSESECTIONCATEGORY).find('.courses-slider').removeClass('show');\n var categoryid = 0;\n if ($(COURSESECTIONCATEGORY).length) {\n generateCourses(instanceid, categoryid, (function () {\n $(COURSESECTIONCATEGORY).siblings().removeClass('active');\n $(COURSESECTIONCATEGORY).addClass('active');\n $(COURSESECTIONCATEGORY).parents('.category-list').removeClass('show');\n }).bind(COURSESECTIONCATEGORY));\n }\n });\n }\n };\n});\n"],"names":["define","$","ModalFactory","Templates","Str","ModalEvents","Fragment","Ajax","Notification","SECTIONSELECTOR","COURSESECTIONCATEGORY","generateCourses","instanceid","categoryid","callback","section","getSectionElement","find","removeClass","call","methodname","args","done","response","JSON","parse","shadowless","sectionproperties","shadowcolor","slick","empty","data","totalcourse","render","html","js","appendNodeContents","options","defaults","dots","arrows","infinite","speed","prevArrow","nextArrow","rtl","attr","slidesToShow","slidesToScroll","responsive","breakpoint","settings","assign","addClass","length","on","event","css","$slides","$slideTrack","height","applySlickToCourses","fail","exception","ex","id","setcategoryInstanceid","Object","target","i","arguments","source","key","prototype","hasOwnProperty","init","document","ready","this","parents","siblings","bind"],"mappings":";AA2BAA,qDAAO,CACH,SACA,qBACA,iBACA,WAAY,oBACZ,gBACA,YACA,oBACA,sBACD,SACCC,EACAC,aACAC,UACAC,IACAC,YACAC,SACAC,KACAC,kBAIIC,gBAAkB,OAClBC,sBAAwB,2DAOnBC,gBAAgBC,WAAYC,WAAYC,cACzCC,QAAUC,kBAAkBJ,YAChCG,QAAQE,KAAK,mBAAmBC,YAAY,QAC5CX,KAAKY,KAAK,CAAC,CACPC,WAAY,qEACZC,KAAM,CACFT,WAAYA,WACZC,WAAYA,YAEhBS,KAAM,SAAUC,WACZA,SAAWC,KAAKC,MAAMF,WACbG,WAAaH,SAASI,kBAAkBD,WACjDH,SAASK,YAAcL,SAASI,kBAAkBC,YAClDb,QAAQE,KAAK,kDAAkDY,MAAM,WACrEd,QAAQE,KAAK,mBAAmBa,QAChCf,QAAQgB,KAAK,eAAgBR,SAASS,aACtCjB,QAAQgB,KAAK,UAAW,GACxB5B,UAAU8B,OAAO,yCAA0CV,UACtDD,MAAK,SAAUY,KAAMC,IAClBhC,UAAUiC,mBAAmBrB,QAAQE,KAAK,mBAAoBiB,KAAMC,aAiE3DvB,WAAYyB,aACjCC,SAAW,CACXC,MAAM,EACNC,QAAQ,EACRC,UAAU,EACVC,MAAO,IACPC,UAAW1C,EAAE,0BAA4BW,WAAa,kCACtDgC,UAAW3C,EAAE,0BAA4BW,WAAa,kCACtDiC,IAA+B,OAAzB5C,EAAE,QAAQ6C,KAAK,OACrBC,aAAc,EACdC,eAAgB,EAChBC,WAAY,CAAC,CACTC,WAAY,KACZC,SA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