mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Removing deprecated ImageFormAction
Use FormAction with setAttribute('src', 'myimage.png') and custom JavaScript to achieve hover effect.
This commit is contained in:
parent
8156f0ff5a
commit
6ce33d5e59
@ -1,43 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Action that uses an image instead of a button.
|
||||
*
|
||||
* @deprecated 3.0 Use FormAction with setAttribute('src', 'myimage.png') and custom JavaScript to achieve hover effect
|
||||
* @package forms
|
||||
* @subpackage actions
|
||||
*/
|
||||
class ImageFormAction extends FormAction {
|
||||
protected $image, $hoverImage, $className;
|
||||
|
||||
/**
|
||||
* Create a new action button.
|
||||
* @param action The method to call when the button is clicked
|
||||
* @param title The label on the button
|
||||
* @param image The default image to display
|
||||
* @param hoverImage The image to display on hover
|
||||
* @param form The parent form, auto-set when the field is placed inside a form
|
||||
*/
|
||||
public function __construct($action, $title = "", $image = "", $hoverImage = null, $className = null,
|
||||
$form = null) {
|
||||
|
||||
Deprecation::notice('3.0',
|
||||
"Use FormAction with setAttribute('src', 'myimage.png') and custom JavaScript to achieve hover effect",
|
||||
Deprecation::SCOPE_CLASS);
|
||||
|
||||
$this->image = $image;
|
||||
$this->hoverImage = $hoverImage;
|
||||
$this->className = $className;
|
||||
parent::__construct($action, $title, $form);
|
||||
}
|
||||
|
||||
public function Field($properties = array()) {
|
||||
Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
|
||||
Requirements::javascript(FRAMEWORK_DIR . '/javascript/ImageFormAction.js');
|
||||
|
||||
$classClause = '';
|
||||
if($this->className) $classClause = $this->className . ' ';
|
||||
if($this->hoverImage) $classClause .= 'rollover ';
|
||||
return "<input class=\"{$classClause}action\" id=\"" . $this->id() . "\" type=\"image\" name=\"{$this->name}\""
|
||||
. " src=\"{$this->image}\" title=\"{$this->title}\" alt=\"{$this->title}\" />";
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
(function($) {
|
||||
$(document).ready(function() {
|
||||
$("input.rollover").live('mouseover', function(){
|
||||
if(!this.overSrc) {
|
||||
var srcParts = $(this).attr('src').match( /(.*)\.([a-zA-Z]+)$/ );
|
||||
var fileName = srcParts[1];
|
||||
var extension = srcParts[2];
|
||||
this.overSrc = fileName + '_over.' + extension;
|
||||
this.outSrc = $(this).attr('src');
|
||||
}
|
||||
$(this).attr('src', this.overSrc);
|
||||
});
|
||||
|
||||
$("input.rollover").live('mouseout', function(){
|
||||
$(this).attr('src', this.outSrc);
|
||||
});
|
||||
});
|
||||
})(jQuery);
|
Loading…
Reference in New Issue
Block a user