Skip to content

Instantly share code, notes, and snippets.

View makeusabrew's full-sized avatar
💭
I may be slow to respond.

Nick Payne makeusabrew

💭
I may be slow to respond.
View GitHub Profile
@makeusabrew
makeusabrew / quick-dirty-ssg.php
Created March 4, 2012 14:38
Quick & dirty SSG function
<?php
// assume $text is our article's full content
$text = preg_replace_callback("@\[gist id=(\d+)\]@s", function($matches) {
// we know that the match at offset 1 will be our target gist ID
$id = $matches[1];
// Go fetch the raw JS from GitHub...
// @todo - you'd want to handle errors here!
$js = file_get_contents("https://gist.github.com/".$id.".js");
// get rid of any superfluous whitespace off either end of the string
This is a test.
// this (obviously, I suppose) doesn't work when the containing element goes walkabouts
// and then later gets reinserted (e.g. via AJAX)
$("div[data-leaderboard] ul").on("click", "a" function(e) {});
// but this, using .live (again, obviously), does
$("div[data-leaderboard] ul a").live("click", function(e) {});
// the solution is to bind .on() to the highest ever-present element. In thick-client
// applications, this has to be something like the following, where #container is a
// wrapper element not too far off body.
@makeusabrew
makeusabrew / bootbox-animate-default.js
Created February 1, 2012 20:41
bootbox.js - animate default
bootbox.animate(false);
// won't animate
bootbox.alert("Hello");
// will animate
bootbox.dialog("I am a custom dialog", {
"label" : "Click me!",
"class" : "btn-success", // or btn-primary, or btn-danger, or nothing at all
"callback": function() {
@makeusabrew
makeusabrew / bootbox-animate.js
Created February 1, 2012 20:38
bootbox.js - animate option
bootbox.dialog("I am a custom dialog", {
"label" : "Click me!",
"class" : "btn-success", // or btn-primary, or btn-danger, or nothing at all
"callback": function() {
console.log("foo");
}
}, {
"animate": false
});
@makeusabrew
makeusabrew / bootbox.2.0.0.js
Created February 1, 2012 20:26
bootbox.js 2.0.0 changes
// OLD - 1.x.x releases
bootbox.dialog("I am a custom dialog", {
"label" : "Click me!",
"class" : "success", // or primary, or danger, or nothing at all
"callback": function() {
console.log("foo");
}
});
@makeusabrew
makeusabrew / base-simplified.tpl
Created January 18, 2012 15:31
Simplified base layout supporting PJAX
{if !$_pjax}
{* everything as normal *}
<html>
<head>
<title>{block name="title"}{/block}</title>
</head>
<body>
<!-- header -->
<!-- nav etc -->
@makeusabrew
makeusabrew / main.css
Created January 18, 2012 15:17
Namespaced transition selectors
/**
* basic theme transition setup stuff
*/
.transition #header,
.transition .label {
-webkit-transition: background-color 1.0s;
-moz-transition: background-color 1.0s;
-ms-transition: background-color 1.0s;
-o-transition: background-color 1.0s;
transition: background-color 1.0s;
@makeusabrew
makeusabrew / pjaxify-extract.js
Created January 18, 2012 15:13
Apply a temporary unique query string to transitioning A elements
$("#inner").bind("end.pjax", function() {
// ...
// we do all this *before* we switch the body class, thus before the transitions are triggered
$("#inner a").each(function(i) {
var dt = new Date().getTime();
$(this).attr("href", $(this).attr("href")+"?__t="+dt);
});
});