"use strict";
/* Basic -------------------------------------------------------------- */
(function($) {
var abrMetabox = {};
( function() {
var $this;
abrMetabox = {
/*
* Initialize
*/
init: function( e ) {
$this = abrMetabox;
// Variables.
$this.wrap = $( '.abr-metabox-wrap' );
// Init.
$this.metaboxInit( e );
// Init events.
$this.events( e );
},
/*
* Events
*/
events: function( e ) {
// Custom Events
$this.wrap.on( 'click change keyup keydown', '.abr-metabox-repeater .attribute-name', $this.setSignature );
$this.wrap.on( 'click', '.abr-metabox-repeater .row-topbar', $this.toggleItems );
$this.wrap.on( 'click', '.abr-metabox-repeater .btn-remove-row', $this.removeRepeaterRow );
$this.wrap.on( 'click', '.abr-metabox-repeater .btn-add-row', $this.addRepeaterRow );
},
/*
* Init metabox elements
*/
metaboxInit: function( e ) {
// Add tabs for Meta Box (UI)
$this.wrap.find( '.abr-metabox-tabs' ).tabs();
// Repeater sortable
$this.wrap.find( '.abr-metabox-repeater tbody' ).sortable( {
items: 'tr',
placeholder: 'ui-state-highlight',
handle: '.row-topbar, .row-handle',
start: function( e, ui ) {
ui.placeholder.height( ui.item.height() );
},
} );
},
/*
* Toggle items
*/
toggleItems: function() {
if ( $( this ).hasClass( 'closed' ) ) {
$( this ).removeClass( 'closed' );
$( this ).siblings( '.row-fields' ).slideDown();
} else {
$( this ).addClass( 'closed' );
$( this ).siblings( '.row-fields' ).slideUp();
}
},
/*
* Set signature
*/
setSignature: function() {
var label = '' + $( this ).data( 'label' ) + '';
var value = $( this ).val() ? $( this ).val() : label;
$( this ).parents( '.row-content' ).find( '.signature' ).html( value );
},
/*
* Add repeater row
*/
addRepeaterRow: function() {
var repeater = $( this ).siblings( '.abr-metabox-repeater-table' )
// Get html row.
var html = repeater.find( 'tbody tr.hidden' ).html();
// Add new row.
repeater.find( 'tbody' ).append( '
\n
\n
PVC 3mm White 36\u00d724<\/strong>
\n(Grommets and Rounded Corners)<\/strong>
\nDesign $25<\/strong><\/p>\n<\/div>\n<\/div>\n\n
\n
\n\n\nQUANTITY<\/td>\n | PRICING<\/td>\n<\/tr>\n |
\n1<\/td>\n | $99.99<\/td>\n<\/tr>\n |
\n3<\/td>\n | $269.99<\/td>\n<\/tr>\n |
\n5<\/td>\n | $335.99<\/td>\n<\/tr>\n |
\n10<\/td>\n | $575.99<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n","protected":false},"featured_media":18789,"comment_status":"open","ping_status":"closed","template":"template-page-builder.php","meta":[],"product_cat":[247],"product_tag":[],"class_list":{"0":"post-18614","1":"product","2":"type-product","3":"status-publish","4":"has-post-thumbnail","6":"product_cat-design-and-print","8":"first","9":"instock","10":"shipping-taxable","11":"purchasable","12":"product-type-variable"},"_links":{"self":[{"href":"https:\/\/hyperfarmer.com\/wp-json\/wp\/v2\/product\/18614"}],"collection":[{"href":"https:\/\/hyperfarmer.com\/wp-json\/wp\/v2\/product"}],"about":[{"href":"https:\/\/hyperfarmer.com\/wp-json\/wp\/v2\/types\/product"}],"replies":[{"embeddable":true,"href":"https:\/\/hyperfarmer.com\/wp-json\/wp\/v2\/comments?post=18614"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hyperfarmer.com\/wp-json\/wp\/v2\/media\/18789"}],"wp:attachment":[{"href":"https:\/\/hyperfarmer.com\/wp-json\/wp\/v2\/media?parent=18614"}],"wp:term":[{"taxonomy":"product_cat","embeddable":true,"href":"https:\/\/hyperfarmer.com\/wp-json\/wp\/v2\/product_cat?post=18614"},{"taxonomy":"product_tag","embeddable":true,"href":"https:\/\/hyperfarmer.com\/wp-json\/wp\/v2\/product_tag?post=18614"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}} |