Skip to content

Commit d3390d7

Browse files
committed
Add/edit package unlim patch;
1 parent 59467f6 commit d3390d7

File tree

2 files changed

+34
-6
lines changed

2 files changed

+34
-6
lines changed

web/js/pages/add.package.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@ App.Actions.PACKAGE.disable_unlimited = function(elm, source_elm) {
1111
if ($(elm).data('prev_value') && $(elm).data('prev_value').trim() != '') {
1212
var prev_value = $(elm).data('prev_value').trim();
1313
$(elm).val(prev_value);
14+
if (App.Helpers.isUnlimitedValue(prev_value)) {
15+
$(elm).val('0');
16+
}
1417
}
1518
else {
16-
$(elm).val('0');
19+
if (App.Helpers.isUnlimitedValue($(elm).val())) {
20+
$(elm).val('0');
21+
}
1722
}
1823
$(elm).attr('disabled', false);
1924
$(source_elm).css('opacity', '0.5');
@@ -38,16 +43,25 @@ App.Listeners.PACKAGE.checkbox_unlimited_feature = function() {
3843
App.Listeners.PACKAGE.init = function() {
3944
$('.unlim-trigger').each(function(i, elm) {
4045
var ref = $(elm).prev('.vst-input');
41-
if ($(ref).val().trim() == App.Constants.UNLIM_VALUE || $(ref).val().trim() == App.Constants.UNLIM_TRANSLATED_VALUE) {
42-
$(ref).val('0');
46+
if (App.Helpers.isUnlimitedValue($(ref).val())) {
4347
App.Actions.PACKAGE.enable_unlimited(ref, elm);
4448
}
4549
else {
50+
$(ref).data('prev_value', $(ref).val());
4651
App.Actions.PACKAGE.disable_unlimited(ref, elm);
4752
}
4853
});
4954
}
5055

56+
App.Helpers.isUnlimitedValue = function(value) {
57+
var value = value.trim();
58+
if (value == App.Constants.UNLIM_VALUE || value == App.Constants.UNLIM_TRANSLATED_VALUE) {
59+
return true;
60+
}
61+
62+
return false;
63+
}
64+
5165
//
5266
// Page entry point
5367
// Trigger listeners

web/js/pages/edit.package.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@ App.Actions.PACKAGE.disable_unlimited = function(elm, source_elm) {
1111
if ($(elm).data('prev_value') && $(elm).data('prev_value').trim() != '') {
1212
var prev_value = $(elm).data('prev_value').trim();
1313
$(elm).val(prev_value);
14+
if (App.Helpers.isUnlimitedValue(prev_value)) {
15+
$(elm).val('0');
16+
}
1417
}
1518
else {
16-
$(elm).val('0');
19+
if (App.Helpers.isUnlimitedValue($(elm).val())) {
20+
$(elm).val('0');
21+
}
1722
}
1823
$(elm).attr('disabled', false);
1924
$(source_elm).css('opacity', '0.5');
@@ -38,16 +43,25 @@ App.Listeners.PACKAGE.checkbox_unlimited_feature = function() {
3843
App.Listeners.PACKAGE.init = function() {
3944
$('.unlim-trigger').each(function(i, elm) {
4045
var ref = $(elm).prev('.vst-input');
41-
if ($(ref).val().trim() == App.Constants.UNLIM_VALUE || $(ref).val().trim() == App.Constants.UNLIM_TRANSLATED_VALUE) {
42-
$(ref).val('0');
46+
if (App.Helpers.isUnlimitedValue($(ref).val())) {
4347
App.Actions.PACKAGE.enable_unlimited(ref, elm);
4448
}
4549
else {
50+
$(ref).data('prev_value', $(ref).val());
4651
App.Actions.PACKAGE.disable_unlimited(ref, elm);
4752
}
4853
});
4954
}
5055

56+
App.Helpers.isUnlimitedValue = function(value) {
57+
var value = value.trim();
58+
if (value == App.Constants.UNLIM_VALUE || value == App.Constants.UNLIM_TRANSLATED_VALUE) {
59+
return true;
60+
}
61+
62+
return false;
63+
}
64+
5165
//
5266
// Page entry point
5367
// Trigger listeners

0 commit comments

Comments
 (0)