Skip to content

Instantly share code, notes, and snippets.

Aziz Gazanchiyan creage

Block or report user

Report or block creage

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
View $.format
(function ($, window, document, undefined) {
$.extend({
/**
* Format at string using .NET C# syntax
$.format("test {0} and {1}", "is cool", "and passed");
$.format("test {1} and {0}", ["is cool", "and passed"]);
*/
format: (function () {
var iterate = function (txt, replacements) {
View $.wait
(function ($, window, document, undefined) {
$.extend({
/*
* wait for timeout until condition returns true
*/
wait: function (conditionCallback, timeout) {
timeout = timeout || 50;
return $.Deferred(function (dfd) {
View $.eachDeferred
(function ($, window, document, undefined) {
$.extend({
/*
* Iterates over elms array/collection using deferred callbacks.
* the function assigned for iterator should return promise.
* resolved promises notify the main deferred, so we can track each loop result.
* returns promise.
*/
eachDeferred: function (elms, c) {
@creage
creage / eachDeferred
Created Apr 25, 2014
jQuery.eachDeferred
View eachDeferred
(function ($, window, document, undefined) {
$.fn.extend({
/*
* Iterates over jQuery object collection using deferred callbacks.
* the function assigned for iterator should return promise.
* resolved promises notify the main deferred, so we can track each loop result.
* returns promise.
*/
eachDeferred: function (c) {
var that = this,
@creage
creage / :detached
Created Apr 25, 2014
jQuery :detached selector
View :detached
$.extend($.expr[':'], {
/*
* check if element is detached from DOM
*/
detached: function (elem) {
return !$.contains(document.documentElement, elem);
}
});
@creage
creage / windowresize
Created Apr 25, 2014
jquery's bounced on('windowresize')
View windowresize
(function ($) {
// Special event definition.
$.event.special.windowresize = {
setup: function () {
$(this).ondelay('resize', { timeout: 300 }, resizeHandler);
},
teardown: function () {
$(this).off('resize', resizeHandler);
}
@creage
creage / ondelay
Last active Aug 29, 2015
jQuery.ondelay
View ondelay
(function ($, window, document, undefined) {
$.fn.extend({
/*
* Provides event handling with delaying ability
* respects two attributes coming as data attributes:
* timeout: integer value of ms to timeout before event will be triggered once event is stopped to be fired
* throttle: boolean, default false
* if set to true - event will be fired once per timeout,
* if set to false - event will be fired only after timeout starting from event is stoped firing
*/
You can’t perform that action at this time.