Skip to content

Commit

Permalink
Initial commit for WordPress plugin version 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
thegulshankumar committed Oct 24, 2024
0 parents commit 8c17857
Show file tree
Hide file tree
Showing 46 changed files with 1,518 additions and 0 deletions.
151 changes: 151 additions & 0 deletions js/alt-editor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
jQuery(document).ready(function($) {
$('.alt-text-input').each(function() {
var $input = $(this);
var postId = $input.data('post-id');
var nonce = $input.data('nonce');
var previousAltText = $input.val().trim(); // Store the initial value trimmed
var typingTimer; // Timer identifier
let currentRequest; // Variable to hold the current fetch request
let isRequestLocked = false; // Lock to prevent multiple requests

// Create success and error icons
var $successIcon = $('<span class="status-icon success-icon" title="Instantly saved as you type">&#10003;</span>').hide().insertAfter($input); // Check mark (green tick)
var $errorIcon = $('<span class="status-icon error-icon" title="Failed">&#10007;</span>').hide().insertAfter($input); // Cross mark (error)

// Apply styles for the success icon (green tick)
$successIcon.css({
'display': 'inline-block',
'margin-left': '8px',
'background-color': 'green', // Green background
'border-radius': '50%', // Circular background
'width': '14px', // Fixed width
'height': '14px', // Fixed height
'text-align': 'center',
'line-height': '14px', // Center the icon vertically
'color': 'white', // Color for the tick
'font-size': '10px', // Small font size for tick
'cursor': 'pointer' // Add pointer cursor to show it's interactive
});

// Apply styles for the error icon (cross)
$errorIcon.css({
'display': 'inline-block',
'margin-left': '8px',
'background-color': 'white', // White background for the error icon
'border-radius': '50%', // Make it circular
'width': '14px',
'height': '14px',
'text-align': 'center',
'line-height': '14px', // Center the cross vertically
'color': 'red', // Red color for the cross
'font-size': '10px', // Small font size for cross
'cursor': 'pointer' // Add pointer cursor to show it's interactive
});

// Function to check if input is empty and apply yellow placeholder background
function updatePlaceholderStyle() {
if (!$input.val()) {
$input.css('background-color', 'lightyellow'); // Light yellow background for empty alt text
} else {
$input.css('background-color', ''); // Reset background if not empty
}
}

// Initial check on page load
updatePlaceholderStyle();

// Function to save alt text
function saveAltText(altText) {
// Only save if the new alt text is different from the previous one
if (altText.trim() !== previousAltText && !isRequestLocked) {
isRequestLocked = true; // Lock the request

// Abort any previous request
if (currentRequest) {
currentRequest.abort();
}

// Send request to save the alt text
currentRequest = $.ajax({
url: `${wpApiSettings.root}matm/v1/save-alt-text`,
method: 'POST',
contentType: 'application/json',
headers: {
'X-WP-Nonce': wpApiSettings.nonce
},
data: JSON.stringify({
post_id: postId,
alt_text: altText,
nonce: nonce
}),
success: function(response) {
previousAltText = altText.trim(); // Update previous alt text
isRequestLocked = false; // Unlock the request
$successIcon.show(); // Show success icon
$errorIcon.hide(); // Hide error icon if it was visible
updatePlaceholderStyle(); // Update placeholder style after saving
},
error: function() {
isRequestLocked = false; // Unlock the request
$errorIcon.show(); // Show error icon
$successIcon.hide(); // Hide success icon if it was visible
}
});
}
}

// Event when user is typing
$input.on('input', function() {
clearTimeout(typingTimer); // Clear the timer
typingTimer = setTimeout(() => {
var altText = $input.val(); // Get the current input value
saveAltText(altText); // Call saveAltText
updatePlaceholderStyle(); // Check placeholder styling during typing
}, 250);
});

// Event when input loses focus
$input.on('blur', function() {
clearTimeout(typingTimer); // Clear the timer
var altText = $input.val(); // Get the current input value
saveAltText(altText); // Save immediately on focus out
updatePlaceholderStyle(); // Check placeholder styling on blur
});

// Handle the Tab, Shift + Tab, Up Arrow, and Down Arrow keys to navigate between alt-text-input fields
$input.on('keydown', function(e) {
if (e.key === 'Tab' && !e.shiftKey) {
e.preventDefault(); // Prevent the default tab behavior
var $nextInput = $('.alt-text-input').eq($('.alt-text-input').index(this) + 1); // Get the next alt input field
if ($nextInput.length) {
$nextInput.focus(); // Move to the next alt text input field
}
} else if (e.key === 'Tab' && e.shiftKey) {
e.preventDefault(); // Prevent the default tab behavior
var $prevInput = $('.alt-text-input').eq($('.alt-text-input').index(this) - 1); // Get the previous alt input field
if ($prevInput.length) {
$prevInput.focus(); // Move to the previous alt text input field
}
} else if (e.key === 'ArrowDown') {
e.preventDefault(); // Prevent scrolling when pressing down
var $nextInput = $('.alt-text-input').eq($('.alt-text-input').index(this) + 1); // Move to the next input field on down arrow
if ($nextInput.length) {
$nextInput.focus(); // Focus the next input
}
} else if (e.key === 'ArrowUp') {
e.preventDefault(); // Prevent scrolling when pressing up
var $prevInput = $('.alt-text-input').eq($('.alt-text-input').index(this) - 1); // Move to the previous input field on up arrow
if ($prevInput.length) {
$prevInput.focus(); // Focus the previous input
}
}
});

// Initial placeholder style setup
updatePlaceholderStyle();

// Hide the icons initially
$successIcon.hide();
$errorIcon.hide();
});
});
2 changes: 2 additions & 0 deletions languages/media-alt-text-manager-cs_CZ.l10n.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
return ['project-id-version'=>'Media Alt Text Manager','report-msgid-bugs-to'=>'','pot-creation-date'=>'2024-10-08 21:25+0000','po-revision-date'=>'2024-10-08 21:36+0000','last-translator'=>'Gulshan Kumar','language-team'=>'Czech','language'=>'cs_CZ','plural-forms'=>'nplurals=3; plural=( n == 1 ) ? 0 : ( n >= 2 && n <= 4 ) ? 1 : 2;','mime-version'=>'1.0','content-type'=>'text/plain; charset=UTF-8','content-transfer-encoding'=>'8bit','x-generator'=>'Loco https://localise.biz/','x-loco-version'=>'2.6.11; wp-6.6.2','x-domain'=>'media-alt-text-manager','messages'=>['Adds a sortable Alt Text column to the media library for quick alt text management.'=>'Do knihovny médií přidává tříditelný sloupec Alt Text pro rychlou správu alt textu.','Alt Text'=>'Alt Text','Buy developer a coffee'=>'Kupte vývojáři kávu','Gulshan Kumar'=>'Gulshan Kumar','Hire for Technical Support'=>'Pronájem pro technickou podporu','https://wordpress.org/plugins/media-alt-text-manager/'=>'https://wordpress.org/plugins/media-alt-text-manager/','https://www.gulshankumar.net'=>'https://www.gulshankumar.net','Media Alt Text Manager'=>'Správce textu Alt médií','Show your support'=>'Vyjádřete svou podporu','To efficiently manage Alt Text for images, please visit the %1$sMedia Library in List Mode%2$s.'=>'Chcete-li efektivně spravovat Alt Text pro obrázky, navštivte %1$sKnihovna médií v režimu seznamu%2$s.','Work with Gulshan'=>'Práce s Gulshanem']];
Binary file added languages/media-alt-text-manager-cs_CZ.mo
Binary file not shown.
71 changes: 71 additions & 0 deletions languages/media-alt-text-manager-cs_CZ.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
msgid ""
msgstr ""
"Project-Id-Version: Media Alt Text Manager\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-10-08 21:25+0000\n"
"PO-Revision-Date: 2024-10-08 21:36+0000\n"
"Last-Translator: Gulshan Kumar\n"
"Language-Team: Czech\n"
"Language: cs_CZ\n"
"Plural-Forms: nplurals=3; plural=( n == 1 ) ? 0 : ( n >= 2 && n <= 4 ) ? 1 : "
"2;\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Loco https://localise.biz/\n"
"X-Loco-Version: 2.6.11; wp-6.6.2\n"
"X-Domain: media-alt-text-manager"

