我使用滑块在的Joomla滚动图像,但我的JS在火狐狸工作正常,但它显示未捕获未捕获的SyntaxError:意外的标记=
语法错误:
Unexpected token = error in chrome
我的代码是:
var $j = jQuery.noConflict();
$j(document).ready(function() {
function animateThumbs(direction, $item, val, opacity) {
var ani = {
opacity: opacity
};
ani[ getMarginProperty() ] = val;
if (direction == 'next') {
var x1 = '.t1',
x2 = '.t2, .t4',
x3 = '.t3, .t5, .t7',
x4 = '.t6, .t8',
x5 = '.t9';
} else {
var x1 = '.t9',
x2 = '.t6, .t8',
x3 = '.t3, .t5, .t7',
x4 = '.t2, .t4',
x5 = '.t1';
}
$j(x1, $item).delay(_duration * 0 ).animate(ani, _duration);
$j(x2, $item).delay(_duration * 0.25).animate(ani, _duration);
$j(x3, $item).delay(_duration * 0.5 ).animate(ani, _duration);
$j(x4, $item).delay(_duration * 0.75).animate(ani, _duration);
$j(x5, $item).delay(_duration * 1 ).animate(ani, _duration);
}
function getMarginProperty() {
return (_orientation == 'horizontal') ? 'marginLeft' : 'marginTop';
}
function getMargin(direction) {
var margin = ($window[ (_orientation == 'horizontal') ? 'width' : 'height' ]()/2) + 210
if (direction == 'next')
{
margin = -margin;
}
return margin;
}
var $window = $j(window),
$inner = $j('#inner'),
$carousel = $j('#carousel');
var _orientation = 'horizontal',
_duration = 500,
_animating = false;
$inner.show();
$carousel.carouFredSel({
width: '100%',
height: '100%',
circular: false,
infinite: false,
direction: 'right',
items: 1,
auto: false,
scroll: {
fx: 'none',
timeoutDuration: 500,
conditions: function(direction) {
_animating = true;
if ($carousel.hasClass('prepared'))
{
$carousel.removeClass('prepared');
return true;
}
$carousel.addClass('prepared');
animateThumbs(direction, $carousel.children().first(), getMargin(direction), 0);
setTimeout(
function() {
$carousel.trigger(direction);
}, _duration + 300
);
return false;
},
onBefore: function(data) {
var direction = data.scroll.direction;
var css = {
opacity: 0
};
css[ getMarginProperty() ] = -getMargin(direction);
$j('img', data.items.visible).css(css);
animateThumbs(direction, data.items.visible, 0, 1);
},
onAfter: function(data) {
data.items.old.children().css({
'marginLeft': 0,
'marginTop': 0
});
setTimeout(
function() {
_animating = false;
}, _duration + 800
);
}
}
});
$carousel.trigger("currentPosition", function(pos=<?php echo 1;?>) {
console.log(pos);
var posi = pos;
});
$j('#left').click(function() {
if (_animating) {
return false;
}
var direction = this.id,
scroll = 'prev',
newOrientation = (direction == 'up' || direction == 'down') ? 'vertical' : 'horizontal';
if (_orientation != newOrientation) {
_orientation = newOrientation;
$inner.toggleClass('horizontal').toggleClass('vertical');
$carousel.trigger('configuration', [ 'direction', direction ]);
}
$carousel.trigger("currentPosition", function(pos=2) {
//console.log(pos);
if(pos > 0 && pos <= 1)
{
$carousel.trigger(scroll);
}
});
return false;
});
$j('#right').click(function() {
if (_animating) {
return false;
}
var direction = this.id,
scroll = 'next',
newOrientation = (direction == 'up' || direction == 'down') ? 'vertical' : 'horizontal';
if (_orientation != newOrientation) {
_orientation = newOrientation;
$inner.toggleClass('horizontal').toggleClass('vertical');
$carousel.trigger('configuration', [ 'direction', direction ]);
}
$carousel.trigger("currentPosition", function(pos) {
//console.log(pos);
if(pos < <?php echo $poscount-1; ?>)
{
$carousel.trigger(scroll);
}
});
return false;
});
$j('a[href=#]').click(function(){
return false;
});
});
任何人都可以告诉我最新出了什么问题吗?
感谢
代码几十行,找一个语法错误,甚至没有行号。我不这么认为。 – 2014-01-17 07:19:02
你并不真正希望我们在这段代码片段中看到每一个“=”的出现,是吗?请指出发生错误的位置。任何它似乎第一行代码未命中4个空格被渲染为代码... – virtualnobi
使用firebug来查看linenumber。 – Jai