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 hashbang(#!) | |
function hasbang(){ | |
$('a').each(function(){ | |
var o = $(this), url = o.attr('href'), p = url.match('^https?://'); | |
var h1 = location.hostname, h2 = h1.replace(/^www\./i,''); | |
if (url == '#') { | |
o.attr('href','javascript:void(0);'); | |
return; | |
} |
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
$.fn.addCss = function(css){ | |
var style = document.createElement('link'); | |
style.rel = 'stylesheet'; | |
style.type = "text/css"; | |
style.href = css; | |
document.getElementById($(this).attr('id')).appendChild(style); | |
}; | |
$.fn.addJs = function(js){ | |
var script = document.createElement("script"); |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<title>{{title}}</title> | |
{{#styles}} | |
{{#browser}}<!--[if {{logic}} ]>{{/browser}}<link rel="stylesheet" type="text/css" href="{{style}}" {{#media}}media="{{target}}"{{/media}} />{{#browser}}<![endif]-->{{/browser}} | |
{{/styles}} | |
{{#scripts}} | |
<script type="text/javascript" src="{{script}}"></script> |
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
/* | |
* Extend HTML::style | |
* | |
* @param string File name | |
* @param array Default attributes | |
* @param string Spesific browser logic/condition | |
* @param mixed Protocol to pass to URL::base() | |
* @param boolean Include the index page | |
* @return 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
// ============================================================ | |
// Objects vs Primitives | |
// To make a long story short, use primitives wherever you can. | |
// ============================================================ | |
// Primitive types: Null, Undefined, Number, Boolean, String. | |
var num1 = 9000, | |
num2 = new Number( 9000 ), | |
str1 = "hello world", |
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 defined('SYSPATH') or die('No direct script access.'); | |
class HELPER { | |
/* | |
* helper to load post from database | |
* | |
* @param int 4 digit ex. 2010 | |
* @param int without leading zero | |
* @param string slug/permalink, if set then limit/offset will be ignore |
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
.pagination { | |
margin-top:1.5em; | |
text-align:center; | |
padding:2px 2px 1.5em; | |
} | |
.pagination a { | |
text-shadow:none; | |
} |
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 defined('SYSPATH') OR die('No direct script access.'); | |
class Valid extends Kohana_Valid { | |
public static function slug($str) | |
{ | |
if (preg_match('/^[a-zA-Z0-9_-]+$/D', $str, $matches)) | |
{ | |
// Strip multiple dashes and trim an ending or starting dashes | |
return ($str === preg_replace('/-{2,}/', '-', trim($matches[0], '-'))); |
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
// $('img.photo',this).imagesLoaded(myFunction) | |
// execute a callback when all images have loaded. | |
// needed because .load() doesn't work on cached images | |
// mit license. paul irish. 2010. | |
// webkit fix from Oren Solomianik. thx! | |
// callback function is passed the last image to load | |
// as an argument, and the collection as `this` |
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 defined('SYSPATH') or die('No direct script access.'); | |
abstract class Sprig extends Sprig_Core { | |
/** | |
* Returns the foreign key of the model, optionally with a table name. | |
* | |
* @param string table name, TRUE for the model table | |
* @return string | |
*/ |
OlderNewer