Andy Blackwell » Web http://www.andyblackwell.com Wed, 26 May 2010 15:17:36 +0000 en hourly 1 http://wordpress.org/?v=3.3.1 Google Fonts API: Asychronously http://www.andyblackwell.com/google-fonts-api-asych-198 http://www.andyblackwell.com/google-fonts-api-asych-198#comments Wed, 26 May 2010 13:00:51 +0000 andyblackwell http://www.andyblackwell.com/?p=198 When Google Fonts came out last week I got really excited (even IE6 is supported!), but it brought up an old problem I’ve had with including code hosted by Google (or anyone else) in a site. Whenever the files host goes down, your sites load time can become lengthy, causing you to lose potential visitors. It’s happened a few times in the last couple months when Google services were down in our area (Search/Code/APIs), which caused a lot of our sites to ‘hang’ while loading because they were trying to download something that wasn’t available.

So I decided to implement these wonderful new fonts in a fail safe way where no site would fall victim to being crippled if/when the files were unreachable. Below are my cross-browser ways of doing just that, whether you would like to use the javascript loading method (example #1), or point directly to the css file (example #2).

The Google Fonts javascript loader method is nice because it gives you some css classes to use once the fonts have loaded, giving you more control over what your site looks like with or without the ‘fancy’ fonts, rather than merely relying on a font stack in the css to do that job.

(function() {
	var loaded = false;
	var script = document.createElement('script');
	script.type = 'text/javascript';
	script.src = 'http://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
	script.onload = script.onreadystatechange = function() {
		if ( !loaded && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) {
			loaded = true;
			// Handle memory leak - IE
			script.onload = script.onreadystatechange = null;
			// check before using - IE6
			if(window['WebFont']){

				// Put your WebFont calls here
				WebFont.load({
					google: {
						families: [ 'Yanone Kaffeesatz', 'Vollkorn' ]
					}
				});

			}
		}
	};
	var s = document.getElementsByTagName('script')[0];
	s.parentNode.insertBefore(script, s);
})();
(function() {
	var head = document.getElementsByTagName("head")[0] || document.documentElement;
	var link = document.createElement('link');
	link.type = 'text/css';
	link.rel = 'stylesheet';
	// enter the Google Fonts css url here
	link.href = 'http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz|Vollkorn';
	head.insertBefore( link, head.firstChild );
})();

Both can be placed in the head or foot of your page, although I recommend placing the snippet in the head so the file(s) will begin downloading as soon as possible.

Did you find this helpful, or have ideas to make it better? Let me know in the comments!

]]>
http://www.andyblackwell.com/google-fonts-api-asych-198/feed 0
Adobe Creative Suite 5 launches today! http://www.andyblackwell.com/adobe-creative-suite-5-launches-today-171 http://www.andyblackwell.com/adobe-creative-suite-5-launches-today-171#comments Mon, 12 Apr 2010 05:15:47 +0000 andyblackwell http://www.andyblackwell.com/?p=171 Excuse me while I geek out over Adobe’s mind-blowing upgrades to their Creative Suite. It’s almost too much awesome to take in.

Photoshop’s new Content-Aware Fill is the auto-drool feature:

And Puppet Warp is blowing my mind:

Illustrator strokes mimicking brushes are awesome:

And Vector drawing in perspective is sweet:

Head over to Adobe to see the other cool features they’ve cooked up, or look for the tutorial videos this week from PhotoshopUser.com at their Photoshop CS5 Learning Center.

]]>
http://www.andyblackwell.com/adobe-creative-suite-5-launches-today-171/feed 0
WordPress Theme Organization Library http://www.andyblackwell.com/wordpress-theme-organization-library-141 http://www.andyblackwell.com/wordpress-theme-organization-library-141#comments Sun, 04 Apr 2010 20:26:46 +0000 andyblackwell http://www.andyblackwell.com/?p=141 I’ve developed a small, flexible library to help WordPress theme developers organize their theme files however they like. I came to the conclusion that all the theme frameworks I had used in the past were overkill for my needs, and personally don’t like the idea of parent/child themes. So I created a simple library that would help in organizing themes with numerous files, which was my primary need. But I also wanted to promote OOP over functional coding where possible as well.

I currently use the library on this site (tentatively named ‘Themeo’) and will release an open source version once I’ve tweaked the code for easy configuration. The basic use will be to extend the library, creating a theme-specific class that will encapsulate your theme code.

class MyTheme extends Themeo {

	static public function get_header($file='header'){
		wp_deregister_script('jquery');
		wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"), false, '1.4');
		wp_register_script('app', Themeo::get_template_url() . "js/app.js", array('jquery'), '1.0');
		wp_enqueue_script('jquery');
		wp_enqueue_script('app');
		self::get_template_file('header/' . $file . '.php');
	}

	static public function get_sidebar($file='sidebar'){
		self::get_template_file('sidebar/' . $file . '.php');
	}

	static public function get_footer($file='footer'){
		self::get_template_file('footer/' . $file . '.php');
	}

}

And then calling your custom class in your theme’s files.

<?php MyTheme::get_header(); ?>

<?php if (have_posts()) : ?>
	<div class="posts">
	<?php while (have_posts()) : the_post(); ?>

		<?php MyTheme::get_template_file('post/loop-item-teaser'); ?>

	<?php endwhile; ?>
	</div><!-- .posts -->

	<div class="navigation">
		<?php next_posts_link('&laquo; Older Entries'); ?>
		<?php previous_posts_link('Newer Entries &raquo;'); ?>
	</div>
<?php endif; ?>

<?php MyTheme::get_footer(); ?>

This is a very simple example of how it could be used. More information to come as I get closer to releasing it.

]]>
http://www.andyblackwell.com/wordpress-theme-organization-library-141/feed 0
1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98|99|100|101|102|103|104|105|106|107|108|109|110|111|112|113|114|115|116|117|118|119|120|121|122|123|124|125|126|127|128|129|130|131|132|133|134|135|136|137|138|139|140|141|142|143|144|145|146|147|148|149|150|151|152|153|154|155|156|157|158|159|160|161|162|163|164|165|166|167|168|169|170|171|172|173|174|175|176|177|178|179|180|181|182|183|184|185|186|187|188|189|190|191|192|193|194|195|196|197|198|199|200|201|202|203|204|205|206|207|208|209|210|211|212|213|214|215|216|217|218|219|220|221|222|223|224|225|226|227|228|229|230|231|232|233|234|235|236|237|238|239|240|241|242|243|244|245|246|247|248|249|250|251|252|253|254|255|256|257|258|259|260|261|262|263|264|265|266|267|268|269|270|271|272|273|274|275|276|277|278|279|280|281|282|283|284|285|286|287|288|289|290|291|292|293|294|295|296|297|298|299|300|301|302|303| inhouse pharmacy sumatriptan imigran imitrex tablets flagyl usa how to use diflucan strattera and weight loss when levaquin doesn't work allied glove and safety products bathroom medicine cabinets with mirror pharmacies 17074 annuals of internal medicine traditional chinese medicine practioner lexington kypayday loans online no checking accountno credit check payday loans magnum cash Buy Cheap Viagra Online Vardenafil Super Viagra Cialis Online Canada Viagra Online without Prescription Buy Levitra Online.Vardenafil Cialis Online without Prescription Cheap Cialis Viagra Coupon Cialis Coupon Viagra with dapoxetine Cialis Black Viagra Online Canadian Pharmacy Viagra Super Force Cheap Cialis Online Cheap Levitra Without Prescription Buy Generic Cialis Online Buy Cheap Cialis Super Active Buy Viagra With Dapoxetine Online Cash Advances Payday Loans