Commit b18123c3 authored by Jim Tittsler's avatar Jim Tittsler

Add WEquizzes support.

For each iDevice, copy any classes that begin "WE" to the oeru_course
shortcode's classes attribute.
If an iDevice has any classes beginning "WEquiz" add the [WEquizzes]
shortcode to the page. (It can appear multiple times per page, the
plugin only processes the page once.)
parent 7e35c9c0
......@@ -9,7 +9,7 @@ function quotedWPstring(s) {
}
module.exports = {
version: '0.1.2',
version: '0.2.0',
// emit headers
header: function ($, opt) {
......@@ -241,7 +241,8 @@ module.exports = {
// restyle iDevices
$('.eXe-iDevice').each(function(){
var classes, $inner, $idtitle, idtitle, idbody,
var classes, $inner, $idtitle, idtitle, idbody, idclasses,
idquizzes = '',
idtype = $(this).data('iDevice'),
idtheme = $(this).data('theme') || 'line';
......@@ -255,6 +256,22 @@ module.exports = {
// WordPress theme uses spaces in iDevice types
idtype = $.trim(idtype.replace(/_+/g, ' '));
// check for any WE classes, and add them to the shortcode
// and if there is a quiz, signal the plugin
idclasses = $(this).attr('class');
if (idclasses) {
idclasses = idclasses.split(' ')
.filter(e => e.slice(0, 2) === 'WE');
if (idclasses.length) {
if (idclasses.find(e => e.slice(0, 6) === 'WEquiz')) {
idquizzes = '[WEquizzes]';
}
idclasses = ` classes="${idclasses.join(' ')}"`;
}
} else {
idclasses = '';
}
// process new style Template:IDevice separately
if ($(this).hasClass('iDevice')) {
idtitle = $(this).find('.iDevice-title').html();
......@@ -286,9 +303,9 @@ module.exports = {
idtitle = $.trim(idtitle);
idbody = $(this).find('table:first tr td').html();
}
$(this).replaceWith(`[oeru_idevice type='${idtype}' title=${quotedWPstring(idtitle)}]
$(this).replaceWith(`[oeru_idevice type='${idtype}' title=${quotedWPstring(idtitle)}${idclasses}]
${idbody}
[/oeru_idevice]
[/oeru_idevice]${idquizzes}
`);
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment