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
jQuery(document).ready(function($){ | |
$('h2.title').html(function(){ | |
// separate the text by spaces | |
var text= $(this).text().split(' '); | |
// drop the last word and store it in a variable | |
var last = text.pop(); | |
// join the text back and if it has more than 1 word add the span tag | |
// to the last word | |
return text.join(" ") + (text.length > 0 ? ' <span class="last">'+last+'</span>' : last); |
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
// Serialize Object Plugin | |
"use strict"; | |
$.fn.serializeObject = function () { | |
var o = {}; | |
var a = this.serializeArray(); // serializeArray - serialize form as an array instead of default object | |
$.each(a, function () { | |
if (o[this.name] !== undefined) { | |
if (!o[this.name].push) { | |
o[this.name] = [o[this.name]]; | |
} |
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
"use strict"; | |
$.fn.serializeObject = function () { | |
var arr = this.serializeArray(); | |
return _.reduce(arr, function (memo, f) { | |
var objField = _.reduceRight(f.name.replace(/\[/g, ".").replace(/\]/g, "").split("."), function (memo, p) { | |
var n = (/^[0-9]+$/.test(p)) ? [] : {}; | |
n[p] = memo; | |
return n; | |
}, f.value); |
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
window.$_GET = {}; | |
document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function () { | |
function decode(s) { | |
return decodeURIComponent(s.split("+").join(" ")); | |
} | |
$_GET[decode(arguments[1])] = decode(arguments[2]); | |
}); |
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 persianToLatinDigits (s) { | |
var a = ["٠", "١", "٢", "٣", "٤", "٥", "٦", "٧", "٨", "٩"]; | |
var p = ["۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹"]; | |
for (var i = 0; i < 10; i++) { | |
s = s.replace(new RegExp(a[i], 'g'), i).replace(new RegExp(p[i], 'g'), i); | |
} | |
return s; | |
} |
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
String.prototype.toPersianDigits = function () { | |
var id = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹']; | |
return this.replace(/[0-9]/g, function (w) { | |
return id[+w]; | |
}); | |
}; | |
String.prototype.toEnglishDigits = function () { | |
var id = { '۰': '0', '۱': '1', '۲': '2', '۳': '3', '۴': '4', '۵': '5', '۶': '6', '۷': '7', '۸': '8', '۹': '9' }; |
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
// module with classes and logic for working with local storage in browsers via JavaScript | |
// see also: http://professorweb.ru/my/html/html5/level5/5_1.php | |
module StorageHelper { | |
export interface IStorageItem { | |
key: string; | |
value: any; | |
} | |
export class StorageItem { | |
key: string; |
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
<script type="text/javascript"> | |
$(document).ready(function() { | |
$('.dragger').mousedown(function (event) { | |
$(this) | |
.data('down', true) | |
.data('x', event.clientX) | |
.data('scrollLeft', this.scrollLeft) | |
.addClass("dragging"); | |
return false; |
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
$(window).on("blur focus", function (e) { | |
var prevType = $(this).data("prevType"); | |
if (prevType != e.type) { // reduce double fire issues | |
switch (e.type) { | |
case "blur": | |
// do work | |
console.log('blurred'); | |
break; | |
case "focus": | |
// do work |
OlderNewer