-
-
Save denisz/a5d764d22969571d2dd67ab10cbab261 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('.unreal-form-call').on('click', function () { | |
var $this = $(this), | |
period = $this.data('period') ? $this.data('period') : null, | |
hiddenTypes = ['Unreal','Epic'], | |
type = $this.data('type'); | |
//console.log("1122312"); | |
// соответствие пак->период: Селект периодов представляет собой значения одномерного массива, | |
// где 0: 3 месяца, 1 - 6 месяцев и т.д. | |
// Когда мы отправляем значение пака, то в periods передаем индекс массива, который соответствует данному периоду | |
// Например: передаем 1 - выбираем период 6 месяцев | |
promise.then(function(content){ | |
var $form = content.find('#orderUnrealForm'), | |
$selectPackages = $form.find('#packages'), | |
$selectPeriods = $form.find('#period'), | |
$periodsOpt = $form.find('#period option'), | |
periods = { | |
Basic : 0, | |
Standart : 1, | |
Optimal : 1, | |
Expert : 1, | |
Unreal : 2, | |
Epic : 2 | |
}, | |
periodPack = periods[type]; | |
$selectPackages.val(type); | |
// скрываем в паках Unreal и Epic периоды только 3 и 6 месяцев | |
if (hiddenTypes.includes(type)) { | |
$periodsOpt.each(function(index) { | |
if (index < 2) $(this).hide(); | |
}); //$("#edit-field-service-sub-cat-value option[value=" + title + "]").hide(); | |
} | |
// если передан период, то выбираем его, иначе первый доступный | |
if (period !== null) { | |
$selectPeriods.val(period); | |
} else { | |
$selectPeriods.val(periodPack); | |
} | |
//console.log(periodPack); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment