integration/js/ressource.js
author Anthony Ly <anthonyly.com@gmail.com>
Thu, 16 May 2013 13:08:20 +0200
changeset 8 7a5de13173b1
parent 6 547b3ddedf7f
child 9 e3d551eda5a6
permissions -rw-r--r--
hide bibliotheque link on home and resource page
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
     1
(function(){
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
	$('.tab-behavior a').click(function (e) {
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
     4
	    e.preventDefault();
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
     5
	    $(this).tab('show');
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
    $(document).on('click', 'a.open-modal', function(e){
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
     9
        e.preventDefault();
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    10
        var modalRemote = $(this).attr('href'),
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    11
            typeMedia = $(this).attr('data-type-media'),
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    12
            modalTitleInfo = $(this).attr('data-title'),
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    13
            titleFront;
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    14
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    15
        switch(typeMedia){
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    16
            case 'video' : titleFront = '<i class="icon-film"></i> Vidéo - '+modalTitleInfo; break;
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    17
            case 'image' : titleFront = '<i class="icon-picture"></i> Image - '+modalTitleInfo; break;
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    18
        }
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    19
        $('#modal-template .modal-header h3').html(titleFront);
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    20
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    21
        $("#modal-template .modal-body").load(modalRemote, function() { 
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    22
            $("#modal-template").modal("show"); 
8
7a5de13173b1 hide bibliotheque link on home and resource page
Anthony Ly <anthonyly.com@gmail.com>
parents: 6
diff changeset
    23
            $("#modal-template").find(".bibliotheque-link").hide();
6
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    24
        });
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
    });
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    27
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    28
//confirmation suppression
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    29
    $(document).on('click','.btn-delete', function(e){
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    30
        e.preventDefault();
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    31
        var titleMedia = $(this).attr('data-title'),
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    32
            textModal = $('<p>Êtes-vous sûr de vouloir supprimer <strong>'+titleMedia+'</strong> ?</p>'),
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    33
            eltDelete = $(this).attr('href');
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    34
        $("#modal-confirm #btn-delete-modal").attr('data-id-elt-delete', eltDelete);
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    35
        $("#modal-confirm .modal-body").empty().append(textModal); 
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    36
        $("#modal-confirm").modal('show');
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
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    39
    $("#modal-confirm").on('click', '#btn-delete-modal', 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 idEltDelete = $(this).attr('data-id-elt-delete');
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    42
        $(idEltDelete).remove();
547b3ddedf7f organisation des fichiers
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    43
        $("#modal-confirm").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
})(jQuery);