Add/edit package unlim patch;

This commit is contained in:
Malishev Dmitry 2015-04-16 14:30:45 -04:00
commit d3390d7ad0
2 changed files with 34 additions and 6 deletions

View file

@ -11,10 +11,15 @@ App.Actions.PACKAGE.disable_unlimited = function(elm, source_elm) {
if ($(elm).data('prev_value') && $(elm).data('prev_value').trim() != '') { if ($(elm).data('prev_value') && $(elm).data('prev_value').trim() != '') {
var prev_value = $(elm).data('prev_value').trim(); var prev_value = $(elm).data('prev_value').trim();
$(elm).val(prev_value); $(elm).val(prev_value);
if (App.Helpers.isUnlimitedValue(prev_value)) {
$(elm).val('0');
}
} }
else { else {
if (App.Helpers.isUnlimitedValue($(elm).val())) {
$(elm).val('0'); $(elm).val('0');
} }
}
$(elm).attr('disabled', false); $(elm).attr('disabled', false);
$(source_elm).css('opacity', '0.5'); $(source_elm).css('opacity', '0.5');
} }
@ -38,16 +43,25 @@ App.Listeners.PACKAGE.checkbox_unlimited_feature = function() {
App.Listeners.PACKAGE.init = function() { App.Listeners.PACKAGE.init = function() {
$('.unlim-trigger').each(function(i, elm) { $('.unlim-trigger').each(function(i, elm) {
var ref = $(elm).prev('.vst-input'); var ref = $(elm).prev('.vst-input');
if ($(ref).val().trim() == App.Constants.UNLIM_VALUE || $(ref).val().trim() == App.Constants.UNLIM_TRANSLATED_VALUE) { if (App.Helpers.isUnlimitedValue($(ref).val())) {
$(ref).val('0');
App.Actions.PACKAGE.enable_unlimited(ref, elm); App.Actions.PACKAGE.enable_unlimited(ref, elm);
} }
else { else {
$(ref).data('prev_value', $(ref).val());
App.Actions.PACKAGE.disable_unlimited(ref, elm); App.Actions.PACKAGE.disable_unlimited(ref, elm);
} }
}); });
} }
App.Helpers.isUnlimitedValue = function(value) {
var value = value.trim();
if (value == App.Constants.UNLIM_VALUE || value == App.Constants.UNLIM_TRANSLATED_VALUE) {
return true;
}
return false;
}
// //
// Page entry point // Page entry point
// Trigger listeners // Trigger listeners

View file

@ -11,10 +11,15 @@ App.Actions.PACKAGE.disable_unlimited = function(elm, source_elm) {
if ($(elm).data('prev_value') && $(elm).data('prev_value').trim() != '') { if ($(elm).data('prev_value') && $(elm).data('prev_value').trim() != '') {
var prev_value = $(elm).data('prev_value').trim(); var prev_value = $(elm).data('prev_value').trim();
$(elm).val(prev_value); $(elm).val(prev_value);
if (App.Helpers.isUnlimitedValue(prev_value)) {
$(elm).val('0');
}
} }
else { else {
if (App.Helpers.isUnlimitedValue($(elm).val())) {
$(elm).val('0'); $(elm).val('0');
} }
}
$(elm).attr('disabled', false); $(elm).attr('disabled', false);
$(source_elm).css('opacity', '0.5'); $(source_elm).css('opacity', '0.5');
} }
@ -38,16 +43,25 @@ App.Listeners.PACKAGE.checkbox_unlimited_feature = function() {
App.Listeners.PACKAGE.init = function() { App.Listeners.PACKAGE.init = function() {
$('.unlim-trigger').each(function(i, elm) { $('.unlim-trigger').each(function(i, elm) {
var ref = $(elm).prev('.vst-input'); var ref = $(elm).prev('.vst-input');
if ($(ref).val().trim() == App.Constants.UNLIM_VALUE || $(ref).val().trim() == App.Constants.UNLIM_TRANSLATED_VALUE) { if (App.Helpers.isUnlimitedValue($(ref).val())) {
$(ref).val('0');
App.Actions.PACKAGE.enable_unlimited(ref, elm); App.Actions.PACKAGE.enable_unlimited(ref, elm);
} }
else { else {
$(ref).data('prev_value', $(ref).val());
App.Actions.PACKAGE.disable_unlimited(ref, elm); App.Actions.PACKAGE.disable_unlimited(ref, elm);
} }
}); });
} }
App.Helpers.isUnlimitedValue = function(value) {
var value = value.trim();
if (value == App.Constants.UNLIM_VALUE || value == App.Constants.UNLIM_TRANSLATED_VALUE) {
return true;
}
return false;
}
// //
// Page entry point // Page entry point
// Trigger listeners // Trigger listeners