#. Description of the plugin
msgid ""
"Adds a sortable Alt Text column to the media library for quick alt text "
"management."
msgstr ""
"Do knihovny médií přidává tříditelný sloupec Alt Text pro rychlou správu alt "
"textu."

#: media-alt-text-manager.php:98
msgid "Alt Text"
msgstr "Alt Text"

#: media-alt-text-manager.php:85
msgid "Buy developer a coffee"
msgstr "Kupte vývojáři kávu"

#. Author of the plugin
msgid "Gulshan Kumar"
msgstr "Gulshan Kumar"

#: media-alt-text-manager.php:75
msgid "Hire for Technical Support"
msgstr "Pronájem pro technickou podporu"

#. URI of the plugin
msgid "https://wordpress.org/plugins/media-alt-text-manager/"
msgstr "https://wordpress.org/plugins/media-alt-text-manager/"

#. Author URI of the plugin
msgid "https://www.gulshankumar.net"
msgstr "https://www.gulshankumar.net"

#. Name of the plugin
msgid "Media Alt Text Manager"
msgstr "Správce textu Alt médií"

#: media-alt-text-manager.php:82
msgid "Show your support"
msgstr "Vyjádřete svou podporu"

#. %1$s: opening link tag, %2$s: closing link tag
#: media-alt-text-manager.php:48
#, php-format
msgid ""
"To efficiently manage Alt Text for images, please visit the %1$sMedia "
"Library in List Mode%2$s."
msgstr ""
"Chcete-li efektivně spravovat Alt Text pro obrázky, navštivte %1$sKnihovna "
"médií v režimu seznamu%2$s."

