From 18b27957b4e4ac89a53323576d86e71ec6da42c3 Mon Sep 17 00:00:00 2001 From: Anon Ray Date: Thu, 11 Jul 2013 12:32:29 +0530 Subject: [PATCH] Small fixes. Still custom menu doesn't work. - small fixes in the UI code. - lot of logging to debug custom menu --- mouchak.conf | 4 ++-- server.py | 2 +- static/js/editor.js | 58 +++++++++++++++++++++++++++++-------------------- static/js/mouchak.js | 7 +++++- templates/editor.html | 4 ++-- 5 files changed, 45 insertions(+), 30 deletions(-) diff --git a/mouchak.conf b/mouchak.conf index b5b16fd..ac8c7e2 100644 --- a/mouchak.conf +++ b/mouchak.conf @@ -1,4 +1,4 @@ -DB=test_mouchak -SITE_TITLE=Testing Mouchak +DB=crin +SITE_TITLE=Community Radio | India HOST=0.0.0.0 PORT=5000 diff --git a/server.py b/server.py index 6e6f154..cc23456 100644 --- a/server.py +++ b/server.py @@ -107,7 +107,7 @@ def updateMenu(_id): print changedMenu res = siteMenu.update({'_id': bson.ObjId(_id)}, changedMenu) print res - return flask.jsonify(status='ok',menu=changedMenu) + return flask.jsonify(status='ok', menu=changedMenu) #elif flask.request.method == 'DELETE': # delMenu = flask.request.url diff --git a/static/js/editor.js b/static/js/editor.js index 5b29040..1c5bbed 100644 --- a/static/js/editor.js +++ b/static/js/editor.js @@ -255,23 +255,8 @@ $('#specific-content').html(template({ data: this.model.get('data') })); - // init the tinymce editor - tinymce.init({ - selector: '#edit', - theme: 'modern', - height: 300, - plugins: ["advlist autolink link image lists charmap print preview hr", - "anchor pagebreak spellchecker searchreplace wordcount", - "visualblocks visualchars code fullscreen insertdatetime", - "media nonbreaking save table contextmenu directionality", - "emoticons template paste textcolor" - ], - toolbar: "undo redo | styleselect | bold italic | " + - "alignleft aligncenter alignright alignjustify | " + - "bullist numlist outdent indent | link image | " + - "print preview media fullpage | forecolor backcolor emoticons" - - }); + // init the wysiwig editor + M.editor.wysiwig('#edit'); } else if(type === 'image' || type === 'video' || type === 'audio') { var template = _.template($('#media-template').html()); @@ -348,12 +333,16 @@ if(this.model.get('customMenu') === true) { $('#custom-menu').attr('checked', true); - this.$menuOptions.show(); + this.$menuOptions.show({complete: function() { + M.editor.wysiwig('#menu'); + }}); } }, showMenuOptions: function(bool) { if(bool === true) { - this.$menuOptions.show(); + this.$menuOptions.show({complete: function() { + //M.editor.wysiwig('#menu'); + }}); } else { this.$menuOptions.hide(); @@ -370,15 +359,19 @@ this.showMenuOptions(this.model.get('customMenu')); }, saveMenu: function() { - var menuHTML = $('#menu').val().trim(); - this.model.set({'html': menuHTML}); - console.log(this.model.toJSON()); - this.model.save({}, { + //console.log('saving menu..'); + // var menuHTML = $('#menu').val().trim(); + //this.model.set({'html': menuHTML}); + //console.log(this.model.toJSON()); + //alert('saveMenu called'); + /*this.model.save({}, { success: function(model, response) { + console.log(model, response); }, error: function(xhr, response) { } - }); + });*/ + //alert('end of save menu'); } }); @@ -391,6 +384,23 @@ pagelistview.render(); }); M.pagelistview = pagelistview; + }, + wysiwig: function($selector) { + tinymce.init({ + selector: $selector, + theme: 'modern', + height: 300, + plugins: ["advlist autolink link image lists charmap print preview hr", + "anchor pagebreak spellchecker searchreplace wordcount", + "visualblocks visualchars code fullscreen insertdatetime", + "media nonbreaking save table contextmenu directionality", + "emoticons template paste textcolor" + ], + toolbar: "undo redo | styleselect | bold italic | " + + "alignleft aligncenter alignright alignjustify | " + + "bullist numlist outdent indent | link image | " + + "print preview media fullpage | forecolor backcolor emoticons" + }); } }; diff --git a/static/js/mouchak.js b/static/js/mouchak.js index 4dde0d9..9b1cea3 100644 --- a/static/js/mouchak.js +++ b/static/js/mouchak.js @@ -49,6 +49,12 @@ var NavigationView = Backbone.View.extend({ console.log('rendering custom menu..'); this.$el.append(this.model.get('html')); } + this.$links = $('.nav li'); + if(!this.$links) { + throw new Error('Ill-formed menu! Please check you have