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