From: Jacob Hilker Date: Tue, 25 Feb 2014 19:15:42 +0000 (-0500) Subject: Remove scope issue for js variables in course_detail.html by moving dataTable call... X-Git-Tag: release-20150131~163^2~3^2 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=932221c1dba903ec37be8a888f67f127bf100791;p=oweals%2Fkarmaworld.git Remove scope issue for js variables in course_detail.html by moving dataTable call in course-detail.js --- diff --git a/karmaworld/assets/js/course-detail.js b/karmaworld/assets/js/course-detail.js index 94871a6..d50fb2a 100644 --- a/karmaworld/assets/js/course-detail.js +++ b/karmaworld/assets/js/course-detail.js @@ -97,4 +97,72 @@ $(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; + } + }, + { + // 1st element: "sort by" label + "aTargets": [ 0 ], + "bSortable": false, + "bVisible": true + } + ], + // Initial sorting + 'aaSorting': [[2,'desc']] + }); + }); diff --git a/karmaworld/templates/courses/course_detail.html b/karmaworld/templates/courses/course_detail.html index 4b5d0aa..abb9787 100644 --- a/karmaworld/templates/courses/course_detail.html +++ b/karmaworld/templates/courses/course_detail.html @@ -9,81 +9,11 @@ {% endblock %}