Skip to content

Instantly share code, notes, and snippets.

@arkadylukashov
arkadylukashov / tiny-placeholder.js
Created September 17, 2012 06:36
jqurey placeholder function
/** > placeholderize ['placeholdered' <- класс когда текст в инпуте из плейсхолдера] */
(function($) {
var activeClass = 'placeholdered';
$('[data-placeholder]').each(function(i) {
var placeholder = $(this).data('placeholder');
if (this.value.length == 0) {
this.value = placeholder;
$(this).addClass(activeClass)
}
$(this)
@arkadylukashov
arkadylukashov / input.clearize.js
Created October 25, 2012 05:23
input clearize (a11.fixed)
/** > inputClearize (Умная очистка инпутов) [применяется для всех инпутов, у которых есть аттрибут rel, равный 'cleared'][Также должен рядом по DOM быть расположен элемент с классом 'clearInput' для опустошения value инпута] @link https://gist.github.com/3950536 */
(function($){
var $e = $('input[rel~="cleared"]')
$e.on('keyup', function(){
var proxy = this,
value = this.value,
isPlace = $(this).data('placeholder') || false,
onClicker = $( $(this).siblings('.clearInput') ),
visibilityValue = ((value.length > 0 && !isPlace) || (value.length !== isPlace.length)) ? 'visible' : 'hidden';
onClicker.css({visibility: visibilityValue})
@arkadylukashov
arkadylukashov / uppanel.js
Created October 29, 2012 02:39
upPanelScroll
(function($){
$.fn.upPanel = function(options) {
var
settings = $.extend({
fade : false, // int, etc;
speed : 300, // up scroll speed
waterline : 600, // 'auto', 'formula'
@arkadylukashov
arkadylukashov / jshortcut.js
Created November 6, 2012 08:48
Simple Shortcutter
$.shortcut = function(combination, callback) {
$(document).on("keydown", function(e){
var combo = combination.split('+'),
eventKey = combo[combo.length-1],
primary = combo[0] == 'ctrl' ? e.ctrlKey: combo[0] == 'shift' ? e.shiftKey : e.altKey;
if(e.keyCode == eventKey.toUpperCase().charCodeAt(0) && primary) {
e.preventDefault();
callback.apply(this);
}
});
@arkadylukashov
arkadylukashov / jFadeToggle.js
Created November 6, 2012 08:55
Fade Toggler
$.fn.fadeToggle = function(speed, callback, important) {
return this.each(function() {
$(this)[ important ? ( important == 'show' ? 'fadeIn' : 'fadeOut') : ( $(this).is(':visible') ? 'fadeOut' : 'fadeIn' ) ](speed, callback);
});
}
(function ($) {
$.fn.liveDraggable = function (opts) {
this.live("mouseover", function() {
if (!$(this).data("init")) {
$(this).data("init", true).draggable(opts);
}
});
return $();
};
}(jQuery));
@arkadylukashov
arkadylukashov / jquery.fullscreen.js
Created December 19, 2012 04:01
Simple jQuery element based Fullscreen API wrapper
(function($) {
$.fn.fullscreen = function(options) {
var settings = $.extend({
to: false,
exit: 'Normal size',
onScreenChange: $.noop,
onFail: $.noop
},options);
@arkadylukashov
arkadylukashov / jquery.preload.js
Created December 19, 2012 09:45
Simple image preloader uses jQuery
(function($) {
$.fn.preload = function(forPreload, options) {
var settings = $.extend({
debug : false,
percentage : {
textCnt : '',
lineCnt : ''
},
/**
* Provides requestAnimationFrame in a cross browser way.
* @author paulirish / http://paulirish.com/
*/
if ( !window.requestAnimationFrame ) {
window.requestAnimationFrame = ( function() {
return window.webkitRequestAnimationFrame ||
@arkadylukashov
arkadylukashov / jquery.preload.piecon.js
Created January 21, 2013 14:39
Simple image preloader uses jQuery and Piecon
/* piecon */
(function(){var i={},j=null,k=null,f=null,g=null,h={},l={color:"#ff0084",background:"#bbb",shadow:"#fff",fallback:!1},c,o=navigator.userAgent.toLowerCase();c=function(e){return-1!==o.indexOf(e)};var p=c("msie");c("chrome");c("chrome")||c("safari");var q=c("safari")&&!c("chrome");c("mozilla")&&!c("chrome")&&c("safari");var m=function(e){for(var a=document.getElementsByTagName("link"),c=document.getElementsByTagName("head")[0],f=0,h=a.length;f<h;f++)("icon"===a[f].getAttribute("rel")||"shortcut icon"===
a[f].getAttribute("rel"))&&c.removeChild(a[f]);a=document.createElement("link");a.type="image/x-icon";a.rel="icon";a.href=e;document.getElementsByTagName("head")[0].appendChild(a)},n=function(){g||(g=document.createElement("canvas"),g.width=16,g.height=16);return g};i.setOptions=function(e){h={};for(var a in l)h[a]=e.hasOwnProperty(a)?e[a]:l[a];return this};i.setProgress=function(e){f||(f=document.title);if(!k||!j){var a;a:{a=document.getElementsByTagName("link");for(var c=0,i=a.length;c<i;c++)if("i