University of Oregon

Re-wrap a modified JS function

The question came up recently about the possibility of modifying an existing javascript without duplicating it. Yesterday, I found out that it’s indeed possible. The key to the solutions is to re-wrap an existing function with it’s modifications in an ‘anonymous function.’
Here’s the scenario:
I have a page where I check for some required browser plugins before sending users on to our eLearning site; Adobe Flash, Reader and Java.

I also check for optimal OS / browser combinations.

So in this scenario I was leveraging available JS & jQuery functions as much as possible but in one particular case I need to accurately display the users browser but jQuery.brower treats all webkit browsers as Safari.

So instead of installing a new jQuery plug in or write a script to parse the user’s browser info I took advantage of a function in the Java detection script I pulled in.
(more…)

Drupal 7 CCK – Creating ‘Label Bulk Operations’

I have a new D7 site in the works and I found that I wanted the majority of my content type field labels to display: inline as opposed to the default: ‘above’.
Several of my content types have dozens and dozens of fields to I wanted a quick way to automate changing all the selectors at once.

I suppose ‘repetition and redundancy are the Aunt and uncle of invention’.

Here’s what I came up with:
image of the new fieldset and buttons
(more…)

Drupal6 Drupal.behaviors context; I may be figuring this out

I’ve been using some jquery functions in my custom views and modules lately but I was having a difficult time trying to figure out how to make the most of these.
I’d wanted to

  • Run multiple functions inside one Drupal.behaviors function
  • Call other Drupal.behaviors functions when while inside one
  • Only execute some Drupal.behaviors on page load or not on page load
  • Extend jquery and use the new function

So I did some tests and had some success; I now know how to achieve the first 3 in a Drupal.behaviors function. Extending jquery should probably be done outside Drupal.behaviors but we’ll have to cross that bridge later.
(more…)