這是JavaScript代碼來調用 功能警報是從的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代碼此功能。 它是反向工程:=)
這裏是從第6階段 http://img10.imageshack.us/img10/1733/83630697.png
我已測試的所有圖像,但是我沒有解決方案。
希望有人能幫助我。
您認爲在這裏的原型功能是什麼? – JaredPar
請描述你正在嘗試做什麼。你想用方法創建一個函數或持久對象嗎?你對'this'的使用通常與一個對象/方法有關,但是我沒有看到任何這種上下文。如果你只是想要一個函數,那麼你可以把'current_page'和'last_page'改成局部變量,並將它用作一個普通函數。 – jfriend00
難道你說的是Prototype.js而不是原型繼承? –