This commit is contained in:
j 2014-05-14 11:57:11 +02:00
commit d385853186
48 changed files with 1344 additions and 488 deletions

View file

@ -9,6 +9,10 @@ oml.UI = (function() {
return value.replace(/\./g, '\\.');
};
that.getPrevious = function(key) {
return !key ? previousUI : previousUI[key];
};
that.reset = function() {
var ui = oml.user.ui;
oml.api.resetUI({}, function() {

View file

@ -4,48 +4,48 @@ oml.ui.appDialog = function() {
var ui = oml.user.ui,
tabs = Ox.getObjectById(oml.config.pages, 'app').parts.map(function(tab) {
return {
id: tab.id,
title: tab.title.replace(/ Open Media Library$/, ''),
selected: tab.id == ui.part.app
};
}),
tabs = Ox.getObjectById(oml.config.pages, 'app').parts.map(function(tab) {
return {
id: tab.id,
title: tab.title.replace(/ Open Media Library$/, ''),
selected: tab.id == ui.part.app
};
}),
$panel = Ox.TabPanel({
content: function(id) {
var $logo = Ox.Element(),
$text = Ox.Element()
.addClass('OxTextPage'),
title = Ox.getObjectById(
Ox.getObjectById(oml.config.pages, 'app').parts,
id
).title;
$('<img>')
$panel = Ox.TabPanel({
content: function(id) {
var $logo = Ox.Element(),
$text = Ox.Element()
.addClass('OxTextPage'),
title = Ox.getObjectById(
Ox.getObjectById(oml.config.pages, 'app').parts,
id
).title;
$('<img>')
.attr({
src: '/static/png/oml.png'
})
.css({
position: 'absolute',
left: '16px',
top: '16px',
position: 'absolute',
left: '16px',
top: '16px',
width: '192px',
height: '192px'
})
.appendTo($logo);
$('<div>')
.css({
position: 'absolute',
left: '16px',
right: '24px',
top: '24px',
overflowY: 'auto'
})
.html(
'<h1><b>' + title + '</b></h1>'
+ '<p>The lazy brown fox jumped over the lazy black fox, but otherwise not really much happened here since you last checked.'
)
.appendTo($text);
.css({
position: 'absolute',
left: '16px',
right: '24px',
top: '24px',
overflowY: 'auto'
})
.html(
'<h1><b>' + title + '</b></h1>'
+ '<p>The lazy brown fox jumped over the lazy black fox, but otherwise not really much happened here since you last checked.'
)
.appendTo($text);
return Ox.SplitPanel({
elements: [
{
@ -58,14 +58,14 @@ oml.ui.appDialog = function() {
],
orientation: 'horizontal'
});
},
tabs: tabs
})
.bindEvent({
change: function(data) {
},
tabs: tabs
})
.bindEvent({
change: function(data) {
oml.UI.set({'part.app': data.selected});
}
}),
}
}),
that = Ox.Dialog({
buttons: [
@ -87,7 +87,7 @@ oml.ui.appDialog = function() {
width: 768
})
.bindEvent({
close: function() {
close: function() {
if (ui.page == 'app') {
oml.UI.set({page: ''});
}
@ -100,7 +100,7 @@ oml.ui.appDialog = function() {
});
that.update = function(section) {
$panel.selectTab(section);
$panel.selectTab(section);
};
return that;

View file

@ -19,17 +19,18 @@ oml.ui.deleteListDialog = function() {
oml.api.removeList({
id: ui._list
}, function() {
oml.UI.set({
find: {
conditions: [{
key: 'list',
operator: '==',
value: ':'
}],
operator: '&'
}
oml.updateLists(function() {
oml.UI.set({
find: {
conditions: [{
key: 'list',
operator: '==',
value: ':'
}],
operator: '&'
}
});
});
oml.updateLists();
});
});

View file

@ -133,12 +133,8 @@ oml.ui.filter = function(id) {
},
sort: function(data) {
var filters = Ox.clone(ui.filters, true);
filters[filterIndex].sort = [Ox.clone(data)];
filters[filterIndex].sort = [{key: data.key, operator: data.operator}];
oml.UI.set({filters: filters});
},
oml_find: function() {
Ox.print('%%%%', 'RELOADING FILTER')
that.reloadList(true);
}
}),

View file

@ -56,6 +56,33 @@ oml.ui.filtersOuterPanel = function() {
});
oml.updateFilterMenus();
}
},
oml_find: function() {
var previousUI = oml.UI.getPrevious();
Ox.print('WTF', ui, oml.user.ui, Object.keys(ui), Object.keys(previousUI));
ui._filterState.forEach(function(data, index) {
if (!Ox.isEqual(data.selected, previousUI._filterState[index].selected)) {
oml.$ui.filters[index].options(
ui.showFilters ? {
selected: data.selected
} : {
_selected: data.selected,
selected: []
}
);
}
if (!Ox.isEqual(data.find, previousUI._filterState[index].find)) {
Ox.print('::::', index, 'UNEQUAL', data.find, previousUI._filterState[index].find)
if (!ui.showFilters) {
oml.$ui.filters[index].options({
_selected: data.selected
});
}
// we can call reloadList here, since the items function
// handles the hidden filters case without making requests
oml.$ui.filters[index].reloadList();
}
});
}
});

56
static/js/findDialog.js Normal file
View file

@ -0,0 +1,56 @@
'use strict';
oml.ui.findDialog = function() {
var ui = oml.user.ui,
that = Ox.Dialog({
buttons: [
Ox.Button({
id: 'done',
title: Ox._('Done')
})
.bindEvent({
click: function() {
var list = oml.$ui.findForm.getList();
if (list.save) {
oml.addList({
name: list.name,
query: list.query
});
}
that.close()
}
})
],
closeButton: true,
content: oml.$ui.findForm = oml.ui.findForm()
.css({margin: '16px'}),
fixedSize: true,
height: 264,
removeOnClose: true,
title: Ox._('Advanced Find'),
width: 648 + Ox.UI.SCROLLBAR_SIZE
}),
$updateCheckbox = Ox.Checkbox({
title: Ox._('Update Results in the Background'),
value: oml.user.ui.updateAdvancedFindResults
})
.css({
float: 'left',
margin: '4px'
})
.bindEvent({
change: function(data) {
oml.UI.set({updateAdvancedFindResults: data.value});
//data.value && oml.$ui.findForm.updateResults();
}
});
$($updateCheckbox.find('.OxButton')[0]).css({margin: 0});
$(that.find('.OxBar')[1]).append($updateCheckbox);
return that;
};

View file

@ -36,12 +36,17 @@ oml.ui.findElement = function() {
})
.bindEvent({
change: function(data) {
var menu = 'findMenu_finditems_' + data.value,
previousMenu = 'findMenu_finditems_' + previousFindKey;
oml.$ui.mainMenu.checkItem(menu);
oml.$ui.mainMenu.setItemKeyboard(previousMenu, '');
oml.$ui.mainMenu.setItemKeyboard(menu, 'control f');
if (data.value == 'advanced') {
oml.$ui.mainMenu.checkItem('findMenu_find_' + previousFindKey);
// FIXME: control f when advanced
that.updateElement();
oml.$ui.filterDialog = oml.ui.filterDialog().open();
oml.$ui.findDialog = oml.ui.findDialog().open();
} else {
oml.$ui.mainMenu.checkItem('findMenu_find_' + data.value);
oml.$ui.findInput.options({
autocomplete: getAutocomplete(),
placeholder: ''
@ -77,7 +82,7 @@ oml.ui.findElement = function() {
hasPressedClear = false;
}
oml.$ui.findInput.blurInput();
oml.$ui.filterDialog = oml.ui.filterDialog().open();
oml.$ui.findDialog = oml.ui.findDialog().open();
}
},
submit: function(data) {

67
static/js/findForm.js Normal file
View file

@ -0,0 +1,67 @@
'use strict';
oml.ui.findForm = function(list) {
//Ox.print('FIND FORM LIST QUERY', list.query);
var ui = oml.user.ui,
that = Ox.Element(),
$filter = Ox.Filter({
findKeys: oml.config.itemKeys.map(function(key) {
return Ox.extend({}, key, {
title: Ox._(key.title),
type: key.id == 'mediastate' ? 'item' : key.type
});
}).concat([{
id: 'list',
title: Ox._('List'),
type: 'item',
values: ui._lists.filter(function(list) {
return list.type != 'smart'
}).map(function(list) {
return {id: list.id, title: list.title};
})
}]),
list: list ? null : {
sort: ui.listSort,
view: ui.listView
},
sortKeys: oml.config.sortKeys,
value: Ox.clone(list ? list.query : ui.find, true),
viewKeys: oml.config.listViews
})
.bindEvent({
change: function(data) {
(list ? oml.api.editList : Ox.noop)(list ? {
id: list.id,
query: data.value
} : {}, function(result) {
if (ui.updateAdvancedFindResults) {
updateResults();
}
});
}
})
.appendTo(that);
function updateResults() {
if (list) {
Ox.Request.clearCache(list.id);
oml.$ui.list.reloadList();
oml.$ui.filters.forEach(function($filter) {
$filter.reloadList();
});
} else {
oml.UI.set({find: Ox.clone($filter.options('value'), true)});
oml.$ui.findElement.updateElement();
}
}
that.getList = $filter.getList;
that.value = $filter.value;
return that;
};

View file

@ -33,9 +33,6 @@ oml.ui.folders = function() {
oml.api.find({query: getFind()}, function(result) {
oml.$ui.librariesList.value('', 'items', result.data.items);
});
},
open: function() {
},
select: function() {
oml.UI.set({find: getFind('')});
@ -148,9 +145,6 @@ oml.ui.folders = function() {
);
});
},
open: function() {
oml.$ui.listDialog = oml.ui.listDialog().open();
},
select: function(data) {
oml.UI.set({find: getFind(data.ids[0])});
},
@ -206,7 +200,7 @@ oml.ui.folders = function() {
});
},
open: function() {
oml.ui.listDialog().open();
!index && oml.ui.listDialog().open();
},
select: function(data) {
oml.UI.set({find: getFind(data.ids[0])});

191
static/js/identifyDialog.js Normal file
View file

@ -0,0 +1,191 @@
'use strict';
oml.ui.identifyDialog = function(data) {
var ui = oml.user.ui,
ids = [
'isbn10', 'isbn13', 'asin', 'lccn', 'oclc', 'olid'
].map(function(id) {
return {
id: id,
title: Ox._(Ox.getObjectById(oml.config.itemKeys, id).title)
};
}),
keys = [
'title', 'author', 'publisher', 'date'
].map(function(id) {
return {
id: id,
title: Ox._(Ox.getObjectById(oml.config.itemKeys, id).title)
};
}),
$input = Ox.FormElementGroup({
elements: [
Ox.Select({
items: ids,
overlap: 'right',
value: 'isbn10',
width: 128
}),
Ox.Input({
value: data['isbn10'] || '',
width: 610
})
]
})
.css({margin: '16px'}),
$preview = Ox.Element(),
$idPanel = Ox.SplitPanel({
elements: [
{element: Ox.Element().append($input), size: 48},
{element: $preview}
],
orientation: 'vertical'
}),
$form = Ox.Form({
items: keys.map(function(key) {
return Ox.Input({
id: key.id,
labelWidth: 128,
label: key.title,
value: key == 'author'
? (data[key.id] || []).join(', ')
: data[key.id],
width: 736
});
})
})
.css({padding: '16px'})
.bindEvent({
change: function(data) {
Ox.print('FORM CHANGE', data);
}
}),
$list = Ox.TableList({
columns: [
{
id: 'index'
},
{
id: 'title',
visible: true,
width: 288,
},
{
id: 'author',
visible: true,
width: 224
},
{
id: 'publisher',
visible: true,
width: 160
},
{
id: 'date',
visible: true,
width: 96
}
],
items: [],
max: 1,
sort: [{key: 'index', operator: '+'}],
unique: 'index'
})
.bindEvent({
select: function(data) {
$that.options('buttons')[1].options({
disabled: data.ids.length == 0
});
}
}),
$titlePanel = Ox.SplitPanel({
elements: [
{element: Ox.Element().append($form), size: 120},
{element: $list}
],
orientation: 'vertical'
}),
$bar = Ox.Bar({size: 24}),
$buttons = Ox.ButtonGroup({
buttons: [
{id: 'id', title: Ox._('Look Up by ID')},
{id: 'title', title: Ox._('Find by Title')}
],
selectable: true,
selected: 'id'
})
.css({
width: '768px',
padding: '4px 0',
textAlign: 'center'
})
.bindEvent({
change: function(data) {
$innerPanel.options({selected: data.value});
}
})
.appendTo($bar),
$innerPanel = Ox.SlidePanel({
elements: [
{id: 'id', element: $idPanel},
{id: 'title', element: $titlePanel}
],
orientation: 'horizontal',
selected: 'id',
size: 768
}),
$outerPanel = Ox.SplitPanel({
elements: [
{element: $bar, size: 24},
{element: $innerPanel}
],
orientation: 'vertical'
}),
that = Ox.Dialog({
buttons: [
Ox.Button({
id: 'dontupdate',
title: Ox._('No, Don\'t Update')
})
.bindEvent({
click: function() {
that.close();
}
}),
Ox.Button({
disabled: true,
id: 'update',
title: Ox._('Yes, Update')
})
.bindEvent({
click: function() {
Ox.print('NOT IMPLEMENTED');
that.close();
}
})
],
closeButton: true,
content: $outerPanel,
fixedSize: true,
height: 384,
title: Ox._('Identify Book'),
width: 768
});
return that;
};

View file

@ -20,45 +20,6 @@ oml.ui.infoView = function() {
}
}),
$identifyPanel = Ox.SplitPanel({
elements: [
{element: Ox.Element(), size: 120},
{element: Ox.Element()}
],
orientation: 'vertical'
}),
$identifyDialog = Ox.Dialog({
buttons: [
Ox.Button({
id: 'dontupdate',
title: Ox._('No, Don\'t Update')
})
.bindEvent({
click: function() {
$identifyDialog.close();
}
}),
Ox.Button({
disabled: true,
id: 'update',
title: Ox._('Yes, Update')
})
.bindEvent({
click: function() {
$identifyDialog.close();
}
})
],
closeButton: true,
content: $identifyPanel,
fixedSize: true,
height: 384,
//removeOnClose: true,
title: Ox._('Identify Book'),
width: 768
}),
$cover = Ox.Element()
.css({
position: 'absolute',
@ -88,71 +49,27 @@ oml.ui.infoView = function() {
})
.appendTo(that);
function formatLight(str) {
return '<span class="OxLight">' + str + '</span>';
}
function formatValue(value, key) {
return (Ox.isArray(value) ? value : [value]).map(function(value) {
return key ?
'<a href="/' + key + '==' + value + '">' + value + '</a>'
: value;
}).join(', ');
}
function identify(data) {
var $form = Ox.Form({
items: [
'title', 'author', 'publisher', 'date'
].map(function(key) {
return Ox.Input({
id: key,
labelWidth: 128,
label: Ox.getObjectById(oml.config.itemKeys, key).title,
value: key == 'author' ? (data[key] || []).join(', ') : data[key],
width: 736
});
})
})
.css({padding: '16px'})
.bindEvent({
change: function(data) {
Ox.print('FORM CHANGE', data);
}
}),
$list = Ox.TableList({
columns: [
{
id: 'index'
},
{
id: 'title',
visible: true,
width: 288,
},
{
id: 'author',
visible: true,
width: 224
},
{
id: 'publisher',
visible: true,
width: 160
},
{
id: 'date',
visible: true,
width: 96
}
],
items: [],
max: 1,
sort: [{key: 'index', operator: '+'}],
unique: 'index'
})
.bindEvent({
select: function(data) {
$identifyDialog.options('buttons')[1].options({
disabled: data.ids.length == 0
});
}
});
$identifyPanel.replaceElement(0, $form);
$identifyPanel.replaceElement(1, $list);
oml.ui.identifyDialog(data).open();
return;
$identifyPanel.select('id');
$identifyDialog.open();
identify(data);
function identify(data) {
oml.api.identify(data, function(result) {
$list.options({
$identifyList.options({
items: result.data.items.map(function(item, index) {
return Ox.extend(item, {index: index});
})
@ -162,7 +79,38 @@ oml.ui.infoView = function() {
}
function renderMediaButton(data) {
return data.mediastate == 'unavailable'
function getListItems() {
var items = [];
if (ui._lists) {
items = ui._lists.filter(function(list) {
return list.user == oml.user.preferences.username
&& list.type != 'smart';
}).map(function(list) {
return {
id: list.id,
title: Ox._('Download to {0}', [list.name])
};
});
items.splice(1, 0, [{}]);
}
return items;
}
function setListItems() {
if ($element && ui._lists) {
$element.options({
disabled: false
}).options('elements')[1].options({
items: getListItems()
});
} else {
setTimeout(setListItems, 100);
}
}
if (data.mediastate == 'unavailable' && !ui._lists) {
setListItems();
}
var $element = data.mediastate == 'unavailable'
? Ox.FormElementGroup({
elements: [
Ox.Button({
@ -179,17 +127,24 @@ oml.ui.infoView = function() {
}
}),
Ox.MenuButton({
items: [
{id: '', title: Ox._('Library')}
],
disabled: !ui._lists,
items: getListItems(),
overlap: 'left',
title: 'list',
tooltip: Ox._('Download Book to a List'),
type: 'image'
})
.bindEvent({
click: function() {
// ...
click: function(data) {
data.mediastate = 'transferring';
that.update(data, $data);
oml.api.download(Ox.extend({
id: ui.item,
}, data.id == ':' ? {} : {
list: data.id.slice(1)
}), function(result) {
// ...
});
}
})
],
@ -234,12 +189,13 @@ oml.ui.infoView = function() {
oml.UI.set({itemView: 'book'});
}
});
return $element;
}
that.update = function(idOrData, $elements) {
var data = Ox.isObject(idOrData) ? idOrData : null,
id = data ? null : idOrData;
id = data ? null : idOrData,
$elements = $elements
? Ox.makeArray($elements)
@ -256,6 +212,7 @@ oml.ui.infoView = function() {
Ox.print('BOOK DATA', data)
var $reflection, $mediaButton,
isEditable = !data.mainid && data.mediastate == 'available',
ratio = data.coverRatio || 0.75,
size = 256,
width = Math.round(ratio >= 1 ? size : size * ratio),
@ -312,22 +269,47 @@ oml.ui.infoView = function() {
} else if ($element == $info) {
$('<div>')
.css({
marginTop: '-4px',
fontSize: '13px',
fontWeight: 'bold'
})
.text(data.title || '')
.css({marginTop: '-2px'})
.append(
Ox.EditableContent({
clickLink: oml.clickLink,
editable: isEditable,
tooltip: isEditable ? oml.getEditTooltip() : '',
value: data.title
})
.css({
fontSize: '13px',
fontWeight: 'bold'
})
)
.appendTo($info);
$('<div>')
.css({
marginTop: '4px',
fontSize: '13px',
fontWeight: 'bold'
})
.text((data.author || []).join(', '))
.appendTo($info);
if (data.author || isEditable) {
$('<div>')
.css({
marginTop: '4px',
fontSize: '13px',
fontWeight: 'bold'
})
.append(
Ox.EditableContent({
clickLink: oml.clickLink,
editable: isEditable,
format: function(value) {
return formatValue(value.split(', '), 'author');
},
placeholder: formatLight(Ox._('Unknown Author')),
tooltip: isEditable ? oml.getEditTooltip() : '',
value: data.author ? data.author.join(', ') : ''
})
.css({
fontSize: '13px',
fontWeight: 'bold'
})
)
.appendTo($info);
}
$('<div>')
.css({
@ -342,17 +324,16 @@ oml.ui.infoView = function() {
)
.appendTo($info);
$('<div>')
.css({
marginTop: '8px',
textAlign: 'justify'
})
.html(
data.description
? Ox.encodeHTMLEntities(data.description)
: '<span class="OxLight">No description</span>'
)
.appendTo($info);
if (data.description) {
$('<div>')
.css({
marginTop: '8px',
textAlign: 'justify'
})
.html(Ox.encodeHTMLEntities(data.description))
.appendTo($info);
}
} else if ($element == $data) {
@ -362,7 +343,7 @@ oml.ui.infoView = function() {
$('<div>')
.addClass('OxSelectable')
.css({
marginTop: '8px',
marginTop: '10px',
})
.text(
[
@ -383,39 +364,31 @@ oml.ui.infoView = function() {
})
.text(title)
.appendTo($data);
Ox.EditableContent({
editable: false,
format: function(value) {
return value ? Ox.formatDate(value, '%b %e, %Y') : '';
},
placeholder: Ox._('unknown'),
value: data[id] || ''
})
$('<div>')
.text(Ox.formatDate(data[id], '%b %e, %Y'))
.appendTo($data);
}
});
if (data.mediastate == 'available') {
Ox.Button({
title: Ox._('Identify Book...'),
width: 128
})
.css({marginTop: '16px'})
.bindEvent({
click: function() {
identify(data);
}
})
.appendTo($data);
[
'isbn10', 'isbn13', 'lccn', 'olid', 'oclc', 'mainid'
].forEach(function(id, index) {
var title = Ox.getObjectById(oml.config.itemKeys, id).title,
placeholder = id == 'mainid' ? 'none' : 'unknown';
Ox.Button({
disabled: data.mediastate != 'available',
title: Ox._('Identify Book...'),
width: 128
})
.css({marginTop: '16px'})
.bindEvent({
click: function() {
identify(data);
}
})
.appendTo($data);
[
'isbn10', 'isbn13', 'asin', 'lccn', 'oclc', 'olid'
].forEach(function(id, index) {
var title;
if (data[id]) {
title = Ox.getObjectById(oml.config.itemKeys, id).title;
$('<div>')
.css({
marginTop: (index == 0 ? 10 : 6) + 'px',
@ -423,28 +396,13 @@ oml.ui.infoView = function() {
})
.text(title)
.appendTo($data);
Ox.EditableContent({
editable: true,
format: function(value) {
return id == 'mainid'
? Ox.getObjectById(oml.config.itemKeys, value).title
: value;
},
placeholder: placeholder,
tooltip: Ox._('Doubleclick to edit'),
value: data[id] || ''
})
.bindEvent({
submit: function(data) {
editMetadata(id, data.value);
}
editable: false,
value: data[id]
})
.appendTo($data);
});
}
}
});
$('<div>').css({height: '16px'}).appendTo($data);

View file

@ -25,7 +25,7 @@ oml.ui.listDialog = function() {
.bindEvent({
click: function() {
that.close();
oml.deleteList();
oml.ui.deleteListDialog().open();
}
})
] : []).concat([
@ -42,7 +42,7 @@ oml.ui.listDialog = function() {
]),
closeButton: true,
content: Ox.LoadingScreen().start(),
height: 256,
height: 264,
title: Ox._('List {0}', [
ui._list == '' ? Ox._('All Libraries')
: ui._list
@ -91,8 +91,15 @@ oml.ui.listDialog = function() {
});
}
})
.appendTo($content),
$findForm;
Ox.print('DEBUG:', list, listData)
if (listData.type == 'smart') {
$findForm = oml.ui.findForm(listData)
.css({marginTop: '8px'})
.appendTo($content);
that.options({content: $content})
}
that.options({content: $content});
});
return that;

View file

@ -228,7 +228,7 @@ oml.ui.mainMenu = function() {
title: Ox._('Find'),
items: [
{
id: 'find',
id: 'finditems',
title: Ox._('Find'),
items: [
{
@ -413,6 +413,9 @@ oml.ui.mainMenu = function() {
Ox.print('MAIN MENU DOES NOT YET HANDLE', id);
}
},
key_backtick: function() {
changeFocus(1);
},
key_control_comma: function() {
if (!oml.hasDialogOrScreen()) {
oml.UI.set({page: 'preferences'});
@ -429,6 +432,35 @@ oml.ui.mainMenu = function() {
}
}
},
key_control_m: function() {
if (!oml.hasDialogOrScreen() && !that.isSelected()) {
that.options('menus')[0].element.trigger('click');
}
},
key_control_shift_w: function() {
if (!oml.hasDialogOrScreen()) {
oml.UI.set({
find: oml.config.user.ui.find,
item: ''
});
}
},
key_control_shift_z: function() {
oml.redoHistory();
},
key_control_slash: function() {
if (!oml.hasDialogOrScreen()) {
oml.UI.set({page: 'help'});
}
},
key_control_w: function() {
if (!oml.hasDialogOrScreen()) {
oml.UI.set({item: ''});
}
},
key_control_z: function() {
oml.undoHistory();
},
key_shift_b: function() {
ui.item && oml.UI.set({showBrowser: !ui.showBrowser});
},

View file

@ -73,6 +73,7 @@
? Ox['format' + Ox.toTitleCase(key.format.type)].apply(
this, [value].concat(key.format.args || [])
)
: Ox.isArray(key.type) ? value.join(', ')
: value;
}
});

View file

@ -107,7 +107,7 @@ oml.ui.preferencesDialog = function() {
},
{
id: 'resetUI',
title: 'Reset UI Settings',
title: 'Reset UI Settings...',
click: function() {
oml.$ui.resetUIDialog = oml.ui.resetUIDialog().open();
},

View file

@ -2,32 +2,21 @@
oml.ui.resetUIDialog = function(data) {
var that = oml.ui.iconDialog({
var that = oml.ui.confirmDialog({
buttons: [
Ox.Button({
id: 'cancel',
title: Ox._('Don\'t Reset')
})
.bindEvent({
click: function() {
that.close();
}
}),
title: Ox._('No, Don\'t Reset')
}),
Ox.Button({
id: 'reset',
title: Ox._('Reset')
}).bindEvent({
click: function() {
that.close();
oml.$ui.preferencesDialog.close();
oml.UI.set({page: ''});
oml.UI.reset();
}
})
title: Ox._('Yes, Reset')
})
],
content: Ox._('Are you sure you want to reset all UI settings?'),
keys: {enter: 'reset', escape: 'cancel'},
title: Ox._('Reset UI Settings')
}, function() {
oml.$ui.preferencesDialog.close();
oml.UI.set({page: ''});
oml.UI.reset();
});
return that;

View file

@ -19,9 +19,13 @@ oml.addList = function() {
name: oml.validateName(Ox._('Untitled'), listNames),
type: !isSmart ? 'static' : 'smart'
};
if (isFrom) {
if (!isSmart) {
if (!isSmart) {
if (isFrom) {
data.items = ui.listSelection;
}
} else {
if (!isFrom) {
data.query = oml.config.user.ui.find;
} else {
data.query = ui.find;
}
@ -532,6 +536,16 @@ oml.enableDragAndDrop = function($list, canMove) {
};
oml.getEditTooltip = function(title) {
return function(e) {
var $target = $(e.target);
return (
$target.is('a') || $target.parents('a').length
? Ox._('Shift+doubleclick to edit') : Ox._('Doubleclick to edit')
) + (title ? ' ' + Ox._(title) : '');
}
};
(function() {
// Note: getFindState has to run after getListState and getFilterState
@ -705,14 +719,9 @@ oml.getInfoHeight = function() {
};
oml.getListData = function(list) {
var data = {}, ui = oml.user.ui;
if (Ox.isUndefined(list)) {
list = ui._list;
}
if (ui._lists) {
data = ui._lists[list];
}
return data;
var ui = oml.user.ui;
list = Ox.isUndefined(list) ? ui._list : list;
return ui._lists ? Ox.getObjectById(ui._lists, list) : {};
};
oml.getListFoldersHeight = function() {
@ -769,25 +778,30 @@ oml.getUsersAndLists = function(callback) {
return user.peered;
})
);
users.forEach(function(user) {
lists.push({
id: (user.nickname == username ? '' : user.nickname) + ':',
name: Ox._('Library'),
type: 'library',
user: user.nickname
});
});
oml.api.getLists(function(result) {
lists = lists.concat(result.data.lists);
users.forEach(function(user) {
lists = lists.concat([{
id: (user.nickname == username ? '' : user.nickname) + ':',
name: Ox._('Library'),
type: 'library',
user: user.nickname
}].concat(
result.data.lists.filter(function(list) {
return list.user == user.nickname;
})
));
});
lists = lists.map(function(list) {
return Ox.extend(list, {
editable: list.user == username && list.type == 'static',
title: (list.user ? list.user + ': ' : '') + list.name
});
})
if (!ui.lists) {
oml.$ui.mainMenu.update();
}
ui._lists = {};
Ox.forEach(lists, function(list) {
ui._lists[list.id] = Ox.extend(list, {
editable: list.user == username && list.type == 'static',
});
});
ui._lists = lists;
Ox.print('UI._LISTS', JSON.stringify(ui._lists));
callback(users, lists);
});
})
@ -857,8 +871,8 @@ oml.updateFilterMenus = function() {
oml.updateLists = function(callback) {
// FIXME: can this go somewhere else?
Ox.Request.clearCache('getLists');
oml.api.getLists(function(result) {
var items = result.data.lists.filter(function(list) {
oml.getUsersAndLists(function(users, lists) {
var items = lists.filter(function(list) {
return list.user == oml.user.preferences.username;
});
oml.$ui.folderList[0].options({