diff -r 78f71aa0a477 -r 547b3ddedf7f integration/js/edition.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/integration/js/edition.js Thu May 16 12:58:48 2013 +0200
@@ -0,0 +1,421 @@
+(function(){
+
+var global = {
+ diaporama : null,
+ idAnnotation : null
+};
+
+//modal
+ $('.popup').on('click', '.popup-content a', function(e){
+ e.preventDefault();
+ if($(this).hasClass('btn-cancel')){
+ $(this).parents('.popup').modal('hide');
+ }
+ if($(this).hasClass('btn-previsualisation')){
+ var imgPrev = $('
');
+ $('.previsualisation').empty().append(imgPrev);
+ }
+ });
+//edition image
+ $('.popup').on('change', '#media-type-select', function(e){
+ var typeImage = $(this).val();
+ $('.input-image-url, .input-image-upload').hide();
+ $('.input-image-'+typeImage).show();
+ });
+//bibliotheque
+ //video
+ $('.popup').on('click', '.bibliotheque-video a', function(e){
+ e.preventDefault();
+ $('.popup').modal('hide');
+ $.get('template.html', function(templates){
+ var videoWrap = $('#'+global.idAnnotation).find('.annotation-video-content'),
+ tplVideo = $(templates).filter('#tpl-video-row').html();
+ videoWrap.empty().append(tplVideo);
+ });
+
+ });
+ //image
+ $('.popup').on('click', '.bibliotheque-image a', function(e){
+ e.preventDefault();
+ var listDiaporama = $('#'+global.diaporama);
+ addImageToDiaporama(listDiaporama);
+ $('.popup').modal('hide');
+ });
+
+ $(document).on('click','.btn-delete', function(e){
+ e.preventDefault();
+ var titleMedia = $(this).attr('data-title'),
+ textModal = $('
Êtes-vous sûr de vouloir supprimer '+titleMedia+' ?
'), + eltDelete = $(this).attr('href'); + $("#modal-confirm #btn-delete-modal").attr('data-id-elt-delete', eltDelete); + $("#modal-confirm .modal-body").empty().append(textModal); + $("#modal-confirm").modal('show'); + + //si c'est une annotation et que la tab est ouverte, on la ferme + var type = $(this).attr('data-type'); + if(type == 'annotation'){ + var idAnnotation = $(this).attr('data-id'); + $('a[href=#annotation-'+idAnnotation+']').closest('li').remove(); + $('.tab-content #annotation'+idAnnotation).remove(); + $('#tab-list-annotation').tab('show'); + } + }); + + //confirmation suppression + $("#modal-confirm").on('click', '#btn-delete-modal', function(e){ + e.preventDefault(); + var idEltDelete = $(this).attr('data-id-elt-delete'); + $(idEltDelete).remove(); + $("#modal-confirm").modal('hide'); + }); + + + +//page edition + +//title-editor +$('.project-title-editor ._popover').bind('click',function(e){e.preventDefault()}); + $('.project-title-editor ._popover').popover({ + html : true, + content : function(){ + var previousValue = $('.project-title').text(), + formInput = + ''; + return formInput; + } + }); + + $('body').on('click', function (e) { + $('._popover').each(function () { + if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) { + $(this).popover('hide'); + } + }); + }); + + $('body').on('submit', '.project-title-editor-form', function(e){ + e.preventDefault(); + $('._popover').popover('hide'); + }); + + $(document).on('keyup', '.project-title-editor-input', function() { + $('.project-title').html($(this).val()); + }); +//chapter + $('.list-chapter-wrap').on('click', '.edit-chapter', function(e){ + e.preventDefault(); + var viewChapter = { + titre : 'titre du chapitre', + tags : 'tag 1, tag 2, tag 3', + description : 'lorem ipsum' + } + + $.get('template.html', function(templates){ + var tpl = $(templates).filter('#tpl-chapter-edit').html(); + var tpl = Mustache.render(tpl, viewChapter); + $('.form-chapter-edit').empty().append(tpl); + }); + }); + //nouveau chapitre + $('.chapter-widget').on('click', '.btn-cut-chapter', function(e){ + e.preventDefault(); + var uniqId = 'id' + (new Date()).getTime(); + $.get('template.html', function(templates){ + var viewChapterRow = { + id : uniqId + }; + var tpl = $(templates).filter('#tpl-chapter-row').html(); + var tpl = Mustache.render(tpl, viewChapterRow); + $('.list-chapter-rows-wrap').append(tpl); + }); + }); +//tab + $('#annotation-tab').on('click', 'a', function(e){ + e.preventDefault(); + $(this).tab('show'); + }); + $('#annotation-tab a:last-child').tab('show'); + + //fermer tab + $('#annotation-tab').on('click', 'span.close-tab', function(e){ + e.preventDefault();e.stopPropagation(); + var idTab = $(this).parents('a').attr('href'); + $(this).closest('li').remove(); + $('.tab-content '+idTab).remove(); + $('#tab-list-annotation').tab('show'); + }); + + //ouvrir tab + $(document).on('click', '.open-tab', function(e){ + e.preventDefault(); + var type = $(this).attr('data-type'); + var data = $(this).attr('data-data'); // à définir + openNewTab(type); + }); + + //edit annotation + $('#list-annotations').on('click', 'a.btn-edit-annotation', function(e){ + e.preventDefault(); + + var idAnnotation = $(this).attr('data-id'); + //si il est déjà ouvert + if($('#annotation-'+idAnnotation).length){ + $('a[href=#annotation-'+idAnnotation+']').tab('show'); + }else{ + var typeAnnotation = $(this).attr('data-type'), + data = {id:idAnnotation}; + openNewTab(typeAnnotation, data); + } + }); + + function openNewTab(type, data){ + + var uniqId = 'id' + (new Date()).getTime(), + idAnnotation = (data !== undefined) ? data.id : uniqId, + tabContent = $(''), + iconTab; + + + $.get('template.html', function(templates){ + //head commun à tous + var view = { + titre : "un titre mustache", + id : uniqId + }; + var tplHead = $(templates).filter('#tpl-head').html(); + var output = Mustache.render(tplHead, view); + $(tabContent).append(output); + $(tabContent).find(".slider-duration").slider(configSlider); + + //type + var viewType = {id : uniqId}; + var tpl = $(templates).filter('#tpl-'+type).html(); + tpl = Mustache.render(tpl, viewType); + $(tabContent).append(tpl); + $('.tab-content').append(tabContent); + + //particularité selon type + switch(type){ + case 'video': iconTab = 'film'; + break; + case 'text': + iconTab = 'align-left'; + $(tabContent).find('.wysiwyg').cleditor(wysiwygConfig); + break; + case 'html': iconTab = 'link'; + break; + case 'diaporama': iconTab = 'picture'; + $(tabContent).find('.number-spin').spin(spinParam); + $(tabContent).find('.ui-sortable').sortable({ + stop : function(event, ui){ + disabledBtnSortable($(this)); + } + }); + break; + } + $(".nav-tabs li:last-child").after('"], ["Header 1", "