This file contains hidden or 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 | |
// 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 file contains hidden or 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
This is a test. |
This file contains hidden or 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
// 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. |
This file contains hidden or 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
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() { |
This file contains hidden or 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
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 | |
}); |
This file contains hidden or 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
// 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"); | |
} | |
}); |
This file contains hidden or 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
$("#mylink").click(function(e) { | |
e.preventDefault(); | |
var link = $(this); | |
bootbox.confirm("Are you sure?", function(result) { | |
if (result == true) { | |
window.location = link.attr("href"); | |
} | |
}); | |
}); |
This file contains hidden or 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
{if !$_pjax} | |
{* everything as normal *} | |
<html> | |
<head> | |
<title>{block name="title"}{/block}</title> | |
</head> | |
<body> | |
<!-- header --> | |
<!-- nav etc --> |
This file contains hidden or 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
/** | |
* 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; |
This file contains hidden or 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
$("#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); | |
}); | |
}); |