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

This commit is contained in:
Frédéric Péters 2016-01-16 18:51:16 +01:00
parent 1532759996
commit c182b1ab78
2 changed files with 1 additions and 43 deletions

View File

@ -24,7 +24,7 @@ class FileWithPreviewAndStrongboxWidget(FileWithPreviewWidget):
root_url, _('Pick a file on mon.Service-Public.fr'),
_('Use file from mon.Service-Public.fr'))
if get_publisher().get_site_option('fargo_url') is not None and not self.preview:
get_response().add_javascript(['../../aq/js/fargo.js'])
get_response().add_javascript(['fargo.js'])
t += htmltext('''<p class="use-file-from-fargo"><span
data-src="%sfargo/pick"
data-width="500"

View File

@ -1,42 +0,0 @@
$(function() {
var iframe = $('<iframe frameborder="0" marginwidth="0" marginheight="0" allowfullscreen></iframe>');
var dialog = $("<div></div>").append(iframe).appendTo("body").dialog({
autoOpen: false,
modal: true,
resizable: false,
width: "auto",
height: "auto",
close: function () {
iframe.attr("src", "");
}
});
$('p.use-file-from-fargo span').click(function(e) {
e.preventDefault();
var base_widget = $(this).parents('.file-upload-widget');
document.fargo_set_token = function (token, title) {
if (token) {
$(base_widget).find('.filename').text(title);
$(base_widget).find('.fileinfo').show();
$(base_widget).find('input[type=hidden]').val(token);
$(base_widget).find('input[type=file]').hide();
}
document.fargo_close_dialog();
}
document.fargo_close_dialog = function () {
document.fargo_set_token = undefined;
dialog.dialog('close');
}
var src = $(this).data('src');
var title = $(this).data("title");
var width = $(this).data("width");
var height = $(this).data("height");
iframe.attr({
width: parseInt(width),
height: parseInt(height),
src: src
});
dialog.dialog("option", "title", title);
dialog.dialog("open");
});
});