Dotclear

source: admin/js/_media_item.js @ 3369:363b4b1ded64

Revision 3369:363b4b1ded64, 2.2 KB checked in by franck <carnet.franck.paul@…>, 9 years ago (diff)

Add overlay (using magnific-popup jQuery plugin) preview of images in media manager

Line 
1$(function() {
2     // Add datePicker if possible
3     var media_dt = document.getElementById('media_dt');
4     if (media_dt != undefined) {
5          var post_dtPick = new datePicker(media_dt);
6          post_dtPick.img_top = '1.5em';
7          post_dtPick.draw();
8     }
9
10     // Preview media
11     $('.modal-image').magnificPopup({ type:'image' });
12
13     // Display zip file content
14     $('#file-unzip').each(function() {
15          var a = document.createElement('a');
16          var mediaId = $(this).find('input[name=id]').val();
17          var self = $(this);
18
19          a.href = '#';
20          $(a).text(dotclear.msg.zip_file_content);
21          self.before(a);
22          $(a).wrap('<p></p>');
23
24          $(a).click(function() {
25               $.get('services.php',{f:'getZipMediaContent',id: mediaId},function(data) {
26                    var rsp = $(data).children('rsp')[0];
27
28                    if (rsp.attributes[0].value == 'ok') {
29                         var div = document.createElement('div');
30                         var list = document.createElement('ul');
31                         var expanded = false;
32
33                         $(div).css({
34                              overflow: 'auto',
35                              margin: '1em 0',
36                              padding: '1px 0.5em'
37                         });
38                         $(div).addClass('color-div');
39                         $(div).append(list);
40                         self.before(div);
41                         $(a).hide();
42                         $(div).before('<h3>' + dotclear.msg.zip_file_content + '</h3>');
43
44                         $(rsp).find('file').each(function() {
45                              $(list).append('<li>' + $(this).text() + '</li>');
46                              if ($(div).height() > 200 && !expanded) {
47                                   $(div).css({height: '200px'});
48                                   expanded = true;
49                              }
50                         });
51                    } else {
52                         alert($(rsp).find('message').text());
53                    }
54               });
55               return false;
56          });
57     });
58
59     // Confirm for inflating in current directory
60     $('#file-unzip').submit(function() {
61          if ($(this).find('#inflate_mode').val() == 'current') {
62               return window.confirm(dotclear.msg.confirm_extract_current);
63          }
64          return true;
65     });
66
67     // Confirm for deleting current medoa
68     $('#delete-form input[name="delete"]').click(function() {
69          return window.confirm(dotclear.msg.confirm_delete_media);
70     });
71
72     // Get current insertion settings
73     $('#save_settings').submit(function() {
74          $('input[name="pref_src"]').val($('input[name="src"][type=radio]:checked').attr('value'));
75          $('input[name="pref_alignment"]').val($('input[name="alignment"][type=radio]:checked').attr('value'));
76          $('input[name="pref_insertion"]').val($('input[name="insertion"][type=radio]:checked').attr('value'));
77     });
78
79});
Note: See TracBrowser for help on using the repository browser.

Sites map