Last active
October 19, 2016 16:32
-
-
Save tiagodealmeida/d76493277ef62b1afff528780d1a844c to your computer and use it in GitHub Desktop.
.js for task 2.7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p = | |
/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js = | |
d.createElement(s);js.id=id;js.src=p+ | |
'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore | |
(js,fjs);}}(document, 'script', 'twitter-wjs'); | |
(function(d, s, id) { | |
var js, fjs = d.getElementsByTagName(s)[0]; | |
if (d.getElementById(id)) return;js = | |
d.createElement(s); js.id = id;js.src = | |
"//connect.facebook.net/en_GB/sdk.js#xfbml=1&version=v2.8"; | |
fjs.parentNode.insertBefore(js, fjs); | |
}(document, 'script', 'facebook-jssdk')); | |
//document ready | |
$(document).ready(function(){ | |
//smooth scrolling | |
var $root = $('html, body'); | |
$('.navbar-nav a').click(function() { | |
var href = $.attr(this, 'href'); | |
$root.animate({ | |
scrollTop: $(href).offset().top | |
}, 500, function () { | |
window.location.hash = href; | |
}); | |
return false; | |
}); | |
//stellar | |
$.stellar(); | |
//tooltips | |
$(function () { | |
$('#item1').tooltip(); | |
}); | |
$(function () { | |
$('[data-toggle="tooltip"]').tooltip(); | |
}); | |
//contact form | |
//submit button | |
$("#submitButton").on("click", function () { | |
var comment = $("#message-box").val(); | |
if(comment != ""){ | |
$("visible-comment").html(comment); | |
console.log("comment"); | |
$("#message-box").hide(); | |
} | |
else { | |
$("#message-box").css("border", "2px solid red"); | |
} | |
}); | |
//email red background | |
$("#email").css("background", "pink"); | |
}); | |
//keyup | |
$("#message-box").on("keyup", function() { | |
console.log("keyup happened"); | |
var charCount = $("#message-box").val().length; | |
console.log(charCount); | |
$("#char-count").html(charCount); | |
if(charCount > 9) { | |
$("#char-count").css("color", "green"); | |
} | |
else { | |
$("#char-count").css("color", "red"); | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment