PDA

View Full Version : Highlight effect like Scriptaculous



krishnak
10 Sep 2009, 8:39 AM
Gives highlight effect for the elements.

Usage: params - el, start_color, end_color, duration (millis) [, restore_background_image]

HighlightEffect.highlight(field.el(), "FFD700", "EEE8AA", 2000);
public class HighlightEffect extends SingleStyleEffect {

private int[] base = new int[3];
private int[] delta = new int[3];

private String backgroundImage;
private boolean restoreBackgroundImage;

public static void highlight(El el, String from, String to, int duration) {
highlight(el, from, to, duration, true);
}

public static void highlight(El el, String from, String to, int duration, boolean restoreBackgroundImage) {
new Fx().run(duration, new HighlightEffect(el, from, to, restoreBackgroundImage));
}

protected HighlightEffect(El el, String from, String to, boolean restoreBackgroundImage) {
super(el);
this.restoreBackgroundImage = restoreBackgroundImage;
for (int i = 0; i < 3; i++) {
int b = Integer.parseInt(from.substring(i * 2, (i + 1) * 2), 16);
int e = Integer.parseInt(to.substring(i * 2, (i + 1) * 2), 16);
base[i] = b;
delta[i] = e - b;
}
}

@Override
public void onUpdate(double progress) {
StringBuilder sb = new StringBuilder(7).append("#");
for (int i = 0; i < 3; i++) {
String v = Integer.toHexString((int) (base[i] + delta[i] * progress));
sb.append((v.length() < 2) ? "0" : "").append(v);
}
el.setStyleAttribute("background-color", sb.toString());
}

@Override
public void onStart() {
this.backgroundImage = el.getStyleAttribute("background-image");
el.setStyleAttribute("background-image", "none");
}

@Override
public void onComplete() {
if (restoreBackgroundImage) {
el.setStyleAttribute("background-image", this.backgroundImage);
}
}
}

Hardrun
19 Sep 2009, 12:52 AM
Pretty strange code.

Arno.Nyhm
21 Sep 2009, 6:45 AM
Pretty strange code.

hello spambot,

i looked over the code and find that there a more pretty strange spam links in your footer ;-)

musyupcu
9 Oct 2009, 3:51 PM
I a trying to make a chat room for a new site design.
So far to show my enterys i have
<?php
require('../PHP/mysql.php');

$settings = mysql_connect($database_comp,$database_user,$database_pass);
if (!$settings)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db($database_db, $settings);

$chat = mysql_query("SELECT * FROM room1");

while($show = mysql_fetch_array($chat))
{
echo '<tr>';
echo '<td width="75">'.$show['username'].' : </td>';
echo '<td width="355"><div align="left">'.$show['text'].'</div></td>';
echo '</tr>';
}

mysql_close($settings);
?>
What i would like help with is that if people no html they can put it in so is there a way i can let them choose a style but they cant enter html.