Commit af908104 by Tom Giannattasio

fixed html tab; started adding upload within widget

parent c2337400
...@@ -33,6 +33,9 @@ function initHTMLEditor($editor, $prev) { ...@@ -33,6 +33,9 @@ function initHTMLEditor($editor, $prev) {
image : '/static/img/visual-editor-image-icon.png', image : '/static/img/visual-editor-image-icon.png',
onclick : function() { onclick : function() {
$assetWidget = $($('#asset-library-widget').html()); $assetWidget = $($('#asset-library-widget').html());
$assetWidget.find('.close-button').bind('click', closeAssetWidget);
$modalCover.unbind('click');
$modalCover.bind('click', closeAssetWidget);
$modalCover.css('z-index', '99999'); $modalCover.css('z-index', '99999');
$('.insert-asset-button', $assetWidget).bind('click', { editor: ed }, insertAsset); $('.insert-asset-button', $assetWidget).bind('click', { editor: ed }, insertAsset);
$body.append($assetWidget); $body.append($assetWidget);
...@@ -41,30 +44,30 @@ function initHTMLEditor($editor, $prev) { ...@@ -41,30 +44,30 @@ function initHTMLEditor($editor, $prev) {
} }
}); });
}, 100); }, 100);
htmlEditor = CodeMirror.fromTextArea($editor.find('.html-box')[0], { htmlEditor = CodeMirror.fromTextArea($editor.find('.html-box')[0], {
lineWrapping: true, lineWrapping: true,
mode: 'text/html', mode: 'text/html',
lineNumbers: true lineNumbers: true
}); });
$(htmlEditor.getWrapperElement()).hide(); $editor.find('.save-button, .cancel-button').bind('click', updateHTMLPreview);
$(htmlEditor.getWrapperElement()).bind('click', function() {
$(htmlEditor).focus();
});
$editor.find('.save-button, .cancel-button').bind('click', updatePreview);
} }
function insertAsset(e) { function insertAsset(e) {
$assetWidget.remove(); closeAssetWidget();
$modalCover.css('z-index', '1000');
var editor = e.data.editor; var editor = e.data.editor;
editor.focus(); editor.focus();
editor.selection.setContent($(this).attr('data-markup')); editor.selection.setContent($(this).attr('data-markup'));
} }
function closeAssetWidget(e) {
$assetWidget.remove();
$modalCover.css('z-index', '1000');
}
function convertVisualToHTML() { function convertVisualToHTML() {
console.log('convert');
htmlEditor.setValue($visualEditor.html()); htmlEditor.setValue($visualEditor.html());
} }
...@@ -72,6 +75,10 @@ function convertHTMLToVisual() { ...@@ -72,6 +75,10 @@ function convertHTMLToVisual() {
$visualEditor.html(htmlEditor.getValue()); $visualEditor.html(htmlEditor.getValue());
} }
function updatePreview() { function updateHTMLPreview() {
$htmlPreview.html($visualEditor.html()); if(currentEditor == htmlEditor) {
$htmlPreview.html(htmlEditor.getValue());
} else {
$htmlPreview.html($visualEditor.html());
}
} }
\ No newline at end of file
...@@ -84,6 +84,7 @@ function setFocus(e) { ...@@ -84,6 +84,7 @@ function setFocus(e) {
} }
function onSimpleEditorUpdate() { function onSimpleEditorUpdate() {
console.log('update');
updatePreview(); updatePreview();
updateXML(); updateXML();
} }
......
...@@ -111,7 +111,8 @@ ...@@ -111,7 +111,8 @@
display: block; display: block;
&.widget { &.widget {
position: absolute; position: fixed;
top: 40px;
left: 50%; left: 50%;
z-index: 99999; z-index: 99999;
width: 900px; width: 900px;
...@@ -190,6 +191,14 @@ ...@@ -190,6 +191,14 @@
th { th {
padding: 5px 20px; padding: 5px 20px;
} }
th a {
color: #3c3c3c;
}
.upload-form {
display: none;
}
} }
table { table {
...@@ -246,7 +255,7 @@ ...@@ -246,7 +255,7 @@
} }
.insert-col { .insert-col {
width: 80px; width: 100px;
} }
.insert-asset-button { .insert-asset-button {
......
...@@ -317,7 +317,18 @@ ...@@ -317,7 +317,18 @@
background: url(../img/problem-settings-icon.png) no-repeat; background: url(../img/problem-settings-icon.png) no-repeat;
} }
.sort-icon {
font-size: 7px;
vertical-align: middle;
&.down:before {
content: '▼';
}
&.up:before {
content: '▲';
}
}
......
...@@ -384,15 +384,14 @@ ...@@ -384,15 +384,14 @@
position: relative; position: relative;
} }
textarea {
display: none;
}
.CodeMirror { .CodeMirror {
display: none;
position: absolute; position: absolute;
top: 47px; top: 47px;
width: 100%; width: 100%;
height: 378px; height: 378px;
background: #fff;
color: #3c3c3c;
@include box-sizing(border-box); @include box-sizing(border-box);
} }
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
e.preventDefault(); e.preventDefault();
$('.editor-tabs .current').removeClass('current'); $('.editor-tabs .current').removeClass('current');
$(this).addClass('current'); $(this).addClass('current');
console.log($(this).attr('data-tab'));
switch($(this).attr('data-tab')) { switch($(this).attr('data-tab')) {
case 'simple': case 'simple':
currentEditor = simpleEditor; currentEditor = simpleEditor;
...@@ -34,6 +33,7 @@ ...@@ -34,6 +33,7 @@
$(simpleEditor.getWrapperElement()).hide(); $(simpleEditor.getWrapperElement()).hide();
$(xmlEditor.getWrapperElement()).show(); $(xmlEditor.getWrapperElement()).show();
$(xmlEditor).focus(); $(xmlEditor).focus();
xmlEditor.refresh();
break; break;
case 'visual': case 'visual':
currentEditor = visualEditor; currentEditor = visualEditor;
...@@ -43,10 +43,11 @@ ...@@ -43,10 +43,11 @@
break; break;
case 'html': case 'html':
currentEditor = htmlEditor; currentEditor = htmlEditor;
convertVisualToHTML();
$('table.mceToolbar').hide(); $('table.mceToolbar').hide();
$(htmlEditor.getWrapperElement()).show(); $(htmlEditor.getWrapperElement()).show();
$(htmlEditor).focus(); $(htmlEditor).focus();
convertVisualToHTML();
htmlEditor.refresh();
break; break;
} }
} }
...@@ -62,16 +63,33 @@ ...@@ -62,16 +63,33 @@
<a href="#" class="close-button"> <a href="#" class="close-button">
<span class="close-icon"></span> <span class="close-icon"></span>
</a> </a>
<div class="upload-form">
<h1>Upload New File</h1>
<p class="file-name"></p>
<div class="progress-bar">
<div class="progress-fill"></div>
</div>
<div class="embeddable">
<label>Embeddable XML:</label>
<input type="text" class="embeddable-xml-input" value="&lt;img src=&quot;&quot;/&gt;">
</div>
<form class="file-chooser" action="/Giannattasio/313/course/Photoshop_for_Monkeys/upload_asset" method="post" enctype="multipart/form-data">
<a href="#" class="choose-file-button">Choose File</a>
<input type="file" class="file-input" name="file">
</form>
</div>
<header> <header>
<a href="#" class="upload-button">Upload New File</a> <a href="#" class="upload-button">Upload New File</a>
<input type="text" class="search"> <input type="text" class="search">
</header> </header>
<table> <table class="library-list">
<thead> <thead>
<tr> <tr>
<th class="thumb-col"></th> <th class="thumb-col"></th>
<th class="name-col">Name</th> <th class="name-col"><a href="#">Name <span class="sort-icon down"></span></a></th>
<th class="date-col">Date Added</th> <th class="date-col"><a href="#">Date Added</a></th>
<th class="insert-col"></th> <th class="insert-col"></th>
</tr> </tr>
</thead> </thead>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment