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($, undefined) { | |
$.extend({ | |
toUTF8 : function(text) { | |
text = text.replace(/\r\n/g,"\n"); | |
var output = []; | |
for (var n = 0 ; n < text.length ; n++) { | |
var c = text.charCodeAt(n); |
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.limit = function (options) { | |
var defaults = { | |
limit : 200, | |
result : false, | |
alertClass : false | |
}, options = $.extend(defaults, options); | |
return this.each(function () { | |
var characters = options.limit; |
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
//http://stackoverflow.com/a/1026087/181295 | |
String.prototype.turkishUpperCase = function () { | |
return this.replace(/ğ/g, 'Ğ') | |
.replace(/ü/g, 'Ü') | |
.replace(/ş/g, 'Ş') | |
.replace(/ı/g, 'I') | |
.replace(/i/g, 'İ') | |
.replace(/ö/g, 'Ö') | |
.replace(/ç/g, 'Ç') | |
.toUpperCase(); |
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 string_to_slug = function (str) | |
{ | |
str = str.replace(/^\s+|\s+$/g, ''); // trim | |
str = str.toLowerCase(); | |
// remove accents, swap ñ for n, etc | |
var from = "àáäâèéëêìíïîıòóöôùúüûñçşğ·/_,:;"; | |
var to = "aaaaeeeeiiiiioooouuuuncsg------"; | |
for (var i=0, l=from.length ; i<l ; 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
<?php | |
/** | |
* BBcode helper class | |
* | |
* @package BBcode | |
* @category Helper | |
* @author Chema <chema@garridodiaz.com> | |
* @copyright (c) 2012 | |
* @license GPL v3 | |
*/ |
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
/** | |
* Convert a template string into HTML DOM nodes | |
* @param {String} str The template string | |
* @return {Node} The template HTML | |
*/ | |
var stringToHTML = function (str) { | |
parser = parser || new DOMParser(); | |
var doc = parser.parseFromString(str, 'text/html'); | |
return doc.body; | |
}; |
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
/** | |
* Return a clone of an object or array | |
* @param {Object|Array} obj The object or array to clone | |
* @return {Object|Array} An exact copy of the object or array | |
*/ | |
var clone = function (obj) { | |
if (!obj) return; | |
return JSON.parse(JSON.stringify(obj)); | |
}; |
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
/** | |
* More accurately check the type of a JavaScript object | |
* @param {Object} obj The object | |
* @return {String} The object type | |
*/ | |
var trueTypeOf = function (obj) { | |
return Object.prototype.toString.call(obj).slice(8, -1).toLowerCase(); | |
}; |
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
/** | |
* Check feature support | |
*/ | |
var supports = function () { | |
if (!window.DOMParser) return false; | |
parser = parser || new DOMParser(); | |
try { | |
parser.parseFromString('x', 'text/html'); | |
} catch(err) { | |
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
/** | |
* Find the first matching item in an array | |
* @param {Array} arr The array to search in | |
* @param {Function} callback The callback to run to find a match | |
* @return {*} The matching item | |
*/ | |
var find = function (arr, callback) { | |
var matches = arr.filter(callback); | |
if (matches.length < 1) return null; | |
return matches[0]; |
OlderNewer