Commit aeb1feb1f1bba0348caece7dcb41d658528abe7c

Add basic notifications for page and menu saving

  Add basic notifications when saving page or menu. Notifications should be
more robust and should also indicate if content has been saved.
  
141141#addPage {
142142 margin: 10px 0 0 200px;
143143}
144#notifications {
145 width: 300px;
146 z-index: 100;
147 margin: 5px auto;
148}
144149
145150/* ==========================================================================
146151 Helper classes
  
191191 return false;
192192 },
193193 updatePage: function() {
194 var success_template = _.template($('#success-notif').html());
195 var fail_template = _.template($('#fail-notif').html());
196
194197 var name = $('#name').val();
195198 var title = $('#title').val();
196199 var children = $('#children').val();
213213 model.set(response.page);
214214 model.id = response.page.id;
215215 M.pagelistview.render();
216 $('#notifications').html(success_template({
217 title: 'Saved',
218 msg: ''
219 }));
216220 },
217221 error: function(model, xhr) {
218222 console.log('failed', model, xhr);
223 $('#notifications').html(fail_template({
224 title: 'Error!',
225 msg: 'Something went wrong, and the page could not be updated'
226 }));
219227 }
220228 });
221229 return false;
374374 this.showMenuOptions(this.model.get('customMenu'));
375375 },
376376 saveMenu: function() {
377 console.log('saving menu..');
377 //console.log('saving menu..');
378 var success_template = _.template($('#success-notif').html());
379 var fail_template = _.template($('#fail-notif').html());
380
378381 var bool, html = '', menuOrder = [];
379382 if($('#custom-menu').is(":checked")) {
380383 bool = true;
392392 this.model.save({}, {
393393 success: function(model, response) {
394394 console.log(model, response);
395 $('#notifications').html(success_template({
396 title: 'Saved',
397 msg: ''
398 }));
399
395400 },
396401 error: function(xhr, response) {
402 $('#notifications').html(fail_template({
403 title: 'Error!',
404 msg: 'Something went wrong, and the page could not be updated'
405 }));
397406 }
398407 });
399408 //alert('end of save menu');
  
2323 <![endif]-->
2424
2525 <div class="container" id="container">
26 <div id="header"> </div>
26 <div id="header"><div id="notifications"></div></div>
2727 <div id="content-container"></div>
2828 <div id="footer">
2929 </div>
219219 </textarea>
220220 </div>
221221 </script>
222
223 <!-- notification templates -->
224 <script type="text/template" id="success-notif">
225 <div class="alert alert-success">
226 <button type="button" class="close" data-dismiss="alert">&times;</button>
227 <h4> <%= title %> </h4>
228 <%= msg %>
229 </div>
230 </script>
231
232 <script type="text/template" id="fail-notif">
233 <div class="alert alert-error">
234 <button type="button" class="close" data-dismiss="alert">&times;</button>
235 <h4> <%= title %> </h4>
236 <%= msg %>
237 </div>
238 </script>
239
222240 </body>
223241</html>