| 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 |
|
| 12 |
this.setValue(id); |
| 13 |
var preview = this.$el.find('.button_preview'); |
| 14 |
|
| 15 |
var query = [{ |
| 16 |
counter: 1, |
| 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 |
nonce: shortcodeUIData.nonces.preview, |
| 25 |
}).done( function( response ) { |
| 26 |
var button = response[1].response; |
| 27 |
preview.html(button); |
| 28 |
}) |
| 29 |
|
| 30 |
}, |
| 31 |
|
| 32 |
render: function () |
| 33 |
{ |
| 34 |
|
| 35 |
var self = this; |
| 36 |
//var maxMedia = window.maxFoundry.maxMedia; |
| 37 |
this.cake_mm = new window.maxFoundry.maxMedia(); |
| 38 |
|
| 39 |
this.cake_mm.init({callback: $.proxy(this.callback, this), useShortCodeOptions: false}); |
| 40 |
//cake_mm.openModal(); |
| 41 |
|
| 42 |
var data = jQuery.extend( { |
| 43 |
id: 'shortcode-ui-' + this.model.get( 'attr' ) + '-' + this.model.cid, |
| 44 |
}, this.model.toJSON() ); |
| 45 |
|
| 46 |
//maxMedia.setCallback( $.proxy(this.updateButton, this) ); |
| 47 |
|
| 48 |
this.$el.html( this.template( data ) ); |
| 49 |
//this.triggerCallbacks(); |
| 50 |
|
| 51 |
$(document).on('click', '.maxbutton_media_button', $.proxy(function(e) |
| 52 |
{ |
| 53 |
e.preventDefault(); |
| 54 |
this.cake_mm.openModal(); |
| 55 |
$('.media-modal, .media-modal-backdrop').hide(); |
| 56 |
},this)); |
| 57 |
|
| 58 |
|
| 59 |
$(document).on('modal_close', function () |
| 60 |
{ |
| 61 |
$('.media-modal, .media-modal-backdrop').show(); |
| 62 |
}); |
| 63 |
|
| 64 |
this.updateButton( this.model.get( 'value' ) ); |
| 65 |
|
| 66 |
return this; |
| 67 |
}, |
| 68 |
|
| 69 |
callback: function(id) |
| 70 |
{ |
| 71 |
this.updateButton(id); |
| 72 |
this.cake_mm.close(); |
| 73 |
$('.media-modal, .media-modal-backdrop').show(); |
| 74 |
} |
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
}); // extend |
| 79 |
|
| 80 |
} )( jQuery ); |
| 81 |
|