adding preview feature, resolves #4

This commit is contained in:
El RIDO 2016-07-11 11:09:41 +02:00
parent 7259105ef6
commit 6a663ba07f
13 changed files with 110 additions and 23 deletions

View File

@ -62,6 +62,10 @@ body.navbar-spacing {
word-wrap: break-word; word-wrap: break-word;
} }
#preview {
margin-bottom: 10px;
}
#message { #message {
font-family: monospace; font-family: monospace;
} }

View File

@ -136,5 +136,7 @@
"Dein Browser unterstützt das hochladen von verschlüsselten Dateien nicht. Bitte verwende einen neueren Browser.", "Dein Browser unterstützt das hochladen von verschlüsselten Dateien nicht. Bitte verwende einen neueren Browser.",
"Invalid attachment.": "Ungültiger Datei-Anhang.", "Invalid attachment.": "Ungültiger Datei-Anhang.",
"Options": "Optionen", "Options": "Optionen",
"Shorten URL": "URL verkürzen" "Shorten URL": "URL verkürzen",
"Editor": "Bearbeiten",
"Preview": "Vorschau"
} }

View File

@ -145,5 +145,7 @@
"Votre navigateur ne supporte pas l'envoi de fichiers chiffrés. Merci d'utiliser un navigateur plus récent.", "Votre navigateur ne supporte pas l'envoi de fichiers chiffrés. Merci d'utiliser un navigateur plus récent.",
"Invalid attachment.": "Attachement invalide.", "Invalid attachment.": "Attachement invalide.",
"Options": "Options", "Options": "Options",
"Shorten URL": "Raccourcir URL" "Shorten URL": "Raccourcir URL",
"Editor": "éditer",
"Preview": "avant-première"
} }

View File

@ -136,5 +136,7 @@
"Twoja przeglądarka nie wspiera wysyłania zaszyfrowanych plików. Użyj nowszej przeglądarki.", "Twoja przeglądarka nie wspiera wysyłania zaszyfrowanych plików. Użyj nowszej przeglądarki.",
"Invalid attachment.": "Nieprawidłowy załącznik.", "Invalid attachment.": "Nieprawidłowy załącznik.",
"Options": "Opcje", "Options": "Opcje",
"Shorten URL": "Skróć adres URL" "Shorten URL": "Skróć adres URL",
"Editor": "Edytować",
"Preview": "Zapowiedź"
} }

View File

@ -145,5 +145,7 @@
"Tvoj brskalnik ne omogoča nalaganje zakodiranih datotek. Prosim uporabi novejši brskalnik.", "Tvoj brskalnik ne omogoča nalaganje zakodiranih datotek. Prosim uporabi novejši brskalnik.",
"Invalid attachment.": "Neveljavna priponka.", "Invalid attachment.": "Neveljavna priponka.",
"Options": "Možnosti", "Options": "Možnosti",
"Shorten URL": "Skrajšajte URL" "Shorten URL": "Skrajšajte URL",
"Editor": "Uredi",
"Preview": "Predogled"
} }

View File

@ -136,5 +136,7 @@
"您的浏览器不支持上传加密的文件,请使用更新的浏览器。", "您的浏览器不支持上传加密的文件,请使用更新的浏览器。",
"Invalid attachment.": "无效的附件", "Invalid attachment.": "无效的附件",
"Options": "选项", "Options": "选项",
"Shorten URL": "缩短链接" "Shorten URL": "缩短链接",
"Editor": "編輯",
"Preview": "預習"
} }

View File

