Javascript 编辑';由于自定义js文件,缺少的工具栏

Javascript 编辑';由于自定义js文件,缺少的工具栏,javascript,wordpress,editor,text-editor,wp-editor,Javascript,Wordpress,Editor,Text Editor,Wp Editor,我已经为主页上的旋转木马添加了一个自定义js文件cr scroll.js。 添加后,页面的编辑器工具栏已丢失。如果我删除了js文件,那么一切都正常 这个js文件有什么问题?任何帮助都将不胜感激。提前谢谢 编辑: wp_register_script('java1', get_template_directory_uri() . '/js/cr-scroll.js?version=4.2', array( 'jquery' )); wp_enqueue_script( 'java1' ); va

我已经为主页上的旋转木马添加了一个自定义js文件
cr scroll.js
。 添加后,页面的编辑器工具栏已丢失。如果我删除了js文件,那么一切都正常

这个js文件有什么问题?任何帮助都将不胜感激。提前谢谢

编辑:

wp_register_script('java1', get_template_directory_uri() . '/js/cr-scroll.js?version=4.2', array( 'jquery' ));
wp_enqueue_script( 'java1' );
var $k = jQuery.noConflict();
(function($k){
$k(document).ready(function($k) {
 $k.fn.make_carousel = function() {
    var speed = 0;
    var scroll = 0;
    var con = $k(this);
    var con_w = con.width();
    var max_scroll = con[0].scrollWidth - con.outerWidth();
    var prev_frame = new Date().getTime();
    con.on('mousemove', function(e) {
        var mouse_x = e.pageX - con.offset().left;
        var mouseperc = 100 * mouse_x / con_w;
        speed = mouseperc - 50;
    }).on ( 'mouseleave', function() {
        speed = 0;
    });

    function updatescroll() {
        var cur_frame = new Date().getTime();
        var time_elapsed = cur_frame - prev_frame;
        prev_frame = cur_frame;
        if (speed !== 0) {
            scroll += speed * time_elapsed / 50;
            if (scroll < 0) scroll = 0;
            if (scroll > max_scroll) scroll = max_scroll;
            con.scrollLeft(scroll);
        }
        window.requestAnimationFrame(updatescroll);
    }
    window.requestAnimationFrame(updatescroll);
}

$k("#carousel1").make_carousel();
$k("#carousel2").make_carousel();

function reset(){
    $k('.maincontent').find('*').removeAttr('class');
    document.getElementById('step1').setAttribute("class", "visible");
}
function back(){
    var previous_class = $k('.visible').data('previous');
    if(previous_class != ''){
        var current_class = $k('.visible').attr('id');
        document.getElementById(current_class).setAttribute("class","");
        document.getElementById(previous_class).setAttribute("class","visible");
    }
}
function show_next(current,next) {
    document.getElementById(current).setAttribute("class", "hidden");
    document.getElementById(next).setAttribute("class", "visible");
}

function show_hide(show_ele,hide_ele) {
    document.getElementById(show_ele).style.display = "block";
    document.getElementById(hide_ele).style.display = "none";
}
function load_after_sec(id) {
    count = 0;
    wordsArray = ["5", "4", "3", "2", "1"];
    var timerID = setInterval(function () {
        count++;
        if(count == 5){
            $k("#"+id).show();
            $k("#seconds_counter").hide();
            clearInterval(timerID);
        } else {
            $k("#num_sec").fadeOut(400, function () {
                $k(this).text(wordsArray[count % wordsArray.length]).fadeIn(400);
            });
        }                               
    }, 2000);
}
function showButton(){
    document.getElementById("btn_repeat").style.display='block';
}
});
})(jQuery);
我添加了带有以下代码的脚本:

wp_register_script('java1', get_template_directory_uri() . '/js/cr-scroll.js?version=4.2', array( 'jquery' ));
wp_enqueue_script( 'java1' );
var $k = jQuery.noConflict();
(function($k){
$k(document).ready(function($k) {
 $k.fn.make_carousel = function() {
    var speed = 0;
    var scroll = 0;
    var con = $k(this);
    var con_w = con.width();
    var max_scroll = con[0].scrollWidth - con.outerWidth();
    var prev_frame = new Date().getTime();
    con.on('mousemove', function(e) {
        var mouse_x = e.pageX - con.offset().left;
        var mouseperc = 100 * mouse_x / con_w;
        speed = mouseperc - 50;
    }).on ( 'mouseleave', function() {
        speed = 0;
    });

    function updatescroll() {
        var cur_frame = new Date().getTime();
        var time_elapsed = cur_frame - prev_frame;
        prev_frame = cur_frame;
        if (speed !== 0) {
            scroll += speed * time_elapsed / 50;
            if (scroll < 0) scroll = 0;
            if (scroll > max_scroll) scroll = max_scroll;
            con.scrollLeft(scroll);
        }
        window.requestAnimationFrame(updatescroll);
    }
    window.requestAnimationFrame(updatescroll);
}

$k("#carousel1").make_carousel();
$k("#carousel2").make_carousel();

function reset(){
    $k('.maincontent').find('*').removeAttr('class');
    document.getElementById('step1').setAttribute("class", "visible");
}
function back(){
    var previous_class = $k('.visible').data('previous');
    if(previous_class != ''){
        var current_class = $k('.visible').attr('id');
        document.getElementById(current_class).setAttribute("class","");
        document.getElementById(previous_class).setAttribute("class","visible");
    }
}
function show_next(current,next) {
    document.getElementById(current).setAttribute("class", "hidden");
    document.getElementById(next).setAttribute("class", "visible");
}

function show_hide(show_ele,hide_ele) {
    document.getElementById(show_ele).style.display = "block";
    document.getElementById(hide_ele).style.display = "none";
}
function load_after_sec(id) {
    count = 0;
    wordsArray = ["5", "4", "3", "2", "1"];
    var timerID = setInterval(function () {
        count++;
        if(count == 5){
            $k("#"+id).show();
            $k("#seconds_counter").hide();
            clearInterval(timerID);
        } else {
            $k("#num_sec").fadeOut(400, function () {
                $k(this).text(wordsArray[count % wordsArray.length]).fadeIn(400);
            });
        }                               
    }, 2000);
}
function showButton(){
    document.getElementById("btn_repeat").style.display='block';
}
});
})(jQuery);
My cs scroll.js:

wp_register_script('java1', get_template_directory_uri() . '/js/cr-scroll.js?version=4.2', array( 'jquery' ));
wp_enqueue_script( 'java1' );
var $k = jQuery.noConflict();
(function($k){
$k(document).ready(function($k) {
 $k.fn.make_carousel = function() {
    var speed = 0;
    var scroll = 0;
    var con = $k(this);
    var con_w = con.width();
    var max_scroll = con[0].scrollWidth - con.outerWidth();
    var prev_frame = new Date().getTime();
    con.on('mousemove', function(e) {
        var mouse_x = e.pageX - con.offset().left;
        var mouseperc = 100 * mouse_x / con_w;
        speed = mouseperc - 50;
    }).on ( 'mouseleave', function() {
        speed = 0;
    });

    function updatescroll() {
        var cur_frame = new Date().getTime();
        var time_elapsed = cur_frame - prev_frame;
        prev_frame = cur_frame;
        if (speed !== 0) {
            scroll += speed * time_elapsed / 50;
            if (scroll < 0) scroll = 0;
            if (scroll > max_scroll) scroll = max_scroll;
            con.scrollLeft(scroll);
        }
        window.requestAnimationFrame(updatescroll);
    }
    window.requestAnimationFrame(updatescroll);
}

$k("#carousel1").make_carousel();
$k("#carousel2").make_carousel();

function reset(){
    $k('.maincontent').find('*').removeAttr('class');
    document.getElementById('step1').setAttribute("class", "visible");
}
function back(){
    var previous_class = $k('.visible').data('previous');
    if(previous_class != ''){
        var current_class = $k('.visible').attr('id');
        document.getElementById(current_class).setAttribute("class","");
        document.getElementById(previous_class).setAttribute("class","visible");
    }
}
function show_next(current,next) {
    document.getElementById(current).setAttribute("class", "hidden");
    document.getElementById(next).setAttribute("class", "visible");
}

function show_hide(show_ele,hide_ele) {
    document.getElementById(show_ele).style.display = "block";
    document.getElementById(hide_ele).style.display = "none";
}
function load_after_sec(id) {
    count = 0;
    wordsArray = ["5", "4", "3", "2", "1"];
    var timerID = setInterval(function () {
        count++;
        if(count == 5){
            $k("#"+id).show();
            $k("#seconds_counter").hide();
            clearInterval(timerID);
        } else {
            $k("#num_sec").fadeOut(400, function () {
                $k(this).text(wordsArray[count % wordsArray.length]).fadeIn(400);
            });
        }                               
    }, 2000);
}
function showButton(){
    document.getElementById("btn_repeat").style.display='block';
}
});
})(jQuery);
var$k=jQuery.noConflict();
(功能(千美元){
$k(文件)。就绪(功能($k){
$k.fn.make_carousel=函数(){
var速度=0;
var=0;
var con=$k(本);
var con_w=con.width();
var max_scroll=con[0]。scrollWidth-con.outerWidth();
var prev_frame=new Date().getTime();
con.on('mousemove',函数(e){
var mouse_x=e.pageX-con.offset().左;
var mouseperc=100*mouse\u x/con\u w;
速度=鼠标器-50;
}).on('mouseleave',function(){
速度=0;
});
函数updatescroll(){
var cur_frame=new Date().getTime();
var时间=当前帧-上一帧;
前一帧=当前帧;
如果(速度!==0){
滚动+=速度*经过的时间/50;
如果(滚动<0)滚动=0;
如果(滚动>最大滚动)滚动=最大滚动;
相反,向左滚动(滚动);
}
window.requestAnimationFrame(updatescroll);
}
window.requestAnimationFrame(updatescroll);
}
$k(“旋转木马”)。制作旋转木马();
$k(“#旋转木马2”)。制作旋转木马();
函数重置(){
$k('.maincontent').find('*').removeAttr('class');
document.getElementById('step1').setAttribute(“类”,“可见”);
}
函数back(){
var previous_class=$k('.visible')。数据('previous');
如果(上一级!=''){
var current_class=$k('.visible').attr('id');
document.getElementById(当前_类).setAttribute(“类”,“类”);
getElementById(以前的_类).setAttribute(“类”,“可见”);
}
}
函数show_next(当前,下一个){
document.getElementById(当前).setAttribute(“类”,“隐藏”);
document.getElementById(下一个).setAttribute(“类”,“可见”);
}
函数show\u hide(show\u ele,hide\u ele){
document.getElementById(show_ele).style.display=“block”;
document.getElementById(hide_ele).style.display=“无”;
}
秒后功能加载(id){
计数=0;
单词数组=[“5”、“4”、“3”、“2”、“1”];
var timerID=setInterval(函数(){
计数++;
如果(计数=5){
$k(“#”+id).show();
$k(“#秒数计数器”).hide();
清除间隔(timerID);
}否则{
$k(“#num_sec”)。淡出(400,函数(){
$k(this.text)(wordsArray[count%wordsArray.length]).fadeIn(400);
});
}                               
}, 2000);
}
函数showButton(){
document.getElementById(“btn_repeat”).style.display='block';
}
});
})(jQuery);

这个部分是全宽度的,但是在包含了js之后,它是一个内部类,它有一些定义的宽度。

似乎您没有使用
wp\u enqueue\u脚本。在
functions.php
中添加此代码,然后重试

    function custom_scripts() {
        wp_register_script('java1', get_template_directory_uri() . '/js/cr-scroll.js', array( 'jquery' ));
        wp_enqueue_script( 'java1' );
    }
    add_action( 'wp_enqueue_scripts', 'custom_scripts' );

您正在使用哪个钩子添加脚本?你能发布你的cr-scroll.js代码吗?@George我已经编辑了我的问题,请检查。非常感谢。编辑器问题已经解决了,但由于那个js文件,定价页面的设计在一个部分发生了更改,现在还没有解决。
定价页面的
意思是在前端?我在首页上看不到这个问题。你能详细说明一下吗?
cr scroll.js
文件中的脚本错误。请登录控制台。非常感谢您的理解……这对我帮助很大。