【发布时间】:2011-09-23 21:50:56
【问题描述】:
这是要调用的 Javascript 代码 来自 Stage6 的功能警报,我将完全重建以使其恢复正常运行 :)
// Alerts (in the header)
function Alerts(total) {
this.current_page = 1;
this.last_page = Math.ceil(total / 4);
if (this.current_page == this.last_page) {
$('alert-next-button').className = 'alert-next-inactive';
}
}
这是来自 DivX Stage6 的原型函数:
Alerts.prototype.next = function () {
if (this.current_page == this.last_page) {
return;
}
new Effect.BlindUp('alerts-' + this.current_page, {
scaleFrom:80,
duration:0.4,
queue:{
position:'end',
scope:'alerts'
}
});
new Effect.BlindDown('alerts-' + (this.current_page + 1), {
scaleTo:80,
duration:0.4,
queue:{
position:'end',
scope:'alerts'
}
});
this.current_page++;
if (this.current_page > 1) {
$('alert-prev-button').className = 'alert-prev';
}
if (this.current_page == this.last_page) {
$('alert-next-button').className = 'alert-next-inactive';
}
}
第二个原型函数:
Alerts.prototype.previous = function () {
if (this.current_page == 1) {
return;
}
new Effect.BlindUp('alerts-' + this.current_page, {
scaleFrom:80,
duration:0.4,
queue:{
position:'end',
scope:'alerts'
}
});
new Effect.BlindDown('alerts-' + (this.current_page - 1), {
scaleTo:80,
duration:0.4,
queue:{
position:'end',
scope:'alerts'
}
});
this.current_page--;
if (this.current_page == 1) {
$('alert-prev-button').className = 'alert-prev-inactive';
}
if (this.current_page < this.last_page) {
$('alert-next-button').className = 'alert-next';
}
}
我需要此功能的 HTML 代码。 这是逆向工程:=)
这是第 6 阶段的图片 http://img10.imageshack.us/img10/1733/83630697.png
我都测试过了,但我没有解决方案。
希望有人能帮帮我。
【问题讨论】:
-
你觉得这里的原型函数是什么?
-
请描述您正在尝试做什么。您是否尝试使用方法创建函数或持久对象?您对
this的使用通常与对象/方法相关联,但我看不到任何上下文。如果你只是想要一个函数,那么你可以将current_page和last_page更改为局部变量并将其用作普通函数。 -
你说的是Prototype.js而不是原型继承吗?
标签: javascript function-prototypes