#: media-alt-text-manager.php:77
msgid "Work with Gulshan"
msgstr "Práce s Gulshanem"
2 changes: 2 additions & 0 deletions languages/media-alt-text-manager-de_DE.l10n.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
return ['project-id-version'=>'Media Alt Text Manager','report-msgid-bugs-to'=>'','pot-creation-date'=>'2024-10-08 21:25+0000','po-revision-date'=>'2024-10-08 21:29+0000','last-translator'=>'Gulshan Kumar','language-team'=>'German','language'=>'de_DE','plural-forms'=>'nplurals=2; plural=n != 1;','mime-version'=>'1.0','content-type'=>'text/plain; charset=UTF-8','content-transfer-encoding'=>'8bit','x-generator'=>'Loco https://localise.biz/','x-loco-version'=>'2.6.11; wp-6.6.2','x-domain'=>'media-alt-text-manager','messages'=>['Adds a sortable Alt Text column to the media library for quick alt text management.'=>'Fügt eine sortierbare Alt-Text-Spalte zur Medienbibliothek hinzu, um Alt-Text schnell zu verwalten.','Alt Text'=>'Alt-Text','Buy developer a coffee'=>'Kaufe Entwickler einen Kaffee','Gulshan Kumar'=>'Gulshan Kumar','Hire for Technical Support'=>'Anstellung für technischen Support','https://wordpress.org/plugins/media-alt-text-manager/'=>'https://wordpress.org/plugins/media-alt-text-manager/','https://www.gulshankumar.net'=>'https://www.gulshankumar.net','Media Alt Text Manager'=>'Media Alt Text Manager','Show your support'=>'Zeige deine Unterstützung','To efficiently manage Alt Text for images, please visit the %1$sMedia Library in List Mode%2$s.'=>'Um Alt-Text für Bilder effizient zu verwalten, besuche bitte die %1$sMedienbibliothek im Listenmodus%2$s.','Work with Gulshan'=>'Arbeit mit Gulshan']];
Binary file added languages/media-alt-text-manager-de_DE.mo
Binary file not shown.
70 changes: 70 additions & 0 deletions languages/media-alt-text-manager-de_DE.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
msgid ""
msgstr ""
"Project-Id-Version: Media Alt Text Manager\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-10-08 21:25+0000\n"
"PO-Revision-Date: 2024-10-08 21:29+0000\n"
"Last-Translator: Gulshan Kumar\n"
"Language-Team: German\n"
"Language: de_DE\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Loco https://localise.biz/\n"
"X-Loco-Version: 2.6.11; wp-6.6.2\n"
"X-Domain: media-alt-text-manager"

