Deactivate toolbar buttons on preview

pull/75/head
Wes Cossick 9 years ago
parent 590dbe5c9a
commit 5790ab6c54

2
simplemde.min.css vendored

File diff suppressed because one or more lines are too long

6
simplemde.min.js vendored

File diff suppressed because one or more lines are too long

@ -231,6 +231,7 @@ function togglePreview(editor) {
/\s*editor-preview-active\s*/g, '' /\s*editor-preview-active\s*/g, ''
); );
toolbar.className = toolbar.className.replace(/\s*active\s*/g, ''); toolbar.className = toolbar.className.replace(/\s*active\s*/g, '');
editor.toolbar.className = editor.toolbar.className.replace(/\s*disabled-for-preview\s*/g, '');
} else { } else {
/* When the preview button is clicked for the first time, /* When the preview button is clicked for the first time,
* give some time for the transition from editor.css to fire and the view to slide from right to left, * give some time for the transition from editor.css to fire and the view to slide from right to left,
@ -240,12 +241,16 @@ function togglePreview(editor) {
preview.className += ' editor-preview-active' preview.className += ' editor-preview-active'
}, 1); }, 1);
toolbar.className += ' active'; toolbar.className += ' active';
editor.toolbar.className += ' disabled-for-preview';
} }
var text = cm.getValue(); var text = cm.getValue();
preview.innerHTML = parse(text); preview.innerHTML = parse(text);
} }
function _replaceSelection(cm, active, start, end) { function _replaceSelection(cm, active, start, end) {
if (/editor-preview-active/.test(cm.getWrapperElement().lastChild.className))
return;
var text; var text;
var startPoint = cm.getCursor('start'); var startPoint = cm.getCursor('start');
var endPoint = cm.getCursor('end'); var endPoint = cm.getCursor('end');
@ -270,6 +275,9 @@ function _replaceSelection(cm, active, start, end) {
function _toggleLine(cm, name) { function _toggleLine(cm, name) {
if (/editor-preview-active/.test(cm.getWrapperElement().lastChild.className))
return;
var stat = getState(cm); var stat = getState(cm);
var startPoint = cm.getCursor('start'); var startPoint = cm.getCursor('start');
var endPoint = cm.getCursor('end'); var endPoint = cm.getCursor('end');
@ -304,6 +312,9 @@ function _toggleLine(cm, name) {
} }
function _toggleBlock(editor, type, start_chars, end_chars) { function _toggleBlock(editor, type, start_chars, end_chars) {
if (/editor-preview-active/.test(cm.getWrapperElement().lastChild.className))
return;
end_chars = (typeof end_chars === 'undefined') ? start_chars : end_chars; end_chars = (typeof end_chars === 'undefined') ? start_chars : end_chars;
var cm = editor.codemirror; var cm = editor.codemirror;
var stat = getState(cm); var stat = getState(cm);

@ -99,6 +99,11 @@
position: absolute; position: absolute;
right: 10px right: 10px
} }
.editor-toolbar.disabled-for-preview a:not(.fa-eye){
pointer-events:none;
background:#fff;
border:none;
}
.editor-statusbar { .editor-statusbar {
padding: 8px 10px; padding: 8px 10px;
font-size: 12px; font-size: 12px;
@ -123,7 +128,7 @@
height: 100%; height: 100%;
top: 0; top: 0;
left: 0; left: 0;
background: #fff; background: #fafafa;
z-index: 9999; z-index: 9999;
overflow: auto; overflow: auto;
display: none display: none

Loading…
Cancel
Save