editor1.js
2 years ago
handlebars.baldrick2.js
8 years ago
handlebars2.js
8 years ago
jquery.baldrick3.js
8 years ago
panel.js
8 years ago
scripts-pod_reference.js
2 years ago
scripts-view_template.js
1 year ago
panel.js
59 lines
| 1 | // General panel scripts . |
| 2 | function pods_templates_randomUUID() { |
| 3 | var s = [], itoh = '0123456789ABCDEF'; |
| 4 | for ( var i = 0; i < 6; i++ ) { |
| 5 | s[i] = Math.floor( Math.random() * 0x10 ); |
| 6 | } |
| 7 | return s.join( '' ); |
| 8 | } |
| 9 | |
| 10 | var pods_templates_field_callbacks = []; |
| 11 | jQuery( function ( $ ) { |
| 12 | // add row |
| 13 | $( 'body' ).on( 'click', '.pods_templates-add-group-row', function () { |
| 14 | var clicked = $( this ), rowid = pods_templates_randomUUID(), |
| 15 | template = $( '#' + clicked.data( 'rowtemplate' ) ).html().replace( /{{id}}/g, rowid ); |
| 16 | if ( clicked.data( 'field' ) ) { |
| 17 | var ref = clicked.data( 'field' ).split( '-' ); |
| 18 | template = template.replace( /\_\_i\_\_/g, ref[ref.length - 2] ); |
| 19 | } |
| 20 | //console.log(clicked.parent().parent().find('.groupitems').last()); |
| 21 | template = template.replace( /\_\_count\_\_/g, clicked.parent().parent().find( '.groupitems' ).length ); |
| 22 | clicked.parent().before( template ); |
| 23 | |
| 24 | for ( var callback in pods_templates_field_callbacks ) { |
| 25 | if ( typeof window[pods_templates_field_callbacks[callback]] === 'function' ) { |
| 26 | window[pods_templates_field_callbacks[callback]](); |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | } ); |
| 31 | $( 'body' ).on( 'click', '.pods_templates-removeRow', function () { |
| 32 | $( this ).next().remove(); |
| 33 | $( this ).remove(); |
| 34 | ////console.log(this); |
| 35 | } ); |
| 36 | // tabs |
| 37 | $( 'body' ).on( 'click', '.pods_templates-metabox-config-nav li a, .pods_templates-shortcode-config-nav li a, .pods_templates-settings-config-nav li a, .pods_templates-widget-config-nav li a', function () { |
| 38 | $( this ).parent().parent().find( '.current' ).removeClass( 'current' ); |
| 39 | $( this ).parent().parent().parent().parent().find( '.group' ).hide(); |
| 40 | $( '' + $( this ).attr( 'href' ) + '' ).show(); |
| 41 | $( this ).parent().addClass( 'current' ); |
| 42 | if ( $( this ).data( 'tabset' ).length ) { |
| 43 | $( '#' + $( this ).data( 'tabset' ) ).val( $( this ).data( 'tabkey' ) ); |
| 44 | } |
| 45 | return false; |
| 46 | } ); |
| 47 | |
| 48 | // initcallbacks |
| 49 | setInterval( function () { |
| 50 | $( '.pods_templates-init-callback' ).each( function ( k, v ) { |
| 51 | var callback = $( this ); |
| 52 | if ( typeof window[callback.data( 'init' )] === 'function' ) { |
| 53 | window[callback.data( 'init' )](); |
| 54 | callback.removeClass( 'pods_templates-init-callback' ); |
| 55 | } |
| 56 | } ); |
| 57 | }, 100 ); |
| 58 | } ); |
| 59 |