Completed
Push — master ( 4c09a9...d26431 )
by Maxence
03:15
created

Bookmarks_FullTextSearch.onEntrySelected   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
nc 1
nop 2
1
/*
2
 * Bookmarks_FullTextSearch - Indexing bookmarks
3
 *
4
 * This file is licensed under the Affero General Public License version 3 or
5
 * later. See the COPYING file.
6
 *
7
 * @author Maxence Lange <[email protected]>
8
 * @copyright 2018
9
 * @license GNU AGPL version 3 or any later version
10
 *
11
 * This program is free software: you can redistribute it and/or modify
12
 * it under the terms of the GNU Affero General Public License as
13
 * published by the Free Software Foundation, either version 3 of the
14
 * License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU Affero General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU Affero General Public License
22
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23
 *
24
 */
25
26
27
/** global: OCA */
28
29
const fullTextSearch = OCA.FullTextSearch.api;
30
31
32
var elements = {
33
	old_bookmarks: null,
34
	search_result: null,
35
	template_entry: null
36
};
37
38
39
const Bookmarks_FullTextSearch = function () {
40
	this.init();
41
};
42
43
44
Bookmarks_FullTextSearch.prototype = {
45
46
	init: function () {
47
		var self = this;
48
49
		elements.old_bookmarks = $('.bookmarks_list');
50
51
		elements.search_result = $('<div>');
52
		elements.search_result.insertBefore(elements.old_bookmarks);
53
54
		elements.search_input = $('#next_search_input');
55
56
		// elements.template_entry = self.generateTemplateEntry();
57
		// fullTextSearch.setEntryTemplate(elements.template_entry);
58
		fullTextSearch.setResultContainer(elements.search_result);
59
		fullTextSearch.initFullTextSearch('bookmarks', 'bookmarks', self);
60
	},
61
62
63
	// generateTemplateEntry: function () {
64
	//
65
	// 	var divLeft = $('<div>', {class: 'result_entry_left'});
66
	// 	divLeft.append($('<div>', {id: 'title'}).html('&nbsp;'));
67
	// 	divLeft.append($('<div>', {id: 'line1'}).html('&nbsp;'));
68
	// 	divLeft.append($('<div>', {id: 'line2'}).html('&nbsp;'));
69
	//
70
	// 	var divRight = $('<div>', {class: 'result_entry_right'});
71
	// 	divRight.append($('<div>', {id: 'source'}).html('&nbsp;'));
72
	// 	divRight.append($('<div>', {id: 'score'}).html('&nbsp;'));
73
	//
74
	// 	var divDefault = $('<div>', {class: 'result_entry_default'});
75
	// 	divDefault.append(divLeft);
76
	// 	divDefault.append(divRight);
77
	//
78
	// 	return $('<div>').append(divDefault);
79
	// },
80
81
82
	onEntryGenerated: function (divEntry, entry) {
83
		if (entry.info.source !== '') {
84
			divEntry.find('#info').text(entry.info.source);
85
		}
86
	},
87
88
89
	onEntrySelected: function (divEntry, event) {
0 ignored issues
show
Unused Code introduced by
The parameter event is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
90
		window.open(divEntry.attr('data-link'), '_blank');
91
92
		return true;
93
	},
94
95
96
	onResultDisplayed: function () {
97
		elements.old_bookmarks.fadeOut(150, function () {
98
			elements.search_result.fadeIn(150);
99
		});
100
	},
101
102
103
	onSearchReset: function () {
104
		elements.search_result.fadeOut(150, function () {
105
			elements.old_bookmarks.fadeIn(150);
106
		});
107
	},
108
109
110
	onResultClose: function () {
111
		elements.search_result.fadeOut(150, function () {
112
			elements.old_bookmarks.fadeIn(150);
113
		});
114
	}
115
116
};
117
118
119
OCA.FullTextSearch.Bookmarks = Bookmarks_FullTextSearch;
120
121
$(document).ready(function () {
122
	OCA.FullTextSearch.navigate = new Bookmarks_FullTextSearch();
123
});
124
125
126
127