Created
March 21, 2014 13:04
-
-
Save diegoliv/9685733 to your computer and use it in GitHub Desktop.
Checando o evento 'close' do wp.media (versão 3.6+) / Checking the 'close' event of wp.media (version 3.6+)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//se o frame já existe, abre-o novamente | |
if ( typeof( custom_uploader ) !== "undefined" ) { | |
custom_uploader.close(); | |
} | |
//Cria o frame da janela de mídia | |
var custom_uploader = wp.media.frames.customHeader = wp.media({ | |
title: "Select An Image", | |
library: { | |
type: 'image' | |
}, | |
button: { | |
text: "insert image" | |
}, | |
}); | |
//callback quando seleciona uma imagem | |
custom_uploader.on( 'select', function() { | |
console.log( 'selected an image' ); | |
}); | |
//callback quando fecha a janela - seja através do botão "fechar" ou usando a tecla "ESC" | |
custom_uploader.on( 'close', function(){ | |
console.log( 'close modal' ); | |
} ); | |
//Abre a janela de mídia | |
custom_uploader.open(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment