• Development

    Userscript: Hulu Right-Click for Pop Out Video

    Hulu’s default rather large video player is usually too big for my needs. I prefer the “Pop Out” player. So, I often load the large video, click the cog wheel, move my mouse to the “popout” link, click it, then close the main window. It’s been a pain in the butt. So, I took some time to write a simple userscript that lets you right-click on any video thumbnail to open its video in the popout immediately. It’s working great for me but I have not tested it elsewhere, so I won’t be surprised if it doesn’t work for you… just let me know in the comments below…

    http://userscripts.org/scripts/show/311800

    UPDATE: I rewrote this as a Chrome Extension and published it. View the blog post.

  • Development

    Add Links to Anchors Automatically

    The following snippet is something I used recently to add (below the current item in a menu) links to any anchors found in the content.

    Honestly I could probably create the <ul> outside of the each() loop and save having to check whether it exists with each iteration. Also, it’s probably not necessary to create the aname variable, but the overhead here is minimal.

  • Development

    Maintaining Lightbox2 Templating

    Lightbox2 is a very popular and powerful Drupal module. One of the helpful features is that you can render a Drupal node in a lightbox rather easily in either PHP or HTML. View detailed explanation. The issue is that when you click a link within that lightboxed content, you will lose the lightbox2 templating (e.g., if your lightbox template hides sidebars, they’ll only be hidden when the node loads. If you click a link within the lightbox, the new node will load and sidebars will appear). Read on for a quick fix.

  • Development

    Make menu header a link to its first child link

    We use menu block a lot to create sidebar menus with specific depths, starting points, etc. The following snippet shows how we can use jQuery to turn a normal <h2> tag into a link. The link’s destination will be the same as the first child link.

    jquery_link

  • Development

    How to check if a jQuery plugin is loaded

    The following snippet is one way to determine if a jQuery plugin is loaded an available. There are probably other ways to achieve the same behavior, however this one never seems to fail me.

     

  • Development

    Open All External Links in a New Window/Tab using jQuery

    … and to match two urls/domains/whatever:
     

  • Development

    Multiple Submit Buttons on a Webform

    multiple-webform-submitI’ve spent a lot of time working with hook_form_alter() functions to modify forms, but the other day I was stumped by a simple problem. I needed to have two submit buttons on a form. By default, in the latest branch of Webform, you can change the text label on the default submit button for a webform. If you take a look at the screenshot on the right, you’ll see what my demo form looks like. The “Request More Information” button is the default submit button. The “Refer a Friend” button is the one I’m showing how to add via hook_form_alter().

  • Development

    Dynamic and AJAX-driven Select Lists in Webform

    multiple-webform-submit

    This example is a two-for-one deal! I’m going to demonstrate how to

    1. dynamically populate a webform select list on page load
    2. dynamically populate a webform select list based upon the value chosen in another webform select list

    For both parts of this example, the demo form I’ll be using is a “Get Started” form.