#. Description of the plugin
msgid ""
"Adds a sortable Alt Text column to the media library for quick alt text "
"management."
msgstr ""
"Fügt eine sortierbare Alt-Text-Spalte zur Medienbibliothek hinzu, um Alt-"
"Text schnell zu verwalten."

#: media-alt-text-manager.php:98
msgid "Alt Text"
msgstr "Alt-Text"

#: media-alt-text-manager.php:85
msgid "Buy developer a coffee"
msgstr "Kaufe Entwickler einen Kaffee"

#. Author of the plugin
msgid "Gulshan Kumar"
msgstr "Gulshan Kumar"

#: media-alt-text-manager.php:75
msgid "Hire for Technical Support"
msgstr "Anstellung für technischen Support"

#. URI of the plugin
msgid "https://wordpress.org/plugins/media-alt-text-manager/"
msgstr "https://wordpress.org/plugins/media-alt-text-manager/"

#. Author URI of the plugin
msgid "https://www.gulshankumar.net"
msgstr "https://www.gulshankumar.net"

#. Name of the plugin
msgid "Media Alt Text Manager"
msgstr "Media Alt Text Manager"

#: media-alt-text-manager.php:82
msgid "Show your support"
msgstr "Zeige deine Unterstützung"

#. %1$s: opening link tag, %2$s: closing link tag
#: media-alt-text-manager.php:48
#, php-format
msgid ""
"To efficiently manage Alt Text for images, please visit the %1$sMedia "
"Library in List Mode%2$s."
msgstr ""
"Um Alt-Text für Bilder effizient zu verwalten, besuche bitte die "
"%1$sMedienbibliothek im Listenmodus%2$s."

#: media-alt-text-manager.php:77
msgid "Work with Gulshan"
msgstr "Arbeit mit Gulshan"
2 changes: 2 additions & 0 deletions languages/media-alt-text-manager-el.l10n.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
return ['project-id-version'=>'Media Alt Text Manager','report-msgid-bugs-to'=>'','pot-creation-date'=>'2024-10-08 21:25+0000','po-revision-date'=>'2024-10-08 21:37+0000','last-translator'=>'Gulshan Kumar','language-team'=>'Greek','language'=>'el','plural-forms'=>'nplurals=2; plural=n != 1;','mime-version'=>'1.0','content-type'=>'text/plain; charset=UTF-8','content-transfer-encoding'=>'8bit','x-generator'=>'Loco https://localise.biz/','x-loco-version'=>'2.6.11; wp-6.6.2','x-domain'=>'media-alt-text-manager','messages'=>['Adds a sortable Alt Text column to the media library for quick alt text management.'=>'Προσθέτει μια ταξινομήσιμη στήλη Alt Text στη βιβλιοθήκη πολυμέσων για γρήγορη διαχείριση του κειμένου alt.','Alt Text'=>'Κείμενο Alt','Buy developer a coffee'=>'Αγοράστε στον προγραμματιστή έναν καφέ','Gulshan Kumar'=>'Gulshan Kumar','Hire for Technical Support'=>'Πρόσληψη για τεχνική υποστήριξη','https://wordpress.org/plugins/media-alt-text-manager/'=>'https://wordpress.org/plugins/media-alt-text-manager/','https://www.gulshankumar.net'=>'https://www.gulshankumar.net','Media Alt Text Manager'=>'Διαχειριστής κειμένου Alt Media','Show your support'=>'Δείξτε την υποστήριξή σας','To efficiently manage Alt Text for images, please visit the %1$sMedia Library in List Mode%2$s.'=>'Για την αποτελεσματική διαχείριση του κειμένου Alt για εικόνες, επισκεφθείτε τη βιβλιοθήκη %1$sMedia Library in List Mode%2$s.','Work with Gulshan'=>'Εργασία με τον Gulshan']];
Binary file added languages/media-alt-text-manager-el.mo
Binary file not shown.
70 changes: 70 additions & 0 deletions languages/media-alt-text-manager-el.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
msgid ""
msgstr ""
"Project-Id-Version: Media Alt Text Manager\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-10-08 21:25+0000\n"
"PO-Revision-Date: 2024-10-08 21:37+0000\n"
"Last-Translator: Gulshan Kumar\n"
"Language-Team: Greek\n"
"Language: el\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Loco https://localise.biz/\n"
"X-Loco-Version: 2.6.11; wp-6.6.2\n"
"X-Domain: media-alt-text-manager"

