University of Oregon

Moved Content Highlight Up Above Links

I moved the content highlight section up above the nav links and administrative content.
I had to do this with javascript/jquery so it’s an enhancement for those with javascript enabled but I think it’s nice to keep the content together. (more…)

Drupal use jquery to coordinate two cck fields.

I have a module that alters a CCK custom content type and I’m using it to include some jQuery that updates the upper value of paired fields.
In the initial use case the two fields were age range, one for low and one for high. Then I added support for a scenario that uses two date fields as well.
Theoretically the function can be called from anywhere. You only need the ID of the two fields and the type: int or date.

The logic behind the update is simple but optimized for for usability. When it’s invoked, the upper range is checked against the lower range and updated if it’s lower.

I experimented with .blur(), .focus() and .change(). These are shortcuts for jQuery’s .bind() function, which I used to combine blur and change where both are used on one element.

Using jquery is always a learning experiment and I’ve got some fun js stuff in there too like !isNaN(parseInt()) to verify that the value we’re dealing with is a number and not a default option like “None”.
Most importantly I learned that we don’t need to use $(document).ready(function(){}); in Drupal modules. Instead we can use Drupal.behaviors.myModuleName = function (context) {} instead.

updateUpperField is the function I wrote to achieve this:
function updateUpperField(‘lowerFieldID’,’upperFieldID’,type:’int’|’date’)
Usage: call updateUpperField from within the document and include the two id’s of the fields in question as well as the type of field.
(more…)

Drupal and ajax or ahah to load content on demand

I’ve been including an external page on load in one of my nodes and that doesn’t make a lot of sense as it’s a curl of another site and isn’t viewed very often so I’d rather include it on demand.
So now it works with jquery and ahah.
Here’s the page: https://odt.uoregon.edu/content/elearning
The function is called when you open the FAQ section and click the first link: ‘What browsers are supported for PC and Mac?’.
Here’s an example of the code: (more…)

Pad your drupal superfish menu

Here’s a bookmarklet I wrote to pad a suckerfish menu so that it fits on one line.
I intend on making this a module for use in drupal6. I have 6 sites that could benefit from this now. (more…)

Tab menu examples

Here’s a collection of links to tab menu examples.
(more…)

Duplicate Drupal dhtml-menu items to use again

I have some sub menus that I want to use as the dominant secondary nav when the user lands on the sub pages.

Now I’ve yet to be able to figure out how to reuse a menu in more that one place on the page. Maybe I need to do a more extensive module search but I set out to to attempt it with jQuery and would you believe it… It worked!
(more…)

Edit CSS and removing line breaks to process through js

I wanted to append the head of a doc with some styles but I didn’t want any line breaks.
So I used this function:

<?php
function removeLB($content){
	$content = str_replace(chr(10), " ", $content); //remove carriage returns
	$content = str_replace(chr(13), " ", $content); //remove carriage returns
	return $content;
}

That way I could edit with line breaks but send it through the jQuery append without.
(more…)

Drupal dhtml_menu accommodate non-javascript viewers

I wanted to find a solution for using dhtml menus while accommodating non-javascript viewers.
Turns out it was an easy fix.

The menu currently uses drupal’s: drupal_add_css to append the css document which collapses all the menu items by default. Since the menu module relies on jQuery, I changed the append method to use jQuery instead.
Here’s my suggested fix: (more…)

Create a wordcloud from any page with search function

Building off of my last post Create a wordcloud from any page. I wanted to add some search functionality.
So now clicking a word highlights the word on the page.

Here’s the example: Word Cloud w/ Search
(more…)

Create a wordcloud from any page

On the ODT web site we’d like to generate word clouds for our local and linked content. So I went looking for a simple javascript word cloud generator. I found a project on Clusterfy that created a jquery bookmarklet to do that on any page: http://clusterify.com/projects/list/fsavard/6/

Here’s the example: Generate Word Cloud

Note: I’ve also created a version that highlights the words on the page when you click them. Create a wordcloud from any page with search function

I made several modifications: (more…)