Skip to content

Commit

Permalink
Bookmarks Sorting Improvements (#67)
Browse files Browse the repository at this point in the history
* Improvements to table.

Remove the edit this work functionality from the preferences page
Add summary as hidden extra row to table
Different default columns shown depending on screen size
Add column widths for better scaling
Auto generate the column toggle
Add word count column

* Remove tablesort.js as not needed

* Add summary/word count to browse and allow users to unclick a star to delete the bookmark

* Add top fandoms tag search

* Word count parsing bugfix

* Bugfix for set/unset by click, added some hover action and formatting for table and table-extra rows.

* Add error handling for case of works missing word count

* Cleanup and use deferRender

* Build new versions
  • Loading branch information
darthkrallt committed Sep 17, 2018
1 parent abfe367 commit fd88759
Show file tree
Hide file tree
Showing 14 changed files with 307 additions and 260 deletions.
Binary file modified ao3rdr.crx
Binary file not shown.
Binary file modified ao3rdr.xpi
Binary file not shown.
1 change: 0 additions & 1 deletion data/settings/articles-table-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ function datadumper(request){
$('#help-message-box').css("display", 'block');
};
loadTable(tableData);
addEditDropdown();
break;
case 'exportdata':
onExportComplete(request.data);
Expand Down
148 changes: 0 additions & 148 deletions data/settings/articles-table-lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,6 @@ function generateUnreadImage(data, size){
return img;
}

function generateTableCheckbox(data){

function checkboxToggle(){
var row = $(this).closest('tr');
$(row).toggleClass('selected');
var checkbox = $(row).find('input[type="checkbox"]');
}

var inp = document.createElement("input");
inp.setAttribute('name', "id[]");
inp.setAttribute("value", data['ao3id']);
inp.setAttribute("type", "checkbox");
$(inp).click(checkboxToggle);
var html = document.createElement("td");
html.appendChild(inp);
return html;
}

// TODO: merge these
function generateImageHtml(data){
var img = generateStarImage(data, 30);
Expand Down Expand Up @@ -84,133 +66,3 @@ function generateChaptersHtml(data){
html.appendChild(text);
return html;
}

function createModal(body, confirm_action, confirm_message){
var overlay_div = document.createElement("div");
overlay_div.setAttribute("class", "modal_overlay");

var modal_div = document.createElement("div");
modal_div.setAttribute("id", "modal_div");
modal_div.setAttribute("class", "modal box four columns");
if (typeof body == "string"){
var append_me = document.createElement("p");
$(append_me).text(body);
modal_div.appendChild(append_me);
} else {
modal_div.appendChild(body);
}

var confirm_button = document.createElement("input");
confirm_button.setAttribute("class", "button-primary");
confirm_button.setAttribute("type", "button");
confirm_button.setAttribute("value", confirm_message);

var cancel_button = document.createElement("input");
cancel_button.setAttribute("class", "button-secondary");
cancel_button.setAttribute("type", "button");
cancel_button.setAttribute("value", "Cancel");

function close_modal(){
$($(this).parent('div.modal')).parent('div.modal_overlay').remove();
}
$(cancel_button).click(close_modal);
//$(overlay_div).click(close_modal);


var confirm_close = (function(confirm_action){
return function() {
confirm_action();
$($(this).parent('div.modal')).parent('div.modal_overlay').remove();
};
})(confirm_action);

$(confirm_button).click(confirm_close);

modal_div.appendChild(confirm_button);
modal_div.appendChild(cancel_button);
overlay_div.appendChild(modal_div);
document.body.appendChild(overlay_div);
}


function addEditDropdown(){
var ddData = [
{
text: "Awesome",
value: 5,
selected: false,
imageSrc: images['star-5-fill']
},
{
text: "Good",
value: 3,
selected: false,
imageSrc: images['star-3-fill']
},
{
text: "Meh",
value: 1,
selected: false,
imageSrc: images['star-1-fill']
},
{
text: "Dislike",
value: -1,
selected: false,
imageSrc: images['dislike-fill']
},
{
text: "Delete",
value: "delete",
selected: false,
imageSrc: images['delete-fill']
},
];

var dds = document.createElement("div");
dds.setAttribute("id", "ddslick-edit-works");

$('#articlesTable_wrapper').prepend(dds);

// Add the interactive dropdown
$('#ddslick-edit-works').ddslick({
data: ddData,
width: 150,
selectText: "Edit Selected",
onSelected: function (data) {
var run_me = (function(update_value){ return function(){updateWorks(update_value)} })(data.selectedData.value);
createModal(generateModalDialogue(data.selectedData),run_me, 'Confirm');
}
});
}

function updateWorks(update_value){
var update_data = {};
if (update_value == "delete"){
update_data['deleted'] = true;
} else {
update_data['rating'] = update_value;
}
$( $('#articlesTable').find('input:checked') ).each(function( index ) {
var ao3id = $( this ).attr('value');
emitWorkEdit(ao3id, update_data);
});
}

function generateModalDialogue(selectedData){
var selected = $('#articlesTable').find('input:checked');
if (selected.length == 0){
return "No works selected!";
}
var p = document.createElement("p");
var img = generateStarImage({'rating': selectedData.value}, 25);

var text = "Change "+ selected.length + " to " + selectedData.text + "(";
if (selectedData.value == "delete"){
var text = "Delete " + selected.length + " works (";
}
$(p).text(text);
$(p).append(img);
$(p).append(")?");
return p;
}
Loading

0 comments on commit fd88759

Please sign in to comment.