mirror of
https://ghproxy.net/https://github.com/fairpm/fair-plugin.git
synced 2025-09-05 02:37:43 +08:00
Initial export of the repository
Signed-off-by: Ryan McCue <me@ryanmccue.info>
This commit is contained in:
commit
583d434505
76 changed files with 39023 additions and 0 deletions
32
assets/css/admin.css
Normal file
32
assets/css/admin.css
Normal file
|
@ -0,0 +1,32 @@
|
|||
.fair-settings .row {
|
||||
align-items: flex-start;
|
||||
display: flex;
|
||||
gap: 1em;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
.fair-settings .row > .label-wrapper {
|
||||
flex: 0 0 auto;
|
||||
font-weight: 600;
|
||||
line-height: 1.3;
|
||||
max-width: 30em;
|
||||
min-width: 20em;
|
||||
}
|
||||
|
||||
.fair-settings .row .description {
|
||||
margin-top: 0.5em;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 782px) {
|
||||
.fair-settings .row {
|
||||
flex-direction: column;
|
||||
gap: 0;
|
||||
}
|
||||
.fair-settings .row > .label-wrapper {
|
||||
max-width: 100%;
|
||||
padding-bottom: 0.5em;
|
||||
}
|
||||
|
||||
.fair-settings .row .field select,
|
||||
margin: 0;
|
||||
}
|
||||
}
|
5
assets/css/global-admin.css
Normal file
5
assets/css/global-admin.css
Normal file
|
@ -0,0 +1,5 @@
|
|||
.fair-notification {
|
||||
display: block;
|
||||
text-align: end;
|
||||
font-style: italic;
|
||||
}
|
62
assets/js/fair-avatars.js
Normal file
62
assets/js/fair-avatars.js
Normal file
|
@ -0,0 +1,62 @@
|
|||
const { __ } = wp.i18n;
|
||||
/**
|
||||
* Now let's get started.
|
||||
*/
|
||||
jQuery( document ).ready( function($) {
|
||||
|
||||
var mediaUploader;
|
||||
|
||||
// Handle adding a new avatar.
|
||||
$( 'tr.user-profile-picture' ).on( 'click', '#fair-avatar-upload', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
// If the media frame already exists, reopen it.
|
||||
if ( mediaUploader ) {
|
||||
mediaUploader.open();
|
||||
return;
|
||||
}
|
||||
|
||||
mediaUploader = wp.media({
|
||||
title: __( 'Choose Profile Picture', 'fair' ),
|
||||
button: {
|
||||
text: __( 'Use as Profile Picture', 'fair' )
|
||||
},
|
||||
library: {
|
||||
type: ['image']
|
||||
},
|
||||
multiple: false
|
||||
});
|
||||
|
||||
mediaUploader.on( 'select', function() {
|
||||
var attachment = mediaUploader.state().get( 'selection' ).first().toJSON();
|
||||
|
||||
if ( attachment.type !== 'image' ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var alttext = ! attachment.alt ? fairAvatars.defaultAlt : attachment.alt;
|
||||
|
||||
// Add the value, swap the image, and show the button.
|
||||
$( '#fair-avatar-id' ).val( attachment.id );
|
||||
$( '.user-profile-picture td img.avatar' ).attr( { src: attachment.url, alt: alttext } );
|
||||
$( '#fair-avatar-remove' ).removeClass( 'button-hidden' );
|
||||
|
||||
wp.a11y.speak( __( 'Profile Picture Assigned', 'fair' ) );
|
||||
});
|
||||
|
||||
mediaUploader.open();
|
||||
});
|
||||
|
||||
// Handle removing an existing avatar.
|
||||
$( 'tr.user-profile-picture' ).on( 'click', '#fair-avatar-remove', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
// Remove the value, swap the image, hide the button, and set the focus.
|
||||
$( '#fair-avatar-id' ).val('');
|
||||
$( '.user-profile-picture td img.avatar' ).attr( { src: fairAvatars.defaultImg, alt: fairAvatars.defaultAlt } );
|
||||
$( this ).addClass( 'button-hidden' );
|
||||
$( '#fair-avatar-upload' ).trigger( 'focus' );
|
||||
|
||||
wp.a11y.speak( __( 'Profile Picture Removed', 'fair' ) );
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue