From 4bf99a46616e7cdd53d5f71a81b71bc6b1f719c5 Mon Sep 17 00:00:00 2001 From: Lucas Arduini Date: Sat, 10 Mar 2012 02:58:27 -0500 Subject: [PATCH 1/2] added optional options argument to card component to prevent flipping when clicked --- lib/components/card/card.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/components/card/card.js b/lib/components/card/card.js index 1ea5eb6..7b9f93c 100644 --- a/lib/components/card/card.js +++ b/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 || $('

front

'); this._back = back || $('

back

'); 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(); + } }); -}; \ No newline at end of file +}; From 379c53344d25e97b10252b11bc1a91599d24e7df Mon Sep 17 00:00:00 2001 From: Lucas Arduini Date: Sat, 10 Mar 2012 02:58:49 -0500 Subject: [PATCH 2/2] updated docs to indicate usage of options argument in card component --- docs/index.html | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/index.html b/docs/index.html index e25c46e..1198dbb 100644 --- a/docs/index.html +++ b/docs/index.html @@ -508,6 +508,14 @@

Example

}) +

You can also include an object as a third argument to prevent the card component from flipping when clicked. If this argument is not specified, the default behavior is to flip when clicked.

+ +
+	    
+    var card = ui.card('<p>I will not flip when clicked</p>', '<p>You must have clicked another element</p>', {self_flip: false});
+    card.el.appendTo('#card');
+            
+	  
@@ -626,4 +634,4 @@

Example

- \ No newline at end of file +