After I upload an js file on my server through FTP none of the functions are executed and I'm getting this error:
Uncaught SyntaxError: Unexpected identifier
When I check to see the code everything is messed up, all the code is on one line something like this:
$(function(){ var $document = $(document), $element = $('.navbar-fixed-top'), className = 'hasScrolled'; $document.scroll(function() { $element.toggleClass(className, $document.scrollTop() >= 50); }); $('#home').parallax("60%", 0.7); $('#services').parallax("60%", 0.7); $('#skills').parallax("60%", 0.2); $('#testimonials').parallax("60%", 0.3); }); $(window).load(function() { $('#portfolio-slider').flexslider({ animation: "fade", directionNav: true, useCSS: false, controlNav: false, }); }); var url ='img/icons.svg'; var c=new XMLHttpRequest(); c.open('GET', url, false); c.setRequestHeader('Content-Type', 'text/xml'); c.send(); document.body.insertBefore(c.responseXML.firstChild, document.body.firstChild) $(document).ready(function() { $('.portfolio-item').hover(function(){ $(this).find(".caption").fadeIn(500) },function(){ $(this).find(".caption").fadeOut(500) }) $( ".search-btn" ).click(function() { $( "input.filter__search" ).show( "slow" ); e.preventDefault(); }); var touch = Modernizr.touch, badIE = $('html').hasClass('lt-ie10'); $('.img-holder').imageScroll({ imageAttribute: (touch === true) ? 'image-mobile' : 'image', parallax: !badIE, coverRatio: 0.8, container: ".bg-portfolio", touch: touch }); $('.tabs-blog').tabslet({ mouseevent: 'click', attribute: 'href', animation: true }); $('.tabs-testimonials').tabslet({ mouseevent: 'click', attribute: 'href', animation: true, autorotate: true, delay: 9000 }); }); $(window).load(function() { $('.flexslider').flexslider({ animation: "fade", slideshow:false, directionNav: false }); var mySwiper = $('.swiper-container').swiper({ mode:'horizontal', loop: false, freeMode: true, freeModeFluid: true, grabCursor: true, autoplay: 5000, autoplayDisableOnInteraction: true, calculateHeight: true, resizeReInit: true, scrollbar: { container : '.swiper-scrollbar', draggable : true, hide: false, snapOnRelease: true } }); }); $(document).ready(function(){ $('.tabs').tabslet({ mouseevent: 'click', attribute: 'href', animation: true, autorotate: true, delay: 9000 }); $('.venobox').venobox(); }); new Share(".social-share", { networks: { facebook: { app_id: "abc123" } }, ui: { flyout: 'bottom center', button_background: 'none', button_color:'#fff' });
Which is very weird because in my editor (Sublime Text 2) the code is organized properly.
Here is the code:
$.scrollIt ({
upKey: 38,
downKey: 40,
scrollTime: 600,
activeClass: 'active',
onPageChange: null,
topOffset: -40
});
$(function(){
var $document = $(document),
$element = $('.navbar-fixed-top'),
className = 'hasScrolled';
$document.scroll(function() {
$element.toggleClass(className, $document.scrollTop() >= 50);
});
$('#home').parallax("60%", 0.7);
$('#services').parallax("60%", 0.7);
$('#skills').parallax("60%", 0.2);
$('#testimonials').parallax("60%", 0.3);
});
$(window).load(function() {
$('#portfolio-slider').flexslider({
animation: "fade",
directionNav: true,
useCSS: false,
controlNav: false,
});
});
var url ='img/icons.svg';
var c=new XMLHttpRequest(); c.open('GET', url, false); c.setRequestHeader('Content-Type', 'text/xml'); c.send();
document.body.insertBefore(c.responseXML.firstChild, document.body.firstChild)
$(document).ready(function() {
$('.portfolio-item').hover(function(){
$(this).find(".caption").fadeIn(500)
},function(){
$(this).find(".caption").fadeOut(500)
})
$( ".search-btn" ).click(function() {
$( "input.filter__search" ).show( "slow" );
e.preventDefault();
});
var touch = Modernizr.touch,
badIE = $('html').hasClass('lt-ie10');
$('.img-holder').imageScroll({
imageAttribute: (touch === true) ? 'image-mobile' : 'image',
parallax: !badIE,
coverRatio: 0.8,
container: ".bg-portfolio",
touch: touch
});
$('.tabs-blog').tabslet({
mouseevent: 'click',
attribute: 'href',
animation: true
});
$('.tabs-testimonials').tabslet({
mouseevent: 'click',
attribute: 'href',
animation: true,
autorotate: true,
delay: 9000
});
});
$(window).load(function() {
$('.flexslider').flexslider({
animation: "fade",
slideshow:false,
directionNav: false
});
var mySwiper = $('.swiper-container').swiper({
mode:'horizontal',
loop: false,
freeMode: true,
freeModeFluid: true,
grabCursor: true,
autoplay: 5000,
autoplayDisableOnInteraction: true,
calculateHeight: true,
resizeReInit: true,
scrollbar: {
container : '.swiper-scrollbar',
draggable : true,
hide: false,
snapOnRelease: true
}
});
});
$(document).ready(function(){
$('.tabs').tabslet({
mouseevent: 'click',
attribute: 'href',
animation: true,
autorotate: true,
delay: 9000
});
$('.venobox').venobox();
});
new Share(".social-share", {
networks: {
facebook: {
app_id: "abc123"
}
},
ui: {
flyout: 'bottom center',
button_background: 'none',
button_color:'#fff'
});
If I'm testing it on Firefox I'm getting this error:
SyntaxError: missing ; before statement
and the code looks messy. What can be wrong ? Is there a JavaScript issue? Is it server related ? Because if I'm testing it locally on Firefox the code looks like in the text editor ( not messy) and receive a different error:
SyntaxError: missing } after property list
UPDATE After I compared the file on the web server with the file from my local machine I've noticed that the file on the web server is missing this:
$.scrollIt ({
upKey: 38,
downKey: 40,
scrollTime: 600,
activeClass: 'active',
onPageChange: null,
topOffset: -40
});
How can this happen?
