added an almost usuable editor
This commit is contained in:
BIN
public/favicon.ico
Normal file
BIN
public/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 88 KiB |
BIN
public/images/back1.png
Normal file
BIN
public/images/back1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 517 KiB |
7
public/js/bootstrap.min.js
vendored
Normal file
7
public/js/bootstrap.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
138
public/js/editor.js
Normal file
138
public/js/editor.js
Normal file
@@ -0,0 +1,138 @@
|
||||
jQuery(function($){
|
||||
|
||||
var max_delay = 3000; // longest update pause (in ms)
|
||||
var processing_time = 0;
|
||||
var last = null;
|
||||
var help_text = '';
|
||||
|
||||
var tx_input = $('#tx_input');
|
||||
var input = tx_input[0];
|
||||
input.value = input.innerHTML;
|
||||
tx_input.val(input.value)
|
||||
var text_preview = $('#text_preview')[0];
|
||||
var html_output = $('#html_output')[0];
|
||||
|
||||
|
||||
function convert_text ( newval ) {
|
||||
|
||||
// make sure we're getting a string here because we want to
|
||||
// be able to pass this function to setTimeout (passes number)
|
||||
if ( arguments.length === 1 && typeof newval === 'string' ) {
|
||||
input.value = newval;
|
||||
}
|
||||
|
||||
var text = tx_input.val();
|
||||
|
||||
if ( text && text == last ) { return; } // no action needed
|
||||
last = text;
|
||||
|
||||
var startTime = new Date() * 1;
|
||||
var html = textile.convert( text );
|
||||
var endTime = new Date() * 1;
|
||||
processing_time = endTime - startTime;
|
||||
|
||||
text_preview.innerHTML = html;
|
||||
//html_output.value = html;
|
||||
|
||||
// save last output text to storage if we have it
|
||||
if ( supports_html5_storage() ) {
|
||||
if ( !input.value || input.value == help_text ) {
|
||||
localStorage.removeItem( "textile-dingus" );
|
||||
}
|
||||
else {
|
||||
localStorage.setItem( "textile-dingus", input.value );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
var supports_html5_storage = function () {
|
||||
var r = false;
|
||||
try { r = 'localStorage' in window && window['localStorage'] !== null; } catch (e) { r = false; }
|
||||
supports_html5_storage = r ? function () { return true; } : function () { return false; };
|
||||
return r;
|
||||
};
|
||||
|
||||
function sync_panels () {
|
||||
var col = $('#col_left');
|
||||
var md = $('#tx_input');
|
||||
var tally = $('body > h1').outerHeight();
|
||||
col.children().each(function(){ tally += $(this).outerHeight(); });
|
||||
var space = col.height() - ( tally - md.outerHeight() );
|
||||
$('#tx_input, #text_preview, #html_output, #syntax_guide').height( space - 4 );
|
||||
}
|
||||
|
||||
|
||||
var convertTextTimer;
|
||||
function on_input ( e ) {
|
||||
clearTimeout( convertTextTimer );
|
||||
defer_time = Math.min( processing_time, max_delay );
|
||||
convertTextTimer = setTimeout( convert_text, defer_time );
|
||||
}
|
||||
|
||||
|
||||
$( '.tab' ).minitabs();
|
||||
|
||||
|
||||
// load syntax guide
|
||||
/* $.get('syntax.txt', function ( txt ) {
|
||||
$( '#syntax_guide' ).val( txt );
|
||||
});
|
||||
*/
|
||||
|
||||
$( window ).bind( 'resize', sync_panels ).trigger( 'resize' );
|
||||
|
||||
$( '#tx_input' ).bind( 'keyup', on_input ).focus();
|
||||
|
||||
|
||||
// app saves and loads from local storage
|
||||
/* if ( supports_html5_storage() ) {
|
||||
var prev = localStorage.getItem( 'textile-dingus' ) || '';
|
||||
// id form holds default text or is empty, load from localStorage
|
||||
if ( prev && !input.value || input.value == input.defaultValue ) {
|
||||
input.value = prev;
|
||||
}
|
||||
}
|
||||
*/
|
||||
console.log(input.value)
|
||||
console.log(input)
|
||||
if ( !input.value ) {
|
||||
$.get('help.txt', function ( txt ) {
|
||||
convert_text( (help_text = txt) );
|
||||
});
|
||||
}
|
||||
else {
|
||||
convert_text();
|
||||
}
|
||||
|
||||
|
||||
// enable loading desktop files
|
||||
|
||||
if ( typeof window.FileReader !== 'undefined' ) {
|
||||
tx_input.bind('dragover', function (e) {
|
||||
$( this ).addClass('drophover');
|
||||
e.preventDefault();
|
||||
});
|
||||
tx_input.bind('dragleave dragend drop', function (e) { $( this ).removeClass('drophover'); });
|
||||
tx_input.bind('drop', function (e) {
|
||||
var file = e.originalEvent.dataTransfer.files[0];
|
||||
var reader = new FileReader();
|
||||
reader.onload = function ( event ) {
|
||||
convert_text( event.target.result );
|
||||
};
|
||||
reader.readAsText( file );
|
||||
e.preventDefault();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$( 'html' ).delegate( 'button.clear,a.clear', 'click', function (e) {
|
||||
convert_text( '' );
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
4
public/js/jquery.min.js
vendored
Normal file
4
public/js/jquery.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
69
public/js/jquery.minitabs.js
Normal file
69
public/js/jquery.minitabs.js
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* jQuery minitabs plugin
|
||||
* Version 1.0
|
||||
*
|
||||
* Licenced under dual MIT/GPL license.
|
||||
* GPL: http://www.opensource.org/licenses/gpl-2.0.php
|
||||
* MIT: http://www.opensource.org/licenses/mit-license.php
|
||||
*
|
||||
*/
|
||||
(function($){
|
||||
|
||||
var _defaultConfig = {
|
||||
open: 'tab-open',
|
||||
closed: 'tab-closed',
|
||||
current: 'current',
|
||||
active: 'tabs-active',
|
||||
panel: 'tab-panel'
|
||||
};
|
||||
|
||||
function getRef ( a ) {
|
||||
return $.attr( a, 'href' ).replace( /^[^#]+/, '' );
|
||||
}
|
||||
|
||||
function switchTabs ( link, c ) {
|
||||
var nav = $( link ).closest( '.' + c.active ),
|
||||
id = getRef( link );
|
||||
if ( id && id !== c.current_id ) {
|
||||
nav.trigger( 'tabswitch', [ link, id ] );
|
||||
|
||||
// find currenly active and close it
|
||||
if ( c.current_id ) {
|
||||
var cid = c.current_id;
|
||||
$( cid ).trigger( 'tabclose' ).removeClass( c.open ).addClass( c.closed );
|
||||
nav.find( 'li:has(a[href$=' + cid + '])' ).removeClass( c.current );
|
||||
}
|
||||
|
||||
// find the desired panel and open it
|
||||
$( id ).removeClass( c.closed ).addClass( c.open ).trigger( 'tabopen' );
|
||||
$( link ).closest('li').addClass( c.current );
|
||||
|
||||
c.current_id = id;
|
||||
}
|
||||
}
|
||||
|
||||
$.fn.minitabs = function ( cfg ) {
|
||||
var conf = $.extend( {}, _defaultConfig, cfg );
|
||||
return this.each(function () {
|
||||
|
||||
var current = null;
|
||||
var links = $( 'a', this ).each(function ( i ) {
|
||||
$( getRef( this ) ).addClass( conf.panel + ' ' + conf.closed );
|
||||
if ( $( this ).closest( 'li' ).is( '.' + conf.current ) ) { current = this; }
|
||||
});
|
||||
|
||||
var tab = $( this )
|
||||
.addClass( conf.active )
|
||||
.data( 'tab.config', conf )
|
||||
.undelegate( 'a', 'click.minitabs' )
|
||||
.delegate( 'a', 'click.minitabs', function (e) {
|
||||
switchTabs( this, $.data( e.delegateTarget, 'tab.config' ) );
|
||||
e.preventDefault();
|
||||
})
|
||||
;
|
||||
switchTabs( current || links[0], conf );
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
1
public/js/textile.min.js
vendored
Normal file
1
public/js/textile.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
5
public/stylesheets/bootstrap.min.css
vendored
Normal file
5
public/stylesheets/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
221
public/stylesheets/editor.css
Normal file
221
public/stylesheets/editor.css
Normal file
@@ -0,0 +1,221 @@
|
||||
html {
|
||||
overflow: hidden;
|
||||
height: 100%;
|
||||
}
|
||||
body {
|
||||
font-family: Helvetica, sans-serif;
|
||||
font-size: 13px;
|
||||
background: #ddd;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
height: 100%;
|
||||
}
|
||||
textarea {
|
||||
font-family: "andale mono", "lucida console", monospace;
|
||||
font-size: 12px;
|
||||
display: block;
|
||||
color:#000000;
|
||||
resize: none;
|
||||
}
|
||||
label {
|
||||
display: block;
|
||||
padding: 4px 0;
|
||||
font-weight: bold;
|
||||
color: #777;
|
||||
}
|
||||
.col {
|
||||
margin: 0;
|
||||
padding: 1em 0;
|
||||
position: relative;
|
||||
width: 45%;
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
-webkit-box-sizing: border-box;
|
||||
}
|
||||
body > h1 {
|
||||
margin : 0;
|
||||
padding : 10px 3% 0;
|
||||
font-size : 20px;
|
||||
color : #444;
|
||||
}
|
||||
#col_left {
|
||||
float: left;
|
||||
left: 3%;
|
||||
}
|
||||
#col_right {
|
||||
float: right;
|
||||
right: 4%;
|
||||
}
|
||||
.panel {
|
||||
background: #fff;
|
||||
border: 1px solid #aaaaaa;
|
||||
outline: none;
|
||||
display: block;
|
||||
margin: 0;
|
||||
padding: 4px;
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
min-width: 100%;
|
||||
height: 400px;
|
||||
box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
-webkit-box-sizing: border-box;
|
||||
}
|
||||
#text_preview {
|
||||
overflow: auto;
|
||||
}
|
||||
#md_input {
|
||||
background: #f6f6f6;
|
||||
}
|
||||
#credit1 {
|
||||
background : url(http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png) 0 0 no-repeat;
|
||||
position: absolute;
|
||||
top: -15px;
|
||||
right: -15px;
|
||||
text-indent: -999em;
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
height: 145px;
|
||||
width: 149px;
|
||||
}
|
||||
#credit2 {
|
||||
position : absolute;
|
||||
bottom : 15px;
|
||||
right : 4%;
|
||||
color : #aaa;
|
||||
font-size : 11px;
|
||||
}
|
||||
.drophover {
|
||||
cursor: copy;
|
||||
/* no-drop, not-allowed */
|
||||
border: 1px solid black;
|
||||
background-color: #ccf;
|
||||
}
|
||||
.tools {
|
||||
position: absolute;
|
||||
top: 1em;
|
||||
right: 0;
|
||||
padding: 0;
|
||||
}
|
||||
.tab-closed {
|
||||
display: none;
|
||||
}
|
||||
.tabs-active {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
list-style: none;
|
||||
}
|
||||
.tabs-active li {
|
||||
display: inline-block;
|
||||
}
|
||||
.tabs-active li a {
|
||||
display: block;
|
||||
padding: 4px 10px;
|
||||
text-decoration: none;
|
||||
color: #999;
|
||||
background: #eee;
|
||||
margin: 0 1px;
|
||||
}
|
||||
.tabs-active .current a {
|
||||
color: #555;
|
||||
background: #fff;
|
||||
padding-bottom: 5px;
|
||||
margin: -1px 0;
|
||||
border: 1px solid #aaaaaa;
|
||||
border-bottom: 0;
|
||||
}
|
||||
::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
background: -webkit-gradient(linear, left top, right top, color-stop(0, #dddddd), color-stop(1, #ffffff));
|
||||
}
|
||||
::-webkit-scrollbar:horizontal {
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #dddddd), color-stop(1, #ffffff));
|
||||
}
|
||||
::-webkit-scrollbar-corner {
|
||||
background: -webkit-gradient(linear, left top, right bottom, color-stop(0, #dddddd), color-stop(0.6, #ffffff));
|
||||
}
|
||||
::-webkit-scrollbar-button:start:decrement, ::-webkit-scrollbar-button:end:increment {
|
||||
height: 0;
|
||||
width: 0;
|
||||
display: block;
|
||||
background-color: transparent;
|
||||
}
|
||||
::-webkit-scrollbar-track-piece {
|
||||
background-color: transparent;
|
||||
}
|
||||
::-webkit-scrollbar-thumb:horizontal, ::-webkit-scrollbar-thumb:vertical {
|
||||
border: 1px solid #bbbbbb;
|
||||
height: 50px;
|
||||
width: 50px;
|
||||
-webkit-border-radius: 6px;
|
||||
background: -webkit-gradient(linear, left top, right top, color-stop(0, #dddddd), color-stop(1, #bbbbbb));
|
||||
}
|
||||
::-webkit-scrollbar-thumb:horizontal {
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #dddddd), color-stop(1, #bbbbbb));
|
||||
}
|
||||
|
||||
#text_preview {
|
||||
padding: 0 1em 4px 1em;
|
||||
color: #444;
|
||||
font-size: 13px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
#text_preview h1 {
|
||||
line-height: 1.1;
|
||||
font-size: 2em;
|
||||
}
|
||||
#text_preview h2 {
|
||||
line-height: 1.1;
|
||||
font-size: 1.6em;
|
||||
}
|
||||
#text_preview h3 {
|
||||
line-height: 1.14;
|
||||
font-size: 1.36em;
|
||||
}
|
||||
#text_preview h4 {
|
||||
line-height: 1.2;
|
||||
font-size: 1.14em;
|
||||
}
|
||||
#text_preview h5 {
|
||||
line-height: 1.24;
|
||||
font-size: 1em;
|
||||
}
|
||||
#text_preview h6 {
|
||||
line-height: 1.24;
|
||||
font-size: 1em;
|
||||
}
|
||||
#text_preview code {
|
||||
background: #f4f4f4;
|
||||
}
|
||||
#text_preview table {
|
||||
border-collapse : collapse;
|
||||
}
|
||||
#text_preview table th,
|
||||
#text_preview table td {
|
||||
padding : 4px 8px;
|
||||
border : 1px solid #aaa;
|
||||
}
|
||||
#text_preview ul {
|
||||
margin-left: 0;
|
||||
padding-left: 2em;
|
||||
}
|
||||
#text_preview acronym {
|
||||
text-decoration : none;
|
||||
border-bottom : 1px dotted #888;
|
||||
cursor: help;
|
||||
}
|
||||
#text_preview blockquote {
|
||||
margin-left: .6em;
|
||||
padding-left: 1em;
|
||||
border-left: .4em solid #ddd;
|
||||
}
|
||||
#text_preview pre > code {
|
||||
display: block;
|
||||
}
|
||||
#text_preview .caps {
|
||||
font-variant: small-caps;
|
||||
text-transform: lowercase;
|
||||
letter-spacing: .1em;
|
||||
}
|
||||
@@ -1,8 +1,25 @@
|
||||
|
||||
body {
|
||||
padding: 50px;
|
||||
background-image: url(../images/back1.png);
|
||||
background-repeat: no-repeat;
|
||||
background-attachment: fixed;
|
||||
background-color: #000000;
|
||||
font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #00B7FF;
|
||||
}
|
||||
}
|
||||
|
||||
#home {
|
||||
display:block;
|
||||
}
|
||||
|
||||
#markdown-editor {
|
||||
margin-top:50px;
|
||||
min-width:500px;
|
||||
min-height:300px;
|
||||
color: #000000
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user