Removed search options button because:
1. It's confusing. People think you click it to perform the search, then are surprised when it doesn't do that. 2. Now that the search results are displayed more clearly, there's really no need for a titles-only search option.
This commit is contained in:
parent
e50d8d909e
commit
5d860300f1
|
@ -670,9 +670,8 @@ class Notebooks( object ):
|
|||
notebook_id = Valid_id(),
|
||||
search_text = Valid_string( min = 0, max = 100 ),
|
||||
user_id = Valid_id( none_okay = True ),
|
||||
titles_only = Valid_bool(),
|
||||
)
|
||||
def search( self, notebook_id, search_text, titles_only, user_id ):
|
||||
def search( self, notebook_id, search_text, user_id ):
|
||||
"""
|
||||
Search the notes within a particular notebook for the given search text. Note that the search
|
||||
is case-insensitive, and all HTML tags are ignored. The matching notes are returned with title
|
||||
|
@ -682,8 +681,6 @@ class Notebooks( object ):
|
|||
@param notebook_id: id of notebook to search
|
||||
@type search_text: unicode
|
||||
@param search_text: search term
|
||||
@type titles_only: bool
|
||||
@param titles_only: if true, only search titles. if false, search all note titles and contents
|
||||
@type user_id: unicode or NoneType
|
||||
@param user_id: id of current logged-in user (if any), determined by @grab_user_id
|
||||
@rtype: json dict
|
||||
|
@ -711,7 +708,7 @@ class Notebooks( object ):
|
|||
if note is None: continue
|
||||
if search_text in nuker.nuke( note.title ).lower():
|
||||
title_matches.append( note )
|
||||
elif not titles_only and search_text in nuker.nuke( note.contents ).lower():
|
||||
elif search_text in nuker.nuke( note.contents ).lower():
|
||||
content_matches.append( note )
|
||||
|
||||
notes = title_matches + content_matches
|
||||
|
|
|
@ -11,14 +11,12 @@ function Wiki( invoker ) {
|
|||
this.all_notes_editor = null; // editor for display of list of all notes
|
||||
this.search_results_editor = null; // editor for display of search results
|
||||
this.invoker = invoker;
|
||||
this.search_titles_only = true;
|
||||
this.rate_plan = null;
|
||||
this.storage_usage_high = false;
|
||||
|
||||
connect( this.invoker, "error_message", this, "display_error" );
|
||||
connect( this.invoker, "message", this, "display_message" );
|
||||
connect( "search_form", "onsubmit", this, "search" );
|
||||
connect( "search_button", "onclick", this, "toggle_search_options" );
|
||||
connect( "html", "onclick", this, "background_clicked" );
|
||||
|
||||
// get info on the requested notebook (if any)
|
||||
|
@ -869,8 +867,7 @@ Wiki.prototype.search = function ( event ) {
|
|||
|
||||
var self = this;
|
||||
this.invoker.invoke( "/notebooks/search", "GET", {
|
||||
"notebook_id": this.notebook_id,
|
||||
"titles_only": this.search_titles_only
|
||||
"notebook_id": this.notebook_id
|
||||
},
|
||||
function( result ) { self.display_search_results( result ); },
|
||||
"search_form"
|
||||
|
@ -879,18 +876,6 @@ Wiki.prototype.search = function ( event ) {
|
|||
event.stop();
|
||||
}
|
||||
|
||||
Wiki.prototype.toggle_search_options = function ( event ) {
|
||||
// if the pulldown is already open, then just close it
|
||||
var existing_div = getElement( "search_pulldown" );
|
||||
if ( existing_div ) {
|
||||
existing_div.pulldown.shutdown();
|
||||
return;
|
||||
}
|
||||
|
||||
new Search_pulldown( this, this.notebook_id, this.search_titles_only );
|
||||
event.stop();
|
||||
}
|
||||
|
||||
Wiki.prototype.display_search_results = function ( result ) {
|
||||
// if there are no search results, indicate that and bail
|
||||
if ( !result || result.notes.length == 0 ) {
|
||||
|
@ -1463,62 +1448,3 @@ Link_pulldown.prototype.shutdown = function () {
|
|||
if ( this.link )
|
||||
this.link.pulldown = null;
|
||||
}
|
||||
|
||||
|
||||
function Search_pulldown( wiki, notebook_id, titles_only ) {
|
||||
Pulldown.call( this, wiki, notebook_id, "search_pulldown", getElement( "search_button" ) );
|
||||
|
||||
this.titles_radio = createDOM( "input", { "type": "radio", "class": "pulldown_radio" } );
|
||||
this.titles_toggle = createDOM( "a", { "href": "", "class": "pulldown_link", "title": "Search only note titles." },
|
||||
"titles only"
|
||||
);
|
||||
this.everything_radio = createDOM( "input", { "type": "radio", "class": "pulldown_radio" } );
|
||||
this.everything_toggle = createDOM( "a", { "href": "", "class": "pulldown_link", "title": "Search everything, including note titles and contents." },
|
||||
"everything"
|
||||
);
|
||||
|
||||
appendChildNodes( this.div, this.titles_radio );
|
||||
appendChildNodes( this.div, this.titles_toggle );
|
||||
appendChildNodes( this.div, createDOM( "br" ) );
|
||||
appendChildNodes( this.div, this.everything_radio );
|
||||
appendChildNodes( this.div, this.everything_toggle );
|
||||
|
||||
if ( titles_only )
|
||||
this.titles_radio.checked = true;
|
||||
else
|
||||
this.everything_radio.checked = true;
|
||||
|
||||
var self = this;
|
||||
connect( this.titles_radio, "onclick", function ( event ) { self.titles_clicked( event ); } );
|
||||
connect( this.titles_toggle, "onclick", function ( event ) { self.titles_clicked( event ); } );
|
||||
connect( this.everything_radio, "onclick", function ( event ) { self.everything_clicked( event ); } );
|
||||
connect( this.everything_toggle, "onclick", function ( event ) { self.everything_clicked( event ); } );
|
||||
}
|
||||
|
||||
Search_pulldown.prototype = new function () { this.prototype = Pulldown.prototype; };
|
||||
Search_pulldown.prototype.constructor = Search_pulldown;
|
||||
|
||||
Search_pulldown.prototype.titles_clicked = function ( event ) {
|
||||
if ( event.target() != this.titles_radio )
|
||||
this.titles_radio.checked = true;
|
||||
this.everything_radio.checked = false;
|
||||
this.wiki.search_titles_only = true;
|
||||
event.stop();
|
||||
}
|
||||
|
||||
Search_pulldown.prototype.everything_clicked = function ( event ) {
|
||||
if ( event.target() != this.everything_radio )
|
||||
this.everything_radio.checked = true;
|
||||
this.titles_radio.checked = false;
|
||||
this.wiki.search_titles_only = false;
|
||||
event.stop();
|
||||
}
|
||||
|
||||
Search_pulldown.prototype.shutdown = function () {
|
||||
Pulldown.prototype.shutdown.call( this );
|
||||
|
||||
disconnectAll( this.titles_radio );
|
||||
disconnectAll( this.titles_toggle );
|
||||
disconnectAll( this.everything_radio );
|
||||
disconnectAll( this.everything_toggle );
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ class Search_form( Form ):
|
|||
|
||||
Form.__init__(
|
||||
self,
|
||||
Input( type = u"button", class_ = u"note_button", id = u"search_button", value = u"search ↓", title = "search options" ),
|
||||
Strong( u"search: " ),
|
||||
Input( type = u"text", name = u"search_text", id = u"search_text", size = 30, maxlength = 100 ),
|
||||
id = u"search_form",
|
||||
)
|
||||
|
|
Reference in New Issue
Block a user