PluginProbe
Ever Compare – Products Compare Plugin for WooCommerce / trunk
Ever Compare – Products Compare Plugin for WooCommerce vtrunk
1.3.7 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 trunk 1.0.0 1.0.1 1.0.2 All 31 releases
← All changes | assets/js/admin.js +103 -4 1.0.2 → trunk View file →
@@ -1,9 +1,108 @@
1 1 ;(function($){
2 2 "use strict";
3 +
4 + var EverCompareAdmin = {
5 +
6 + /**
7 + * [init]
8 + * @return @return {[void]} Initial Function
9 + */
10 + init: function(){
11 + this.MenuActive();
12 +
13 + /**
14 + * For save value
15 + */
16 + this.HideShowField( '.depend_shop_btn_position_use_shortcode', evercompare.option_data['shop_btn_position'], 'use_shortcode' );
17 + this.HideShowField( '.depend_shop_btn_position_custom_hook', evercompare.option_data['shop_btn_position'], 'custom_position' );
18 +
19 + this.HideShowField( '.depend_product_btn_position_use_shortcode', evercompare.option_data['product_btn_position'], 'use_shortcode' );
20 + this.HideShowField( '.depend_product_btn_position_custom_hook', evercompare.option_data['product_btn_position'], 'custom_position' );
21 +
22 + this.HideShowField( '.depend_button_icon_type_custom', evercompare.option_data['button_icon_type'], 'custom' );
23 + this.HideShowField( '.depend_added_button_icon_type_custom', evercompare.option_data['added_button_icon_type'], 'custom' );
24 +
25 + this.HideShowField( '.depend_enable_shareable_link', evercompare.option_data['enable_shareable_link'], 'on' );
26 +
27 + this.HideShowField( '.depend_button_custom_style', evercompare.option_data['button_style'], 'custom' );
28 + this.HideShowField( '.depend_table_custom_style', evercompare.option_data['table_style'], 'custom' );
29 +
30 + this.HideShowField( '.depend_remove_on_click', evercompare.option_data['remove_on_click'], 'on' );
31 + this.HideShowField( '.depend_enable_success_notification', evercompare.option_data['enable_success_notification'], 'on' );
32 + this.HideShowField( '.depend_notification_custom_style', evercompare.option_data['notification_style'], 'custom' );
33 +
34 + /**
35 + * After Change
36 + */
37 + this.ConditionField( '.shop_btn_position select', '.depend_shop_btn_position_use_shortcode', 'use_shortcode' );
38 + this.ConditionField( '.shop_btn_position select', '.depend_shop_btn_position_custom_hook', 'custom_position' );
39 +
40 + this.ConditionField( '.product_btn_position select', '.depend_product_btn_position_use_shortcode', 'use_shortcode' );
41 + this.ConditionField( '.product_btn_position select', '.depend_product_btn_position_custom_hook', 'custom_position' );
42 +
43 + this.ConditionField( '.button_icon_type select', '.depend_button_icon_type_custom', 'custom' );
44 + this.ConditionField( '.added_button_icon_type select', '.depend_added_button_icon_type_custom', 'custom' );
45 +
46 + this.ConditionField( '.enable_shareable_link .checkbox', '.depend_enable_shareable_link', 'on', 'radio' );
47 +
48 + this.ConditionField( '.button_style select', '.depend_button_custom_style', 'custom' );
49 + this.ConditionField( '.table_style select', '.depend_table_custom_style', 'custom' );
50 +
51 + this.ConditionField( '.remove_on_click .checkbox', '.depend_remove_on_click', 'on', 'radio' );
52 + this.ConditionField( '.enable_success_notification .checkbox', '.depend_enable_success_notification', 'on', 'radio' );
53 + this.ConditionField( '.notification_style select', '.depend_notification_custom_style', 'custom' );
54 +
55 + },
56 +
57 + /**
58 + * [MenuActive] Active first menu item
59 + */
60 + MenuActive: function(){
61 + if ( typeof evercompare.is_settings != "undefined" && evercompare.is_settings == 1 ){
62 + $('.toplevel_page_evercompare .wp-first-item').addClass('current');
63 + }
64 + },
65 +
66 + /**
67 + * [ConditionField]
68 + * @param {[String]} controller
69 + * @param {[String]} field
70 + * @param {[String]} condition_value
71 + * @param {String} fieldtype
72 + */
73 + ConditionField: function( controller, field, condition_value, fieldtype = 'select' ){
74 + $( controller ).on('change',function(){
75 + var change_value = '';
76 + if( fieldtype === 'radio' ){
77 + if( $(this).is(":checked") ){
78 + change_value = $(this).val();
79 + }
80 + }else{
81 + change_value = $(this).val();
82 + }
83 + EverCompareAdmin.HideShowField( field, change_value, condition_value );
84 + });
85 +
86 + },
87 +
88 + /**
89 + * [HideShowField]
90 + * @param {[String]} field
91 + * @param {[String]} current_value
92 + * @param {[String]} condition_value
93 + */
94 + HideShowField: function( field, current_value, condition_value ){
95 + if( current_value === condition_value ){
96 + $( field ).show();
97 + }else{
98 + $( field ).hide();
99 + }
100 + },
101 +
102 + };
3 103
4 - // Active settigns menu item
5 - if ( typeof evercompare.is_settings != "undefined" && evercompare.is_settings == 1 ){
6 - $('.toplevel_page_evercompare .wp-first-item').addClass('current');
7 - }
104 + $( document ).ready( function() {
105 + EverCompareAdmin.init();
106 + });
8 107
9 108 })(jQuery);