Project

General

Profile

0001-use-wcs-native-version-of-fargo.js-9680.patch

Frédéric Péters, 16 January 2016 06:52 PM

Download (2.73 KB)

View differences:

Subject: [PATCH] use wcs native version of fargo.js (#9680)

 extra/modules/form.py |  2 +-
 static/js/fargo.js    | 42 ------------------------------------------
 2 files changed, 1 insertion(+), 43 deletions(-)
 delete mode 100644 static/js/fargo.js
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
});
43
-