// source --> https://servicios.intec.santafe-conicet.gov.ar/grupos/iayb/wp-content/plugins/file-away/lib/js/management.js?ver=3.9.6.1
(function(jQuery)
{
jQuery.fn.hasAttr = function(name)
{
for(var i = 0, l = this.length; i < l; i++)
{
if(!!(this.attr(name) !== undefined)) return true;
}
return false;
};
})(jQuery);
jQuery(document).ready(function($)
{
// FLASH BODY WIDTH FOR WEB FONTS
setTimeout(function(){
$('body').width($('body').width()+1).width('auto');
}, 500);
// OPEN RSS LINKS
$('span.ssfa-rssmini').on('click', function()
{
window.open($(this).data('href'));
});
});
FlightBoxes = [];
jQuery(document).ready(function($)
{
flightbox = function(url, uid, theme, icons, nolinks)
{
var in_iframe = (window.location != window.parent.location) ? 'iframe ' : '';
if(typeof(url) === 'undefined') url = false;
if(!url) return false;
var id = uid.split("-");
var flightbox_nonce = $('div.flightbox-parent[data-uid="'+id[0]+'"]').data('fbn');
if(!$('#ssfa-flightbox-shadow').length)
{
var FlightBox = $('
');
var FlightBoxCont = $('');
var theShadow = $('');
$('body', window.top.document).append(theShadow);
$('body', window.top.document).append(FlightBox);
theShadow.hide();
FlightBox.hide();
}
else
{
var FlightBox = $('div#ssfa-flightbox', window.top.document);
var FlightBoxCont = $('div.ssfa-flightbox-controls', window.top.document);
var theShadow = $('div#ssfa-flightbox-shadow', window.top.document);
}
theShadow.on('click', function(e)
{
Xflightbox();
});
$('body').on("contextmenu", 'div#ssfa-flightbox-shadow, div#ssfa-flightbox', function()
{
return false;
});
if(!$('div.flightbox-spinner').length)
{
var loading = $(
''
);
}
else var loading = $('div.flightbox-spinner');
FlightBoxCont.prepend(loading);
var total = FlightBoxes[id[0]];
var next = id[1] >= total ? 1 : (+id[1]+1);
var prev = id[1] == 1 ? total : (+id[1]-1);
$next = $('div.ssfa-meta-container[data-uid="'+id[0]+'"] a[data-flightbox="'+(next)+'"]');
$next = $next.length
? $next.get(0).attributes.onclick.value
: $('iframe').contents().find('div.ssfa-meta-container[data-uid="'+id[0]+'"] a[data-flightbox="'+(next)+'"]').get(0).attributes.onclick.value;
$prev = $('div.ssfa-meta-container[data-uid="'+id[0]+'"] a[data-flightbox="'+(prev)+'"]');
$prev = $prev.length
? $prev.get(0).attributes.onclick.value
: $('iframe').contents().find('div.ssfa-meta-container[data-uid="'+id[0]+'"] a[data-flightbox="'+(prev)+'"]').get(0).attributes.onclick.value;
$current = $('div.ssfa-meta-container[data-uid="'+id[0]+'"] a[data-flightbox="'+(id[1])+'"]');
$current = $current.length
? $current.get(0).attributes.onclick.value
: $('iframe').contents().find('div.ssfa-meta-container[data-uid="'+id[0]+'"] a[data-flightbox="'+(id[1])+'"]').get(0).attributes.onclick.value;
$nexturl = $('div.ssfa-meta-container[data-uid="'+id[0]+'"] a[data-flightbox="'+(next)+'"]');
$nexturl = $nexturl.length
? $nexturl.attr('href')
: $('iframe').contents().find('div.ssfa-meta-container[data-uid="'+id[0]+'"] a[data-flightbox="'+(next)+'"]').attr('href');
$prevurl = $('div.ssfa-meta-container[data-uid="'+id[0]+'"] a[data-flightbox="'+(prev)+'"]');
$prevurl = $prevurl.length
? $prevurl.attr('href')
: $('iframe').contents().find('div.ssfa-meta-container[data-uid="'+id[0]+'"] a[data-flightbox="'+(prev)+'"]').attr('href');
$url = $('div.ssfa-meta-container[data-uid="'+id[0]+'"] a[data-flightbox="'+(id[1])+'"]');
$url = $url.length
? $url.attr('href')
: $('iframe').contents().find('div.ssfa-meta-container[data-uid="'+id[0]+'"] a[data-flightbox="'+(id[1])+'"]').attr('href');
var wh = $(window.top).height();
var ww = $(window.top).width();
theShadow.fadeIn(500);
$.post
(
fileaway_mgmt.ajaxurl,
{
action : 'fileaway-manager',
dataType : 'html',
act : 'flightbox',
url : url,
uid : String(uid),
theme : theme,
icons : icons,
wh : wh,
ww : ww,
next : $next,
prev : $prev,
nexturl : $nexturl,
prevurl : $prevurl,
currenturl : $url,
current : $current,
nolinks : nolinks,
nonce : fileaway_mgmt.nonce,
flightbox_nonce : flightbox_nonce
},
function(response)
{
$('div#ssfa-flightbox-inner', window.top.document).animate({opacity:'0'}, 500);
$('div.ssfa-flightbox-controls a', window.top.document).animate({opacity:'0'}, 0);
loading.remove();
FlightBox.delay(500).animate({
left: response.offset,
height: response.height,
width: response.width,
top: response.top
}, 500, function(){
$(this).replaceWith(response.html);
$('div#ssfa-flightbox-inner', window.top.document).animate({opacity:'1'}, 500);
$('div.ssfa-flightbox-controls span', window.top.document).css({opacity:'0.8'});
if(response.iframe == 'true', window.top.document)
{
$('div#ssfa-flightbox-inner iframe', window.top.document).width(response.iwidth);
$('div#ssfa-flightbox-inner iframe', window.top.document).height(response.iheight);
}
});
}
)
return false;
}
// close the flightbox
Xflightbox = function()
{
$('div#ssfa-flightbox', window.parent.document).fadeOut(500).queue(function(){$(this).remove();});
$('div#ssfa-flightbox-shadow', window.parent.document).fadeOut(500).queue(function(){$(this).remove();});
}
});
jQuery(document).ready(function($)
{
// Bulk Download Check
if($('span[id^=ssfa-bulk-download-engage]').length)
{
// Cache the Data on DOM Ready
$('table.bd-table tr[id^=ssfa-file-]').each(function()
{
$sfx = this.id;
$type = $('td#filetype-'+$sfx).data('ext');
$path = $('td#filename-'+$sfx).data('path');
$name = $('td#filename-'+$sfx).data('name');
});
// Bulk Download Select All Function
$checkall = $('input[id^="ssfa-bulk-download-select-all-"]');
$checkall.on('change', function()
{
$uid = this.id;
$uid = $uid.replace('ssfa-bulk-download-select-all-', '');
$selectalltext = $(this).data('selectall');
$clearalltext = $(this).data('clearall');
$selectall = $('label#ssfa-bulkdownload-select-all-'+$uid);
if(this.checked)
{
$selectall.text($clearalltext);
$('table.bd-table tr[id^=ssfa-file-'+$uid+']').addClass('ssfabd-selected');
$('table.bd-table tr[id^=ssfa-file-'+$uid+'].fileaway-dynamic').removeClass('ssfabd-selected');
}
else
{
$selectall.text($selectalltext);
$('table.bd-table tr[id^=ssfa-file-'+$uid+']').removeClass('ssfabd-selected');
}
});
// Bulk Download Toggle Selected Files
$('table.bd-table tr[id^=ssfa-file-]').each(function()
{
$(this).on('click', function(e)
{
var target = $(e.target);
if(!target.is('a', this)
&& !target.is('span', this)
&& !target.is('div.ssfa-audio-download', this)
&& !target.is('div.ssfa-player', this)
&& !target.is('div.ssfa-player-extended', this))
{
if($(this).hasClass('ssfabd-selected')) $(this).removeClass('ssfabd-selected');
else if(!$(this).hasClass('fileaway-dynamic')) $(this).addClass('ssfabd-selected');
}
});
});
// Bulk Download Engage Function
$('span[id^="ssfa-bulk-download-engage-"]').on('click', function()
{
$uid = this.id;
$uid = $uid.replace('ssfa-bulk-download-engage-', '');
$loading = $('img#ssfa-engage-ajax-loading-'+$uid);
var stats = $('table#ssfa-table-'+$uid).data('stats') ? 'true' : 'false';
var bulkdownload_nonce = $('table#ssfa-table-'+$uid).data('bd');
var selectedFilesFrom = {};
var selectedCount = 0;
var messages = '';
var jackoff = false;
$('table.bd-table tr[id^=ssfa-file-'+$uid+']').each(function(index)
{
if($(this).hasClass('ssfabd-selected'))
{
var sfx = this.id;
var filepath = String($('td#filename-'+sfx).data('path'));
var oldname = String($('td#filename-'+sfx).data('name'));
var ext = String($('td#filetype-'+sfx).data('ext'));
if(oldname.indexOf('..') >= 0 || filepath.indexOf('..') >= 0 || filepath === '/') jackoff = true;
else
{
selectedFilesFrom[index] = filepath+'/'+oldname+'.'+ext;
selectedCount++;
}
}
});
if(jackoff)
{
filertify.set({labels:{ok : fileaway_mgmt.ok_label}});
filertify.alert(fileaway_mgmt.tamper1);
}
else
{
if(selectedCount == 0)
messages += fileaway_mgmt.no_files_selected+'
';
if(messages !== '')
{
filertify.set({labels:{ok : fileaway_mgmt.ok_label }});
filertify.alert(messages)
}
else
{
// Ajax Bulk Action Download Function
$loading.show();
$.post(
fileaway_mgmt.ajaxurl,
{
action : 'fileaway-manager',
dataType : 'html',
act : 'bulkdownload',
files : selectedFilesFrom,
stats : stats,
nonce : fileaway_mgmt.nonce,
bulkdownload_nonce : bulkdownload_nonce
},
function(response)
{
$loading.hide();
if(response == 'Error')
{
filertify.set({labels:{ok : fileaway_mgmt.ok_label }});
filertify.alert(response);
}
else
{
$('