|
@@ -6,15 +6,9 @@ $(document).ready(function() {
|
|
|
var $editorWrapper = $('#editor-wrapper');
|
|
var $editorWrapper = $('#editor-wrapper');
|
|
|
var $editor = $('#editor');
|
|
var $editor = $('#editor');
|
|
|
|
|
|
|
|
- var $addExampleBtn = $('#add-example-btn');
|
|
|
|
|
- var $exampleForm = $('#add-example-form');
|
|
|
|
|
- var $exampleFormIn = $exampleForm.find('input')
|
|
|
|
|
- var $exampleSave = $('#add-example-save');
|
|
|
|
|
- var $exampleCancel = $('#add-example-cancel');
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
var $saveChanges = $('#save-changes');
|
|
var $saveChanges = $('#save-changes');
|
|
|
- var $notification = $('#notification');
|
|
|
|
|
|
|
+
|
|
|
var $revertEditor = $('#revert-editor');
|
|
var $revertEditor = $('#revert-editor');
|
|
|
// var $panelLeft = $('.panel-left');
|
|
// var $panelLeft = $('.panel-left');
|
|
|
// var $panelRight = $('.panel-right');
|
|
// var $panelRight = $('.panel-right');
|
|
@@ -79,8 +73,8 @@ $(document).ready(function() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- function onTabClicked() {
|
|
|
|
|
- var clickedItem = $(this);
|
|
|
|
|
|
|
+ function onTabClicked(e) {
|
|
|
|
|
+ var clickedItem = $(e.target);
|
|
|
var type = clickedItem.data('type');
|
|
var type = clickedItem.data('type');
|
|
|
editorSession.setMode("ace/mode/" + mapTypes[type]);
|
|
editorSession.setMode("ace/mode/" + mapTypes[type]);
|
|
|
var name = clickedItem.html();
|
|
var name = clickedItem.html();
|
|
@@ -278,51 +272,6 @@ $(document).ready(function() {
|
|
|
// });
|
|
// });
|
|
|
// }
|
|
// }
|
|
|
|
|
|
|
|
- function notify(type, text) {
|
|
|
|
|
- $notification
|
|
|
|
|
- .addClass(type)
|
|
|
|
|
- .addClass('active');
|
|
|
|
|
- $notification.html(text);
|
|
|
|
|
- setTimeout(function() {
|
|
|
|
|
- $notification.removeClass('active');
|
|
|
|
|
- }, 2000);
|
|
|
|
|
- setTimeout(function() {
|
|
|
|
|
- $notification.removeClass(type);
|
|
|
|
|
- }, 3000);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- function toggleEditor() {
|
|
|
|
|
- $addExampleBtn.toggle();
|
|
|
|
|
- $selectorNav.toggle();
|
|
|
|
|
- $exampleForm.toggle();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * Add new example
|
|
|
|
|
- */
|
|
|
|
|
- function addExample(e) {
|
|
|
|
|
- e.preventDefault();
|
|
|
|
|
- var repoSlug = $detailsRepo.data('slug');
|
|
|
|
|
- var title = $(this).find('input[name="title"]').val();
|
|
|
|
|
- rp.post('/' + repoSlug + '/examples', { title: title })
|
|
|
|
|
- .then(function(example) {
|
|
|
|
|
- clearAndCloseEditor();
|
|
|
|
|
- // $fileSelect.append(makeFileSelectOption(example));
|
|
|
|
|
- // $fileSelect.val(example.slug);
|
|
|
|
|
-
|
|
|
|
|
- // var $exMenuItem = $('<li><a href="/' + repoSlug + '/' + example.slug + '">' + example.title + '</a></li>')
|
|
|
|
|
- // .appendTo( $('#cat-' + example.category) );
|
|
|
|
|
- notify('success', "Exemple créé !");
|
|
|
|
|
- // navigateTo('/'+ repoSlug + '/' + example.slug);
|
|
|
|
|
- })
|
|
|
|
|
- .catch(errText => notify('error', 'Erreur: ' + errText));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- function clearAndCloseEditor() {
|
|
|
|
|
- $exampleFormIn.val('');
|
|
|
|
|
- toggleEditor();
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
// function navigateTo(path) {
|
|
// function navigateTo(path) {
|
|
|
// history.pushState({}, 'pouet', path)
|
|
// history.pushState({}, 'pouet', path)
|
|
@@ -350,12 +299,7 @@ $(document).ready(function() {
|
|
|
// $fileSelect.change(function() {
|
|
// $fileSelect.change(function() {
|
|
|
// loadExample($(this).val());
|
|
// loadExample($(this).val());
|
|
|
// });
|
|
// });
|
|
|
- console.log($addExampleBtn);
|
|
|
|
|
- $addExampleBtn.click(toggleEditor);
|
|
|
|
|
- $addExampleBtn.click(console.log);
|
|
|
|
|
- $exampleCancel.click(clearAndCloseEditor);
|
|
|
|
|
// $saveChanges.click(saveChanges);
|
|
// $saveChanges.click(saveChanges);
|
|
|
- $exampleForm.submit(addExample);
|
|
|
|
|
// $revertEditor.click(revertEditor);
|
|
// $revertEditor.click(revertEditor);
|
|
|
// $.get('/menu', menu => $('#site-menu').html(menu), 'html');
|
|
// $.get('/menu', menu => $('#site-menu').html(menu), 'html');
|
|
|
// loadExampleList();
|
|
// loadExampleList();
|