如何将此 MooTools 代码转换为 jQuery

发布于 2024-12-11 21:01:12 字数 1673 浏览 0 评论 0原文

当我尝试将 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技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梅倚清风 2024-12-18 21:01:12

如果我把这个当作一个字面意义上的问题,答案就是:

  1. 学习mootools。
  2. 学习 jQuery。
  3. 编写代码来做到这一点。
  4. 如果遇到问题,请通过将新编写的 jquery 代码与旧代码一起发布来寻求帮助。

就目前情况而言,您是在要求有人为您做这件事吗?这不是 StackOverflow 的主题,您应该尝试使用自由职业者网站。

If I treat this as a question in the literal sense, the answer is:

  1. Learn mootools.
  2. Learn jQuery.
  3. Write code to do it.
  4. If you get problems, ask and get help -- by posting your newly written jquery code in conjunction with the old code.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文