diff -r 827066f875c7 -r 06627f23df42 integration/js/edition.js --- a/integration/js/edition.js Mon May 27 17:48:17 2013 +0200 +++ b/integration/js/edition.js Tue May 28 11:39:25 2013 +0200 @@ -137,11 +137,14 @@ //video $('.popup').on('click', '.bibliotheque-video a', function(e){ e.preventDefault(); + + var url = $(this).attr('href'); + currentAnnotation.content.url = url; + $('.popup').modal('hide'); $.get('template.html', function(templates){ var videoWrap = $('#tab-'+global.idAnnotation).find('.annotation-video-content'), tplVideo = $(templates).filter('#tpl-video-row').html(); - console.log(videoWrap) videoWrap.empty().append(tplVideo); }); @@ -505,6 +508,7 @@ currentAnnotation = _.find(annotations, function(c){ return c.id == idAnnotation; }); $.get('template.html', function(templates){ + //head commun à tous var tplHead = $(templates).filter('#tpl-head').html(); var output = Mustache.render(tplHead, dataView); @@ -512,8 +516,12 @@ $(tabContent).find(".slider-duration").slider(configSlider(dataView)); $(tabContent).find('.tag-it').tagit(tagitParam); //type - var viewType = {id : idAnnotation}; + var viewType = { + id : idAnnotation, + content : dataView.content + }; var tpl = $(templates).filter('#tpl-'+type).html(); + tpl = Mustache.render(tpl, viewType); $(tabContent).append(tpl); $('.tab-content').append(tabContent); @@ -523,14 +531,29 @@ case 'audio': break; case 'video': + + if(viewType.content.url != ""){ + var videoWrap = $(tabContent).find('.annotation-video-content'), + tplVideo = $(templates).filter('#tpl-video-row').html(); + videoWrap.empty().append(tplVideo); + } + break; case 'text': var cledit = $(tabContent).find('.wysiwyg').cleditor(wysiwygConfig)[0]; break; case 'links': - var tbody = $(tabContent).find('tbody.links-rows'); - addLinkRow(tbody); + var tbody = $(tabContent).find('tbody.links-rows'), + links = viewType.content.links; + if(links.length){ + $.each(links, function(k,v){ + addLinkRow(tbody, v); + }); + }else{//il n'y a pas de lien on en ajoute 1 + addLinkRow(tbody); + } break; + case 'slideshow': $(tabContent).find('.number-spin').spin(spinParam); $(tabContent).find('.ui-sortable').sortable({ @@ -674,6 +697,7 @@ //annotation html +/* $('.tab-content').on('click', '.btn-html-apercu', function(e){ e.preventDefault(); @@ -682,15 +706,15 @@ apercuWrap.empty().html(htmlTextarea.val()); }); - -//annotation texte -$(document).on('keyup', ".cleditorMain iframe", function(){ +*/ - var v = $(this).text(); // or .html() if desired - $('#x').html(v); +//annotation audio +$('.tab-content').on('keyup', '.annotation-audio-content input, .annotation-audio-content textarea', function(){ + var name = $(this).attr('name'), + value = $(this).val(); + + currentAnnotation.content[name] = value; }); -//annotation > diaporama (spin) - //################ config @@ -730,11 +754,11 @@ docType: '', bodyStyle: "margin:0; font-family: 'Helvetica Neue',​Helvetica,​Arial,​sans-serif;", updateTextArea : function(text){ - + currentAnnotation.content.text = text; return text; }, updateFrame: function(text){ - + currentAnnotation.content.text = text; return text; } }; @@ -793,13 +817,12 @@ content = { mimetype : "application/x-ldt-text", markup : "html", - text : "" + text : "azerty" }; break; case 'links': content = { mimetype : "application/x-ldt-links", - markup : "html", links : [] }; break; @@ -817,7 +840,7 @@ //test -a = $(".wysiwyg").cleditor(wysiwygConfig); +//a = $(".wysiwyg").cleditor(wysiwygConfig); $('.number-spin').spin(spinParam); @@ -835,11 +858,11 @@ $('.log-annotations').bind('click', function(e){ e.preventDefault(); - console.log(annotations); + console.log(annotations.length + ' annotations', annotations); }); $('.log-chapters').bind('click', function(e){ e.preventDefault(); - console.log(chapters); + console.log(chapters.length + ' chapitres',chapters); }); });//ready \ No newline at end of file