diff options
-rw-r--r-- | css/fulltextsearch.css | 15 | ||||
-rw-r--r-- | css/navigate.css | 5 | ||||
-rw-r--r-- | js/fulltextsearch.v1.js | 2 | ||||
-rw-r--r-- | js/fulltextsearch.v1.navigation.js | 146 | ||||
-rw-r--r-- | js/fulltextsearch.v1.result.js | 14 | ||||
-rw-r--r-- | js/fulltextsearch.v1.settings.js | 40 | ||||
-rw-r--r-- | js/navigate.js | 8 | ||||
-rw-r--r-- | lib/Model/Index.php | 1 |
8 files changed, 130 insertions, 101 deletions
diff --git a/css/fulltextsearch.css b/css/fulltextsearch.css index 5f7f81f..1708d24 100644 --- a/css/fulltextsearch.css +++ b/css/fulltextsearch.css @@ -62,7 +62,6 @@ input.options_small { */ .provider_result { -// font-style: italic; } .provider_navigation_right { @@ -75,7 +74,8 @@ input.options_small { } .provider_navigation_close { - margin-left: 20px; + margin: 3px 20px 3px 3px; + opacity: 0.6; } .provider_navigation_prev, .provider_navigation_curr, .provider_navigation_next, .provider_navigation_close { @@ -139,6 +139,7 @@ input.options_small { #source { color: #a5a5a5; } + .result_entry_default #info { font-weight: bold; } @@ -152,14 +153,12 @@ input.options_small { .provider_navigation { position: relative; - font-size: 15px; - font-weight: bold; + font-size: 13px; color: #898989; - padding-top: 10px; + padding-top: 13px; padding-left: 20px; - padding-bottom: 10px; - margin-top: 40px; - border-bottom: solid 1px #a1a1a1; + padding-bottom: 13px; + border-bottom: solid 1px #eaeaea; } .icon-page-prev { diff --git a/css/navigate.css b/css/navigate.css index 46df48a..a00f447 100644 --- a/css/navigate.css +++ b/css/navigate.css @@ -57,7 +57,10 @@ a.ulsub { */ #search_result { - margin: 50px 30px 0 30px; +} + +.provider_header { + margin-bottom: 35px; } .provider_result { diff --git a/js/fulltextsearch.v1.js b/js/fulltextsearch.v1.js index cda072e..6a33b13 100644 --- a/js/fulltextsearch.v1.js +++ b/js/fulltextsearch.v1.js @@ -43,7 +43,7 @@ $.extend(FullTextSearch.prototype, nav); $.extend(FullTextSearch.prototype, api); - settings.generateNoResultDiv(); +// settings.generateNoResultDiv(); }; OCA.FullTextSearch = FullTextSearch; diff --git a/js/fulltextsearch.v1.navigation.js b/js/fulltextsearch.v1.navigation.js index 4799c87..756912d 100644 --- a/js/fulltextsearch.v1.navigation.js +++ b/js/fulltextsearch.v1.navigation.js @@ -56,7 +56,6 @@ var curr = { var nav = { - manageDivProviderNavigation: function (divProviderNavigation, request, meta) { var maxPage = Math.ceil(meta.total / request.size); @@ -106,12 +105,12 @@ var nav = { for (var i = 0; i < newResult.length; i++) { var entry = newResult[i]; if (result.getResultIndex(entry.id, oldResult) > -1) { - precItem = nav.getDivResult(entry.id, divProviderResult); - nav.fillDivResult(precItem, entry); + precItem = nav.getDivEntry(entry.id, divProviderResult); + nav.fillDivEntry(precItem, entry); continue; } - var divResult = nav.generateDivResult(entry, nav.generateTemplateEntry(entry)); + var divResult = nav.generateDivEntry(entry, nav.generateTemplateEntry(entry)); if (precItem === null) { divProviderResult.prepend(divResult); } else { @@ -132,7 +131,7 @@ var nav = { for (var i = 0; i < oldResult.length; i++) { var entry = oldResult[i]; if (result.getResultIndex(entry.id, newResult) === -1) { - var divResult = nav.getDivResult(entry.id, divProviderResult); + var divResult = nav.getDivEntry(entry.id, divProviderResult); divResult.fadeTo(settings.delay_result, 0, function () { $(this).slideUp(settings.delay_result, function () { $(this).remove(); @@ -164,14 +163,14 @@ var nav = { animateMoveDivResult: function (entryId, divProviderResult, precId) { - var divResult = nav.getDivResult(entryId, divProviderResult); + var divResult = nav.getDivEntry(entryId, divProviderResult); if (precId === '') { divResult.fadeTo(settings.delay_result, 0.35, function () { $(this).prependTo(divProviderResult).fadeTo(100, 1); }); } else { - var precItem = nav.getDivResult(precId, divProviderResult); + var precItem = nav.getDivEntry(precId, divProviderResult); divResult.fadeTo(settings.delay_result, 0.35, function () { $(this).insertAfter(precItem).fadeTo(100, 1); }); @@ -197,8 +196,9 @@ var nav = { }, - getDivResult: function (resultId, divProviderResult) { + getDivEntry: function (resultId, divProviderResult) { var ret = null; + divProviderResult.children('.result_entry').each(function () { if ($(this).attr('data-id') === resultId) { ret = $(this); @@ -209,28 +209,34 @@ var nav = { }, - fillDivResult: function (divResult, entry) { - divResult.find('#title').text(entry.title); + fillDivEntry: function (divEntry, entry) { + divEntry.find('#title').text(entry.title); - divResult.find('#source').html(' '); + divEntry.find('#source').html(' '); if (entry.info.source !== '') { - divResult.find('#source').text(entry.info.source); + divEntry.find('#source').text(entry.info.source); } if (settings.options.show_hash === '1') { - divResult.find('#source').text(entry.hash); + divEntry.find('#source').text(entry.hash); } - nav.fillDivResultExcepts(divResult, entry); + nav.fillDivResultExcepts(divEntry, entry); if (entry.link !== '') { - divResult.on('click', function () { - window.open(entry.link, '_self'); + divEntry.off('click').on('click', function (event) { + if (nav.onEntrySelect($(this), event)) { + return; + } + + window.open(entry.link); }); - divResult.find('div').each(function () { + divEntry.find('div').each(function () { $(this).css('cursor', 'pointer'); }); } + + nav.onEntryGenerated(divEntry, entry); }, @@ -243,41 +249,40 @@ var nav = { } if (entry.excerpts.length > 0) { - divResult.find('#line1').text(entry.excerpts[0]); + divResult.find('#extract').text(entry.excerpts[0]); } else { - divResult.find('#line1').html(' '); + divResult.find('#extract').text(''); } - - if (entry.excerpts.length > 1) { - divResult.find('#line2').text(entry.excerpts[1]); - } else { - divResult.find('#line2').html(' '); - } - }, - onEntryGenerated: function (divResult) { - - nav.deleteEmptyDiv(divResult, '#line1'); - nav.deleteEmptyDiv(divResult, '#line2'); + onEntryGenerated: function (divEntry, entry) { if (settings.parentHasMethod('onEntryGenerated')) { - settings.parent.onEntryGenerated(divResult); + settings.parent.onEntryGenerated(divEntry, entry); } }, + + onEntrySelect: function (divEntry, event) { + return !!(settings.parentHasMethod('onEntrySelect') && + settings.parent.onEntrySelect(divEntry, event)); + }, + + onSearchRequest: function (data) { if (settings.parentHasMethod('onSearchRequest')) { settings.parent.onSearchRequest(data); } }, + onSearchReset: function () { if (settings.parentHasMethod('onSearchReset')) { settings.parent.onSearchReset(); } }, + onResultDisplayed: function (data) { if (settings.parentHasMethod('onResultDisplayed')) { settings.parent.onResultDisplayed(data); @@ -296,28 +301,31 @@ var nav = { } }, - deleteEmptyDiv: function (entry, divId) { - var div = entry.find(divId); - if (div.text() === '') { - div.remove(); - } - }, + // deleteEmptyDiv: function (entry, divId) { + // var div = entry.find(divId); + // if (div.text() === '') { + // div.remove(); + // } + // }, - generateTemplateEntry: function (document) { + generateTemplateEntry: function () { var divTemplate = settings.entryTemplate; if (divTemplate === null) { divTemplate = settings.generateDefaultTemplate(); } if (!divTemplate.length) { - console.log('FullTextSearch Error: template_entry is not defined'); + console.log('FullTextSearch Error: entryTemplate is not defined'); return; } var tmpl = divTemplate.html(); -// tmpl = tmpl.replace(/%%id%%/g, escapeHTML(document.id)); - + // var divNavToggle = $('<div>', { + // id: 'app-navigation-toggle', + // class: 'icon-menu' + // }); + // var div = $('<div>', {class: 'result_template'}); div.html(tmpl).fadeTo(0); @@ -325,20 +333,20 @@ var nav = { }, - generateDivResult: function (entry, divResultContent) { - var divResult = $('<div>', {class: 'result_entry'}); + generateDivEntry: function (entry, divResultContent) { + var divEntry = $('<div>', {class: 'result_entry'}); - divResult.hide(); - divResult.attr('data-id', entry.id); - divResult.attr('data-link', entry.link); - divResult.attr('data-source', entry.source); - divResult.attr('data-info', JSON.stringify(entry.info)); - divResult.attr('data-result', JSON.stringify(entry)); - divResult.append(divResultContent); + divEntry.hide(); + divEntry.attr('data-id', entry.id); + divEntry.attr('data-link', entry.link); + divEntry.attr('data-source', entry.source); + divEntry.attr('data-info', JSON.stringify(entry.info)); + divEntry.attr('data-result', JSON.stringify(entry)); + divEntry.append(divResultContent); - nav.fillDivResult(divResult, entry); + nav.fillDivEntry(divEntry, entry); - return divResult; + return divEntry; }, @@ -347,7 +355,20 @@ var nav = { var divProviderNavigation = $('<div>', {class: 'provider_navigation'}); divProviderNavigation.attr('data-provider-id', providerId); divProviderNavigation.attr('data-provider-title', providerName); - divProviderNavigation.append($('<div>', {class: 'provider_navigation_left'})); + + var divProviderLeftNav = $('<div>', {class: 'provider_navigation_left'}); + if (settings.searchProviderId !== '') { + console.log('--- !!'); + var divProviderPaginationClose = $('<div>', + {class: 'icon-close provider_navigation_close'}); + divProviderPaginationClose.on('click', function () { + nav.onResultClose(); + }); + divProviderNavigation.append(divProviderPaginationClose); + } + + divProviderNavigation.append(divProviderLeftNav); + var divProviderPagination = $('<div>', {class: 'provider_navigation_right'}); var divProviderPaginationPrev = $('<div>', {class: 'provider_navigation_prev'}).append( @@ -391,16 +412,6 @@ var nav = { }); divProviderPagination.append(divProviderPaginationNext); - if (settings.searchProviderId !== '') { - var divProviderPaginationClose = $('<div>', - {class: 'icon-close provider_navigation_close'}); - divProviderPaginationClose.on('click', function () { - nav.onResultClose(); - }); - divProviderPagination.append(divProviderPaginationClose); - } - - divProviderNavigation.append(divProviderPagination); var divProviderResult = $('<div>', {class: 'provider_result'}); @@ -409,8 +420,17 @@ var nav = { divProvider.hide(); divProvider.attr('data-id', providerId); divProvider.append(divProviderNavigation); + + if (settings.resultHeader !== null) { + divProvider.append(settings.resultHeader); + } + divProvider.append(divProviderResult); + if (settings.resultFooter !== null) { + divProvider.append(settings.resultFooter); + } + return divProvider; } diff --git a/js/fulltextsearch.v1.result.js b/js/fulltextsearch.v1.result.js index f107f56..a0bbfed 100644 --- a/js/fulltextsearch.v1.result.js +++ b/js/fulltextsearch.v1.result.js @@ -41,7 +41,7 @@ var result = { var searchResult = res.result; if (searchResult.length === 0) { - result.displayNoResult(); + // result.displayNoResult(); return; } @@ -57,23 +57,15 @@ var result = { }, - displayNoResult: function () { - settings.divNoResult.fadeTo(settings.delay_result, 1); - settings.resultContainer.find('.provider_header').each(function () { - $(this).fadeTo(settings.delay_result, 0); - }); - }, - - displayProviderResult: function (request, result) { - settings.divNoResult.fadeTo(settings.delay_result, 0); + // settings.divNoResult.fadeTo(settings.delay_result, 0); var current = curr.getProviderResult(result.provider.id); var divProvider = nav.getDivProvider(result.provider.id, result.provider.name); nav.manageDivProviderNavigation(divProvider.children('.provider_navigation'), request, result.meta); - nav.manageDivProviderResult(divProvider.children('.provider_result'), result.documents, + nav.manageDivProviderResult(divProvider.find('.provider_result'), result.documents, current.documents); divProvider.slideDown(settings.delay_provider, function () { diff --git a/js/fulltextsearch.v1.settings.js b/js/fulltextsearch.v1.settings.js index 5915d86..b3623e3 100644 --- a/js/fulltextsearch.v1.settings.js +++ b/js/fulltextsearch.v1.settings.js @@ -37,9 +37,11 @@ var settings = { searchProviderId: '', searchProviderName: '', resultContainer: null, + resultHeader: null, + resultFooter: null, entryTemplate: null, entryTemplateDefault: null, - divNoResult: null, + // divNoResult: null, options: [], /** @@ -62,15 +64,30 @@ var settings = { return $('<div>').append(div); }, + // + // /** + // * generate a no result display + // */ + // generateNoResultDiv: function () { + // var div = $('<div>', {id: 'noresult'}); + // div.html('no result'); + // div.hide(); + // settings.divNoResult = div; + // }, + + + /** + * @param template + */ + setResultHeader: function (template) { + settings.resultHeader = template; + }, /** - * generate a no result display + * @param template */ - generateNoResultDiv: function () { - var div = $('<div>', {id: 'noresult'}); - div.html('no result'); - div.hide(); - settings.divNoResult = div; + setResultFooter: function (template) { + settings.resultFooter = template; }, @@ -78,15 +95,12 @@ var settings = { * used to set the template to display search result entries * * @param template - * @param parent */ - setEntryTemplate: function (template, parent) { + setEntryTemplate: function (template) { settings.entryTemplate = template; - if (parent !== null) { - settings.parent = parent; - } }, + /** * used to set the container for the search result entries * @@ -94,7 +108,7 @@ var settings = { */ setResultContainer: function (container) { settings.resultContainer = container; - settings.resultContainer.prepend(settings.divNoResult); + // settings.resultContainer.prepend(settings.divNoResult); }, diff --git a/js/navigate.js b/js/navigate.js index ad5d5ca..0abff5f 100644 --- a/js/navigate.js +++ b/js/navigate.js @@ -468,10 +468,10 @@ Navigate.prototype = { }, - onEntryGenerated: function (entry) { - this.deleteEmptyDiv(entry, '#line1'); - this.deleteEmptyDiv(entry, '#line2'); - }, + // onEntryGenerated: function (entry) { + // this.deleteEmptyDiv(entry, '#line1'); + // this.deleteEmptyDiv(entry, '#line2'); + // }, deleteEmptyDiv: function (entry, divId) { diff --git a/lib/Model/Index.php b/lib/Model/Index.php index 0c01171..e5efa1a 100644 --- a/lib/Model/Index.php +++ b/lib/Model/Index.php @@ -298,6 +298,7 @@ class Index implements \JsonSerializable { return [ 'ownerId' => $this->getOwnerId(), 'providerId' => $this->getProviderId(), + 'source' => $this->getSource(), 'documentId' => $this->getDocumentId(), 'lastIndex' => $this->getLastIndex(), 'status' => (int)$this->getStatus(), |