Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed ace editor + added Accept-Language box #221

Merged
merged 1 commit into from
Apr 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 20 additions & 27 deletions registry/views/component-info.jade
Original file line number Diff line number Diff line change
Expand Up @@ -69,29 +69,22 @@ block content
| You can edit the following area and then
a.refresh-preview(href="#refresh") refresh
| to apply the change into the preview window.
#editor
| <oc-component href="#{href + component.name + '/' + component.version + '/' + sandBoxDefaultQs}"></oc-component>

div.field
p Component's href:
textarea.search#href(placeholder="Insert component href here") #{href + component.name + '/' + component.version + '/' + sandBoxDefaultQs}

div.field
p Accept-Language header:
input.search#lang(value="*")

h3
| Preview
a.refresh-preview(href="#refresh") (Refresh)
iframe.preview(src='~preview/' + sandBoxDefaultQs)

block scripts
script(src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.0/ace.min.js")
script(src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.0/mode-html.js")
script(src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.0/theme-github.js")
script.
var editor;
if(!!window.ace){
editor = ace.edit('editor');
editor.container.style.opacity = '';
editor.session.setMode('ace/mode/html');
editor.setAutoScrollEditorIntoView(true);
editor.setOption('maxLines', 40);
editor.setTheme('ace/theme/github');
}

var oc = oc || {};
oc.cmd = oc.cmd || [];

Expand All @@ -101,24 +94,24 @@ block scripts
});

$('.refresh-preview').click(function(){
if(!!editor){
var code = editor.getValue(),
splitted = $(code).attr('href').split('?'),
url = splitted[0];

if(url.slice(-1) !== '/'){
url += '/';
}
var splitted = $('#href').val().split('?'),
url = splitted[0],
lang = $('#lang').val();

url = url.replace('http\:\/\/', '\/\/').replace('https\:\/\/', '\/\/') + '~preview';
if(url.slice(-1) !== '/'){
url += '/';
}

if(splitted.length > 1){
url += '/?' + splitted[1];
}
url = url.replace('http\:\/\/', '\/\/').replace('https\:\/\/', '\/\/');
url += '~preview/?__ocAcceptLanguage=' + lang + '&';

$('.preview').attr('src', url);
if(splitted.length > 1){
url += splitted[1];
}

$('.preview').attr('src', url);

return false;
});
});
10 changes: 4 additions & 6 deletions registry/views/css.jade
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ style.
width: 100%;
}

#editor {
height: 200px;
float: left;
width: 100%;
}

.preview {
height: 300px;
border: 1px solid #000;
Expand Down Expand Up @@ -171,6 +165,10 @@ style.
padding: 10px;
}

#href {
height: 30px;
}

.states {
width: 100%;
margin-bottom: 30px;
Expand Down