From a383f3ed04fd243eb9d8cb3c85eea67c6300ba80 Mon Sep 17 00:00:00 2001 From: Sanj Date: Wed, 10 Aug 2011 00:50:04 +0530 Subject: [PATCH] arrow function + templatetag for title added --- itf/frontpage/templatetags/__init__.py | 0 itf/frontpage/templatetags/itftags.py | 29 ++++++++++++++++++++++++++ itf/static/js/frontpage.js | 7 ++++++- 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 itf/frontpage/templatetags/__init__.py create mode 100644 itf/frontpage/templatetags/itftags.py diff --git a/itf/frontpage/templatetags/__init__.py b/itf/frontpage/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/itf/frontpage/templatetags/itftags.py b/itf/frontpage/templatetags/itftags.py new file mode 100644 index 0000000..29f31cf --- /dev/null +++ b/itf/frontpage/templatetags/itftags.py @@ -0,0 +1,29 @@ +from django import template + +register = template.Library() + +''' +Used to format titles in the front slider boxes + +>>>format_title("Script Bank") +>>>SCRIPT BANK + +>>>format_title("Script-Bank") +>>>SCRIPT-BANK +''' + +def format_title(value): + v = value.strip() + if v.find('-') != -1: + splitter = "-" + else: + splitter = " " + words = v.split(splitter) + l = len(words) + if l > 1: + boldWord = "" + words[l - 1] + "" + return (splitter.join(words[:l-1]) + splitter + boldWord).upper() + else: + return words[0].upper() + +register.filter("format_title") diff --git a/itf/static/js/frontpage.js b/itf/static/js/frontpage.js index 71bc248..5a0cb55 100644 --- a/itf/static/js/frontpage.js +++ b/itf/static/js/frontpage.js @@ -22,6 +22,7 @@ $(function() { $('#arrowLeft').mouseout(function() { clearInterval(slideInterval); + slider.stop(); }); $('#arrowRight').mouseover(function() { @@ -33,6 +34,7 @@ $(function() { $('#arrowRight').mouseout(function() { clearInterval(slideInterval); + slider.stop(); }); @@ -67,7 +69,10 @@ var ItfSlider = function(o) { var arrLeft = (0 - this.getLeft()) + (this.contentWidth - 10); console.log(arrLeft); this.rightArr.animate({'left': arrLeft + "px"}); - } + }; + this.stop = function() { + this.ul.stop(); + }; }; ItfSlider.prototype.moveLeft = function(distance, speed) {