How to use vC method in fast-check-monorepo

Best JavaScript code snippet using fast-check-monorepo

editor.js

Source:editor.js Github

copy

Full Screen

1/* =========================================================2 * lib/panels.js v0.5.03 * =========================================================4 * Copyright 2014 Wpbakery5 *6 * Visual composer panels & modals for frontend editor7 *8 * ========================================================= */9/* global vcDefaultGridItemContent, vc */10(function ( $ ) {11 vc.gridItemEditor = true;12 vc.Storage.prototype.getContent = function () {13 var content;14 if ( _.isObject( window.tinymce ) && tinymce.editors.content ) {15 tinymce.editors.content.save();16 }17 content = window.vc_wpnop( $( '#content' ).val() );18 return ! content.length ? vcDefaultGridItemContent : content;19 };20 vc.visualComposerView.prototype.rowSortableSelector = "> [data-element_type]";21 vc.visualComposerView.prototype.events = {22 'click #vc_templates-editor-button': 'openTemplatesWindow',23 'click [data-vc-navbar-control="edit"]': 'openVcGitemEditForm',24 'click [data-vc-navbar-control="preview"]': 'renderGitemPreview',25 'change [data-vc-navbar-control="preview_width"]': 'setPreviewItemWidth',26 'click #wpb-save-post': 'save',27 'change [data-vc-navbar-control="animation"]': 'changeAnimation'28 };29 vc.visualComposerView.previewActivated = false;30 vc.visualComposerView.prototype.renderGitemPreview = function ( e ) {31 e && e.preventDefault();32 if ( this.previewActivated ) {33 this.hidePreview();34 } else {35 vc.showSpinner();36 this.sendDataGitemPreview();37 }38 };39 /**40 * Creates form to post data to iframe with preview.41 *42 * @since 4.543 */44 vc.visualComposerView.prototype.sendDataGitemPreview = function () {45 var $form;46 $( '[data-vc-grid-item="preview"]' )47 .html( '<iframe name="vc_gitem-preview-iframe"></iframe>' ).addClass( 'vc_visible' );48 // Create content49 $form = $( '<form id="vc_gitem-preview-form" action="' + encodeURI( ajaxurl ) + '" method="post"'50 + ' target="vc_gitem-preview-iframe" style="position: absolute;visibility: hidden;right: 0; bottom:0">'51 + '<input type="hidden" name="action" value="vc_gitem_preview">'52 + '<input type="hidden" id="vc_gitem-preview-form-shortcode-string" name="shortcodes_string">'53 + '<input type="hidden" name="post_id">'54 + '<input type="hidden" name="_vcnonce" value="' + window.vcAdminNonce + '">'55 + '<input type="submit" name="submit">' ).prependTo( 'body' );56 // Set values57 $form.find( '[name="post_id"]' ).val( $( '#post_ID' ).val() );58 $form.find( '[name="shortcodes_string"]' ).val( vc.storage.getContent() );59 // Submit form60 $form.find( '[type="submit"]' ).trigger( 'click' );61 // Remove as useless62 $form.remove();63 };64 vc.visualComposerView.prototype.showPreview = function ( e ) {65 $( '#visual_composer_content' ).hide();66 $( '[data-vc-grid-item="preview"]' ).addClass( 'vc_visible' );67 if ( _.isString( e ) ) {68 $( '[data-vc-grid-item="navbar_preview_width"] select' ).val( e );69 }70 $( '[data-vc-grid-item="navbar_preview_width"]' ).addClass( 'vc_visible' );71 vc.hideSpinner();72 $( '[data-vc-navbar-control="preview"]' ).text( i18nLocaleGItem.builder );73 this.previewActivated = true;74 };75 vc.visualComposerView.prototype.hidePreview = function () {76 $( '#visual_composer_content' ).show();77 $( '[data-vc-grid-item="preview"]' ).removeClass( 'vc_visible' ).empty();78 $( '[data-vc-grid-item="navbar_preview_width"]' ).removeClass( 'vc_visible' );79 this.previewActivated = false;80 $( '[data-vc-navbar-control="preview"]' ).text( i18nLocaleGItem.preview );81 };82 vc.visualComposerView.prototype.setPreviewItemWidth = function ( e ) {83 var iframeWindow = $( '#vc_gitem-preview iframe' ).get( 0 ).contentWindow;84 if ( _.isString( e ) ) {85 $( '[data-vc-grid-item="navbar_preview_width"] select' ).val( e );86 } else if ( e && e.currentTarget ) {87 iframeWindow.vcSetItemWidth( $( e.currentTarget ).val() );88 }89 };90 vc.visualComposerView.prototype.openVcGitemEditForm = function ( e ) {91 e && e.preventDefault();92 var vcGitemModel = vc.shortcodes.findWhere( { shortcode: 'vc_gitem' } );93 this.previewActivated && this.hidePreview();94 vcGitemModel && vc.edit_element_block_view.render( vcGitemModel );95 };96 vc.visualComposerView.prototype.setSortable = function () {97 // 1st level sorting (rows). work also in wp41.98 // 2st level sorting (elements).99 $( '.wpb_column_container' ).sortable( {100 forcePlaceholderSize: true,101 forceHelperSize: false,102 connectWith: ".wpb_column_container",103 placeholder: "vc_placeholder",104 items: "> .wpb_sortable.wpb_content_element,> .wpb_content_element.vc-non-draggable", //wpb_sortablee105 cancel: ".vc-non-draggable", //wpb_sortablee106 helper: this.renderPlaceholder,107 distance: 3,108 scroll: true,109 scrollSensitivity: 70,110 cursor: 'move',111 cursorAt: { top: 20, left: 16 },112 tolerance: 'intersect', // this helps with dragging textblock into tabs113 start: function () {114 $( '#visual_composer_content' ).addClass( 'vc_sorting-started' );115 $( '.vc_not_inner_content' ).addClass( 'dragging_in' );116 },117 stop: function ( event, ui ) {118 $( '#visual_composer_content' ).removeClass( 'vc_sorting-started' );119 $( '.dragging_in' ).removeClass( 'dragging_in' );120 var tag = ui.item.data( 'element_type' ),121 parent_tag = ui.item.parent().closest( '[data-element_type]' ).data( 'element_type' ),122 allowed_container_element = ! _.isUndefined( vc.map[ parent_tag ].allowed_container_element ) ? vc.map[ parent_tag ].allowed_container_element : true;123 if ( ! vc.check_relevance( parent_tag, tag ) ) {124 $( this ).sortable( 'cancel' );125 }126 var is_container = _.isObject( vc.map[ tag ] ) && ( ( _.isBoolean( vc.map[ tag ].is_container ) && true === vc.map[ tag ].is_container ) || ! _.isEmpty( vc.map[ tag ].as_parent ) );127 if ( is_container && ! (true === allowed_container_element || allowed_container_element === ui.item.data( 'element_type' ).replace( /_inner$/,128 '' )) ) {129 $( this ).sortable( 'cancel' );130 }131 $( '.vc_sorting-empty-container' ).removeClass( 'vc_sorting-empty-container' );132 },133 update: this.updateElementsSorting,134 over: function ( event, ui ) {135 var tag = ui.item.data( 'element_type' ),136 parent_tag = ui.placeholder.closest( '[data-element_type]' ).data( 'element_type' ),137 allowed_container_element = ! _.isUndefined( vc.map[ parent_tag ].allowed_container_element ) ? vc.map[ parent_tag ].allowed_container_element : true;138 if ( ! vc.check_relevance( parent_tag, tag ) ) {139 ui.placeholder.addClass( 'vc_hidden-placeholder' );140 return false;141 }142 var is_container = _.isObject( vc.map[ tag ] ) && ( ( _.isBoolean( vc.map[ tag ].is_container ) && true === vc.map[ tag ].is_container ) || ! _.isEmpty( vc.map[ tag ].as_parent ) );143 if ( is_container && ! (true === allowed_container_element || allowed_container_element === ui.item.data( 'element_type' ).replace( /_inner$/,144 '' )) ) {145 ui.placeholder.addClass( 'vc_hidden-placeholder' );146 return false;147 }148 if ( ui.sender && ui.sender.length && ! ui.sender.find( '[data-element_type]:visible' ).length ) {149 ui.sender.addClass( 'vc_sorting-empty-container' );150 }151 ui.placeholder.removeClass( 'vc_hidden-placeholder' );152 ui.placeholder.css( { maxWidth: ui.placeholder.parent().width() } );153 }154 } );155 return this;156 };157 vc.visualComposerView.prototype.changeAnimation = function ( e ) {158 var $dropdown, params, model, prevAnimation;159 model = vc.shortcodes.findWhere( { shortcode: 'vc_gitem_animated_block' } );160 if ( ! model ) {161 return false;162 }163 $dropdown = $( e.currentTarget );164 params = $.extend( {}, model.get( 'params' ) );165 params.animation = $dropdown.val();166 model.save( { params: params } );167 this.previewActivated && this.changePreviewAnimation( params.animation );168 };169 vc.visualComposerView.prototype.changePreviewAnimation = function ( animation ) {170 var iframeWindow = $( '#vc_gitem-preview iframe' ).get( 0 ).contentWindow;171 iframeWindow && iframeWindow.changeAnimation( animation );172 };173 vc.visualComposerView.prototype.initializeAccessPolicy = function () {174 this.accessPolicy = {175 be_editor: vc_user_access().editor( 'grid_builder' ),176 fe_editor: false,177 classic_editor: false178 };179 };180 vc.EditElementPanelView.prototype.ajaxData = function () {181 var params, mergedParams;182 params = this.model.get( 'params' );183 mergedParams = vc.getMergedParams( this.model.get( 'shortcode' ),184 _.extend( {}, vc.getDefaults( this.model.get( 'shortcode' ) ), params ) );185 if ( ! _.isUndefined( params.content ) ) {186 mergedParams.content = params.content;187 }188 return {189 action: 'vc_edit_form',190 vc_grid_item_editor: 'true',191 tag: this.model.get( 'shortcode' ),192 post_id: $( '#post_ID' ).val(),193 params: mergedParams,194 _vcnonce: window.vcAdminNonce195 };196 };197 vc.EditElementPanelView.prototype.fetchSaveSettingsDialogAjaxData = function () {198 return {199 action: 'vc_action_render_settings_preset_title_prompt',200 vc_inline: true,201 vc_grid_item_editor: true,202 _vcnonce: window.vcAdminNonce203 };204 };205 vc.EditElementPanelView.prototype.saveSettingsAjaxData = function ( shortcode_name, title, is_default, data ) {206 return {207 action: 'vc_action_save_settings_preset',208 shortcode_name: shortcode_name,209 is_default: is_default ? 1 : 0,210 vc_inline: true,211 title: title,212 data: data,213 vc_grid_item_editor: true,214 _vcnonce: window.vcAdminNonce215 };216 };217 vc.EditElementPanelView.prototype.fetchSaveSettingsDialogAjaxData = function () {218 return {219 action: 'vc_action_render_settings_preset_title_prompt',220 vc_inline: true,221 vc_grid_item_editor: true,222 _vcnonce: window.vcAdminNonce223 };224 };225 vc.EditElementPanelView.prototype.loadSettingsAjaxData = function ( id ) {226 return {227 action: 'vc_action_get_settings_preset',228 vc_inline: true,229 id: id,230 vc_grid_item_editor: true,231 _vcnonce: window.vcAdminNonce232 };233 };234 vc.EditElementPanelView.prototype.deleteSettingsAjaxData = function ( shortcode_name, id ) {235 return {236 action: 'vc_action_delete_settings_preset',237 shortcode_name: shortcode_name,238 vc_inline: true,239 id: id,240 vc_grid_item_editor: true,241 _vcnonce: window.vcAdminNonce242 }243 };244 vc.EditElementPanelView.prototype.saveAsDefaultSettingsAjaxData = function ( shortcode_name ) {245 return {246 action: 'vc_action_set_as_default_settings_preset',247 shortcode_name: shortcode_name,248 id: this.settingsPresetId,249 vc_inline: true,250 vc_grid_item_editor: true,251 _vcnonce: window.vcAdminNonce252 };253 };254 vc.EditElementPanelView.prototype.restoreDefaultSettingsAjaxData = function ( shortcode_name ) {255 return {256 action: 'vc_action_restore_default_settings_preset',257 shortcode_name: shortcode_name,258 vc_inline: true,259 vc_grid_item_editor: true,260 _vcnonce: window.vcAdminNonce261 };262 };263 vc.EditElementPanelView.prototype.reloadSettingsMenuContentAjaxData = function ( shortcode_name ) {264 return {265 action: 'vc_action_render_settings_preset_popup',266 shortcode_name: shortcode_name,267 vc_inline: true,268 vc_grid_item_editor: true,269 _vcnonce: window.vcAdminNonce270 };271 };272 vc.EditElementPanelView.prototype.renderSettingsPresetAjaxData = function ( params ) {273 var parent_id;274 parent_id = this.model.get( 'parent_id' );275 return {276 action: 'vc_edit_form',277 tag: this.model.get( 'shortcode' ),278 parent_tag: parent_id ? this.model.collection.get( parent_id ).get( 'shortcode' ) : null,279 post_id: $( '#post_ID' ).val(),280 params: params,281 vc_grid_item_editor: true,282 _vcnonce: window.vcAdminNonce283 };284 };285 window.VcGitemView = window.VcColumnView.extend( {286 animatedBlock: false,287 cZone: false,288 events: {289 'click > .vc_controls [data-vc-control="delete"]': 'deleteShortcode',290 'click > .vc_controls [data-vc-control="add"]': 'addElement',291 'click > .vc_controls [data-vc-control="edit"]': 'editElement',292 'click > .vc_controls [data-vc-control="clone"]': 'clone',293 'click [data-vc-gitem="add-c"]': 'addCZone',294 'click > .vc_empty [data-vc-gitem="add-ab"]': 'addAnimatedBlock'295 },296 initialize: function ( options ) {297 window.VcColumnView.__super__.initialize.call( this, options );298 vc.shortcodes.on( 'all', this.setCZoneHeight );299 },300 setContent: function () {301 this.$content = this.$el.find( '> .vc_gitem-content' );302 _.bindAll( this, 'savePositionC', 'startCDragging', 'stopCDragging' );303 },304 setCEmpty: function () {305 this.$content.addClass( 'vc_empty-c' );306 },307 unsetCEmpty: function () {308 this.$content.removeClass( 'vc_empty-c' );309 },310 setEmpty: function () {311 this.$content.addClass( 'vc_empty' );312 },313 unsetEmpty: function () {314 this.$content.removeClass( 'vc_empty' );315 },316 checkIsEmpty: function () {317 // Check for C zone318 if ( vc.shortcodes.where( { parent_id: this.model.id, shortcode: 'vc_gitem_zone_c' } ).length ) {319 this.unsetCEmpty();320 } else {321 this.setCEmpty();322 }323 // Check for Animated block324 if ( vc.shortcodes.where( { parent_id: this.model.if, shortcode: 'vc_gitem_animated_block' } ).length ) {325 this.unsetEmpty();326 } else {327 this.setEmpty();328 }329 window.VcColumnView.__super__.checkIsEmpty.call( this );330 },331 addAnimatedBlock: function ( e ) {332 var animatedBlock;333 e && e.preventDefault();334 if ( this.animatedBlock ) {335 return;336 }337 vc.storage.lock();338 animatedBlock = vc.shortcodes.create( {339 shortcode: 'vc_gitem_animated_block',340 parent_id: this.model.get( 'id' ),341 order: 1,342 params: vc.getDefaults( 'vc_gitem_animated_block' ),343 root_id: this.model.get( 'id' )344 } );345 vc.storage.lock();346 animatedBlock.view.addZone( 'a' );347 animatedBlock.view.addZone( 'b' );348 },349 addCZone: function ( e ) {350 var $column = $( e.currentTarget ),351 position = $column.data( 'vcPosition' ), model;352 if ( this.cZone ) {353 this.updateCZonePosition( $column, position );354 return false;355 }356 model = new vc.shortcode( {357 shortcode: 'vc_gitem_add_c_zone',358 params: {359 cZonePosition: this.getCZoneModelOrder( position ),360 position: position361 },362 parent_id: this.model.get( 'id' )363 } );364 model.view = this;365 vc.add_element_block_view.render( model );366 },367 updateCZonePosition: function ( $column, position ) {368 this.setCZonePosition( position );369 this.setCZoneOrder( position );370 this.changeCZonePosition( $column );371 this.setCssPosition( $column );372 },373 setCZoneOrder: function ( position ) {374 this.cZone.save( { order: this.getCZoneModelOrder( position ) } );375 },376 changeCZonePosition: function ( $column ) {377 this.cZone.view.$el.appendTo( $column );378 },379 setCZonePosition: function ( position ) {380 this.model.save( {381 params: _.extend( {}, this.model.get( 'params' ) || {}, {382 c_zone_position: position383 } )384 } );385 },386 setCZoneHeight: function () {387 var $left = $( '[data-vc-gitem="add-c"][data-vc-position="left"]' ),388 $animated = $( '[data-element_type="vc_gitem_animated_block"]' ),389 $right = $( '[data-vc-gitem="add-c"][data-vc-position="right"]' ),390 max_height;391 $left.height( 'auto' );392 $right.height( 'auto' );393 max_height = Math.max( $left.height(), $animated.height(), $right.height() );394 $left.css( 'height', max_height );395 $right.css( 'height', max_height );396 },397 getCZoneModelOrder: function ( position ) {398 var animatedBlockOrder = this.animatedBlock.get( 'order' );399 return 'top' === position || 'left' === position ? animatedBlockOrder - 1 : animatedBlockOrder + 1400 },401 cZoneRemoved: function () {402 this.cZone = false;403 this.$content.find( '.vc_zone-added' ).removeClass( 'vc_zone-added' );404 this.setCZonePosition( '' );405 },406 setDraggableC: function () {407 this.$content.find( '[data-vc-gitem="add-c"]' ).sortable( {408 items: '[data-element_type="vc_gitem_zone_c"]:not(.vc-non-draggable)',409 connectWith: '[data-vc-gitem="add-c"]',410 forcePlaceholderSize: true,411 forceHelperSize: false,412 placeholder: 'vc_placeholder',413 update: this.savePositionC,414 start: this.startCDragging,415 stop: this.stopCDragging416 } ).disableSelection();417 },418 startCDragging: function ( event, ui ) {419 this.$el.addClass( 'vc_sorting' );420 },421 stopCDragging: function ( event, ui ) {422 this.$el.removeClass( 'vc_sorting' );423 },424 savePositionC: function ( event, ui ) {425 var cBlockContainer = ui.item.parent(),426 position = cBlockContainer.data( 'vcPosition' ) || 'bottom';427 vc.storage.lock();428 this.cZone && this.cZone.save( {429 order: this.getCZoneModelOrder( position )430 } );431 this.setCZonePosition( position );432 this.setCssPosition( cBlockContainer );433 },434 setCssPosition: function ( $container ) {435 this.$content436 .find( '[data-vc-gitem="add-c"].vc_zone-added' )437 .removeClass( 'vc_zone-added' );438 $container.addClass( 'vc_zone-added' );439 },440 addShortcode: function ( view ) {441 var tag = view.model.get( 'shortcode' ),442 position, $zone;443 view.render();444 if ( 'vc_gitem_zone_c' === tag ) {445 position = this.model.getParam( 'c_zone_position' ) || 'bottom';446 $zone = this.$content.find( '[data-vc-gitem="add-c"][data-vc-position="' + position + '"]' );447 view.$el.appendTo( $zone.addClass( 'vc_zone-added' ) );448 this.setDraggableC();449 this.cZone = view.model;450 } else if ( 'vc_gitem_animated_block' === tag ) {451 view.$el.appendTo( $( '[data-vc-gitem="add-ab"]' ) );452 this.animatedBlock = view.model;453 }454 }455 } );456 window.VcGitemAnimatedBlockView = window.VcColumnView.extend( {457 aZone: false,458 bZone: false,459 currentAnimation: '',460 events: {461 'click > .vc_controls [data-vc-control="delete"]': 'deleteShortcode',462 'click > .vc_controls [data-vc-control="add"]': 'addElement',463 'click > .vc_controls [data-vc-control="edit"]': 'editElement',464 'click > .vc_controls [data-vc-control="clone"]': 'clone',465 'click > .vc_empty-a [data-vc-gitem-animated-block="add-a"]': 'addAZone',466 'click > .vc_empty-b [data-vc-gitem-animated-block="add-b"]': 'addBZone',467 'click > .vc_gitem-animated-block-content [data-vc-gitem-tab-link]': 'activateZone',468 'click > .vc_gitem-animated-block-content [data-vc-control="edit"]': 'showEditForm'469 },470 render: function () {471 var animation;472 window.VcGitemAnimatedBlockView.__super__.render.call( this );473 animation = this.model.getParam( 'animation' );474 if ( animation ) {475 $( '[data-vc-navbar-control="animation"]' ).val( animation );476 }477 return this;478 },479 setContent: function () {480 this.$content = this.$el.find( '> .vc_gitem-animated-block-content' );481 },482 buildDesignHelpers: function () {483 window.VcGitemAnimatedBlockView.__super__.buildDesignHelpers.call( this );484 this.setAnimationDropDown();485 this.setAnimationClassToBlock();486 },487 changeShortcodeParams: function ( model ) {488 window.VcGitemAnimatedBlockView.__super__.changeShortcodeParams.call( this, model );489 },490 setAnimationClassToBlock: function () {491 var animation = this.model.getParam( 'animation' ) || 'single';492 if ( this.currentAnimation ) {493 this.$el.removeClass( 'vc_gitem-animation-' + this.currentAnimation );494 }495 this.$el.addClass( 'vc_gitem-animation vc_gitem-animation-' + animation );496 this.currentAnimation = animation;497 },498 setAnimationDropDown: function () {499 var animation = this.model.getParam( 'animation' );500 if ( animation ) {501 $( '[data-vc-gitem-animated-block="animation-dropdown"]' ).val( animation );502 }503 if ( '' === animation ) {504 this.activateZone( { currentTarget: $( '.vc_gitem-tab-a' ).get( 0 ) } )505 }506 },507 addAZone: function ( e ) {508 e && e.preventDefault();509 this.addZone( 'a' );510 },511 addBZone: function ( e ) {512 e && e.preventDefault();513 this.addZone( 'b' );514 },515 addZone: function ( zone ) {516 if ( this[ zone + 'Zone' ] ) {517 return;518 }519 vc.shortcodes.create( {520 shortcode: 'vc_gitem_zone_' + zone,521 parent_id: this.model.get( 'id' ),522 params: vc.getDefaults( 'vc_gitem_zone_' + zone )523 } );524 },525 addTab: function ( zone, id ) {526 var $zone = $( '<li class="vc_gitem-animated-block-tab vc_gitem-tab-'527 + zone + '"><a href="#" data-vc-gitem-tab-link="' + zone + '"><span class="vc_label">' + this.getZoneLabel( zone )528 + '</span></a><a class="vc_control column_edit" data-vc-control="edit" data-vc-zone-model-id="' + id + '"><span class="vc_icon"></span></a></li>' );529 $zone.appendTo( '[data-vc-gitem-animated-block="tabs"]' );530 'a' === zone && this.switchZone( $zone.find( 'a' ) );531 },532 getZoneLabel: function ( zone ) {533 var zoneSettings = vc.map[ 'vc_gitem_zone_' + zone ] ? vc.map[ 'vc_gitem_zone_' + zone ] : false;534 return zoneSettings && zoneSettings.name ? zoneSettings.name : zone;535 },536 activateZone: function ( e ) {537 var $control = $( e.currentTarget );538 e && e.preventDefault && e.preventDefault();539 ! $control.hasClass( 'vc_active' ) && this.switchZone( $control );540 },541 showEditForm: function ( e ) {542 var model_id;543 e && e.preventDefault();544 model_id = $( e.currentTarget ).data( 'vcZoneModelId' );545 model_id && vc.app.views[ model_id ] && vc.app.views[ model_id ].editElement();546 },547 switchZone: function ( $zone ) {548 this.$el.find( '[data-vc-gitem-animated-block="tabs"] .vc_active, [data-vc-gitem-animated-block].vc_active' )549 .removeClass( 'vc_active' );550 $zone.parent().addClass( 'vc_active' );551 this.$el.find( '[data-vc-gitem-animated-block="add-' + $zone.data( 'vcGitemTabLink' ) + '"]' )552 .addClass( 'vc_active' );553 },554 setAEmpty: function () {555 this.$content.addClass( 'vc_empty-a' );556 },557 unsetAEmpty: function () {558 this.$content.removeClass( 'vc_empty-a' );559 },560 setBEmpty: function () {561 this.$content.addClass( 'vc_empty-b' );562 },563 unsetBEmpty: function () {564 this.$content.removeClass( 'vc_empty-b' );565 },566 setEmpty: function () {567 this.setAEmpty();568 this.setBEmpty();569 },570 checkIsEmpty: function () {571 // Check for A zone572 if ( vc.shortcodes.where( { parent_id: this.model.get( 'id' ), shortcode: 'vc_gitem_zone_a' } ).length ) {573 this.unsetAEmpty();574 } else {575 this.setAEmpty();576 }577 // Check for B zone578 if ( vc.shortcodes.where( { parent_id: this.model.get( 'id' ), shortcode: 'vc_gitem_zone_b' } ).length ) {579 this.unsetBEmpty();580 } else {581 this.setBEmpty();582 }583 },584 addShortcode: function ( view ) {585 var tag = view.model.get( 'shortcode' );586 view.render();587 if ( 'vc_gitem_zone_a' === tag ) {588 view.$el.appendTo( this.$el.find( '[data-vc-gitem-animated-block="add-a"]' ) );589 this.aZone = view.model;590 this.addTab( 'a', view.model.get( 'id' ) );591 } else if ( 'vc_gitem_zone_b' === tag ) {592 view.$el.appendTo( this.$el.find( '[data-vc-gitem-animated-block="add-b"]' ) );593 this.bZone = view.model;594 this.addTab( 'b', view.model.get( 'id' ) );595 }596 }597 } );598 window.VcGitemZoneView = window.VcColumnView.extend( {599 addElement: function ( e ) {600 var row;601 e && e.preventDefault();602 vc.storage.lock();603 row = vc.shortcodes.create( {604 shortcode: 'vc_gitem_row',605 params: _.extend( {}, vc.getDefaults( 'vc_gitem_row' ) ),606 parent_id: this.model.get( 'id' )607 } );608 vc.shortcodes.create( {609 shortcode: 'vc_gitem_col',610 params: _.extend( { width: '1/1' }, vc.getDefaults( 'vc_gitem_col' ) ),611 parent_id: row.get( 'id' )612 } );613 },614 buildDesignHelpers: function () {615 var matches;616 var featuredImage, css = this.model.getParam( 'css' ),617 $before = this.$el.find( '> .vc_controls' ).get( 0 ),618 image, color;619 featuredImage = this.model.getParam( 'featured_image' );620 this.$el.find( '> [data-vc-helper="color"]' ).remove();621 this.$el.find( '> [data-vc-helper="image"]' ).remove();622 this.$el.find( '> [data-vc-helper="image-featured"]' ).remove();623 matches = css.match( /background\-image:\s*url\(([^\)]+)\)/ );624 if ( matches && ! _.isUndefined( matches[ 1 ] ) ) {625 image = matches[ 1 ];626 }627 matches = css.match( /background\-color:\s*([^\s\;]+)\b/ );628 if ( matches && ! _.isUndefined( matches[ 1 ] ) ) {629 color = matches[ 1 ];630 }631 matches = css.match( /background:\s*([^\s]+)\b\s*url\(([^\)]+)\)/ );632 if ( matches && ! _.isUndefined( matches[ 1 ] ) ) {633 color = matches[ 1 ];634 image = matches[ 2 ];635 }636 if ( image ) {637 $( '<span class="vc_css-helper vc_image-helper" data-vc-helper="image" style="background-image: url(' + image + ');" title="'638 + i18nLocale.column_background_image + '"></span>' )639 .insertBefore( $before );640 }641 if ( color ) {642 $( '<span class="vc_css-helper vc_color-helper" data-vc-helper="color" style="background-color: ' + color + '" title="'643 + i18nLocale.column_background_color + '"></span>' )644 .insertBefore( $before );645 }646 if ( 'yes' === featuredImage ) {647 $( '<span class="vc_css-helper vc_featured" data-vc-helper="image-featured"></span>' )648 .insertBefore( $before );649 }650 }651 } );652 window.VcGitemZoneCView = window.VcGitemZoneView.extend( {653 removeView: function () {654 window.VcGitemZoneCView.__super__.removeView.call( this );655 var parentModel = vc.shortcodes.get( this.model.get( 'parent_id' ) );656 if ( parentModel && vc.app.views[ parentModel.get( 'id' ) ] ) {657 vc.app.views[ parentModel.get( 'id' ) ].cZoneRemoved();658 }659 }660 } );661 window.VcGitemRowView = window.VcRowView.extend( {662 zone: '',663 sortingSelector: "> [data-element_type=vc_gitem_col]",664 getChildTag: function () {665 return 'vc_gitem_col';666 },667 addElement: function ( e ) {668 e && e.preventDefault();669 vc.shortcodes.create( { shortcode: this.getChildTag(), params: {}, parent_id: this.model.id } );670 this.setActiveLayoutButton();671 },672 buildDesignHelpers: function () {673 /*674 window.VcGitemRowView.__super__.buildDesignHelpers.call(this);675 var $column_move = this.$el.find('> .controls .column_move'),676 zone = this.model.getParam('zone');677 if (this.zone != zone) {678 this.$el.find('> .controls .vc_row-zone').remove();679 $('<span class="vc_control vc_row-zone">' + zone.toUpperCase() + '</span>')680 .insertAfter($column_move);681 !_.isEmpty(this.zone) && this.$el.removeClass('vc_gitem-zone-' + this.zone);682 this.zone = zone;683 this.$el.removeClass('wpb_sortable').addClass(' vc_gitem-zone-' + this.zone);684 }685 */686 }687 } );688 window.VcGitemColView = window.VcColumnView.extend( {689 events: {690 'click > .vc_controls [data-vc-control="delete"]': 'deleteShortcode',691 'click > .vc_controls [data-vc-control="add"]': 'addElement',692 'click > .vc_controls [data-vc-control="edit"]': 'editElement',693 'click > .vc_controls [data-vc-control="clone"]': 'clone',694 'click > .vc_controls [data-vc-align]': 'changeTextAlign',695 'click > .wpb_element_wrapper > .vc_empty-container': 'addToEmpty'696 },697 designHelpersSelector: '> .vc_controls .column_edit',698 changeTextAlign: function ( e ) {699 var $control;700 if ( e ) {701 e.preventDefault();702 $control = $( e.currentTarget );703 // Set controls settings704 if ( $control.hasClass( 'vc_active' ) ) {705 return false;706 }707 $control.parent().find( '.vc_active' ).removeClass( 'vc_active' );708 $control.addClass( 'vc_active' );709 // Change param align.710 _.defer( this.setTextAlign, ($control.data( 'vcAlign' ) || 'left') );711 } else {712 this.$el.find( '> .vc_controls [data-vc-align="'713 + (this.model.getParam( 'align' ) || 'left') + '"]' )714 .addClass( 'vc_active' );715 }716 },717 setTextAlign: function ( align ) {718 var params = _.extend( {}, this.model.get( 'params' ), { align: align } );719 this.model.save( { params: params } );720 },721 render: function () {722 _.bindAll( this, 'setTextAlign' );723 window.VcGitemColView.__super__.render.call( this );724 this.changeTextAlign( undefined );725 return this;726 }727 } );728 vc.AddElementUIPanelBackendEditor.prototype.createElement = function ( e ) {729 _.isObject( e ) && e.preventDefault();730 var model, tag, parent_id = false, cZone, cZoneRow, cZoneCol, showSettings;731 tag = $( e.currentTarget ).data( 'tag' );732 if ( false !== this.model && 'vc_gitem_add_c_zone' === this.model.get( 'shortcode' ) ) {733 this.model.view.setCZonePosition( this.model.getParam( 'position' ) );734 vc.storage.lock();735 cZone = vc.shortcodes.create( {736 shortcode: 'vc_gitem_zone_c',737 parent_id: this.model.get( 'parent_id' ),738 params: _.extend( {}, vc.getDefaults( 'vc_gitem_zone_c' ) ),739 order: this.model.getParam( 'cZonePosition' )740 } );741 this.model.view.cZone = cZone;742 vc.storage.lock();743 cZoneRow = vc.shortcodes.create( {744 shortcode: 'vc_gitem_row',745 params: _.extend( {}, vc.getDefaults( 'vc_gitem_row' ) ),746 parent_id: cZone.get( 'id' )747 } );748 vc.storage.lock();749 cZoneCol = vc.shortcodes.create( {750 shortcode: 'vc_gitem_col',751 params: _.extend( { width: '1/1' }, vc.getDefaults( 'vc_gitem_col' ) ),752 parent_id: cZoneRow.get( 'id' )753 } );754 parent_id = cZoneCol.get( 'id' );755 cZone = null;756 cZoneCol = null;757 } else if ( false !== this.model ) {758 parent_id = this.model.get( 'id' );759 }760 model = vc.shortcodes.create( {761 shortcode: tag,762 parent_id: parent_id,763 params: vc.getDefaults( tag ),764 root_id: vc.shortcodes.findWhere( { shortcode: 'vc_gitem' } ) || false765 } );766 if ( 'vc_gitem_row' === tag ) {767 vc.shortcodes.create( {768 shortcode: 'vc_gitem_col',769 params: { width: '1/1' },770 parent_id: model.get( 'id' ),771 root_id: model.get( 'id' )772 } );773 }774 this.model = model;775 showSettings = ! (_.isBoolean( vc.getMapped( tag ).show_settings_on_create ) && false === vc.getMapped( tag ).show_settings_on_create );776 // extend default params with settings presets if there are any777 shortcode = this.model.get( 'shortcode' );778 if ( 'undefined' !== typeof(window.vc_settings_presets[ shortcode ]) ) {779 this.model.save( {780 params: _.extend( {},781 this.model.attributes.params,782 window.vc_settings_presets[ shortcode ]783 )784 } );785 }786 this.hide();787 if ( showSettings ) {788 this.showEditForm();789 }790 this.addCustomCssStyleTag();791 };792 vc.TemplatesPanelViewBackend.prototype.templateLoadPreviewAction = 'vc_grid_item_editor_load_template_preview';793 vc.TemplatesPanelViewBackend.prototype.renderTemplate = function ( html ) {794 // Render template for backend795 _.each( vc.filters.templates, function ( callback ) {796 html = callback( html );797 } );798 vc.storage.setContent( html );799 vc.shortcodes.fetch( { reset: true } );800 this.hide();801 // TODO: show message802 };803 // Show on one column804 $( document ).ready( function () {805 $( '[name="screen_columns"][value="1"]' ).trigger( 'click' );806 $( '#screen-meta-links, #screen-meta' ).hide();807 } );...

Full Screen

Full Screen

build.js

Source:build.js Github

copy

Full Screen

1/* =========================================================2 * build.js v1.0.13 * =========================================================4 * Copyright 2013 Wpbakery5 *6 * Visual composer builder backbone/underscore version7 * ========================================================= */8if ( _.isUndefined( vc ) ) {9 var vc = {};10}11(function ( $ ) {12 "use strict";13 vc.createPreLoader = function () {14 vc.$preloader = $( '#vc_preloader' );15 };16 vc.removePreLoader = function () {17 vc.$preloader && vc.$preloader.remove();18 };19 vc.createPreLoader();20 vc.$frame_wrapper = $( '#vc_inline-frame-wrapper' );21 vc.$frame = $( '<iframe src="'22 + vc_iframe_src + '" scrolling="auto" style="width: 100%;" id="vc_inline-frame"></iframe>' );23 vc.$frame.appendTo( vc.$frame_wrapper );24 vc.build = function () {25 if ( vc.loaded ) {26 return;27 }28 vc.loaded = true;29 vc.map = window.vc_mapper; // vc_user_mapper // TODO: check why user mapper30 $( '#wpadminbar' ).remove();31 $( '#screen-meta-links, #screen-meta' ).hide();32 var $body = $( 'body' );33 $body.attr( 'data-vc', true );34 vc.post_id = $( '#vc_post-id' ).val();35 vc.is_mobile = 0 < $( 'body.mobile' ).length;36 vc.title = $( '#vc_title-saved' ).val();37 // Create Modals & panels38 vc.add_element_block_view = new vc.AddElementUIPanelFrontendEditor( { el: '#vc_ui-panel-add-element' } );39 vc.edit_element_block_view = new vc.EditElementUIPanel( { el: '#vc_ui-panel-edit-element' } );40 vc.post_settings_view = new vc.PostSettingsUIPanelFrontendEditor( { el: '#vc_ui-panel-post-settings' } );41 /**42 * @deprecated 4.443 * @type {vc.TemplatesEditorPanelView}44 */45 vc.templates_editor_view = new vc.TemplatesEditorPanelView( { el: '#vc_templates-editor' } );46 vc.templates_panel_view = new vc.TemplateWindowUIPanelFrontendEditor( { el: '#vc_ui-panel-templates' } );47 vc.app = new vc.View();48 vc.buildRelevance();49 if ( $body.hasClass( 'vc_responsive_disabled' ) ) {50 vc.responsive_disabled = true;51 }52 // Build Frame {{53 vc.setFrameSize( '100%' );54 vc.frame = new vc.FrameView( { el: $( vc.$frame.get( 0 ).contentWindow.document ).find( 'body' ).get( 0 ) } );55 vc.app.render();56 // }}57 // Build content of the page58 // Get current content data59 vc.post_shortcodes = vc.frame_window.vc_post_shortcodes;60 vc.builder.buildFromContent();61 vc.removePreLoader();62 $( window ).trigger( 'vc_build' );63 };64 vc.$frame.load( function () {65 if ( ! vc.loaded ) {66 window.setTimeout( function () {67 vc.build()68 }, 10 );69 }70 } );...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2const fc2 = require('fast-check/lib/fast-check-default');3const fc1 = require('fast-check/lib/fast-check');4console.log(fc);5console.log(fc2);6console.log(fc1);7{8 "scripts": {9 },10 "dependencies": {11 }12}

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2const fc2 = require('fast-check/lib/fast-check');3const fc1 = require('fast-check/dist/fast-check');4const fc0 = require('fast-check/dist/lib/fast-check');5const fc3 = require('fast-check/lib/fast-check');6const fc4 = require('fast-check/lib/fast-check');7const fc5 = require('fast-check/dist/fast-check');8const fc6 = require('fast-check/dist/lib/fast-check');9const fc7 = require('fast-check/lib/fast-check');10const fc8 = require('fast-check/lib/fast-check');11const fc9 = require('fast-check/dist/fast-check');12const fc10 = require('fast-check/dist/lib/fast-check');13const fc11 = require('fast-check/lib/fast-check');14const fc12 = require('fast-check/lib/fast-check');15const fc13 = require('fast-check/dist/fast-check');16const fc14 = require('fast-check/dist/lib/fast-check');17const fc15 = require('fast-check/lib/fast-check');18const fc16 = require('fast-check/lib/fast-check');19const fc17 = require('fast-check/dist/fast-check');20const fc18 = require('fast-check/dist/lib/fast-check');21const fc19 = require('fast-check/lib/fast-check');

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2const fc1 = require('fast-check/v1');3const fc2 = require('fast-check/v2');4const fc3 = require('fast-check/v3');5const fc4 = require('fast-check/v4');6const fc5 = require('fast-check/v5');7const fc6 = require('fast-check/v6');8const fc7 = require('fast-check/v7');9const fc8 = require('fast-check/v8');10const fc9 = require('fast-check/v9');11const fc10 = require('fast-check/v10');12const fc11 = require('fast-check/v11');13const fc12 = require('fast-check/v12');14const fc13 = require('fast-check/v13');15const fc14 = require('fast-check/v14');16const fc15 = require('fast-check/v15');17const fc16 = require('fast-check/v16');18const fc17 = require('fast-check/v17');19const fc18 = require('fast-check/v18');20const fc19 = require('fast-check/v19');

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2fc.assert(3 fc.property(fc.integer(), fc.integer(), (a, b) => a + b >= a),4 { verbose: true }5);6{7 "scripts": {8 },9 "dependencies": {10 }11}12 at Function.integer (C:\Users\james\Documents\GitHub\test\node_modules\fast-check\lib\arbitrary\IntegerArbitrary.js: 25: 21)13 at Array.map ()14 at Object. <anonymous> (C:\Users\james\Documents\GitHub\test\test.js: 4: 14)15 at Module._compile (module.js: 652: 30)16 at Object.Module._extensions..js (module.js: 663: 10)17 at Module.load (module.js: 565: 32)18 at tryModuleLoad (module.js: 505: 12)19 at Function.Module._load (module.js: 497: 3)20 at Function.Module.runMain (module.js: 693: 10)

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check/lib/fast-check-default');2fc.configureGlobal({verbose: 1});3fc.assert(4 fc.property(fc.integer(), fc.integer(), fc.integer(), (a, b, c) => {5 return (a + b) * c === a * c + b * c;6 })7);8const fc = require('fast-check/lib/fast-check-default');9fc.configureGlobal({verbose: 1});10fc.assert(11 fc.property(fc.integer(), fc.integer(), fc.integer(), (a, b, c) => {12 return (a + b) * c === a * c + b * c;13 })14);15const fc = require('fast-check/lib/fast-check-default');16fc.configureGlobal({verbose: 1});17fc.assert(18 fc.property(fc.integer(), fc.integer(), fc.integer(), (a, b, c) => {19 return (a + b) * c === a * c + b * c;20 })21);22const fc = require('fast-check/lib/fast-check-default');23fc.configureGlobal({verbose: 1});24fc.assert(25 fc.property(fc.integer(), fc.integer(), fc.integer(), (a, b, c) => {26 return (a + b) * c === a * c + b * c;27 })28);29const fc = require('fast-check/lib/fast-check-default');30fc.configureGlobal({verbose: 1});31fc.assert(32 fc.property(fc.integer(), fc.integer(), fc.integer(), (a,

Full Screen

Using AI Code Generation

copy

Full Screen

1const {check} = require('fast-check');2const fc = require('fast-check');3const { vC } = require('fast-check-monorepo');4check(vC, 1000, fc.string(), (s) => {5 return s === s;6});

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fast-check-monorepo automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful