From a7d310401b365275a7514eacf157cb08ff1296d1 Mon Sep 17 00:00:00 2001 From: Rens Date: Tue, 7 May 2019 21:46:19 +0200 Subject: [PATCH] Translation feature --- .../assets/js/frontend/calculator.min.js | 74 ++++++------------- .../super-forms-calculator/changelog.txt | 3 + .../super-forms-calculator.php | 4 +- src/assets/js/backend/create-form.js | 29 ++++++-- src/assets/js/common.js | 8 +- src/docs/changelog.md | 4 + src/includes/class-common.php | 2 +- src/includes/class-shortcodes.php | 2 +- src/super-forms.php | 4 +- 9 files changed, 65 insertions(+), 65 deletions(-) diff --git a/src/add-ons/super-forms-calculator/assets/js/frontend/calculator.min.js b/src/add-ons/super-forms-calculator/assets/js/frontend/calculator.min.js index 010f5bfa..401d553b 100644 --- a/src/add-ons/super-forms-calculator/assets/js/frontend/calculator.min.js +++ b/src/add-ons/super-forms-calculator/assets/js/frontend/calculator.min.js @@ -320,7 +320,6 @@ } } }else{ - //$amount = (Math.ceil($amount * 100) / 100).toFixed($decimals); $amount = $amount.toFixed($decimals); } @@ -328,66 +327,37 @@ $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('-'); - } - $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('-'); - } - $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('-'); + } + $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); } } } diff --git a/src/add-ons/super-forms-calculator/changelog.txt b/src/add-ons/super-forms-calculator/changelog.txt index 2b925d51..99105e89 100644 --- a/src/add-ons/super-forms-calculator/changelog.txt +++ b/src/add-ons/super-forms-calculator/changelog.txt @@ -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. diff --git a/src/add-ons/super-forms-calculator/super-forms-calculator.php b/src/add-ons/super-forms-calculator/super-forms-calculator.php index 2adb55fc..f9d55999 100644 --- a/src/add-ons/super-forms-calculator/super-forms-calculator.php +++ b/src/add-ons/super-forms-calculator/super-forms-calculator.php @@ -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 */ @@ -37,7 +37,7 @@ final class SUPER_Calculator { * * @since 1.0.0 */ - public $version = '2.0.1'; + public $version = '2.0.2'; /** diff --git a/src/assets/js/backend/create-form.js b/src/assets/js/backend/create-form.js index 61590bf2..ee1b7933 100644 --- a/src/assets/js/backend/create-form.js +++ b/src/assets/js/backend/create-form.js @@ -766,7 +766,7 @@ shape: 'circle', radius: 50, nextButton : {text: "Start"}, - description: '

Hello! This is a short tutorial to get you up and running with Super Forms. Please click "Start" to begin the tutorial :)

If you wish to skip the tutorial, you can skip it by clicking the close buttonWe strongly suggest you complete this step by step guide. It will help you get started nicely and quickly without any issues.', + description: '

PLEASE DO NOT SKIP THIS TUTORIAL...

Especially when you are new to Super Forms it is recommended to read through each step!

We strongly suggest you complete this step by step guide. It will help you get started nicely and quickly without any issues.If you wish to skip the tutorial, you can skip it by clicking the close button', }, { onBeforeStart: function() { @@ -994,7 +994,7 @@ selector: '.super-form-history .super-maximize-toggle', event: 'click', shape: 'circle', - description: '

Maximizing all elements

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.', + description: '

Maximizing all elements

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.', }, { selector: '.super-element-actions .transfer', @@ -1099,9 +1099,26 @@ selector: '.super-header .super-get-form-shortcodes', description: '

This is the [shortcode] of your form. You can display your form by copy pasting the shortcode to any of your posts/pages.

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 Documentation', }, + { + selector: '.super-tab-translations', + event: 'click', + description: '

Build-in Translation feature!

With the build in translation system you can easily translate all elements and all form settings to the configured languages.', + }, + { + selector: '.super-default-language', + description: '

Set a default language for your form

Whenever you are going to have multiple languages you will want to define a default language for your form, you can do this here' + }, + { + selector: '.super-create-translation', + description: '

Adding a new translation

To add a new translation (language) for your form, you can click on this button' + }, + { + selector: '.super-i18n-switch', + description: '

Language switcher

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.' + }, { selector: '.super-actions .save', - description: '

You can save your form simply by clicking the "Save" button

', + description: '

You can save your form simply by clicking the "Save" button

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.', }, { selector: '.super-actions .clear', @@ -1112,7 +1129,7 @@ onBeforeStart: function() { $('.super-actions .delete').css( 'pointer-events', 'none' ); }, - description: '

Here you can delete your form

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.', + description: '

Here you can delete your form

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.', }, { onBeforeStart: function() { @@ -1124,11 +1141,11 @@ }, { selector: '.super-actions > label:last', - description: '

(For Developers Only) Enable this whenever you require to be able to save a form that has duplicate field names

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.', + description: '

(For Developers Only) Enable this whenever you require to save a form with duplicate field names

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.', }, { selector: '.wp-submenu a[href*="page=super_marketplace"]', - description: '

You finished the tutorial! Now you know how to navigate around Super Forms page and create awesome forms with it.

Please check out the Marketplace with awesome one click install forms that can get you up and running in no time!

We hope you will enjoy the plugin, if you have future questions do not hesitate to contact support!Don\'t forget to checkout the Documentation whenever you need more information about the plugin and all of it\'s features :)Want to do more? Check out these awesome Add-ons for Super Forms!', + description: '

You finished the tutorial! Now you know how to navigate around in Super Forms and create awesome forms with it.

Please check out the Marketplace with awesome one click installable forms that can get you up and running in no time!

We hope you will enjoy the plugin, if you have future questions do not hesitate to contact support!Don\'t forget to checkout the Documentation whenever you need more information about the plugin and all of it\'s features :)Want to do more? Check out these awesome Add-ons for Super Forms!', nextButton : { text: "Finish" }, diff --git a/src/assets/js/common.js b/src/assets/js/common.js index 25c2f81c..fcef7ff9 100644 --- a/src/assets/js/common.js +++ b/src/assets/js/common.js @@ -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){ @@ -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. diff --git a/src/docs/changelog.md b/src/docs/changelog.md index 34b7e1d0..4c416afd 100644 --- a/src/docs/changelog.md +++ b/src/docs/changelog.md @@ -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 diff --git a/src/includes/class-common.php b/src/includes/class-common.php index 86f607b9..2cd582ab 100644 --- a/src/includes/class-common.php +++ b/src/includes/class-common.php @@ -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 diff --git a/src/includes/class-shortcodes.php b/src/includes/class-shortcodes.php index 0e6758f5..1e42b6bd 100644 --- a/src/includes/class-shortcodes.php +++ b/src/includes/class-shortcodes.php @@ -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'] . '"'; } diff --git a/src/super-forms.php b/src/super-forms.php index c4548a3f..c945f6f8 100644 --- a/src/super-forms.php +++ b/src/super-forms.php @@ -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 @@ -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'; /**