// var gClickFlag = false;
var gResizeInitCount = 0;
function veo_commonInit()
{
var gIsAutoPlay = true;
$.each($(".topSlider .sliderItem"), function(_i, _el){
if($(_el).find('.videoWrapper').data("video") !== undefined){
gIsAutoPlay = false;
}
});
$(".topSlider").slick
(
{
dots: true,
infinite: true,
speed: 300,
slidesToShow: 1,
adaptiveHeight: true,
fade: true,
autoplay: gIsAutoPlay,
autoplaySpeed: 5000
}
);
$(".topSlider").on
(
"beforeChange",
function(pEvent, pSlick, pCurrentSlide, pNextSlide)
{
var _video = $(".topSlider").find(".sliderItem[data-slick-index=" + pNextSlide + "]").find(".videoWrapper").data("video");
$(".topSlider").find(".sliderItem").removeClass("active");
$(".topSlider").find(".sliderItem[data-slick-index=" + pNextSlide + "]").addClass("active");
updateSliderVideo($(".topSlider"), $(".topSlider").find(".sliderItem[data-slick-index=" + pNextSlide + "]"), _video);
}
);
/*
$(".topSlider").on
(
"afterChange",
function(pEvent, pSlick, pCurrentSlide)
{
}
);
*/
$(".topSlider").find(".sliderItem").removeClass("active");
$(".topSlider").find(".sliderItem[data-slick-index=0]").addClass("active");
updateSliderVideo($(".topSlider"), $(".topSlider").find(".sliderItem.active"), $(".topSlider").find(".sliderItem.active").find(".videoWrapper").data("video"));
closeFilters();
$(".tableSection").each
(
function (pIndex, pElement)
{
var _tableSectionIndex = pIndex + 1;
var _tableSection = $(pElement);
if (_tableSection.find(".toggleSelectionHolder").length > 0)
{
_tableSection.find(".toggleSelectionHolder").each
(
function (pIndex, pElement)
{
closeToggleSelection($(pElement));
$(pElement).find(".toggleSelection").find("input[type='radio']").on
(
"change",
function ()
{
return function (pEvent)
{
updateToggleSelection(_tableSectionIndex, $(pElement), $(pEvent.currentTarget));
};
}()
);
}
);
}
else
{
var _tableSection = $(".tableSection" + _tableSectionIndex);
var _table = _tableSection.find("table");
var _rowEven = false;
var _colEven = false;
_table.find("thead").find(".headRow").find("th").each
(
function (pIndex, pElement)
{
$(pElement).addClass("active");
}
);
_table.find("tbody").find("tr").each
(
function (pIndex, pElement)
{
$(pElement).addClass("active");
if (_rowEven)
{
$(pElement).addClass("even");
}
_rowEven = !_rowEven;
$(pElement).find("td").each
(
function (pIndex, pElement)
{
$(pElement).addClass("active");
if (_colEven)
{
$(pElement).addClass("even");
}
_colEven = !_colEven;
}
);
}
);
}
}
);
resetFilters();
$(window).on
(
"resize",
function(pEvent, pResponsive_str)
{
gResizeInitCount++;
if ((gResizeInitCount < 2) || ($(window).width() != gDisplayWidth))
{
gDisplayWidth = $(window).width();
$("html, body").removeClass("transitionFreeze").addClass("transitionFreeze");
$(".toggleSelectionHolder").each
(
function (pIndex, pElement)
{
closeToggleSelection($(pElement));
}
);
closeFilters();
if ($(".campusMenuWrapper").length > 0)
{
updateCampusMenu($(".campusMenuWrapper").find("#learningwithusMenu_timetable"));
}
if ($(".learningwithusMenuWrapper").length > 0)
{
updateLearningwithusMenu($(".learningwithusMenuWrapper").find("#learningwithusMenu_timetable"));
}
if ($(".tabMenuWrapper").length > 0)
{
if(gCurrentTab != '') {
updateTabMenu(gCurrentTab);
}
// 20180115 call closeFaqItems() only when it is declared
if (typeof closeFaqItems !== 'undefined' && typeof closeFaqItems === 'function') {
closeFaqItems();
}
}
setTimeout
(
function ()
{
$("html, body").removeClass("transitionFreeze");
},
10
);
}
}
);
}
function veo_campusInit()
{
$(".campusMenu").find("input[type='radio']").on
(
"change",
function (pEvent)
{
updateCampusMenu($(pEvent.currentTarget));
}
);
gDisplayWidth = $(window).width();
gCurrentCampusSection = $(".campusMenuWrapper").find("#learningwithusMenu_timetable").val();
$(".campusMenuWrapper").find("#learningwithusMenu_timetable").trigger("click");
updateCampusMenu($(".campusMenuWrapper").find("#learningwithusMenu_timetable"));
}
function veo_learningwithusInit()
{
$(".learningwithusMenu").find("input[type='radio']").on
(
"change",
function (pEvent)
{
updateLearningwithusMenu($(pEvent.currentTarget));
}
);
gDisplayWidth = $(window).width();
gCurrentLearningwithusSection = $(".learningwithusMenuWrapper").find("#learningwithusMenu_timetable").val();
$(".learningwithusMenuWrapper").find("#learningwithusMenu_timetable").trigger("click");
}
function updateSliderVideo(pSlider, pSliderItem, pVideo)
{
var _html = null;
var _popVideoType = pSliderItem.data("type");
var _popVideo = pSliderItem.data("id");
_html = '';
if (pVideo != undefined)
{
if ($("body").hasClass("deviceDesktop"))
{
_html += '';
}
}
if ((_popVideoType != undefined) && (_popVideoType != ""))
{
_html += '';
}
pSliderItem.find(".videoWrapper").html(_html);
}
function toggleToggleSelection(pTarget)
{
if ($(pTarget).find(".toggleSelectionBtn").hasClass("active"))
{
closeToggleSelection(pTarget);
$(pTarget).find(".toggleSelectionBtn").html($(pTarget).find(".toggleSelectionContainer").find(".toggleSelection").find("input[type='radio']:checked").data("desc"));
}
else
{
closeToggleSelection(pTarget);
$(pTarget).find(".toggleSelectionBtn").addClass("active");
$(pTarget).find(".toggleSelectionContainer").find(".toggleSelection").css({"margin-top": 0});
$(pTarget).find(".toggleSelectionBtn").html($(pTarget).data("select-desc"));
}
}
function updateToggleSelection(pTableSectionIndex, pToggleSelection, pTarget)
{
closeToggleSelection(pToggleSelection);
$(pToggleSelection).find(".toggleSelectionBtn").html(pTarget.data("desc"));
updateTable(pTableSectionIndex);
}
function closeToggleSelection(pTarget)
{
pTarget.find(".toggleSelectionBtn").removeClass("active");
pTarget.find(".toggleSelection").css({"margin-top": (-1 * pTarget.find(".toggleSelection").height()) + "px"});
}
function toggleFilters(pTarget)
{
if (pTarget.find(".toggleSelectionWrapper").hasClass("active"))
{
pTarget.find(".filterBtnWrapper").removeClass("active");
closeFilters();
}
else
{
pTarget.find(".filterBtnWrapper").removeClass("active").addClass("active");
pTarget.find(".toggleSelectionWrapper").removeClass("active").addClass("active");
}
}
function closeFilters()
{
$(".toggleSelectionWrapper").each
(
function (pIndex, pElement)
{
$(pElement).removeClass("active");
$(pElement).css({"margin-top": (-1 * $(pElement).height()) + "px"});
}
)
;
}
function updateTable(pTableSectionIndex)
{
var _tableSection = $(".tableSection" + pTableSectionIndex);
var _table = _tableSection.find("table");
var _rowFilter = 0;
var _colFilter = 0;
var _rowEven = false;
var _colEven = false;
var _html = null;
var _desc = null;
var _filtered = false;
_tableSection.find(".appliedFilters").html("");
$(".appliedFilterWrapper").removeClass("hide");
if (_tableSection.find(".filterRow").length == 1)
{
_rowFilter = _tableSection.find("input[name='tableSection" + pTableSectionIndex + "_filterRow']:checked").val();
if (_rowFilter == undefined)
{
_rowFilter = 0;
}
}
if (_tableSection.find(".filterCol").length == 1)
{
_colFilter = _tableSection.find("input[name='tableSection" + pTableSectionIndex + "_filterCol']:checked").val();
if (_colFilter == undefined)
{
_colFilter = 0;
}
}
_table.find("thead").find(".headRow").find("th").removeClass("active");
_table.find("tbody").find("tr").removeClass("active");
_table.find("tbody").find("tr").removeClass("even");
_table.find("tbody").find("td").removeClass("active");
_table.find("tbody").find("td").removeClass("even");
_table.find("thead").find(".headRow").find("th").each
(
function (pIndex, pElement)
{
if ((pIndex == 0) || (_colFilter == 0) || ($(pElement).hasClass("tableCol" + _colFilter)))
{
$(pElement).addClass("active");
}
}
);
_table.find("tbody").find("tr").each
(
function (pIndex, pElement)
{
if ((_rowFilter == 0) || ($(pElement).hasClass("tableRow" + _rowFilter)))
{
$(pElement).addClass("active");
if (_rowEven)
{
$(pElement).addClass("even");
}
_rowEven = !_rowEven;
$(pElement).find("td").each
(
function (pIndex, pElement)
{
if ((pIndex == 0) || (_colFilter == 0) || ($(pElement).hasClass("tableCol" + _colFilter)))
{
$(pElement).addClass("active");
if (_colEven)
{
$(pElement).addClass("even");
}
_colEven = !_colEven;
}
}
);
}
}
);
if (_rowFilter != 0)
{
_filtered = true;
_desc = _tableSection.find("input[name='tableSection" + pTableSectionIndex + "_filterRow']#tableSection" + pTableSectionIndex + "_filterRow_" + _rowFilter).data('desc');
_html = '';
_html += '' + _desc + '';
_tableSection.find(".appliedFilters").append($(_html));
}
if (_colFilter != 0)
{
_filtered = true;
_desc = _tableSection.find("input[name='tableSection" + pTableSectionIndex + "_filterCol']#tableSection" + pTableSectionIndex + "_filterCol_" + _colFilter).data('desc');
_html = '';
_html += '' + _desc + '';
_tableSection.find(".appliedFilters").append($(_html));
}
if (!_filtered)
{
$(".appliedFilterWrapper").addClass("hide");
}
if (_tableSection.hasClass("kindergartenTimetable"))
{
updateKindergartenTimetable(_tableSection, _rowFilter, _colFilter);
}
}
function resetFilters()
{
$(".tableSection").each
(
function (pTableSectionIndex, pTableSectionElement)
{
$(pTableSectionElement).find(".toggleSelectionHolder").each
(
function (pIndex, pElement)
{
if ($(pElement).hasClass("filterCol"))
{
$(pElement).find("input[type='radio']#tableSection" + (pTableSectionIndex + 1) + "_filterCol_0").trigger("click");
}
else if ($(pElement).hasClass("filterRow"))
{
$(pElement).find("input[type='radio']#tableSection" + (pTableSectionIndex + 1) + "_filterRow_0").trigger("click");
}
}
);
}
);
}
function removeFilter(pTableSectionIndex, pType)
{
var _tableSection = $(".tableSection" + pTableSectionIndex);
var _table = _tableSection.find("table");
_tableSection.find("input[type='radio']#tableSection" + pTableSectionIndex + "_" + pType + "_0").trigger("click");
}
function updateKindergartenTimetable(pTableSection, pRowFilter, pColFilter)
{
if (pColFilter == 0)
{
pTableSection.find(".topRow").find(".bilingual").attr({"colspan": 4});
pTableSection.find(".topRow").find(".trilingual").attr({"colspan": 5});
pTableSection.find(".langRow").find(".bilingual").attr({"colspan": 4});
pTableSection.find(".langRow").find(".trilingual").attr({"colspan": 5});
}
else if (pColFilter == 1)
{
pTableSection.find(".topRow").find(".bilingual").attr({"colspan": 1});
pTableSection.find(".topRow").find(".trilingual").attr({"colspan": 2});
pTableSection.find(".langRow").find(".bilingual").attr({"colspan": 1});
pTableSection.find(".langRow").find(".trilingual").attr({"colspan": 2});
}
else
{
pTableSection.find(".topRow").find(".bilingual").attr({"colspan": 1});
pTableSection.find(".topRow").find(".trilingual").attr({"colspan": 1});
pTableSection.find(".langRow").find(".bilingual").attr({"colspan": 1});
pTableSection.find(".langRow").find(".trilingual").attr({"colspan": 1});
}
}