2

theme.js ファイルに関数があります

 $('.open_copy').click(function(){
        var that = $(this);
        var copy = that.prev();

        that.parents('.asset').find('.cover').click();
        copy.css('opacity', 0).show();
        if (copy.children('.copy_content').data('jsp')) {
            copy.children('.copy_content').data('jsp').destroy();
        }
        var height = copy.children('.copy_content').css({height: ''}).height();

        if (height < that.parents('.asset').height() - 37) {
            var top = (that.parents('.asset').height() - height)/2;
            top = top < 37 ? 37 : top;
            copy.children('.copy_content').css({'margin-top': top});
        } else {
            copy.children('.copy_content').css({'margin-top': '', height: that.parents('.asset').height() - 37}).jScrollPane();
        }

        if (!that.parents('.asset').find('.close_copy').length) {
            that.prev().append('<a href="#" class="close_copy">Close</a>');
        }

        copy.animate({ 'opacity' : 1 }, 500);

        that.fadeOut(500);
        return false;
    });

不透明度の値を 0.9 に変更する必要がありますが、theme.js ファイルにアクセスできません。HTMLページに関数を追加して、この関数を変更/変更する方法はありますか?

copy.animate({ 'opacity' : 1 }, 500);
4

2 に答える 2

3

はい。コードが設定するクリック ハンドラを削除してから、1=>の0.9変更を除いて同一のコードを使用して独自のハンドラを追加できます。

そのコードのクリック ハンドラー (およびその他すべて) を削除するには、次を使用しますoff

$('.open_copy').off('click');

...そしてもちろん、独自の新しいclickハンドラーを追加します。

したがって、合計すると、次のコードが必要になります (を含むタグの、このコードはそのコードの後に​​実行されます)。scripttheme.js

$('.open_copy').off('click').click(function(){ // <== Changed
    var that = $(this);
    var copy = that.prev();

    that.parents('.asset').find('.cover').click();
    copy.css('opacity', 0).show();
    if (copy.children('.copy_content').data('jsp')) {
        copy.children('.copy_content').data('jsp').destroy();
    }
    var height = copy.children('.copy_content').css({height: ''}).height();

    if (height < that.parents('.asset').height() - 37) {
        var top = (that.parents('.asset').height() - height)/2;
        top = top < 37 ? 37 : top;
        copy.children('.copy_content').css({'margin-top': top});
    } else {
        copy.children('.copy_content').css({'margin-top': '', height: that.parents('.asset').height() - 37}).jScrollPane();
    }

    if (!that.parents('.asset').find('.close_copy').length) {
        that.prev().append('<a href="#" class="close_copy">Close</a>');
    }

    copy.animate({ 'opacity' : 0.9 }, 500);  // <== Changed

    that.fadeOut(500);
    return false;
});

副作用を確認する必要があります (たとえば、click上記のコードではそれらも削除されるため、これらの要素にハンドラーを設定する他のコードがあるかどうか)。

于 2013-05-09T17:14:30.403 に答える
0

Javascript は、変数とメソッドのオーバーライドをサポートします。Theme.js ファイルのインポート後に、オーバーライドする JS スクリプトを宣言する必要があります。そのため、必要な値のみを変更して、その関数を正確にコピー/貼り付けることができます。

その関数はイベント バインドであるため、最初に onclick イベントのバインドを解除する必要がある場合があることに注意してください。

于 2013-05-09T17:17:30.693 に答える