0

Joomla 1.5 Web サイトを Joomla 2.5 に移行しました。

Joomla 1.5 Web サイトは Mootools 1.11 を使用しています。
Joomla 2.5 Web サイトは Mootools 1.4.5 を使用しています。
Web サイトには、annuary という名前の特定の機能が含まれています。

annuary には、Mootools 1.11 に基づくいくつかの JavaScript ファイルが必要です。
これらのファイルのいくつかの指示を Mootools 1.4.5 に適合させる必要があります。
これらの JavaScript ファイルの 1 つが Autocompleter.js です。
以下は Autocompleter.js からの抜粋です。

var Autocompleter = {};

Autocompleter.Base = new Class({

    ...

    initialize: function(el, options) {

        this.setOptions(options);
        this.element = $(el);
        this.build();
        this.observer = new Observer(this.element, this.prefetch.bind(this), $merge({
        delay: 400
        }, this.options.observerOptions));
        this.value = this.observer.value;
        this.queryValue = null;
    },

    ...

});

Autocompleter.Base.implement(new Events);

Autocompleter.Base.implement(new Options);

Autocompleter.Local = Autocompleter.Base.extend({

    ...

    initialize: function(el, tokens, options) {

        this.parent(el, options);
        this.tokens = tokens;
        if (this.options.filterTokens) this.filterTokens = this.options.filterTokens.bind(this);
    },

    ...

});

年次に関する次の JavaScript 命令が期待どおりに機能しないことに気付きました。

new Autocompleter.Local(idChamp, tabValues, {

    'delay': 100,
    'injectChoice': function(choice) {
        var el = new Element('li')
        .setHTML(this.markQueryValue(choice[0]))
        .adopt(new Element('span', {'class': 'example-info'}).setHTML(this.markQueryValue(choice[1])));
        el.inputValue = choice[0];
        this.addChoiceEvents(el).injectInside(this.choices);
    }
});

Autocompleter.Base の初期化関数が実行されます。
しかし、Autocompleter.Local の初期化関数はそうではありません。
誰かが私に理由を説明できますか?
この問題は Mootools 1.4.5 の使用が原因であると確信しています。

4

1 に答える 1

1

これは私を元に戻します...

1.2.5 では、クラスが大幅に改良されました。プロトタイプを実行してから実装/拡張を呼び出す代わりに、これらをミューテーターとして実行するようになりました

Autocompleter.Base = new Class({

    Implements: [Options, Events],

    initialize: function(el, options) {

        this.setOptions(options);
        this.element = $(el);
        this.build();
        this.observer = new Observer(this.element, this.prefetch.bind(this), $merge({
        delay: 400
        }, this.options.observerOptions));
        this.value = this.observer.value;
        this.queryValue = null;
    },

    ...

});

Autocompleter.Local = new Class({
    Extends: Autocompleter.Base
});

1.11 から 1.2.5 への移行に関するガイド/チュートリアルを読む必要があります。そして 1.2.5 は実際には今のところ良いリリースではなく、2.5 年前のものであり、https: //bugzilla.mozilla.org/show_bug.cgi?id=789036 のために現在 FireFox 18 で壊れています。

http://fragged.org/tutorial-write-a-small-content-slider-class-in-mootools-and-extend-it_1321.htmlなどのクラスの作成に関するチュートリアルを参照してください。

于 2013-01-16T15:46:45.107 に答える