September 22, 2007

This is why showing off new tablet laptops can backfire on ya.

Filed under: comic, humor — Andrew @ 12:42 am

September 21, 2007

Filed under: art, tim hortons — Andrew @ 12:01 am

September 16, 2007


A doodle of my folks, who are pretty awesome.

Filed under: comic, art — Andrew @ 2:01 am

September 14, 2007

Client throwing in far too many content? This will automatically abbreviate too-lengthy content with - read more - tags that activate on a mouseover. Then you can click to hide them again.

It’ll try and break things at the nearest full stop, (”.”), or the nearest space if it can’t find a period. Hope someone finds this useful - you can see it in action over here.

/*
<ul class="accordion">

	<li>Your content here.</li>
</ul>
*/

$(document).ready(function(){

	//Snippet settings
	var max_length = 110;	// Maximum amount of characters to display
	var margin_of_error = 80; // If your break point is closer than this value to the end of the string, it won't bother abbreviating it.
	var read_more = "( Read More )";  // Message
	var read_less = "( Click to hide )";	// Message

	$(".accordion li").each(function(){
		var length = $(this).html().length;
		var text = $(this).html();

	  if (length >= max_length)  {
		  var point = text.substr(max_length, length).indexOf(".");
		  if (point == 0) {
			  point = text.substr(max_length, length).indexOf(" ");
		  }
		  if (point + max_length + margin_of_error >= length) {
			  return;	//too few characters to make a difference? Abbreviate.
		  }
		  var cutpoint = max_length + point + 1;
		  var newtext = text.substr(0, cutpoint);
		  var hiddentext = text.substr(cutpoint, length);
		 $(this).empty().append(newtext);
		 $(this).append("<span class=\"hidden\">" + hiddentext + "</span>");
		 $(this).append("<span class=\"read_more\">" + read_more + "</span>");
	  }
	});

	//On mouseover, expand.
	$(".read_more").mouseover(function() {
		if ($(this).prev(".hidden").css("display") == 'none')
		{
			if ( $(this).text() == read_more ) {
				$(this).text(read_less);
			}
			else {
				$(this).text(read_more);
			}
			$(this).prev(".hidden").slideDown(400);
		}
		});

	//On mouseclick, hide.
	$(".read_more").click(function() {
			if ( $(this).text() == read_more ) {
				$(this).text(read_less);
			}
			else {
				$(this).text(read_more);
			}
		$(this).prev(".hidden").slideUp(400);
	});

});

Filed under: art, jquery — Andrew @ 6:09 pm
Creative Commons License
All drupal-related paintings are licensed under a Creative Commons Attribution-Noncommercial 2.5 Canada License.
Everything else, all rights reserved, so hands off, you! :D
andrew stevenson the life of me comic blog art angst humor stuff sheridan college windsor oakville south africa toronto richmond hill walkerville