From 1548eab1000721b6d01d4269fc1829a1204722bb Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Wed, 16 Dec 2009 05:38:28 +0000 Subject: [PATCH] BUGFIX: convert ImageFormAction form prototype syntax to jQuery syntax, merged from r94304 (from r94332) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@95596 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- forms/ImageFormAction.php | 4 ++-- javascript/ImageFormAction.js | 30 ++++++++++++++---------------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/forms/ImageFormAction.php b/forms/ImageFormAction.php index 9331dc012..c6dda0f39 100755 --- a/forms/ImageFormAction.php +++ b/forms/ImageFormAction.php @@ -22,8 +22,8 @@ class ImageFormAction extends FormAction { parent::__construct($action, $title, $form); } function Field() { - Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/prototype/prototype.js'); - Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/behaviour/behaviour.js'); + Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js'); + Requirements::javascript(THIRDPARTY_DIR . '/jquery-livequery/jquery.livequery.js'); Requirements::javascript(SAPPHIRE_DIR . '/javascript/ImageFormAction.js'); $classClause = ''; diff --git a/javascript/ImageFormAction.js b/javascript/ImageFormAction.js index 1890d7e65..548c85609 100755 --- a/javascript/ImageFormAction.js +++ b/javascript/ImageFormAction.js @@ -1,20 +1,18 @@ -Behaviour.register({ - 'input.rollover' : { - initialize: function() { - var srcParts = this.src.match( /(.*)\.([a-zA-Z]+)$/ ); +(function($) { + $(document).ready(function() { + $("input.rollover").livequery(function(){ + var srcParts = jQuery(this).attr('src').match( /(.*)\.([a-zA-Z]+)$/ ); var fileName = srcParts[1]; var extension = srcParts[2]; - this.overSrc = fileName + '_over.' + extension; - this.outSrc = this.src; - }, + this.outSrc = jQuery(this).attr('src'); + }); + $("input.rollover").livequery('mouseover', function(){ + jQuery(this).attr('src', this.overSrc); + }); - onmouseover: function() { - this.src = this.overSrc; - }, - - onmouseout: function() { - this.src = this.outSrc; - } - } -}); \ No newline at end of file + $("input.rollover").livequery('mouseout', function(){ + jQuery(this).attr('src', this.outSrc); + }); + }); +})(jQuery); \ No newline at end of file