Best JavaScript code snippet using mountebank
fusion-previews.js
Source:fusion-previews.js
1/*2* Previews of builder elements3*/4( function($) {5 var fusionPreview = {};6 window.fusionPreview = fusionPreview;7 /**8 * Caller for respective element9 *10 * @since 2.0.011 *12 * @param OBJECT Reference to current element13 *14 * @param OBJECT Data model of element15 *16 * @param OBJECT Sub elements data17 *18 * @return NULL19 **/20 fusionPreview.updatePreview = function ( thisRef, model, subElements ) {21 if(typeof model.get('css_class') != 'undefined' && model.get('css_class').indexOf('fusion_layout_column') > -1) {22 return;23 }24 switch( model.get( 'php_class' ) ) { //switch case on name of element25 case 'TF_AlertBox':26 fusionPreview.updateAlertPreview( thisRef, model, subElements );27 break;28 case 'TF_WpBlog':29 fusionPreview.updateBlogPreview( thisRef, model, subElements );30 break;31 case 'TF_ButtonBlock':32 fusionPreview.updateButtonPreview( thisRef, model, subElements );33 break;34 case 'TF_CheckList':35 fusionPreview.updateChecklistPreview( thisRef, model, subElements );36 break;37 case 'TF_ClientSlider':38 fusionPreview.updateClientSliderPreview( thisRef, model, subElements );39 break;40 case 'TF_ContentBoxes':41 fusionPreview.updateContentBoxesPreview( thisRef, model, subElements );42 break;43 case 'TF_CounterBox':44 fusionPreview.updateCounterBoxPreview( thisRef, model, subElements );45 break;46 case 'TF_FlipBoxes':47 fusionPreview.updateFlipBoxesPreview( thisRef, model, subElements );48 break;49 case 'TF_FontAwesome':50 fusionPreview.updateFontAwesomePreview( thisRef, model, subElements );51 break;52 case 'TF_FusionSlider':53 fusionPreview.updateFusionSliderPreview( thisRef, model, subElements );54 break;55 case 'TF_GoogleMap':56 fusionPreview.updateGoogleMapPreview( thisRef, model, subElements );57 break;58 case 'TF_ImageFrame':59 fusionPreview.updateImageFramePreview( thisRef, model, subElements );60 break;61 case 'TF_ImageCarousel':62 fusionPreview.updateImageCarouselPreview( thisRef, model, subElements );63 break;64 case 'TF_LightBox':65 fusionPreview.updateLightBoxPreview( thisRef, model, subElements );66 break;67 case 'TF_LayerSlider':68 fusionPreview.updateLayerSliderPreview( thisRef, model, subElements );69 break;70 case 'TF_MenuAnchor':71 fusionPreview.updateMenuAnchorPreview( thisRef, model, subElements );72 break;73 case 'TF_Modal':74 fusionPreview.updateModalPreview( thisRef, model, subElements );75 break;76 case 'TF_Person':77 fusionPreview.updatePersonPreview( thisRef, model, subElements );78 break;79 case 'TF_PostSlider':80 fusionPreview.updatePostSliderPreview( thisRef, model, subElements );81 break;82 case 'TF_PricingTable':83 fusionPreview.updatePricingTablePreview( thisRef, model, subElements );84 break;85 case 'TF_ProgressBar':86 fusionPreview.updateProgressBarPreview( thisRef, model, subElements );87 break;88 case 'TF_RecentPosts':89 fusionPreview.updateRecentPostsPreview( thisRef, model, subElements );90 break;91 case 'TF_RecentWorks':92 fusionPreview.updateRecentWorksPreview( thisRef, model, subElements );93 break;94 case 'TF_RevolutionSlider':95 fusionPreview.updateRevSliderPreview( thisRef, model, subElements );96 break;97 case 'TF_Separator':98 fusionPreview.updateSeparatorPreview( thisRef, model, subElements );99 break;100 case 'TF_SharingBox':101 fusionPreview.updateSharingBoxPreview( thisRef, model, subElements );102 break;103 case 'TF_Slider':104 fusionPreview.updateSliderPreview( thisRef, model, subElements );105 break;106 case 'TF_SoundCloud':107 fusionPreview.updateSoundCloudPreview( thisRef, model, subElements );108 break;109 case 'TF_Tabs':110 fusionPreview.updateTabsPreview( thisRef, model, subElements );111 break;112 case 'TF_Table':113 fusionPreview.updateTablePreview( thisRef, model, subElements );114 break;115 case 'TF_TaglineBox':116 fusionPreview.updateTaglineBoxPreview( thisRef, model, subElements );117 break;118 case 'TF_Testimonial':119 fusionPreview.updateTestimonialPreview( thisRef, model, subElements );120 break;121 case 'TF_FusionText':122 fusionPreview.updateTextBlockPreview( thisRef, model, subElements );123 break;124 case 'TF_Title':125 fusionPreview.updateTitlePreview( thisRef, model, subElements );126 break;127 case 'TF_Toggles':128 fusionPreview.updateTogglesPreview( thisRef, model, subElements );129 break;130 case 'TF_Vimeo':131 fusionPreview.updateVimeoPreview( thisRef, model, subElements );132 break;133 case 'TF_WooShortcodes':134 fusionPreview.updateWooShortcodesPreview( thisRef, model, subElements );135 break;136 case 'TF_Youtube':137 fusionPreview.updateYoutubePreview( thisRef, model, subElements );138 break;139 default:140 $(thisRef.el).find('.innerElement').html( model.get('innerHtml') );141 }142 }143 /**144 * Update Preview of element145 *146 * @since 2.0.0147 *148 * @param OBJECT Reference to current element149 *150 * @param OBJECT Data model of element151 *152 * @param OBJECT Sub elements data153 *154 * @return NULL155 **/156 fusionPreview.updateAlertPreview = function( thisRef, model, subElements ) {157 var innerHtml = model.get('innerHtml');158 var icon = '';159 //for icon160 switch(subElements[0].value ) {161 case 'general':162 icon = 'fa fa-lg fa-info-circle';163 break;164 case 'error':165 icon = 'fa fa-lg fa-exclamation-triangle';166 break;167 case 'success':168 icon = 'fa fa-lg fa-check-circle';169 break;170 case 'notice':171 icon = 'fa fa-lg fa-lg fa-cog';172 break;173 case 'custom':174 icon = 'fa '+subElements[4].value;175 break;176 }177 innerHtml = innerHtml.replace( $(innerHtml).find('sub.sub').html() , subElements[6].value );178 innerHtml = innerHtml.replace( $(innerHtml).find('i').attr('class') , icon );179 $(thisRef.el).find('.innerElement').html( innerHtml );180 }181 /**182 * Update Preview of element183 *184 * @since 2.0.0185 *186 * @param OBJECT Reference to current element187 *188 * @param OBJECT Data model of element189 *190 * @param OBJECT Sub elements data191 *192 * @return NULL193 **/194 fusionPreview.updateBlogPreview = function( thisRef, model, subElements ) {195 var innerHtml = model.get('innerHtml');196 innerHtml = innerHtml.replace( $(innerHtml).find('span.blog_layout').html() , subElements[0].value );197 if(subElements[0].value == 'grid') {198 innerHtml = innerHtml.replace( $(innerHtml).find('font.blog_columns').html() , '<br /> columns = ' + subElements[19].value );199 } else {200 innerHtml = innerHtml.replace( $(innerHtml).find('font.blog_columns').html(), '' );201 }202 $(thisRef.el).find('.innerElement').html( innerHtml );203 }204 /**205 * Update Preview of element206 *207 * @since 2.0.0208 *209 * @param OBJECT Reference to current element210 *211 * @param OBJECT Data model of element212 *213 * @param OBJECT Sub elements data214 *215 * @return NULL216 **/217 fusionPreview.updateButtonPreview = function( thisRef, model, subElements ) {218 var innerHtml = model.get('innerHtml');219 var buttonStyle = '';220 //for button color221 switch( subElements[1].value ) {222 case 'custom':223 var topC = ( subElements[8].value == 'transparent' ) ? '#ebeaea' : subElements[8].value;224 var botC = subElements[9].value;225 var acnC = subElements[12].value;226 buttonStyle = "background: "+topC+";background: -moz-linear-gradient(top, "+topC+" 0%, "+botC+" 100%);background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,"+topC+"), color-stop(100%,"+botC+"));background: -webkit-linear-gradient(top, "+topC+" 0%,"+botC+" 100%);background: -o-linear-gradient(top, "+topC+" 0%,"+botC+" 100%);background: -ms-linear-gradient(top, "+topC+" 0%,"+botC+" 100%);background: linear-gradient(to bottom, "+topC+" 0%,"+botC+" 100%);filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='"+topC+"', endColorstr='"+botC+"',GradientType=0 );border: 1px solid #fff;color: #fff;border: 1px solid "+acnC+";color: "+acnC+";";227 innerHtml = innerHtml.replace( $(innerHtml).find('a.button').attr('style') , buttonStyle );228 innerHtml = innerHtml.replace( $(innerHtml).find('a.button').attr('class') , 'button custom' );229 break;230 default:231 buttonStyle = "button "+subElements[1].value;232 innerHtml = innerHtml.replace( $(innerHtml).find('a.button').attr('class') , buttonStyle );233 break;234 }235 innerHtml = innerHtml.replace( $(innerHtml).find('span.fusion-button-text').html() , subElements[7].value );236 $(thisRef.el).find('.innerElement').html( innerHtml );237 }238 /**239 * Update Preview of element240 *241 * @since 2.0.0242 *243 * @param OBJECT Reference to current element244 *245 * @param OBJECT Data model of element246 *247 * @param OBJECT Sub elements data248 *249 * @return NULL250 **/251 fusionPreview.updateChecklistPreview = function( thisRef, model, subElements ) {252 var innerHtml = model.get('innerHtml');253 var totalElements = subElements[7].elements.length;254 var previewData = '';255 var counter = 0;256 for ( i = 0; i < totalElements; i ++) {257 element = subElements[7].elements[i];258 value = '';259 //fot HTML260 if( /<[a-z][\s\S]*>/i.test( element[1].value ) ) {261 value = $(element[1].value).text();262 }else {263 value = element[1].value;264 }265 if( element[1].value != '' ) {266 previewData+= '<li><i ';267 if( element[0].value != '' ) {268 previewData+= 'class="fa '+element[0].value+'"></i>';269 } else {270 previewData+= 'class="fa '+subElements[0].value+'"></i>';271 }272 previewData+= value;273 previewData+= '</li>';274 counter++;275 }276 if( counter == 3 ) { break; }277 }278 innerHtml = innerHtml.replace( $(innerHtml).find('ul.checklist_elements').html() , previewData );279 $(thisRef.el).find('.innerElement').html( innerHtml );280 }281 /**282 * Update Preview of element283 *284 * @since 2.0.0285 *286 * @param OBJECT Reference to current element287 *288 * @param OBJECT Data model of element289 *290 * @param OBJECT Sub elements data291 *292 * @return NULL293 **/294 fusionPreview.updateClientSliderPreview = function( thisRef, model, subElements ) {295 var innerHtml = model.get('innerHtml');296 var totalElements = subElements[3].elements.length;297 var previewData = '';298 for ( i = 0; i < totalElements; i ++) {299 element = subElements[3].elements[i];300 previewData+= '<li>';301 previewData+= ' <img src="'+element[2].value+'">';302 previewData+= '</li>';303 if( i == 4 ) break;304 }305 innerHtml = innerHtml.replace( $(innerHtml).find('ul.client_slider_elements').html() , previewData );306 $(thisRef.el).find('.innerElement').html( innerHtml );307 }308 /**309 * Update Preview of element310 *311 * @since 2.0.0312 *313 * @param OBJECT Reference to current element314 *315 * @param OBJECT Data model of element316 *317 * @param OBJECT Sub elements data318 *319 * @return NULL320 **/321 fusionPreview.updateContentBoxesPreview = function( thisRef, model, subElements ) {322 var innerHtml = model.get('innerHtml');323 innerHtml = innerHtml.replace( $(innerHtml).find('span.content_boxes_layout').html() , subElements[1].value );324 innerHtml = innerHtml.replace( $(innerHtml).find('font.content_boxes_columns').html() , subElements[2].value );325 $(thisRef.el).find('.innerElement').html( innerHtml );326 }327 /**328 * Update Preview of element329 *330 * @since 2.0.0331 *332 * @param OBJECT Reference to current element333 *334 * @param OBJECT Data model of element335 *336 * @param OBJECT Sub elements data337 *338 * @return NULL339 **/340 fusionPreview.updateCounterBoxPreview = function( thisRef, model, subElements ) {341 var innerHtml = model.get('innerHtml');342 innerHtml = innerHtml.replace( $(innerHtml).find('font.counter_box_columns').html() , subElements[0].value );343 $(thisRef.el).find('.innerElement').html( innerHtml );344 }345 /**346 * Update Preview of element347 *348 * @since 2.0.0349 *350 * @param OBJECT Reference to current element351 *352 * @param OBJECT Data model of element353 *354 * @param OBJECT Sub elements data355 *356 * @return NULL357 **/358 fusionPreview.updateFlipBoxesPreview = function( thisRef, model, subElements ) {359 var innerHtml = model.get('innerHtml');360 innerHtml = innerHtml.replace( $(innerHtml).find('font.flip_boxes_columns').html() , subElements[0].value );361 $(thisRef.el).find('.innerElement').html( innerHtml );362 }363 /**364 * Update Preview of element365 *366 * @since 2.0.0367 *368 * @param OBJECT Reference to current element369 *370 * @param OBJECT Data model of element371 *372 * @param OBJECT Sub elements data373 *374 * @return NULL375 **/376 fusionPreview.updateFontAwesomePreview = function( thisRef, model, subElements ) {377 var innerHtml = model.get('innerHtml');378 var previewData = '';379 var iconElement = '';380 //for icon381 if( !subElements[0].value.trim() ) {382 iconElement = '<i class="fusiona-flag" style="color:'+subElements[3].value+'"></i>';383 } else {384 iconElement = '<i class="fa '+subElements[0].value+'" style="color:'+subElements[3].value+'"></i>';385 }386 //for circle387 if( subElements[1].value == 'yes' ) {388 previewData = '<h3 style="background:'+subElements[4].value+'">'+iconElement+'</h3>';389 } else {390 previewData = iconElement;391 }392 innerHtml = innerHtml.replace( $(innerHtml).find('span.fusion_iconbox_icon').html() , previewData );393 $(thisRef.el).find('.innerElement').html( innerHtml );394 }395 /**396 * Update Preview of element397 *398 * @since 2.0.0399 *400 * @param OBJECT Reference to current element401 *402 * @param OBJECT Data model of element403 *404 * @param OBJECT Sub elements data405 *406 * @return NULL407 **/408 fusionPreview.updateFusionSliderPreview = function( thisRef, model, subElements ) {409 var innerHtml = model.get('innerHtml');410 innerHtml = innerHtml.replace( $(innerHtml).find('span.fusion_slider_name').html() , subElements[0].value );411 $(thisRef.el).find('.innerElement').html( innerHtml );412 }413 /**414 * Update Preview of element415 *416 * @since 2.0.0417 *418 * @param OBJECT Reference to current element419 *420 * @param OBJECT Data model of element421 *422 * @param OBJECT Sub elements data423 *424 * @return NULL425 **/426 fusionPreview.updateGoogleMapPreview = function( thisRef, model, subElements ) {427 var innerHtml = model.get('innerHtml');428 innerHtml = innerHtml.replace( $(innerHtml).find('p.google_map_address').html() , subElements[16].value );429 $(thisRef.el).find('.innerElement').html( innerHtml );430 }431 /**432 * Update Preview of element433 *434 * @since 2.0.0435 *436 * @param OBJECT Reference to current element437 *438 * @param OBJECT Data model of element439 *440 * @param OBJECT Sub elements data441 *442 * @return NULL443 **/444 fusionPreview.updateImageFramePreview = function( thisRef, model, subElements ) {445 var innerHtml = model.get('innerHtml');446 innerHtml = innerHtml.replace( $(innerHtml).find('div.img_frame_section').html() , '<img src="'+subElements[9].value+'">' );447 $(thisRef.el).find('.innerElement').html( innerHtml );448 }449 /**450 * Update Preview of element451 *452 * @since 2.0.0453 *454 * @param OBJECT Reference to current element455 *456 * @param OBJECT Data model of element457 *458 * @param OBJECT Sub elements data459 *460 * @return NULL461 **/462 fusionPreview.updateImageCarouselPreview = function( thisRef, model, subElements ) {463 var innerHtml = model.get('innerHtml');464 var totalElements = subElements[12].elements.length;465 var previewData = '';466 for ( i = 0; i < totalElements; i ++) {467 element = subElements[12].elements[i];468 previewData+= '<li>';469 previewData+= ' <img src="'+element[2].value+'">';470 previewData+= '</li>';471 if( i == 4 ) break;472 }473 innerHtml = innerHtml.replace( $(innerHtml).find('ul.image_carousel_elements').html() , previewData );474 $(thisRef.el).find('.innerElement').html( innerHtml );475 }476 /**477 * Update Preview of element478 *479 * @since 2.0.0480 *481 * @param OBJECT Reference to current element482 *483 * @param OBJECT Data model of element484 *485 * @param OBJECT Sub elements data486 *487 * @return NULL488 **/489 fusionPreview.updateLayerSliderPreview = function( thisRef, model, subElements ) {490 var innerHtml = model.get('innerHtml');491 innerHtml = innerHtml.replace( $(innerHtml).find('span.layer_slider_id').html() , subElements[0].value );492 $(thisRef.el).find('.innerElement').html( innerHtml );493 }494 /**495 * Update Preview of element496 *497 * @since 2.0.0498 *499 * @param OBJECT Reference to current element500 *501 * @param OBJECT Data model of element502 *503 * @param OBJECT Sub elements data504 *505 * @return NULL506 **/507 fusionPreview.updateMenuAnchorPreview = function( thisRef, model, subElements ) {508 var innerHtml = model.get('innerHtml');509 innerHtml = innerHtml.replace( $(innerHtml).find('span.anchor_name').html() , subElements[0].value );510 $(thisRef.el).find('.innerElement').html( innerHtml );511 }512 /**513 * Update Preview of element514 *515 * @since 2.0.0516 *517 * @param OBJECT Reference to current element518 *519 * @param OBJECT Data model of element520 *521 * @param OBJECT Sub elements data522 *523 * @return NULL524 **/525 fusionPreview.updateModalPreview = function( thisRef, model, subElements ) {526 var innerHtml = model.get('innerHtml');527 innerHtml = innerHtml.replace( $(innerHtml).find('span.modal_name').html() , subElements[0].value );528 $(thisRef.el).find('.innerElement').html( innerHtml );529 }530 /**531 * Update Preview of element532 *533 * @since 2.0.0534 *535 * @param OBJECT Reference to current element536 *537 * @param OBJECT Data model of element538 *539 * @param OBJECT Sub elements data540 *541 * @return NULL542 **/543 fusionPreview.updatePersonPreview = function( thisRef, model, subElements ) {544 var innerHtml = model.get('innerHtml');545 innerHtml = innerHtml.replace( $(innerHtml).find('div.img_frame_section').html() , '<img src="'+subElements[3].value+'">' );546 innerHtml = innerHtml.replace( $(innerHtml).find('p.person_name').html() , subElements[0].value );547 $(thisRef.el).find('.innerElement').html( innerHtml );548 }549 /**550 * Update Preview of element551 *552 * @since 2.0.0553 *554 * @param OBJECT Reference to current element555 *556 * @param OBJECT Data model of element557 *558 * @param OBJECT Sub elements data559 *560 * @return NULL561 **/562 fusionPreview.updatePostSliderPreview = function( thisRef, model, subElements ) {563 var innerHtml = model.get('innerHtml');564 //for attachment layout565 if( subElements[0].value == 'attachments' ) {566 innerHtml = innerHtml.replace( $(innerHtml).find('span.cat_container').attr('style') , 'display:none' );567 } else {568 innerHtml = innerHtml.replace( $(innerHtml).find('span.cat_container').attr('style') , 'display:' );569 }570 innerHtml = innerHtml.replace( $(innerHtml).find('span.post_slider_layout').html() , subElements[0].value );571 var cat = ( !subElements[2].value.trim() ) ? 'all' : subElements[2].value;572 innerHtml = innerHtml.replace( $(innerHtml).find('span.post_slider_cat').html() , cat );573 $(thisRef.el).find('.innerElement').html( innerHtml );574 }575 /**576 * Update Preview of element577 *578 * @since 2.0.0579 *580 * @param OBJECT Reference to current element581 *582 * @param OBJECT Data model of element583 *584 * @param OBJECT Sub elements data585 *586 * @return NULL587 **/588 fusionPreview.updatePricingTablePreview = function( thisRef, model, subElements ) {589 var innerHtml = model.get('innerHtml');590 var columns = subElements[4].value.match(/pricing_column/g);591 innerHtml = innerHtml.replace( $(innerHtml).find('span.pricing_table_style').html() , subElements[0].value );592 innerHtml = innerHtml.replace( $(innerHtml).find('font.pricing_table_columns').html() , columns.length / 2 );593 $(thisRef.el).find('.innerElement').html( innerHtml );594 }595 /**596 * Update Preview of element597 *598 * @since 2.0.0599 *600 * @param OBJECT Reference to current element601 *602 * @param OBJECT Data model of element603 *604 * @param OBJECT Sub elements data605 *606 * @return NULL607 **/608 fusionPreview.updateProgressBarPreview = function( thisRef, model, subElements ) {609 var innerHtml = model.get('innerHtml');610 innerHtml = innerHtml.replace( $(innerHtml).find('p.progress_bar_text').html() , subElements[9].value );611 $(thisRef.el).find('.innerElement').html( innerHtml );612 }613 /**614 * Update Preview of element615 *616 * @since 2.0.0617 *618 * @param OBJECT Reference to current element619 *620 * @param OBJECT Data model of element621 *622 * @param OBJECT Sub elements data623 *624 * @return NULL625 **/626 fusionPreview.updateRecentPostsPreview = function( thisRef, model, subElements ) {627 var innerHtml = model.get('innerHtml');628 innerHtml = innerHtml.replace( $(innerHtml).find('span.recent_posts_layout').html() , subElements[0].value );629 innerHtml = innerHtml.replace( $(innerHtml).find('font.recent_posts_columns').html() , subElements[2].value );630 var cats = fusionParser.getUniqueElements( subElements[5].value ).join();631 cats = ( cats == '' ? 'All' : cats);632 innerHtml = innerHtml.replace( $(innerHtml).find('font.recent_posts_cats').html() , cats );633 $(thisRef.el).find('.innerElement').html( innerHtml );634 }635 /**636 * Update Preview of element637 *638 * @since 2.0.0639 *640 * @param OBJECT Reference to current element641 *642 * @param OBJECT Data model of element643 *644 * @param OBJECT Sub elements data645 *646 * @return NULL647 **/648 fusionPreview.updateRecentWorksPreview = function( thisRef, model, subElements ) {649 var innerHtml = model.get('innerHtml');650 //for carousel layout651 if( subElements[0].value == 'carousel' ) {652 innerHtml = innerHtml.replace( $(innerHtml).find('span.columns_container').attr('style') , 'display:none' );653 } else {654 innerHtml = innerHtml.replace( $(innerHtml).find('span.columns_container').attr('style') , 'display:' );655 }656 innerHtml = innerHtml.replace( $(innerHtml).find('span.recent_works_layout').html() , subElements[0].value );657 innerHtml = innerHtml.replace( $(innerHtml).find('font.recent_works_columns').html() , subElements[4].value );658 var cats = fusionParser.getUniqueElements(subElements[6].value).join();659 cats = ( cats == '' ? 'All' : cats);660 innerHtml = innerHtml.replace( $(innerHtml).find('font.recent_works_cats').html() , cats );661 $(thisRef.el).find('.innerElement').html( innerHtml );662 }663 /**664 * Update Preview of element665 *666 * @since 2.0.0667 *668 * @param OBJECT Reference to current element669 *670 * @param OBJECT Data model of element671 *672 * @param OBJECT Sub elements data673 *674 * @return NULL675 **/676 fusionPreview.updateRevSliderPreview = function( thisRef, model, subElements ) {677 var innerHtml = model.get('innerHtml');678 innerHtml = innerHtml.replace( $(innerHtml).find('span.rev_slider_name').html() , subElements[0].value );679 $(thisRef.el).find('.innerElement').html( innerHtml );680 }681 /**682 * Update Preview of element683 *684 * @since 2.0.0685 *686 * @param OBJECT Reference to current element687 *688 * @param OBJECT Data model of element689 *690 * @param OBJECT Sub elements data691 *692 * @return NULL693 **/694 fusionPreview.updateSeparatorPreview = function( thisRef, model, subElements ) {695 var innerHtml = model.get('innerHtml');696 var sep_css, icon_css = '';697 subElements[0].value = ( !subElements[0].value.trim() ) ? 'none' : subElements[0].value;698 innerHtml = innerHtml.replace( $(innerHtml).find('section').attr('class') , 'separator ' + subElements[0].value.replace("|", "_") );699 switch( subElements[0].value ) {700 case 'none':701 //do nothing702 break;703 case 'double':704 sep_css = 'border-bottom: 1px solid '+subElements[3].value+';border-top: 1px solid '+subElements[3].value+';';705 break;706 case 'double|dashed':707 sep_css = 'border-bottom: 1px dashed '+subElements[3].value+';border-top: 1px dashed '+subElements[3].value+';';708 break;709 case 'double|dotted':710 sep_css = 'border-bottom: 1px dotted '+subElements[3].value+';border-top: 1px dotted '+subElements[3].value+';';711 break;712 case 'shadow':713 sep_css = 'background:radial-gradient(ellipse at 50% -50% , '+subElements[3].value+' 0px, rgba(255, 255, 255, 0) 80%) repeat scroll 0 0 rgba(0, 0, 0, 0)';714 break;715 default:716 sep_css = 'background:'+subElements[3].value+';';717 break;718 }719 // width720 if( subElements[8].value != '' ) {721 sep_css += 'width:'+subElements[7].value+';';722 // alignment723 if( subElements[9].value == 'left' ) {724 sep_css += 'margin-left:5%;margin-right:0;';725 } else if ( subElements[9].value == 'right' ) {726 sep_css += 'float:right;margin-right:5%;';727 }728 }729 if( subElements[3].value != '' || subElements[8].value != '' ) {730 innerHtml = innerHtml.replace( $(innerHtml).find('section').attr('style') , sep_css );731 }732 //for icon733 if( subElements[0].value != 'none' && subElements[0].value != '' && subElements[5].value != '' ) {734 innerHtml = innerHtml.replace( $(innerHtml).find('i:eq(1)').attr('class') , "icon fa "+subElements[5].value);735 } else {736 innerHtml = innerHtml.replace( $(innerHtml).find('i:eq(1)').attr('class') , "fake_class");737 }738 //color for circle border739 if ( subElements[6].value != 'no' ) {740 icon_css = "color:"+subElements[3].value+";border-color:"+subElements[3].value+';';741 } else {742 icon_css = "color:"+subElements[3].value+";border-color:transparent;";743 }744 //color for circle bg745 if ( subElements[7].value != '' ) {746 icon_css += "background-color:"+subElements[7].value;747 }748 innerHtml = innerHtml.replace( $(innerHtml).find('i:eq(1)').attr('style') , icon_css );749 //for upper content750 if( subElements[0].value != 'none' ) {751 innerHtml = innerHtml.replace( $(innerHtml).find('span.upper_container').attr('style') , 'display:none' );752 } else {753 innerHtml = innerHtml.replace( $(innerHtml).find('span.upper_container').attr('style') , '' );754 }755 $(thisRef.el).find('.innerElement').html( innerHtml );756 }757 /**758 * Update Preview of element759 *760 * @since 2.0.0761 *762 * @param OBJECT Reference to current element763 *764 * @param OBJECT Data model of element765 *766 * @param OBJECT Sub elements data767 *768 * @return NULL769 **/770 fusionPreview.updateSharingBoxPreview = function( thisRef, model, subElements ) {771 var innerHtml = model.get('innerHtml');772 innerHtml = innerHtml.replace( $(innerHtml).find('p.sharing_tagline').html() , subElements[0].value );773 $(thisRef.el).find('.innerElement').html( innerHtml );774 }775 /**776 * Update Preview of element777 *778 * @since 2.0.0779 *780 * @param OBJECT Reference to current element781 *782 * @param OBJECT Data model of element783 *784 * @param OBJECT Sub elements data785 *786 * @return NULL787 **/788 fusionPreview.updateSliderPreview = function( thisRef, model, subElements ) {789 var innerHtml = model.get('innerHtml');790 var totalElements = subElements[5].elements.length;791 var previewData = '';792 for ( i = 0; i < totalElements; i ++) {793 element = subElements[5].elements[i];794 previewData+= '<li>';795 if( element[0].value == 'video' ) {796 previewData+= '<h1 class="video_type">Video</h1>';797 } else if ( element[0].value == 'image' ) {798 previewData+= ' <img src="'+element[1].value+'">';799 }800 previewData+= '</li>';801 if( i == 4 ) break;802 }803 innerHtml = innerHtml.replace( $(innerHtml).find('ul.slider_elements').html() , previewData );804 $(thisRef.el).find('.innerElement').html( innerHtml );805 }806 /**807 * Update Preview of element808 *809 * @since 2.0.0810 *811 * @param OBJECT Reference to current element812 *813 * @param OBJECT Data model of element814 *815 * @param OBJECT Sub elements data816 *817 * @return NULL818 **/819 fusionPreview.updateSoundCloudPreview = function( thisRef, model, subElements ) {820 var innerHtml = model.get('innerHtml');821 innerHtml = innerHtml.replace( $(innerHtml).find('p.soundcloud_url').html() , subElements[0].value );822 $(thisRef.el).find('.innerElement').html( innerHtml );823 }824 /**825 * Update Preview of element826 *827 * @since 2.0.0828 *829 * @param OBJECT Reference to current element830 *831 * @param OBJECT Data model of element832 *833 * @param OBJECT Sub elements data834 *835 * @return NULL836 **/837 fusionPreview.updateTabsPreview = function( thisRef, model, subElements ) {838 var innerHtml = model.get('innerHtml');839 var totalElements = subElements[8].elements.length;840 var previewData = '';841 var counter = 0;842 for ( i = 0; i < totalElements; i ++) {843 element = subElements[8].elements[i];844 if( element[0].value != '' ) {845 previewData+= '<li>'+element[0].value+'</li>';846 counter++;847 }848 if( counter == 3 ) break;849 }850 innerHtml = innerHtml.replace( $(innerHtml).find('ul.tabs_elements').html() , previewData );851 $(thisRef.el).find('.innerElement').html( innerHtml );852 }853 /**854 * Update Preview of element855 *856 * @since 2.0.0857 *858 * @param OBJECT Reference to current element859 *860 * @param OBJECT Data model of element861 *862 * @param OBJECT Sub elements data863 *864 * @return NULL865 **/866 fusionPreview.updateTablePreview = function( thisRef, model, subElements ) {867 var innerHtml = model.get('innerHtml');868 innerHtml = innerHtml.replace( $(innerHtml).find('span.table_style').html() , subElements[0].value );869 innerHtml = innerHtml.replace( $(innerHtml).find('font.table_columns').html() , subElements[1].value );870 $(thisRef.el).find('.innerElement').html( innerHtml );871 }872 /**873 * Update Preview of element874 *875 * @since 2.0.0876 *877 * @param OBJECT Reference to current element878 *879 * @param OBJECT Data model of element880 *881 * @param OBJECT Sub elements data882 *883 * @return NULL884 **/885 fusionPreview.updateTaglineBoxPreview = function( thisRef, model, subElements ) {886 var innerHtml = model.get('innerHtml');887 innerHtml = innerHtml.replace( $(innerHtml).find('p.tagline_title').html() , subElements[15].value );888 $(thisRef.el).find('.innerElement').html( innerHtml );889 }890 /**891 * Update Preview of element892 *893 * @since 2.0.0894 *895 * @param OBJECT Reference to current element896 *897 * @param OBJECT Data model of element898 *899 * @param OBJECT Sub elements data900 *901 * @return NULL902 **/903 fusionPreview.updateTestimonialPreview = function( thisRef, model, subElements ) {904 var innerHtml = model.get('innerHtml');905 var totalElements = subElements[6].elements.length;906 var previewData = '';907 for ( i = 0; i < totalElements; i ++) {908 element = subElements[6].elements[i];909 //if name exists910 if ( element[0].value != '' ) {911 previewData+= element[0].value ;912 }913 //if company exists914 if( element[4].value != '' ) {915 previewData+= ', '+element[4].value+'<br>';916 } else {917 previewData+= ', <br>';918 }919 }920 innerHtml = innerHtml.replace( $(innerHtml).find('p.testimonial_content').html() , previewData );921 $(thisRef.el).find('.innerElement').html( innerHtml );922 }923 /**924 * Update Preview of element925 *926 * @since 2.0.0927 *928 * @param OBJECT Reference to current element929 *930 * @param OBJECT Data model of element931 *932 * @param OBJECT Sub elements data933 *934 * @return NULL935 **/936 fusionPreview.updateTextBlockPreview = function( thisRef, model, subElements ) {937 var text_block = $.parseHTML( subElements[0].value );938 var text_block_html = '';939 var insert_icon = '';940 $(text_block).each(function() {941 if($(this).get(0).tagName != 'IMG' && typeof $(this).get(0).tagName != 'undefined') {942 var childrens = $($(this).get(0)).find('*');943 var child_img = false;944 if(childrens.length >= 1) {945 $.each(childrens, function() {946 if($(this).get(0).tagName == 'IMG') {947 child_img = true;948 }949 });950 }951 if(child_img == true) {952 text_block_html += $(this).outerHTML();953 } else {954 text_block_html += $(this).text();955 }956 } else {957 text_block_html += $(this).outerHTML();958 }959 });960 if(text_block_html.indexOf('[/pricing_table]') > -1) {961 insert_icon = '<span class="text-block-icon"><i class="fusiona-icon fusiona-dollar"></i>Pricing Table</span>';962 }963 if(subElements[0].value.indexOf('<div class="table-1">') > -1 || subElements[0].value.indexOf('<div class="table-2">') > -1) {964 insert_icon = '<span class="text-block-icon"><i class="fusiona-icon fusiona-table"></i>Table</span>';965 }966 if(967 typeof wp.shortcode.next('woocommerce_order_tracking', text_block_html) == 'object' ||968 typeof wp.shortcode.next('add_to_cart', text_block_html) == 'object' ||969 typeof wp.shortcode.next('product', text_block_html) == 'object' ||970 typeof wp.shortcode.next('products', text_block_html) == 'object' ||971 typeof wp.shortcode.next('product_categories', text_block_html) == 'object' ||972 typeof wp.shortcode.next('product_category', text_block_html) == 'object' ||973 typeof wp.shortcode.next('recent_products', text_block_html) == 'object' ||974 typeof wp.shortcode.next('featured_products', text_block_html) == 'object' ||975 typeof wp.shortcode.next('woocommerce_shop_messages', text_block_html) == 'object'976 ) {977 insert_icon = '<span class="text-block-icon"><i class="fusiona-icon fusiona-shopping-cart"></i>Woo Shortcodes</span>';978 }979 innerHtml = $( '<div class="fake-wrapper">' + model.get('innerHtml') + '</div>' ).find( 'span' ).append( insert_icon + '<small>'+text_block_html+'</small>' ).parents('.fake-wrapper').html();980 $(thisRef.el).find('.innerElement').html( innerHtml );981 }982 /**983 * Update Preview of element984 *985 * @since 2.0.0986 *987 * @param OBJECT Reference to current element988 *989 * @param OBJECT Data model of element990 *991 * @param OBJECT Sub elements data992 *993 * @return NULL994 **/995 fusionPreview.updateTitlePreview = function( thisRef, model, subElements ) {996 var innerHtml = model.get('innerHtml');997 var value = '';998 //HTML check999 if( /<[a-z][\s\S]*>/i.test( subElements[6].value ) ) {1000 value = $(subElements[6].value).text();1001 }else {1002 value = subElements[6].value;1003 }1004 //for text1005 if( value != '' ) {1006 innerHtml = innerHtml.replace( $(innerHtml).find('sub.title_text').html() , value );1007 }1008 //for color and style1009 innerHtml = innerHtml.replace( $(innerHtml).find('section').attr('class') , subElements[2].value.replace(' ','_') );1010 innerHtml = innerHtml.replace( $(innerHtml).find('section').attr('style') , "border-color:"+subElements[3].value);1011 //for alignment1012 if( subElements[1].value == 'right' ) {1013 innerHtml = innerHtml.replace( $(innerHtml).find('sub.title_text').attr('class') , 'title_text align_right' );1014 } else {1015 innerHtml = innerHtml.replace( $(innerHtml).find('sub.title_text').attr('class') , 'title_text align_left' );1016 }1017 $(thisRef.el).find('.innerElement').html( innerHtml );1018 }1019 /**1020 * Update Preview of element1021 *1022 * @since 2.0.01023 *1024 * @param OBJECT Reference to current element1025 *1026 * @param OBJECT Data model of element1027 *1028 * @param OBJECT Sub elements data1029 *1030 * @return NULL1031 **/1032 fusionPreview.updateTogglesPreview = function( thisRef, model, subElements ) {1033 var innerHtml = model.get('innerHtml');1034 var totalElements = subElements[3].elements.length;1035 var previewData = '';1036 var counter = 0;1037 for ( i = 0; i < totalElements; i ++) {1038 element = subElements[3].elements[i];1039 if( element[0].value != '' ) {1040 previewData+= '<li>'+element[0].value+'</li>';1041 counter++;1042 }1043 if( counter == 3 ) break;1044 }1045 innerHtml = innerHtml.replace( $(innerHtml).find('ul.toggles_content').html() , previewData );1046 $(thisRef.el).find('.innerElement').html( innerHtml );1047 }1048 /**1049 * Update Preview of element1050 *1051 * @since 2.0.01052 *1053 * @param OBJECT Reference to current element1054 *1055 * @param OBJECT Data model of element1056 *1057 * @param OBJECT Sub elements data1058 *1059 * @return NULL1060 **/1061 fusionPreview.updateVimeoPreview = function( thisRef, model, subElements ) {1062 var innerHtml = model.get('innerHtml');1063 innerHtml = innerHtml.replace( $(innerHtml).find('p.viemo_url').html() , "https://vimeo.com/"+subElements[0].value );1064 $(thisRef.el).find('.innerElement').html( innerHtml );1065 }1066 /**1067 * Update Preview of element1068 *1069 * @since 2.0.01070 *1071 * @param OBJECT Reference to current element1072 *1073 * @param OBJECT Data model of element1074 *1075 * @param OBJECT Sub elements data1076 *1077 * @return NULL1078 **/1079 fusionPreview.updateWooShortcodesPreview = function( thisRef, model, subElements ) {1080 var innerHtml = model.get('innerHtml');1081 innerHtml = innerHtml.replace( $(innerHtml).find('p.woo_shortcode').html() , subElements[1].value );1082 $(thisRef.el).find('.innerElement').html( innerHtml );1083 }1084 /**1085 * Update Preview of element1086 *1087 * @since 2.0.01088 *1089 * @param OBJECT Reference to current element1090 *1091 * @param OBJECT Data model of element1092 *1093 * @param OBJECT Sub elements data1094 *1095 * @return NULL1096 **/1097 fusionPreview.updateYoutubePreview = function( thisRef, model, subElements ) {1098 var innerHtml = model.get('innerHtml');1099 innerHtml = innerHtml.replace( $(innerHtml).find('p.youtube_url').html() , "http://www.youtube.com/"+subElements[0].value );1100 $(thisRef.el).find('.innerElement').html( innerHtml );1101 }...
Using AI Code Generation
1var imposter = {2 {3 {4 "is": {5 "headers": {6 },7 "body": {8 }9 }10 }11 {12 {13 "equals": {14 }15 }16 }17 }18};19imposters = {20};21var options = {22};23rp(options)24 .then(function (parsedBody) {25 console.log(parsedBody);26 })27 .catch(function (err) {28 console.log(err);29 });30var subElement = {31 {32 "is": {33 "headers": {34 },35 "body": {36 }37 }38 }39 {40 {41 "equals": {42 }43 }44 }45};46var subElementOptions = {47};48rp(subElementOptions)49 .then(function (parsedBody) {50 console.log(parsedBody);51 })52 .catch(function (err) {53 console.log(err);54 });55var subElement = {56 {57 "is": {58 "headers": {59 },60 "body": {
Using AI Code Generation
1var mb = require('mountebank');2var port = 2525;3 {4 {5 {6 is: {7 }8 }9 }10 }11];12mb.create({ port: 2525, ipWhitelist: ['*'] }, imposters).then(function (server) {13 return server.get('/imposters');14}).then(function (response) {15 console.log(response.body);16});17var mb = require('mountebank');18var port = 2525;19 {20 {21 {22 is: {23 }24 }25 }26 }27];28mb.create({ port: 2525, ipWhitelist: ['*'] }, imposters).then(function (server) {29 return server.get('/imposters');30}).then(function (response) {31 console.log(response.body);32});33var mb = require('mountebank');34var port = 2525;35 {36 {37 {38 is: {39 }40 }41 }42 }43];44mb.create({ port: 2525, ipWhitelist: ['*'] }, imposters).then(function (server) {45 return server.get('/imposters');46}).then(function (response) {47 console.log(response.body);48});49var mb = require('mountebank');50var port = 2525;51 {52 {53 {54 is: {55 }
Using AI Code Generation
1var mb = require('mountebank');2var imposter = mb.create({3 {4 predicates: [{ equals: { path: '/test' } }],5 responses: [{ is: { body: 'Hello World!' } }]6 }7});8imposter.then(function (imposter) {9 console.log('imposter', imposter.port);10});11imposter.then(function (imposter) {12 imposter.addStub({13 predicates: [{ equals: { path: '/test2' } }],14 responses: [{ is: { body: 'Hello World2!' } }]15 });16});17imposter.then(function (imposter) {18 imposter.get().then(function (imposter) {19 console.log(imposter.stubs[0].responses[0].is.body);20 console.log(imposter.stubs[1].responses[0].is.body);21 });22});23imposter.then(function (imposter) {24 imposter.del();25});26var mb = require('mountebank');27var imposter = mb.create({28 {29 predicates: [{ equals: { path: '/test' } }],30 responses: [{ is: { body: 'Hello World!' } }]31 }32});33imposter.then(function (imposter) {34 console.log('imposter', imposter.port);35});36imposter.then(function (imposter) {37 imposter.addStub({38 predicates: [{ equals: { path: '/test2' } }],39 responses: [{ is: { body: 'Hello World2!' } }]40 });41});42imposter.then(function (imposter) {43 imposter.get().then(function (imposter) {44 console.log(imposter.stubs[0].responses[0].is.body);45 console.log(imposter.stubs[1].responses[0].is.body);46 });47});48imposter.then(function (imposter) {49 imposter.del();50});51var mb = require('mountebank');52var imposter = mb.create({53 {54 predicates: [{ equals: { path: '/test'
Using AI Code Generation
1var mb = require('mountebank');2var config = {host: 'localhost', port: 2525};3var imposter = {4 {5 {6 is: {7 }8 }9 }10};11mb.create(config, imposter).then(function (response) {12 console.log(response.body);13});
Using AI Code Generation
1const mb = require('mountebank');2const port = 2525;3const imposterPort = 3000;4const imposterProtocol = 'http';5const imposterName = 'test';6const imposterStub = {7 {8 is: {9 headers: {10 },11 }12 }13};14mb.create(port)15 .then(() => {16 return mb.post('/imposters', {17 });18 })19 .then(response => {20 console.log(JSON.stringify(response.body, null, 2));21 return mb.get('/imposters');22 })23 .then(response => {24 console.log(JSON.stringify(response.body, null, 2));25 return mb.del('/imposters');26 })27 .then(() => {28 console.log('All imposters deleted');29 return mb.stop();30 })31 .then(() => {32 console.log('All done');33 })34 .catch(error => {35 console.error(error);36 process.exit(1);37 });38{39 {40 {41 "is": {42 "headers": {43 },44 }45 }46 }47 "_links": {48 "self": {49 },50 "logs": {51 },52 "stubs": {53 }54 }55}56 {57 {58 {59 "is": {
Using AI Code Generation
1var mb = require('mountebank'),2 assert = require('assert'),3 mbHelper = require('./mbHelper');4mb.create(url, 2525, {protocol: 'http', port: 3000}, function (error, imposter) {5 assert.equal(error, null);6 assert.equal(imposter.port, 2525);7 assert.equal(imposter.protocol, 'http');8 assert.equal(imposter.stubs.length, 0);9 var stub = {10 {11 equals: {12 }13 }14 {15 is: {16 headers: {17 },18 body: JSON.stringify({test: 'test'})19 }20 }21 };22 imposter.addStub(stub, function (error, addedStub) {23 assert.equal(error, null);24 assert.equal(addedStub.predicates[0].equals.method, 'GET');25 assert.equal(addedStub.predicates[0].equals.path, '/test');26 assert.equal(addedStub.responses[0].is.statusCode, 200);27 assert.equal(addedStub.responses[0].is.headers['Content-Type'], 'application/json');28 assert.equal(addedStub.responses[0].is.body, JSON.stringify({test: 'test'}));29 assert.equal(addedStub._links.self.href, '/imposters/2525/stubs/1');30 imposter.getStubs(function (error, stubs) {31 assert.equal(error, null);32 assert.equal(stubs[0].predicates[0].equals.method, 'GET');33 assert.equal(stubs[0].predicates[0].equals.path, '/test');34 assert.equal(stubs[0].responses[0].is.statusCode, 200);35 assert.equal(stubs[0].responses[0].is.headers['Content-Type'], 'application/json');36 assert.equal(stubs[0].responses[0].is.body, JSON.stringify
Using AI Code Generation
1var mb = require('mountebank');2mb.create(2525, function (error, imposter) {3 imposter.post('/path', { statusCode: 200, body: 'Hello World' }, function (error, request, response) {4 console.log('POST /path', response.statusCode, response.body);5 });6 imposter.get('/path', function (error, request, response) {7 console.log('GET /path', response.statusCode, response.body);8 });9 imposter.get('/path', { subElements: true }, function (error, request, response) {10 console.log('GET /path', response.statusCode, response.body);11 });12});13var mb = require('mountebank');14mb.create(2525, function (error, imposter) {15 imposter.post('/path', { statusCode: 200, body: 'Hello World' }, function (error, request, response) {16 console.log('POST /path', response.statusCode, response.body);17 });18 imposter.get('/path', function (error, request, response) {19 console.log('GET /path', response.statusCode, response.body);20 });21 imposter.get('/path', { subElements: true }, function (error, request, response) {22 console.log('GET /path', response.statusCode, response.body);23 });24});25var mb = require('mountebank');26mb.create(2525, function (error, imposter) {27 imposter.post('/path', { statusCode: 200, body: 'Hello World' }, function (error, request, response) {28 console.log('POST /path', response.statusCode, response.body);29 });30 imposter.get('/path', function (error, request, response) {31 console.log('GET /path', response.statusCode, response.body);32 });33 imposter.get('/path', { subElements: true }, function (error, request, response) {34 console.log('GET /path', response.statusCode, response.body);35 });36});37var mb = require('mountebank');38mb.create(2525, function (error, imposter) {
Using AI Code Generation
1mb.subElements('imposters', 'POST', {port: 5000, protocol: 'http', stubs: [{responses: [{is: {body: 'Hello World'}}]}]})2.then(function (response) {3 console.log(response.body);4});5mb.subElements('imposters', 'DELETE', {port: 5000})6.then(function (response) {7 console.log(response.body);8});9mb.subElements('imposters', 'GET', {port: 5000})10.then(function (response) {11 console.log(response.body);12});13mb.subElements('imposters', 'PUT', {port: 5000, protocol: 'http', stubs: [{responses: [{is: {body: 'Hello World'}}]}]})14.then(function (response) {15 console.log(response.body);16});17mb.subElements('imposters', 'PATCH', {port: 5000, protocol: 'http', stubs: [{responses: [{is: {body: 'Hello World'}}]}]})18.then(function (response) {19 console.log(response.body);20});21mb.subElements('imposters', 'OPTIONS', {port: 5000, protocol: 'http', stubs: [{responses: [{is: {body: 'Hello World'}}]}]})22.then(function (response) {23 console.log(response.body);24});25mb.subElements('imposters', 'HEAD', {port: 5000, protocol: 'http', stubs: [{responses: [{is: {body: 'Hello World'}}]}]})26.then(function (response) {27 console.log(response.body);28});29mb.subElements('imposters', 'TRACE
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!