From f83ffd87d4decbbe05a4c8a26c4c9860c223e72e Mon Sep 17 00:00:00 2001 From: Jayaram R Pai Date: Wed, 30 Jul 2014 18:12:23 +0530 Subject: added quick_links for jobs page --- css/main.css | 5 +++++ job_portal.module | 28 +++++++++++++++++++++++----- js/smooth_scroll.js | 26 ++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 js/smooth_scroll.js diff --git a/css/main.css b/css/main.css index 1617b3d..661dfe6 100644 --- a/css/main.css +++ b/css/main.css @@ -11,3 +11,8 @@ #job-application legend { text-align: center; } +#quick-links { + position: fixed; + left: 45px; + top: 250px; +} diff --git a/job_portal.module b/job_portal.module index bc98aa5..667e8e6 100644 --- a/job_portal.module +++ b/job_portal.module @@ -185,9 +185,11 @@ FOSSEE Team } function job_portal_page() { - $result = get_jobs_available(); - $output = ""; + $output = ""; + $quick_links = ""; $i = 1; + + $result = get_jobs_available(); foreach($result as $row) { $collapser_header = "#{$i} - {$row->project} - Job Details"; $collapser_content = " @@ -205,11 +207,17 @@ FOSSEE Team "html" => TRUE, )); $collapser_content .= ""; - $output .= collapser($collapser_header, $collapser_content); + $output .= collapser($collapser_header, $collapser_content, "", $i); + $quick_links .= "{$i}
"; $i++; } $output = array( + "quick_links" => array( + "#prefix" => "", + ), "job_description" => array( "#prefix" => "
", "#markup" => $output, @@ -302,12 +310,22 @@ FOSSEE Team function job_portal_init() { drupal_add_js("misc/form.js"); drupal_add_js("misc/collapse.js"); + drupal_add_js( + drupal_get_path('module', 'job_portal') . '/js/smooth_scroll.js', + array( + 'group' => JS_THEME, + 'weight' => 20, + 'every_page' => TRUE, + 'cache' => TRUE, + 'scope' => 'header', + ) + ); } /* helper functions */ - function collapser($title="", $content="", $description="") { + function collapser($title="", $content="", $description="", $key="") { return " -
+
{$title} diff --git a/js/smooth_scroll.js b/js/smooth_scroll.js new file mode 100644 index 0000000..d16dc1a --- /dev/null +++ b/js/smooth_scroll.js @@ -0,0 +1,26 @@ +(function($) { + $(document).ready(function() { + $('a[href*=#]:not([href=#])').click(function() { + if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') + || location.hostname == this.hostname) { + + var target = $(this.hash); + target = target.length ? target : $('[name=' + this.hash.slice(1) +']'); + if (target.length) { + $('html,body').animate({ + scrollTop: target.offset().top + }, 1000); + return false; + } + } + }); + $(".quick").click(function() { + $(".quick").removeClass("badge-success"); + $(this).addClass("badge-success"); + setTimeout(function() { + $(".quick").removeClass("badge-success"); + }, 4000); + }); + $('.quick').tooltip(); + }); +})(jQuery); -- cgit