| 1 |
|
| 2 |
pagelayer_svg_cache = {}; |
| 3 |
var pagelayer_document_width; |
| 4 |
|
| 5 |
// For automatic row parent change |
| 6 |
jQuery(window).resize(function(){ |
| 7 |
|
| 8 |
var new_vw = jQuery(document).width(); |
| 9 |
|
| 10 |
if(new_vw == pagelayer_document_width){ |
| 11 |
return false; |
| 12 |
} |
| 13 |
|
| 14 |
pagelayer_document_width = new_vw; |
| 15 |
|
| 16 |
// Set a timeout to prevent bubbling |
| 17 |
setTimeout(function(){ |
| 18 |
|
| 19 |
jQuery('.pagelayer-row-stretch-full').each(function(){ |
| 20 |
var par = jQuery(this).parent(); |
| 21 |
pagelayer_pl_row_parent_full(par); |
| 22 |
}); |
| 23 |
|
| 24 |
}, 200); |
| 25 |
|
| 26 |
}); |
| 27 |
|
| 28 |
// Render for row |
| 29 |
function pagelayer_render_pl_row(el){ |
| 30 |
pagelayer_bg_video(el); |
| 31 |
} |
| 32 |
|
| 33 |
// Render for col |
| 34 |
function pagelayer_render_pl_col(el){ |
| 35 |
|
| 36 |
// Apply to wrapper |
| 37 |
if(!pagelayer_empty(el.atts['col'])){ |
| 38 |
|
| 39 |
for(var x=1; x<=12; x++){ |
| 40 |
if(el.$.parent().hasClass('pagelayer-col-'+x)){ |
| 41 |
el.$.parent().removeClass('pagelayer-col-'+x); |
| 42 |
break; |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
el.$.parent().addClass('pagelayer-col-'+el.atts['col']); |
| 47 |
} |
| 48 |
|
| 49 |
if(el.atts['col_width']){ |
| 50 |
el.$.parent().css('width', el.atts['col_width']+'%'); |
| 51 |
} |
| 52 |
|
| 53 |
pagelayer_bg_video(el); |
| 54 |
} |
| 55 |
|
| 56 |
function pagelayer_bg_video(el){ |
| 57 |
|
| 58 |
var youtubeRegExp = /youtube\.com|youtu\.be/; |
| 59 |
var vimeoRegExp = /vimeo\.com/; |
| 60 |
|
| 61 |
el.tmp['bg_video_src-url'] = el.tmp['bg_video_src-url'] || el.atts['bg_video_src']; |
| 62 |
|
| 63 |
var src = el.tmp['bg_video_src-url']; |
| 64 |
|
| 65 |
var iframe_src = pagelayer_video_url(el.tmp['bg_video_src-url']); |
| 66 |
|
| 67 |
if (youtubeRegExp.exec(src)) { |
| 68 |
|
| 69 |
var youtubeRegExp1 = /youtube\.com/; |
| 70 |
var youtubewatch = /watch/; |
| 71 |
var youtubeembed = /embed/; |
| 72 |
var youtube = /youtu\.be/; |
| 73 |
var videoId; |
| 74 |
|
| 75 |
if (youtubeRegExp1.exec(src)) { |
| 76 |
|
| 77 |
if (youtubewatch.exec(src)) { |
| 78 |
videoId = src.split('?v='); |
| 79 |
|
| 80 |
} else if (youtubewatch.exec(src)) { |
| 81 |
videoId = src.split('embed/'); |
| 82 |
} |
| 83 |
|
| 84 |
} else if (youtube.exec(src)) { |
| 85 |
videoId = src.split('.be/'); |
| 86 |
} |
| 87 |
//console.log(frame_height); |
| 88 |
el.atts['vid_src'] = '<iframe src="'+iframe_src+'?autoplay=1&controls=0&showinfo=0&rel=0&loop=1&autohide=1&playlist='+videoId[1]+'" allowfullscreen="1" webkitallowfullscreen="1" mozallowfullscreen="1" frameborder="0"></iframe>'; |
| 89 |
|
| 90 |
} else if (vimeoRegExp.exec(src)) { |
| 91 |
|
| 92 |
el.atts['vid_src'] = '<iframe src="'+iframe_src+'?background=1&autoplay=1&loop=1&byline=0&title=0" allowfullscreen="1" webkitallowfullscreen="1" mozallowfullscreen="1" frameborder="0"></iframe>'; |
| 93 |
|
| 94 |
}else{ |
| 95 |
|
| 96 |
el.atts['vid_src'] = '<video autoplay loop>'+ |
| 97 |
'<source src="'+iframe_src+'" type="video/mp4">'+ |
| 98 |
'</video>'; |
| 99 |
|
| 100 |
} |
| 101 |
|
| 102 |
} |
| 103 |
|
| 104 |
// Load the full width row |
| 105 |
function pagelayer_render_end_pl_row(el){ |
| 106 |
|
| 107 |
// The parent |
| 108 |
var par = el.$.parent(); |
| 109 |
|
| 110 |
// Any class with full width |
| 111 |
if(el.$.hasClass('pagelayer-row-stretch-full')){ |
| 112 |
|
| 113 |
// Give it the full width |
| 114 |
pagelayer_pl_row_full(el.$); |
| 115 |
|
| 116 |
// Give full width to the parent |
| 117 |
pagelayer_pl_row_parent_full(par); |
| 118 |
|
| 119 |
// Also add that we had a full width |
| 120 |
el.$.addClass('pagelayer-row-stretch-had-full'); |
| 121 |
|
| 122 |
// Did this row have full width ? |
| 123 |
}else if(el.$.hasClass('pagelayer-row-stretch-had-full')){ |
| 124 |
|
| 125 |
// Remove style |
| 126 |
el.$.removeAttr('style'); |
| 127 |
par.removeAttr('style'); |
| 128 |
par.children('.pagelayer-ele-overlay').removeAttr('style'); |
| 129 |
|
| 130 |
// Remove HAD class |
| 131 |
el.$.removeClass('pagelayer-row-stretch-had-full'); |
| 132 |
|
| 133 |
} |
| 134 |
|
| 135 |
pagelayer_pl_row_video(el.$); |
| 136 |
|
| 137 |
el.$.find('.pagelayer-parallax-window img').each(function(){ |
| 138 |
pagelayer_pl_row_parallax(jQuery(this)); |
| 139 |
}); |
| 140 |
|
| 141 |
// Row shape |
| 142 |
if('row_shape_type_top' in el.atts){ |
| 143 |
pagelayer_render_row_shape(el, 'top') |
| 144 |
} |
| 145 |
|
| 146 |
if('row_shape_type_bottom' in el.atts){ |
| 147 |
pagelayer_render_row_shape(el, 'bottom') |
| 148 |
} |
| 149 |
} |
| 150 |
|
| 151 |
// Set Row parent width |
| 152 |
function pagelayer_pl_row_parent_full(par){ |
| 153 |
var vw = jQuery(document).width(); |
| 154 |
par.css({'width': vw,'max-width': '100vw'}); |
| 155 |
par.offset({left: 0}); |
| 156 |
par.children('.pagelayer-row').css({left: 0}); |
| 157 |
} |
| 158 |
|
| 159 |
// Row shape render |
| 160 |
function pagelayer_render_row_shape(el, shape_pos){ |
| 161 |
|
| 162 |
var name = el.atts['row_shape_type_'+shape_pos]+'-'+shape_pos+'.svg'; |
| 163 |
|
| 164 |
// DO we have in cache |
| 165 |
if(!(name in pagelayer_svg_cache)){ |
| 166 |
// Make url and fetch |
| 167 |
var url = pagelayer_url+'/images/shapes/'+name; |
| 168 |
jQuery.get(url, function(data){ |
| 169 |
el.$.find('.pagelayer-svg-'+shape_pos).html(data); |
| 170 |
pagelayer_svg_cache[name] = data; |
| 171 |
}, 'html'); |
| 172 |
|
| 173 |
// Fill with cache |
| 174 |
}else{ |
| 175 |
el.$.find('.pagelayer-svg-'+shape_pos).html(pagelayer_svg_cache[name]); |
| 176 |
} |
| 177 |
|
| 178 |
} |
| 179 |
|
| 180 |
// Load the col |
| 181 |
function pagelayer_render_end_pl_col(el){ |
| 182 |
|
| 183 |
pagelayer_pl_row_video(el.$); |
| 184 |
|
| 185 |
el.$.find('.pagelayer-parallax-window img').each(function(){ |
| 186 |
pagelayer_pl_row_parallax(jQuery(this)); |
| 187 |
}); |
| 188 |
|
| 189 |
} |
| 190 |
|
| 191 |
// Render the image object |
| 192 |
function pagelayer_render_pl_image(el){ |
| 193 |
|
| 194 |
// Decide the image URL |
| 195 |
el.atts['func_id'] = el.tmp['id-'+el.atts['id-size']+'-url'] || el.tmp['id-url']; |
| 196 |
el.atts['func_id'] = el.atts['func_id'] || el.atts['id']; |
| 197 |
|
| 198 |
// What is the link ? |
| 199 |
if('link_type' in el.atts){ |
| 200 |
|
| 201 |
// Custom url |
| 202 |
if(el.atts['link_type'] == 'custom_url'){ |
| 203 |
el.atts['func_link'] = el.atts['link']; |
| 204 |
} |
| 205 |
|
| 206 |
// Link to the media file itself |
| 207 |
if(el.atts['link_type'] == 'media_file'){ |
| 208 |
el.atts['func_link'] = el.tmp['id-url'] || el.atts['id']; |
| 209 |
} |
| 210 |
|
| 211 |
// Lightbox |
| 212 |
if(el.atts['link_type'] == 'lightbox'){ |
| 213 |
el.atts['func_link'] = el.tmp['id-url'] || el.atts['id']; |
| 214 |
} |
| 215 |
} |
| 216 |
} |
| 217 |
|
| 218 |
// Incase if there is a lightbox |
| 219 |
function pagelayer_render_end_pl_image(el){ |
| 220 |
pagelayer_pl_image(el.$); |
| 221 |
} |
| 222 |
|
| 223 |
// Render for video |
| 224 |
function pagelayer_render_pl_video(el){ |
| 225 |
el.atts['video_overlay_image-url'] = el.tmp['video_overlay_image-'+el.atts['custom_size']+'-url'] || el.tmp['video_overlay_image-url']; |
| 226 |
el.atts['video_overlay_image-url'] = el.atts['video_overlay_image-url'] || el.atts['video_overlay_image']; |
| 227 |
el.tmp['src-url'] = el.tmp['src-url'] || el.atts['src']; |
| 228 |
el.tmp['ele_id'] = el['id']; |
| 229 |
el.atts['vid_src'] = pagelayer_video_url(el.tmp['src-url']); |
| 230 |
|
| 231 |
if(el.atts['autoplay'] == "true"){ |
| 232 |
el.atts['vid_src'] +="?&autoplay=1"; |
| 233 |
}else{ |
| 234 |
el.atts['vid_src'] +="?&autoplay=0"; |
| 235 |
} |
| 236 |
|
| 237 |
if(el.atts['mute'] == "true"){ |
| 238 |
el.atts['vid_src'] +="&mute=1"; |
| 239 |
}else{ |
| 240 |
el.atts['vid_src'] +="&mute=0"; |
| 241 |
} |
| 242 |
|
| 243 |
if(el.atts['loop'] == "true"){ |
| 244 |
el.atts['vid_src'] +="&loop=1"; |
| 245 |
}else{ |
| 246 |
el.atts['vid_src'] +="&loop=0"; |
| 247 |
} |
| 248 |
} |
| 249 |
|
| 250 |
// Incase if there is a lightbox |
| 251 |
function pagelayer_render_end_pl_video(el){ |
| 252 |
pagelayer_pl_video(el.$); |
| 253 |
} |
| 254 |
|
| 255 |
// Render the testimonial |
| 256 |
function pagelayer_render_pl_testimonial(el){ |
| 257 |
//console.log(el); |
| 258 |
// Decide the image URL |
| 259 |
el.atts['func_image'] = el.tmp['avatar-'+el.atts['custom_size']+'-url'] || el.tmp['avatar-url']; |
| 260 |
el.atts['func_image'] = el.atts['func_image'] || el.atts['avatar']; |
| 261 |
|
| 262 |
} |
| 263 |
|
| 264 |
// Render the stars |
| 265 |
function pagelayer_render_end_pl_stars(el){ |
| 266 |
pagelayer_stars(); |
| 267 |
}; |
| 268 |
|
| 269 |
|
| 270 |
// Render the service box |
| 271 |
function pagelayer_render_pl_service(el){ |
| 272 |
|
| 273 |
// Decide the image URL |
| 274 |
el.atts['func_image'] = el.tmp['service_image-'+el.atts['service_image_size']+'-url'] || el.tmp['service_image-url']; |
| 275 |
el.atts['func_image'] = el.atts['func_image'] || el.atts['service_image']; |
| 276 |
|
| 277 |
} |
| 278 |
|
| 279 |
// Render the counter |
| 280 |
function pagelayer_render_end_pl_counter(el){ |
| 281 |
pagelayer_counter(); |
| 282 |
}; |
| 283 |
|
| 284 |
// Render the progress |
| 285 |
function pagelayer_render_end_pl_progress(el){ |
| 286 |
pagelayer_progress(); |
| 287 |
}; |
| 288 |
|
| 289 |
// Render the image slider |
| 290 |
function pagelayer_render_pl_image_slider(el){ |
| 291 |
|
| 292 |
// The URLs |
| 293 |
var img_urls = !pagelayer_empty(el.tmp['ids-urls']) ? JSON.parse(el.tmp['ids-urls']) : []; |
| 294 |
var all_urls = !pagelayer_empty(el.tmp['ids-all-urls']) ? JSON.parse(el.tmp['ids-all-urls']) : []; |
| 295 |
//console.log(img_urls); |
| 296 |
|
| 297 |
var ul = ''; |
| 298 |
var is_link = 'link_type' in el.atts && !pagelayer_empty(el.atts['link_type']) ? true : false; |
| 299 |
|
| 300 |
// Create figure HTML |
| 301 |
for (var x in img_urls){ |
| 302 |
|
| 303 |
// Use the default URL first |
| 304 |
var url = img_urls[x]; |
| 305 |
|
| 306 |
// But if we have a custom size, use that |
| 307 |
if(el.atts['size'] != 'custom' && x in all_urls && el.atts['size'] in all_urls[x]){ |
| 308 |
url = all_urls[x][el.atts['size']]; |
| 309 |
} |
| 310 |
|
| 311 |
ul += '<li class="pagelayer-slider-item">'; |
| 312 |
|
| 313 |
if(is_link){ |
| 314 |
var link = (el.atts['link_type'] == 'media_file' ? url : (el.atts['link'] || '')) |
| 315 |
ul += '<a href="'+link+'">'; |
| 316 |
} |
| 317 |
|
| 318 |
ul += '<img src="'+url+'">'; |
| 319 |
|
| 320 |
if(is_link){ |
| 321 |
ul += '</a>'; |
| 322 |
} |
| 323 |
|
| 324 |
ul += '</li>'; |
| 325 |
} |
| 326 |
|
| 327 |
el.atts['ul'] = ul; |
| 328 |
|
| 329 |
// Which arrows to show |
| 330 |
if('controls' in el.atts && (el.atts['controls'] == 'arrows' || el.atts['controls'] == 'none')){ |
| 331 |
el.CSS.attr.push({'sel': '.pagelayer-image-slider-ul', 'val': 'data-pager="false"'}); |
| 332 |
} |
| 333 |
|
| 334 |
if('controls' in el.atts && (el.atts['controls'] == 'pager' || el.atts['controls'] == 'none')){ |
| 335 |
el.CSS.attr.push({'sel': '.pagelayer-image-slider-ul', 'val': 'data-controls="false"'}); |
| 336 |
} |
| 337 |
|
| 338 |
}; |
| 339 |
|
| 340 |
// Render the image slider |
| 341 |
function pagelayer_render_end_pl_image_slider(el){ |
| 342 |
pagelayer_pl_image_slider(); |
| 343 |
}; |
| 344 |
|
| 345 |
|
| 346 |
// Render the grid gallery |
| 347 |
function pagelayer_render_pl_grid_gallery(el){ |
| 348 |
|
| 349 |
// The URLs |
| 350 |
var img_urls = !pagelayer_empty(el.tmp['ids-urls']) ? JSON.parse(el.tmp['ids-urls']) : []; |
| 351 |
var all_urls = !pagelayer_empty(el.tmp['ids-all-urls']) ? JSON.parse(el.tmp['ids-all-urls']) : []; |
| 352 |
var img_title = !pagelayer_empty(el.tmp['ids-all-titles']) ? JSON.parse(el.tmp['ids-all-titles']) : []; |
| 353 |
var img_links = !pagelayer_empty(el.tmp['ids-all-links']) ? JSON.parse(el.tmp['ids-all-links']) : []; |
| 354 |
var img_captions = !pagelayer_empty(el.tmp['ids-all-captions']) ? JSON.parse(el.tmp['ids-all-captions']) : []; |
| 355 |
//console.log(img_urls); |
| 356 |
|
| 357 |
var ul = ''; |
| 358 |
var is_link = 'link_to' in el.atts && !pagelayer_empty(el.atts['link_to']) ? true : false; |
| 359 |
var col = el.atts['columns']; |
| 360 |
|
| 361 |
var i = 0; |
| 362 |
|
| 363 |
ul += '<ul class="pagelayer-grid-gallery-ul">'; |
| 364 |
var gallery_rand = 'gallery-id-'+Math.floor((Math.random() * 100) + 1); |
| 365 |
|
| 366 |
// Create figure HTML |
| 367 |
for (var x in img_urls){ |
| 368 |
|
| 369 |
if(i % col == 0 && i != 0){ |
| 370 |
ul += '</ul><ul class="pagelayer-grid-gallery-ul">'; |
| 371 |
} |
| 372 |
|
| 373 |
// Use the default URL first |
| 374 |
var url = img_urls[x]; |
| 375 |
|
| 376 |
// But if we have a custom size, use that |
| 377 |
if(el.atts['size'] != 'custom' && x in all_urls && el.atts['size'] in all_urls[x]){ |
| 378 |
url = all_urls[x][el.atts['size']]; |
| 379 |
} |
| 380 |
|
| 381 |
|
| 382 |
ul += '<li class="pagelayer-gallery-item" >'; |
| 383 |
|
| 384 |
if(!is_link){ |
| 385 |
ul += '<div>'; |
| 386 |
} |
| 387 |
|
| 388 |
if(is_link && el.atts['link_to'] == 'media_file'){ |
| 389 |
var link = (el.atts['link_to'] == 'media_file' ? url : (el.atts['link'] || '')) |
| 390 |
ul += '<a href="'+link+'" class="pagelayer-ele-link">'; |
| 391 |
} |
| 392 |
|
| 393 |
if(is_link && el.atts['link_to'] == 'attachment'){ |
| 394 |
var link = img_links[x]; |
| 395 |
ul += '<a href="'+link+'" class="pagelayer-ele-link">'; |
| 396 |
} |
| 397 |
|
| 398 |
if(is_link && el.atts['link_to'] == 'lightbox'){ |
| 399 |
ul += '<a href="'+img_urls[x]+'" class="pagelayer-ele-link" data-lightbox-gallery="'+gallery_rand+'" alt="'+img_title[x]+'" pagelayer-grid-gallery-type="'+el.atts['link_to']+'">' |
| 400 |
} |
| 401 |
|
| 402 |
ul += '<img src="'+url+'" title="'+img_title[x]+'" alt="'+img_title[x]+'">'; |
| 403 |
|
| 404 |
if(el.atts['caption'] == 'true'){ |
| 405 |
ul += '<span class="pagelayer-grid-gallery-caption">'+img_captions[x]+'</span>'; |
| 406 |
} |
| 407 |
|
| 408 |
if(is_link){ |
| 409 |
ul += '</a>'; |
| 410 |
} |
| 411 |
|
| 412 |
if(!is_link){ |
| 413 |
ul += '</div>'; |
| 414 |
} |
| 415 |
|
| 416 |
ul += '</li>'; |
| 417 |
i++; |
| 418 |
} |
| 419 |
ul += '</ul>'; |
| 420 |
|
| 421 |
el.tmp['gallery-random-id'] = gallery_rand; |
| 422 |
|
| 423 |
el.atts['ul'] = ul; |
| 424 |
|
| 425 |
}; |
| 426 |
|
| 427 |
// Render for tabs |
| 428 |
function pagelayer_render_html_pl_tabs(el){ |
| 429 |
el.CSS.attr.push({'sel': '{{element}}', 'val': 'pagelayer-tabs-rotate="'+el.atts["rotate"]+'"'}); |
| 430 |
}; |
| 431 |
|
| 432 |
// Render the accordion item |
| 433 |
function pagelayer_render_end_pl_tabs(el){ |
| 434 |
pagelayer_pl_tabs(el.$); |
| 435 |
} |
| 436 |
|
| 437 |
// Render the accordion item |
| 438 |
function pagelayer_render_end_pl_accordion(el){ |
| 439 |
pagelayer_pl_accordion(el.$); |
| 440 |
}; |
| 441 |
|
| 442 |
// Render the collapse item |
| 443 |
function pagelayer_render_end_pl_collapse(el){ |
| 444 |
pagelayer_pl_collapse(el.$); |
| 445 |
}; |
| 446 |
|
| 447 |
// Shortcode Handler |
| 448 |
var pagelayer_shortcodes_timer; |
| 449 |
function pagelayer_render_pl_shortcodes(el){ |
| 450 |
|
| 451 |
// Clear any previous timeout |
| 452 |
clearTimeout(pagelayer_shortcodes_timer); |
| 453 |
|
| 454 |
// Set a timer for constant change |
| 455 |
pagelayer_shortcodes_timer = setTimeout(function(){ |
| 456 |
|
| 457 |
// Make the call |
| 458 |
jQuery.ajax({ |
| 459 |
url: pagelayer_ajax_url+'?action=pagelayer_do_shortcodes', |
| 460 |
type: 'POST', |
| 461 |
data: { |
| 462 |
nonce: pagelayer_ajax_nonce, |
| 463 |
shortcode_data: el.atts['data'] |
| 464 |
}, |
| 465 |
success:function(data) { |
| 466 |
el.$.find('.pagelayer-shortcodes-container').html(data); |
| 467 |
} |
| 468 |
}); |
| 469 |
|
| 470 |
}, 500); |
| 471 |
|
| 472 |
}; |
| 473 |
|
| 474 |
// Render the widget area i.e. Sidebars |
| 475 |
function pagelayer_render_pl_wp_widgets(el){ |
| 476 |
|
| 477 |
// Clear any previous timeout |
| 478 |
clearTimeout(pagelayer_shortcodes_timer); |
| 479 |
|
| 480 |
// Set a timer for constant change |
| 481 |
pagelayer_shortcodes_timer = setTimeout(function(){ |
| 482 |
|
| 483 |
// Make the call |
| 484 |
jQuery.ajax({ |
| 485 |
url: pagelayer_ajax_url+'?action=pagelayer_fetch_sidebar', |
| 486 |
type: 'POST', |
| 487 |
data: { |
| 488 |
nonce: pagelayer_ajax_nonce, |
| 489 |
sidebar: el.atts['sidebar'] |
| 490 |
}, |
| 491 |
success:function(data) { |
| 492 |
el.$.find('.pagelayer-wp-sidebar-holder').html(data); |
| 493 |
} |
| 494 |
}); |
| 495 |
|
| 496 |
}, 500); |
| 497 |
|
| 498 |
}; |
| 499 |
|