Merge branch 'staging' into framework
This commit is contained in:
@@ -191,6 +191,8 @@ define([
|
||||
|
||||
var listener;
|
||||
var close = Util.once(function (result, ev) {
|
||||
ev.stopPropagation();
|
||||
ev.preventDefault();
|
||||
var $frame = $(tagger).fadeOut(150, function () {
|
||||
stopListening(listener);
|
||||
$frame.remove();
|
||||
@@ -198,17 +200,21 @@ define([
|
||||
});
|
||||
});
|
||||
|
||||
var $ok = findOKButton(tagger).click(function () {
|
||||
var $ok = findOKButton(tagger).click(function (e) {
|
||||
var tokens = field.getTokens();
|
||||
close(tokens);
|
||||
close(tokens, e);
|
||||
});
|
||||
var $cancel = findCancelButton(tagger).click(function () {
|
||||
close(null);
|
||||
var $cancel = findCancelButton(tagger).click(function (e) {
|
||||
close(null, e);
|
||||
});
|
||||
listenForKeys(function () {
|
||||
$ok.click();
|
||||
}, function () {
|
||||
$cancel.click();
|
||||
}, tagger);
|
||||
|
||||
$(tagger).on('click submit', function (e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
document.body.appendChild(tagger);
|
||||
@@ -503,7 +509,7 @@ define([
|
||||
var $icon = $defaultIcon.clone();
|
||||
|
||||
if (AppConfig.applicationsIcon && AppConfig.applicationsIcon[type]) {
|
||||
var appClass = ' cp-icon-color-'+type;
|
||||
var appClass = ' cp-icon cp-icon-color-'+type;
|
||||
$icon = $('<span>', {'class': 'fa ' + AppConfig.applicationsIcon[type] + appClass});
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -341,6 +341,7 @@ function isDataSchema(url) {
|
||||
return url.substr(i, 5).toLowerCase() === 'data:';
|
||||
}
|
||||
function getPDFFileNameFromURL(url) {
|
||||
url = document.location.href;
|
||||
var query;
|
||||
var title;
|
||||
if (/\#/.test(url)) {
|
||||
|
||||
@@ -10,6 +10,58 @@ define([
|
||||
var saveAs = window.saveAs;
|
||||
var module = {};
|
||||
|
||||
var cursorToPos = function(cursor, oldText) {
|
||||
var cLine = cursor.line;
|
||||
var cCh = cursor.ch;
|
||||
var pos = 0;
|
||||
var textLines = oldText.split("\n");
|
||||
for (var line = 0; line <= cLine; line++) {
|
||||
if(line < cLine) {
|
||||
pos += textLines[line].length+1;
|
||||
}
|
||||
else if(line === cLine) {
|
||||
pos += cCh;
|
||||
}
|
||||
}
|
||||
return pos;
|
||||
};
|
||||
|
||||
var posToCursor = function(position, newText) {
|
||||
var cursor = {
|
||||
line: 0,
|
||||
ch: 0
|
||||
};
|
||||
var textLines = newText.substr(0, position).split("\n");
|
||||
cursor.line = textLines.length - 1;
|
||||
cursor.ch = textLines[cursor.line].length;
|
||||
return cursor;
|
||||
};
|
||||
|
||||
module.setValueAndCursor = function (editor, oldDoc, remoteDoc, TextPatcher) {
|
||||
var scroll = editor.getScrollInfo();
|
||||
//get old cursor here
|
||||
var oldCursor = {};
|
||||
oldCursor.selectionStart = cursorToPos(editor.getCursor('from'), oldDoc);
|
||||
oldCursor.selectionEnd = cursorToPos(editor.getCursor('to'), oldDoc);
|
||||
|
||||
editor.setValue(remoteDoc);
|
||||
editor.save();
|
||||
|
||||
var op = TextPatcher.diff(oldDoc, remoteDoc);
|
||||
var selects = ['selectionStart', 'selectionEnd'].map(function (attr) {
|
||||
return TextPatcher.transformCursor(oldCursor[attr], op);
|
||||
});
|
||||
|
||||
if(selects[0] === selects[1]) {
|
||||
editor.setCursor(posToCursor(selects[0], remoteDoc));
|
||||
}
|
||||
else {
|
||||
editor.setSelection(posToCursor(selects[0], remoteDoc), posToCursor(selects[1], remoteDoc));
|
||||
}
|
||||
|
||||
editor.scrollTo(scroll.left, scroll.top);
|
||||
};
|
||||
|
||||
module.create = function (Common, defaultMode, CMeditor) {
|
||||
var exp = {};
|
||||
var Messages = Cryptpad.Messages;
|
||||
@@ -242,56 +294,8 @@ define([
|
||||
return { content: content };
|
||||
};
|
||||
|
||||
var cursorToPos = function(cursor, oldText) {
|
||||
var cLine = cursor.line;
|
||||
var cCh = cursor.ch;
|
||||
var pos = 0;
|
||||
var textLines = oldText.split("\n");
|
||||
for (var line = 0; line <= cLine; line++) {
|
||||
if(line < cLine) {
|
||||
pos += textLines[line].length+1;
|
||||
}
|
||||
else if(line === cLine) {
|
||||
pos += cCh;
|
||||
}
|
||||
}
|
||||
return pos;
|
||||
};
|
||||
|
||||
var posToCursor = function(position, newText) {
|
||||
var cursor = {
|
||||
line: 0,
|
||||
ch: 0
|
||||
};
|
||||
var textLines = newText.substr(0, position).split("\n");
|
||||
cursor.line = textLines.length - 1;
|
||||
cursor.ch = textLines[cursor.line].length;
|
||||
return cursor;
|
||||
};
|
||||
|
||||
exp.setValueAndCursor = function (oldDoc, remoteDoc, TextPatcher) {
|
||||
var scroll = editor.getScrollInfo();
|
||||
//get old cursor here
|
||||
var oldCursor = {};
|
||||
oldCursor.selectionStart = cursorToPos(editor.getCursor('from'), oldDoc);
|
||||
oldCursor.selectionEnd = cursorToPos(editor.getCursor('to'), oldDoc);
|
||||
|
||||
editor.setValue(remoteDoc);
|
||||
editor.save();
|
||||
|
||||
var op = TextPatcher.diff(oldDoc, remoteDoc);
|
||||
var selects = ['selectionStart', 'selectionEnd'].map(function (attr) {
|
||||
return TextPatcher.transformCursor(oldCursor[attr], op);
|
||||
});
|
||||
|
||||
if(selects[0] === selects[1]) {
|
||||
editor.setCursor(posToCursor(selects[0], remoteDoc));
|
||||
}
|
||||
else {
|
||||
editor.setSelection(posToCursor(selects[0], remoteDoc), posToCursor(selects[1], remoteDoc));
|
||||
}
|
||||
|
||||
editor.scrollTo(scroll.left, scroll.top);
|
||||
return module.setValueAndCursor(editor, oldDoc, remoteDoc, TextPatcher);
|
||||
};
|
||||
|
||||
/////
|
||||
|
||||
@@ -28,6 +28,20 @@ define([
|
||||
* - createDropdown
|
||||
*/
|
||||
|
||||
UI.updateTags = function (common, href) {
|
||||
var sframeChan = common.getSframeChannel();
|
||||
sframeChan.query('Q_TAGS_GET', href || null, function (err, res) {
|
||||
if (err || res.error) { return void console.error(err || res.error); }
|
||||
Cryptpad.dialog.tagPrompt(res.data, function (tags) {
|
||||
if (!Array.isArray(tags)) { return; }
|
||||
sframeChan.event('EV_TAGS_SET', {
|
||||
tags: tags,
|
||||
href: href,
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
UI.createButton = function (common, type, rightside, data, callback) {
|
||||
var AppConfig = common.getAppConfig();
|
||||
var button;
|
||||
@@ -202,16 +216,7 @@ define([
|
||||
title: Messages.tags_title,
|
||||
})
|
||||
.click(common.prepareFeedback(type))
|
||||
.click(function () {
|
||||
sframeChan.query('Q_TAGS_GET', null, function (err, res) {
|
||||
if (err || res.error) { return void console.error(err || res.error); }
|
||||
Cryptpad.dialog.tagPrompt(res.data, function (tags) {
|
||||
if (!Array.isArray(tags)) { return; }
|
||||
console.error(tags);
|
||||
sframeChan.event('EV_TAGS_SET', tags);
|
||||
});
|
||||
});
|
||||
});
|
||||
.click(function () { UI.updateTags(null); });
|
||||
break;
|
||||
default:
|
||||
button = $('<button>', {
|
||||
|
||||
@@ -65,6 +65,7 @@ define([
|
||||
Cryptpad.ready(waitFor());
|
||||
}));
|
||||
}).nThen(function (waitFor) {
|
||||
$('#sbox-iframe').focus();
|
||||
|
||||
sframeChan.on('EV_CACHE_PUT', function (x) {
|
||||
Object.keys(x).forEach(function (k) {
|
||||
@@ -401,7 +402,7 @@ define([
|
||||
});
|
||||
|
||||
sframeChan.on('Q_TAGS_GET', function (data, cb) {
|
||||
Cryptpad.getPadTags(null, function (err, data) {
|
||||
Cryptpad.getPadTags(data, function (err, data) {
|
||||
cb({
|
||||
error: err,
|
||||
data: data
|
||||
@@ -410,8 +411,7 @@ define([
|
||||
});
|
||||
|
||||
sframeChan.on('EV_TAGS_SET', function (data) {
|
||||
console.log(data);
|
||||
Cryptpad.resetTags(null, data);
|
||||
Cryptpad.resetTags(data.href, data.tags);
|
||||
});
|
||||
|
||||
sframeChan.on('Q_PIN_GET_USAGE', function (data, cb) {
|
||||
|
||||
@@ -21,6 +21,7 @@ define([
|
||||
var $title;
|
||||
exp.setToolbar = function (toolbar) {
|
||||
$title = toolbar && (toolbar.title || toolbar.pageTitle);
|
||||
console.log('SET TOOLBAR');
|
||||
};
|
||||
|
||||
exp.getTitle = function () { return exp.title; };
|
||||
|
||||
@@ -78,6 +78,7 @@ define([
|
||||
funcs.displayAvatar = callWithCommon(UI.displayAvatar);
|
||||
funcs.createButton = callWithCommon(UI.createButton);
|
||||
funcs.createUsageBar = callWithCommon(UI.createUsageBar);
|
||||
funcs.updateTags = callWithCommon(UI.updateTags);
|
||||
|
||||
// History
|
||||
funcs.getHistory = callWithCommon(History.create);
|
||||
|
||||
@@ -228,7 +228,7 @@ define([
|
||||
$span.append($rightCol);
|
||||
} else {
|
||||
Common.displayAvatar($span, data.avatar, name, function ($img) {
|
||||
if (data.avatar && $img) {
|
||||
if (data.avatar && $img.length) {
|
||||
avatars[data.avatar] = $img[0].outerHTML;
|
||||
}
|
||||
$span.append($rightCol);
|
||||
@@ -448,7 +448,7 @@ define([
|
||||
var $content = $('<div>');
|
||||
$('<input>', {'style':'display:none;'}).appendTo($content);
|
||||
$('<h3>').text(Messages.viewEmbedTitle).appendTo($content);
|
||||
var $tag = $('<p>').text(Messages.fileEmbedTag).appendTo($content);
|
||||
var $tag = $('<p>').text(Messages.viewEmbedTag).appendTo($content);
|
||||
$('<br>').appendTo($tag);
|
||||
var iframeId = uid();
|
||||
var iframeEmbed = '<iframe src="' + url + '"></iframe>';
|
||||
|
||||
Reference in New Issue
Block a user