Commit 5b80c38f authored by Malcolm Blaney's avatar Malcolm Blaney

Reader module improvements following recent commits, ListChannels

also needed special case for Facebook and Twitter. Tooltip UI
improvements and fix reappearing tooltip when newFeedEvents gets
called again.
parent 1d219089
Pipeline #43266029 passed with stage
in 1 minute and 15 seconds
......@@ -879,7 +879,6 @@ button.ui-button::-moz-focus-inner {
padding: 8px;
position: absolute;
z-index: 99;
max-width: 300px;
}
body .ui-tooltip {
border-width: 2px;
......
......@@ -556,7 +556,7 @@ class Reader extends Base {
'"","a.tooltip-photo img","border-radius","2px"',
'"","a.tooltip-name","line-height","2em"',
'"","a.tooltip-name","font-size","1.2em"',
'"","a.tooltip-name","padding-right","30px"',
'"","a.tooltip-name","padding-right","100px"',
'"","a.tooltip-name","text-decoration","none"',
'"","a.tooltip-url","font-size","0.8em"',
'"","a.tooltip-url","text-decoration","none"',
......@@ -2093,7 +2093,8 @@ class Reader extends Base {
}
private function ListChannels($id, $info_only = false) {
$result = ['info' => [], 'author' => []];
// Make sure empty arrays aren't converted to the wrong json.
$result = ['info' => (object)[], 'author' => (object)[]];
$mysqli = connect_db();
$owner = $this->SwitchOwner();
$query = 'SELECT channel_name, channel_order, display_unread FROM ' .
......@@ -2120,6 +2121,12 @@ class Reader extends Base {
while ($reader_channels = $mysqli_result->fetch_assoc()) {
$us_author = $reader_channels['author'];
$us_feed = $reader_channels['xml_url'];
if (strpos($us_feed, 'https://facebook-atom.appspot.com') === 0) {
$us_feed = 'https://facebook-atom.appspot.com';
}
else if (strpos($us_feed, 'https://twitter-atom.appspot.com') === 0) {
$us_feed = 'https://twitter-atom.appspot.com';
}
$result['author'][$us_author . ' ' . $us_feed] =
$reader_channels['channel'];
}
......
......@@ -263,6 +263,7 @@ class Writer extends Base {
'"",".writer-options-title","padding","2px"',
'"",".writer-options-author","padding","2px"',
'"",".writer-options-twitter","padding","2px"',
'"",".writer-options-photo","padding","2px"',
'"",".writer-menu-wrapper","opacity",".8"',
'"",".writer-menu-wrapper","position","absolute"',
'"",".writer-menu-wrapper","left","-3px"',
......@@ -310,6 +311,7 @@ class Writer extends Base {
'"",".writer label[for=writer-author]","display",' .
'"inline-block"',
'"",".writer-twitter","margin-left","10px"',
'"",".writer-photo","margin","0 5px 0 10px"',
'"","#writer-follow","float","right"',
'"","#writer-photo-selected","margin","5px 5px 0 40px"',
'"","#writer-photo-selected","background-color","#eeeeee"',
......
......@@ -77,8 +77,11 @@ var formData=new FormData();if(!formData){dobrado.log('Your browser doesn\'t sup
dobrado.log('Importing file...','info');var file=$('#reader-file-import').get(0).files[0];if(file){formData.append('file',file);formData.append('request','reader');formData.append('action','import');formData.append('url',location.href);formData.append('token',dobrado.token);$.ajax({url:'/php/request.php',data:formData,contentType:false,processData:false,type:'POST',success:function(response){if(dobrado.checkResponseError(response,'reader importFile')){return;}
importList=JSON.parse(response);importCount=0;if(importList.length!==0){var text='<p>Found <b>'+importList.length+'</b> feeds in imported file:</p>';$('.reader-discovered').html(text).dialog('open');addImportedFeed();}}});}
return false;}
function newFeedEvents(){(function tooltipEvents(){var channelOptions=$('#reader-channel-select').html();function tooltipContent(){var photo=$(this).siblings('.author-photo-url');var name=$(this).html();var link=$(this).attr('href');var feed=$(this).parents('.reader-group').find('a.reader-group-link');var feedUrl=feed.attr('href');var content='<a class="tooltip-photo" href="'+photo.attr('href')+'">'+
photo.html()+'</a>'+'<a class="tooltip-name" href="'+link+'">'+name+'</a><br>'+'<a class="tooltip-url" href="'+link+'">'+link+'</a>';if(channelOptions!==''){content+='<div class="tooltip-channel-info">';if(feedUrl===link||feedUrl==='https://twitter-atom.appspot.com'||feedUrl==='https://facebook-atom.appspot.com'){content+='Channel: <a class="tooltip-feed" href="'+
function newFeedEvents(){$('.ui-tooltip').remove();(function tooltipEvents(){var channelOptions=$('#reader-channel-select').html();function tooltipContent(){var name=$(this).html();var link=$(this).attr('href');var feed=$(this).parents('.reader-group').find('a.reader-group-link');var feedUrl=feed.attr('href');var photo=$(this).siblings('.author-photo-url');var content='';if(photo.length!==0){content+='<a class="tooltip-photo" href="'+
photo.attr('href')+'">'+photo.html()+'</a>';}
content+='<a class="tooltip-name" href="'+link+'">'+
name+'</a><br><a class="tooltip-url" href="'+link+'">'+
link+'</a>';if(channelOptions!==''){content+='<div class="tooltip-channel-info">';if(feedUrl===link||feedUrl==='https://twitter-atom.appspot.com'||feedUrl==='https://facebook-atom.appspot.com'){content+='Channel: <a class="tooltip-feed" href="'+
feedUrl+'"></a>';}
else{content+='Channel for posts from '+name+' in <a class="tooltip-feed" href="'+feedUrl+'">'+
feed.html()+'</a>: ';}
......@@ -91,9 +94,10 @@ $('#tooltip-channel-add').val('');tooltipSetChannel(option,true);}
function tooltipSetChannel(option,add){var feed=$('.tooltip-feed').attr('href');var author=$('.tooltip-name').html();dobrado.log('Setting channel for author','info');$.post('/php/request.php',{id:'#'+$('.reader').attr('id'),request:'reader',action:'setChannel',channel:option,feed:feed,author:author,url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'reader tooltipsetChannel')){return;}
var channel=JSON.parse(response);if(add){$('#reader-channel-select').append('<option>'+channel.name+'</option>');}
if(dobrado.localStorage){let authorChannel={};if(localStorage.readerAuthorChannel){authorChannel=JSON.parse(localStorage.readerAuthorChannel);}
authorChannel[author+' '+feed]=channel.name;localStorage.readerAuthorChannel=JSON.stringify(authorChannel);}});}
authorChannel[author+' '+feed]=channel.name;localStorage.readerAuthorChannel=JSON.stringify(authorChannel);}
$('.ui-tooltip').remove();});}
if(!event.originalEvent){return false;}
$('.ui-tooltip').not('#'+ui.tooltip.attr('id')).remove();$('#tooltip-channel-submit').button().click(tooltipAddChannel);let author=$('.tooltip-name').html();let feed=$('.tooltip-feed').attr('href');let currentChannel='';if(dobrado.localStorage&&localStorage.readerAuthorChannel){let authorChannel=JSON.parse(localStorage.readerAuthorChannel);if(authorChannel[author+' '+feed]){currentChannel=authorChannel[author+' '+feed];}}
$('.ui-tooltip').not('#'+ui.tooltip.attr('id')).remove();$('#tooltip-channel-submit').button().click(tooltipAddChannel);let author=$('.tooltip-name').html();let feed=$('.tooltip-feed').attr('href');let currentChannel=$('#page-select').val();if(dobrado.localStorage&&localStorage.readerAuthorChannel){let authorChannel=JSON.parse(localStorage.readerAuthorChannel);if(authorChannel[author+' '+feed]){currentChannel=authorChannel[author+' '+feed];}}
$('#tooltip-channel-select').val(currentChannel).selectmenu({change:tooltipSelectChannel});}
$('.reader-item .author-name').tooltip({items:'.author-name',content:tooltipContent,open:tooltipOpen,close:function(event,ui){function over(){$(this).stop(true).fadeIn();}
function out(){if(!$('#tooltip-channel-select-menu').parent().hasClass('ui-selectmenu-open')){$(this).fadeOut(400,function(){$(this).remove();});}}
......@@ -153,5 +157,5 @@ if(reader.content){$('.reader-content').html(reader.content);}
if(reader.more){$('.reader-more').show();}
else{$('.reader-more').hide();}
$('.reader-settings').html(reader.settings);feedSettings();newFeedEvents();if(dobrado.localStorage){localStorage.reader=reader.content;localStorage.readerUpdate=new Date().getTime();localStorage.readerPage=location.href;}});};dobrado.reader.channelSelect=function(channel){$.post('/php/request.php',{id:'#'+$('.reader').attr('id'),request:'reader',action:'changeChannel',channel:channel,url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'reader change channel')){return;}
var change=JSON.parse(response);if(change.channel){reset(false);updatePageSelect(channel,false);$('#page-select').pageselectmenu('refresh');}
var change=JSON.parse(response);if(change.channel){updatePageSelect(channel,false);$('#page-select').pageselectmenu('refresh');reset(false);}
else{dobrado.changePage(channel);}});};dobrado.reader.update=function(action){request('newer',action);};dobrado.reader.scrollback=function(url,cancelled){if($('.reader-item a[href="'+url+'"]').length!==0){$('.reader-item a[href="'+url+'"]').get(0).scrollIntoView();if(!cancelled){let item=$('.reader-item a[href="'+url+'"]').parents('.reader-item');item.find('indie-action').data('checked',false);dobrado.indieConfig();}}};}());
\ No newline at end of file
......@@ -460,21 +460,27 @@ if (!this.dobrado.reader) {
function newFeedEvents() {
// Remove any existing tooltips before setting up new ones.
$('.ui-tooltip').remove();
(function tooltipEvents() {
var channelOptions = $('#reader-channel-select').html();
function tooltipContent() {
var photo = $(this).siblings('.author-photo-url');
var name = $(this).html();
var link = $(this).attr('href');
var feed = $(this).parents('.reader-group').find('a.reader-group-link');
var feedUrl = feed.attr('href');
var content =
'<a class="tooltip-photo" href="' + photo.attr('href') + '">' +
photo.html() + '</a>' +
'<a class="tooltip-name" href="' + link + '">' + name + '</a><br>' +
'<a class="tooltip-url" href="' + link + '">' + link + '</a>';
var photo = $(this).siblings('.author-photo-url');
var content = '';
if (photo.length !== 0) {
content += '<a class="tooltip-photo" href="' +
photo.attr('href') + '">' + photo.html() + '</a>';
}
content += '<a class="tooltip-name" href="' + link + '">' +
name + '</a><br><a class="tooltip-url" href="' + link + '">' +
link + '</a>';
if (channelOptions !== '') {
content += '<div class="tooltip-channel-info">';
// If author matches feed don't need to show as much detail here.
......@@ -548,6 +554,7 @@ if (!this.dobrado.reader) {
localStorage.readerAuthorChannel =
JSON.stringify(authorChannel);
}
$('.ui-tooltip').remove();
});
}
......@@ -559,7 +566,7 @@ if (!this.dobrado.reader) {
$('#tooltip-channel-submit').button().click(tooltipAddChannel);
let author = $('.tooltip-name').html();
let feed = $('.tooltip-feed').attr('href');
let currentChannel = '';
let currentChannel = $('#page-select').val();
if (dobrado.localStorage && localStorage.readerAuthorChannel) {
let authorChannel = JSON.parse(localStorage.readerAuthorChannel);
if (authorChannel[author + ' ' + feed]) {
......@@ -920,10 +927,10 @@ if (!this.dobrado.reader) {
}
var change = JSON.parse(response);
if (change.channel) {
reset(false);
// Reset the html for this option to remove unread status.
updatePageSelect(channel, false);
$('#page-select').pageselectmenu('refresh');
reset(false);
}
else {
dobrado.changePage(channel);
......
......@@ -230,7 +230,7 @@ class Control extends Base {
$site_style = ['"",".control","position","sticky"',
'"",".control","width","100%"',
'"",".control","top","0"',
'"",".control","z-index","50"',
'"",".control","z-index","100"',
'"",".control","height","48px"',
'"",".control","display","none"',
'"",".control .wrapper","height","38px"',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment