| 1 |
jQuery( function ( $ ) { |
| 2 |
|
| 3 |
if ($('#contextual-help-link-wrap .show-recently-viewed').length == 0) |
| 4 |
{ |
| 5 |
$("#screen-meta-links").append('<div id="contextual-help-link-wrap" class="hide-if-no-js screen-meta-toggle" style="z-index:2;"><button class="show-settings show-recently-viewed" style="cursor:pointer">Recently Viewed</button></div>'); |
| 6 |
|
| 7 |
var html = ''; |
| 8 |
|
| 9 |
if ( Object.keys(propertyhive_admin_recently_viewed.recently_viewed).length > 0 ) |
| 10 |
{ |
| 11 |
html += '<ul>'; |
| 12 |
for ( var i in propertyhive_admin_recently_viewed.recently_viewed ) |
| 13 |
{ |
| 14 |
html += '<li><a href="' + propertyhive_admin_recently_viewed.recently_viewed[i].edit_link + '">' + propertyhive_admin_recently_viewed.recently_viewed[i].title + '</a></li>'; |
| 15 |
} |
| 16 |
html += '</ul>'; |
| 17 |
} |
| 18 |
else |
| 19 |
{ |
| 20 |
html += '<div class="none">No recently viewed items to display</div>'; |
| 21 |
} |
| 22 |
|
| 23 |
$("#screen-meta-links").append('<div class="ph-recently-viewed-popup">' + html + '</div>'); |
| 24 |
|
| 25 |
$('body').on('click', '#contextual-help-link-wrap .show-recently-viewed', function(e) |
| 26 |
{ |
| 27 |
e.preventDefault(); |
| 28 |
|
| 29 |
jQuery('.ph-recently-viewed-popup').css({ |
| 30 |
top: $(this).position().top + $(this).outerHeight(), |
| 31 |
right: $(document).width() - ($(this).parent().offset().left + $(this).parent().outerWidth()) |
| 32 |
}).fadeToggle('fast'); |
| 33 |
}); |
| 34 |
} |
| 35 |
}); |