From: Charles Connell Date: Mon, 24 Mar 2014 19:41:06 +0000 (-0400) Subject: Course page, datatables X-Git-Tag: release-20150131~144^2~33 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=dc8cfd6cade31aa4f09874ae658d3d1161736a3e;p=oweals%2Fkarmaworld.git Course page, datatables --- diff --git a/karmaworld/apps/notes/models.py b/karmaworld/apps/notes/models.py index 56e8d2c..dc25b96 100644 --- a/karmaworld/apps/notes/models.py +++ b/karmaworld/apps/notes/models.py @@ -324,7 +324,10 @@ class Note(Document): """ if self.slug is not None: # return a url ending in slug - return reverse('note_detail', args=[self.course.school.slug, self.course.slug, self.slug]) + if self.course.school: + return reverse('note_detail', args=[self.course.school.slug, self.course.slug, self.slug]) + else: + return reverse('note_detail', args=[self.course.department.school.slug, self.course.slug, self.slug]) else: # return a url ending in id return reverse('note_detail', args=[self.course.school.slug, self.course.slug, self.id]) diff --git a/karmaworld/assets/css/global.css b/karmaworld/assets/css/global.css index ccdec2c..ab21bcd 100644 --- a/karmaworld/assets/css/global.css +++ b/karmaworld/assets/css/global.css @@ -1,3 +1,19 @@ +body { + font-family: 'adelle-sans'; +} + +.museo300 { + font-family: 'museo300'; +} + +.museo700 { + font-family: 'museo700'; +} + +.adelle-sans { + font-family: 'adelle-sans'; +} + .nav-list ul { list-style-type: none; margin: 0; @@ -14,8 +30,15 @@ } .mobile-nav-list li { - padding: 10px 10px 10px 10px; font-size: 1.5em; + padding: 0 20px 0 10px; +} + +.mobile-nav-item { + padding: 5px 0px 5px 0px; + border-bottom: 1px solid black; + width: 100%; + color: #999999; } #header-nav { @@ -26,11 +49,12 @@ #header-login-nav { text-align: right; background: #000000; - color: #d4d4d4; + padding: 3px 0 3px 0; } -#header-login-nav a { +#header-login-nav ul { color: #d4d4d4; + font: 0.8em 'adelle-sans'; } #logo-container { @@ -41,7 +65,6 @@ background: #333333; color: #d4d4d4; padding: 1em 0 0.4em 0; - font: 1em 'museo300'; } .gradient-bar @@ -93,15 +116,19 @@ a:hover { } -span.table-school, +span.table-school { + font-weight: bold; +} + span.table-note-count, span.table-quiz-count, span.table-thanks-count { - font-weight: bold; + margin-right: 15px; } -span.table-course-name { +.table-course-name { font-size: 1.8em; + margin-right: 10px; } table.dataTable { @@ -110,17 +137,17 @@ table.dataTable { } table.dataTable div.table-entry-first-line { - padding-top: 20px; - font-family: 'museo700'; + font-size: 0.9em; + margin: 0 0 5px 0; } -table.dataTable div.table-entry-second-line { - font-family: 'museo700'; +table.dataTable div.table-entry-third-line { + font-size: 0.9em; + margin: 5px 0 0 0; } -table.dataTable div.table-entry-third-line { - padding-bottom: 20px; - font-family: 'Akkurat-Leicht'; +table.dataTable div.data-table-entry { + margin: 20px 0 20px 0; } table.dataTable tr.even { diff --git a/karmaworld/assets/css/home.css b/karmaworld/assets/css/home.css index 5625234..e682e00 100644 --- a/karmaworld/assets/css/home.css +++ b/karmaworld/assets/css/home.css @@ -1,7 +1,6 @@ #splash { font: 3em 'Museo700'; padding: 10vh 5vh 10vh 5vh; - background: grey; color: #ffffff; text-align: center; } diff --git a/karmaworld/assets/css/note_course_pages.css b/karmaworld/assets/css/note_course_pages.css index e28b387..e8008a3 100644 --- a/karmaworld/assets/css/note_course_pages.css +++ b/karmaworld/assets/css/note_course_pages.css @@ -18,7 +18,6 @@ span.course-header-school #end-header { margin-top: 20px; - border-bottom: 1px solid black; } #edit-button, @@ -47,9 +46,10 @@ select.note-sort { } #note-search-bar { - margin-top: 20px; - border: 1px solid grey; - padding: 10px 0 0 0; + background: #f5f5f5; + padding: 15px 0 0 0; + font: 1em 'museo300'; + margin-bottom: 20px; } ul.socialaccount_providers li, @@ -58,3 +58,11 @@ ul#uploaded_files li display: inline; } +table.dataTable div.note-date { + margin-bottom: 10px; +} + +table.dataTable div.note-text { + margin: 10px 0 10px 0; +} + diff --git a/karmaworld/assets/img/banner.jpg b/karmaworld/assets/img/banner.jpg new file mode 100644 index 0000000..7e0a6d1 Binary files /dev/null and b/karmaworld/assets/img/banner.jpg differ diff --git a/karmaworld/assets/js/course-detail.js b/karmaworld/assets/js/course-detail.js index 9c2e15c..ebdaabd 100644 --- a/karmaworld/assets/js/course-detail.js +++ b/karmaworld/assets/js/course-detail.js @@ -103,72 +103,51 @@ $(function() { KARMAWORLD.Course.initCourseNameAutocomplete({}); KARMAWORLD.Course.initInstructorNameAutocomplete({}); - $('#data_table_list').dataTable({ - // remove the default filter label - 'oLanguage': { - 'sSearch': '', - }, - // we will set column widths explicitly - 'bAutoWidth': false, - // don't provide a option for the user to change the table page length - 'bLengthChange': false, - // sepcify the number of rows in a page - 'iDisplayLength': 20, - // Position the filter bar at the top - // DIFF: do not show search bar (f) - 'sDom': '<"top">rt<"bottom"p><"clear">', - // Specify options for each column - "aoColumnDefs": [ - { - // 3rd element: likes - "aTargets": [ 2 ], - "bSortable": true, - "bVisible": true, - "mData": function ( source, type, val ) { - //console.log(source); - if (type === 'set') { - source.count = val; - // Store the computed dislay and filter values for efficiency - // DIFF: label name change. - source.count_display = val=="" ? "" : ""+val+" Thanks"; - return; - } - else if (type === 'display') { - return source.count_display; - } - // 'sort', 'type', 'filter' and undefined all just use the integer - return source.count; - } - }, - { - // 2nd element: date - "aTargets": [ 1 ], - "bSortable": true, - "bVisible": true, - "mData": function ( source, type, val ) { - //console.log(source); - if (type === 'set') { - source.date = val; - // DIFF: label name change. - source.date_display = val=="" ? "" : "Uploaded "+val+""; - return; - } - else if (type === 'display') { - return source.date_display; - } - // for types 'sort', 'type', 'filter' and undefined use raw date - return source.date; + $(function() { + + // load dataTable for course data + var dataTable = $('#data_table_list').dataTable({ + // we will set column widths explicitly + 'bAutoWidth': false, + // don't provide a option for the user to change the table page length + 'bLengthChange': false, + // sepcify the number of rows in a page + 'iDisplayLength': 20, + // Position the filter bar at the top + 'sDom': '<"top">rt<"bottom"p><"clear">', + // Specify options for each column + "aoColumnDefs": [ + { + // 2nd element: thanks + "aTargets": [ 1 ], + "bSortable": true, + "bVisible": true + }, + { + // 1st element: date + "aTargets": [ 0 ], + "bSortable": true, + "bVisible": true } - }, - { - // 1st element: "sort by" label - "aTargets": [ 0 ], - "bSortable": false, - "bVisible": true - } - ], - // Initial sorting - 'aaSorting': [[2,'desc']] + ], + // Initial sorting + 'aaSorting': [[1,'desc']] + }); + + // wire up search box + $('input.search-notes').keyup(function() { + dataTable.fnFilter($(this).val()); + }); + + // wire up sort chooser + $('select.course-sort').change(function() { + dataTable.fnSort([[$(this).val(), 'desc']]); + }); + + // sort by current value of sort chooser, since + // the browser may change this from our default + dataTable.fnSort([[$('select.note-sort').val(), 'desc']]); + }); }); diff --git a/karmaworld/assets/js/jquery.backstretch.min.js b/karmaworld/assets/js/jquery.backstretch.min.js new file mode 100644 index 0000000..1bb20f8 --- /dev/null +++ b/karmaworld/assets/js/jquery.backstretch.min.js @@ -0,0 +1,4 @@ +/*! Backstretch - v2.0.4 - 2013-06-19 +* http://srobbin.com/jquery-plugins/backstretch/ +* Copyright (c) 2013 Scott Robbin; Licensed MIT */ +(function(a,d,p){a.fn.backstretch=function(c,b){(c===p||0===c.length)&&a.error("No images were supplied for Backstretch");0===a(d).scrollTop()&&d.scrollTo(0,0);return this.each(function(){var d=a(this),g=d.data("backstretch");if(g){if("string"==typeof c&&"function"==typeof g[c]){g[c](b);return}b=a.extend(g.options,b);g.destroy(!0)}g=new q(this,c,b);d.data("backstretch",g)})};a.backstretch=function(c,b){return a("body").backstretch(c,b).data("backstretch")};a.expr[":"].backstretch=function(c){return a(c).data("backstretch")!==p};a.fn.backstretch.defaults={centeredX:!0,centeredY:!0,duration:5E3,fade:0};var r={left:0,top:0,overflow:"hidden",margin:0,padding:0,height:"100%",width:"100%",zIndex:-999999},s={position:"absolute",display:"none",margin:0,padding:0,border:"none",width:"auto",height:"auto",maxHeight:"none",maxWidth:"none",zIndex:-999999},q=function(c,b,e){this.options=a.extend({},a.fn.backstretch.defaults,e||{});this.images=a.isArray(b)?b:[b];a.each(this.images,function(){a("")[0].src=this});this.isBody=c===document.body;this.$container=a(c);this.$root=this.isBody?l?a(d):a(document):this.$container;c=this.$container.children(".backstretch").first();this.$wrap=c.length?c:a('
').css(r).appendTo(this.$container);this.isBody||(c=this.$container.css("position"),b=this.$container.css("zIndex"),this.$container.css({position:"static"===c?"relative":c,zIndex:"auto"===b?0:b,background:"none"}),this.$wrap.css({zIndex:-999998}));this.$wrap.css({position:this.isBody&&l?"fixed":"absolute"});this.index=0;this.show(this.index);a(d).on("resize.backstretch",a.proxy(this.resize,this)).on("orientationchange.backstretch",a.proxy(function(){this.isBody&&0===d.pageYOffset&&(d.scrollTo(0,1),this.resize())},this))};q.prototype={resize:function(){try{var a={left:0,top:0},b=this.isBody?this.$root.width():this.$root.innerWidth(),e=b,g=this.isBody?d.innerHeight?d.innerHeight:this.$root.height():this.$root.innerHeight(),j=e/this.$img.data("ratio"),f;j>=g?(f=(j-g)/2,this.options.centeredY&&(a.top="-"+f+"px")):(j=g,e=j*this.$img.data("ratio"),f=(e-b)/2,this.options.centeredX&&(a.left="-"+f+"px"));this.$wrap.css({width:b,height:g}).find("img:not(.deleteable)").css({width:e,height:j}).css(a)}catch(h){}return this},show:function(c){if(!(Math.abs(c)>this.images.length-1)){var b=this,e=b.$wrap.find("img").addClass("deleteable"),d={relatedTarget:b.$container[0]};b.$container.trigger(a.Event("backstretch.before",d),[b,c]);this.index=c;clearInterval(b.interval);b.$img=a("").css(s).bind("load",function(f){var h=this.width||a(f.target).width();f=this.height||a(f.target).height();a(this).data("ratio",h/f);a(this).fadeIn(b.options.speed||b.options.fade,function(){e.remove();b.paused||b.cycle();a(["after","show"]).each(function(){b.$container.trigger(a.Event("backstretch."+this,d),[b,c])})});b.resize()}).appendTo(b.$wrap);b.$img.attr("src",b.images[c]);return b}},next:function(){return this.show(this.indexe||d.operamini&&"[object OperaMini]"==={}.toString.call(d.operamini)||n&&7458>t||-1e||h&&6>h||"palmGetResource"in d&&e&&534>e||-1=k)})(jQuery,window); \ No newline at end of file diff --git a/karmaworld/templates/base.html b/karmaworld/templates/base.html index 6946868..575f45e 100644 --- a/karmaworld/templates/base.html +++ b/karmaworld/templates/base.html @@ -17,6 +17,8 @@ + + @@ -49,6 +51,8 @@ {% include 'footer.html' %} + + {% block bodyscripts %} {% endblock %} @@ -59,7 +63,6 @@ - diff --git a/karmaworld/templates/courses/course_detail.html b/karmaworld/templates/courses/course_detail.html index c1fe72e..0ea9db7 100644 --- a/karmaworld/templates/courses/course_detail.html +++ b/karmaworld/templates/courses/course_detail.html @@ -139,7 +139,7 @@ {{ file_upload_form.fp_file }}
-
+
@@ -149,8 +149,7 @@ Sort By
@@ -159,22 +158,18 @@ -
-

-
-
-
+
+ - - - - - - - - + + + + + + + {% for note in note_set %} {% include 'notes/note_list_entry.html' with note=note %} @@ -182,7 +177,8 @@
Sort by: Date Popularity Name Tags Preview
Date Popularity Note
-
+
+
diff --git a/karmaworld/templates/courses/course_list.html b/karmaworld/templates/courses/course_list.html index 2c18eef..ce0463e 100644 --- a/karmaworld/templates/courses/course_list.html +++ b/karmaworld/templates/courses/course_list.html @@ -27,21 +27,24 @@ {% block bodyscripts %} + + {% endblock %} {% block content %}