Skip to content

Commit

Permalink
click search
Browse files Browse the repository at this point in the history
  • Loading branch information
agrberg committed Nov 6, 2010
1 parent db48814 commit 55066f5
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions public/javascripts/main.js
@@ -1,3 +1,14 @@
function getSelectedText() {
if (window.getSelection) {
return window.getSelection();
}
else if (document.selection) {
return document.selection.createRange().text;
}
return null;
}


$(function(){
window.Search = Backbone.Model.extend({
urlf: function() {
Expand Down Expand Up @@ -66,11 +77,21 @@ $(function(){

events : {
"change #search_term" : "render",
"click a.search" : "doThing"
"click a.search" : "doThing",
"click": "narrowSearch"
},

initialize: function() {
_.bindAll(this, 'render','doThing')
_.bindAll(this, 'render','doThing','narrowSearch')
},

narrowSearch: function(event) {
var text = getSelectedText()
if (text && text != '') {
var term = this.get_term() + " " + text
this.showTerm(term,true)
$("#search_term").val(term)
}
},

get_term: function() {
Expand Down

0 comments on commit 55066f5

Please sign in to comment.