Skip to content

Instantly share code, notes, and snippets.

@oguzhanaslan
oguzhanaslan / x.js
Created May 11, 2014 15:39
Clear form fields - focus
$('textarea, input:text').bind('focus click', function(){
if (this.value == this.defaultValue) {
this.value = '';
}
}).bind('blur', function(){
if (this.value == '') {
this.value = this.defaultValue;
}
});
@oguzhanaslan
oguzhanaslan / app.js
Created May 11, 2014 15:36
Check if page scroll is at bottom
$('#topScroll').hide();
$(window).scroll(function(){
if ( document.body.scrollHeight - $(this).scrollTop() <= $(this).height() ){
$('#topScroll').show();
} else {
$('#topScroll').hide();
}
});
<a href="http://www.facebook.com/sharer.php?u=[URL-TO-SHARE]">Share on Facebook</a>
<a href="http://twitter.com/share?text=[TEXT]&url=[URL-TO-SHARE]">Tweet</a>
<a href="https://plus.google.com/share?url=[URL-TO-SHARE]">Google+ share</a>
@oguzhanaslan
oguzhanaslan / gist:10524828
Created April 12, 2014 08:34
ie css hack
/*
* Property prefix hacks
*/
/* IE6 only - any combination of these characters */
_ - £ ¬ ¦
/* IE6/7 only - any combination of these characters */
@oguzhanaslan
oguzhanaslan / ResizingImageJquery.js
Last active February 23, 2020 08:08
Resizing image with jQuery
$(document).ready(function(){
$('.img-responsive').each(function() {
var maxWidth = 180; // Max width for the image
var maxHeight = 3000; // Max height for the image
var ratio = 0; // Used for aspect ratio
var width = $(this).width(); // Current image width
var height = $(this).height(); // Current image height
// Check if the current width is larger than the max