如何将此 MooTools 代码转换为 jQuery
当我尝试将 Mootools 转换为 Jquery 时,我遇到了一些问题。
var Site = new Class({
Implements : Options,
options : {
},
initialize : function(options) {
// Set opzioni
this.setOptions(options);
var section = $$("body")[0].getProperty("class");
// Chiama metodo
if( typeof(this[section]) == "function" ) this[section]();
},
// Orerazioni di sezione
home: function(){
// Init scrollTo
new SmoothScroll({ duration: 800, transition:Fx.Transitions.Sine.easeOut, offset:{"x":0, "y":-40} });
// Definisce elementi draggabili
$("handle").addEvent("click", function(e){ e.stop(); })
new Drag.Move($('window'), {'handle':'handle'});
$("logo").fade("hide");
var ttop = $("simple-modal-title").getCoordinates().top + 100;
window.addEvent("scroll", function(){
if( window.getScroll().y >= ttop ){
if( !$("simple-modal-title").hasClass("fixed") ){ $("logo").fade("in"); }
$("simple-modal-title").addClass("fixed")
}else{
if( $("simple-modal-title").hasClass("fixed") ){ $("logo").fade("out"); }
$("simple-modal-title").removeClass("fixed");
}
}.bind(this));
this.checkLogo();
// Inizializza esempi
this.initExamples();
},
checkLogo: function(){
window.fireEvent("scroll")
},
// Smart Template
templating: function(s,d){
for (var p in d)
s = s.replace(new RegExp('{'+p+'}','g'), d[p]);
return s;
}
});
window.addEvent("domready", function(){
var site = new Site();
});
不知道能不能转换成功。感谢您的帮助! :)
I have a certain problem when I try to Convert Mootools to Jquery.
var Site = new Class({
Implements : Options,
options : {
},
initialize : function(options) {
// Set opzioni
this.setOptions(options);
var section = $("body")[0].getProperty("class");
// Chiama metodo
if( typeof(this[section]) == "function" ) this[section]();
},
// Orerazioni di sezione
home: function(){
// Init scrollTo
new SmoothScroll({ duration: 800, transition:Fx.Transitions.Sine.easeOut, offset:{"x":0, "y":-40} });
// Definisce elementi draggabili
$("handle").addEvent("click", function(e){ e.stop(); })
new Drag.Move($('window'), {'handle':'handle'});
$("logo").fade("hide");
var ttop = $("simple-modal-title").getCoordinates().top + 100;
window.addEvent("scroll", function(){
if( window.getScroll().y >= ttop ){
if( !$("simple-modal-title").hasClass("fixed") ){ $("logo").fade("in"); }
$("simple-modal-title").addClass("fixed")
}else{
if( $("simple-modal-title").hasClass("fixed") ){ $("logo").fade("out"); }
$("simple-modal-title").removeClass("fixed");
}
}.bind(this));
this.checkLogo();
// Inizializza esempi
this.initExamples();
},
checkLogo: function(){
window.fireEvent("scroll")
},
// Smart Template
templating: function(s,d){
for (var p in d)
s = s.replace(new RegExp('{'+p+'}','g'), d[p]);
return s;
}
});
window.addEvent("domready", function(){
var site = new Site();
});
I don't really know if it is possible to convert successfully. Thanks for your help! :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我把这个当作一个字面意义上的问题,答案就是:
就目前情况而言,您是在要求有人为您做这件事吗?这不是 StackOverflow 的主题,您应该尝试使用自由职业者网站。
If I treat this as a question in the literal sense, the answer is:
As it stands, you are kind of asking for somebody to do it for you? this is not what StackOverflow is about, you should try a freelancer site for that.