Skip to content

Instantly share code, notes, and snippets.

<fest:template>
&bem b-datalist {
ctx.head ? &__head ctx.head
for item in ctx.items {
&__item item
}
ctx.foot ? &__foot ctx.foot
}
@RubaXa
RubaXa / jquery.event.scroll.js
Last active December 17, 2015 06:58
jQuery extension, add support `scrollstart` and `scrollend` events.
/**
* jQuery extension, add support `scrollstart` and `scrollend` events.
*
* @author RubaXa <trash@rubaxa.org>
* @github https://gist.github.com/RubaXa/5568964
* @license MIT
*
*
* @settings
* $.special.scrollend.delay = 300; // default ms
@RubaXa
RubaXa / jquery.classList.js
Last active December 17, 2015 07:48
jQuery extension, add support `classList`.
/**
* jQuery extension, add support `classList`.
*
* @author RubaXa <trash@rubaxa.org>
* @license MIT
*/
(function ($){
var
_rspace = /\s+/
var el = document.getElementById('choose');
FileAPI.event.on(el, 'change', function (evt){
var files = FileAPI.getFiles(evt);
FileAPI.filterFiles(files, function (file, info){
return /^image/.test(file.type);
}, function (files, ignor){
if( files.length ){
// ...
}
@RubaXa
RubaXa / PickMeUp
Last active December 28, 2015 18:59
PickMeUp в 30 строк
/*! PickMeUp - jQuery datepicker plugin | Nazar Mokrynskyi <nazar@mokrynskyi.com> | Stefan Petre <www.eyecon.ro> MIT */
(function(d){function getMaxDays(){var tmpDate=new Date(this.toString()),d=28,m=tmpDate.getMonth();while(tmpDate.getMonth()==m){++d;tmpDate.setDate(d);}return d-1;}d.addDays=function(n){this.setDate(this.getDate()+n);};d.addMonths=function(n){
var day=this.getDate();this.setDate(1);this.setMonth(this.getMonth()+n);this.setDate(Math.min(day,getMaxDays.apply(this)));};d.addYears=function(n){var day=this.getDate();this.setDate(1);this.setFullYear(this.getFullYear()+n);this.setDate(Math.min(day,getMaxDays.apply(this)));};d.getDayOfYear=function(){var now=new Date(this.getFullYear(),this.getMonth(),this.getDate(),0,0,0);var then=new Date(this.getFullYear(),0,0,0,0,0);var time=now-then;return Math.floor(time/24*60*60*1000);};})(Date.prototype);(function($){
$.pickmeup=$.extend($.pickmeup||{},{date:new Date,flat:false,first_day:1,prev:"&#9664;",next:"&#9654;",mode:"single",view:"days",calendars:1,f
/*! $.ajaxCache | RubaXa <trash@rubaxa.org> | MIT */
(function ($){
var _cache = {};
var _cacheKey = function (options){
return options.url + $.param(options.data || {});
};
/**
* Get cache storage
/**
* jQuery event "tap" (Based on https://developers.google.com/mobile/articles/fast_buttons)
*
* @author RubaXa <trash@rubaxa.org>
* @license MIT
*/
(function (window, $){
var
support = window.TapSupportEnabled && ('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch
(new UISequence)
.on('click', '.js-cbx') // начало цепочки
.choose() // любое следующее действие
.group() // группа действий
.choose() // опять выбор любого
.scrollDY(-200) // либо scrollUp на 200px
.group() // либо группа из
.scrollDY(100) // scrollDown на 100px
.endPage() // и достигли конца страницы
.end() // закрываем группу
@RubaXa
RubaXa / EventEmitter.js
Created January 19, 2014 06:56
EventEmitter.js
/**
* @author RubaXa <trash@rubaxa.org>
* @license MIT
*/
(function (){
"use strict";
var _rspace = /\s+/;
@RubaXa
RubaXa / jQuery.fn.dataset.js
Last active January 4, 2016 09:09
jQuery.fn.dataset
/**
* Set/get dataset
*
* @param {String|Object} [data]
* @param {Mixed} [value]
* @retuns {Mixed}
*/
jQuery.fn.dataset = function (data, value){
var
argsNum = arguments.length