fulltext search in pages
This commit is contained in:
parent
cc2b60453b
commit
950bec609d
13 changed files with 608 additions and 22 deletions
|
|
@ -399,13 +399,14 @@ pandora.URL = (function() {
|
|||
|
||||
// Documents
|
||||
views['documents'] = {
|
||||
list: ['grid', 'list'],
|
||||
list: ['grid', 'list', 'pages'],
|
||||
item: ['view', 'info']
|
||||
};
|
||||
sortKeys['documents'] = {
|
||||
list: {
|
||||
list: pandora.site.documentKeys,
|
||||
grid: pandora.site.documentKeys
|
||||
grid: pandora.site.documentKeys,
|
||||
pages: pandora.site.documentKeys
|
||||
},
|
||||
item: {}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -124,6 +124,67 @@ pandora.ui.collection = function() {
|
|||
unique: 'id'
|
||||
})
|
||||
.addClass('OxMedia');
|
||||
} else if (view == 'pages') {
|
||||
that = Ox.InfoList({
|
||||
borderRadius: 0,
|
||||
defaultRatio: 640/1024,
|
||||
draggable: true,
|
||||
id: 'list',
|
||||
item: function(data, sort, size) {
|
||||
size = 128;
|
||||
var sortKey = sort[0].key,
|
||||
infoKey = sortKey == 'title' ? 'extension' : sortKey,
|
||||
key = Ox.getObjectById(pandora.site.documentKeys, infoKey),
|
||||
info = pandora.formatDocumentKey(key, data, size);
|
||||
return {
|
||||
icon: {
|
||||
height: Math.round(data.ratio > 1 ? size / data.ratio : size),
|
||||
id: data.id,
|
||||
info: info,
|
||||
title: data.title,
|
||||
url: pandora.getMediaURL('/documents/' + data.id + '/256p.jpg?' + data.modified),
|
||||
width: Math.round(data.ratio >= 1 ? size : size * data.ratio)
|
||||
},
|
||||
info: {
|
||||
css: {marginTop: '2px'},
|
||||
element: pandora.ui.documentPages,
|
||||
id: data.id,
|
||||
options: {
|
||||
id: data.id,
|
||||
pages: data.pages,
|
||||
query: ui.findDocuments,
|
||||
ratio: data.ratio
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
items: function(data, callback) {
|
||||
pandora.api.findDocuments(Ox.extend(data, {
|
||||
query: ui.findDocuments
|
||||
}), callback);
|
||||
return Ox.clone(data, true);
|
||||
},
|
||||
keys: ['id', 'pages', 'title', 'ratio', 'modified'],
|
||||
selected: ui.listSelection,
|
||||
size: 192,
|
||||
sort: ui.collectionSort.concat([
|
||||
{key: 'extension', operator: '+'},
|
||||
{key: 'title', operator: '+'}
|
||||
]),
|
||||
unique: 'id',
|
||||
width: window.innerWidth
|
||||
- ui.showSidebar * ui.sidebarSize - 1
|
||||
- Ox.UI.SCROLLBAR_SIZE
|
||||
})
|
||||
.addClass('OxMedia')
|
||||
.bindEvent({
|
||||
key_left: function() {
|
||||
// ...
|
||||
},
|
||||
key_right: function() {
|
||||
// ...
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (['list', 'grid'].indexOf(view) > -1) {
|
||||
|
|
@ -138,7 +199,7 @@ pandora.ui.collection = function() {
|
|||
});
|
||||
}
|
||||
|
||||
if (['list', 'grid'].indexOf(view) > -1) {
|
||||
if (['list', 'grid', 'pages'].indexOf(view) > -1) {
|
||||
|
||||
//fixme
|
||||
|
||||
|
|
|
|||
106
static/js/documentPages.js
Normal file
106
static/js/documentPages.js
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
'use strict';
|
||||
|
||||
pandora.ui.documentPages = function(options) {
|
||||
|
||||
var self = {},
|
||||
that = Ox.Element()
|
||||
.css({
|
||||
height: '192px',
|
||||
margin: '4px',
|
||||
display: 'flex'
|
||||
})
|
||||
.bindEvent({
|
||||
doubleclick: doubleclick,
|
||||
singleclick: singleclick
|
||||
});
|
||||
|
||||
self.options = Ox.extend({
|
||||
id: '',
|
||||
pages: 1,
|
||||
query: null,
|
||||
ratio: 8/5
|
||||
}, options);
|
||||
|
||||
self.size = 128;
|
||||
self.width = self.options.ratio > 1 ? self.size : Math.round(self.size * self.options.ratio);
|
||||
self.height = self.options.ratio > 1 ? Math.round(self.size / self.options.ratio) : self.size;
|
||||
|
||||
function renderPage(page) {
|
||||
var url = `/documents/${self.options.id}/${self.size}p${page}.jpg`
|
||||
var $item = Ox.IconItem({
|
||||
imageHeight: self.height,
|
||||
imageWidth: self.width,
|
||||
id: `${self.options.id}/${page}`,
|
||||
info: '',
|
||||
title: `Page ${page}`,
|
||||
url: url
|
||||
})
|
||||
.addClass('OxInfoIcon')
|
||||
.css({
|
||||
})
|
||||
.data({
|
||||
page: page
|
||||
});
|
||||
$item.find('.OxTarget').addClass('OxSpecialTarget');
|
||||
that.append($item);
|
||||
}
|
||||
|
||||
function renderPages(pages) {
|
||||
console.log('renderPages', pages, self.options.pages)
|
||||
if (pages) {
|
||||
console.log('renderPages', pages)
|
||||
pages.forEach(page => {
|
||||
renderPage(page.page)
|
||||
})
|
||||
} else {
|
||||
if (self.options.pages > 1) {
|
||||
Ox.range(Ox.min([self.options.pages, 5])).forEach(page => { renderPage(page + 2) })
|
||||
}
|
||||
}
|
||||
}
|
||||
var query
|
||||
if (self.options.query) {
|
||||
var condition = self.options.query.conditions.filter(condition => {
|
||||
return condition.key == 'fulltext'
|
||||
})
|
||||
if (condition.length) {
|
||||
query = {
|
||||
'conditions': [
|
||||
{'key': 'document', 'operator': '==', 'value': self.options.id},
|
||||
{'key': 'fulltext', 'operator': '=', 'value': condition[0].value}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
if (query) {
|
||||
pandora.api.findPages({
|
||||
query: query,
|
||||
range: [0, 100],
|
||||
keys: ['page']
|
||||
}, function(result) {
|
||||
renderPages(result.data.items)
|
||||
})
|
||||
} else {
|
||||
renderPages()
|
||||
}
|
||||
|
||||
function doubleclick(data) {
|
||||
var $item, $target = $(data.target), annotation, item, points, set;
|
||||
if ($target.parent().parent().is('.OxSpecialTarget')) {
|
||||
$target = $target.parent().parent();
|
||||
}
|
||||
if ($target.is('.OxSpecialTarget')) {
|
||||
$item = $target.parent().parent();
|
||||
var page = $item.data('page')
|
||||
pandora.URL.push(`/documents/${self.options.id}/${page}`);
|
||||
}
|
||||
}
|
||||
|
||||
function singleclick(data) {
|
||||
// ..
|
||||
}
|
||||
|
||||
return that;
|
||||
|
||||
};
|
||||
|
||||
|
|
@ -64,10 +64,7 @@ pandora.ui.documentSortSelect = function() {
|
|||
pandora.ui.documentViewSelect = function() {
|
||||
var ui = pandora.user.ui,
|
||||
that = Ox.Select({
|
||||
items: [
|
||||
{id: 'list', title: Ox._('View as List')},
|
||||
{id: 'grid', title: Ox._('View as Grid')}
|
||||
],
|
||||
items: pandora.site.collectionViews,
|
||||
value: ui.documentsView,
|
||||
width: 128
|
||||
})
|
||||
|
|
|
|||
|
|
@ -995,7 +995,7 @@ pandora.ui.mainMenu = function() {
|
|||
if (ui.document && i < 2) {
|
||||
pandora.UI.set({documentView: ['info', 'view'][i]});
|
||||
} else if (i < 2) {
|
||||
pandora.UI.set({collectionView: ['list', 'grid'][i]});
|
||||
pandora.UI.set({collectionView: ['list', 'grid', 'pages'][i]});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -1498,7 +1498,7 @@ pandora.ui.mainMenu = function() {
|
|||
return [
|
||||
{ id: 'documents', title: Ox._('View Documents'), items: [
|
||||
{ group: 'collectionview', min: 1, max: 1, items: pandora.site.listViews.filter(function(view) {
|
||||
return Ox.contains(['list', 'grid'], view.id)
|
||||
return Ox.contains(['list', 'grid', 'pages'], view.id)
|
||||
}).map(function(view) {
|
||||
return Ox.extend({
|
||||
checked: ui.collectionView == view.id
|
||||
|
|
|
|||
|
|
@ -419,11 +419,13 @@ appPanel
|
|||
]
|
||||
},
|
||||
sortKeys: pandora.getSortKeys(),
|
||||
documentSortKeys: pandora.getDocumentSortKeys(),
|
||||
collectionViews: [
|
||||
{id: 'list', title: Ox._('View as List')},
|
||||
{id: 'grid', title: Ox._('View as Grid')}
|
||||
]
|
||||
documentSortKeys: pandora.getDocumentSortKeys()
|
||||
});
|
||||
pandora.site.collectionViews = (pandora.site.collectionViews || [
|
||||
{id: 'list', title: 'as List'},
|
||||
{id: 'grid', title: 'as Grid'}
|
||||
]).map(view => {
|
||||
return {id: view.id, title: Ox._('View {0}', [Ox._(view.title)])};
|
||||
});
|
||||
pandora.site.listSettings = {};
|
||||
Ox.forEach(pandora.site.user.ui, function(val, key) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue