integration/js/edition.js
changeset 49 06627f23df42
parent 48 827066f875c7
child 51 c7ece022eca8
equal deleted inserted replaced
48:827066f875c7 49:06627f23df42
   135 
   135 
   136 //bibliotheque
   136 //bibliotheque
   137     //video
   137     //video
   138     $('.popup').on('click', '.bibliotheque-video a', function(e){
   138     $('.popup').on('click', '.bibliotheque-video a', function(e){
   139         e.preventDefault();
   139         e.preventDefault();
       
   140 
       
   141         var url = $(this).attr('href');
       
   142         currentAnnotation.content.url = url;
       
   143 
   140         $('.popup').modal('hide');
   144         $('.popup').modal('hide');
   141         $.get('template.html', function(templates){
   145         $.get('template.html', function(templates){
   142             var videoWrap = $('#tab-'+global.idAnnotation).find('.annotation-video-content'),
   146             var videoWrap = $('#tab-'+global.idAnnotation).find('.annotation-video-content'),
   143                 tplVideo = $(templates).filter('#tpl-video-row').html();
   147                 tplVideo = $(templates).filter('#tpl-video-row').html();
   144                 console.log(videoWrap)
       
   145             videoWrap.empty().append(tplVideo);
   148             videoWrap.empty().append(tplVideo);
   146         });
   149         });
   147         
   150         
   148     });
   151     });
   149     //image
   152     //image
   503             iconTab;
   506             iconTab;
   504 
   507 
   505         currentAnnotation = _.find(annotations, function(c){ return c.id == idAnnotation; });
   508         currentAnnotation = _.find(annotations, function(c){ return c.id == idAnnotation; });
   506 
   509 
   507         $.get('template.html', function(templates){
   510         $.get('template.html', function(templates){
       
   511 
   508             //head commun à tous
   512             //head commun à tous
   509             var tplHead = $(templates).filter('#tpl-head').html();
   513             var tplHead = $(templates).filter('#tpl-head').html();
   510             var output = Mustache.render(tplHead, dataView);
   514             var output = Mustache.render(tplHead, dataView);
   511             $(tabContent).append(output);
   515             $(tabContent).append(output);
   512             $(tabContent).find(".slider-duration").slider(configSlider(dataView));
   516             $(tabContent).find(".slider-duration").slider(configSlider(dataView));
   513             $(tabContent).find('.tag-it').tagit(tagitParam);
   517             $(tabContent).find('.tag-it').tagit(tagitParam);
   514             //type
   518             //type
   515             var viewType = {id : idAnnotation};
   519             var viewType = {
       
   520                 id : idAnnotation,
       
   521                 content : dataView.content
       
   522             };
   516             var tpl = $(templates).filter('#tpl-'+type).html();
   523             var tpl = $(templates).filter('#tpl-'+type).html();
       
   524 
   517             tpl = Mustache.render(tpl, viewType);
   525             tpl = Mustache.render(tpl, viewType);
   518             $(tabContent).append(tpl);
   526             $(tabContent).append(tpl);
   519             $('.tab-content').append(tabContent);
   527             $('.tab-content').append(tabContent);
   520 
   528 
   521             //particularité selon type
   529             //particularité selon type
   522             switch(type){
   530             switch(type){
   523                 case 'audio':
   531                 case 'audio':
   524                     break;
   532                     break;
   525                 case 'video':
   533                 case 'video':
       
   534                     
       
   535                     if(viewType.content.url != ""){
       
   536                         var videoWrap = $(tabContent).find('.annotation-video-content'),
       
   537                             tplVideo = $(templates).filter('#tpl-video-row').html();
       
   538                         videoWrap.empty().append(tplVideo);
       
   539                     }
       
   540 
   526                     break;
   541                     break;
   527                 case 'text': 
   542                 case 'text': 
   528                     var cledit = $(tabContent).find('.wysiwyg').cleditor(wysiwygConfig)[0];
   543                     var cledit = $(tabContent).find('.wysiwyg').cleditor(wysiwygConfig)[0];
   529                     break;
   544                     break;
   530                 case 'links': 
   545                 case 'links': 
   531                     var tbody = $(tabContent).find('tbody.links-rows');
   546                     var tbody = $(tabContent).find('tbody.links-rows'),
   532                     addLinkRow(tbody);
   547                         links = viewType.content.links;
       
   548                     if(links.length){
       
   549                         $.each(links, function(k,v){
       
   550                             addLinkRow(tbody, v);
       
   551                         });
       
   552                     }else{//il n'y a pas de lien on en ajoute 1
       
   553                         addLinkRow(tbody);
       
   554                     }
   533                     break;
   555                     break;
       
   556 
   534                 case 'slideshow': 
   557                 case 'slideshow': 
   535                     $(tabContent).find('.number-spin').spin(spinParam);
   558                     $(tabContent).find('.number-spin').spin(spinParam);
   536                     $(tabContent).find('.ui-sortable').sortable({
   559                     $(tabContent).find('.ui-sortable').sortable({
   537                         stop : function(event, ui){
   560                         stop : function(event, ui){
   538                             disabledBtnSortable($(this));
   561                             disabledBtnSortable($(this));
   672     currentAnnotation.content.links = links;
   695     currentAnnotation.content.links = links;
   673 }
   696 }
   674 
   697 
   675 
   698 
   676 //annotation html
   699 //annotation html
       
   700 /*
   677 $('.tab-content').on('click', '.btn-html-apercu', function(e){
   701 $('.tab-content').on('click', '.btn-html-apercu', function(e){
   678     e.preventDefault();
   702     e.preventDefault();
   679 
   703 
   680     var apercuWrap = $(this).parents('.edit-annotation-html').find('.html-apercu'),
   704     var apercuWrap = $(this).parents('.edit-annotation-html').find('.html-apercu'),
   681         htmlTextarea = $(this).parents('.edit-annotation-html').find('textarea');
   705         htmlTextarea = $(this).parents('.edit-annotation-html').find('textarea');
   682 
   706 
   683     apercuWrap.empty().html(htmlTextarea.val());
   707     apercuWrap.empty().html(htmlTextarea.val());
   684 });
   708 });
   685 
   709 */
   686 //annotation texte
   710 
   687 $(document).on('keyup', ".cleditorMain iframe", function(){
   711 //annotation audio
   688 
   712 $('.tab-content').on('keyup', '.annotation-audio-content input, .annotation-audio-content textarea', function(){
   689     var v = $(this).text(); // or .html() if desired
   713     var name = $(this).attr('name'),
   690     $('#x').html(v);
   714         value = $(this).val();
   691 });
   715 
   692 //annotation > diaporama (spin)
   716     currentAnnotation.content[name] = value;
   693 
   717 });
   694 
   718 
   695 //################ config
   719 //################ config
   696 
   720 
   697 //tagit
   721 //tagit
   698 function onTagItChange(e, ui) {
   722 function onTagItChange(e, ui) {
   728                     ["Header 3", "<h3>"],  ["Header 4","<h4>"],  ["Header 5","<h5>"],
   752                     ["Header 3", "<h3>"],  ["Header 4","<h4>"],  ["Header 5","<h5>"],
   729                     ["Header 6","<h6>"]],
   753                     ["Header 6","<h6>"]],
   730     docType:      '<!DOCTYPE HTML>',
   754     docType:      '<!DOCTYPE HTML>',
   731     bodyStyle:    "margin:0; font-family: 'Helvetica Neue',​Helvetica,​Arial,​sans-serif;",
   755     bodyStyle:    "margin:0; font-family: 'Helvetica Neue',​Helvetica,​Arial,​sans-serif;",
   732     updateTextArea : function(text){
   756     updateTextArea : function(text){
   733 
   757         currentAnnotation.content.text = text;
   734         return text;
   758         return text;
   735     },
   759     },
   736     updateFrame: function(text){
   760     updateFrame: function(text){
   737   
   761         currentAnnotation.content.text = text;
   738         return text;
   762         return text;
   739     }
   763     }
   740 };
   764 };
   741 
   765 
   742 //slider
   766 //slider
   791             break;
   815             break;
   792         case 'text': 
   816         case 'text': 
   793             content = {
   817             content = {
   794                 mimetype : "application/x-ldt-text",
   818                 mimetype : "application/x-ldt-text",
   795                 markup : "html",
   819                 markup : "html",
   796                 text : ""
   820                 text : "azerty"
   797             };
   821             };
   798             break;
   822             break;
   799         case 'links': 
   823         case 'links': 
   800             content = {
   824             content = {
   801                 mimetype : "application/x-ldt-links",
   825                 mimetype : "application/x-ldt-links",
   802                 markup : "html",
       
   803                 links : []
   826                 links : []
   804             };
   827             };
   805             break;
   828             break;
   806         case 'slideshow': 
   829         case 'slideshow': 
   807             content = {
   830             content = {
   815     return content;
   838     return content;
   816 }//getContentAnnotationByType
   839 }//getContentAnnotationByType
   817 
   840 
   818 
   841 
   819 //test
   842 //test
   820 a = $(".wysiwyg").cleditor(wysiwygConfig);
   843 //a = $(".wysiwyg").cleditor(wysiwygConfig);
   821 
   844 
   822 
   845 
   823 $('.number-spin').spin(spinParam);
   846 $('.number-spin').spin(spinParam);
   824 
   847 
   825 disabledBtnSortable($('.ui-sortable'))
   848 disabledBtnSortable($('.ui-sortable'))
   833 
   856 
   834 $(".tag-it").tagit();
   857 $(".tag-it").tagit();
   835 
   858 
   836 $('.log-annotations').bind('click', function(e){
   859 $('.log-annotations').bind('click', function(e){
   837     e.preventDefault();
   860     e.preventDefault();
   838     console.log(annotations);
   861     console.log(annotations.length + ' annotations', annotations);
   839 });
   862 });
   840 
   863 
   841 $('.log-chapters').bind('click', function(e){
   864 $('.log-chapters').bind('click', function(e){
   842     e.preventDefault();
   865     e.preventDefault();
   843     console.log(chapters);
   866     console.log(chapters.length + ' chapitres',chapters);
   844 });
   867 });
   845 });//ready
   868 });//ready