| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- /**
- * Admin JavaScript for the QDR Temporary Shared Storage plugin
- */
- (function($) {
- 'use strict';
- // Initialize datepickers on dynamically created elements
- function initDatepickers() {
- $('.qdr-tss-datepicker').datepicker({
- dateFormat: 'yy-mm-dd',
- changeMonth: true,
- changeYear: true
- });
- }
- // Format file size to human readable format
- function formatFileSize(bytes) {
- if (bytes === 0) return '0 Bytes';
- const k = 1024;
- const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
- const i = Math.floor(Math.log(bytes) / Math.log(k));
- return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
- }
- // Format date to local format
- function formatDate(dateString) {
- if (!dateString || dateString === '0000-00-00 00:00:00') {
- return '-';
- }
-
- var date = new Date(dateString);
-
- // Check if date is valid
- if (isNaN(date.getTime())) {
- return dateString;
- }
-
- return date.toLocaleString();
- }
- // Set active sort indicators
- function updateSortIndicators(orderBy, order) {
- // Remove all indicators
- $('.qdr-tss-table th').removeClass('sorted asc desc');
-
- // Add indicator to current sort column
- var $th = $('.qdr-tss-table th[data-sort="' + orderBy + '"]');
- $th.addClass('sorted ' + order.toLowerCase());
- }
- // Initialize tooltips
- function initTooltips() {
- $('.qdr-tss-tooltip').tooltip({
- position: {
- my: 'center bottom-20',
- at: 'center top',
- using: function(position, feedback) {
- $(this).css(position);
- $('<div>')
- .addClass('arrow')
- .addClass(feedback.vertical)
- .addClass(feedback.horizontal)
- .appendTo(this);
- }
- }
- });
- }
- // Document ready
- $(function() {
- // Initialize datepickers on page load
- initDatepickers();
-
- // Initialize tooltips
- initTooltips();
-
- // Add button for refreshing the list
- $('#qdr-tss-items-list').on('updated', function() {
- initTooltips();
- });
- });
- })(jQuery);
|