@ -583,7 +583,13 @@ $(function() {
this.prettyMessage.addClass('hidden'); this.prettyMessage.addClass('hidden');
break; break;
case 'syntaxhighlighting': case 'syntaxhighlighting':
if (typeof prettyPrintOne == 'function')
{
if (typeof prettyPrint == 'function') prettyPrint(); if (typeof prettyPrint == 'function') prettyPrint();
this.prettyPrint.html(
prettyPrintOne(text, null, true)
);
};
default: default:
// Convert URLs to clickable links. // Convert URLs to clickable links.
helper.urls2links(this.clearText); helper.urls2links(this.clearText);
@ -1055,16 +1061,21 @@ $(function() {
this.password.removeClass('hidden'); this.password.removeClass('hidden');
this.attach.removeClass('hidden'); this.attach.removeClass('hidden');
this.message.removeClass('hidden'); this.message.removeClass('hidden');
this.preview.removeClass('hidden');
this.message.focus(); this.message.focus();
}, },
/** /**
* Put the screen in "Existing paste" mode. * Put the screen in "Existing paste" mode.
*
* @param boolean preview (optional) : tell if the preview tabs should be displayed, defaults to false.
*/ */
stateExistingPaste: function() stateExistingPaste: function(preview)
{ {
this.sendButton.addClass('hidden'); preview = preview || false;
if (!preview)
{
// No "clone" for IE<10. // No "clone" for IE<10.
if ($('#oldienotice').is(":visible")) if ($('#oldienotice').is(":visible"))
{ {
@ -1074,14 +1085,18 @@ $(function() {
{ {
this.cloneButton.removeClass('hidden'); this.cloneButton.removeClass('hidden');
} }
this.rawTextButton.removeClass('hidden');
this.rawTextButton.removeClass('hidden');
this.sendButton.addClass('hidden');
this.attach.addClass('hidden'); this.attach.addClass('hidden');
this.expiration.addClass('hidden'); this.expiration.addClass('hidden');
this.formatter.addClass('hidden'); this.formatter.addClass('hidden');
this.burnAfterReadingOption.addClass('hidden'); this.burnAfterReadingOption.addClass('hidden');
this.openDisc.addClass('hidden'); this.openDisc.addClass('hidden');
this.newButton.removeClass('hidden'); this.newButton.removeClass('hidden');
this.preview.addClass('hidden');
}
this.pasteResult.addClass('hidden'); this.pasteResult.addClass('hidden');
this.message.addClass('hidden'); this.message.addClass('hidden');
this.clearText.addClass('hidden'); this.clearText.addClass('hidden');
@ -1177,6 +1192,35 @@ $(function() {
} }
}, },
/**
* View the editor tab.
*
* @param Event event
*/
viewEditor: function(event)
{
event.preventDefault();
this.messagePreview.parent().removeClass('active');
this.messageEdit.parent().addClass('active');
this.message.focus();
this.stateNewPaste();
},
/**
* View the preview tab.
*
* @param Event event
*/
viewPreview: function(event)
{
event.preventDefault();
this.messageEdit.parent().removeClass('active');
this.messagePreview.parent().addClass('active');
this.message.focus();
this.stateExistingPaste(true);
this.formatPaste($('#pasteFormatter').val(), this.message.val());
},
/** /**
* Create a new paste. * Create a new paste.
*/ */
@ -1261,6 +1305,8 @@ $(function() {
this.fileRemoveButton.click($.proxy(this.removeAttachment, this)); this.fileRemoveButton.click($.proxy(this.removeAttachment, this));
$('.reloadlink').click($.proxy(this.reloadPage, this)); $('.reloadlink').click($.proxy(this.reloadPage, this));
this.message.keydown(this.supportTabs); this.message.keydown(this.supportTabs);
this.messageEdit.click($.proxy(this.viewEditor, this));
this.messagePreview.click($.proxy(this.viewPreview, this));
}, },
/** /**
@ -1290,6 +1336,8 @@ $(function() {
this.formatter = $('#formatter'); this.formatter = $('#formatter');
this.image = $('#image'); this.image = $('#image');
this.message = $('#message'); this.message = $('#message');
this.messageEdit = $('#messageedit');
this.messagePreview = $('#messagepreview');
this.newButton = $('#newbutton'); this.newButton = $('#newbutton');
this.openDisc = $('#opendisc'); this.openDisc = $('#opendisc');
this.openDiscussion = $('#opendiscussion'); this.openDiscussion = $('#opendiscussion');
@ -1298,6 +1346,7 @@ $(function() {
this.pasteResult = $('#pasteresult'); this.pasteResult = $('#pasteresult');
this.prettyMessage = $('#prettymessage'); this.prettyMessage = $('#prettymessage');
this.prettyPrint = $('#prettyprint'); this.prettyPrint = $('#prettyprint');
this.preview = $('#preview');
this.rawTextButton = $('#rawtextbutton'); this.rawTextButton = $('#rawtextbutton');
this.remainingTime = $('#remainingtime'); this.remainingTime = $('#remainingtime');
this.replyStatus = $('#replystatus'); this.replyStatus = $('#replystatus');

View File

@ -175,6 +175,10 @@
</button> </button>
{/if}</div> {/if}</div>
</div> </div>
<ul id="preview" class="nav nav-tabs hidden">
<li role="presentation" class="active"><a id="messageedit" href="#">{function="t('Editor')"}</a></li>
<li role="presentation"><a id="messagepreview" href="#">{function="t('Preview')"}</a></li>
</ul>
</header> </header>
<section class="container"> <section class="container">
<article class="row"> <article class="row">

View File

@ -171,6 +171,10 @@
</button> </button>
{/if}</div> {/if}</div>
</div> </div>
<ul id="preview" class="nav nav-tabs hidden">
<li role="presentation" class="active"><a id="messageedit" href="#">{function="t('Editor')"}</a></li>
<li role="presentation"><a id="messagepreview" href="#">{function="t('Preview')"}</a></li>
</ul>
</header> </header>
<section class="container"> <section class="container">
<article class="row"> <article class="row">

View File

@ -171,6 +171,10 @@
</button> </button>
{/if}</div> {/if}</div>
</div> </div>
<ul id="preview" class="nav nav-tabs hidden">
<li role="presentation" class="active"><a id="messageedit" href="#">{function="t('Editor')"}</a></li>
<li role="presentation"><a id="messagepreview" href="#">{function="t('Preview')"}</a></li>
</ul>
</header> </header>
<section class="container"> <section class="container">
<article class="row"> <article class="row">

View File

@ -171,6 +171,10 @@
</button> </button>
{/if}</div> {/if}</div>
</div> </div>
<ul id="preview" class="nav nav-tabs hidden">
<li role="presentation" class="active"><a id="messageedit" href="#">{function="t('Editor')"}</a></li>
<li role="presentation"><a id="messagepreview" href="#">{function="t('Preview')"}</a></li>
</ul>
</header> </header>
<section class="container"> <section class="container">
<article class="row"> <article class="row">

View File

@ -171,6 +171,10 @@
</button> </button>
{/if}</div> {/if}</div>
</div> </div>
<ul id="preview" class="nav nav-tabs hidden">
<li role="presentation" class="active"><a id="messageedit" href="#">{function="t('Editor')"}</a></li>
<li role="presentation"><a id="messagepreview" href="#">{function="t('Preview')"}</a></li>
</ul>
</header> </header>
<section class="container"> <section class="container">
<article class="row"> <article class="row">

View File

@ -94,6 +94,10 @@
<span id="filewrap">{function="t('Attach a file')"}: <input type="file" id="file" name="file" /></span> <span id="filewrap">{function="t('Attach a file')"}: <input type="file" id="file" name="file" /></span>
<button id="fileremovebutton">{function="t('Remove attachment')"}</button> <button id="fileremovebutton">{function="t('Remove attachment')"}</button>
</div>{/if} </div>{/if}
<div id="preview" class="hidden">
<button id="messageedit">{function="t('Editor')"}</button>
<button id="messagepreview">{function="t('Preview')"}</button>
</div>
<div id="image" class="hidden"></div> <div id="image" class="hidden"></div>
<div id="prettymessage" class="hidden"> <div id="prettymessage" class="hidden">
<pre id="prettyprint" class="prettyprint linenums:1"></pre> <pre id="prettyprint" class="prettyprint linenums:1"></pre>