0

ローカライズされた JSON エンコード オブジェクトがあり、最終的にオプションの JS ファイルに入力します。オプションの期待される出力は次のとおりです (デフォルトと、探している「タイプ」の説明):

jQuery(window).load(function() {
    jQuery('.flexslider').flexslider({
        animation: "fade",              //String: Select your animation type, "fade" or "slide"
        slideDirection: "horizontal",   //String: Select the sliding direction, "horizontal" or "vertical"
        slideshow: true,                //Boolean: Animate slider automatically
        slideshowSpeed: 7000,           //Integer: Set the speed of the slideshow cycling, in milliseconds
        animationDuration: 600,         //Integer: Set the speed of animations, in milliseconds
        directionNav: true,             //Boolean: Create navigation for previous/next navigation? (true/false)
        controlNav: true,               //Boolean: Create navigation for paging control of each clide? Note: Leave true for manualControls usage
        keyboardNav: true,              //Boolean: Allow slider navigating via keyboard left/right keys
        mousewheel: false,              //Boolean: Allow slider navigating via mousewheel
        prevText: "Previous",           //String: Set the text for the "previous" directionNav item
        nextText: "Next",               //String: Set the text for the "next" directionNav item
        pausePlay: false,               //Boolean: Create pause/play dynamic element
        pauseText: 'Pause',             //String: Set the text for the "pause" pausePlay item
        playText: 'Play',               //String: Set the text for the "play" pausePlay item
        randomize: false,               //Boolean: Randomize slide order
        slideToStart: 0,                //Integer: The slide that the slider should start on. Array notation (0 = first slide)
        animationLoop: true,            //Boolean: Should the animation loop? If false, directionNav will received "disable" classes at either end
        pauseOnAction: true,            //Boolean: Pause the slideshow when interacting with control elements, highly recommended.
        pauseOnHover: false,            //Boolean: Pause the slideshow when hovering over slider, then resume when no longer hovering
        controlsContainer: "",          //Selector: Declare which container the navigation elements should be appended too. Default container is the flexSlider element. Example use would be ".flexslider-container", "#container", etc. If the given element is not found, the default action will be taken.
        manualControls: "",             //Selector: Declare custom control navigation. Example would be ".flex-control-nav li" or "#tabs-nav li img", etc. The number of elements in your controlNav should match the number of slides/tabs.
        start: function(){},            //Callback: function(slider) - Fires when the slider loads the first slide
        before: function(){},           //Callback: function(slider) - Fires asynchronously with each slider animation
        after: function(){},            //Callback: function(slider) - Fires after each slider animation completes
        end: function(){}               //Callback: function(slider) - Fires when the slider reaches the last slide (asynchronous)
    });
});

JSON エンコードされたオブジェクトの現在の HTML 出力は次のとおりです。

/*<![
    CDATA[
        */varflexslider_vars=[

        ];flexslider_vars={
            "js_animation": "fade",
            "js_slide_direction": "horizontal",
            "js_slideshow": "1",
            "js_slideshow_speed": "7000",
            "js_animation_duration": "600",
            "js_direction_nav": "1",
            "js_control_nav": "1",
            "js_keyboard_nav": "1",
            "js_mousewheel": null,
            "js_prev_text": "Prevous",
            "js_next_text": "Next",
            "js_pause_play": null,
            "js_pause_text": "Pause",
            "js_play_text": "Play",
            "js_randomize": null,
            "js_slide_start": "0",
            "js_animation_loop": "1",
            "js_pause_on_action": "1",
            "js_pause_on_hover": null,
            "js_controls_container": "",
            "js_manual_controls": "",
            "js_start_function": "function(){}",
            "js_before_function": "function(){}",
            "js_after_function": "function(){}",
            "js_end_function": "function(){}"
        };/*
    ]
]>*/

そして、これは私が現在(そして失敗して)これらのオプションをJSファイルに追加する方法です:

jQuery(window).load(function() {
    jQuery('.flexslider').flexslider({
        animation: flexslider_vars.js_animation,              //String: Select your animation type, "fade" or "slide"
        slideDirection: flexslider_vars.js_slide_direction,   //String: Select the sliding direction, "horizontal" or "vertical"
        slideshow: flexslider_vars.js_slideshow,                //Boolean: Animate slider automatically
        slideshowSpeed: flexslider_vars.js_slideshow_speed,           //Integer: Set the speed of the slideshow cycling, in milliseconds
        animationDuration: flexslider_vars.js_animation_duration,         //Integer: Set the speed of animations, in milliseconds
        directionNav: flexslider_vars.js_direction_nav,             //Boolean: Create navigation for previous/next navigation? (true/false)
        controlNav: flexslider_vars.js_control_nav,               //Boolean: Create navigation for paging control of each clide? Note: Leave true for manualControls usage
        keyboardNav: flexslider_vars.js_keyboard_navjs_mousewheel,              //Boolean: Allow slider navigating via keyboard left/right keys
        mousewheel: flexslider_vars.js_mousewheel,              //Boolean: Allow slider navigating via mousewheel
        prevText: flexslider_vars.js_prev_text,           //String: Set the text for the "previous" directionNav item
        nextText: flexslider_vars.js_next_text,               //String: Set the text for the "next" directionNav item
        pausePlay: flexslider_vars.js_pause_play,               //Boolean: Create pause/play dynamic element
        pauseText: flexslider_vars.js_pause_text,             //String: Set the text for the "pause" pausePlay item
        playText: flexslider_vars.js_play_text,               //String: Set the text for the "play" pausePlay item
        randomize: flexslider_vars.js_randomize,               //Boolean: Randomize slide order
        slideToStart: flexslider_vars.js_slide_start,                //Integer: The slide that the slider should start on. Array notation (0 = first slide)
        animationLoop: flexslider_vars.js_animation_loop,            //Boolean: Should the animation loop? If false, directionNav will received "disable" classes at either end
        pauseOnAction: flexslider_vars.js_pause_on_action,            //Boolean: Pause the slideshow when interacting with control elements, highly recommended.
        pauseOnHover: flexslider_vars.js_pause_on_hover,            //Boolean: Pause the slideshow when hovering over slider, then resume when no longer hovering
        controlsContainer: flexslider_vars.js_controls_container,          //Selector: Declare which container the navigation elements should be appended too. Default container is the flexSlider element. Example use would be ".flexslider-container", "#container", etc. If the given element is not found, the default action will be taken.
        manualControls: flexslider_vars.js_manual_controls,             //Selector: Declare custom control navigation. Example would be ".flex-control-nav li" or "#tabs-nav li img", etc. The number of elements in your controlNav should match the number of slides/tabs.
        start: flexslider_vars.js_start_function,            //Callback: function(slider) - Fires when the slider loads the first slide
        before: flexslider_vars.js_before_function,           //Callback: function(slider) - Fires asynchronously with each slider animation
        after: flexslider_vars.js_after_function,            //Callback: function(slider) - Fires after each slider animation completes
        end: flexslider_vars.js_end_function              //Callback: function(slider) - Fires when the slider reaches the last slide (asynchronous)
    });
});

したがって、問題はオプション自体を呼び出すことではなく (正常に動作するようです)、JS ファイルの必要な値に基づいて実際の出力 (文字列、ブール値、整数など) を変更しています。そのせいでずるいスクワットをしている。正しい方向へのナッジをいただければ幸いです。ありがとう!

4

0 に答える 0