Get embed code for pad and code

This commit is contained in:
yflory
2017-09-06 10:56:27 +02:00
parent 0bb6698399
commit 3ca9f41290
7 changed files with 49 additions and 13 deletions

View File

@@ -7,7 +7,7 @@ define([
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 handlers = {};
var queries = {};
@@ -131,7 +131,7 @@ define([
console.log(msg);
}
});
if (window !== window.top) {
if (isSandbox) {
// we're in the sandbox
otherWindow = ow;
cb(chan);

View File

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

View File

@@ -357,7 +357,7 @@ define([
Object.freeze(funcs);
return { create: function (cb) {
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....
}).nThen(function () {
ctx.metadataMgr = MetadataMgr.create(ctx.sframeChan);

View File

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

View File

@@ -408,6 +408,15 @@ define([
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 = {
text: $('<div>').append($shareIcon).html(),
@@ -438,6 +447,31 @@ define([
var success = Cryptpad.Clipboard.copy(url);
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);
@@ -611,7 +645,7 @@ define([
window.open(href);
return;
}
window.top.location = href;
window.parent.location = href;
};
var onContext = function (e) { e.stopPropagation(); };