Permalink
Browse files

added optional options argument to card component to prevent flipping…

… when clicked
  • Loading branch information...
1 parent baec734 commit 4bf99a46616e7cdd53d5f71a81b71bc6b1f719c5 @luk- committed Mar 10, 2012
Showing with 11 additions and 6 deletions.
  1. +11 −6 lib/components/card/card.js
@@ -10,12 +10,13 @@ exports.Card = Card;
*
* @param {Mixed} front
* @param {Mixed} back
+ * @param {Object} options
* @return {Card}
* @api public
*/
-exports.card = function(front, back){
- return new Card(front, back);
+exports.card = function(front, back, options){
+ return new Card(front, back, options);
};
/**
@@ -26,15 +27,17 @@ exports.card = function(front, back){
*
* @param {Mixed} front
* @param {Mixed} back
+ * @param {Object} options
* @api public
*/
-function Card(front, back) {
+function Card(front, back, options) {
ui.Emitter.call(this);
this._front = front || $('<p>front</p>');
this._back = back || $('<p>back</p>');
this.template = html;
- this.render();
+ this.options = options || {self_flip: true};
+ this.render(this.options);
};
/**
@@ -110,6 +113,8 @@ Card.prototype.render = function(options){
el.find('.front').empty().append(this._front.el || $(this._front));
el.find('.back').empty().append(this._back.el || $(this._back));
el.click(function(){
- self.flip();
+ if (options.self_flip === true) {
+ self.flip();
+ }
});
-};
+};

0 comments on commit 4bf99a4

Please sign in to comment.