From: Charles Connell Date: Wed, 9 Apr 2014 23:53:49 +0000 (-0400) Subject: Keyword cleanup X-Git-Tag: release-20150131~144^2~9 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=refs%2Fheads%2Fredesign;p=oweals%2Fkarmaworld.git Keyword cleanup --- diff --git a/karmaworld/apps/notes/views.py b/karmaworld/apps/notes/views.py index 8c62087..ba02345 100644 --- a/karmaworld/apps/notes/views.py +++ b/karmaworld/apps/notes/views.py @@ -38,15 +38,15 @@ class NoteDetailView(DetailView): context_object_name = u"note" # name passed to template keyword_form_class = formset_factory(KeywordForm) - def post(self, requests, *args, **kwargs): - formset = self.keyword_form_class(requests) + def post(self, request, *args, **kwargs): + formset = self.keyword_form_class(request.POST) if formset.is_valid(): self.keyword_form_valid(formset) self.keyword_formset = self.keyword_form_class(initial=self.get_initial_keywords()) - return super(NoteDetailView, self).post(requests, *args, **kwargs) + return super(NoteDetailView, self).get(request, *args, **kwargs) else: self.keyword_formset = formset - return super(NoteDetailView, self).post(requests, *args, **kwargs) + return super(NoteDetailView, self).get(request, *args, **kwargs) def get(self, request, *args, **kwargs): self.keyword_formset = self.keyword_form_class(initial=self.get_initial_keywords()) @@ -96,7 +96,7 @@ class NoteDetailView(DetailView): except (ValueError, ObjectDoesNotExist): keyword_object = Keyword() - keyword_object.note = self.note + keyword_object.note = self.get_object() keyword_object.word = word keyword_object.definition = definition keyword_object.save() @@ -115,7 +115,6 @@ class NoteSaveView(FormView, SingleObjectMixin): context = { 'object': self.get_object(), } - print "get context for NoteSaveView" return super(NoteSaveView, self).get_context_data(**context) def get_success_url(self): @@ -159,17 +158,13 @@ class NoteView(View): return view(request, *args, **kwargs) def post(self, request, *args, **kwargs): - view = NoteSaveView.as_view() + if request.POST['action'] == 'tags-form': + view = NoteSaveView.as_view() + else: + view = NoteDetailView.as_view() return view(request, *args, **kwargs) -class RawNoteDetailView(DetailView): - """ Class-based view for the raw note html for iframes """ - template_name = u'notes/note_raw.html' - context_object_name = u"note" - model = Note - - class NoteSearchView(ListView): template_name = 'notes/search_results.html' diff --git a/karmaworld/assets/css/note_course_pages.css b/karmaworld/assets/css/note_course_pages.css index 1b0ab22..6524e16 100644 --- a/karmaworld/assets/css/note_course_pages.css +++ b/karmaworld/assets/css/note_course_pages.css @@ -105,4 +105,16 @@ div.header-title-row { .keyword-form-row textarea.definition { max-height: 75px; +} + +#add-row-btn { + cursor: pointer; +} + +.keywords-hint { + font-size: 0.8em; +} + +.note-keyword-toggle { + margin: 0 0 10px 0; } \ No newline at end of file diff --git a/karmaworld/assets/js/note-detail.js b/karmaworld/assets/js/note-detail.js index b150f56..cf6358b 100644 --- a/karmaworld/assets/js/note-detail.js +++ b/karmaworld/assets/js/note-detail.js @@ -1,9 +1,8 @@ - - -function rescalePdf(viewer, frameWidth) { +function rescalePdf(viewer) { var scaleBase = 750; var outlineWidth = 250; + var frameWidth = parseInt($('#tabs-content')[0].clientWidth); var pdfWidth = frameWidth; if ($(viewer.sidebar).hasClass('opened')){ @@ -14,8 +13,7 @@ function rescalePdf(viewer, frameWidth) { viewer.rescale(newPdfScale); } -function setupPdfViewer(noteframe) { - var pdfViewer = noteframe.pdf2htmlEX.defaultViewer; +function setupPdfViewer(noteframe, pdfViewer) { $('#plus-btn').click(function (){ pdfViewer.rescale(1.20, true, [0,0]); @@ -38,7 +36,7 @@ function setupPdfViewer(noteframe) { $('#outline-btn').click(function() { $(pdfViewer.sidebar).toggleClass('opened'); // rescale the PDF to fit the available space - rescalePdf(pdfViewer, parseInt(noteframe.frameElement.clientWidth)); + rescalePdf(pdfViewer); }); $('#scroll-to').change(function() { @@ -47,7 +45,7 @@ function setupPdfViewer(noteframe) { }); // rescale the PDF to fit the available space - rescalePdf(pdfViewer, parseInt(noteframe.frameElement.clientWidth)); + rescalePdf(pdfViewer); } function writeNoteFrame(contents) { @@ -249,9 +247,11 @@ $(function() { } \ }); })"; injectScript(js, noteframe); + if (pdfControls == true) { + var pdfViewer = noteframe.pdf2htmlEX.defaultViewer; $(noteframe.document).ready(function() { - setupPdfViewer(noteframe); + setupPdfViewer(noteframe, pdfViewer); }); } }); diff --git a/karmaworld/templates/base.html b/karmaworld/templates/base.html index 109b6a8..52b25b9 100644 --- a/karmaworld/templates/base.html +++ b/karmaworld/templates/base.html @@ -15,10 +15,6 @@ - - - - {% block pagescripts %} @@ -49,6 +45,9 @@ {% include 'footer.html' %} + + +