Commit 66e3c71ebb4c3875c964dbc631e3486b10fa1ec1
- Diff rendering mode:
- inline
- side by side
mouchak/static/js/editor.js
(8 / 9)
  | |||
165 | 165 | showContent: function(event) { | |
166 | 166 | var idx = $(event.target).closest('.content-item').attr('id'). | |
167 | 167 | split('-')[1]; | |
168 | this.edit = {on: true, idx: idx}; | ||
169 | 168 | var content = this.model.get('content')[idx]; | |
170 | 169 | content = new M.types.model[content.type](content); | |
170 | this.editing = true; | ||
171 | 171 | var contentview = new ContentView({model: content}); | |
172 | 172 | contentview.render(); | |
173 | 173 | M.editor.contentview = contentview; | |
… | … | ||
365 | 365 | this.$menuOrder = $('#menu-order-wrap'); | |
366 | 366 | ||
367 | 367 | if(this.model.get('customMenu') === true) { | |
368 | this.$menuOrder.hide(); | ||
368 | 369 | $('#custom-menu').attr('checked', true); | |
369 | 370 | this.$menuOptions.show({complete: function() { | |
370 | 371 | //M.editor.wysiwig('#menu'); | |
… | … | ||
399 | 399 | var success_template = _.template($('#success-notif').html()); | |
400 | 400 | var fail_template = _.template($('#fail-notif').html()); | |
401 | 401 | ||
402 | var bool, html = '', menuOrder = []; | ||
403 | if($('#custom-menu').is(":checked")) { | ||
404 | bool = true; | ||
405 | html = $('#menu').val().trim(); | ||
402 | if($('#custom-menu').is(':checked')) { | ||
403 | var html = $('#menu').val().trim() || ''; | ||
404 | this.model.set({'customMenu': true, 'html': html}); | ||
406 | 405 | } | |
407 | 406 | else { | |
408 | bool = false; | ||
409 | menuOrder = $('#menu-order').val().split(','); | ||
407 | var menuOrder = $('#menu-order').val().split(',') || []; | ||
408 | this.model.set({'customMenu': false, 'menuOrder': menuOrder}); | ||
410 | 409 | } | |
411 | this.model.set({'customMenu': bool, 'html': html, 'menuOrder': menuOrder}); | ||
412 | //console.log(this.model.toJSON()); | ||
410 | //console.log('menu model: ', this.model.toJSON()); | ||
413 | 411 | this.model.save({}, { | |
414 | 412 | success: function(model, response) { | |
415 | 413 | //console.log(model, response); |
mouchak/templates/editor.html
(11 / 9)
  | |||
54 | 54 | <div class="page"> | |
55 | 55 | <div class="menu-config"> | |
56 | 56 | <h4> Menu Config </h4> | |
57 | |||
58 | <div class="control-group" id="menu-order-wrap"> | ||
59 | <div class="input-prepend"> | ||
60 | <span class="add-on"> <strong> Menu Order</strong></span> | ||
61 | <input id="menu-order" type="text" class="span4" | ||
62 | placeholder="list,page,names,for,menu,order" value="<%= menu_order %>"> | ||
63 | </div> | ||
64 | </div> | ||
65 | |||
57 | 66 | <div class="control-group"> | |
58 | 67 | <input id="custom-menu" type="checkbox"> | |
59 | 68 | <span class=""><strong> Custom Menu </strong></span> | |
60 | 69 | </div> | |
61 | <div class="control-group" id="menu-order-wrap"> | ||
62 | <% if(!$('#custom-menu').is(':checked')) { %> | ||
63 | <div class="input-prepend"> | ||
64 | <span class="add-on"> <strong> Menu Order</strong></span> | ||
65 | <input id="menu-order" type="text" class="span4" | ||
66 | placeholder="list,page,names,for,menu,order" value="<%= menu_order %>"> | ||
67 | </div> | ||
68 | <% } %> | ||
69 | </div> | ||
70 | |||
70 | 71 | <div class="menu-options" style="display: none;"> | |
71 | 72 | <div class="control-group"> | |
72 | 73 | <div class="input-prepend"> | |
… | … | ||
79 | 79 | <label><strong> HTML for menu: </strong></label> | |
80 | 80 | <textarea cols="25" rows="8" id="menu"><%= menu %></textarea> | |
81 | 81 | </div> | |
82 | |||
82 | 83 | </div> | |
83 | 84 | <button id="updateMenu" class="btn btn-primary pull-right"> Update </button> | |
84 | 85 | <div class="clearfix"></div> |