NOTE I now use the conventions detailed in the SUIT framework
Used to provide structural templates.
Pattern
t-template-name
| // from https://twitter.com/#!/LeaVerou/status/16613276313980929 | |
| // this pattern below is common for using an incoming value otherwise using some default. | |
| /* Bad: */ x = x ? x : y; // simple ternary. | |
| // if x is truthy lets use it. | |
| /* Better: */ x = x || y; // logical OR. | |
| // you could string a bunch of these easily to grab the first non-falsy value: |
| /** | |
| * Helper function for passing arrays of promises to $.when | |
| */ | |
| jQuery.whenArray = function ( array ) { | |
| return jQuery.when.apply( this, array ); | |
| }; | |
| /** | |
| * Accepts a single image src or an array of image srcs. |
| function multiply(a, b) { | |
| return a * b; | |
| } | |
| function divide(a, b) { | |
| if (b === 0) { | |
| throw "Don't try to divide by zero!"; | |
| } | |
| return Math.round(a / b); |
| // stolen from http://api.jquery.com/map/ | |
| // usage: $('div').equalizeHeights(); | |
| $.fn.equalizeHeights = function(){ | |
| return this.height( Math.max.apply( this, $(this).map(function(i,e){ return $(e).height() }).get() ) ); | |
| } |
| // Unserialize (to) form plugin - by Christopher Thielen | |
| // adapted and desuckified (a little) by Paul Irish | |
| // takes a GET-serialized string, e.g. first=5&second=3&a=b and sets input tags (e.g. input name="first") to their values (e.g. 5) | |
| (function($) { | |
| $.fn.unserializeForm = function(values) { |
| /* | |
| * Updated to use the function-based method described in http://www.phpied.com/social-button-bffs/ | |
| * Better handling of scripts without supplied ids. | |
| * | |
| * N.B. Be sure to include Google Analytics's _gaq and Facebook's fbAsyncInit prior to this function. | |
| */ | |
| (function(doc, script) { | |
| var js, | |
| fjs = doc.getElementsByTagName(script)[0], |
| <!DOCTYPE html> | |
| <head> | |
| <title>Stay Standalone</title> | |
| <meta name="apple-mobile-web-app-capable" content="yes"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"> | |
| <script src="stay_standalone.js" type="text/javascript"></script> | |
| </head> | |
| <body> | |
| <ul> | |
| <li><a href="http://google.com/">Remote Link (Google)</a></li> |
NOTE I now use the conventions detailed in the SUIT framework
Used to provide structural templates.
Pattern
t-template-name
#Four Ways To Do Pub/Sub With jQuery and jQuery UI (in the future)
Between jQuery 1.7 and some of work going into future versions of jQuery UI, there are a ton of hot new ways for you to get your publish/subscribe on. Here are just four of them, three of which are new.
(PS: If you're unfamiliar with pub/sub, read the guide to it that Julian Aubourg and I wrote here http://msdn.microsoft.com/en-us/scriptjunkie/hh201955.aspx)
##Option 1: Using jQuery 1.7's $.Callbacks() feature:
| <?php | |
| /** | |
| * Custom configuration bootsrtap file for ExpressionEngine | |
| * | |
| * Place config.php in your site root | |
| * Add require(realpath(dirname(__FILE__) . '/../../config.php')); to the bottom of system/expressionengine/config/config.php | |
| * Add require(realpath(dirname(__FILE__) . '/../../config.php')); to the bottom of system/expressionengine/config/database.php | |
| * If you have moved your site root you'll need to update the require_once path | |
| * |