%PDF- %PDF-
| Direktori : /dom645759/wp-content/plugins/fusion-builder/shortcodes/js/ |
| Current File : /dom645759/wp-content/plugins/fusion-builder/shortcodes/js/fusion-pricing-table.js |
/* global FusionPageBuilderApp */
( function( $ ) {
$( document ).ready( function() {
// Pricing table. Build pricing table shortcode.
FusionPageBuilderApp.pricingTableShortcodeFilter = function( attributes, view ) {
var shortcode = '',
columnCounter = 0,
table = view.$( '.fusion-builder-table' ),
existingAtts = [],
columnRegExp = /\[fusion_pricing_column([^\]]*)\]/g,
match;
// Collect the attributes of the existing columns, so the params which are
// only editable in the column dialogs survive a spreadsheet save.
while ( null !== ( match = columnRegExp.exec( attributes.params.element_content || '' ) ) ) {
existingAtts.push( match[ 1 ] );
}
function setAtt( atts, name, value ) {
var attRegExp = new RegExp( ' ' + name + '="[^"]*"' );
value = ' ' + name + '="' + value + '"';
return attRegExp.test( atts ) ? atts.replace( attRegExp, value ) : atts + value;
}
// Table head
table.find( 'thead th' ).each( function() {
var $thisTh = $( this ),
thCID = $thisTh.data( 'th-id' ),
thTitle = $thisTh.find( '.title-input' ).val() || '',
thSubTitle = $thisTh.find( '.sub-title-input' ).val() || '',
thDescription = $thisTh.find( '.description-input' ).val() || '',
thStandout = $thisTh.find( '.button-set-value' ).val(),
thBadge = $thisTh.find( '.badge-input' ).val() || '',
thAbove = table.find( 'tbody .price .td-' + thCID + ' .above-input' ).val() || '',
thBelow = table.find( 'tbody .price .td-' + thCID + ' .below-input' ).val() || '',
columnAtts = 'undefined' !== typeof existingAtts[ columnCounter ] ? existingAtts[ columnCounter ] : '';
columnCounter++;
columnAtts = setAtt( columnAtts, 'title', thTitle );
columnAtts = setAtt( columnAtts, 'sub_heading', thSubTitle );
columnAtts = setAtt( columnAtts, 'description', thDescription );
columnAtts = setAtt( columnAtts, 'badge_text', thBadge );
columnAtts = setAtt( columnAtts, 'price_above', thAbove );
columnAtts = setAtt( columnAtts, 'price_below', thBelow );
columnAtts = setAtt( columnAtts, 'standout', thStandout );
shortcode += '[fusion_pricing_column' + columnAtts + ']';
// Table price
table.find( 'tbody .price .td-' + thCID ).each( function() {
var $thisPrice = $( this ),
price = $thisPrice.find( '.price-input' ).val(),
currency = $thisPrice.find( '.currency-input' ).val(),
currencyPosition = $thisPrice.find( '.currency-position' ).val(),
time = $thisPrice.find( '.time-input' ).val();
shortcode += '[fusion_pricing_price currency="' + currency + '" currency_position="' + currencyPosition + '" price="' + price + '" time="' + time + '" ][/fusion_pricing_price]';
} );
// Table rows
table.find( '.fusion-table-row .td-' + thCID ).each( function() {
var $thisRow = $( this ),
content = $thisRow.find( 'input' ).val();
if ( '' !== content ) {
shortcode += '[fusion_pricing_row]' + content + '[/fusion_pricing_row]';
}
} );
// Table footer
table.find( 'tfoot .td-' + thCID ).each( function() {
var $thisFooter = $( this ),
footerContent = $thisFooter.find( 'textarea' ).val();
if ( '' !== footerContent ) {
shortcode += '[fusion_pricing_footer]' + footerContent + '[/fusion_pricing_footer]';
}
} );
shortcode += '[/fusion_pricing_column]';
} );
attributes.params.element_content = shortcode;
attributes.params.columns = columnCounter;
return attributes;
};
} );
}( jQuery ) );