integration/js/edition.js
author Anthony Ly <anthonyly.com@gmail.com>
Thu, 16 May 2013 14:00:50 +0200
changeset 9 e3d551eda5a6
parent 6 547b3ddedf7f
child 16 c66274d0d850
permissions -rw-r--r--
ajout de common.js
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
     1
$(function(){
6
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
     2
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
     3
var global = {
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
     4
    diaporama : null,
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
     5
    idAnnotation : null
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
     6
};
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
     7
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
     8
//modal
9
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
     9
    $(document).on('click', 'a.open-modal', function(e){
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
    10
        var diaporama = $(this).attr('data-diaporama'),
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
    11
            idAnnotation = $(this).attr('data-id');
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
    12
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
    13
        if(diaporama !== undefined){
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
    14
            global.diaporama = diaporama;
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
    15
        }
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
    16
        if(idAnnotation !== undefined){
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
    17
            global.idAnnotation = idAnnotation;
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
    18
        }
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
    19
    })
6
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    20
//edition image
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    21
    $('.popup').on('change', '#media-type-select', function(e){
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    22
        var typeImage = $(this).val();
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    23
        $('.input-image-url, .input-image-upload').hide();
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    24
        $('.input-image-'+typeImage).show();
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    25
    });
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    26
//bibliotheque
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    27
    //video
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    28
    $('.popup').on('click', '.bibliotheque-video a', function(e){
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    29
        e.preventDefault();
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    30
        $('.popup').modal('hide');
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    31
        $.get('template.html', function(templates){
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    32
            var videoWrap = $('#'+global.idAnnotation).find('.annotation-video-content'),
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    33
                tplVideo = $(templates).filter('#tpl-video-row').html();
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    34
            videoWrap.empty().append(tplVideo);
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    35
        });
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    36
        
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    37
    });
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    38
    //image
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    39
    $('.popup').on('click', '.bibliotheque-image a', function(e){
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    40
        e.preventDefault();
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    41
        var listDiaporama = $('#'+global.diaporama);
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    42
        addImageToDiaporama(listDiaporama);
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    43
        $('.popup').modal('hide');
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    44
    });
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    45
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    46
    $(document).on('click','.btn-delete', function(e){
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    47
        e.preventDefault();
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    48
        //si c'est une annotation et que la tab est ouverte, on la ferme
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    49
        var type = $(this).attr('data-type');
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    50
        if(type == 'annotation'){
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    51
            var idAnnotation = $(this).attr('data-id');
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    52
            $('a[href=#annotation-'+idAnnotation+']').closest('li').remove();
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    53
            $('.tab-content #annotation'+idAnnotation).remove();
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    54
            $('#tab-list-annotation').tab('show');
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    55
        }
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    56
    });
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    57
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    58
    //confirmation suppression
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    59
    $("#modal-confirm").on('click', '#btn-delete-modal', function(e){
9
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
    60
6
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    61
    });
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    62
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    63
//title-editor
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    64
$('.project-title-editor ._popover').bind('click',function(e){e.preventDefault()});
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    65
    $('.project-title-editor ._popover').popover({
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    66
        html : true,
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    67
        content : function(){
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    68
            var previousValue = $('.project-title').text(),
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    69
                formInput = 
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    70
                    '<form action="#" class="project-title-editor-form">'+
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    71
                        '<input type="text" class="project-title-editor-input" value="'+previousValue+'">'+
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    72
                    '</form>';
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    73
            return formInput;
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    74
        }
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    75
    });
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    76
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    77
    $('body').on('click', function (e) {
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    78
        $('._popover').each(function () {
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    79
            if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    80
                $(this).popover('hide');
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    81
            }
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    82
        });
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    83
    });
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    84
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    85
    $('body').on('submit', '.project-title-editor-form', function(e){
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    86
        e.preventDefault();
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    87
        $('._popover').popover('hide');
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    88
    });
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    89
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    90
    $(document).on('keyup', '.project-title-editor-input', function() {
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    91
        $('.project-title').html($(this).val());
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    92
    });
9
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
    93
6
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    94
//chapter
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    95
    $('.list-chapter-wrap').on('click', '.edit-chapter', function(e){
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    96
        e.preventDefault();
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    97
        var viewChapter = {
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    98
            titre : 'titre du chapitre',
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    99
            tags : 'tag 1, tag 2, tag 3',
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   100
            description : 'lorem ipsum'
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   101
        }
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   102
        
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   103
        $.get('template.html', function(templates){
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   104
            var tpl = $(templates).filter('#tpl-chapter-edit').html();
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   105
            var tpl = Mustache.render(tpl, viewChapter);
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   106
            $('.form-chapter-edit').empty().append(tpl);
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   107
        });
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   108
    });
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   109
    //nouveau chapitre
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   110
    $('.chapter-widget').on('click', '.btn-cut-chapter', function(e){
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   111
        e.preventDefault();
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   112
        var uniqId = 'id' + (new Date()).getTime();
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   113
        $.get('template.html', function(templates){
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   114
            var viewChapterRow = {
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   115
                    id : uniqId
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   116
                };
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   117
            var tpl = $(templates).filter('#tpl-chapter-row').html();
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   118
            var tpl = Mustache.render(tpl, viewChapterRow);
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   119
            $('.list-chapter-rows-wrap').append(tpl);
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   120
        });
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   121
    });
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   122
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   123
    
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   124
    //edit annotation
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   125
    $('#list-annotations').on('click', 'a.btn-edit-annotation', function(e){
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   126
        e.preventDefault();
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   127
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   128
        var idAnnotation = $(this).attr('data-id');
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   129
        //si il est déjà ouvert
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   130
        if($('#annotation-'+idAnnotation).length){
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   131
            $('a[href=#annotation-'+idAnnotation+']').tab('show');
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   132
        }else{
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   133
            var typeAnnotation = $(this).attr('data-type'),
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   134
                data = {id:idAnnotation};
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   135
            openNewTab(typeAnnotation, data);
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   136
        } 
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   137
    });
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   138
9
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   139
//tab
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   140
    $('#annotation-tab').on('click', 'a', function(e){
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   141
        e.preventDefault();
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   142
        $(this).tab('show');
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   143
    });
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   144
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   145
    //ouvrir tab
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   146
    $(document).on('click', '.open-tab', function(e){
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   147
        e.preventDefault();
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   148
        var type = $(this).attr('data-type');
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   149
        var data = $(this).attr('data-data'); // à définir
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   150
        openNewTab(type);
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   151
    });
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   152
6
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   153
    function openNewTab(type, data){
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   154
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   155
        var uniqId = 'id' + (new Date()).getTime(),
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   156
            idAnnotation = (data !== undefined) ? data.id : uniqId,
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   157
            tabContent = $('<div class="tab-pane" id="annotation-'+idAnnotation+'"></div>'),
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   158
            iconTab;
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   159
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   160
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   161
        $.get('template.html', function(templates){
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   162
            //head commun à tous
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   163
            var view = {
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   164
                    titre : "un titre mustache",
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   165
                    id : uniqId
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   166
                };
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   167
            var tplHead = $(templates).filter('#tpl-head').html();
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   168
            var output = Mustache.render(tplHead, view);
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   169
            $(tabContent).append(output);
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   170
            $(tabContent).find(".slider-duration").slider(configSlider);
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   171
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   172
            //type
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   173
            var viewType = {id : uniqId};
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   174
            var tpl = $(templates).filter('#tpl-'+type).html();
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   175
            tpl = Mustache.render(tpl, viewType);
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   176
            $(tabContent).append(tpl);
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   177
            $('.tab-content').append(tabContent);
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   178
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   179
            //particularité selon type
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   180
            switch(type){
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   181
                case 'video': iconTab = 'film';
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   182
                    break;
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   183
                case 'text': 
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   184
                    iconTab = 'align-left';
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   185
                    $(tabContent).find('.wysiwyg').cleditor(wysiwygConfig);
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   186
                    break;
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   187
                case 'html': iconTab = 'link';
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   188
                    break;
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   189
                case 'diaporama': iconTab = 'picture';
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   190
                    $(tabContent).find('.number-spin').spin(spinParam);
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   191
                    $(tabContent).find('.ui-sortable').sortable({
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   192
                        stop : function(event, ui){
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   193
                            disabledBtnSortable($(this));
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   194
                        }
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   195
                    });
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   196
                    break;
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   197
            }
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   198
            $(".nav-tabs li:last-child").after('<li><a href="#annotation-'+idAnnotation+'"><i class="icon-'+iconTab+'"></i> New <span class="close-tab">&times;</span></a></li>');
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   199
            $('a[href=#annotation-'+idAnnotation+']').tab('show');
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   200
        });
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   201
    }//openNewTab()
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   202
9
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   203
    //fermer tab
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   204
    $('#annotation-tab').on('click', 'span.close-tab', function(e){
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   205
        e.preventDefault();e.stopPropagation();
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   206
        var idTab = $(this).parents('a').attr('href');
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   207
        $(this).closest('li').remove();
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   208
        $('.tab-content '+idTab).remove();
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   209
        $('#tab-list-annotation').tab('show');
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   210
    });
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   211
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   212
6
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   213
//diaporama
9
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   214
    function addImageToDiaporama(diaporama){
6
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   215
        $.get('template.html', function(templates){
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   216
            var tplDiapo = $(templates).filter('#tpl-diaporama-row').html(),
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   217
                uniqId = 'id' + (new Date()).getTime(),
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   218
                viewDiapo = { ridid : uniqId};
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   219
            tplDiapo = Mustache.render(tplDiapo, viewDiapo);
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   220
            diaporama.append(tplDiapo);
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   221
            disabledBtnSortable(diaporama);
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   222
        });
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   223
    };
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   224
9
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   225
    //bouton up / down
6
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   226
    $(document).on('click', '.ui-sortable .btn-sort', function(e){
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   227
        e.preventDefault();
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   228
        var row = $(this).parents('tr.row-image-diaporama'),
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   229
            listDiaporama = $(this).parents('.list-image-diaporama');
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   230
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   231
        if($(this).hasClass('down'))
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   232
            row.insertAfter(row.next());
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   233
        else if($(this).hasClass('up'))
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   234
            row.insertBefore(row.prev());
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   235
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   236
        disabledBtnSortable(listDiaporama);
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   237
    });
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   238
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   239
    function disabledBtnSortable(listDiaporama){
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   240
        listDiaporama.find('.btn-sort.disabled').removeClass('disabled');
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   241
        listDiaporama.find('tr.row-image-diaporama:first-child').find('.btn-sort.up').addClass('disabled');
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   242
        listDiaporama.find('tr.row-image-diaporama:last-child').find('.btn-sort.down').addClass('disabled');
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   243
    }
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   244
9
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   245
    
6
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   246
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   247
//sauvegarder annotation
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   248
$('.tab-content').on('click', '.btn-save-annotation', function(e){
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   249
    e.preventDefault();
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   250
    var idAnnotation = $(this).attr('data-id');
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   251
});
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   252
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   253
//annotation html
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   254
$('.tab-content').on('click', '.btn-html-apercu', function(e){
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   255
    e.preventDefault();
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   256
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   257
    var apercuWrap = $(this).parents('.edit-annotation-html').find('.html-apercu'),
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   258
        htmlTextarea = $(this).parents('.edit-annotation-html').find('textarea');
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   259
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   260
    apercuWrap.empty().html(htmlTextarea.val());
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   261
});
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   262
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   263
//annotation > diaporama (spin)
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   264
var spinParam = {
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   265
    imageBasePath :'lib/spin/img/',
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   266
    max:60,
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   267
    min:0
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   268
};
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   269
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   270
//config
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   271
//CLEditor annotation > text (wysiwyg)
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   272
//http://premiumsoftware.net/cleditor/docs/GettingStarted.html#optionalParameters
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   273
var wysiwygConfig = {
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   274
    width:        456, 
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   275
    height:       250, 
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   276
    controls:     "bold italic underline strikethrough | font size " +
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   277
                    "style | color highlight removeformat | bullets numbering | outdent ",
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   278
    fonts:        "Arial,Arial Black,Comic Sans MS,Courier New,Narrow,Garamond," +
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   279
                    "Georgia,Impact,Sans Serif,Serif,Tahoma,Trebuchet MS,Verdana",
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   280
    sizes:        "1,2,3,4,5,6,7",
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   281
    styles:       [["Paragraph", "<p>"], ["Header 1", "<h1>"], ["Header 2", "<h2>"],
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   282
                    ["Header 3", "<h3>"],  ["Header 4","<h4>"],  ["Header 5","<h5>"],
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   283
                    ["Header 6","<h6>"]],
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   284
    docType:      '<!DOCTYPE HTML>',
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   285
    bodyStyle:    "margin:0; font-family: 'Helvetica Neue',​Helvetica,​Arial,​sans-serif;"
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   286
};
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   287
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   288
//slider
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   289
var configSlider = {
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   290
    range: true,
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   291
    values: [ 0, 1*60*1000 ],
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   292
    min: 0,
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   293
    max: 10*60*1000,
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   294
    slide: function( event, ui ) {
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   295
        
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   296
        var debutString = millisecondsToString(ui.values[0]);
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   297
        var endString = millisecondsToString(ui.values[1]);
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   298
        var durationString = millisecondsToString(ui.values[1] - ui.values[0]);
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   299
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   300
        var idSlider = $(this).attr('data-id');
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   301
        
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   302
        $( '#'+ idSlider +'-begin' ).html(debutString);
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   303
        $( '#'+ idSlider +'-duration' ).html(durationString);
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   304
        $( '#'+ idSlider +'-end' ).html(endString);
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   305
        
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   306
    }
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   307
};
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   308
9
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   309
//milliseconds To 12h12m12s
6
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   310
function millisecondsToString(milliseconds) {
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   311
    var oneHour = 3600000;
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   312
    var oneMinute = 60000;
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   313
    var oneSecond = 1000;
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   314
    var seconds = 0;
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   315
    var minutes = 0;
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   316
    var hours = 0;
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   317
    var result;
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   318
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   319
    if (milliseconds >= oneHour) {
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   320
        hours = Math.floor(milliseconds / oneHour);
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   321
    }
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   322
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   323
    milliseconds = hours > 0 ? (milliseconds - hours * oneHour) : milliseconds;
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   324
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   325
    if (milliseconds >= oneMinute) {
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   326
        minutes = Math.floor(milliseconds / oneMinute);
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   327
    }
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   328
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   329
    milliseconds = minutes > 0 ? (milliseconds - minutes * oneMinute) : milliseconds;
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   330
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   331
    if (milliseconds >= oneSecond) {
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   332
        seconds = Math.floor(milliseconds / oneSecond);
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   333
    }
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   334
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   335
    milliseconds = seconds > 0 ? (milliseconds - seconds * oneSecond) : milliseconds;
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   336
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   337
    if (hours > 0) {
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   338
        result = (hours > 9 ? hours : "0" + hours) + "h";
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   339
    } else {
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   340
        result = "";
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   341
    }
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   342
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   343
    if (minutes > 0) {
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   344
        result += (minutes > 9 ? minutes : "0" + minutes) + "m";
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   345
    } else {
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   346
        result += "00m";
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   347
    }
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   348
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   349
    if (seconds > 0) {
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   350
        result += (seconds > 9 ? seconds : "0" + seconds) + "s";
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   351
    } else {
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   352
        result += "00s";
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   353
    }
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   354
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   355
    return result;
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
   356
}
9
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   357
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   358
//test
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   359
$(".wysiwyg").cleditor(wysiwygConfig);
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   360
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   361
$('.number-spin').spin(spinParam);
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   362
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   363
disabledBtnSortable($('.ui-sortable'))
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   364
$('.ui-sortable').sortable({
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   365
    stop : function(event, ui){
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   366
        disabledBtnSortable($(this));
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   367
    }
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   368
});
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   369
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   370
$('.slider-duration').slider(configSlider);
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   371
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   372
$('#annotation-tab a:last-child').tab('show');
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   373
e3d551eda5a6 ajout de common.js
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
   374
});