Initial Git import
This commit is contained in:
71
includes/js/admin-post-download.js
Normal file
71
includes/js/admin-post-download.js
Normal file
@ -0,0 +1,71 @@
|
||||
jQuery( document ).ready( function( $ ){
|
||||
|
||||
var uploader = new plupload.Uploader( plupload_args );
|
||||
|
||||
// User clicks upload
|
||||
$( '#plupload-upload-button' ).click( function( e ) {
|
||||
$( '#plupload-upload-button' ).fadeOut( 'fast' );
|
||||
$( '#plupload-cancel-button' ).fadeOut( 'fast' );
|
||||
$( '#plupload-progress' ).slideDown( 'fast', function() {
|
||||
uploader.start();
|
||||
} );
|
||||
|
||||
e.preventDefault();
|
||||
} );
|
||||
|
||||
// User clicks cancel
|
||||
$( '#plupload-cancel-button' ).click( function( e ) {
|
||||
// Empty queue
|
||||
uploader.splice();
|
||||
e.preventDefault();
|
||||
|
||||
$( '#plupload-file' ).html( '----' );
|
||||
$( '#plupload-file-size' ).html( '----' );
|
||||
$( '#plupload-browse-button' ).removeAttr( 'disabled' );
|
||||
$( '#plupload-upload-button' ).fadeOut( 'fast' );
|
||||
$( '#plupload-cancel-button' ).fadeOut( 'fast' );
|
||||
|
||||
} );
|
||||
|
||||
// Init
|
||||
uploader.init();
|
||||
|
||||
// File added to queue
|
||||
uploader.bind('FilesAdded', function( up, files ) {
|
||||
plupload.each( files, function( file ) {
|
||||
$( '#plupload-file' ).html( file.name );
|
||||
$( '#plupload-file-size' ).html( plupload.formatSize( file.size ) );
|
||||
} );
|
||||
|
||||
$( '#plupload-browse-button' ).attr( 'disabled', 'disabled' );
|
||||
$( '#plupload-upload-button' ).fadeIn( 'fast' );
|
||||
$( '#plupload-cancel-button' ).fadeIn( 'fast' );
|
||||
|
||||
up.refresh();
|
||||
} );
|
||||
|
||||
// Error
|
||||
uploader.bind( 'Error', function( up, err ) {
|
||||
$( '#plupload-file' ).html( '<span class="error">' + err.message + '</span>' );
|
||||
$( '#plupload-file-size' ).html( '----' );
|
||||
|
||||
up.refresh();
|
||||
} );
|
||||
|
||||
// Progress bar
|
||||
uploader.bind( 'UploadProgress', function( up, file ) {
|
||||
$( '#plupload-progress .bar' ).css( 'width', file.percent + '%' );
|
||||
$( '#plupload-progress .percent' ).html( '<p>' + file.percent + '%</p>' );
|
||||
} );
|
||||
|
||||
// File uploaded
|
||||
uploader.bind( 'FileUploaded', function( up, file, response ) {
|
||||
$( '#plupload-browse-button' ).removeAttr( 'disabled' );
|
||||
$( '#plupload-upload-button' ).fadeOut( 'fast' );
|
||||
$( '#plupload-cancel-button' ).fadeOut( 'fast' );
|
||||
$( '#plupload-progress' ).slideUp( 'fast' );
|
||||
$( '#plupload-file' ).html( '<span class="success">' + response.response + '</span>' );
|
||||
|
||||
} );
|
||||
|
||||
} );
|
92
includes/js/admin-post.js
Normal file
92
includes/js/admin-post.js
Normal file
@ -0,0 +1,92 @@
|
||||
jQuery( document ).ready( function( $ ){
|
||||
|
||||
var download_id;
|
||||
|
||||
// Display download modal
|
||||
$( '#sdm-media-button' ).click( function( e ) {
|
||||
$( '#sdm-download-modal' ).show();
|
||||
|
||||
e.preventDefault();
|
||||
} );
|
||||
|
||||
// Close download modal
|
||||
$( '#sdm-download-modal-close' ).click( function( e ) {
|
||||
$( '#sdm-download-modal' ).hide();
|
||||
|
||||
e.preventDefault();
|
||||
} );
|
||||
|
||||
$( '.media-modal-backdrop' ).click( function() {
|
||||
$( '#sdm-download-modal' ).hide();
|
||||
} );
|
||||
|
||||
// Hide/show color select
|
||||
if( $( '#sdm-download-style' ).val() == 'button' ) {
|
||||
$( '.sdm-download-color-container' ).show();
|
||||
}
|
||||
else {
|
||||
$( '.sdm-download-color-container' ).hide();
|
||||
}
|
||||
|
||||
// Hide/show color select on change
|
||||
$( '#sdm-download-style' ).change( function() {
|
||||
if( $( '#sdm-download-style' ).val() == 'button' ) {
|
||||
$( '.sdm-download-color-container' ).slisdmwn();
|
||||
}
|
||||
else {
|
||||
$( '.sdm-download-color-container' ).slideUp();
|
||||
}
|
||||
} );
|
||||
|
||||
// Selectable list items
|
||||
var selectableOpts = {
|
||||
selected: function( e, ui ) {
|
||||
download_id = $( ui.selected ).attr( 'data-ID' );
|
||||
$( '.download-details' ).show();
|
||||
}
|
||||
};
|
||||
|
||||
// Set selectable item
|
||||
$( '#selectable_list' ).selectable( selectableOpts );
|
||||
|
||||
// Download insert button
|
||||
$( '#sdm-download-button' ).click( function() {
|
||||
var download_text = $( '#sdm-download-text' ).val();
|
||||
var download_style = $( '#sdm-download-style' ).val();
|
||||
var download_color = $( '#sdm-download-color' ).val();
|
||||
|
||||
// Check if button and add color
|
||||
if( download_style == 'button' ) {
|
||||
color = ' color="' + download_color + '"'
|
||||
}
|
||||
else {
|
||||
color = ''
|
||||
}
|
||||
|
||||
// Add to editor
|
||||
window.send_to_editor( '[download id=' + download_id + ' text="' + download_text + '" style="' + download_style + '"' + color + ']' );
|
||||
|
||||
// Hide modal
|
||||
$( '#sdm-download-modal' ).hide();
|
||||
} );
|
||||
|
||||
// Download filesize button
|
||||
$( '#sdm-filesize-button' ).click( function() {
|
||||
// Add to editor
|
||||
window.send_to_editor( '[download_size id=' + download_id + ']' );
|
||||
|
||||
// Hide modal
|
||||
$( '#sdm-download-modal' ).hide();
|
||||
} );
|
||||
|
||||
// Download count button
|
||||
$( '#sdm-count-button' ).click( function() {
|
||||
// Add to editor
|
||||
window.send_to_editor( '[download_count id=' + download_id + ']' );
|
||||
|
||||
// Hide modal
|
||||
$( '#sdm-download-modal' ).hide();
|
||||
} );
|
||||
|
||||
|
||||
} );
|
Reference in New Issue
Block a user