1(function($) { 2$(document).ready(function() { 3 4 function ccf_set_sc_res() { 5 var screenWidth = window.screen.width, 6 screenHeight = window.screen.height; 7 8 var sc_res = screenWidth + 'X' + screenHeight; 9 $('.ccf_sc_res').val(sc_res); 10 } 11 ccf_set_sc_res(); 12 13 function check_pro_version($elem) { 14 15 return true; 16 17 $elem_1 = $elem.find('.powered_by'); 18 $elem_2 = $elem.find('.powered_by a'); 19 20 var creative_font_size_1 = parseInt($elem_1.css('font-size')); 21 var creative_top_1 = parseInt($elem_1.css('top')); 22 var creative_left_1 = parseInt($elem_1.css('left')); 23 var creative_bottom_1 = parseInt($elem_1.css('bottom')); 24 var creative_right_1 = parseInt($elem_1.css('right')); 25 var creative_text_indent_1 = parseInt($elem_1.css('text-indent')); 26 var creative_margin_top_1 = parseInt($elem_1.css('margin-top')); 27 var creative_margin_bottom_1 = parseInt($elem_1.css('margin-bottom')); 28 var creative_margin_left_1 = parseInt($elem_1.css('margin-left')); 29 var creative_margin_right_1 = parseInt($elem_1.css('margin-right')); 30 var creative_display_1 = $elem_1.css('display'); 31 var creative_position_1 = $elem_1.css('position'); 32 var creative_width_1 = parseInt($elem_1.css('width')); 33 var creative_height_1 = parseInt($elem_1.css('height')); 34 var creative_visibility_1 = $elem_1.css('visibility'); 35 var creative_overflow_1 = $elem_1.css('overflow'); 36 var creative_zindex_1 = parseInt($elem_1.css('z-index')); 37 var creative_font_size_2 = parseInt($elem_2.css('font-size')); 38 var creative_top_2 = parseInt($elem_2.css('top')); 39 var creative_left_2 = parseInt($elem_2.css('left')); 40 var creative_bottom_2 = parseInt($elem_2.css('bottom')); 41 var creative_right_2 = parseInt($elem_2.css('right')); 42 var creative_text_indent_2 = parseInt($elem_2.css('text-indent')); 43 var creative_margin_top_2 = parseInt($elem_2.css('margin-top')); 44 var creative_margin_right_2 = parseInt($elem_2.css('margin-right')); 45 var creative_margin_bottom_2 = parseInt($elem_2.css('margin-bottom')); 46 var creative_margin_left_2 = parseInt($elem_2.css('margin-left')); 47 var creative_display_2 = $elem_2.css('display'); 48 var creative_position_2 = $elem_2.css('position'); 49 var creative_width_2 = parseInt($elem_2.css('width')); 50 var creative_height_2 = parseInt($elem_2.css('height')); 51 var creative_visibility_2 = $elem_2.css('visibility'); 52 var creative_overflow_2 = $elem_2.css('overflow'); 53 var creative_zindex_2 = parseInt($elem_2.css('z-index')); 54 55 var txt1 = $.trim($elem_1.html().replace(/<[^>]+>.*?<\/[^>]+>/gi, '')); 56 var txt2 = $.trim($elem_2.html().replace(/<[^>]+>.*?<\/[^>]+>/gi, '')); 57 var txt1_l = parseInt(txt1.length); 58 var txt2_l = parseInt(txt2.length); 59 60 var a_href = $elem_2.attr("href").replace('http://',''); 61 a_href = a_href.replace('www.',''); 62 a_href = $.trim(a_href.replace('www','')); 63 a_href_l = parseInt(a_href.length); 64 65 if( 66 creative_font_size_1 == '12' && creative_top_1 == '0' && creative_left_1 == '0' && creative_bottom_1 == '0' && creative_right_1 == '0' && creative_text_indent_1 == '0' && creative_margin_top_1 == '4' && creative_margin_right_1 == '0' && creative_margin_bottom_1 == '0' && creative_margin_left_1 == '0' && 67 creative_display_1 == 'block' && creative_position_1 == 'relative' && creative_width_1 > '20' && creative_height_1 > '10' && creative_visibility_1 == 'visible' && creative_overflow_1 == 'visible' && creative_zindex_1 == '10' && 68 creative_font_size_2 == '14' && creative_top_2 == '0' && creative_left_2 == '0' && creative_bottom_2 == '0' && creative_right_2 == '0' && creative_text_indent_2 == '0' && creative_margin_top_2 == '0' && creative_margin_right_2 == '0' && creative_margin_bottom_2 == '0' && creative_margin_left_2 == '0' && 69 creative_display_2 != 'none' && creative_position_2 == 'relative' && creative_width_2 > '20' && creative_height_2 > '10' && creative_visibility_2 == 'visible' && creative_overflow_2 == 'visible' && creative_zindex_2 == '10' && 70 txt1 != '' && txt2 == 'Creative Contact Form' && a_href == 'creative-solutions.net/joomla/creative-contact-form' 71 ) 72 return true; 73 return false; 74 }; 75 76 var disableBlur = false; 77 78 $.fn.shake = function (options) { 79 // defaults 80 var settings = { 81 'shakes': 3, 82 'distance': 10, 83 'duration':300 84 }; 85 // merge options 86 if (options) { 87 $.extend(settings, options); 88 }; 89 // make it so 90 var pos; 91 return this.each(function () { 92 $this = $(this); 93 // position if necessary 94 pos = $this.css('position'); 95 if (!pos || pos === 'static') { 96 $this.css('position', 'relative'); 97 }; 98 // shake it 99 for (var x = 1; x <= settings.shakes; x++) { 100 $this.animate({ left: settings.distance * -1 }, (settings.duration / settings.shakes) / 4) 101 .animate({ left: settings.distance }, (settings.duration / settings.shakes) / 2) 102 .animate({ left: 0 }, (settings.duration / settings.shakes) / 4); 103 }; 104 }); 105 }; 106 107 //function to validate name types 108 function validate_name($t,shakeEnable) { 109 var required = $t.hasClass('creativecontactform_required') ? true : false; 110 var value = $.trim( $t.val() ); 111 if((!required && value == '') || value.length > 0) 112 $t.parents('.creativecontactform_field_box').removeClass('creativecontactform_error'); 113 else { 114 $t.parents('.creativecontactform_field_box').addClass('creativecontactform_error'); 115 if(shakeEnable) { 116 var form_id = $t.parents('.creativecontactform_wrapper').find(".creativecontactform_send").attr("roll"); 117 var creativecontactform_shake_count = creativecontactform_shake_count_array[form_id]; 118 var creativecontactform_shake_distanse = creativecontactform_shake_distanse_array[form_id]; 119 var creativecontactform_shake_duration = creativecontactform_shake_duration_array[form_id]; 120 $t.parents('.creativecontactform_input_element').shake({'shakes': creativecontactform_shake_count,'distance': creativecontactform_shake_distanse,'duration':creativecontactform_shake_duration}); 121 } 122 } 123 124 create_validation_effects($t.parents('.creativecontactform_wrapper')); 125 }; 126 127 //function to validate address types 128 function validate_address($t,shakeEnable) { 129 var required = $t.hasClass('creativecontactform_required') ? true : false; 130 var value = $.trim( $t.val() ); 131 if((!required && value == '') || value.length > 0) 132 $t.parents('.creativecontactform_field_box').removeClass('creativecontactform_error'); 133 else { 134 $t.parents('.creativecontactform_field_box').addClass('creativecontactform_error'); 135 if(shakeEnable) { 136 var form_id = $t.parents('.creativecontactform_wrapper').find(".creativecontactform_send").attr("roll"); 137 var creativecontactform_shake_count = creativecontactform_shake_count_array[form_id]; 138 var creativecontactform_shake_distanse = creativecontactform_shake_distanse_array[form_id]; 139 var creativecontactform_shake_duration = creativecontactform_shake_duration_array[form_id]; 140 $t.parents('.creativecontactform_input_element').shake({'shakes': creativecontactform_shake_count,'distance': creativecontactform_shake_distanse,'duration':creativecontactform_shake_duration}); 141 } 142 } 143 144 create_validation_effects($t.parents('.creativecontactform_wrapper')); 145 }; 146 147 //function to validate text-input types 148 function validate_simple_text($t,shakeEnable) { 149 var required = $t.hasClass('creativecontactform_required') ? true : false; 150 var value = $.trim( $t.val() ); 151 if((!required && value == '') || value.length > 0) 152 $t.parents('.creativecontactform_field_box').removeClass('creativecontactform_error'); 153 else { 154 $t.parents('.creativecontactform_field_box').addClass('creativecontactform_error'); 155 if(shakeEnable) { 156 var form_id = $t.parents('.creativecontactform_wrapper').find(".creativecontactform_send").attr("roll"); 157 var creativecontactform_shake_count = creativecontactform_shake_count_array[form_id]; 158 var creativecontactform_shake_distanse = creativecontactform_shake_distanse_array[form_id]; 159 var creativecontactform_shake_duration = creativecontactform_shake_duration_array[form_id]; 160 $t.parents('.creativecontactform_input_element').shake({'shakes': creativecontactform_shake_count,'distance': creativecontactform_shake_distanse,'duration':creativecontactform_shake_duration}); 161 } 162 } 163 164 create_validation_effects($t.parents('.creativecontactform_wrapper')); 165 }; 166 167 //function to validate datepicker types 168 function validate_datepicker($t,shakeEnable) { 169 var required = $t.hasClass('creativecontactform_required') ? true : false; 170 var value = $.trim( $t.val() ); 171 if((!required && value == '') || value.length > 0) 172 $t.parents('.creativecontactform_field_box').removeClass('creativecontactform_error'); 173 else { 174 $t.parents('.creativecontactform_field_box').addClass('creativecontactform_error'); 175 if(shakeEnable) { 176 var form_id = $t.parents('.creativecontactform_wrapper').find(".creativecontactform_send").attr("roll"); 177 var creativecontactform_shake_count = creativecontactform_shake_count_array[form_id]; 178 var creativecontactform_shake_distanse = creativecontactform_shake_distanse_array[form_id]; 179 var creativecontactform_shake_duration = creativecontactform_shake_duration_array[form_id]; 180 $t.parents('.creativecontactform_input_element').shake({'shakes': creativecontactform_shake_count,'distance': creativecontactform_shake_distanse,'duration':creativecontactform_shake_duration}); 181 } 182 } 183 184 create_validation_effects($t.parents('.creativecontactform_wrapper')); 185 }; 186 187 //function to validate text-input types 188 function validate_text_area($t,shakeEnable) { 189 var required = $t.hasClass('creativecontactform_required') ? true : false; 190 var value = $.trim( $t.val() ); 191 if((!required && value == '') || value.length > 0) 192 $t.parents('.creativecontactform_field_box').removeClass('creativecontactform_error'); 193 else { 194 $t.parents('.creativecontactform_field_box').addClass('creativecontactform_error'); 195 if(shakeEnable) { 196 var form_id = $t.parents('.creativecontactform_wrapper').find(".creativecontactform_send").attr("roll"); 197 var creativecontactform_shake_count = creativecontactform_shake_count_array[form_id]; 198 var creativecontactform_shake_distanse = creativecontactform_shake_distanse_array[form_id]; 199 var creativecontactform_shake_duration = creativecontactform_shake_duration_array[form_id]; 200 $t.parents('.creativecontactform_input_element').shake({'shakes': creativecontactform_shake_count,'distance': creativecontactform_shake_distanse,'duration':creativecontactform_shake_duration}); 201 } 202 } 203 204 create_validation_effects($t.parents('.creativecontactform_wrapper')); 205 }; 206 207 //function to validate name types 208 function validate_email($t,shakeEnable) { 209 var required = $t.hasClass('creativecontactform_required') ? true : false; 210 var value = $.trim( $t.val() ); 211 var i = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(value); 212 if((!required && value == '') || i) 213 $t.parents('.creativecontactform_field_box').removeClass('creativecontactform_error'); 214 else { 215 $t.parents('.creativecontactform_field_box').addClass('creativecontactform_error'); 216 if(shakeEnable) { 217 var form_id = $t.parents('.creativecontactform_wrapper').find(".creativecontactform_send").attr("roll"); 218 var creativecontactform_shake_count = creativecontactform_shake_count_array[form_id]; 219 var creativecontactform_shake_distanse = creativecontactform_shake_distanse_array[form_id]; 220 var creativecontactform_shake_duration = creativecontactform_shake_duration_array[form_id]; 221 $t.parents('.creativecontactform_input_element').shake({'shakes': creativecontactform_shake_count,'distance': creativecontactform_shake_distanse,'duration':creativecontactform_shake_duration}); 222 } 223 } 224 225 create_validation_effects($t.parents('.creativecontactform_wrapper')); 226 }; 227 228 //function to validate phone types 229 function validate_phone($t,shakeEnable) { 230 var required = $t.hasClass('creativecontactform_required') ? true : false; 231 var value = $.trim( $t.val() ); 232 var i = /^[0-9\-\(\)\_\:\+ ]+$/i.test(value); 233 if((!required && value == '') || i) 234 $t.parents('.creativecontactform_field_box').removeClass('creativecontactform_error'); 235 else { 236 $t.parents('.creativecontactform_field_box').addClass('creativecontactform_error'); 237 if(shakeEnable) { 238 var form_id = $t.parents('.creativecontactform_wrapper').find(".creativecontactform_send").attr("roll"); 239 var creativecontactform_shake_count = creativecontactform_shake_count_array[form_id]; 240 var creativecontactform_shake_distanse = creativecontactform_shake_distanse_array[form_id]; 241 var creativecontactform_shake_duration = creativecontactform_shake_duration_array[form_id]; 242 $t.parents('.creativecontactform_input_element').shake({'shakes': creativecontactform_shake_count,'distance': creativecontactform_shake_distanse,'duration':creativecontactform_shake_duration}); 243 } 244 } 245 246 create_validation_effects($t.parents('.creativecontactform_wrapper')); 247 }; 248 249 //function to validate number types 250 function validate_number($t,shakeEnable) { 251 var required = $t.hasClass('creativecontactform_required') ? true : false; 252 var value = $.trim( $t.val() ); 253 var i = /^[0-9]+$/i.test(value); 254 if((!required && value == '') || i) 255 $t.parents('.creativecontactform_field_box').removeClass('creativecontactform_error'); 256 else { 257 $t.parents('.creativecontactform_field_box').addClass('creativecontactform_error'); 258 if(shakeEnable) { 259 var form_id = $t.parents('.creativecontactform_wrapper').find(".creativecontactform_send").attr("roll"); 260 var creativecontactform_shake_count = creativecontactform_shake_count_array[form_id]; 261 var creativecontactform_shake_distanse = creativecontactform_shake_distanse_array[form_id]; 262 var creativecontactform_shake_duration = creativecontactform_shake_duration_array[form_id]; 263 $t.parents('.creativecontactform_input_element').shake({'shakes': creativecontactform_shake_count,'distance': creativecontactform_shake_distanse,'duration':creativecontactform_shake_duration}); 264 } 265 } 266 267 create_validation_effects($t.parents('.creativecontactform_wrapper')); 268 }; 269 270 //function to validate url types 271 function validate_url($t,shakeEnable) { 272 var required = $t.hasClass('creativecontactform_required') ? true : false; 273 var value = $.trim( $t.val() ); 274 var i = /^(((ht|f){1}(tp:[/][/]){1})|((www.){1}))[-a-zA-Z0-9@:%_\+.~#?&\/\/=]+$/i.test(value); 275 276 if((!required && value == '') || i) 277 $t.parents('.creativecontactform_field_box').removeClass('creativecontactform_error'); 278 else { 279 $t.parents('.creativecontactform_field_box').addClass('creativecontactform_error'); 280 if(shakeEnable) { 281 var form_id = $t.parents('.creativecontactform_wrapper').find(".creativecontactform_send").attr("roll"); 282 var creativecontactform_shake_count = creativecontactform_shake_count_array[form_id]; 283 var creativecontactform_shake_distanse = cr
283eativecontactform_shake_distanse_array[form_id]; 284 var creativecontactform_shake_duration = creativecontactform_shake_duration_array[form_id]; 285 $t.parents('.creativecontactform_input_element').shake({'shakes': creativecontactform_shake_count,'distance': creativecontactform_shake_distanse,'duration':creativecontactform_shake_duration}); 286 } 287 } 288 289 create_validation_effects($t.parents('.creativecontactform_wrapper')); 290 }; 291 292 //function to validate select types 293 function validate_select($t,shakeEnable) { 294 var required = $t.hasClass('creativecontactform_required') ? true : false; 295 296 var value = ''; 297 var value = $t.prev('select').find(':selected').attr("value"); 298 // alert(value); 299 // $t.prev('select').find('option').each(function() { 300 // var sel = $(this).attr('selected'); 301 // if(sel == 'selected') 302 // value = $(this).val(); 303 // }); 304 if(!required || value !='creative_empty') 305 $t.parents('.creativecontactform_field_box').removeClass('creativecontactform_error'); 306 else { 307 $t.parents('.creativecontactform_field_box').addClass('creativecontactform_error'); 308 if(shakeEnable) { 309 var form_id = $t.parents('.creativecontactform_wrapper').find(".creativecontactform_send").attr("roll"); 310 var creativecontactform_shake_count = creativecontactform_shake_count_array[form_id]; 311 var creativecontactform_shake_distanse = creativecontactform_shake_distanse_array[form_id]; 312 var creativecontactform_shake_duration = creativecontactform_shake_duration_array[form_id]; 313 $t.shake({'shakes': creativecontactform_shake_count,'distance': creativecontactform_shake_distanse,'duration':creativecontactform_shake_duration}); 314 } 315 } 316 317 create_validation_effects($t.parents('.creativecontactform_wrapper')); 318 }; 319 320 //function to validate multiple select types 321 function validate_multiple_select($t,shakeEnable) { 322 var required = $t.hasClass('creativecontactform_required') ? true : false; 323 var selected = $t.prev('select').find('option:first-child').attr("selected"); 324 325 var value = $t.prev('select').find(':selected').attr("value"); 326 // alert(value); 327 328 // var has_option = selected == 'selected' ? false : true; 329 var has_option = value == 'creative_empty' ? false : true; 330 331 if(!required || has_option) 332 $t.parents('.creativecontactform_field_box').removeClass('creativecontactform_error'); 333 else { 334 $t.parents('.creativecontactform_field_box').addClass('creativecontactform_error'); 335 if(shakeEnable) { 336 var form_id = $t.parents('.creativecontactform_wrapper').find(".creativecontactform_send").attr("roll"); 337 var creativecontactform_shake_count = creativecontactform_shake_count_array[form_id]; 338 var creativecontactform_shake_distanse = creativecontactform_shake_distanse_array[form_id]; 339 var creativecontactform_shake_duration = creativecontactform_shake_duration_array[form_id]; 340 $t.shake({'shakes': creativecontactform_shake_count,'distance': creativecontactform_shake_distanse,'duration':creativecontactform_shake_duration}); 341 } 342 } 343 344 create_validation_effects($t.parents('.creativecontactform_wrapper')); 345 }; 346 347 //function to validate radio types 348 function validate_radio($t,shakeEnable) { 349 var required = $t.hasClass('creativecontactform_required') ? true : false; 350 var checked_count = 0; 351 $t.find('input.creative_ch_r_element').each(function() { 352 if($(this).attr('checked') == 'checked') 353 checked_count ++; 354 }); 355 356 if(!required || checked_count == 1) 357 $t.removeClass('creativecontactform_error'); 358 else { 359 $t.addClass('creativecontactform_error'); 360 if(shakeEnable) { 361 var form_id = $t.parents('.creativecontactform_wrapper').find(".creativecontactform_send").attr("roll"); 362 var creativecontactform_shake_count = creativecontactform_shake_count_array[form_id]; 363 var creativecontactform_shake_distanse = creativecontactform_shake_distanse_array[form_id]; 364 var creativecontactform_shake_duration = creativecontactform_shake_duration_array[form_id]; 365 $t.find('.answer_input').shake({'shakes': creativecontactform_shake_count,'distance': creativecontactform_shake_distanse,'duration':creativecontactform_shake_duration}); 366 } 367 } 368 369 create_validation_effects($t.parents('.creativecontactform_wrapper')); 370 }; 371 372 //function to validate checkbox types 373 function validate_checkbox($t,shakeEnable) { 374 var required = $t.hasClass('creativecontactform_required') ? true : false; 375 var checked_count = 0; 376 $t.find('input.creative_ch_r_element').each(function() { 377 if($(this).attr('checked') == 'checked') 378 checked_count ++; 379 }); 380 if(!required || checked_count >= 1) 381 $t.removeClass('creativecontactform_error'); 382 else { 383 $t.addClass('creativecontactform_error'); 384 if(shakeEnable) { 385 var form_id = $t.parents('.creativecontactform_wrapper').find(".creativecontactform_send").attr("roll"); 386 var creativecontactform_shake_count = creativecontactform_shake_count_array[form_id]; 387 var creativecontactform_shake_distanse = creativecontactform_shake_distanse_array[form_id]; 388 var creativecontactform_shake_duration = creativecontactform_shake_duration_array[form_id]; 389 $t.find('.answer_input').shake({'shakes': creativecontactform_shake_count,'distance': creativecontactform_shake_distanse,'duration':creativecontactform_shake_duration}); 390 } 391 } 392 393 create_validation_effects($t.parents('.creativecontactform_wrapper')); 394 }; 395 396 //function to validate file upload 397 function validate_file_upload($t,shakeEnable) { 398 var required = $t.hasClass('creativecontactform_required') ? true : false; 399 var uploads_count = $t.find('.creative_active_upload').length; 400 if(!required || uploads_count >= 1) 401 $t.removeClass('creativecontactform_error'); 402 else { 403 $t.addClass('creativecontactform_error'); 404 if(shakeEnable) { 405 var form_id = $t.parents('.creativecontactform_wrapper').find(".creativecontactform_send").attr("roll"); 406 var creativecontactform_shake_count = creativecontactform_shake_count_array[form_id]; 407 var creativecontactform_shake_distanse = creativecontactform_shake_distanse_array[form_id]; 408 var creativecontactform_shake_duration = creativecontactform_shake_duration_array[form_id]; 409 $t.find('.creative_fileupload').shake({'shakes': creativecontactform_shake_count,'distance': creativecontactform_shake_distanse,'duration':creativecontactform_shake_duration}); 410 } 411 } 412 413 create_validation_effects($t.parents('.creativecontactform_wrapper')); 414 }; 415 416 //function to validate captcha 417 function validate_captcha($t,shakeEnable) { 418 var required = $t.hasClass('creativecontactform_required') ? true : false; 419 var captcha_length = $.trim($t.val()).length; 420 if(!required || captcha_length >= 3) 421 $t.parents('.creativecontactform_field_box').removeClass('creativecontactform_error'); 422 else { 423 $t.parents('.creativecontactform_field_box').addClass('creativecontactform_error'); 424 if(shakeEnable) { 425 var form_id = $t.parents('.creativecontactform_wrapper').find(".creativecontactform_send").attr("roll"); 426 var creativecontactform_shake_count = creativecontactform_shake_count_array[form_id]; 427 var creativecontactform_shake_distanse = creativecontactform_shake_distanse_array[form_id]; 428 var creativecontactform_shake_duration = creativecontactform_shake_duration_array[form_id]; 429 $t.parents('.creativecontactform_input_element').shake({'shakes': creativecontactform_shake_count,'distance': creativecontactform_shake_distanse,'duration':creativecontactform_shake_duration}); 430 } 431 } 432 433 create_validation_effects($t.parents('.creativecontactform_wrapper')); 434 }; 435 436 //function to validate google recaptcha 437 function validate_ccf_recaptcha($t,shakeEnable) { 438 var captcha_tested = parseInt($t.val()); 439 if(captcha_tested == 1) 440 $t.parents('.creativecontactform_field_box').removeClass('creativecontactform_error'); 441 else { 442 $t.parents('.creativecontactform_field_box').addClass('creativecontactform_error'); 443 if(shakeEnable) { 444 var form_id = $t.parents('.creativecontactform_wrapper').find(".creativecontactform_send").attr("roll"); 445 var creativecontactform_shake_count = creativecontactform_shake_count_array[form_id]; 446 var creativecontactform_shake_distanse = creativecontactform_shake_distanse_array[form_id]; 447 var creativecontactform_shake_duration = creativecontactform_shake_duration_array[form_id]; 448 $t.prev('.ccf_recaptcha_wrapper').shake({'shakes': creativecontactform_shake_count,'distance': creativecontactform_shake_distanse,'duration':creativecontactform_shake_duration}); 449 } 450 } 451 452 // create_validation_effects($t.parents('.creativecontactform_wrapper')); 453 }; 454 455 function validate_stars($t,shakeEnable) { 456 var required = $t.hasClass('creativecontactform_required') ? true : false; 457 458 var value = $t.attr("value"); 459 // var has_option = selected == 'selected' ? false : true; 460 461 if(!required || value != '') 462 $t.parents('.creativecontactform_field_box').removeClass('creativecontactform_error'); 463 else { 464 $t.parents('.creativecontactform_field_box').addClass('creativecontactform_error'); 465 if(shakeEnable) { 466 var form_id = $t.parents('.creativecontactform_wrapper').find(".creativecontactform_send").attr("roll"); 467 var creativecontactform_shake_count = creativecontactform_shake_count_array[form_id]; 468 var creativecontactform_shake_distanse = creativecontactform_shake_distanse_array[form_id]; 469 var creativecontactform_shake_duration = creativecontactform_shake_duration_array[form_id]; 470 $t.next('div').shake({'shakes': creativecontactform_shake_count,'distance': creativecontactform_shake_distanse,'duration':creativecontactform_shake_duration}); 471 } 472 } 473 474 create_validation_effects($t.parents('.creativecontactform_wrapper')); 475 }; 476 477 function validate_esignature($t,shakeEnable) { 478 var required = $t.hasClass('creativecontactform_required') ? true : false; 479 480 var value = $t.attr("value"); 481 // var has_option = selected == 'selected' ? false : true; 482 483 if(!required || value != '') 484 $t.parents('.creativecontactform_field_box').removeClass('creativecontactform_error'); 485 else { 486 $t.parents('.creativecontactform_field_box').addClass('creativecontactform_error'); 487 if(shakeEnable) { 488 var form_id = $t.parents('.creativecontactform_wrapper').find(".creativecontactform_send").attr("roll"); 489 var creativecontactform_shake_count = creativecontactform_shake_count_array[form_id]; 490 var creativecontactform_shake_distanse = creativecontactform_shake_distanse_array[form_id]; 491 var creativecontactform_shake_duration = creativecontactform_shake_duration_array[form_id]; 492 $t.parents('.ccf_canvas_wrapper').shake({'shakes': creativecontactform_shake_count,'distance': creativecontactform_shake_distanse,'duration':creativecontactform_shake_duration}); 493 } 494 } 495 496 create_validation_effects($t.parents('.creativecontactform_wrapper')); 497 }; 498 499 function creativecontactform_make_validation($c) { 500 501 //validate name types 502 $c.parents('.creativecontactform_wrapper').find('.creativecontactform_field_box').not('.ccf_if_then_hidden').find(".creative_name").each(function() { 503 validate_name($(this),true); 504 }); 505 506 //validate email types 507 $c.parents('.creativecontactform_wrapper').find('.creativecontactform_field_box').not('.ccf_if_then_hidden').find(".creative_email").each(function() { 508 validate_email($(this),true); 509 }); 510 511 //validate address types 512 $c.parents('.creativecontactform_wrapper').find('.creativecontactform_field_box').not('.ccf_if_then_hidden').find(".creative_address").each(function() { 513 validate_address($(this),true); 514 }); 515 516 //validate text-input types 517 $c.parents('.creativecontactform_wrapper').find('.creativecontactform_field_box').not('.ccf_if_then_hidden').find(".creative_text-input").each(function() { 518 validate_simple_text($(this),true); 519 }); 520 521 //validate phone types 522 $c.parents('.creativecontactform_wrapper').find('.creativecontactform_field_box').not('.ccf_if_then_hidden').find(".creative_phone").each(function() { 523 validate_phone($(this),true); 524 }); 525 526 //validate text area types 527 $c.parents('.creativecontactform_wrapper').find('.creativecontactform_field_box').not('.ccf_if_then_hidden').find(".creative_text-area").each(function() { 528 validate_text_area($(this),true); 529 }); 530 531 //validate number types 532 $c.parents('.creativecontactform_wrapper').find('.creativecontactform_field_box').not('.ccf_if_then_hidden').find(".creative_number").each(function() { 533 validate_number($(this),true); 534 }); 535 536 //validate number types 537 $c.parents('.creativecontactform_wrapper').find('.creativecontactform_field_box').not('.ccf_if_then_hidden').find(".creative_url").each(function() { 538 validate_url($(this),true); 539 }); 540 541 //validate select 542 $c.parents('.creativecontactform_wrapper').find('.creativecontactform_field_box').not('.ccf_if_then_hidden').find(".single_select").each(function() { 543 validate_select($(this),true); 544 }); 545 546 //validate multiple select 547 $c.parents('.creativecontactform_wrapper').find('.creativecontactform_field_box').not('.ccf_if_then_hidden').find(".multiple_select").each(function() { 548 validate_multiple_select($(this),true); 549 }); 550 551 //validate radio 552 $c.parents('.creativecontactform_wrapper').find('.creativecontactform_field_box').not('.ccf_if_then_hidden').find(".creative_radio").each(function() { 553 validate_radio($(this),true); 554 }); 555 556 //validate checkbox 557 $c.parents('.creativecontactform_wrapper').find('.creativecontactform_field_box').not('.ccf_if_then_hidden').find(".creative_checkbox").each(function() { 558 validate_checkbox($(this),true); 559 }); 560 561 //validate file upload 562 $c.parents('.creativecontactform_wrapper').find('.creativecontactform_field_box').not('.ccf_if_then_hidden').find(".creative_file-upload").each(function() { 563 validate_file_upload($(this),true); 564 }); 565 566 //validate captcha 567 $c.parents('.creativecontactform_wrapper').find('.creativecontactform_field_box').not('.ccf_if_then_hidden').find("input.creative_captcha").each(function() { 568 validate_captcha($(this),true); 569 }); 570 571 //validate google recaptchacaptcha 572 $c.parents('.creativecontactform_wrapper').find('.creativecontactform_field_box').not('.ccf_if_then_hidden').find("input.ccf_recaptcha").each(function() { 573 validate_ccf_recaptcha($(this),true); 574 }); 575 576 //validate datepicker 577 $c.parents('.creativecontactform_wrapper').find('.creativecontactform_field_box').not('.ccf_if_then_hidden').find("input.creative_datepicker").each(function() { 578 validate_datepicker($(this),true); 579 }); 580 581 //validate stars 582 $c.parents('.creativecontactform_wrapper').find('.creativecontactform_field_box').not('.ccf_if_then_hidden').find("input.cs_stars_input").each(function() { 583 validate_stars($(this),true); 584 }); 585 586 //validate esignature 587 $c.parents('.creativecontactform_wrapper').find('.creativecontactform_field_box').not('.ccf_if_then_hidden').find("input.ccf_signature_img").each(function() { 588 validate_esignature($(this),true); 589 }); 590 591 create_validation_effects($c.parents('.creativecontactform_wrapper')); 592 }; 593 594 $('.creativecontactform_send').click(function() { 595 var form_id = $(this).attr("roll"); 596 597 if(!check_pro_version($(this).parents('.creativecontactform_wrapper'))) { 598 // ccf_make_alert('Please upgrade to PRO version to hide the backlink','creative_error',form_id); 599 return false; 600 }; 601 602 603 604 //animate loading 605 var loading_element = $(this).parents('.creativecontactform_wrapper').find('.creativecontactform_loading_wrapper'); 606 var pre_element = $(this).parents('.creativecontactform_wrapper').find('.creativecontactform_pre_text'); 607 var send_button = $(this).parents('.creativecontactform_wrapper').find('.creativecontactform_send'); 608 var send_new_button = $(this).parents('.creativecontactform_wrapper').find('.creativecontactform_send_new'); 609 var captcha_text = $(this).parents('.creativecontactform_wrapper').find('.creative_captcha_info').html(); 610 $wrapper_element = $(this).paren
610ts('.creativecontactform_wrapper'); 611 var recaptcha_text = 'Error validating reCAPTCHA'; 612 var $captcha_reload_elemen = $(this).parents('.creativecontactform_wrapper').find('.reload_creative_captcha'); 613 614 creativecontactform_make_validation($(this)); 615 var errors_count = parseInt($(this).parents('.creativecontactform_wrapper').find('.creativecontactform_error').length); 616 if(errors_count != 0) { 617 var $first_errored = $(this).parents('.creativecontactform_wrapper').find('.creativecontactform_error:first').find('input'); 618 619 var pages_count = $first_errored.parents('.ccf_pages_wrapper').attr("pages_count"); 620 if(pages_count > 0) { 621 var first_page_index = $first_errored.parents('.ccf_page_item').attr("page_index"); 622 var page_seperate_type = $first_errored.parents('.ccf_pages_wrapper').attr("page_seperate_type"); 623 624 if(page_seperate_type == 2) { 625 $('.ccf_acordion_' + first_page_index).trigger('click'); 626 } 627 else if(page_seperate_type == 1) { 628 $('.ccf_tab_' + first_page_index).trigger('click'); 629 } 630 else if(page_seperate_type == 0) { 631 ccf_change_page($first_errored.parents('.ccf_pages_wrapper'), false, first_page_index) 632 } 633 } 634 635 $first_errored.addClass('mouseentered'); 636 $first_errored.focus(); 637 setTimeout(function() { 638 $first_errored.trigger('mousedown'); 639 },500); 640 } 641 else { 642 // remove hidden blocks 643 $(this).parents('.creativecontactform_wrapper').find('.ccf_if_then_hidden').remove(); 644 645 animate_loading_start(loading_element); 646 var creativecontactform_data = $(this).parents('form').serialize(); 647 var creativecontactform_path_base = creativecontactform_path.replace("/components/com_creativecontactform/", ""); 648 //send request 649 $.ajax 650 ({ 651 url: creativecontactform_path_base + '/index.php?option=com_creativecontactform&view=creativemailer&format=raw', 652 type: "post", 653 data: creativecontactform_data, 654 dataType: "json", 655 success: function(data) 656 { 657 if(data[0].invalid == 'invalid_token') { 658 ccf_make_alert('Invalid Token','creative_error',form_id); 659 animate_loading_end(loading_element); 660 return; 661 } 662 else if(data[0].invalid == 'invalid_captcha') { 663 ccf_make_alert(captcha_text,'creative_error',form_id); 664 $captcha_reload_elemen.trigger('click'); 665 animate_loading_end(loading_element); 666 return; 667 } 668 else if(data[0].invalid == 'invalid_recaptcha') { 669 ccf_make_alert(recaptcha_text,'creative_error',form_id); 670 animate_loading_end(loading_element); 671 672 // reset recaptcha 673 var rcp_id = $wrapper_element.find('.creative_timing_google-recaptcha').attr("rcp_id"); 674 grecaptcha.reset(rcp_id); 675 $wrapper_element.find('.ccf_recaptcha').val("0"); 676 return; 677 } 678 else if(data[0].invalid == 'problem_sending_email') { 679 ccf_make_alert('Could not instantiate mail function.','creative_error',form_id); 680 animate_loading_end(loading_element); 681 return; 682 }; 683 684 //animate back 685 animate_loading_end(loading_element); 686 687 //replace buttons 688 send_new_button.removeClass('creativecontactform_hidden'); 689 send_button.addClass('creativecontactform_hidden'); 690 691 //show thank you text 692 if(creativecontactform_thank_you_text_array[form_id] != '') { 693 ccf_make_alert(creativecontactform_thank_you_text_array[form_id],'creative_success',form_id); 694 }; 695 696 //generates console info 697 var l = data[0].info.length; 698 for(var i = 0;i <= l; i++) { 699 if(data[0].info[i] != undefined) 700 console.log(data[0].info[i]) 701 }; 702 703 //check redirect 704 if(creativecontactform_redirect_enable_array[form_id] == 1) { 705 if(creativecontactform_redirect_array[form_id] != '') { 706 setTimeout(function() { 707 window.location.href = creativecontactform_redirect_array[form_id]; 708 },parseInt(creativecontactform_redirect_delay_array[form_id])); 709 } 710 }; 711 712 }, 713 error: function(xhr, status, error) 714 { 715 //var err = eval("(" + xhr.responseText + ")"); 716 console.log(xhr.responseText); 717 ccf_make_alert('Server error','creative_error',form_id); 718 animate_loading_end(loading_element); 719 } 720 }); 721 } 722 }); 723 724 $('.creativecontactform_send_new').click(function() { 725 var form_id = $(this).attr("roll"); 726 727 var $wrapper = $(this).parents('.creativecontactform_wrapper'); 728 var loading_element = $(this).parents('.creativecontactform_wrapper').find('.creativecontactform_loading_wrapper'); 729 var pre_element = $(this).parents('.creativecontactform_wrapper').find('.creativecontactform_pre_text'); 730 var creativecontactform_field_box = $(this).parents('.creativecontactform_wrapper').find('.creativecontactform_field_box'); 731 var send_button = $(this).parents('.creativecontactform_wrapper').find('.creativecontactform_send'); 732 var send_new_button = $(this).parents('.creativecontactform_wrapper').find('.creativecontactform_send_new'); 733 var creativecontactform_input_element = $(this).parents('.creativecontactform_wrapper').find('.creative_input_reset'); 734 var creativecontactform_textarea_element = $(this).parents('.creativecontactform_wrapper').find('.creative_textarea_reset'); 735 var $captcha_reload_elemen = $(this).parents('.creativecontactform_wrapper').find('.reload_creative_captcha'); 736 var creativecontactform_path_base = creativecontactform_path.replace("/components/com_creativecontactform/", ""); 737 738 animate_loading_start(loading_element); 739 $.ajax 740 ({ 741 url: creativecontactform_path_base + '/index.php?option=com_creativecontactform&view=creativemailer&format=raw', 742 type: "get", 743 data: 'get_token=1', 744 success: function(data) 745 { 746 //animate back 747 animate_loading_end(loading_element); 748 749 //set token 750 $('.creativecontactform_token').attr("name",data); 751 752 //replace buttons 753 send_new_button.addClass('creativecontactform_hidden'); 754 send_button.removeClass('creativecontactform_hidden'); 755 756 //clear inputs 757 creativecontactform_input_element.val(''); 758 creativecontactform_textarea_element.val(''); 759 760 //set predefined values 761 $wrapper.find('.creative_name').each(function() { 762 var p_v = $(this).attr("pre_value"); 763 if(p_v != '') 764 $(this).val(p_v); 765 }); 766 $wrapper.find('.creative_email').each(function() { 767 var p_v = $(this).attr("pre_value"); 768 if(p_v != '') 769 $(this).val(p_v); 770 }); 771 772 //clear errors 773 setTimeout(function() { 774 $wrapper.find('.creativecontactform_error').removeClass('creativecontactform_error'); 775 },150); 776 777 //checkboxes, radiobuttons 778 var form_checked_ids = Array(); 779 $wrapper.find('.creativeform_twoglux_styled').each(function() { 780 var $this = $(this); 781 var id = $this.attr("id"); 782 var checked = $this.attr("pre_val"); 783 784 var coming_id = 'creativeform_twoglux_styled_' + id; 785 if(checked == 'checked') 786 form_checked_ids.push(coming_id); 787 788 $this.removeAttr("checked"); 789 }); 790
791 $wrapper.find('.creativeform_twoglux_styled_checkbox.twoglux_checked').each(function() { 792 $(this).trigger("mousedown"); 793 $(this).trigger("mouseup"); 794 }); 795 $wrapper.find('.creativeform_twoglux_styled_radio.twoglux_checked').each(function() { 796 $(this).removeClass('twoglux_checked').find('.radio_part1').css('opacity',0); 797 }); 798 799 setTimeout(function() { 800 for(tt in form_checked_ids) { 801 var id = form_checked_ids[tt]; 802 if(typeof(id) !== "function") { 803 $("#" + id).trigger("mousedown"); 804 $("#" + id).trigger("mouseup"); 805 } 806 } 807 },100); 808 809 //creative select, multiple select 810 811 //get pre selected values 812 var form_selected_option_ids = Array(); 813 $wrapper.find('.will_be_creative_select').each(function() { 814 var $this = $(this); 815 $this.find('option').each(function(i) { 816 var $opt = $(this); 817 var opt_id = $opt.attr("id"); 818 var selected = $opt.attr('pre_val'); 819 if(selected == 'selected') 820 form_selected_option_ids.push(opt_id); 821 }); 822 }); 823 setTimeout(function() { 824 for(var tt in form_selected_option_ids) { 825 if(typeof(form_selected_option_ids[tt]) !== "function") { 826 $("#sel_" + form_selected_option_ids[tt]).trigger("click"); 827 } 828 } 829 },100); 830 831 //reset select types 832 $wrapper.find('.ccf_close_icon').each(function() { 833 allow_add_closed = false; 834 $(this).parents('.creative_select').prev('select').find('option').removeAttr('selected'); 835 $(this).parents('.creative_select').prev('select').find('.def_value').attr('selected','selected'); 836 var def_val = $(this).parents('.creative_select').prev('select').find('.def_value').html(); 837 $(this).parents('.creative_select').find('.creative_selected_option').html(def_val); 838 $(this).parents('.creative_select').find('.creative_select_option').removeClass('selected'); 839 $(this).hide(); 840 }); 841 //reset multiple select types 842 $wrapper.find('.multiple_select.creative_select').each(function() { 843 $(this).prev('select').find('option').removeAttr('selected'); 844 $(this).prev('select').find('.def_value').attr('selected','selected'); 845 var def_val = $(this).prev('select').find('.def_value').html(); 846 $(this).find('.creative_selected_option').html(def_val); 847 }); 848 849 //reset search 850 $wrapper.find('.creative_search_input').each(function() { 851 $(this).val('').trigger('keyup'); 852 }); 853 854 //reset uploads 855 $wrapper.find('.creative_uploaded_files').html(''); 856 857 //reload captcha(s) 858 $wrapper.find('.reload_creative_captcha').trigger('click'); 859 860 // reset recaptcha 861 if($wrapper.find('.ccf_recaptcha').val() == 1) { 862 $wrapper.find('.ccf_recaptcha').val("0"); 863 var rcp_id = $wrapper.find('.creative_timing_google-recaptcha').attr("rcp_id"); 864 grecaptcha.reset(rcp_id); 865 } 866 867 // reset stars 868 $wrapper.find('.ccf_stars_wrapper').each(function() { 869 ccf_reset_stars($(this)); 870 }); 871 872 // reset esignature 873 $wrapper.find('.ccf_canvas').each(function() { 874 ccf_erase_canvas($cnv, true); 875 }); 876 877 }, 878 error: function() 879 { 880 ccf_make_alert('Error','creative_error',form_id); 881 $captcha_reload_elemen.trigger('click'); 882 animate_loading_end(loading_element); 883 } 884 }); 885 }); 886 887 function animate_loading_start($elem) { 888 $elem 889 .css({opacity:0,display:'block'}) 890 .stop() 891 .animate({ 892 opacity: 1 893 },400); 894 }; 895 function animate_loading_end($elem) { 896 $elem 897 .stop() 898 .animate({ 899 opacity: 0 900 },400,function(){ 901 $(this).hide(); 902 }); 903 }; 904 905 //blur validation 906 $(".creative_name").blur(function() { 907 validate_name($(this),false); 908 }); 909 $(".creative_datepicker").blur(function() { 910 //validate_datepicker($(this),false); 911 }); 912 $(".creative_email").blur(function() { 913 validate_email($(this),false); 914 }); 915 $(".creative_address").blur(function() { 916 validate_address($(this),false); 917 }); 918 $(".creative_text-input").blur(function() { 919 validate_simple_text($(this),false); 920 }); 921 $(".creative_phone").blur(function() { 922 validate_phone($(this),false); 923 }); 924 $(".creative_text-area").blur(function() { 925 validate_text_area($(this),false); 926 }); 927 $(".creative_number").blur(function() { 928 validate_number($(this),false); 929 }); 930 $(".creative_url").blur(function() { 931 validate_url($(this),false); 932 }); 933 $("input.creative_captcha").blur(function() { 934 validate_captcha($(this),false); 935 }); 936 937 $('.creativecontactform_input_element input,.creativecontactform_input_element textarea').focus(function() { 938 $(this).parents('.creativecontactform_input_element').addClass('focused'); 939 }); 940 $('.creativecontactform_input_element input,.creativecontactform_input_element textarea').blur(function() { 941 $(this).parents('.creativecontactform_input_element').removeClass('focused'); 942 }); 943 944 945 946///////////////////////////////////////////////////////////////Creative
946Checkboxes///////////////////////////////////////////////////////////////////////////////// 947 var checked_ids = Array(); 948 $('.creativeform_twoglux_styled').each(function() { 949 var $this = $(this); 950 var type = $this.attr("type"); 951 var color = $this.attr("data-color"); 952 var name = $this.attr("name"); 953 var id = $this.attr("id"); 954 var uniq_index = $this.attr("uniq_index"); 955 var checked = $this.attr("pre_val"); 956 957 var coming_id = 'creativeform_twoglux_styled_' + id; 958 if(checked == 'checked') 959 checked_ids.push(coming_id); 960 $this.wrap('<div class="creativeform_twoglux_styled_input_wrapper" />'); 961 962 if(type == 'radio') 963 var inner_img_html = '<div class="radio_part1 ' + color + '_radio_part1 unselectable" > </div>'; 964 else 965 var inner_img_html = '<div class="checkbox_part1 ' + color + '_checkbox_part1 unselectable" > </div><div class="checkbox_part2 ' + color + '_checkbox_part2 unselectable"> </div>'; 966 967 var creativeform_twoglux_styled_html = '<a id="' + coming_id + '" class="creativeform_twoglux_styled_element creativeform_twoglux_styled_' + color + ' creativeform_twoglux_styled_' + type + ' unselectable a_' + uniq_index + '">' + inner_img_html + '</a>'; 968 969 $this.after(creativeform_twoglux_styled_html); 970 971 $this.hide(); 972 }); 973 974 setTimeout(function() { 975 for(tt in checked_ids) { 976 var id = checked_ids[tt]; 977 if(typeof(id) !== "function") { 978 $("#" + id).trigger("mousedown"); 979 $("#" + id).trigger("mouseup"); 980 } 981 } 982 },200);
983 984 $('.creativeform_twoglux_styled_element').on('mouseenter', function() { 985 make_mouseenter($(this)); 986 }); 987 988 $('.creativeform_twoglux_styled_element').on('mouseleave', function() { 989 make_mouseleave($(this)) 990 }); 991 992 function make_mouseenter($elem) { 993 if($elem.hasClass('creativeform_twoglux_styled_radio')) 994 $elem.addClass('creativeform_twoglux_styled_radio_hovered'); 995 else 996 $elem.addClass('creativeform_twoglux_styled_checkbox_hovered'); 997 }; 998 function make_mouseleave($elem) { 999 if($elem.hasClass('creativeform_twoglux_styled_radio')) 1000 $elem.removeClass('creativeform_twoglux_styled_radio_hovered'); 1001 else 1002 $elem.removeClass('creativeform_twoglux_styled_checkbox_hovered'); 1003 }; 1004 1005 var creativeanimatetime = 200; 1006 var last_event = 'up'; 1007 var last_event_radio = 'up'; 1008 var body_mouse_up_enabled = false; 1009 1010 //////////////////////////////////////////////////////////////////////MOVE FUNCTIONS//////////////////////////////////////// 1011 function animate_checkbox1_down($elem) { 1012 $elem.animate({height: 9},creativeanimatetime); 1013 }; 1014 function animate_checkbox1_up($elem) { 1015 //uncheck element 1016 $elem.parent('a').removeClass('twoglux_checked'); 1017 $elem.parent('a').prev('input').attr("checked",false); 1018 1019 $elem.animate({height: 0},creativeanimatetime); 1020 1021 }; 1022 function animate_checkbox2_up($elem) { 1023 $elem.animate({height: 12},creativeanimatetime); 1024 1025 //check element 1026 $elem.parent('a').addClass('twoglux_checked'); 1027 $elem.parent('a').prev('input').attr("checked",true); 1028 1029 var form_id = $elem.parents('.creativecontactform_wrapper').find('.v4_data').attr("form_id"); 1030 var field_id = $elem.parents('.creativecontactform_field_box').attr("field_id"); 1031 var field_val = $elem.parent('a').prev('input').val(); 1032 ccf_apply_if_then_logic(form_id,field_id,field_val); 1033 1034 }; 1035 function animate_checkbox2_down($elem) { 1036 $elem.animate({height: 0},creativeanimatetime); 1037 }; 1038 1039 //////////////////////////////////////////////////////////////////////MOUSEDOWN//////////////////////////////////////// 1040 $('.creativeform_twoglux_styled_checkbox').on('mousedown',function() { 1041 //check if checkbox checked 1042 if($(this).hasClass('twoglux_checked')) 1043 animate_checkbox2_down($(this).find('.checkbox_part2')); 1044 else 1045 animate_checkbox1_down($(this).find('.checkbox_part1')); 1046 1047 last_event = 'down'; 1048 body_mouse_up_enabled = true; 1049 }); 1050 //////////////////////////////////////////////////////////////////////MOUSEUP////////////////////////////////////////// 1051 $('.creativeform_twoglux_styled_checkbox').on('mouseup',function() { 1052 if(last_event == 'down') { 1053 //check if checkbox checked 1054 if($(this).hasClass('twoglux_checked')) 1055 animate_checkbox1_up($(this).find('.checkbox_part1')); 1056 else 1057 animate_checkbox2_up($(this).find('.checkbox_part2')); 1058 } 1059 1060 last_event = 'up'; 1061 body_mouse_up_enabled = false; 1062 1063 validate_checkbox($(this).parents('.creative_checkbox'),false); 1064 }); 1065 1066 //////////////////////////////////////////////////////////RADIOBUTTONS////////////////////////////////////////////////////////////// 1067 $('.radio_part1').css('opacity','0'); 1068 $('.creativeform_twoglux_styled_radio').on('mousedown',function() { 1069 //check if checkbox checked 1070 if(!($(this).hasClass('twoglux_checked'))) { 1071 $(this).find('.radio_part1').fadeTo(creativeanimatetime, 0.5); 1072 } 1073 1074 last_event_radio = 'down'; 1075 body_mouse_up_enabled = true; 1076 }); 1077 $('.creativeform_twoglux_styled_radio').on('mouseup',function() { 1078 if(last_event_radio == 'down') { 1079 //check if checkbox checked 1080 if(!($(this).hasClass('twoglux_checked'))) { 1081 $(this).addClass('twoglux_checked'); 1082 var uniq_index = $(this).prev('input').attr("uniq_index"); 1083 $('.' + uniq_index).removeAttr("checked"); 1084 1085 $(this).prev('input').attr("checked",true); 1086 1087 //fixing strange bug with predefined radio value and riggering click event 1088 var val = $(this).prev('input').val(); 1089 var name = $(this).prev('input').attr("name"); 1090 name = name.replace('remove_this_part',''); 1091 $(this).parents('.creative_radio').find('.bug_fixer').remove(); 1092 var radio_new_val_input_html = '<input class="bug_fixer" type="hidden" name="' + name + '" value="' + val + '" />'; 1093 $(this).parents('.creative_radio').find('.creativecontactform_field_name').after(radio_new_val_input_html); 1094 1095 1096 $('.a_' + uniq_index).removeClass('twoglux_checked'); 1097 $(this).addClass('twoglux_checked'); 1098 1099 $('.a_' + uniq_index).not($(this)).find('.radio_part1').fadeTo(creativeanimatetime, 0); 1100 $(this).find('.radio_part1').fadeTo(creativeanimatetime, 1); 1101 1102 var form_id = $(this).parents('.creativecontactform_wrapper').find('.v4_data').attr("form_id"); 1103 var field_id = $(this).parents('.creativecontactform_field_box').attr("field_id"); 1104 var field_val = $(this).prev('input').val(); 1105 ccf_apply_if_then_logic(form_id,field_id,field_val); 1106 } 1107 }; 1108 1109 last_event_radio = 'up'; 1110 body_mouse_up_enabled = false; 1111 1112 validate_radio($(this).parents('.creativecontactform_field_box'),false); 1113 });
1114 //////////////////////////////////////////////////////////////OTHER//////////////////////////////////////////////////////////////////////////////// 1115 //fixing bug in firefox 1116 $('.creativeform_twoglux_styled_input_wrapper').bind("dragstart", function() { 1117 return false; 1118 }); 1119 $("body").on('mouseup',function() { 1120 if(body_mouse_up_enabled) { 1121 //checkbox 1122 var $elems = $('.creativeform_twoglux_styled_element').not('.twoglux_checked').find('.checkbox_part1'); 1123 animate_checkbox1_up($elems); 1124 1125 var $elems = $('.creativeform_twoglux_styled_element.twoglux_checked').find('.checkbox_part2'); 1126 animate_checkbox2_up($elems); 1127 1128 var $elems = $('.creativeform_twoglux_styled_element').not('.twoglux_checked').find('.radio_part1'); 1129 $elems.fadeTo(creativeanimatetime, 0); 1130 } 1131 }); 1132 1133 //trigger events for label 1134 $('.twoglux_label').on('mouseenter', function() { 1135 var uniq_index = $(this).attr("uniq_index"); 1136 make_mouseenter($("#creativeform_twoglux_styled_" + uniq_index)); 1137 }); 1138 $('.twoglux_label').on('mouseleave',function() { 1139 var uniq_index = $(this).attr("uniq_index"); 1140 make_mouseleave($("#creativeform_twoglux_styled_" + uniq_index)); 1141 }); 1142 $('.twoglux_label').on('mousedown',function(e) { 1143 if($(e.target).hasClass('ccf_popup_link')) 1144 return; 1145 var uniq_index = $(this).attr("uniq_index"); 1146 $("#creativeform_twoglux_styled_" + uniq_index).trigger("mousedown"); 1147 }); 1148 $('.twoglux_label').on('mouseup',function(e) { 1149 if($(e.target).hasClass('ccf_popup_link')) 1150 return; 1151 var uniq_index = $(this).attr("uniq_index"); 1152 $("#creativeform_twoglux_styled_" + uniq_index).trigger("mouseup"); 1153 }); 1154 1155 //////////////////////////////////////////////////////////////CREATIVE SELECT//////////////////////////////////////////////////////////////////////////////// 1156 var selected_option_ids = Array(); 1157 $('.will_be_creative_select').each(function() { 1158 var $this = $(this); 1159 var multiple = $this.attr("multiple"); 1160 var creative_def_val = ''; 1161 var req_class = $(this).hasClass("creativecontactform_required") ? 'creativecontactform_required' : ''; 1162 var special_width = $this.attr("special_width"); 1163 var special_width_rule = special_width != '' ? 'style="width: ' + special_width + ' !important"' : ''; 1164 var select_no_match_text =$this.attr("select_no_match_text"); 1165 var show_search = $this.attr("show_search") == 'show' ? '' : 'style="display: none"'; 1166 var show_scroll_after = parseInt($this.attr("scroll_after")); 1167 1168 var select_type = multiple == 'multiple' ? 'multiple_select' : 'single_select'; 1169 1170 var form_id = $(this).parents('.creativecontactform_wrapper').find('.creativecontactform_send').attr('roll'); 1171 1172 //get options creative html 1173 var inner_htm = '<div class="creative_options_wrapper wrapper_of_' + select_type + '"><div '+ show_search +' class="creative_search"><input class="creative_search_input" type="text" value="" /><span class="creative_search_icon"> </span></div><div class="creative_scrollbar creative_scoll_inner_wrapper"><div class="creative_scrollbar_mask creative_scroll_inner"><div class="creative_select_empty_option do_not_hide_onclcik">' + select_no_match_text + ' "<span class="do_not_hide_onclcik"></span>"</div>'; 1174 $this.find('option').each(function(i) { 1175 var $opt = $(this); 1176 var htm = $opt.html(); 1177 var opt_id = $opt.attr("id"); 1178 var val = $opt.val(); 1179 if(val == 'creative_empty') 1180 creative_def_val = htm; 1181 if(val != 'creative_empty') 1182 inner_htm += '<div id="sel_' + opt_id + '" opt_id="' + opt_id + '" class="creative_select_option option_of_' + select_type + '"><span class="creative_option_state wrapper_of_' + select_type + '"> </span><span class="creative_opt_value wrapper_of_' + select_type + '">' + htm + '</span></div>'; 1183 1184 var selected = $opt.attr('selected'); 1185 if(selected == 'selected') 1186 selected_option_ids.push(opt_id); 1187 }); 1188 inner_htm += '</div><div class="creative_scrollbar_draggable"><a href="#" class="draggable"></a></div><div class="creative_clear"></div></div></div>'; 1189 1190 var creative_select_html = '<div class="creative_select creativecontactform_input_element ' + select_type + ' '+ req_class +'"><div class="ccf_select_icon closed"></div><div class="ccf_close_icon"></div><div class="creative_input_dummy_wrapper creative_selected_option">' + creative_def_val + '</div>' + inner_htm + '</div>'; 1191 1192 $this.after(creative_select_html); 1193 1194 $this.hide(); 1195 }); 1196 1197 setTimeout(function() { 1198 $(".creativecontactform_wrapper").each(function() { 1199 var scrollbar_popup_style = $(this).attr("scrollbar_popup_style"); 1200 var scrollbar_content_style = $(this).attr("scrollbar_content_style"); 1201 1202 $(".creative_scrollbar").mCustomScrollbar({ 1203 mouseWheel:{ 1204 enable:true 1205 }, 1206 scrollButtons:{ 1207 enable:true 1208 }, 1209 theme:scrollbar_popup_style 1210 }); 1211 $(".creative_content_scrollbar").mCustomScrollbar({ 1212 mouseWheel:{ 1213 enable:true 1214 }, 1215 scrollButtons:{ 1216 enable:true 1217 }, 1218 theme:scrollbar_content_style 1219 }); 1220 }); 1221 },150); 1222 1223 setTimeout(function() { 1224 $('.creative_select').each(function() { 1225 generate_max_height($(this)); 1226 });
1227 },50); 1228 1229 function generate_max_height($elem) { 1230 var show_scroll_after = parseInt($elem.prev('select').attr("scroll_after")); 1231 $elem.find('.creative_options_wrapper').css({'visibility':'hidden','display':'block'}); 1232 1233 var h = $elem.find('.creative_select_option:first').height(); 1234 var p_top = parseFloat($elem.find('.creative_select_option:first').css('padding-top')); 1235 var p_bottom = parseFloat($elem.find('.creative_select_option:first').css('padding-bottom')); 1236 var total_h = show_scroll_after * (h + 1*p_top + 1*p_bottom); 1237 $elem.find('.creative_scoll_inner_wrapper').css({'max-height':total_h}); 1238 1239 $elem.find('.creative_options_wrapper').css({'visibility':'visible','display':'none'}); 1240 }; 1241 1242 1243 setTimeout(function() { 1244 for(var tt in selected_option_ids) { 1245 if(typeof(selected_option_ids[tt]) !== "function") { 1246 $("#sel_" + selected_option_ids[tt]).trigger("click"); 1247 } 1248 } 1249 },10); 1250 1251 $("body").click(function(e) { 1252 if(! $(e.target).hasClass('creative_selected_option') && ! $(e.target).hasClass('ccf_close_icon') && ! $(e.target).hasClass('option_of_multiple_select') && ! $(e.target).hasClass('wrapper_of_multiple_select') && ! $(e.target).hasClass('ccf_select_icon') && ! $(e.target).hasClass('creative_search') && ! $(e.target).hasClass('creative_search_input') && ! $(e.target).hasClass('do_not_hide_onclcik') && ! $(e.target).hasClass('mCSB_buttonDown') && ! $(e.target).hasClass('mCSB_buttonUp') && ! $(e.target).hasClass('mCSB_dragger_bar') && ! $(e.target).hasClass('mCSB_draggerContainer') && ! $(e.target).hasClass('mCustomScrollBox') && ! $(e.target).hasClass('mCSB_dragger') && ! $(e.target).hasClass('mCSB_draggerRail') && ! $(e.target).hasClass('creative_scrollbar')) { 1253 close_creative_options($('.creative_select')); 1254 } 1255 }); 1256 var allow_add_closed = true; 1257 $('.creative_select .creative_input_dummy_wrapper,.creative_select .ccf_select_icon').on('click', function() { 1258 var $elem = $(this).parents('.creative_select'); 1259 if($elem.hasClass('opened')) { 1260 allow_add_closed = false; 1261 close_creative_options($elem); 1262 } 1263 else { 1264 $('.creative_select.opened').removeClass('focused').removeClass('opened').find('.ccf_select_icon').removeClass('opened').addClass('closed').parents('.creative_select').find('.creative_options_wrapper').hide(); 1265 open_creative_options($elem); 1266 1267 $('.creative_search_input').focus(); 1268 } 1269 }); 1270 1271 $(window).scroll(function() { 1272 replace_creative_optios_wrapper($('.creative_select.opened')); 1273 }); 1274 $(window).resize(function() { 1275 replace_creative_optios_wrapper($('.creative_select.opened')); 1276 }); 1277 1278 function replace_creative_optios_wrapper($elem) { 1279 var offset = $elem.offset(); 1280 if(offset == null) 1281 return; 1282 var offset_top = parseFloat(offset.top); 1283 var scroll_top = parseFloat($(window).scrollTop()); 1284 var w_h = parseFloat($(window).height()); 1285 var offset_bottom = w_h - 33 - (offset_top - scroll_top); 1286 1287 if($elem.find('.creative_options_wrapper').css('display') == 'none') { 1288 $elem.find('.creative_options_wrapper').css({'visibility':'hidden','display':'block'}); 1289 var elem_h = parseFloat($elem.find('.creative_options_wrapper').height()) + 2*1; 1290 $elem.find('.creative_options_wrapper').css({'visibility':'visible','display':'none'}); 1291 } 1292 else { 1293 var elem_h = parseFloat($elem.find('.creative_options_wrapper').height()) + 2*1; 1294 }; 1295 1296 if(offset_bottom > elem_h + 10*1) { 1297 $elem.find('.creative_options_wrapper').css({'top':'100%','bottom':'auto'}); 1298 } 1299 else { 1300 $elem.find('.creative_options_wrapper').css({'bottom':'100%','top':'auto'}); 1301 } 1302 }; 1303 1304 function open_creative_options($elem) { 1305 $elem.addClass('opened'); 1306 $elem.removeClass('closed'); 1307 $elem.addClass('focused'); 1308 $elem.find('.ccf_select_icon').removeClass('closed').addClass('opened'); 1309 1310 replace_creative_optios_wrapper($elem); 1311 $elem.find('.creative_options_wrapper').stop().fadeIn(400); 1312 }; 1313 function close_creative_options($elem) { 1314 if(allow_add_closed) 1315 $elem.addClass('closed'); 1316 $elem.removeClass('opened'); 1317 $elem.removeClass('focused'); 1318 $elem.find('.ccf_select_icon').removeClass('opened').addClass('closed'); 1319 setTimeout(function() { 1320 allow_add_closed = true; 1321 $elem.removeClass('closed'); 1322 },500); 1323 1324 $elem.find('.creative_options_wrapper').stop().fadeOut(400); 1325 }; 1326 1327 //single select options check, uncheck 1328 $(".single_select .creative_select_option").on('click', function() { 1329 if(!$(this).hasClass('selected')) { 1330 var select_original = $(this).parents('.creative_select').prev('select'); 1331 select_original.find('option').removeAttr('selected'); 1332 var id = $(this).attr("opt_id"); 1333 $("#" + id).prop("selected",true); 1334 var sel_val = $("#" + id).val(); 1335 select_original.val(sel_val); 1336 $(this).parent('div').find('.creative_select_option').removeClass('selected'); 1337 $(this).addClass('selected'); 1338 1339 var val = $(this).find('.creative_opt_value').html(); 1340 val = val.replace('<b>',''); 1341 val = val.replace('</b>',''); 1342 $(this).parents('.creative_select ').find('.creative_selected_option').html(val); 1343 $(this).parents('.creative_select ').find('.ccf_close_icon').show(); 1344 1345 validate_select($(this).parents('.creative_select'),false); 1346 1347 1348 var form_id = $(this).parents('.creativecontactform_wrapper').find('.v4_data').attr("form_id"); 1349 var field_id = $(this).parents('.creativecontactform_field_box').attr("field_id"); 1350 var field_val = $("#" + id).val(); 1351 ccf_apply_if_then_logic(form_id,field_id,field_val); 1352 } 1353 else { 1354 return; 1355 } 1356 }); 1357 //multiple select options check, uncheck 1358 $(".multiple_select .creative_select_option").on('click', function() { 1359 if(!$(this).hasClass('selected')) { 1360 var select_original = $(this).parents('.creative_select').prev('select'); 1361 var id = $(this).attr("opt_id"); 1362 // $("#" + id).attr("selected","selected"); 1363 $(this).addClass('selected'); 1364 1365 make_multiple_select_value($(this).parents('.creative_select')); 1366 } 1367 else { 1368 var select_original = $(this).parent('div').parent('div').prev('select'); 1369 var id = $(this).attr("opt_id"); 1370 // $("#" + id).removeAttr("selected"); 1371 $(this).removeClass('selected'); 1372 1373 var val = $(this).find('.creative_opt_value').html(); 1374 $(this).parents('.creative_select').find('.creative_selected_option').html(val); 1375 1376 make_multiple_select_value($(this).parents('.creative_select')); 1377 } 1378 validate_multiple_select($(this).parents('.creative_select'),false); 1379 }); 1380 1381 function make_multiple_select_value($elem) { 1382 var count = 0; 1383 var count_selected = $elem.find('.creative_select_option.selected').length; 1384 var selected_text = ''; 1385 $elem.prev('select').find('option').removeAttr('selected'); 1386 1387 $elem.find('.creative_select_option.selected').each(function() { 1388 var id = $(this).attr("opt_id"); 1389 var val = $(this).find('.creative_opt_value').html(); 1390 val = val.replace('<b>',''); 1391 val = val.replace('</b>',''); 1392 $("#" + id).prop("selected",true); 1393 selected_text += val; 1394 if(count != count_selected - 1) 1395 selected_text += ', '; 1396 1397 $elem.find('.creative_selected_option').html(selected_text); 1398 count ++; 1399 1400 var form_id = $elem.parents('.creativecontactform_wrapper').find('.v4_data').attr("form_id"); 1401 var field_id = $elem.parents('.creativecontactform_field_box').attr("field_id"); 1402 var field_val = $("#" + id).val(); 1403 ccf_apply_if_then_logic(form_id,field_id,field_val); 1404 });
1405 if(count == 0) { 1406 $elem.prev('select').find('option').removeAttr('selected'); 1407 $elem.prev('select').find('.def_value').prop("selected",true); 1408 var def_val = $elem.prev('select').find('.def_value').html(); 1409 $elem.find('.creative_selected_option').html(def_val); 1410 }; 1411 }; 1412 1413 $('.ccf_close_icon').on('click', function() { 1414 allow_add_closed = false; 1415 $(this).parents('.creative_select').prev('select').find('option').removeAttr('selected'); 1416 $(this).parents('.creative_select').prev('select').find('.def_value').attr('selected','selected'); 1417 var def_val = $(this).parents('.creative_select').prev('select').find('.def_value').html(); 1418 $(this).parents('.creative_select').find('.creative_selected_option').html(def_val); 1419 $(this).parents('.creative_select').find('.creative_select_option').removeClass('selected'); 1420 $(this).hide(); 1421 validate_select($(this).parents('.creative_select'),false); 1422 }); 1423 1424 $('.creative_search_input').on('keyup',function() { 1425 var val = $.trim($(this).val()); 1426 if(val == '') { 1427 make_search($(this).parents('.creative_select'),val); 1428 return; 1429 } 1430 else { 1431 make_search($(this).parents('.creative_select'),val); 1432 }; 1433 }); 1434 1435 $('.creative_search_input').on('focus', function() { 1436 $(this).parent('div').addClass('focused'); 1437 }); 1438 $('.creative_search_input').on('blur', function() { 1439 $(this).parent('div').removeClass('focused'); 1440 }); 1441 1442 function escapeRegExp(str) { 1443 return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); 1444 }; 1445 1446 function make_search($elem,val) { 1447 var c = 0; 1448 $elem.find('.creative_select_option').each(function() { 1449 var val_1 = $(this).find('.creative_opt_value').html(); 1450 val_1 = val_1.replace('<b>',''); 1451 val_1 = val_1.replace('</b>',''); 1452 var escaped_val = escapeRegExp(val); 1453 var pattern = new RegExp('^' + escaped_val + '| ' + escaped_val,'gi'); 1454 if(pattern.test(val_1)) { 1455 1456 var val_lc = val.toLowerCase(); 1457 var val_1_lc = val_1.toLowerCase(); 1458 var start_pos = parseInt(val_1_lc.indexOf(val_lc)); 1459 var end_pos = start_pos + parseInt(val_lc.length) + 3*1; 1460 1461 var new_val = val_1.substr(0, start_pos) + '<b>' + val_1.substr(start_pos); 1462 new_val = new_val.substr(0, end_pos) + '</b>' + new_val.substr(end_pos); 1463 1464 $(this).find('.creative_opt_value ').html(new_val); 1465 $(this).show(); 1466 c ++; 1467 } 1468 else { 1469 $(this).removeClass('selected'); 1470 $(this).hide(); 1471 } 1472 }); 1473 if(c == 0) { 1474 $elem.find('.creative_select_empty_option').show().find('span').html(val); 1475 } 1476 else { 1477 $elem.find('.creative_select_empty_option').hide(); 1478 }; 1479 // make_scrolling($elem); 1480 make_multiple_select_value($elem); 1481 }; 1482 1483/////////////////////////////////////////////////////////////////////////CREATIVE CAPTCHA////////////////////////////////////////////////////////// 1484 1485 $('.reload_creative_captcha').click(function(e) { 1486 var fid = $(this).attr('fid'); 1487 var captcha_path = creativecontactform_juri + '/components/com_creativecontactform/captcha.php?fid=' + fid + '&r=' + Math.random(); 1488 var holder = $(this).attr('holder'); 1489 $(this).prev('img').attr('src',captcha_path); 1490 1491 if (e.originalEvent !== undefined) { 1492 $(this).parents('.creativecontactform_field_box').find('input.creative_captcha:last').focus(); 1493 } 1494 }); 1495/////////////////////////////////////////////////////////////////////////CREATIVE UPLOAD////////////////////////////////////////////////////////// 1496 $('.creative_fileupload_submit').mousedown(function() { 1497 var upload_maxfilesize = parseFloat($(this).parents('.creative_fileupload_wrapper').find('.creative_upload_info').attr("upload_maxfilesize")) * 1048576; 1498 var upload_minfilesize = parseFloat($(this).parents('.creative_fileupload_wrapper').find('.creative_upload_info').attr("upload_minfilesize")); 1499 var upload_acceptfiletypes = $(this).parents('.creative_fileupload_wrapper').find('.creative_upload_info').attr("upload_acceptfiletypes"); 1500 var upload_acceptfiletypes_final = '(\.|\/)(' + upload_acceptfiletypes + ')$'; 1501 var upload_acceptfiletypes_final_pattern = new RegExp(upload_acceptfiletypes_final,'i'); 1502 var upload_url = creativecontactform_juri + '/index.php?option=com_creativecontactform&view=creativeupload&format=raw'; 1503 $(this).fileupload({ 1504 minFileSize: upload_minfilesize, 1505 maxFileSize: upload_maxfilesize, 1506 acceptFileTypes: upload_acceptfiletypes_final_pattern, 1507 url: upload_url, 1508 dataType: 'json' 1509 }); 1510 }); 1511 1512 $('.creative_fileupload_submit').on('fileuploaddone', function (e, data) { 1513 var $uploaded_files_wrapper = $(this).parents('.creative_fileupload_wrapper').find('.creative_uploaded_files'); 1514 $.each(data.result.files, function (index, file) { 1515 var size_unit = 'MB'; 1516 var size_formated = file.size / 1048576; 1517 if(size_formated < 1) { 1518 size_formated = size_formated * 1024; 1519 size_unit = 'KB'; 1520 }; 1521 size_formated = size_formated.toFixed(1); 1522 var inner_htm = '<div class="creative_uploaded_file_item" ><input type="hidden" class="creative_active_upload" name="creativecontactform_upload[]" value="'+ file.name +'" /><div class="creative_uploaded_icon"></div><div class="creative_uploaded_file">'+ file.name + ' (' + size_formated + size_unit + ')</div><div class="creative_remove_uploaded"></div></div>'; 1523 $uploaded_files_wrapper.append(inner_htm); 1524 }); 1525 1526 var $progress_wrapper = $(this).parents('.creative_fileupload_wrapper').find('.creative_progress'); 1527 setTimeout(function() { 1528 $progress_wrapper.animate({'height': 0},600); 1529 $progress_wrapper.find('.bar').css({'width': 0}); 1530 validate_file_upload($uploaded_files_wrapper.parents('.creative_file-upload'),false); 1531 },2000); 1532 1533 $('.creative_remove_uploaded').on('click', function() { 1534 $(this).parent('.creative_uploaded_file_item').animate({'height': 0}, function() {$(this).hide();}); 1535 var removed_input_name = 'creativecontactform_removed_upload[]'; 1536 $(this).parent('.creative_uploaded_file_item').find('.creative_active_upload').addClass('creative_removed_upload').removeClass('creative_active_upload').attr("name",removed_input_name); 1537 validate_file_upload($(this).parents('.creative_file-upload'),false); 1538 }); 1539 }).on('fileuploadprocessalways', function (e, data) { 1540 var index = data.index, 1541 file = data.files[index], 1542 original_error_message = ''; 1543 if (file.error) { 1544 if(file.error == 'error_message_file_types') 1545 original_error_message = $(this).parents('.creative_fileupload_wrapper').find('.creative_upload_info').attr("upload_acceptfiletypes_message"); 1546 else if(file.error == 'error_message_file_large') 1547 original_error_message = $(this).parents('.creative_fileupload_wrapper').find('.creative_upload_info').attr("upload_maxfilesize_message"); 1548 else if(file.error == 'error_message_file_small') 1549 original_error_message = $(this).parents('.creative_fileupload_wrapper').find('.creative_upload_info').attr("upload_minfilesize_message"); 1550 1551 var form_id = $(this).parents('.creativecontactform_wrapper').find('.creativecontactform_form_id').val(); 1552 ccf_make_alert(original_error_message,'creative_error',form_id); 1553 }; 1554 }).on('fileuploadprogressall', function (e, data) { 1555 var $progress_wrapper = $(this).parents('.creative_fileupload_wrapper').find('.creative_progress'); 1556 var progress = parseInt(data.loaded / data.total * 100, 10); 1557 $progress_wrapper.find('.bar').css( 1558 'width', 1559 progress + '%' 1560 ); 1561 }).on('fileuploadstart', function (e, data) { 1562 var $progress_wrapper = $(this).parents('.creative_fileupload_wrapper').find('.creative_progress'); 1563 $progress_wrapper.animate({'height': 15},600); 1564 }).on('fileuploadfail', function (e, data) { 1565 console.log(data); 1566 console.log(data.result); 1567 1568 var form_id = $(this).parents('.creativecontactform_wrapper').find('.creativecontactform_form_id').val(); 1569 ccf_make_alert('Error uploading file','creative_error',form_id); 1570 });
1571 1572/////////////////////////////////////////////////////////////////////////////////////CREATIVE Datepicker//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 1573 $( ".creative_datepicker").each(function() { 1574 var $this = $(this); 1575 1576 //get options 1577 var $options_element = $this.parent('div'); 1578 1579 var datepicker_date_format = $options_element.attr("datepicker_date_format"); 1580 var datepicker_animation = $options_element.attr("datepicker_animation"); 1581 var datepicker_style = 'creative_datepicker_style_' + parseInt($options_element.attr("datepicker_style")); 1582 var datepicker_icon_style = $options_element.attr("datepicker_icon_style"); 1583 var datepicker_show_icon = $options_element.attr("datepicker_show_icon"); 1584 var datepicker_input_readonly = $options_element.attr("datepicker_input_readonly"); 1585 var datepicker_number_months = parseInt($options_element.attr("datepicker_number_months")); 1586 var datepicker_mindate = $options_element.attr("datepicker_mindate"); 1587 var datepicker_maxdate = $options_element.attr("datepicker_maxdate"); 1588 var datepicker_changemonths = parseInt($options_element.attr("datepicker_changemonths")) == 0 ? false : true; 1589 var datepicker_changeyears = parseInt($options_element.attr("datepicker_changeyears")) == 0 ? false : true; 1590 var datepicker_juri = $options_element.attr("juri"); 1591 var datepicker_img = datepicker_juri + '/components/com_creativecontactform/assets/images/datepicker/style-' + datepicker_icon_style + '.png'; 1592 1593 var show_on = datepicker_show_icon == 0 ? 'focus' : (datepicker_input_readonly == 0 ? 'both' : 'both'); 1594 1595 var patt = new RegExp("^[0-9]{4}:[0-9]{4}$", "i"); 1596 var dateRangeExists = patt.test(datepicker_mindate); 1597 var yearRange = dateRangeExists ? datepicker_mindate : ''; 1598 datepicker_mindate = dateRangeExists ? '' : datepicker_mindate; 1599 1600 //add datepicker 1601 if(yearRange == '') { 1602 $this.datepicker( 1603 { 1604 showOtherMonths: true, 1605 selectOtherMonths: false, 1606 changeMonth: datepicker_changemonths, 1607 changeYear: datepicker_changeyears, 1608 minDate: datepicker_mindate, 1609 maxDate: datepicker_maxdate, 1610 showAnim: datepicker_animation, 1611 dateFormat: datepicker_date_format, 1612 numberOfMonths: datepicker_number_months, 1613 showOn: show_on, 1614 buttonImage: datepicker_img, 1615 buttonImageOnly: true, 1616 buttonText: "Select date", 1617 beforeShow: function(input, inst) { 1618 var wrp_count = $('#ui-datepicker-div').parent('.creative_datepicker_wrapper').length; 1619 if(wrp_count == 0) 1620 $('#ui-datepicker-div').wrap('<div class="creative_datepicker_wrapper ' + datepicker_style + '"></div>') 1621 } 1622 }); 1623 } 1624 else { 1625 $this.datepicker( 1626 { 1627 showOtherMonths: true, 1628 selectOtherMonths: false, 1629 changeMonth: datepicker_changemonths, 1630 changeYear: datepicker_changeyears, 1631 yearRange: yearRange, 1632 minDate: datepicker_mindate, 1633 maxDate: datepicker_maxdate, 1634 showAnim: datepicker_animation, 1635 dateFormat: datepicker_date_format, 1636 numberOfMonths: datepicker_number_months, 1637 showOn: show_on, 1638 buttonImage: datepicker_img, 1639 buttonImageOnly: true, 1640 buttonText: "Select date", 1641 beforeShow: function(input, inst) { 1642 var wrp_count = $('#ui-datepicker-div').parent('.creative_datepicker_wrapper').length; 1643 if(wrp_count == 0) 1644 $('#ui-datepicker-div').wrap('<div class="creative_datepicker_wrapper ' + datepicker_style + '"></div>') 1645 } 1646 }); 1647 } 1648 }); 1649 1650/////////////////////////////////////////////////////////////////////////////////////CREATIVE tooltip//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 1651 1652 $('.creative_input_reset,.creative_textarea_reset').focus(function() { 1653 if(!$(this).hasClass('mouseentered')) 1654 $(this).trigger('mousedown'); 1655 }); 1656 1657 $('.creative_input_reset,.creative_textarea_reset').mousedown(function() { 1658 1659 $(this).addClass('mouseentered'); 1660 var $tooltip = $(this).parent('div').find('.tooltip_inner'); 1661 $tooltip.css('display','block'); 1662 setTimeout(function() { 1663 $tooltip.removeClass('creative_tooltip_ivisible'); 1664 $tooltip.addClass('cr_rotate'); 1665 },100); 1666 }); 1667 $('.creative_input_reset,.creative_textarea_reset').blur(function() { 1668 $(this).removeClass('mouseentered'); 1669 var $tooltip = $(this).parent('div').find('.tooltip_inner'); 1670 $tooltip.addClass('creative_tooltip_ivisible'); 1671 $tooltip.removeClass('cr_rotate'); 1672 setTimeout(function() { 1673 $tooltip.css('display','none'); 1674 },500); 1675 }); 1676/////////////////////////////////////////////////////////////////////////////////////CREATIVE box animations//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 1677 function create_zoom_in_animation($form) { 1678 $form.filter('.creative_wrapper_animation_state_1').addClass('creative_wrapper_animation_state_2'); 1679 $form.find('.creative_header_animation_state_1').addClass('creative_header_animation_state_2'); 1680 $form.find('.creative_field_box_animation_state_1').addClass('creative_field_box_animation_state_2'); 1681 $form.find('.creative_footer_animation_state_1').addClass('creative_footer_animation_state_2'); 1682 1683 $form.filter('.creative_wrapper_animation_state_1_short').addClass('creative_wrapper_animation_state_2_short'); 1684 $form.find('.creative_header_animation_state_1_short').addClass('creative_header_animation_state_2_short'); 1685 $form.find('.creative_field_box_animation_state_1_short').addClass('creative_field_box_animation_state_2_short'); 1686 $form.find('.creative_footer_animation_state_1_short').addClass('creative_footer_animation_state_2_short'); 1687 1688 setTimeout(function() { 1689 $form.filter('.creative_wrapper_animation_state_1').removeClass('creative_wrapper_animation_state_1').removeClass('creative_wrapper_animation_state_2'); 1690 $form.find('.creative_header_animation_state_1').removeClass('creative_header_animation_state_1').removeClass('creative_header_animation_state_2'); 1691 $form.find('.creative_field_box_animation_state_1').removeClass('creative_field_box_animation_state_1').removeClass('creative_field_box_animation_state_2'); 1692 $form.find('.creative_footer_animation_state_1').removeClass('creative_footer_animation_state_1').removeClass('creative_footer_animation_state_2'); 1693 },3000); 1694 1695 setTimeout(function() { 1696 $form.filter('.creative_wrapper_animation_state_1_short').removeClass('creative_wrapper_animation_state_1_short').removeClass('creative_wrapper_animation_state_2_short'); 1697 $form.find('.creative_header_animation_state_1_short').removeClass('creative_header_animation_state_1_short').removeClass('creative_header_animation_state_2_short'); 1698 $form.find('.creative_field_box_animation_state_1_short').removeClass('creative_field_box_animation_state_1_short').removeClass('creative_field_box_animation_state_2_short'); 1699 $form.find('.creative_footer_animation_state_1_short').removeClass('creative_footer_animation_state_1_short').removeClass('creative_footer_animation_state_2_short'); 1700 },1500); 1701 1702 } 1703 function set_zoom_in_animation($form) { 1704 $form.filter('.creativecontactform_wrapper').addClass('creative_wrapper_animation_state_1_short'); 1705 $form.find('.creativecontactform_header').addClass('creative_header_animation_state_1_short'); 1706 $form.find('.creative_field_box_wrapper').addClass('creative_field_box_animation_state_1_short'); 1707 $form.find('.creativecontactform_footer').addClass('creative_footer_animation_state_1_short'); 1708 } 1709 $('.creativecontactform_wrapper').each(function() { 1710 var $form = $(this); 1711 var render_type = $form.attr("render_type"); 1712 var $v4_data = $form.find('.v4_data'); 1713 var appear_animation_type = $v4_data.attr("appear_animation_type"); 1714 if(render_type == 0 && appear_animation_type == 1) { 1715 create_zoom_in_animation($form); 1716 } 1717 1718 // flip animation 1719 if(render_type == 0 && appear_animation_type == 2) { 1720 console.log('do it here'); 1721 $form.wrap('<div class="ccf_flip_wrapper"></div>'); 1722 1723 $form 1724 .addClass('opacity_0') 1725 .css({ 1726 '-moz-transform':'rotateY(-10deg)', 1727 '-webkit-transform':'rotateY(-10deg)', 1728 '-o-transform':'rotateY(-10deg)', 1729 'transform':'rotateY(-10deg)', 1730 'textIndent' : '-10px' 1731 }); 1732 setTimeout(function() { 1733 $form.addClass('opacity_transition'); 1734 $form.removeClass('opacity_0'); 1735 1736 $form.animate({ textIndent: 0 }, { 1737 step: function(go) { 1738 $(this).css('-moz-transform','rotateY('+go+'deg)'); 1739 $(this).css('-webkit-transform','rotateY('+go+'deg)'); 1740 $(this).css('-o-transform','rotateY('+go+'deg)'); 1741 $(this).css('transform','rotateY('+go+'deg)'); 1742 }, 1743 duration: 1500, 1744 easing: 'easeOutElastic' 1745 }); 1746 1747 },100); 1748 1749 setTimeout(function() { 1750 $('.ccf_cached_wrapper').removeClass('ccf_flip_wrapper'); 1751 $form 1752 .removeClass('opacity_0') 1753 .removeClass('opacity_transition'); 1754 },1600); 1755 } 1756 1757 1758 }) 1759 1760 1761 1762/////////////////////////////////////////////////////////////////////////Correct bugs/////////////////////////////////////////////////////////////////////////////////////////////////////////// 1763//IE bug 1764 //function to check if browser is ie, or not 1765 var is_creative_ie = (function(){ 1766 1767 var undef, 1768 v = 3, 1769 div = document.createElement('div'), 1770 all = div.getElementsByTagName('i'); 1771 1772 while ( 1773 div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->', 1774 all[0] 1775 ); 1776 1777 return v > 4 ? v : undef; 1778 1779 }()); 1780 if(is_creative_ie) { 1781 $('.creativecontactform_input_element,.creativecontactform_wrapper,.creativecontactform_send,.creativecontactform_send_new').css('border-radius','0'); 1782 }; 1783 1784 1785 $('.creative_input_reset').on('focus',function() { 1786 //check if animation enabled 1787 if($(this).parents('.creativecontactform_wrapper').attr('focus_anim_enabled') == 0) 1788 return; 1789 1790 if($(this).parents('.creativecontactform_field_box').hasClass('creativecontactform_error')) 1791 return; 1792 1793 var $label = $(this).parents('.creativecontactform_field_box').find('label'); 1794 var normal_class = $label.attr("normal_effect_class"); 1795 var hover_class = $label.attr("hover_effect_class"); 1796 var error_class = $label.attr("error_effect_class"); 1797 1798 $label.removeClass(normal_class).addClass(hover_class); 1799 }); 1800 $('.creative_textarea_reset').on('focus',function() { 1801 //check if animation enabled 1802 if($(this).parents('.creativecontactform_wrapper').attr('focus_anim_enabled') == 0) 1803 return; 1804 1805 if($(this).parents('.creativecontactform_field_box').hasClass('creativecontactform_error')) 1806 return; 1807 1808 var $label = $(this).parents('.creativecontactform_field_box').find('label'); 1809 var normal_class = $label.attr("normal_effect_class"); 1810 var hover_class = $label.attr("hover_effect_class"); 1811 var error_class = $label.attr("error_effect_class"); 1812 1813 $label.removeClass(normal_class).addClass(hover_class); 1814 }); 1815 1816 $('.creative_input_reset').on('blur',function() { 1817 //check if animation enabled 1818 if($(this).parents('.creativecontactform_wrapper').attr('focus_anim_enabled') == 0) 1819 return; 1820 1821 var $label = $(this).parents('.creativecontactform_field_box').find('label'); 1822 1823 var normal_class = $label.attr("normal_effect_class"); 1824 var hover_class = $label.attr("hover_effect_class"); 1825 var error_class = $label.attr("error_effect_class"); 1826 1827 $label.removeClass(hover_class).addClass(normal_class); 1828 }); 1829 $('.creative_textarea_reset').on('blur',function() { 1830 //check if animation enabled 1831 if($(this).parents('.creativecontactform_wrapper').attr('focus_anim_enabled') == 0) 1832 return; 1833 1834 var $label = $(this).parents('.creativecontactform_field_box').find('label'); 1835 1836 var normal_class = $label.attr("normal_effect_class"); 1837 var hover_class = $label.attr("hover_effect_class"); 1838 var error_class = $label.attr("error_effect_class"); 1839 1840 $label.removeClass(hover_class).addClass(normal_class); 1841 }); 1842 1843 function create_validation_effects($wrapper) { 1844 //check if animation enabled 1845 if($wrapper.attr('error_anim_enabled') == 0) 1846 return; 1847 1848 $wrapper.find('.creativecontactform_field_box').not('.ccf_if_then_hidden').each(function() { 1849 var $label = $(this).find('label').not('.twoglux_label'); 1850 1851 var normal_class = $label.attr("normal_effect_class"); 1852 var hover_class = $label.attr("hover_effect_class"); 1853 var error_class = $label.attr("error_effect_class"); 1854 1855 if($(this).hasClass('creativecontactform_error')) 1856 $label.removeClass(hover_class).removeClass(normal_class).addClass(error_class); 1857 else 1858 $label.removeClass(hover_class).removeClass(error_class).addClass(normal_class); 1859 }) 1860 }; 1861 1862 $('.creativecontactform_send').hover(function() { 1863 var normal_class = $(this).attr("normal_effect_class"); 1864 var hover_class = $(this).attr("hover_effect_class"); 1865 1866 $(this).removeClass(normal_class).addClass(hover_class); 1867 },function() { 1868 var normal_class = $(this).attr("normal_effect_class"); 1869 var hover_class = $(this).attr("hover_effect_class"); 1870 1871 $(this).removeClass(hover_class).addClass(normal_class); 1872 }); 1873 1874 $('.creative_fileupload').hover(function() { 1875 var normal_class = $(this).attr("normal_effect_class"); 1876 var hover_class = $(this).attr("hover_effect_class"); 1877 $(this).removeClass(normal_class).addClass(hover_class); 1878 },function() { 1879 var normal_class = $(this).attr("normal_effect_class"); 1880 var hover_class = $(this).attr("hover_effect_class"); 1881 $(this).removeClass(hover_class).addClass(normal_class); 1882 }); 1883
1884/////////////////////////////////////////////////////////////////////////////////////CREATIVE ALERT//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 1885 //alert box //////////////////////////////////////////////////////////////////////////////////////// 1886 //function to create shadow 1887 function ccf_create_shadow() { 1888 var $shadow = '<div id="creative_shadow"></div>'; 1889 $('body').css('position','relative').append($shadow); 1890 var w_width = parseInt($(window).width()); 1891 var w_height = parseInt($(window).height()); 1892 1893 $("#creative_shadow") 1894 .css( { 1895 'position' : 'fixed', 1896 'top' : '0', 1897 'right' : '0', 1898 'bottom' : '0', 1899 'left' : '0', 1900 'z-index' : '10000', 1901 'opacity' : '0', 1902 'width' : w_width + 'px', 1903 'height' : w_height + 'px', 1904 'backgroundColor' : '#000' 1905 }) 1906 .fadeTo(200,'0.7'); 1907 }; 1908 1909 function ccf_resize_shadow() { 1910 if($('#creative_shadow').length == 0) 1911 return; 1912 1913 var w_width = parseInt($(window).width()); 1914 var w_height = parseInt($(window).height()); 1915 1916 $("#creative_shadow") 1917 .css( { 1918 'width' : w_width + 'px', 1919 'height' : w_height + 'px' 1920 }) 1921 } 1922 1923 function ccf_make_alert(txt,type,form_id) { 1924 //create shadow 1925 ccf_create_shadow(); 1926 var close_text = close_alert_text[form_id]; 1927 1928 //make alert 1929 var $alert_body = '<div id="creative_alert_wrapper"><div id="creative_alert_body" class="' + type + '">' + txt + '</div><input type="button" id="close_creative_alert" value="'+ close_text +'" /></div>'; 1930 $('body').append($alert_body); 1931 var scollTop = $(window).scrollTop(); 1932 var w_width = $(window).width(); 1933 var w_height = $(window).height(); 1934 var s_height = $("#creative_alert_wrapper").height(); 1935 1936 var alert_left = (w_width - 420) / 2; 1937 var alert_top = (w_height - s_height) / 2; 1938 1939 $("#creative_alert_wrapper") 1940 .css( { 1941 'top' : -1 * (s_height + 55 * 1) + scollTop * 1, 1942 'left' : alert_left 1943 }) 1944 .stop() 1945 .animate({ 1946 'top' : alert_top + scollTop * 1 1947 },450,'easeOutBack',function() { 1948 //$(this).css('position','fixed'); 1949 }); 1950 }; 1951 1952 function ccf_remove_alert_box() { 1953 if($('#creative_alert_wrapper').length == 0) 1954 return; 1955 1956 setTimeout(function() { 1957 var popup_form_exists = $('.ccf_popup_form').length; 1958 var popup_form_visible = false; 1959 $('.ccf_popup_form').each(function() { 1960 var popup_top = parseInt($(this).css('top')); 1961 if(popup_top != -100000) { 1962 popup_form_visible = true; 1963 return false; 1964 } 1965 }); 1966 1967 // var chat_form_exists = $('.ccf_chat_form').length; 1968 // var chat_bottom = parseInt($('.ccf_chat_form').css('bottom')); 1969 // var chat_form_visible = chat_bottom == 0 ? true : false; 1970 1971 // var static_form_exists = $('.ccf_static_form').length; 1972 // var static_left = parseInt($('.ccf_static_form').css('left')); 1973 // var static_right = parseInt($('.ccf_static_form').css('right')); 1974 // var static_form_visible = static_left > 0 || static_right ? false : true; 1975 1976 if 1977 ( 1978 (!popup_form_exists || (popup_form_exists && !popup_form_visible)) 1979 1980 ) 1981 $("#creative_shadow").stop().fadeTo(200,0,function() {$(this).remove();}); 1982 },10); 1983 1984 $("#creative_alert_wrapper").stop().fadeTo(200,0,function() {$(this).remove();}); 1985 }; 1986 1987 function ccf_move_alert_box() { 1988 if($('#creative_alert_wrapper').length == 0) 1989 return; 1990 1991 var scollTop = $(window).scrollTop(); 1992 var w_width = $(window).width(); 1993 var w_height = $(window).height(); 1994 var s_height = $("#creative_alert_wrapper").height(); 1995 1996 1997 var alert_left = (w_width - 420) / 2; 1998 var alert_top = (w_height - s_height) / 2; 1999 2000 $("#creative_alert_wrapper") 2001 .stop() 2002 .animate({ 2003 'top' : alert_top + scollTop * 1, 2004 'left' : alert_left 2005 },450,'easeOutBack',function() { 2006 //$(this).css('position','fixed'); 2007 }); 2008 }; 2009 2010 $(document).on('click','#close_creative_alert,#creative_shadow', function() { 2011 2012 ccf_remove_alert_box(); 2013 }); 2014 2015 $(window).resize(function() { 2016 ccf_resize_shadow(); 2017 ccf_move_alert_box(); 2018 ccf_move_popup_box(); 2019 }); 2020 $(window).scroll(function() { 2021 ccf_move_alert_box(); 2022 ccf_move_popup_box(); 2023 }); 2024
2025////////////////////////////////////////////// creative popup ////////////////////////////////////////////////////////// 2026 $(".ccf_popup_link").click(function() { 2027 var form_id = $(this).parents('.creativecontactform_wrapper').find('.creativecontactform_send').attr("roll"); 2028 var popup_id = parseInt($(this).attr("popup_id")); 2029 var popup_w = parseInt($(this).attr("w")); 2030 var popup_h = parseInt($(this).attr("h")); 2031 ccf_make_popup(popup_id,popup_w,popup_h,form_id); 2032 }); 2033 2034 function ccf_make_popup(popup_id,popup_w,popup_h,form_id) { 2035 //create shadow 2036 ccf_create_shadow(); 2037 2038 //make popup 2039 var popup_html = $("#popup_" + popup_id).html(); 2040 var $popup_body = '<div id="creative_popup_wrapper" style="width: ' + popup_w + 'px;height: ' + popup_h + 'px;"><div class="ccf_close_popup"><div class="ccf_close_popup_icon"></div><div class="ccf_close_popup_bg"></div></div><div class="ccf_popup_inner_wrapper creative_form_' + form_id + '">' + popup_html + '</div></div>'; 2041 $('body').append($popup_body); 2042 2043 var scrollbar_popup_style = $(".creativecontactform_wrapper.creative_form_" + form_id).attr("scrollbar_popup_style"); 2044 2045 $(".ccf_popup_inner_wrapper").mCustomScrollbar({ 2046 mouseWheel:{ 2047 enable:true 2048 }, 2049 scrollButtons:{ 2050 enable:true 2051 }, 2052 theme:scrollbar_popup_style 2053 }); 2054 2055 var scollTop = $(window).scrollTop(); 2056 var w_width = $(window).width(); 2057 var w_height = $(window).height(); 2058 2059 var alert_left = (w_width - popup_w) / 2; 2060 var alert_top = (w_height - popup_h) / 2; 2061 2062 alert_left = alert_left < 0 ? 0 : alert_left; 2063 alert_top = alert_top < 0 ? 0 : alert_top; 2064 2065 if(alert_left == 0 || alert_top == 0) { 2066 $("#creative_popup_wrapper").addClass('disableScroll'); 2067 } 2068 2069 $("#creative_popup_wrapper") 2070 .css( { 2071 'top' : -1 * (popup_h + 55 * 1) + scollTop * 1, 2072 'left' : alert_left 2073 }) 2074 .stop() 2075 .animate({ 2076 'top' : alert_top + scollTop * 1 2077 },450,'easeOutBack',function() { 2078 //$(this).css('position','fixed'); 2079 2080 }); 2081 }; 2082 2083 function ccf_move_popup_box() { 2084 if($('#creative_shadow').length == 0) 2085 return; 2086 2087 var scollTop = $(window).scrollTop(); 2088 var w_width = $(window).width(); 2089 var w_height = $(window).height(); 2090 var popup_w = $("#creative_popup_wrapper").width(); 2091 var popup_h = $("#creative_popup_wrapper").height(); 2092 2093 var alert_left = (w_width - popup_w) / 2; 2094 var alert_top = (w_height - popup_h) / 2; 2095 2096 alert_left = alert_left < 0 ? 0 : alert_left; 2097 alert_top = alert_top < 0 ? 0 : alert_top; 2098 2099 if(!$("#creative_popup_wrapper").hasClass('disableScroll')) { 2100 $("#creative_popup_wrapper") 2101 .stop() 2102 .animate({ 2103 'top' : alert_top + scollTop * 1, 2104 'left' : alert_left 2105 },450,'easeOutBack',function() { 2106 //$(this).css('position','fixed'); 2107 }); 2108 } 2109 2110 if(alert_left == 0 || alert_top == 0) { 2111 $("#creative_popup_wrapper").addClass('disableScroll'); 2112 } 2113 else 2114 $("#creative_popup_wrapper").removeClass('disableScroll'); 2115 }; 2116 2117 function ccf_remove_popup_box() { 2118 if($('#creative_shadow').length == 0) 2119 return; 2120 2121 setTimeout(function() { 2122 var popup_form_exists = $('.ccf_popup_form').length; 2123 var popup_form_visible = false; 2124 $('.ccf_popup_form').each(function() { 2125 var popup_top = parseInt($(this).css('top')); 2126 if(popup_top != -100000) { 2127 popup_form_visible = true; 2128 return false; 2129 } 2130 }); 2131 2132 if( (!popup_form_exists || (popup_form_exists && !popup_form_visible)) ) 2133 $("#creative_shadow").stop().fadeTo(200,0,function() {$(this).remove();}); 2134 },10); 2135 2136 $("#creative_popup_wrapper").stop().fadeTo(200,0,function() {$(this).remove();}); 2137 }; 2138 2139 $(document).on('click','.ccf_close_popup,#creative_shadow', function() { 2140 ccf_remove_popup_box(); 2141 }); 2142 2143 // version 4.0 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 2144 2145 $(".creativecontactform_wrapper").each(function() { 2146 var $form_wrapper = $(this); 2147 var render_type = parseInt($form_wrapper.attr("render_type")); 2148 if(render_type == 0) { // static 2149 return; 2150 } 2151 else if(render_type == 1 || render_type == 2 || render_type == 3 || render_type == 4) { // popup button 2152 var $cached_form = $form_wrapper; 2153 // $form_wrapper.remove(); 2154 2155 // render static button ************************************************************************************* 2156 // render static button ************************************************************************************* 2157 if(render_type == 3) { 2158 var $v4_data = $cached_form.find('.v4_data'); 2159 2160 // get data 2161 var popup_button_text = $v4_data.attr("popup_button_text"); 2162 var static_button_position = $v4_data.attr("static_button_position"); 2163 var static_button_offset = $v4_data.attr("static_button_offset"); 2164 var form_id = $v4_data.attr("form_id"); 2165 var form_w = $v4_data.attr("form_w"); 2166 2167 // chek for width 2168 if(form_w.indexOf('%') !== -1) { 2169 var fixed_w = 450;
2170 $cached_form.attr("style","width: " + fixed_w + "px !important"); 2171 } 2172 var form_w_final = $cached_form.width() + 50*1; 2173 // alert(form_w_final); 2174 2175 // create button 2176 var ccf_static_popup_button = '<div class="ccf_static_button ccf_static_button_hidden_'+static_button_position+' ccf_static_button_'+form_id+' ccf_button_align_'+static_button_position+'" form_id="'+form_id+'" style="top: '+static_button_offset+';">'+popup_button_text+'</div>'; 2177 2178 // add button to html 2179 $("body").append(ccf_static_popup_button); 2180 2181 setTimeout(function() { 2182 $('.ccf_static_button').removeClass('ccf_static_button_hidden_0'); 2183 $('.ccf_static_button').removeClass('ccf_static_button_hidden_1'); 2184 },1500); 2185 2186 $('.ccf_static_button').attr("offset_index", form_w_final) 2187 2188 // add cached form 2189 if (!$('.ccf_cached_wrapper').length){ 2190 var ccf_cached_wrapper = '<div class="ccf_cached_wrapper"></div>'; 2191 $("body").append(ccf_cached_wrapper); 2192 } 2193 $('.ccf_cached_wrapper').append($cached_form); 2194 2195 var form_align_index = static_button_position == 0 ? 'left' : 'right'; 2196 2197 // $cached_form.addClass("ccf_static_form_hidden"); 2198 $cached_form.addClass('ccf_static_form'); 2199 $cached_form.css({ 2200 'top' : static_button_offset, 2201 }); 2202 if(form_align_index == 'left') { 2203 $cached_form.css({ 2204 'left' : -1 * form_w_final, 2205 }); 2206 } 2207 else { 2208 $cached_form.css({ 2209 'right' : -1 * form_w_final, 2210 }); 2211 } 2212 2213 // OPEN/CLOSE EVENTS ******************************************************************** 2214 $('.ccf_static_button_' + form_id).on('click', function() { 2215 2216 // if already opened *********************************************************** 2217 if($(this).hasClass('ccf_static_button_opened')) { 2218 if(form_align_index == 'left') { 2219 $('.creative_form_' + form_id).stop().animate({ 2220 left: -1*form_w_final 2221 },400,'swing'); 2222 } 2223 else if(form_align_index == 'right') { 2224 $('.creative_form_' + form_id).stop().animate({ 2225 right: -1*form_w_final 2226 },400,'swing'); 2227 } 2228 $(this).removeClass('ccf_static_button_opened'); 2229 } 2230 else { 2231 if(form_align_index == 'left') { 2232 $('.creative_form_' + form_id).stop().animate({ 2233 left: 0 2234 },400,'swing'); 2235 } 2236 else if(form_align_index == 'right') { 2237 $('.creative_form_' + form_id).stop().animate({ 2238 right: 0 2239 },400,'swing'); 2240 } 2241 $(this).addClass('ccf_static_button_opened'); 2242 } 2243 }) 2244 2245 } 2246 // render popup button ************************************************************************************* 2247 else if(render_type == 1 || render_type == 2) { 2248 var $v4_data = $cached_form.find('.v4_data'); 2249 2250 // get data 2251 var popup_button_text = $v4_data.attr("popup_button_text"); 2252 var form_id = $v4_data.attr("form_id"); 2253 var form_w = $v4_data.attr("form_w"); 2254 2255 // chek for width 2256 if(form_w.indexOf('%') !== -1) { 2257 var fixed_w = 500; 2258 $cached_form.attr("style","width: " + fixed_w + "px !important"); 2259 } 2260 var form_w_final = $cached_form.width(); 2261 // alert(form_w_final); 2262 2263 // create button 2264 if(render_type == 1) 2265 var ccf_popup_button = '<div class="ccf_popup_button ccf_popup_button_'+form_id+'" form_id="'+form_id+'" >'+popup_button_text+'</div>'; 2266 else if(render_type == 2) 2267 var ccf_popup_button = '<div class="ccf_popup_link ccf_popup_link_'+form_id+'" form_id="'+form_id+'" >'+popup_button_text+'</div>'; 2268 2269 // add button to html 2270 $cached_form.after(ccf_popup_button); 2271 2272 // add cached form 2273 if (!$('.ccf_cached_wrapper').length){ 2274 var ccf_cached_wrapper = '<div class="ccf_cached_wrapper"></div>'; 2275 $("body").append(ccf_cached_wrapper); 2276 } 2277 $cached_form.addClass('ccf_popup_form'); 2278 $('.ccf_cached_wrapper').append($cached_form); 2279 2280 2281 // onlcik event ***************************************************** 2282 $(".ccf_popup_button.ccf_popup_button_" + form_id).on('click',function() { 2283 ccf_show_popup_form(form_id); 2284 }); 2285 $(".ccf_popup_link.ccf_popup_link_" + form_id).on('click',function() { 2286 ccf_show_popup_form(form_id); 2287 }); 2288 2289 } 2290 // end render popup button ************************************************************************************* 2291 // render chat************************************************************************************* 2292 else if(render_type == 4) { 2293 var $v4_data = $cached_form.find('.v4_data'); 2294 2295 // get data 2296 var popup_button_text = $v4_data.attr("popup_button_text"); 2297 var static_button_position = $v4_data.attr("static_button_position"); 2298 var form_id = $v4_data.attr("form_id"); 2299 var form_w = $v4_data.attr("form_w"); 2300 2301 // chek for width 2302 if(form_w.indexOf('%') !== -1) { 2303 var fixed_w = 250;
2304 $cached_form.attr("style","width: " + fixed_w + "px !important"); 2305 } 2306 var form_w_final = $cached_form.width(); 2307 // alert(form_w_final); 2308 2309 // create button 2310 var ccf_chat_button = '<div class="ccf_chat_button_wrapper ccf_chat_align_'+static_button_position+'"><div class="ccf_chat_button ccf_chat_btn_cursor_pointer ccf_chat_button_top_30 ccf_chat_button_'+form_id+' " form_id="'+form_id+'" ><div class="ccf_chat_btn_txt">'+popup_button_text+'</div><div class="ccf_chat_btn_sign"></div></div></div>'; 2311 $("body").append(ccf_chat_button); 2312 2313 $('.ccf_chat_button').attr("btn_w",$('.ccf_chat_button').width() + 2*1); 2314 2315 $('.ccf_chat_button').addClass('ccf_chat_button_transition'); 2316 setTimeout(function() { 2317 $('.ccf_chat_button').removeClass('ccf_chat_button_top_30'); 2318 },800); 2319 2320 setTimeout(function() { 2321 $('.ccf_chat_button').removeClass('ccf_chat_button_transition'); 2322 },1300); 2323 2324 2325 2326 // add cached form 2327 if (!$('.ccf_cached_wrapper').length){ 2328 var ccf_cached_wrapper = '<div class="ccf_cached_wrapper"></div>'; 2329 $("body").append(ccf_cached_wrapper); 2330 } 2331 $cached_form.addClass('ccf_chat_form'); 2332 $cached_form.addClass('ccf_chat_align_'+static_button_position); 2333 $('.ccf_cached_wrapper').append($cached_form); 2334 2335 var form_h = parseInt($cached_form.height()) + 2*1; 2336 $cached_form 2337 .attr("form_h",form_h) 2338 .css("bottom",-1*form_h); 2339 2340 2341 // onlcik event ***************************************************** 2342 $(".ccf_chat_button.ccf_chat_button_" + form_id).on('click',function() { 2343 ccf_show_chat_form(form_id); 2344 }); 2345 2346 2347 } 2348 // end render chat************************************************************************************* 2349 } 2350 }); 2351 2352 function ccf_show_popup_form(form_id) { 2353 ccf_create_shadow(); 2354 2355 var $form = $(".ccf_popup_form.creative_form_" + form_id); 2356 var $v4_data = $form.find('.v4_data'); 2357 var appear_animation_type = $v4_data.attr("appear_animation_type"); 2358 // flip animation ********************************************************************* 2359 if(appear_animation_type == 2) { 2360 $('.ccf_cached_wrapper').addClass('ccf_flip_wrapper'); 2361 2362 $form 2363 .addClass('opacity_0') 2364 .css({ 2365 '-moz-transform':'rotateY(-10deg)', 2366 '-webkit-transform':'rotateY(-10deg)', 2367 '-o-transform':'rotateY(-10deg)', 2368 'transform':'rotateY(-10deg)', 2369 'textIndent' : '-10px' 2370 }); 2371 setTimeout(function() { 2372 $form.addClass('opacity_transition'); 2373 $form.removeClass('opacity_0'); 2374 2375 $form.animate({ textIndent: 0 }, { 2376 step: function(go) { 2377 $(this).css('-moz-transform','rotateY('+go+'deg)'); 2378 $(this).css('-webkit-transform','rotateY('+go+'deg)'); 2379 $(this).css('-o-transform','rotateY('+go+'deg)'); 2380 $(this).css('transform','rotateY('+go+'deg)'); 2381 }, 2382 duration: 1500, 2383 easing: 'easeOutElastic' 2384 }); 2385 2386 },100); 2387 2388 setTimeout(function() { 2389 $('.ccf_cached_wrapper').removeClass('ccf_flip_wrapper'); 2390 $form 2391 .removeClass('opacity_0') 2392 .removeClass('opacity_transition'); 2393 },1600); 2394 } 2395 // zoom in animation ********************************************************************* 2396 else if (appear_animation_type == 1) { 2397 setTimeout(function() { 2398 create_zoom_in_animation($form); 2399 },5); 2400 } 2401 2402 $form.addClass('no_transition'); 2403 var form_w = parseInt($form.width()); 2404 var form_h = parseInt($form.height()); 2405 2406 var body_w = parseInt($('#creative_shadow').width()); 2407 var scollTop = parseInt($(window).scrollTop()); 2408 var w_h = parseInt($(window).height()); 2409 2410 console.log(w_h) 2411 console.log(form_h) 2412 2413 var top_ofset = form_h < w_h ? ((w_h - form_h) / 2) * 0.8 : w_h * 0.05; 2414 // top_ofset = top_ofset < 0 ? (w_h - form_h) / 2 : top_ofset; 2415 2416 2417 var curr_l = (body_w - form_w) / 2; 2418 var cur_top = top_ofset + scollTop*1; 2419 $form.css( { 2420 top: cur_top, 2421 left: curr_l 2422 }); 2423 setTimeout(function() { 2424 $form.removeClass('no_transition'); 2425 },1); 2426 } 2427 2428 $(window).resize(function() { 2429 ccf_move_popup(); 2430 }); 2431 2432 function ccf_move_popup() { 2433 var popup_form_exists = $('.ccf_popup_form').length; 2434 var popup_top = parseInt($('.ccf_popup_form').css('top')); 2435 var popup_form_visible = popup_top == -100000 ? false : true; 2436 2437 if(popup_form_exists && popup_form_visible) { 2438 $form = $('.ccf_popup_form'); 2439 2440 $form.addClass('no_transition'); 2441 var form_w = parseInt($form.width()); 2442 var form_h = parseInt($form.height()); 2443 2444 var body_w = parseInt($('#creative_shadow').width()); 2445 var scollTop = parseInt($(window).scrollTop()); 2446 var w_h = parseInt($(window).height()); 2447 2448 var top_ofset = form_h < w_h ? ((w_h - form_h) / 2) * 0.8 : w_h * 0.05; 2449 // top_ofset = top_ofset < 0 ? (w_h - form_h) / 2 : top_ofset; 2450 2451 var curr_l = (body_w - form_w) / 2; 2452 var cur_top = top_ofset + scollTop*1; 2453 $form.css( { 2454 top: cur_top, 2455 left: curr_l 2456 }); 2457 setTimeout(function() { 2458 $form.removeClass('no_transition'); 2459 },1); 2460 } 2461 else { 2462 return; 2463 } 2464 } 2465 2466 function ccf_hide_popup_form() { 2467 var $forms = $('.ccf_popup_form'); 2468 if($forms.length) { 2469 $forms.each(function() { 2470 $form = $(this); 2471 $form.addClass('no_transition'); 2472 var $v4_data = $form.find('.v4_data'); 2473 var appear_animation_type = parseInt($v4_data.attr("appear_animation_type")); 2474 if(appear_animation_type == 1) { 2475 set_zoom_in_animation($form); 2476 } 2477 $form.css({ 2478 top: '-100000px', 2479 left: '-100000px' 2480 }); 2481 }) 2482 2483 } 2484 } 2485 2486 $(document).on('click','#creative_shadow', function() { 2487 ccf_hide_popup_form(); 2488 }); 2489 2490 function ccf_show_chat_form(form_id) { 2491 2492 // check if opened 2493 if($('.ccf_chat_button_' + form_id).hasClass('ccf_chat_opened')) 2494 return; 2495 2496 // make actions 2497 $('.ccf_chat_button_' + form_id).addClass('ccf_chat_opened'); 2498 $('.ccf_chat_button_' + form_id).css('top','30px').removeClass('ccf_chat_btn_cursor_pointer'); 2499 2500 // GET FORM 2501 var $form = $(".ccf_chat_form.creative_form_" + form_id); 2502 var $v4_data = $form.find('.v4_data'); 2503 2504 var form_h = $form.attr('form_h'); 2505 var form_w = $form.width(); 2506 $form.animate({ 2507 bottom: 0 2508 },400,'swing'); 2509 2510 setTimeout(function() { 2511 $('.ccf_chat_button_' + form_id).find('.ccf_chat_btn_sign').addClass('ccf_chat_hide'); 2512 $('.ccf_chat_button_wrapper').css('width',form_w); 2513 $('.ccf_chat_button_' + form_id).css({ 2514 'top': -1 * form_h, 2515 'width': form_w 2516 }) 2517 },400); 2518 } 2519 2520 function ccf_hide_chat(form_id) { 2521 var $form = $(".ccf_chat_form.creative_form_" + form_id); 2522 var form_h = $form.attr('form_h'); 2523 2524 $form.css({ 2525 'bottom': -1*form_h 2526 }); 2527 $('.ccf_chat_button_' + form_id).find('.ccf_chat_btn_sign').removeClass('ccf_chat_hide'); 2528 $('.ccf_chat_button_' + form_id).addClass('ccf_chat_btn_cursor_pointer'); 2529 2530 var btn_w = $('.ccf_chat_button_' + form_id).attr("btn_w"); 2531 $('.ccf_chat_button_' + form_id).parents('.ccf_chat_button_wrapper').width(btn_w); 2532 $('.ccf_chat_button_' + form_id).width(btn_w); 2533 $('.ccf_chat_button_' + form_id).css('top',0); 2534 2535 $('.ccf_chat_button_' + form_id).addClass('ccf_chat_button_top_30'); 2536 setTimeout(function() { 2537 $('.ccf_chat_button_' + form_id).addClass('ccf_chat_button_transition'); 2538 $('.ccf_chat_button').removeClass('ccf_chat_button_top_30'); 2539 },400); 2540 2541 setTimeout(function() { 2542 $('.ccf_chat_button_' + form_id).removeClass('ccf_chat_button_transition'); 2543 },900); 2544 2545 $('.ccf_chat_button_' + form_id).removeClass('ccf_chat_opened'); 2546 } 2547 2548 $(document).on('click','.ccf_chat_hide', function() { 2549 var form_id = $(this).parents('.ccf_chat_button').attr('form_id'); 2550 ccf_hide_chat(form_id); 2551 }); 2552 2553 // END version 4.0 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 2554 2555 // version 4.5.0 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 2556 $('.ccf_star').mouseenter(function() { 2557 var star_index = $(this).attr('star_index'); 2558 var $stars_wrapper = $(this).parent('.ccf_stars_wrapper'); 2559 2560 ccf_make_stars(star_index, $stars_wrapper); 2561 }); 2562 2563 function ccf_make_stars(star_index, $stars_wrapper) { 2564 $stars_wrapper.prev('input').val(star_index + '-stars'); 2565 $stars_wrapper.find('.ccf_star').addClass('ccf_star_empty').removeClass('ccf_star_filled'); 2566 for(var i = 1; i <= star_index; i ++) { 2567 $stars_wrapper.find('.ccf_star_' + i).removeClass('ccf_star_empty').addClass('ccf_star_filled'); 2568 } 2569 2570 $stars_wrapper.find('.ccf_star_reset').show(); 2571 2572 // validate stars 2573 validate_stars($stars_wrapper.prev('input'),false); 2574 } 2575 $('.ccf_star_reset').click(function() { 2576 var $stars_wrapper = $(this).parent('.ccf_stars_wrapper'); 2577 2578 ccf_reset_stars($stars_wrapper); 2579 $stars_wrapper.find('.ccf_star').addClass('ccf_star_empty').removeClass('ccf_star_filled'); 2580 $(this).hide(); 2581 2582 // validate stars 2583 validate_stars($stars_wrapper.prev('input'),false); 2584 }); 2585 function ccf_reset_stars($stars_wrapper) { 2586 $stars_wrapper.prev('input').val(""); 2587 $stars_wrapper.find('.ccf_star').addClass('ccf_star_empty').removeClass('ccf_star_filled'); 2588 $stars_wrapper.find('.ccf_star_reset').hide(); 2589 }; 2590
2591 // signature //////////////////////////////////////////////////////////////////////////////////////////////// 2592 var ccf_ctx, 2593 ccf_flag = false, 2594 ccf_prevX = 0, 2595 ccf_currX = 0, 2596 ccf_prevY = 0, 2597 ccf_currY = 0, 2598 ccf_dot_ccf_flag = false, 2599 ccf_x = "black", 2600 ccf_y = 2; 2601 2602 function ccf_init() { 2603 $('.ccf_canvas_wrapper').each(function() { 2604 var ccf_canvas_inner = $(this).find('.ccf_canvas')[0]; 2605 var ccf_canvas = $(this).find('.ccf_canvas'); 2606 2607 ccf_ctx = ccf_canvas_inner.getContext("2d"); 2608 ccf_canvas_w = ccf_canvas_inner.width; 2609 ccf_canvas_h = ccf_canvas_inner.height; 2610 2611 ccf_canvas_inner.addEventListener("mousemove", function (e) { 2612 ccf_findxy(ccf_canvas, 'move', e) 2613 }, false); 2614 ccf_canvas_inner.addEventListener("mousedown", function (e) { 2615 ccf_findxy(ccf_canvas, 'down', e) 2616 }, false); 2617 ccf_canvas_inner.addEventListener("mouseup", function (e) { 2618 ccf_findxy(ccf_canvas, 'up', e) 2619 }, false); 2620 ccf_canvas_inner.addEventListener("mouseout", function (e) { 2621 ccf_findxy(ccf_canvas, 'out', e) 2622 }, false); 2623 }); 2624 }; 2625 ccf_init(); 2626 2627 function ccf_color(data_color) { 2628 ccf_x = data_color; 2629 if (ccf_x == "white") ccf_y = 14; 2630 else ccf_y = 2; 2631 }; 2632 2633 function ccf_draw() { 2634 ccf_ctx.beginPath(); 2635 ccf_ctx.moveTo(ccf_prevX, ccf_prevY); 2636 ccf_ctx.lineTo(ccf_currX, ccf_currY); 2637 ccf_ctx.strokeStyle = ccf_x; 2638 ccf_ctx.lineWidth = ccf_y; 2639 ccf_ctx.stroke(); 2640 ccf_ctx.closePath(); 2641 }; 2642 2643 function ccf_erase_canvas($cnv, force_clean) { 2644 var m; 2645 if(!force_clean) 2646 m = confirm("Want to clear"); 2647 if (m || force_clean) { 2648 ccf_ctx.clearRect(0, 0, ccf_canvas_w, ccf_canvas_h); 2649 $cnv.next('img').hide(); 2650 $cnv.next('img').next('.ccf_signature_img').val(''); 2651 2652 $save_btn = $cnv.parents('.ccf_canvas_wrapper').find('.ccf_save_canvas'); 2653 $clear_btn = $cnv.parents('.ccf_canvas_wrapper').find('.ccf_clear_canvas'); 2654 $colors_wrapper = $cnv.parents('.ccf_canvas_wrapper').find('.ccf_colors_wrapper'); 2655 2656 $save_btn.show(); 2657 $colors_wrapper.show(); 2658 $clear_btn.removeClass('ccf_margin_top_8'); 2659 2660 validate_esignature($cnv.next('img').next('.ccf_signature_img'),false); 2661 } 2662 }; 2663 2664 function ccf_save_canvas($cnv) { 2665 var $cnv_img = $cnv.next('img'); 2666 $save_btn = $cnv.parents('.ccf_canvas_wrapper').find('.ccf_save_canvas'); 2667 $clear_btn = $cnv.parents('.ccf_canvas_wrapper').find('.ccf_clear_canvas'); 2668 $colors_wrapper = $cnv.parents('.ccf_canvas_wrapper').find('.ccf_colors_wrapper'); 2669 var dataURL = $cnv[0].toDataURL(); 2670 $cnv_img.attr("src",dataURL); 2671 $cnv_img.next('.ccf_signature_img').val(dataURL); 2672 $cnv_img.show(); 2673 2674 $save_btn.hide(); 2675 $colors_wrapper.hide(); 2676 $clear_btn.addClass('ccf_margin_top_8'); 2677 2678 validate_esignature($cnv_img.next('.ccf_signature_img'),false); 2679 }; 2680 2681 function ccf_findxy(ccf_canvas, res, e) { 2682 2683 var canvas_ratio_x = 0; 2684 var canvas_ratio_y = -16; 2685 if (res == 'down') { 2686 ccf_prevX = ccf_currX; 2687 ccf_prevY = ccf_currY; 2688 ccf_currX = e.clientX - ccf_canvas.offset().left - canvas_ratio_x; 2689 var scrollTop = parseInt($(window).scrollTop()); 2690 ccf_currY = e.clientY - ccf_canvas.offset().top + scrollTop - canvas_ratio_y; 2691 2692 2693 2694 ccf_flag = true; 2695 ccf_dot_ccf_flag = true; 2696 if (ccf_dot_ccf_flag) { 2697 ccf_ctx.beginPath(); 2698 ccf_ctx.fillStyle = ccf_x; 2699 ccf_ctx.fillRect(ccf_currX, ccf_currY, 2, 2); 2700 ccf_ctx.closePath(); 2701 ccf_dot_ccf_flag = false; 2702 } 2703 } 2704 if (res == 'up' || res == "out") { 2705 ccf_flag = false; 2706 } 2707 if (res == 'move') { 2708 if (ccf_flag) { 2709 var scrollTop = parseInt($(window).scrollTop()); 2710 2711 ccf_prevX = ccf_currX; 2712 ccf_prevY = ccf_currY; 2713 ccf_currX = e.clientX - ccf_canvas.offset().left - canvas_ratio_x; 2714 ccf_currY = e.clientY - ccf_canvas.offset().top + scrollTop - canvas_ratio_y; 2715 2716 // ccf_currX = 10; 2717 // ccf_currY = 10; 2718 2719 ccf_draw(); 2720 } 2721 } 2722 }; 2723 2724 $('.ccf_change_cnv_color').click(function() { 2725 var data_color = $(this).attr("data-color"); 2726 ccf_color(data_color); 2727 }); 2728 2729 $(".ccf_save_canvas").click(function() { 2730 $cnv = $(this).parents('.ccf_canvas_wrapper').find('.ccf_canvas'); 2731 ccf_save_canvas($cnv); 2732 }); 2733 $(".ccf_clear_canvas").click(function() { 2734 $cnv = $(this).parents('.ccf_canvas_wrapper').find('.ccf_canvas'); 2735 ccf_erase_canvas($cnv, false); 2736 });
2737 // END signature //////////////////////////////////////////////////////////////////////////////////////////// 2738 // pages //////////////////////////////////////////////////////////////////////////////////////////// 2739 2740 function ccf_render_pages() { 2741 $('.ccf_pages_wrapper').each(function() { 2742 $pages_wrapper = $(this); 2743 var current_page = parseInt($pages_wrapper.attr("current_page")); 2744 var pages_count = parseInt($pages_wrapper.attr("pages_count")); 2745 var page_seperate_type = parseInt($pages_wrapper.attr("page_seperate_type")); 2746 2747 if(page_seperate_type == 0 || page_seperate_type == 1) { // render pages buttons view, tabs view 2748 if(pages_count > 1) { 2749 2750 $pages_wrapper.find('.ccf_page_item').removeClass('ccf_pos_abs').height("auto"); 2751 var single_w = parseInt($pages_wrapper.width()); 2752 var total_w = (pages_count) * single_w; 2753 2754 $pages_wrapper.find('.ccf_page_item').each(function() { 2755 $(this).width(single_w); 2756 var h = $(this).height(); 2757 $(this).height(h).attr("h",h); 2758 2759 }) 2760 2761 $pages_wrapper.find('.ccf_page_item').not('.ccf_page_' + current_page).hide(); 2762 var visible_h = $pages_wrapper.find('.ccf_page_' + current_page).height(); 2763 2764 $pages_wrapper.find('.ccf_pages_inner').height(visible_h); 2765 $pages_wrapper.find('.ccf_page_item').addClass('ccf_pos_abs'); 2766 2767 } 2768 } 2769 else if (page_seperate_type == 2) { 2770 $pages_wrapper.find('.ccf_page_item').each(function() { 2771 var h = $(this).height(); 2772 $(this).height(h).attr("h",h); 2773 }); 2774 2775 $pages_wrapper.find('.ccf_page_item').not('.ccf_page_' + current_page).hide(); 2776 } 2777 }); 2778 }; 2779 setTimeout(function() { 2780 ccf_render_pages(); 2781 },200); 2782 2783 $('.ccf_next_page_button').click(function() { 2784 ccf_change_page($(this).parents('.creativecontactform_wrapper').find('.ccf_pages_wrapper'),'next', false); 2785 }); 2786 $('.ccf_prev_page_button').click(function() { 2787 ccf_change_page($(this).parents('.creativecontactform_wrapper').find('.ccf_pages_wrapper'),'prev', false); 2788 }); 2789 function ccf_change_page($page_wrapper, direction, new_page) { 2790 var current_page = parseInt($page_wrapper.attr("current_page")); 2791 var pages_count = parseInt($page_wrapper.attr("pages_count")); 2792 2793 if(direction != false) { 2794 if(direction == 'next') { 2795 var next_page = current_page < pages_count - 1 ? current_page + 1*1 : current_page; 2796 } 2797 if(direction == 'prev') { 2798 var next_page = current_page > 0 ? current_page - 1*1 : current_page; 2799 } 2800 } 2801 else { 2802 var next_page = new_page; 2803 2804 if(new_page > current_page) { 2805 direction = 'next'; 2806 } 2807 } 2808 2809 if(next_page != current_page) { 2810 var new_h = $('.ccf_page_' + next_page).attr('h'); 2811 $page_wrapper.find('.ccf_pages_inner').stop().animate({ 2812 height: new_h 2813 },400); 2814 2815 var next_pos = direction == 'next' ? -200 : 200; 2816 var prev_pos = direction == 'next' ? 200 : -200; 2817 2818 $('.ccf_page_' + current_page).stop().animate({ 2819 left: next_pos, 2820 opacity: 0 2821 },400,function() { 2822 $(this).hide(); 2823 }); 2824 $('.ccf_page_' + next_page) 2825 .css( 2826 { 2827 'left':prev_pos, 2828 'opacity': '0', 2829 'display':'block' 2830 }) 2831 .stop() 2832 .animate({ 2833 left: 0, 2834 opacity: 1 2835 },400); 2836 } 2837 $page_wrapper.attr("current_page", next_page); 2838 2839 if(direction != false) { 2840 if(next_page == pages_count - 1*1) { 2841 $page_wrapper.parents('.creativecontactform_wrapper').find('.ccf_next_page_button').addClass('ccf_cursor_default'); 2842 } 2843 else { 2844 $page_wrapper.parents('.creativecontactform_wrapper').find('.ccf_next_page_button').removeClass('ccf_cursor_default'); 2845 } 2846 if(next_page == 0) { 2847 $page_wrapper.parents('.creativecontactform_wrapper').find('.ccf_prev_page_button').addClass('ccf_cursor_default'); 2848 } 2849 else { 2850 $page_wrapper.parents('.creativecontactform_wrapper').find('.ccf_prev_page_button').removeClass('ccf_cursor_default'); 2851 } 2852 } 2853 } 2854 // tabs 2855 $('.ccf_tab_item').click(function() { 2856 $('.ccf_tab_item').removeClass('ccf_active'); 2857 $(this).addClass('ccf_active'); 2858 2859 var tab_index = $(this).attr("tab_index"); 2860 2861 ccf_change_page($(this).parents('.creativecontactform_wrapper').find('.ccf_pages_wrapper'), false, tab_index) 2862 2863 }); 2864 // acordion
2865 $('.ccf_acordion_item').click(function() { 2866 if($(this).hasClass('ccf_acordion_active')) 2867 return; 2868 2869 $('.ccf_acordion_active').removeClass('ccf_acordion_active'); 2870 $(this).addClass('ccf_acordion_active') 2871 2872 var page_index = $(this).attr("page_index"); 2873 var $page_to_show = $(this).next('.ccf_page_item'); 2874 var h = $page_to_show.attr("h"); 2875 2876 $('.ccf_page_item').not($page_to_show).animate({ 2877 height: 0 2878 },400, function() { 2879 $(this).hide(); 2880 }); 2881 2882 $page_to_show.show().css('height',0).animate({ 2883 height: h 2884 },400); 2885 }); 2886 // if then logic 2887 var ccf_if_then_array = new Array(); 2888 setTimeout(function() { 2889 $('.creativecontactform_wrapper').each(function() { 2890 $ccf_wrapper = $(this); 2891 2892 var form_id = $ccf_wrapper.find('.v4_data').attr("form_id"); 2893 2894 ccf_if_then_array[form_id] = [ 2895 [], 2896 [], 2897 [] 2898 ]; 2899 $ccf_wrapper.find('.ccf_if_then').each(function() { 2900 $if_then = $(this); 2901 var if_id = $if_then.attr("if_id"); 2902 var if_val = $if_then.attr("if_val"); 2903 var then_id = $if_then.attr("then_id"); 2904 2905 ccf_if_then_array[form_id][0].push(if_id); 2906 ccf_if_then_array[form_id][1].push(if_val); 2907 ccf_if_then_array[form_id][2].push(then_id); 2908 2909 $('.ccf_field_box_' + then_id).addClass('ccf_if_then_hidden'); 2910 }); 2911 }); 2912 },150); 2913 2914 function ccf_apply_if_then_logic(form_id,field_id,field_val) { 2915 for(var i in ccf_if_then_array[form_id][0]) { 2916 if(ccf_if_then_array[form_id][0][i] == field_id) { 2917 var then_id = ccf_if_then_array[form_id][2][i]; 2918 2919 if(ccf_if_then_array[form_id][1][i] == field_val) { 2920 $('.ccf_field_box_' + then_id).removeClass('ccf_if_then_hidden'); 2921 } 2922 else { 2923 $('.ccf_field_box_' + then_id).removeClass('creativecontactform_error').addClass('ccf_if_then_hidden'); 2924 } 2925 ccf_render_pages(); 2926 } 2927 else { 2928 continue; 2929 } 2930 } 2931 } 2932 2933 2934 2935 2936}) 2937})(creativeJ); 2938
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.