Archive for November 2011
-
Adding custom method calls to the jQuery Rambling Slider
November 12, 2011
This post was originally published in the Rambling Labs Blog on November 12, 2011.
The jQuery Rambling Slider v0.1.2 was released a couple of days ago. One of the features added was the ability to start and stop the slider like this:
$('#slider').ramblingSlider('stop'); $('#slider').ramblingSlider('start');
Every serious jQuery plugin has some way to change it’s behaviour or query some data after initialized and the general approach for this is calling the custom methods as showed above.
It is well known that in order to do this, you have to perform some dynamic method calling magic. This is what you find in the jQuery documentation:
(function($){ var methods = { init : function(options) { /*...*/ }, show : function() { /*…
-
jQuery Rambling Slider v0.1.2 is out!
November 11, 2011
This post was originally published in the Rambling Labs Blog on November 11, 2011.
I am proud to announce that version 0.1.2 of the jQuery Rambling Slider has been released!
It really has been out for a couple of days now, but I’ve had a couple of busy weeks. Nevertheless, I managed to do the major refactoring that I mentioned when version 0.1.1 was released. So, what have I added to this new release? Here’s the list:
- Added the ability to call the
stop
andstart
methods from$('#slider').ramblingSlider('stop')
. - Added the
foldLeft
animation. - Refactored the build process, as the commands remain the same (
cake build
andcake minify
) - Added the missing yuicompressor (oops…)
- Reformatted the for loops to be more CoffeeScript-ish.
- Added the…
- Added the ability to call the
-
The joy of writing CoffeeScript
November 11, 2011
This post was originally published in the Rambling Labs Blog on November 11, 2011.
I have been a fan of JavaScript for a while now, and I have dived into the CoffeeScript world for the last month or so.
Guess what? I love it! It’s been a great experience so far.
Definitely the one thing that I’m loving the most right now about CoffeeScript is the syntactic sugar. It’s basically a lot of simple shorthands for certain things (the
->
is so handy). Take this example (and ignore what the excluded methods are doing):I had this:
class BuildUtils combine_source_files: (callback) -> self = @ fs.readdir './src', (err, files) -> self.error_handler err content = new Array() files = files.sort() for file, index
-
Rails 3.1 - will_paginate and AJAX
November 10, 2011
This post was originally published in the Rambling Labs Blog on November 10, 2011.
For a project that I’m currently working on, I have a couple of list views that needed pagination. So I went with the ol’
will_paginate
gem (which I first saw years ago when I didn’t even consider myself a developer) to take care of this.It’s as simple as including a line with
gem 'will_paginate'
on yourGemfile
, runningbundle install
, and include this in the controller:class OrdersController < ApplicationController def index @orders = Order.paginate(page: params[:page], per_page: 10) end end
And this in the view
orders/index.html.erb
:<div id="orders"> <ul> <% @orders.each do |order| %> <li> <!-- Show order stuff --> …
-
Unit testing the jQuery Rambling Slider - Part 2 - The DOM, jQuery and node.js
November 9, 2011
This post was originally published in the Rambling Labs Blog on November 9, 2011.
In order to continue to add tests to the jQuery Rambling Slider, I needed to test something against the DOM. Problem is, you don’t count with the DOM when you’re running the Jasmine tests from console. So what should I do?
As expected, I found that there is a DOM emulator in node.js :D. Also, to test using jQuery I needed to download the corresponding node package. So I didn’t waste any time and went ahead to install them:
npm install -g jsdom npm install -g jquery
So now, I can write something like this in my
src/jquery.plugins.coffee
:(($) -> $.fn.reverse = [].reverse )(jQuery)
And test it on my
spec/jquery.plugins.spec.coffee
with something like this… -
Unit testing the jQuery Rambling Slider - CoffeeScript, Jasmine and node.js
November 9, 2011
This post was originally published in the Rambling Labs Blog on November 9, 2011.
As you may know, I have been working lately on the jQuery Rambling Slider. One of my personal milestones with this project is to write as many unit tests as possible, so I began my research.
Honestly, I didn’t know where to begin. I remember to have read once on twitter that someone was writing their tests with Jasmine and CoffeeScript, so that could be a good starting point (and it sounds really fun too!). I have worked with Jasmine before and it sure was a great experience. It’s yet another productivity tool made by the great Pivotal Labs guys.
After googling for a while, I stumbled into a post from someone that was writing tests in Jasmine and node.js