Mercurial > defr > drupal > scald > mee
diff mee.js @ 14:50a57b1517cb
Fully working MEE, with Ressource Manager & all
| author | Franck Deroche <franck@defr.org> |
|---|---|
| date | Fri, 18 Sep 2009 15:18:53 +0200 |
| parents | da5d54d099b1 |
| children | 75106ee96c1e |
line wrap: on
line diff
--- a/mee.js Mon Jun 08 18:33:19 2009 +0200 +++ b/mee.js Fri Sep 18 15:18:53 2009 +0200 @@ -26,7 +26,8 @@ .find('table.mee-ressource-manager') .each(function(i) { $(this).append(Drupal.mee.generate( - rep.title, + data.representation_id, + rep, Drupal.tableDrag[this.id] )); }); @@ -37,17 +38,29 @@ detach: function(e, data) { }, - generate: function(title, tableDrag) { - var $select = $("<select />"), $tr = $('<tr />'), $td = $("<td />"), parity; + generate: function(id, representation, tableDrag) { + var $weight = $("<select />"), $tr = $('<tr />'), $td = $("<td />"), parity; + var separator = $(tableDrag.table).find('div.mee-rm-separator select')[0]; + var wn = separator.name.replace(/\[0\]\[weight\]$/, '[' + id +'][weight]'); + var $required = $("<select />") + .attr('name', wn.replace(/\[weight\]$/, '[required]')) + .append("<option value='0'>"+ Drupal.t('Optional') +"</option>") + .append("<option value='1'>"+ Drupal.t('Required') +"</option>") + .val(representation.meta.action); + // If this ressource is already in the Ressource Manager, don't add a line + if ($('select[name="'+ wn +'"]', tableDrag.table).length) { + return ''; + } $tr .addClass('draggable') .append($('<td></td>')) - .append($('<td></td>').append(title)); + .append($('<td></td>').append(representation.title)) + .append($('<td></td>').append($required)); for (var i = -10; i <= 10; i++) { - $select.append("<option>"+ i +"</option>"); + $weight.append("<option>"+ i +"</option>"); } - $select.val(0).addClass('mee-rm-weight'); - $td.append($select); + $weight.val(0).addClass('mee-rm-weight').attr('name', wn); + $td.append($weight); $tr.append($td); parity = $(tableDrag.table).find('tr').size() % 2 ? 'odd' : 'even'; $tr.addClass(parity);