#. Description of the plugin
msgid ""
"Adds a sortable Alt Text column to the media library for quick alt text "
"management."
msgstr ""
"Προσθέτει μια ταξινομήσιμη στήλη Alt Text στη βιβλιοθήκη πολυμέσων για "
"γρήγορη διαχείριση του κειμένου alt."

#: media-alt-text-manager.php:98
msgid "Alt Text"
msgstr "Κείμενο Alt"

#: media-alt-text-manager.php:85
msgid "Buy developer a coffee"
msgstr "Αγοράστε στον προγραμματιστή έναν καφέ"

#. Author of the plugin
msgid "Gulshan Kumar"
msgstr "Gulshan Kumar"

#: media-alt-text-manager.php:75
msgid "Hire for Technical Support"
msgstr "Πρόσληψη για τεχνική υποστήριξη"

#. URI of the plugin
msgid "https://wordpress.org/plugins/media-alt-text-manager/"
msgstr "https://wordpress.org/plugins/media-alt-text-manager/"

#. Author URI of the plugin
msgid "https://www.gulshankumar.net"
msgstr "https://www.gulshankumar.net"

#. Name of the plugin
msgid "Media Alt Text Manager"
msgstr "Διαχειριστής κειμένου Alt Media"

#: media-alt-text-manager.php:82
msgid "Show your support"
msgstr "Δείξτε την υποστήριξή σας"

#. %1$s: opening link tag, %2$s: closing link tag
#: media-alt-text-manager.php:48
#, php-format
msgid ""
"To efficiently manage Alt Text for images, please visit the %1$sMedia "
"Library in List Mode%2$s."
msgstr ""
"Για την αποτελεσματική διαχείριση του κειμένου Alt για εικόνες, επισκεφθείτε "
"τη βιβλιοθήκη %1$sMedia Library in List Mode%2$s."

#: media-alt-text-manager.php:77
msgid "Work with Gulshan"
msgstr "Εργασία με τον Gulshan"
2 changes: 2 additions & 0 deletions languages/media-alt-text-manager-es_ES.l10n.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
return ['project-id-version'=>'Media Alt Text Manager','report-msgid-bugs-to'=>'','pot-creation-date'=>'2024-10-08 21:25+0000','po-revision-date'=>'2024-10-08 21:27+0000','last-translator'=>'Gulshan Kumar','language-team'=>'Spanish (Spain)','language'=>'es_ES','plural-forms'=>'nplurals=2; plural=n != 1;','mime-version'=>'1.0','content-type'=>'text/plain; charset=UTF-8','content-transfer-encoding'=>'8bit','x-generator'=>'Loco https://localise.biz/','x-loco-version'=>'2.6.11; wp-6.6.2','x-domain'=>'media-alt-text-manager','messages'=>['Adds a sortable Alt Text column to the media library for quick alt text management.'=>'Añade una columna de texto alternativo ordenable a la biblioteca multimedia para una gestión rápida del texto alternativo.','Alt Text'=>'Texto alternativo','Buy developer a coffee'=>'Invita a un café al promotor','Gulshan Kumar'=>'Gulshan Kumar','Hire for Technical Support'=>'Contratación de asistencia técnica','https://wordpress.org/plugins/media-alt-text-manager/'=>'https://wordpress.org/plugins/media-alt-text-manager/','https://www.gulshankumar.net'=>'https://www.gulshankumar.net','Media Alt Text Manager'=>'Gestor de texto alternativo multimedia','Show your support'=>'Muestra tu apoyo','To efficiently manage Alt Text for images, please visit the %1$sMedia Library in List Mode%2$s.'=>'Para gestionar eficazmente el texto alternativo de las imágenes, visite %1$sBiblioteca multimedia en modo lista%2$s.','Work with Gulshan'=>'Trabaja con Gulshan']];
Binary file added languages/media-alt-text-manager-es_ES.mo
Binary file not shown.
Loading

0 comments on commit 8c17857

Please sign in to comment.