fix for when an element is passed to the programatic timeago helper

This commit is contained in:
Ryan McGeary 2008-07-30 10:38:21 -04:00
parent 8e1c2502e3
commit c03993e2d0
2 changed files with 3 additions and 3 deletions

View file

@ -17,7 +17,7 @@
$.timeago = function(timestamp) { $.timeago = function(timestamp) {
if (timestamp instanceof Date) return inWords(timestamp); if (timestamp instanceof Date) return inWords(timestamp);
else if (typeof timestamp == "string") return inWords($.timeago.parse(timestamp)); else if (typeof timestamp == "string") return inWords($.timeago.parse(timestamp));
else return inWords($.timeago.parse(timestamp.title)); else return inWords($.timeago.parse($(timestamp).attr("title")));
}; };
$.extend($.timeago, { $.extend($.timeago, {

View file

@ -27,7 +27,7 @@
// unit tests // unit tests
$("#helper_date").text($.timeago(new Date())); $("#helper_date").text($.timeago(new Date()));
$("#helper_string").text($.timeago(iso8601(new Date()))); $("#helper_string").text($.timeago(iso8601(new Date())));
$.timeago($("#helper_element")); $("#helper_element").text($.timeago($("#helper_element")));
}); });
</script> </script>
<style> <style>
@ -92,6 +92,6 @@
<h1>Helper unit tests:</h1> <h1>Helper unit tests:</h1>
You opened this page <abbr id="helper_date"></abbr> [won't refresh]<br /> You opened this page <abbr id="helper_date"></abbr> [won't refresh]<br />
You opened this page <abbr id="helper_string"></abbr> [won't refresh]<br /> You opened this page <abbr id="helper_string"></abbr> [won't refresh]<br />
You opened this page <abbr id="helper_element" class="loaded"></abbr> [should refresh]<br /> You opened this page <abbr id="helper_element" class="a loaded"></abbr> [won't refresh]<br />
</body> </body>
</html> </html>