shrink de l'image si écran rikiki.
[Portfolio.git] / skins / cart_listing.js
1 /*
2 * 2009 Benoit Pin - MINES ParisTech
3 * http://plinn.org
4 * Licence GPL
5 */
6
7 var CartListing;
8
9 (function(){
10 var ENTERKEY = 13;
11
12 CartListing = function(table) {
13 var thisCL = this;
14 this.table = table;
15 var form = table.parentNode;
16 while(form.tagName != 'FORM')
17 form = form.parentNode;
18
19 this.fm = new FormManager(form);
20
21 if (browser.isIE)
22 addListener(table, 'focusout', function(evt){thisCL.updateRow(evt);});
23 else
24 addListener(table, 'change', function(evt){thisCL.updateRow(evt);});
25
26 addListener(table, 'keypress', function(evt){thisCL.onKeypress(evt);});
27 }
28
29 CartListing.prototype.updateRow = function(evt) {
30 var target = getTargetedObject(evt);
31 if (target.tagName != 'INPUT')
32 return;
33
34
35 var row = target.parentNode.parentNode;
36 var inputs = row.getElementsByTagName('input')
37 var refreshBtn = inputs[1];
38 this.fm.submitButton = refreshBtn;
39 this.fm.submit(evt);
40 };
41
42 CartListing.prototype.onKeypress = function(evt){
43 if (evt.keyCode == ENTERKEY)
44 this.updateRow(evt);
45 };
46
47 })();