[英]How I can Call Javascript prototype functions?
这是从Stage6调用功能警报的Javascript代码,我将对其进行完全重建以使其恢复活动:)
// 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代码。 这是逆向工程:=)
这是第六阶段的图片http://img10.imageshack.us/img10/1733/83630697.png
我都进行了测试,但没有解决方案。
希望有人可以帮助我。
不知道您是要定义原型函数还是调用一个原型函数:
制作原型功能:
Alerts.prototype.nameYourFunction = function(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';
}
};
将nameYourFunction
替换为您要调用的nameYourFunction
那么您就可以像这样调用它:
Alerts.nameYourFunction(2);
或致电您添加到问题中的一个:
Alerts.next();
mmm ... mmm .... var a = new Alerts(5); a.next()
var a = new Alerts(5); a.next()
????
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.