Projet

Général

Profil

« Précédent | Suivant » 

Révision c182b1ab

Ajouté par Frédéric Péters il y a plus de 8 ans

use wcs native version of fargo.js (#9680)

Voir les différences:

extra/modules/form.py
24 24
                                root_url, _('Pick a file on mon.Service-Public.fr'),
25 25
                                _('Use file from mon.Service-Public.fr'))
26 26
        if get_publisher().get_site_option('fargo_url') is not None and not self.preview:
27
            get_response().add_javascript(['../../aq/js/fargo.js'])
27
            get_response().add_javascript(['fargo.js'])
28 28
            t += htmltext('''<p class="use-file-from-fargo"><span
29 29
                               data-src="%sfargo/pick"
30 30
                               data-width="500"
static/js/fargo.js
1

  
2
$(function() {
3
  var iframe = $('<iframe frameborder="0" marginwidth="0" marginheight="0" allowfullscreen></iframe>');
4
  var dialog = $("<div></div>").append(iframe).appendTo("body").dialog({
5
        autoOpen: false,
6
        modal: true,
7
        resizable: false,
8
        width: "auto",
9
        height: "auto",
10
        close: function () {
11
            iframe.attr("src", "");
12
        }
13
  });
14
  $('p.use-file-from-fargo span').click(function(e) {
15
    e.preventDefault();
16
    var base_widget = $(this).parents('.file-upload-widget');
17
    document.fargo_set_token = function (token, title) {
18
       if (token) {
19
         $(base_widget).find('.filename').text(title);
20
         $(base_widget).find('.fileinfo').show();
21
         $(base_widget).find('input[type=hidden]').val(token);
22
         $(base_widget).find('input[type=file]').hide();
23
       }
24
       document.fargo_close_dialog();
25
    }
26
    document.fargo_close_dialog = function () {
27
       document.fargo_set_token = undefined;
28
       dialog.dialog('close');
29
    }
30
    var src = $(this).data('src');
31
    var title = $(this).data("title");
32
    var width = $(this).data("width");
33
    var height = $(this).data("height");
34
    iframe.attr({
35
        width: parseInt(width),
36
        height: parseInt(height),
37
        src: src
38
    });
39
    dialog.dialog("option", "title", title);
40
    dialog.dialog("open");
41
  });
42
});

Formats disponibles : Unified diff