|
|
@@ -10,6 +10,7 @@ $(document).ready(function() {
|
|
|
var $fileSelect = $('#file-select');
|
|
|
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');
|
|
|
@@ -257,33 +258,33 @@ $(document).ready(function() {
|
|
|
// }, 3000);
|
|
|
// }
|
|
|
|
|
|
- // function toggleEditor() {
|
|
|
- // $addExampleBtn.toggle();
|
|
|
- // $selectorNav.toggle();
|
|
|
- // $exampleForm.toggle();
|
|
|
- // }
|
|
|
+ function toggleEditor() {
|
|
|
+ $addExampleBtn.toggle();
|
|
|
+ $selectorNav.toggle();
|
|
|
+ $exampleForm.toggle();
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- // /**
|
|
|
- // * Save new example
|
|
|
- // */
|
|
|
- // function saveExample(e) {
|
|
|
- // e.preventDefault();
|
|
|
- // var title = $(this).find('input[name="title"]').val();
|
|
|
- // rp.post('/examples', { title: title })
|
|
|
- // .then(function(newExample) {
|
|
|
- // clearAndCloseEditor();
|
|
|
- // $fileSelect.append(makeFileSelectOption(newExample));
|
|
|
- // $fileSelect.val(newExample.slug);
|
|
|
- // notify('success', "Exemple créé !");
|
|
|
- // })
|
|
|
- // .catch(errText => notify('error', 'Erreur: ' + errText));
|
|
|
- // }
|
|
|
+ /**
|
|
|
+ * Add new example
|
|
|
+ */
|
|
|
+ function addExample(e) {
|
|
|
+ e.preventDefault();
|
|
|
+ var title = $(this).find('input[name="title"]').val();
|
|
|
+ rp.post('/examples', { title: title })
|
|
|
+ .then(function(newExample) {
|
|
|
+ clearAndCloseEditor();
|
|
|
+ $fileSelect.append(makeFileSelectOption(newExample));
|
|
|
+ $fileSelect.val(newExample.slug);
|
|
|
+ notify('success', "Exemple créé !");
|
|
|
+ })
|
|
|
+ .catch(errText => notify('error', 'Erreur: ' + errText));
|
|
|
+ }
|
|
|
|
|
|
- // function clearAndCloseEditor() {
|
|
|
- // $exampleForm.find('input').val('');
|
|
|
- // toggleEditor();
|
|
|
- // }
|
|
|
+ function clearAndCloseEditor() {
|
|
|
+ $exampleFormIn.val('');
|
|
|
+ toggleEditor();
|
|
|
+ }
|
|
|
|
|
|
// function revertEditor() {
|
|
|
// editorStorage.reset();
|
|
|
@@ -307,10 +308,10 @@ $(document).ready(function() {
|
|
|
// $fileSelect.change(function() {
|
|
|
// loadExample($(this).val());
|
|
|
// });
|
|
|
- // $addExampleBtn.click(toggleEditor);
|
|
|
- // $exampleCancel.click(clearAndCloseEditor);
|
|
|
+ $addExampleBtn.click(toggleEditor);
|
|
|
+ $exampleCancel.click(clearAndCloseEditor);
|
|
|
// $saveChanges.click(saveChanges);
|
|
|
- // $exampleForm.submit(saveExample);
|
|
|
+ $exampleForm.submit(addExample);
|
|
|
// $revertEditor.click(revertEditor);
|
|
|
// $.get('/menu', menu => $('#site-menu').html(menu), 'html');
|
|
|
// loadExampleList();
|