var sourceListHtmlReturned = function (data){
var $popupWindow = $('#popup-window');
$popupWindow.html(data);
$popupWindow.find("div:first").trigger('slotReady');
}
var gettingSourceListHtmlFail = function (xhr, ajaxOptions, thrownError){
var $popupWindow = $('#popup-window');
var html = $(xhr.responseText);
$popupWindow.html(html);
}
var linkOnClick = function(){
var $_this = $(this);
var href = $_this.attr('href');
// show the loading image for this
var loadingImageUrl = "https://wikirate-production-storage.fra1.cdn.digitaloceanspaces.com/files/20531/12604360-large.gif";
var $popupWindow = $('#popup-window');
if($popupWindow.length==0)
$("#main").prepend('<div id="popup-window" style="display:none;"></div>');//create one
$popupWindow = $('#popup-window');
$popupWindow.html("<img src='"+loadingImageUrl+"' />");
$popupWindow.removeAttr('style');
$popupWindow.dialog({
height: 'auto',
minWidth: 700,
position: 'center',
title: '<i class="fa fa-arrows"></i>',
closeOnEscape: false,
resizable: false,
draggable: true,
close: function( event, ui ) {
$popupWindow.dialog("destroy");
}
});
//create a ajax call to get content and show
var jqxhr = $.ajax(href+"?view=content")
.done(sourceListHtmlReturned)
.fail(gettingSourceListHtmlFail);
return false;
}
wagn.slotReady(function(slot) {
slot.find('.show-link-in-popup').each(function(){
$(this).off("click").click(linkOnClick);
});
});