Posts

Showing posts with the label plugin

jQuery plug-in distributed elements via If, ElseIf, and Else

After a couple of instant and consecutive releases, I ended up with a plug-in that fits minified into 240 bytes :) Here is the official plug-in page , while this is the example page and this is the summary: ;jQuery.fn.extend({ // Andrea Giammarchi - Mit Style Licence - V0.2 If:function(fn){ var __If__ = this.__If__ || this, $ = __If__.filter(fn); $.__If__ = __If__.filter(function(){return !~$.index(this)}); return $; }, Else:function(){ return this.__If__; }, Do:jQuery.fn.each }); jQuery.fn.ElseIf = jQuery.fn.If;

jQuery If, ElseIf, and Else plugin

Update Guys, I have to admit I created silly prototypes while all I need were much more simpler than I though :) Enjoy last version ! ------------------------------------- Try to imagine a page like this one: <body> <div>1</div> <div>2</div> <div>3</div> <div>4</div> <div>5</div> <div>6</div> <div>7</div> <div>8</div> </body> .. and now try to imagine something like this: function oddNumbers(){ // return true if element contain an odd number return $(this).text() & 1; }; $(function(){ $("div") .If(function(){return $(this).text() == "3" || $(this).text() == "5"}) .text("match the 3 or 5 check") .ElseIf(oddNumbers) .text("odd numbers") .ElseIf(function(){return $(this).text() == 2}) .Do(function(){ // if you need a closure ... $(this).text(...

jSmile 0.4 - Stand alone Version

nic comment: hey. thank u for that awesome plugin. how can i download the smilie package? i want to host them on my webspace because i want to be independet from other hosters. I have recently updated my jQuery plugin, called jSmile , and the biggest news is that it does not require anymore external resources. Thanks to inline uri data, the script now comes " full optionals ", or better, with base64 encoded GIFs images included. Instead of external CSS classes, images, and cross host dependencies, jSmile can now easily be integrated in every http or http s site, and without network delays. Its size is obviously bigger than before, but using a minifier and gzip compression, it fits perfectly under 7Kb . Compatibility Chrome FireFox Internet Explorer 8 Opera Safari WebKit Enjoy ;)