Skip to content

Instantly share code, notes, and snippets.

Barlas Apaydin barlas

Block or report user

Report or block barlas

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@barlas
barlas / ready-initialise.js
Last active Aug 29, 2015
jQuery - Better way to initialise function on document ready.
View ready-initialise.js
$(function() {
functionsss.init();
});
functionsss = {
init: function() {
}
};
@barlas
barlas / ready-resize-func.js
Last active Aug 29, 2015
jQuery - Responsive return function triggering on document ready and window resize.
View ready-resize-func.js
var windowW = $(window).width(),
windowH = $(window).height();
var resizeThread = 0;
function responsiveReturn() {
clearTimeout(resizeThread);
windowW = $(window).width();
windowH = $(window).height();
@barlas
barlas / ready-detection-var.js
Last active Aug 29, 2015
javascript - Browser, mobile and tablet device detection on boolean variables.
View ready-detection-var.js
var isChrome = navigator.userAgent.indexOf('Chrome') > -1;
var isFireFox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
var isSafari = navigator.userAgent.indexOf('Safari') > -1;
if ((isChrome)&&(isSafari)) {isSafari=false;}
var isIE = navigator.appName.indexOf('Internet Explorer')!=-1;
var isIE7 = navigator.appVersion.indexOf("MSIE 7.") != -1;
var isIE8 = navigator.appVersion.indexOf("MSIE 8.") != -1;
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ? isTabletMobile = true : isTabletMobile = false;
/iPad/i.test(navigator.userAgent) ? isTablet = true : isTablet = false;
/Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ? isMobile = true : isMobile = false;
@barlas
barlas / ready-hash-var.js
Last active Aug 29, 2015
javascript - Detecting hash on browser's address bar.
View ready-hash-var.js
var currentUrl = top.location.href;
var currentHash = window.location.hash;
if ( currentHash.length > 0 ) {
var stripHash = currentHash.replace('#!/','');
}
@barlas
barlas / ready-disable-scroll.js
Last active Aug 29, 2015
jQuery - Disable browser's scrolling method temporarily.
View ready-disable-scroll.js
// source: http://stackoverflow.com/a/4770179/1428241
var keys = [37, 38, 39, 40];
function preventDefault(e) {
e = e || window.event;
if (e.preventDefault)
e.preventDefault();
e.returnValue = false;
}
function keydown(e) {
@barlas
barlas / ready-hash-history.js
Last active Aug 29, 2015 — forked from sstephenson/back_forward.js
javascript - Detecting hash change from browser's back and foward buttons.
View ready-hash-history.js
var detectBackOrForward = function(onBack, onForward) {
hashHistory = [window.location.hash];
historyLength = window.history.length;
return function() {
var hash = window.location.hash, length = window.history.length;
if (hashHistory.length && historyLength == length) {
if (hashHistory[hashHistory.length - 2] == hash) {
hashHistory = hashHistory.slice(0, -1);
onBack();
@barlas
barlas / ready-fb-twt-share-func.js
Last active Aug 29, 2015
jQuery - Facebook and Twitter share functions compatible with utf-8 charset.
View ready-fb-twt-share-func.js
$('.fb_share').click(function() {
fbShare('www.google.com','Baslik');
return false;
});
$('.twt_share').click(function() {
twtShare('Aciklama');
});
function twtShare(a){
window.open('http://twitter.com/home?status='+encodeURIComponent(a),'twitter','toolbar=0,status=0,width=650,height=436');
return false
@barlas
barlas / ready-scrolling-func.js
Created Nov 27, 2014
jQuery - Detecting user's scrolling down or up.
View ready-scrolling-func.js
var currentScroll = 0;
$(window).scroll(function() {
var nextScroll = $(this).scrollTop();
if ( nextScroll > currentScroll ) {// scroll down
}else{// scroll up
}
@barlas
barlas / ready-slider.js
Last active Aug 29, 2015
jQuery - Simple slider with toggleclass method. Animations can be defined from css.
View ready-slider.js
// Sample: http://stackoverflow.com/questions/12608356/how-to-build-simple-jquery-image-slider-with-sliding-or-opacity-effect/12608357#12608357
var $selector = $(selector);
var $btnPrev = $selector.find('.tri-prev');
var $btnNext = $selector.find('.tri-next');
var $slides = $selector.find('.slides li');
var lastIndex = $slides.length-1;
var index;
@barlas
barlas / ready-placeholder.js
Last active Aug 29, 2015
jQuery - Placeholder fix for older browsers.
View ready-placeholder.js
$('*[placeholder]').val(function () { return $(this).prop('placeholder')});
$(document).on('focus', '[placeholder]',function(){
$(this).val() == $(this).prop('placeholder') ? $(this).val('') : '';
});
$(document).on('blur', '[placeholder]',function(){
$(this).val() == '' ? $(this).val($(this).prop('placeholder')) : '';
});
You can’t perform that action at this time.