Hello, my name is Rafa. I am new here. My problem brought me here and hopefully someone could help me out with that. I found an outdated javascript on my computer which i want to implement on my website.
Well, at the moment its working, but when i update my CMS, the homepage will not work anymore and in my google console, there appears an uncaught TypeError: e(…).addClass is not a function at this code line:
[code]$(‘#cubeTransition>div:eq(0)’).addClass(‘visible’);
Unfortunatly i cannot solve this. I tried to change the line like people suggested to similar errors in different forums, i tried different setups with my CMS, but no progress. Standalone, without CMS it works fine, also no error appears in the google console.
i post the full code here:
[code]
(function($) {
var length = $(‘#cubeTransition>div’).length,
current = 1,
next = 1,
outClass, inClass, onGoing = false;
$(‘#cubeTransition>div:eq(0)’).addClass(‘visible’);
for (i = 0; i < length; i++) {
var bullet = $(“<li></li>”);
if (i == 0) bullet.addClass(‘active’);
$(“#bullets”).append(bullet);
}
function openIndex(i) {
if (!onGoing && next != i) {
onGoing = true;
next = i
outClass = current > i ? ‘rotateCubeBottomOut’ : ‘rotateCubeTopOut’
inClass = current > i ? ‘rotateCubeBottomIn’ : ‘rotateCubeTopIn’;
show()
}
}
function trans(direction) {
if (!onGoing) {
onGoing = true;
if (direction == ‘up’) {
next = current > 1 ? current – 1 : length;
outClass = ‘rotateCubeBottomOut’;
inClass = ‘rotateCubeBottomIn’;
} else {
next = current < length ? current + 1 : 1;
outClass = ‘rotateCubeTopOut’;
inClass = ‘rotateCubeTopIn’;
}
show();
}
}
function show() {
$(‘#cubeTransition>div:eq(‘ + (next – 1) + ‘)’).addClass(‘visible’);
$(‘#cubeTransition>div:eq(‘ + (current – 1) + ‘)’).addClass(outClass);
$(‘#cubeTransition>div:eq(‘ + (next – 1) + ‘)’).addClass(inClass);
$(‘#bullets>li:eq(‘ + (current – 1) + ‘)’).removeClass(‘active’);
$(‘#bullets>li:eq(‘ + (next – 1) + ‘)’).addClass(‘active’);
animationOut(current – 1)
setTimeout(function() {
$(‘#cubeTransition>div:eq(‘ + (current – 1) + ‘)’).removeClass(‘visible’);
}, 500)
setTimeout(function() {
$(‘#cubeTransition>div:eq(‘ + (current – 1) + ‘)’).removeClass(outClass);
$(‘#cubeTransition>div:eq(‘ + (next – 1) + ‘)’).removeClass(inClass);
animationIn(next – 1)
current = next;
onGoing = false;
}, 600)
}
$(document).ready(
function() {
//for scroll by mouse or MAC track pad
var indicator = new WheelIndicator({
callback: function(e){
if (e.direction == ‘up’) {
trans(‘up’)
} else {
trans(‘down’)
}
}
});
indicator.getOption(‘preventMouse’); // true
//update this instead of mousewheel.js
//in issuses#2 a friend want to use this plugin on MAC track pad
$(document).keydown(function(e) {
if (e.keyCode == 38 || e && e.keyCode == 37) {
trans(‘up’)
}
if (e.keyCode == 39 || e && e.keyCode == 40) {
trans(‘down’)
}
});
$(document).swipe({
swipe: function(event, direction, distance, duration, fingerCount) {
if (direction == “up”) {
trans(‘down’)
} else if (direction == “down”) {
trans(‘up’)
}
}
});
$(‘#bullets>li’).on(‘click’, function() {
openIndex($(this).index() + 1);
});
});
})(jQuery);
would be very cool if someone solves this. my solution would be in changing CMS or even without, but that is not a very timesaving solution.
thanks in advance