This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function resizeImgOO(el){ | |
function imgRatio(){ | |
return (el.height / el.width); | |
} | |
function holderRatio(){ | |
return (el.offsetParent.offsetHeight / el.offsetParent.offsetWidth); | |
} | |
function fitToContainer(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var str = 'fooooo1#foo1:1,bfooooo1#foo1:1,arrrr2#barr2:2', | |
slice = [].slice; | |
String.prototype.esplit = function(){ | |
if(this.length == 0) | |
return []; | |
var args = slice.apply(arguments) | |
, options = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ajaxForms = function(/* TODO translations */){ | |
var self = this; | |
$('form.ajax').each(function(i, form){ | |
var f = $(form) | |
, submit = f.find('input[type="submit"]'); | |
if($.fn.html5Uploader && f.hasClass('html5')){ | |
f.find('[type="file"]').html5Uploader(); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fileUploads = function(input){ | |
var self = this; | |
if(input.length > 0 && !window.FileReader){ // TODO failover | |
$.sticky('Ваш браузер не поддерживает HTML5 FileReader, обновитесь.'); | |
return false; | |
} | |
this.input = input; | |
var parent = input.parent() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var ajaxBindings = function(){ | |
if(window.csrf) { | |
$('body').bind('ajaxSend', function(ev, xhr, s){ | |
if (s.type == 'POST') { | |
xhr.setRequestHeader('X-CSRF-Token', csrf); | |
} | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($){ | |
$.fn.html5Uploader = function(){ | |
return this.each(function(){ | |
var $this = $(this); | |
if($this.is('[type="file"]')){ | |
$this.bind('change', function(){ | |
var files = this.files; | |
for(var i = 0;i < files.length;i++){ | |
fileHandler.call($this, files[i]); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var getObj = { | |
a: { | |
foo: 1, | |
bar: 2 | |
} | |
}; | |
var objectPath = function(obj, path, value, options){ | |
path = typeof path == 'string' ? path.split('.') : path; | |
var key = path.shift() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Utils = {}; | |
/** | |
* Fetch multiple models(or collections) and execute passed callback | |
* | |
* @param {Array} stack - stack of objects | |
* @param {Function} callback - exec on ready | |
* @param {Object} ctx - callback context | |
* | |
* @returns {Object} context |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(Backbone, _) { | |
var leave; | |
_.extend(Backbone.Router.prototype, Backbone.Events, { | |
route : function(route, name, callback) { | |
var before | |
, fn = callback | |
, after; | |
Backbone.history || (Backbone.history = new Backbone.History); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// node count-lines.js "somefile.txt" 12 | |
var fs = require('fs') | |
, length = process.argv.pop() | |
, filename = process.argv.pop() | |
, stream | |
, counter = 0; | |
stream = fs.createReadStream(filename); |
OlderNewer