Get embed code for pad and code

pull/1/head
yflory 7 years ago
parent 0bb6698399
commit 3ca9f41290

@ -172,7 +172,7 @@ define(function () {
out.viewOpen = "Voir dans un nouvel onglet"; out.viewOpen = "Voir dans un nouvel onglet";
out.viewOpenTitle = "Ouvrir le lien en lecture seule dans un nouvel onglet"; out.viewOpenTitle = "Ouvrir le lien en lecture seule dans un nouvel onglet";
out.fileShare = "Copier le lien"; out.fileShare = "Copier le lien";
out.fileEmbed = "Obtenir le code d'intégration"; out.getEmbedCode = "Obtenir le code d'intégration";
out.fileEmbedTitle = "Intégrer le fichier dans une page web"; out.fileEmbedTitle = "Intégrer le fichier dans une page web";
out.fileEmbedScript = "Pour intégrer un fichier, veuillez inclure le script suivant une fois dans votre page afin de pouvoir charger le Media Tag :"; out.fileEmbedScript = "Pour intégrer un fichier, veuillez inclure le script suivant une fois dans votre page afin de pouvoir charger le Media Tag :";
out.fileEmbedTag = "Ensuite vous pouvez placer ce Media Tag où vous souhaitez dans votre page pour l'intégrer :"; out.fileEmbedTag = "Ensuite vous pouvez placer ce Media Tag où vous souhaitez dans votre page pour l'intégrer :";

@ -174,7 +174,9 @@ define(function () {
out.viewOpen = "Open read-only link in a new tab"; out.viewOpen = "Open read-only link in a new tab";
out.viewOpenTitle = "Open this pad in read-only mode in a new tab"; out.viewOpenTitle = "Open this pad in read-only mode in a new tab";
out.fileShare = "Copy link"; out.fileShare = "Copy link";
out.fileEmbed = "Get embed code"; out.getEmbedCode = "Get embed code";
out.viewEmbedTitle = "";
out.viewEmbedTag = "";
out.fileEmbedTitle = "Embed the file in an external page"; out.fileEmbedTitle = "Embed the file in an external page";
out.fileEmbedScript = "To embed this file, include this script once in your page to load the Media Tag:"; out.fileEmbedScript = "To embed this file, include this script once in your page to load the Media Tag:";
out.fileEmbedTag = "Then place this Media Tag wherever in your page you would like to embed:"; out.fileEmbedTag = "Then place this Media Tag wherever in your page you would like to embed:";

@ -7,7 +7,7 @@ define([
return Math.random().toString(16).replace('0.', '') + Math.random().toString(16).replace('0.', ''); return Math.random().toString(16).replace('0.', '') + Math.random().toString(16).replace('0.', '');
}; };
var create = function (ow, cb) { var create = function (ow, cb, isSandbox) {
var otherWindow; var otherWindow;
var handlers = {}; var handlers = {};
var queries = {}; var queries = {};
@ -131,7 +131,7 @@ define([
console.log(msg); console.log(msg);
} }
}); });
if (window !== window.top) { if (isSandbox) {
// we're in the sandbox // we're in the sandbox
otherWindow = ow; otherWindow = ow;
cb(chan); cb(chan);

@ -230,31 +230,31 @@ define([
$userAdmin.find('a.logout').click(function () { $userAdmin.find('a.logout').click(function () {
Common.logout(function () { Common.logout(function () {
window.top.location = origin+'/'; window.parent.location = origin+'/';
}); });
}); });
$userAdmin.find('a.settings').click(function () { $userAdmin.find('a.settings').click(function () {
if (padType) { if (padType) {
window.open(origin+'/settings/'); window.open(origin+'/settings/');
} else { } else {
window.top.location = origin+'/settings/'; window.parent.location = origin+'/settings/';
} }
}); });
$userAdmin.find('a.profile').click(function () { $userAdmin.find('a.profile').click(function () {
if (padType) { if (padType) {
window.open(origin+'/profile/'); window.open(origin+'/profile/');
} else { } else {
window.top.location = origin+'/profile/'; window.parent.location = origin+'/profile/';
} }
}); });
$userAdmin.find('a.login').click(function () { $userAdmin.find('a.login').click(function () {
Common.setLoginRedirect(function () { Common.setLoginRedirect(function () {
window.top.location = origin+'/login/'; window.parent.location = origin+'/login/';
}); });
}); });
$userAdmin.find('a.register').click(function () { $userAdmin.find('a.register').click(function () {
Common.setLoginRedirect(function () { Common.setLoginRedirect(function () {
window.top.location = origin+'/register/'; window.parent.location = origin+'/register/';
}); });
}); });

@ -357,7 +357,7 @@ define([
Object.freeze(funcs); Object.freeze(funcs);
return { create: function (cb) { return { create: function (cb) {
nThen(function (waitFor) { nThen(function (waitFor) {
SFrameChannel.create(window.top, waitFor(function (sfc) { ctx.sframeChan = sfc; })); SFrameChannel.create(window.parent, waitFor(function (sfc) { ctx.sframeChan = sfc; }), true);
// CpNfInner.start() should be here.... // CpNfInner.start() should be here....
}).nThen(function () { }).nThen(function () {
ctx.metadataMgr = MetadataMgr.create(ctx.sframeChan); ctx.metadataMgr = MetadataMgr.create(ctx.sframeChan);

@ -491,8 +491,8 @@ define([
}); });
options.push({ options.push({
tag: 'a', tag: 'a',
attributes: {title: Messages.editShareTitle, 'class': 'fileEmbed'}, attributes: {title: Messages.fileEmbedTitle, 'class': 'fileEmbed'},
content: '<span class="fa fa-file"></span> ' + Messages.fileEmbed content: '<span class="fa fa-file"></span> ' + Messages.getEmbedCode
}); });
var dropdownConfigShare = { var dropdownConfigShare = {
text: $('<div>').append($shareIcon).html(), text: $('<div>').append($shareIcon).html(),

@ -408,6 +408,15 @@ define([
content: '<span class="fa fa-eye"></span> ' + Messages.viewOpen content: '<span class="fa fa-eye"></span> ' + Messages.viewOpen
}); });
} }
options.push({tag: 'hr'});
options.push({
tag: 'a',
attributes: {
title: Messages.viewEmbedTitle,
'class': 'cp-toolbar-share-view-embed',
},
content: '<span class="fa fa-eye"></span> ' + Messages.getEmbedCode
});
} }
var dropdownConfigShare = { var dropdownConfigShare = {
text: $('<div>').append($shareIcon).html(), text: $('<div>').append($shareIcon).html(),
@ -438,6 +447,31 @@ define([
var success = Cryptpad.Clipboard.copy(url); var success = Cryptpad.Clipboard.copy(url);
if (success) { Cryptpad.log(Messages.shareSuccess); } if (success) { Cryptpad.log(Messages.shareSuccess); }
}); });
$shareBlock.find('a.cp-toolbar-share-view-embed').click(function () {
var url = origin + pathname + '#' + hashes.viewHash;
var parsed = Cryptpad.parsePadUrl(url);
url = origin + parsed.getUrl({embed: true});
// Alertify content
var $content = $('<div>');
$('<input>', {'style':'display:none;'}).appendTo($content);
$('<h3>').text(Messages.viewEmbedTitle).appendTo($content);
var $tag = $('<p>').text(Messages.fileEmbedTag).appendTo($content);
$('<br>').appendTo($tag);
var iframeId = uid();
var iframeEmbed = '<iframe src="' + url + '"></iframe>';
$('<input>', {
type: 'text',
id: iframeId,
readonly: 'readonly',
value: iframeEmbed,
}).appendTo($tag);
Cryptpad.alert($content.html(), null, true);
$('#'+iframeId).click(function () {
this.select();
});
//var success = Cryptpad.Clipboard.copy(url);
//if (success) { Cryptpad.log(Messages.shareSuccess); }
});
} }
toolbar.$leftside.append($shareBlock); toolbar.$leftside.append($shareBlock);
@ -611,7 +645,7 @@ define([
window.open(href); window.open(href);
return; return;
} }
window.top.location = href; window.parent.location = href;
}; };
var onContext = function (e) { e.stopPropagation(); }; var onContext = function (e) { e.stopPropagation(); };

Loading…
Cancel
Save