Commit a5a11b97 authored by Malcolm Blaney's avatar Malcolm Blaney

Bug fix for Reader module to re-render channel buttons when feed

settings are refreshed. A few other small UI improvements to
Writer and Control modules.
parent 6b9185ce
Pipeline #40243029 passed with stage
in 1 minute and 15 seconds
......@@ -117,7 +117,7 @@ class Writer extends Base {
if (!$this->AlreadyOnPage('reader')) {
$feed_title = '<div class="form-spacing">' .
'<label for="writer-feed-title-input">Feed title</label>' .
'<input id="writer-feed-title-input" maxlength="100" ' .
'<input id="writer-feed-title-input" type="text" maxlength="100" ' .
'value="' . $this->FeedTitle() . '">' .
'<button class="submit-feed-title">submit</button>' .
'</div>';
......@@ -135,7 +135,7 @@ class Writer extends Base {
'<div class="form-spacing">' .
'<label for="writer-designate-input">Page for displaying </label>' .
'<select id="writer-designate-action">' . $options . '</select>' .
'<input id="writer-designate-input" maxlength="200" ' .
'<input id="writer-designate-input" type="text" maxlength="200" ' .
'value="' . $this->Designate($action) . '">' .
'<button class="submit-designate">submit</button>' .
'</div>' .
......@@ -167,13 +167,13 @@ class Writer extends Base {
'<div class="writer-options-title hidden">' .
'<button class="writer-remove-title">remove</button>' .
'<label for="writer-title">Title: </label>' .
'<input id="writer-title" maxlength="180">' .
'<input id="writer-title" type="text" maxlength="180">' .
'</div>' .
'<div class="writer-options-author hidden">' .
'<button class="writer-remove-author">remove</button>' .
'<label for="writer-author">Author: </label>' .
'<input id="writer-author" value="' . $this->user->name . '" ' .
'maxlength="50">' .
'type="text" maxlength="50">' .
'</div>' .
'<div class="writer-options-twitter hidden">' .
'<button class="writer-remove-twitter">remove</button>' .
......@@ -282,10 +282,13 @@ class Writer extends Base {
'"1px solid #aaaaaa"',
'"",".writer .designate","padding","5px"',
'"",".writer .designate","margin-bottom","10px"',
'"",".writer .designate label","width","15em"',
'"",".writer .designate label","width","10em"',
'"",".writer .submit-designate","margin-left","5px"',
'"","#writer-feed-title-input","width","324px"',
'"",".writer .submit-feed-title","margin-left","5px"',
'"","#writer-feed-title-input","width","394px"',
'"","#writer-designate-action-button","width","100px"',
'"","#writer-designate-input","width","250px"',
'"","#writer-designate-input","margin-left","5px"',
'"","#writer-webaction-info","padding-bottom","2px"',
'"","#writer-action-type","font-weight","bold"',
'"",".writer .info .ui-icon","display","inline-block"',
......
......@@ -26,15 +26,15 @@
if(!this.dobrado.reader){dobrado.reader={};}
(function(){'use strict';var importList=[];var importCount=0;$(function(){if($('.reader').length===0){return;}
var tenMinutes=600000;var elapsed=tenMinutes+1;var pageChanged=true;$('.reader-edit-settings').button({icon:'ui-icon-signal-diag',showLabel:false}).click(function(){$('.reader-settings').toggle();});$('.reader-more').button().click(function(){$('.reader-more').button('option','label','Loading...');request('older','feed');});$('.reader-reset').button().click(reset);$('#reader-show-hidden').button().click(function(){$('.reader-hidden').show();$('.reader-show-hidden-wrapper').hide();});$('#reader-feed-input').val('');$('.reader-discovered').dialog({show:true,autoOpen:false,width:600,height:300,position:{my:'top',at:'top+50',of:window},title:'Discovered Feeds',close:function(){importList=[];importCount=0;},create:dobrado.fixedDialog});$('.reader-channel-button').button().click(channelSettings);$('.reader-channel-settings').dialog({show:true,autoOpen:false,width:600,height:300,position:{my:'top',at:'top+50',of:window},title:'Channel List',create:dobrado.fixedDialog});feedSettings();if(dobrado.localStorage&&localStorage.reader){$('.reader-content').html(localStorage.reader);$('.reader-writer').show();$('.reader-more').show();$('.reader-reset').show();if(localStorage.readerUpdate){elapsed=new Date().getTime()-localStorage.readerUpdate;}
var tenMinutes=600000;var elapsed=tenMinutes+1;var pageChanged=true;$('.reader-edit-settings').button({icon:'ui-icon-signal-diag',showLabel:false}).click(function(){$('.reader-settings').toggle();});$('.reader-more').button().click(function(){$('.reader-more').button('option','label','Loading...');request('older','feed');});$('.reader-reset').button().click(reset);$('#reader-show-hidden').button().click(function(){$('.reader-hidden').show();$('.reader-show-hidden-wrapper').hide();});$('#reader-feed-input').val('');$('.reader-discovered').dialog({show:true,autoOpen:false,width:600,height:300,position:{my:'top',at:'top+50',of:window},title:'Discovered Feeds',close:function(){importList=[];importCount=0;},create:dobrado.fixedDialog});$('.reader-channel-settings').dialog({show:true,autoOpen:false,width:600,height:300,position:{my:'top',at:'top+50',of:window},title:'Channel List',create:dobrado.fixedDialog});feedSettings();if(dobrado.localStorage&&localStorage.reader){$('.reader-content').html(localStorage.reader);$('.reader-writer').show();$('.reader-more').show();$('.reader-reset').show();if(localStorage.readerUpdate){elapsed=new Date().getTime()-localStorage.readerUpdate;}
if(localStorage.readerPage){pageChanged=location.href!==localStorage.readerPage;}}
if(pageChanged||($(window).scrollTop()<200&&elapsed>tenMinutes)){reset(true);}
else{if($('.reader-settings .feed-item').length<=5){$('.reader-settings').show();}
newFeedEvents();dobrado.notify('feed',dobrado.reader.update);}});function channelSettings(){function addChannel(){var option=$('#reader-channel-add').val();if(option===''){return;}
$('#reader-channel-add').val('');setChannel(option,true);}
function setChannel(option,add){var feed=$('#reader-channel-url').html();$.post('/php/request.php',{id:'#'+$('.reader').attr('id'),request:'reader',action:'setChannel',channel:option,feed:feed,url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'reader setChannel')){return;}
function setChannel(option,add){var feed=$('#reader-channel-url').attr('href');$.post('/php/request.php',{id:'#'+$('.reader').attr('id'),request:'reader',action:'setChannel',channel:option,feed:feed,url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'reader setChannel')){return;}
var channel=JSON.parse(response);var text=channel.name==='not set'?'The channel for this feed is no longer set.':'The channel for this feed has been updated to <b>'+
channel.name+'</b>';$('#reader-channel-status').html(text);$('.reader-feed-list .feed-url').each(function(){if($(this).html()===feed){let channelButton=$(this).parents('.feed-item').find('.reader-channel-button');channelButton.button('option','label',channel.name);}});if(add){$('#reader-channel-select').append('<option selected="selected">'+
channel.name+'</b>';$('#reader-channel-status').html(text);$('.reader-feed-list .feed-url').each(function(){if($(this).attr('href')===feed){let channelButton=$(this).parents('.feed-item').find('.reader-channel-button');channelButton.button('option','label',channel.name);}});if(add){$('#reader-channel-select').append('<option selected="selected">'+
channel.name+'</option>');$('#reader-channel-select').selectmenu('refresh');$('#reader-channel-select').parent().show();}});}
var title=$(this).parent().find('.feed-title');var link=$(this).parent().find('.feed-url');var channel=$(this).html();var text='';if(title&&link){text='<span id="reader-channel-title">'+title.html()+'</span> [<a href="'+link.attr('href')+'" '+'id="reader-channel-url">'+link.html()+'</a>]';}
else if(link){text+='<a href="'+link.attr('href')+'" id="reader-channel-url">'+
......@@ -51,7 +51,7 @@ else if(ui.item.value==='writer'){$('.writer .designate').show();$('#reader-feed
function channelFeeds(event,ui){$('.reader-feed-list .feed-item').show();if(ui.item.value!==''){$('.reader-feed-list .reader-channel-button').each(function(){if($(this).html()!==ui.item.value){$(this).parents('.feed-item').hide();}});}}
$('#reader-feed-input').keypress(function(event){if(event.keyCode!==13){return;}
event.preventDefault();dobrado.reader.addFeed();});$('.reader-add-feed').button().click(dobrado.reader.addFeed);$('.remove-feed-item').button({icon:'ui-icon-closethick',showLabel:false}).click(removeFeed);if($('.writer .designate').length!==0){$('#reader-options').append('<option value="writer">Writer Settings</option>');}
$('#reader-options').selectmenu({change:readerOption});$('#reader-file-import').change(importFile);$('#reader-channel-show').selectmenu({change:channelFeeds});if($('.feed-text.added').length!==0){$('.feed-text.added').get(0).scrollIntoView();setTimeout(function(){$('.feed-text.added').removeClass('added');},5000);}}
$('#reader-options').selectmenu({change:readerOption});$('#reader-file-import').change(importFile);$('#reader-channel-show').selectmenu({change:channelFeeds});$('.reader-channel-button').button().click(channelSettings);if($('.feed-text.added').length!==0){$('.feed-text.added').get(0).scrollIntoView();setTimeout(function(){$('.feed-text.added').removeClass('added');},5000);}}
function importFile(){function addImportedFeed(){var xmlUrl=importList[importCount].xmlUrl;var last=importCount===importList.length-1;var text='<br><span class="reader-imported-feed-'+importCount+'">Adding: <b>'+importList[importCount].title+'</b> <span class="reader-discovered-feed-url">[<a href="'+
importList[importCount].htmlUrl+'">'+
importList[importCount].htmlUrl+'</a>]</span> ... </span>';$('.reader-discovered').append(text);$.post('/php/request.php',{id:'#'+$('.reader').attr('id'),request:'reader',action:'addImport',last:last,force:true,xmlUrl:xmlUrl,url:location.href,token:dobrado.token},function(response){if(!response){dobrado.log('No response to reader addImport call.','error');return;}
......
......@@ -69,7 +69,6 @@ if (!this.dobrado.reader) {
title: 'Discovered Feeds',
close: function() { importList = []; importCount = 0; },
create: dobrado.fixedDialog });
$('.reader-channel-button').button().click(channelSettings);
$('.reader-channel-settings').dialog({
show: true,
autoOpen: false,
......@@ -124,7 +123,7 @@ if (!this.dobrado.reader) {
}
function setChannel(option, add) {
var feed = $('#reader-channel-url').html();
var feed = $('#reader-channel-url').attr('href');
$.post('/php/request.php',
{ id: '#' + $('.reader').attr('id'), request : 'reader',
action: 'setChannel', channel: option, feed: feed,
......@@ -141,7 +140,7 @@ if (!this.dobrado.reader) {
$('#reader-channel-status').html(text);
// Also update the channel button in the feed setting list.
$('.reader-feed-list .feed-url').each(function() {
if ($(this).html() === feed) {
if ($(this).attr('href') === feed) {
let channelButton =
$(this).parents('.feed-item').find('.reader-channel-button');
channelButton.button('option', 'label', channel.name);
......@@ -264,6 +263,7 @@ if (!this.dobrado.reader) {
$('#reader-options').selectmenu({ change: readerOption });
$('#reader-file-import').change(importFile);
$('#reader-channel-show').selectmenu({ change: channelFeeds });
$('.reader-channel-button').button().click(channelSettings);
// Any newly added entry will be highlighted, remove the extra
// class after a few seconds.
if ($('.feed-text.added').length !== 0) {
......
......@@ -27,13 +27,13 @@
if(!this.dobrado.writer){dobrado.writer={};}
(function(){'use strict';var sendToTwitter=0;var webactionType='';var webactionUrl='';var defaultText='Write a new post...';$(function(){if($('#writer-content').length===0){return;}
$('#writer-content').click(function(){if(!$('.extended').dialog('isOpen')){dobrado.writer.showEditor();}});$('.writer-post').button({disabled:true}).click(function(){dobrado.log('Creating post...','info');dobrado.createModule('writer','post','post');});$('#writer-author').val(dobrado.readCookie('user'));$('#writer-title').val('');$('#writer-tag-input').val('');$('#writer-tags').checkboxradio({icon:false}).click(toggleTags);$('.writer .menu').menu();$('#writer-photo-browse').button().click(function(){dobrado.createModule('browser','browser','writer');});$('.writer-edit-settings').button({icon:'ui-icon-signal-diag',showLabel:false}).click(function(){if($('.reader-settings').length===0){$('.writer .designate').toggle();}
else{$('.reader-settings').toggle();}});$('#writer-designate-action').val('post').change(showDesignate);$('.writer .submit-designate').button().click(designate);$('.writer .submit-feed-title').button().click(feedTitle);$('.writer-remove-title').button({icon:'ui-icon-closethick',showLabel:false}).click(removeTitle);$('.writer-remove-author').button({icon:'ui-icon-closethick',showLabel:false}).click(removeAuthor);$('.writer-remove-twitter').button({icon:'ui-icon-closethick',showLabel:false}).click(removeTwitter);$('.writer-remove-photo').button({icon:'ui-icon-closethick',showLabel:false}).click(removePhoto);$('#writer-remove-action').button({icon:'ui-icon-closethick',showLabel:false}).click(removeActionExplicit);if(dobrado.reader){$('#writer-follow').button().click(dobrado.reader.addFeed);}
else{$('.reader-settings').toggle();}});$('#writer-designate-action').val('post');$('#writer-designate-action').selectmenu({change:showDesignate});$('.writer .submit-designate').button().click(designate);$('.writer .submit-feed-title').button().click(feedTitle);$('.writer-remove-title').button({icon:'ui-icon-closethick',showLabel:false}).click(removeTitle);$('.writer-remove-author').button({icon:'ui-icon-closethick',showLabel:false}).click(removeAuthor);$('.writer-remove-twitter').button({icon:'ui-icon-closethick',showLabel:false}).click(removeTwitter);$('.writer-remove-photo').button({icon:'ui-icon-closethick',showLabel:false}).click(removePhoto);$('#writer-remove-action').button({icon:'ui-icon-closethick',showLabel:false}).click(removeActionExplicit);if(dobrado.reader){$('#writer-follow').button().click(dobrado.reader.addFeed);}
if($('.post-comment').length===0){$('<div></div>').addClass('post-comment').appendTo('.writer');}
webactionType=$('#writer-action-type').html();if(webactionType==='like'||webactionType==='reply'){$('#writer-content').val('');}
webactionUrl=$('#writer-action-url').attr('href');if(webactionType==='share'){shareFullText();}
$('.writer-options-add').button({icon:'ui-icon-plus',showLabel:false}).click(add);$('.writer-menu-wrapper .menu li').each(function(){$(this).click(showOptions);});hideOptions();dobrado.writer.showEditor();$('.writer-options').show();});function hideMenu(){$('.writer-menu-wrapper').hide();}
function add(){dobrado.hideOtherMenu('writer-menu-wrapper');dobrado.toggleMenu('writer-menu-wrapper');$('body').one('click',hideMenu);return false;}
function showDesignate(){var action=$('#writer-designate-action').val();dobrado.log('Loading page for displaying '+action+'.','info');$.post('/php/request.php',{request:'writer',mode:'showDesignate',action:action,url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'writer showDesignate')){return;}
function showDesignate(event,ui){dobrado.log('Loading page for displaying '+ui.item.value+'.','info');$.post('/php/request.php',{request:'writer',mode:'showDesignate',action:ui.item.value,url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'writer showDesignate')){return;}
var designate=JSON.parse(response);$('#writer-designate-input').val(designate.page);});return false;}
function designate(){var action=$('#writer-designate-action').val();dobrado.log('Updating page for displaying '+action+'.','info');$.post('/php/request.php',{request:'writer',mode:'designate',action:action,designate:$('#writer-designate-input').val(),url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'writer designate')){return;}});return false;}
function feedTitle(){dobrado.log('Updating feed title.','info');$.post('/php/request.php',{request:'writer',mode:'feedTitle',title:$('#writer-feed-title-input').val(),url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'writer feedTitle')){return;}});return false;}
......
......@@ -73,7 +73,8 @@ if (!this.dobrado.writer) {
$('.reader-settings').toggle();
}
});
$('#writer-designate-action').val('post').change(showDesignate);
$('#writer-designate-action').val('post');
$('#writer-designate-action').selectmenu({ change: showDesignate });
$('.writer .submit-designate').button().click(designate);
$('.writer .submit-feed-title').button().click(feedTitle);
$('.writer-remove-title').button({
......@@ -128,11 +129,10 @@ if (!this.dobrado.writer) {
return false;
}
function showDesignate() {
var action = $('#writer-designate-action').val();
dobrado.log('Loading page for displaying ' + action + '.', 'info');
function showDesignate(event, ui) {
dobrado.log('Loading page for displaying ' + ui.item.value + '.', 'info');
$.post('/php/request.php',
{ request: 'writer', mode: 'showDesignate', action: action,
{ request: 'writer', mode: 'showDesignate', action: ui.item.value,
url: location.href, token: dobrado.token },
function(response) {
if (dobrado.checkResponseError(response, 'writer showDesignate')) {
......
......@@ -260,14 +260,20 @@ class Control extends Base {
'"","#page-input","width","200px"',
'"' . $media . '","#page-input","width","100px"',
'"","#page-select","width","150px"',
'"","#reset-page-select","margin-left","2px"',
'"' . $media . '","#page-select","width","100px"',
'"","#reset-page-select","margin-left","2px"',
'"","#control-page-form .ui-selectmenu-button","width",' .
'"150px"',
'"","#control-page-form .ui-selectmenu-button",' .
'"padding-top","5px"',
'"","#control-page-form .ui-selectmenu-button",' .
'"padding-bottom","5px"',
'"' . $media . '","#control-page-form ' .
'.ui-selectmenu-button","width","100px"',
'"' . $media . '","#control-page-form ' .
'.ui-selectmenu-button","padding-top","3px"',
'"' . $media . '","#control-page-form ' .
'.ui-selectmenu-button","padding-bottom","3px"',
'"","#control-page-form .ui-selectmenu-icon","top","3px"',
'"",".control-input","color","#828282"',
'"",".message-count","position","absolute"',
......@@ -328,13 +334,15 @@ class Control extends Base {
'"' . $media . '",".control .username","display","none"',
'"",".control .info","position","absolute"',
'"",".control .info","width","18em"',
'"",".control .info","padding","8px"',
'"",".control .info","padding","6px"',
'"",".control .info","z-index","1"',
'"",".control .info .message","padding-left","0.2em"',
'"",".control .info .message","font-family","Helvetica"',
'"",".control .error .message","font-family","Helvetica"',
'"",".control .error","position","absolute"',
'"",".control .error","width","18em"',
'"",".control .error","padding","8px"',
'"",".control .error","padding","6px"',
'"",".control .error","z-index","1"',
'"",".control .error .message","padding-left","0.2em"'];
$this->AddSiteStyle($site_style);
$this->AddSettingTypes(['"control","position","scroll,fixed","radio",' .
......
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