PluginProbe
Ever Compare – Products Compare Plugin for WooCommerce / 1.2.1
Ever Compare – Products Compare Plugin for WooCommerce v1.2.1
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
ever-compare / assets / js / admin.js

admin.js in Ever Compare – Products Compare Plugin for WooCommerce 1.2.1, at assets/js/admin.js

100 lines 4.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 ;(function($){
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 /**
31 * After Change
32 */
33 this.ConditionField( '.shop_btn_position select', '.depend_shop_btn_position_use_shortcode', 'use_shortcode' );
34 this.ConditionField( '.shop_btn_position select', '.depend_shop_btn_position_custom_hook', 'custom_position' );
35
36 this.ConditionField( '.product_btn_position select', '.depend_product_btn_position_use_shortcode', 'use_shortcode' );
37 this.ConditionField( '.product_btn_position select', '.depend_product_btn_position_custom_hook', 'custom_position' );
38
39 this.ConditionField( '.button_icon_type select', '.depend_button_icon_type_custom', 'custom' );
40 this.ConditionField( '.added_button_icon_type select', '.depend_added_button_icon_type_custom', 'custom' );
41
42 this.ConditionField( '.enable_shareable_link .checkbox', '.depend_enable_shareable_link', 'on', 'radio' );
43
44 this.ConditionField( '.button_style select', '.depend_button_custom_style', 'custom' );
45 this.ConditionField( '.table_style select', '.depend_table_custom_style', 'custom' );
46
47 },
48
49 /**
50 * [MenuActive] Active first menu item
51 */
52 MenuActive: function(){
53 if ( typeof evercompare.is_settings != "undefined" && evercompare.is_settings == 1 ){
54 $('.toplevel_page_evercompare .wp-first-item').addClass('current');
55 }
56 },
57
58 /**
59 * [ConditionField]
60 * @param {[String]} controller
61 * @param {[String]} field
62 * @param {[String]} condition_value
63 * @param {String} fieldtype
64 */
65 ConditionField: function( controller, field, condition_value, fieldtype = 'select' ){
66 $( controller ).on('change',function(){
67 var change_value = '';
68 if( fieldtype === 'radio' ){
69 if( $(this).is(":checked") ){
70 change_value = $(this).val();
71 }
72 }else{
73 change_value = $(this).val();
74 }
75 EverCompareAdmin.HideShowField( field, change_value, condition_value );
76 });
77
78 },
79
80 /**
81 * [HideShowField]
82 * @param {[String]} field
83 * @param {[String]} current_value
84 * @param {[String]} condition_value
85 */
86 HideShowField: function( field, current_value, condition_value ){
87 if( current_value === condition_value ){
88 $( field ).show();
89 }else{
90 $( field ).hide();
91 }
92 },
93
94 };
95
96 $( document ).ready( function() {
97 EverCompareAdmin.init();
98 });
99
100 })(jQuery);