PluginProbe
GetResponse Forms by Optin Cat / 1.8.0
GetResponse Forms by Optin Cat v1.8.0
1.3.4 1.3.5 1.3.6 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 1.8.0 1.8.1 2.0.0 All 36 releases
getresponse / assets / admin / fca-eoi-rules.js

fca-eoi-rules.js in GetResponse Forms by Optin Cat 1.8.0, at assets/admin/fca-eoi-rules.js

147 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /* jshint asi: true */
2
3 jQuery( document ).ready( function( $ ) {
4
5 $('#fca_eoi_add_rule').click(function(e){
6 e.preventDefault()
7 jQuery('#fca_eoi_primary_rules_table').append( ruleTableHtml.rowNew )
8
9 add_condition_select_handlers()
10 set_available_conditions()
11 add_delete_handlers()
12 $(this).blur()
13 })
14
15 function load_rules() {
16 var optional_rules = []
17 //unset the conditions that always show
18 if ( typeof rules === 'object' ) {
19 //backward compatibility from 1.7.x & earlier to 1.8
20 for ( el in rules ) {
21 var obj = rules[el]
22 if ( obj.parameter !== 'devices' && obj.parameter !== 'show_every' && obj.parameter !== 'live' ) {
23 optional_rules.push( {
24 'parameter': obj.parameter,
25 'value': obj.value
26 } )
27 }
28 }
29 //set devices
30 if ( distro === 'premium' ) {
31 $('[name="fca_eoi[publish_lightbox][devices]"]').val( 'all' )
32 } else {
33 $('[name="fca_eoi[publish_lightbox][devices]"]').val( 'desktop' )
34 }
35
36 if ( $('[name="fca_eoi[publish_lightbox][show_every]"]').val() === 'never' ) {
37 $('[name="fca_eoi[publish_lightbox][live]"]').prop( 'checked', false )
38 } else {
39 $('[name="fca_eoi[publish_lightbox][live]"]').prop( 'checked', true )
40 }
41
42
43
44 } else {
45 optional_rules = rules.filter(function( el ){
46 return el.parameter !== 'devices' && el.parameter !== 'show_every' && el.parameter !== 'live'
47 })
48 }
49 $.each( optional_rules, function ( key, obj ) {
50 $('#fca_eoi_add_rule').click()
51 $('.fca_eoi_condition_select').last().val( obj.parameter ).change()
52 if ( obj.parameter === 'exit_intervention' ) {
53 $('.fca_eoi_condition_select').last().closest('th').next().find('input, select').prop( 'checked', 'checked' ).change()
54 } else {
55 $('.fca_eoi_condition_select').last().closest('th').next().find('input, select').val( obj.value ).change()
56 }
57 })
58
59 }
60 console.log ( rules )
61 load_rules()
62
63 })
64
65 function add_delete_handlers() {
66 var $ = jQuery
67
68 $('.fca_eoi_delete_condition').unbind('click')
69
70 $('.fca_eoi_delete_condition').click(function(){
71 $(this).closest('tr').remove()
72 set_available_conditions()
73 })
74
75 }
76
77 function set_available_conditions() {
78 var $ = jQuery
79
80 var activeConditions = []
81 $('.fca_eoi_condition_select').each(function(){
82 activeConditions.push( $(this).val() )
83 })
84 $('.fca_eoi_condition_select').children().show()
85
86 $.each( activeConditions, function ( index, conditionStr ) {
87 $('.fca_eoi_condition_select').children('[value="' + conditionStr + '"]').hide()
88 })
89 }
90
91 function add_condition_select_handlers() {
92
93 var $ = jQuery
94
95 $('.fca_eoi_condition_select').unbind('change')
96
97 $('.fca_eoi_condition_select').change(function(){
98
99 $targetTd = $(this).closest('th').next()
100 var newHtml = false
101
102 set_available_conditions()
103
104 $(this).siblings('.fca_eoi_at_least').hide()
105
106 switch ( $(this).val() ) {
107
108 case "scrolled_percent":
109 newHtml = ruleTableHtml.dataScroll
110 $(this).siblings('.fca_eoi_at_least').show()
111 break
112
113 case "pageviews":
114 newHtml = ruleTableHtml.dataPageviews
115 $(this).siblings('.fca_eoi_at_least').show()
116 break
117
118 case "time_on_page":
119 newHtml = ruleTableHtml.dataTime
120 $(this).siblings('.fca_eoi_at_least').show()
121 break
122
123 case "include":
124 newHtml = ruleTableHtml.dataInclude
125 break
126
127 case "exclude":
128 newHtml = ruleTableHtml.dataExclude
129 break
130
131 case "exit_intervention":
132 newHtml = ruleTableHtml.dataExit
133 break
134
135 default:
136
137 }
138
139 $targetTd.html( newHtml )
140 //show delete icon
141 if ( newHtml ) {
142 $targetTd.next().show()
143 $targetTd.find('.select2').select2()
144 }
145 })
146
147 }