}
h1 {
-font-size: 200%;
+font-size: 150%;
color: #000;
}
display: grid;
margin: 0 1em 1em 1em;
}
-@media (min-width: 640pt) {
+@media (min-width: 500pt) {
#page {
grid-template-columns: auto minmax(25%,20em);
grid-column-gap: 1em;
}
#sidebar {
- min-width: 15em;
}
#about, #getting-started {
padding-right: 30px;
}
+#head-list-name {
+ display: grid;
+ grid-template-columns: auto 2em;
+ grid-column-gap: 1ex;
+ min-height: 2em;
+ align-items: center;
+}
#header h1, #header h2 {margin: 0}
#header { font-weight: bold; }
opacity: 1;
padding: 0 0.5ex;
}
-.list-edit-trigger:hover {
- background: hsla(0, 0%, 80%, 1);
- border-left: 1px solid black;
+#list-edit-trigger:hover {
+ background: hsla(0, 0%, 90%, 1);
}
#busy-screen {
#new-list-item {
margin-top: 1em;
}
-span.list-edit-trigger {
- visibility: hidden;
- opacity: 0;
+#list-edit-trigger {
transition: 0.25s;
- height: 100%;
- min-width: 2em;
+ height: 2em;
+ width: 2em;
display: grid;
align-items: center;
justify-items: center;
-}
-ul#lists > li:hover span.list-edit-trigger {
- visibility: visible;
- opacity: 1;
+ border-radius: 0.75ex;
}
ul#lists > li.editing span.ui-icon-disk { display: inline-block; }
+ul#list-items {
+ padding: 0;
+}
+
.ui-widget-overlay {
opacity: 0.3;
}
selected_list = new_selected_list;
}
-function edit_list(li) {
- li.addClass('editing');
-
+function edit_list() {
var d = $('<div>')
.append(
$('<fieldset>')
.append(
$('<legend>').text('List name'),
- $('<input type="text" size="40">').val(li.data('lsl-name'))
+ $('<input type="text" size="40">')
+ .val(selected_list.data('lsl-name'))
)
);
autoOpen: true,
modal: true,
title: 'Edit list',
- close: ()=>{
- li.removeClass('editing');
- },
width: 'max-content',
buttons: [
{
icon: 'ui-icon-trash',
text: 'Delete',
click: () => {
- delete_list(li, d);
+ delete_list(d);
},
},
{
icon: 'ui-icon-disk',
text: 'OK',
click: () => {
- save_list(li, d);
+ save_list(d);
},
},
],
});
}
-function delete_list(li, dlg) {
- // TODO: fetch all list items and store all data in a "Deleted"
+function delete_list(dlg) {
+ // TODO: store all data including list items in a "Deleted"
// pop-up with an "Undo" link that can be used to restore the list
var lists_ver = lists_version;
- $.ajax( li.data('lsl-uri'),
+ $.ajax( selected_list.data('lsl-uri'),
{ type: 'DELETE' }
)
.done((d)=>{
lists_version = lists_ver + 1;
- if (li.hasClass('selected')) {
- var new_selected = li.next();
+ var deleted_list = selected_list;
+
+ var new_selected = deleted_list.next();
+ if (new_selected.length) {
+ select_list(new_selected)
+ }
+ else {
+ new_selected = deleted_list.prev();
if (new_selected.length) {
- select_list(new_selected)
+ select_list(new_selected);
}
else {
- new_selected = li.prev();
- if (new_selected.length) {
- select_list(new_selected);
- }
- else {
- $('#page').removeClass('have-lists');
- }
+ $('#page').removeClass('have-lists');
}
}
- li.remove();
+ deleted_list.remove();
+ dlg.dialog('destroy');
+ got_lists_version(d.lists_version);
+ });
dlg.dialog('destroy');
got_lists_version(d.lists_version);
});
.append(
$('<span class="list-name">')
.text(list.name)
- )
- .append(
- $('<span class="list-edit-trigger">')
- .append('<span class="ui-icon ui-icon-pencil">')
);
lists.append(list_item);
}
return true;
});
- $('ul#lists')
+ $('#lists')
.on('click', 'li', ev=>{
select_list($(ev.target).closest('li'));
- })
- .on('click', 'li > span.list-edit-trigger', ev => {
- edit_list($(ev.target).closest('li'));
- return false;
});
+ $('#list-edit-trigger').on('click', ev => {
+ edit_list();
+ return false;
+ });
$('#new-list-item button').on('click', handle_new_list_item_submission);
$('#new-list-item input').on('keypress', ev => {
if (13 == ev.keyCode) {
<div id="page" class="loading-lists" lsl-uri-base="<% request.uri_base %>" lsl-environment="<% settings.environment %>" >
<div id="content">
<div id="header">
- <h1 id="selected-list-name" class="needs-lists"></h1>
+ <div id="head-list-name" class="needs-lists">
+ <span id="selected-list-name"></span>
+ <span id="list-edit-trigger">
+ <span class="ui-icon ui-icon-pencil"></span>
+ </span>
+ </div>
<div class="have-no-lists">
<div class="table-2-col">
<h1>First create a shopping list</h1><div class="arrow">→</div>
The list has no items
</div>
<div id="new-list-item" class="input-with-button">
- <input type="text" size="15" maxlength="80" name="new_list_item" />
+ <input type="text" size="10" axlength="80" name="new_list_item" />
<button id="add-list-item" class="ui-icon-plusthick">Add</button>
</div>
</div>