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
/* View documents with Google Docs ... | |
* because my laptop can't handle Word and Chrome at the same time. */ | |
$(document).ready(function(){ | |
// I'm sure there's a more efficient selector for this. | |
$('a[href$=doc], a[href$=docx], a[href$=pdf], a[href$=rtf]').attr( | |
'href', | |
function(){ | |
return 'http://docs.google.com/viewer?url=' + this.href; | |
} |
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 Tiny Pub/Sub - v0.3pre - 11/4/2010 | |
* http://benalman.com/ | |
* | |
* Copyright (c) 2010 "Cowboy" Ben Alman | |
* Dual licensed under the MIT and GPL licenses. | |
* http://benalman.com/about/license/ | |
*/ | |
(function($){ |
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 Tiny Pub/Sub - v0.3pre - 11/4/2010 | |
* http://benalman.com/ | |
* | |
* Copyright (c) 2010 "Cowboy" Ben Alman | |
* Dual licensed under the MIT and GPL licenses. | |
* http://benalman.com/about/license/ | |
*/ | |
(function($){ |
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
//For use on the jquery functions that except selectors | |
jQuery.fn.atLeastOne = function(prop, selectorsArr) { | |
var ret = 0, self = this, | |
testSelector = function(value){ | |
return self[prop].apply(self, [value]).size() > 0; | |
}; | |
$.each(selectorsArr, function(i, value){ | |
ret = testSelector(value); | |
// break loop if found | |
if(ret) { return false } |
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
(function($){ | |
$.pubsub = (function(){ | |
var mule = $({}); | |
return { | |
subscribe:function(key, fn){ | |
//Normalise | |
mule.bind(key, function(e, data){ | |
fn.apply(null, [data]); | |
}); |
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
(function($) { | |
$.fn.recurse = function(closure, options) { | |
var self = this, settings = $.extend({}, $.fn.recurse.defaults, options); | |
self.queue(settings.queue, function(next){ | |
if (!closure.apply(self, [self])) { | |
self.delay(settings.delay, settings.queue).queue(settings.queue, arguments.callee).trigger('queue').dequeue(settings.queue); | |
} else { | |
self.trigger('complete'); | |
} | |
}); |
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
(function( $ ){ | |
$.fn.pushTop = function() { | |
return this.each(function() { | |
var $this = $(this); | |
top_z_index = 0; | |
$('*').each(function() { | |
var this_z_index = $(this).css('z-index'); | |
if (this_z_index != "auto" && this_z_index > top_z_index) { | |
top_z_index = this_z_index; | |
} |
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
(function($) { | |
$.fn.enable = function() { | |
// Enable each selected element by removing its 'disabled' attribute. | |
return this.each(function() { | |
$(this).removeAttr('disabled'); | |
}); | |
}; | |
$.fn.disable = function() { |
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
(function($){ | |
$.Class = function(code){ | |
var klass = function() { | |
var instance = (arguments[0] !== null && this.__init__ && typeof this.__init__ == 'function') ? this.__init__.apply(this, arguments) : this; | |
return instance; | |
}; | |
$.extend(klass, this); | |
$.extend(klass.prototype, { | |
'bind': function(type, fn) { | |
this.__events__ = this.__events__ || {}; |
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
Knockout JS - Knockout uses MVVM (which can be considered as MVC with declarative syntax). It's very much catered to those using JavaScript for user interfaces but does also provide dependency management, templating and works well with jQuery to boot. What I will say for Knockout is that it can make heavy usage of data-binding. If you're not used to this, I would recommend spending time reviewing before choosing Knockout as your MVC solution of choice. It's clean and it does work quite well, but is a little different from what you might expect. | |
http://knockoutjs.com/documentation/introduction.html | |
Backbone - this is significantly easier to get started with than any of the other solutions I reviewed today, however, note that it's support for MVC isn't atypical. The (C) here stands for collections and you'll want to review just how close to 'expected' MVC this solution is before you use it. I recommend Backbone for those who like to work with jQuery and need to get started with MVC without a long period of l |
OlderNewer