Permalink
Browse files

day 19

  • Loading branch information...
1 parent 088bea2 commit 5b297032b206f235e1a9c58742bbbdb37ded26fc @typester committed Dec 21, 2009
Showing with 54 additions and 1 deletion.
  1. +4 −0 lib/Jobeet/Controller/Search.pm
  2. +5 −1 root/common/base.mt
  3. +19 −0 root/js/jquery-1.3.2.min.js
  4. +18 −0 root/js/search.js
  5. +8 −0 root/search/ajax.mt
@@ -10,6 +10,10 @@ sub index :Path {
or $c->detach('/default');
$c->stash->{jobs} = models('Schema::Job')->search_fulltext($query);
+
+ if ($c->req->header('X-Requested-With') =~ /XMLHttpRequest/i) {
+ $c->view('MT')->template('search/ajax');
+ }
}
1;
View
@@ -6,7 +6,10 @@
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="alternate" type="application/atom+xml" title="Latest Jobs"
href="<?= $c->uri_for('/job/atom') ?>" />
- <? block javascripts => '' ?>
+? block javascripts => sub {
+ <script type="text/javascript" src="<?= $c->uri_for('/js/jquery-1.3.2.min.js') ?>"></script>
+ <script type="text/javascript" src="<?= $c->uri_for('/js/search.js') ?>"></script>
+? } # endblock javascripts
<? block stylesheets => '' ?>
</head>
<body>
@@ -31,6 +34,7 @@
<input type="text" name="q"
id="search_keywords" />
<input type="submit" value="search" />
+ <img id="loader" src="<?= $c->uri_for('/images/loader.gif') ?>" style="vertical-align: middle; display: none" />
<div class="help">
Enter some keywords (city, country, position, ...)
</div>

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -0,0 +1,18 @@
+$(document).ready(function()
+{
+ $('.search input[type="submit"]').hide();
+
+ $('#search_keywords').keyup(function(key)
+ {
+ if (this.value.length >= 3 || this.value == '')
+ {
+ $('#loader').show();
+ $('#jobs').load(
+ $(this).parents('form').attr('action'),
+ { q: this.value + '*' },
+ function() { $('#loader').hide(); }
+ );
+ }
+ });
+});
+
View
@@ -0,0 +1,8 @@
+? my @jobs = $c->stash->{jobs}->all;
+
+? if (@jobs) {
+?= include('job/partial_jobs', @jobs );
+? } else {
+No results.
+? }
+

0 comments on commit 5b29703

Please sign in to comment.