PluginProbe
Customify / 2.5.8
Customify v2.5.8
2.10.9 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.7.1 1.3.0 1.3.1 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.6.0 1.6.0.1 1.6.5 1.7.0 1.7.1 All 77 releases
customify / js / admin.js

admin.js in Customify 2.5.8, at js/admin.js

86 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function ($) {
2 'use strict'
3 $(function () {
4
5 /**
6 * Checkbox value switcher
7 * Any checkbox should switch between value 1 and 0
8 * Also test if the checkbox needs to hide or show something under it.
9 */
10 // $('#customify_form input:checkbox').each(function(i,e){
11 // check_checkbox_checked(e);
12 // $(e).check_for_extended_options();
13 // });
14 // $('#customify_form').on('click', 'input:checkbox', function(){
15 // check_checkbox_checked(this);
16 // $(this).check_for_extended_options();
17 // });
18 /** End Checkbox value switcher **/
19
20 /* Ensure groups visibility */
21 $('.switch input[type=checkbox], .select select').each(function () {
22
23 if ($(this).data('show_group')) {
24
25 var show = false
26 if ($(this).attr('checked')) {
27 show = true
28 } else if (typeof $(this).data('display_option') !== 'undefined' && $(this).data('display_option') === $(this).val()) {
29 show = true
30 }
31
32 toggleGroup($(this).data('show_group'), show)
33 }
34 })
35
36 $('.switch, .select ').on('change', 'input[type=checkbox], select', function () {
37 if ($(this).data('show_group')) {
38 var show = false
39 if ($(this).attr('checked')) {
40 show = true
41 } else if (typeof $(this).data('display_option') !== 'undefined' && $(this).data('display_option') === $(this).val()) {
42 show = true
43 }
44 toggleGroup($(this).data('show_group'), show)
45 }
46 })
47 })
48
49 var toggleGroup = function (name, show) {
50 var $group = $('#' + name)
51
52 if (show) {
53 $group.show()
54 } else {
55 $group.hide()
56 }
57 }
58
59 /*
60 * Useful functions
61 */
62 function check_checkbox_checked (input) { // yes the name is an ironic
63 if ($(input).attr('checked') === 'checked') {
64 $(input).siblings('input:hidden').val('on')
65 } else {
66 $(input).siblings('input:hidden').val('off')
67 }
68 } /* End check_checkbox_checked() */
69
70 $.fn.check_for_extended_options = function () {
71 var extended_options = $(this).siblings('fieldset.group')
72 if ($(this).data('show-next')) {
73 if (extended_options.data('extended') === true) {
74 extended_options
75 .data('extended', false)
76 .css('height', '0')
77 } else if ((typeof extended_options.data('extended') === 'undefined' && $(this).attr('checked') === 'checked') || extended_options.data('extended') === false) {
78 extended_options
79 .data('extended', true)
80 .css('height', 'auto')
81 }
82 }
83 }
84
85 }(jQuery))
86