JS If Blocks plugin

Plugin details

Plugin to support generating javascript IF/UNLESS blocks.

Websitehttp://rubyforge.org/projects/js-if-blocks/ Repositorysvn://rubyforge.org/var/svn/js-if-blocks/trunk Author Maxim Kulkin Tags rjs, Javascript LicenseMIT

Documentation

Install the plugin:
ruby script/plugin install svn://rubyforge.org/var/svn/js-if-blocks/trunk

Lets say you want to produce javascript that will execute blind_down visual effect to show some DOM element unless it is already visible. To accomplish this you need an IF block:

  update_page do |page|
    page << "if( !($('#{element_id}').visible()) ) {"
    page.visual_effect :blind_down, element_id
    page << "}"
  end


Instead you can use +if+ method that this plugin provides:

  update_page do |page|
    page.unless "$('#{element_id}').visible()" do
      page.visual_effect :blind_down, element_id
    end
  end


Also, you can make use of javascript element proxy in the expression:

  update_page do |page|
    page.unless page[element_id].visible do
      page.visual_effect :blind_down, element_id
    end
  end

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | Back in time (1 older version) | Last edited by: scott, 7 months ago