| 1 |
( function( $ ) { |
| 2 |
|
| 3 |
|
| 4 |
var sui = window.Shortcode_UI; |
| 5 |
//var construct = sui.utils.shortcodeViewConstructor; |
| 6 |
|
| 7 |
sui.views.editAttributeFieldMaxButton = sui.views.editAttributeField.extend( { |
| 8 |
|
| 9 |
updateButton: function(id) |
| 10 |
{ |
| 11 |
this.setValue(id); |
| 12 |
var preview = this.$el.find('.button_preview'); |
| 13 |
|
| 14 |
var query = [{ |
| 15 |
counter: 1, |
| 16 |
nonce: shortcodeUIData.nonces.preview, |
| 17 |
post_id: $( '#post_ID' ).val(), |
| 18 |
shortcode: this.shortcode.formatShortcode(), |
| 19 |
}]; |
| 20 |
|
| 21 |
// provisional |
| 22 |
wp.ajax.post( 'bulk_do_shortcode', { |
| 23 |
queries: query, |
| 24 |
}).done( function( response ) { |
| 25 |
var button = response[1].response; |
| 26 |
preview.html(button); |
| 27 |
}) |
| 28 |
|
| 29 |
}, |
| 30 |
|
| 31 |
render: function () |
| 32 |
{ |
| 33 |
var self = this; |
| 34 |
var maxMedia = window.maxMedia; |
| 35 |
|
| 36 |
var data = jQuery.extend( { |
| 37 |
id: 'shortcode-ui-' + this.model.get( 'attr' ) + '-' + this.model.cid, |
| 38 |
}, this.model.toJSON() ); |
| 39 |
|
| 40 |
maxMedia.setCallback( $.proxy(this.updateButton, this) ); |
| 41 |
|
| 42 |
this.$el.html( this.template( data ) ); |
| 43 |
this.triggerCallbacks(); |
| 44 |
|
| 45 |
$(document).on('mb_media_buttons_open', function () |
| 46 |
{ |
| 47 |
$('.media-modal, .media-modal-backdrop').hide(); |
| 48 |
|
| 49 |
}); |
| 50 |
|
| 51 |
$(document).on('modal_close', function () |
| 52 |
{ |
| 53 |
$('.media-modal, .media-modal-backdrop').show(); |
| 54 |
}); |
| 55 |
|
| 56 |
this.updateButton( this.model.get( 'value' ) ); |
| 57 |
|
| 58 |
return this; |
| 59 |
} |
| 60 |
|
| 61 |
}); // extend |
| 62 |
|
| 63 |
} )( jQuery ); |
| 64 |
|
| 65 |
|