Skip to content

Commit

Permalink
fix media uploader interactions
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo Solar committed Jun 3, 2024
1 parent f29dbc7 commit 4df3515
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
13 changes: 9 additions & 4 deletions js/src/windows-azure-storage-media-replace.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var replaceMedia = function(attachmentID) {
},
multiple: false
}).on('select', function(){
console.log(mediaUploader.state().get( 'selection' ));
var attachment = mediaUploader.state().get( 'selection' ).first().toJSON();
jQuery.ajax({
type: 'post',
Expand All @@ -39,9 +40,11 @@ var replaceMedia = function(attachmentID) {
dataType: 'JSON',
beforeSend: function() {
jQuery('.settings-save-status').find('.spinner').addClass('is-active');
jQuery('.edit-media-header').find('.media-modal-close').first().prop('disabled', true);
},
success: function(result) {
jQuery('.settings-save-status').find('.spinner').removeClass('is-active');
jQuery('.edit-media-header').find('.media-modal-close').first().prop('disabled', false);

var image = jQuery('.media-modal').find('.details-image').attr('src');
var cacheVar = generateCacheVar(7);
Expand All @@ -64,10 +67,12 @@ var replaceMedia = function(attachmentID) {
});

mediaUploader.on('open', function(){
var tab = document.getElementById('menu-item-upload');
var browse = document.getElementById('menu-item-browse');
browse.style.display = 'none';
tab.click();
mediaUploader.reset();
var context = jQuery(mediaUploader.el);
var tab = context.find('#menu-item-upload');
var browse = context.find('#menu-item-browse');
browse.css('display', 'none');
tab.trigger('click');
});

mediaUploader.open();
Expand Down
13 changes: 9 additions & 4 deletions js/windows-azure-storage-media-replace.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ var replaceMedia = function(attachmentID) {
},
multiple: false
}).on('select', function(){
console.log(mediaUploader.state().get( 'selection' ));
var attachment = mediaUploader.state().get( 'selection' ).first().toJSON();
jQuery.ajax({
type: 'post',
Expand All @@ -42,9 +43,11 @@ var replaceMedia = function(attachmentID) {
dataType: 'JSON',
beforeSend: function() {
jQuery('.settings-save-status').find('.spinner').addClass('is-active');
jQuery('.edit-media-header').find('.media-modal-close').first().prop('disabled', true);
},
success: function(result) {
jQuery('.settings-save-status').find('.spinner').removeClass('is-active');
jQuery('.edit-media-header').find('.media-modal-close').first().prop('disabled', false);

var image = jQuery('.media-modal').find('.details-image').attr('src');
var cacheVar = generateCacheVar(7);
Expand All @@ -67,10 +70,12 @@ var replaceMedia = function(attachmentID) {
});

mediaUploader.on('open', function(){
var tab = document.getElementById('menu-item-upload');
var browse = document.getElementById('menu-item-browse');
browse.style.display = 'none';
tab.click();
mediaUploader.reset();
var context = jQuery(mediaUploader.el);
var tab = context.find('#menu-item-upload');
var browse = context.find('#menu-item-browse');
browse.css('display', 'none');
tab.trigger('click');
});

mediaUploader.open();
Expand Down
2 changes: 1 addition & 1 deletion js/windows-azure-storage-media-replace.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4df3515

Please sign in to comment.