Skip to content

Commit

Permalink
Translation feature
Browse files Browse the repository at this point in the history
  • Loading branch information
RensTillmann committed May 7, 2019
1 parent 006ca97 commit a7d3104
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -320,74 +320,44 @@
}
}
}else{
//$amount = (Math.ceil($amount * 100) / 100).toFixed($decimals);
$amount = $amount.toFixed($decimals);
}

var $field = $target.parent().find('.super-shortcode-field');
$field.val($amount);
$updated_calculator_fields[$field.attr('name')] = $field;

if( (typeof $prev_amount === 'string' ) && ( $prev_amount == 'NaN' ) ) {
if( ((typeof $prev_amount === 'string' ) && ( $prev_amount == 'NaN' )) ||
((typeof $prev_amount === 'number' ) && ( $prev_amount == 'Infinity' )) ) {
return true;
}else{
if( (typeof $amount === 'string' ) && ( $amount == 'NaN' ) ) {
if( ((typeof $amount === 'string' ) && ( $amount == 'NaN' )) ||
((typeof $amount === 'number' ) && ( $amount == 'Infinity' )) ) {
return true;
}else{
if( typeof $jsformat !== 'undefined' ) {
// Just output date
if( typeof $jsformat !== 'undefined' ) {
// Just output date
$target.find('.super-calculator-amount').text($amount);
var $currency = $target.find('.super-calculator-currency').html();
var $format = $target.find('.super-calculator-format').html();
var $number = $target.find('.super-calculator-amount').html();
$field.attr('data-value', $currency+''+$number+''+$format);
}else{
// Now lets play the animation :)
if(!$target.hasClass('animating')){
$target.addClass('animating');
$({ Counter: parseFloat($prev_amount) }).animate({ Counter: parseFloat($amount) }, {
duration: 0,
easing: 'swing',
step: function ( now, fx ) {
var $regex2 = '\\d(?=(\\d{' + (3 || 3) + '})+' + ($decimals > 0 ? '\\D' : '$') + ')';
var $number = (this.Counter).toFixed($decimals);
var $numeric_number = $number;
var $number = ($decimal_separator ? $number.replace('.', $decimal_separator) : $number).replace(new RegExp($regex2, 'g'), '$&' + ($thousand_separator || ''));
if ($numeric_number >= 0) {
$target.find('.super-calculator-currency').find('.super-minus-value').remove();
$target.find('.super-calculator-amount').text($number);
}else{
if(!$target.find('.super-calculator-currency').find('.super-minus-value').length){
$target.find('.super-calculator-currency').prepend('<span class="super-minus-value">-</span>');
}
$target.find('.super-calculator-amount').text($number.replace('-',''));
}
},
complete: function() {
var $regex2 = '\\d(?=(\\d{' + (3 || 3) + '})+' + ($decimals > 0 ? '\\D' : '$') + ')';
var $number = (this.Counter).toFixed($decimals);
var $numeric_number = $number;
var $number = ($decimal_separator ? $number.replace('.', $decimal_separator) : $number).replace(new RegExp($regex2, 'g'), '$&' + ($thousand_separator || ''));
if ($numeric_number >= 0) {
$target.find('.super-calculator-currency').find('.super-minus-value').remove();
$target.find('.super-calculator-amount').text($number);
var $currency = $target.find('.super-calculator-currency').html();
var $format = $target.find('.super-calculator-format').html();
var $number = $target.find('.super-calculator-amount').html();
$field.attr('data-value', $currency+''+$number+''+$format);
}else{
if(!$target.find('.super-calculator-currency').find('.super-minus-value').length){
$target.find('.super-calculator-currency').prepend('<span class="super-minus-value">-</span>');
}
$target.find('.super-calculator-amount').text($number.replace('-',''));
var $currency = $target.find('.super-calculator-currency').html();
var $format = $target.find('.super-calculator-format').html();
var $number = $target.find('.super-calculator-amount').html();
$field.attr('data-value', $currency+''+$number+''+$format);
}
$target.removeClass('animating');
}
});
}else{
$amount = parseFloat($amount).toFixed($decimals);
if ($amount >= 0) {
$target.find('.super-calculator-currency').find('.super-minus-value').remove();
$target.find('.super-calculator-amount').text($amount);
var $currency = $target.find('.super-calculator-currency').html();
var $format = $target.find('.super-calculator-format').html();
$field.attr('data-value', $currency+''+$amount+''+$format);
}else{
if(!$target.find('.super-calculator-currency').find('.super-minus-value').length){
$target.find('.super-calculator-currency').prepend('<span class="super-minus-value">-</span>');
}
$target.find('.super-calculator-amount').text($amount.replace('-',''));
var $currency = $target.find('.super-calculator-currency').html();
var $format = $target.find('.super-calculator-format').html();
$field.attr('data-value', $currency+''+$amount+''+$format);
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/add-ons/super-forms-calculator/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
May 07, 2019 - Version 2.0.2
- Fix: Sometimes returning "NaN" as value

Apr 24, 2019 - Version 2.0.1
- Fix: Not working when using both regex and advanced tags like so: `{_option$;3}` or `{server_*;4}` or `{server_^;2}` etc.

Expand Down
4 changes: 2 additions & 2 deletions src/add-ons/super-forms-calculator/super-forms-calculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Plugin Name: Super Forms - Calculator
* Plugin URI: http://codecanyon.net/item/super-forms-drag-drop-form-builder/13979866
* Description: Adds an extra element that allows you to do calculations on any of your fields
* Version: 2.0.1
* Version: 2.0.2
* Author: feeling4design
* Author URI: http://codecanyon.net/user/feeling4design
*/
Expand All @@ -37,7 +37,7 @@ final class SUPER_Calculator {
*
* @since 1.0.0
*/
public $version = '2.0.1';
public $version = '2.0.2';


/**
Expand Down
29 changes: 23 additions & 6 deletions src/assets/js/backend/create-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@
shape: 'circle',
radius: 50,
nextButton : {text: "Start"},
description: '<h1>Hello! This is a short tutorial to get you up and running with Super Forms. Please click "Start" to begin the tutorial :)</h1><span class="super-tip">If you wish to skip the tutorial, you can skip it by clicking the close button</span><span class="super-tip">We strongly suggest you complete this step by step guide. It will help you get started nicely and quickly without any issues.</span><label class="tutorial-do-not-show-again"><input type="checkbox" name="tutorial_do_not_show_again" />Do not show me this tuturial again.</label>',
description: '<h1>PLEASE DO NOT SKIP THIS TUTORIAL...</h1><h1>Especially when you are new to Super Forms it is recommended to read through each step!</h1><span class="super-tip">We strongly suggest you complete this step by step guide. It will help you get started nicely and quickly without any issues.</span><span class="super-tip">If you wish to skip the tutorial, you can skip it by clicking the close button</span><label class="tutorial-do-not-show-again"><input type="checkbox" name="tutorial_do_not_show_again" />Do not show me this tuturial again.</label>',
},
{
onBeforeStart: function() {
Expand Down Expand Up @@ -994,7 +994,7 @@
selector: '.super-form-history .super-maximize-toggle',
event: 'click',
shape: 'circle',
description: '<h1>Maximizing all elements</h1><span class="super-tip">Whenever you working with large forms and used the minimize button, you can maximize all of your elements at once to quickly find the element that you need to edit.</span>',
description: '<h1>Maximizing all elements</h1><span class="super-tip">Whenever you are working with large forms and used the minimize button, you can maximize all of your elements at once to quickly find the element that you need to edit.</span>',
},
{
selector: '.super-element-actions .transfer',
Expand Down Expand Up @@ -1099,9 +1099,26 @@
selector: '.super-header .super-get-form-shortcodes',
description: '<h1>This is the [shortcode] of your form. You can display your form by copy pasting the shortcode to any of your posts/pages.</h1><span class="super-tip">You can add your shortcode in posts, pages and widgets (e.g: sidebars or in your footer). Anywhere within your site where your theme supports shortcodes you can basically display your form. In case you want to read more about how to build and publish your first form you can read the <a target="_blank" href="'+$git+'build">Documentation</a></span>',
},
{
selector: '.super-tab-translations',
event: 'click',
description: '<h1>Build-in Translation feature!</h1><span class="super-tip">With the build in translation system you can easily translate all elements and all form settings to the configured languages.</span>',
},
{
selector: '.super-default-language',
description: '<h1>Set a default language for your form</h1><span class="super-tip">Whenever you are going to have multiple languages you will want to define a default language for your form, you can do this here</span>'
},
{
selector: '.super-create-translation',
description: '<h1>Adding a new translation</h1><span class="super-tip">To add a new translation (language) for your form, you can click on this button</span>'
},
{
selector: '.super-i18n-switch',
description: '<h1>Language switcher</h1><span class="super-tip">If you don\'t want to use shortcodes to explicit define the form language you can also allow your users to choose the desired language from a dropdown. When this option is enabled it will add a so called "Language Switcher" at the top of your form.</span>'
},
{
selector: '.super-actions .save',
description: '<h1>You can save your form simply by clicking the "Save" button</h1>',
description: '<h1>You can save your form simply by clicking the "Save" button</h1><span class="super-tip">Every time you save your form an automatic backup of your form will be stored, this way you can always revert back to a previous version in case you made a mistake.</span>',
},
{
selector: '.super-actions .clear',
Expand All @@ -1112,7 +1129,7 @@
onBeforeStart: function() {
$('.super-actions .delete').css( 'pointer-events', 'none' );
},
description: '<h1>Here you can delete your form</h1><span class="super-tip">This will delete the form itself allong with it\'s Elements, Settings and all it\'s backups. It will not delete the associated Contact Entries that where created by the form.</span>',
description: '<h1>Here you can delete your form</h1><span class="super-tip">This will delete the form itself allong with it\'s Elements, Settings and all it\'s backups. It will not delete the associated Contact Entries that were created by the form.</span>',
},
{
onBeforeStart: function() {
Expand All @@ -1124,11 +1141,11 @@
},
{
selector: '.super-actions > label:last',
description: '<h1>(For Developers Only) Enable this whenever you require to be able to save a form that has duplicate field names</h1><span class="super-tip">Whenever you are a developer and require the need to save a form that consists of duplicate field names, then you have to enable this setting. By default Super Forms prevents saving a form that contains duplicate field names.</span>',
description: '<h1>(For Developers Only) Enable this whenever you require to save a form with duplicate field names</h1><span class="super-tip">Whenever you are a developer and require the need to save a form that consists of duplicate field names, then you have to enable this setting. By default Super Forms prevents saving a form that contains duplicate field names.</span>',
},
{
selector: '.wp-submenu a[href*="page=super_marketplace"]',
description: '<h1>You finished the tutorial! Now you know how to navigate around Super Forms page and create awesome forms with it.<br /><br />Please check out the Marketplace with awesome one click install forms that can get you up and running in no time!</h1><span class="super-tip">We hope you will enjoy the plugin, if you have future questions do not hesitate to contact support!</span><span class="super-tip">Don\'t forget to checkout the <a target="_blank" href="'+$git+'">Documentation</a> whenever you need more information about the plugin and all of it\'s features :)</i></span><span class="super-tip">Want to do more? Check out these awesome <a target="_blank" href="'+$git+'add-ons">Add-ons</a> for Super Forms!</span>',
description: '<h1>You finished the tutorial! Now you know how to navigate around in Super Forms and create awesome forms with it.<br /><br />Please check out the Marketplace with awesome one click installable forms that can get you up and running in no time!</h1><span class="super-tip">We hope you will enjoy the plugin, if you have future questions do not hesitate to contact support!</span><span class="super-tip">Don\'t forget to checkout the <a target="_blank" href="'+$git+'">Documentation</a> whenever you need more information about the plugin and all of it\'s features :)</i></span><span class="super-tip">Want to do more? Check out these awesome <a target="_blank" href="'+$git+'add-ons">Add-ons</a> for Super Forms!</span>',
nextButton : {
text: "Finish"
},
Expand Down
8 changes: 7 additions & 1 deletion src/assets/js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,7 @@ function SUPERreCaptcha(){
$i++;
}
for ($i = 0; $i < $array.length; $i++) {
$element = undefined; // @important!
$name = $array[$i];
if($name=='dynamic_column_counter'){
if($target!==null){
Expand Down Expand Up @@ -1265,10 +1266,15 @@ function SUPERreCaptcha(){
if($value_type=='int'){
$sum += parseFloat($new_value);
}else{
$sum += ($new_value);
if($sum===''){
$sum += $new_value;
}else{
$sum += ','+$new_value;
}
}
}
}

$value = $sum;
}
// @since 1.7.0 - check for radio tags because it now can contain advanced tags like {field;2} etc.
Expand Down
4 changes: 4 additions & 0 deletions src/docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### May 07, 2019 - Version 4.6.2
- Added: Translation feature (allows you to translate your form into multiple languages, this also includes translating specific form settings)
*when in translation mode, you won't be able to delete and change the layout of the form, just the strings of each element and the form settings*

### Apr 24, 2019 - Version 4.6.1
- Added: Compatibility for HTML elements to handle {tags} with regexes `*` (contains), `$` (ends with) and `^` (starts with)
- Fix: HTML element in back-end not wrapping words
Expand Down
2 changes: 1 addition & 1 deletion src/includes/class-common.php
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ public static function decode_email_header( $value ) {
* @since 1.0.6
*/
public static function email_tags( $value=null, $data=null, $settings=null, $user=null, $skip=true ) {
if( (empty($value)) && ($skip==true) ) return '';
if( ($value==='') && ($skip==true) ) return '';

// // Check if contains advanced tags e.g {field;2}
// // If so then we know we want to return form data because this is only used on dropdowns, checkboxes, radio buttons
Expand Down
2 changes: 1 addition & 1 deletion src/includes/class-shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -2242,7 +2242,7 @@ public static function text( $tag, $atts, $inner, $shortcodes=null, $settings=nu
}

$result .= ' name="' . $atts['name'] . '"';
if( !empty($atts['value']) ) {
if( $atts['value']!=='' ) {
$result .= ' value="' . $atts['value'] . '"';
}

Expand Down
4 changes: 2 additions & 2 deletions src/super-forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* Plugin Name: Super Forms - Drag & Drop Form Builder
* Plugin URI: http://codecanyon.net/user/feeling4design
* Description: Build forms anywhere on your website with ease.
* Version: 4.6.1
* Version: 4.6.2
* Author: feeling4design
* Author URI: http://codecanyon.net/user/feeling4design
* Text Domain: super-forms
Expand All @@ -41,7 +41,7 @@ final class SUPER_Forms {
*
* @since 1.0.0
*/
public $version = '4.6.1';
public $version = '4.6.2';
public $slug = 'super-forms';

/**
Expand Down

0 comments on commit a7d3104

Please sign in to comment.