Commit 6bcc5713 authored by Jim Tittsler's avatar Jim Tittsler

WP: use [oeru_idevice] in snapshots

parent 2847f2d5
......@@ -2,7 +2,7 @@
/* jshint node: true, multistr: true, trailing: true, esnext: true */
"use strict";
var VERSION = '0.10.2',
var VERSION = '0.11.0',
JQUERY = 'http://code.jquery.com/jquery-2.1.1.min.js',
FILEPATH = '/home/www/www';
......
/* jshint node: true, multistr: true, trailing: true, esnext: true */
function quotedWPstring(s) {
if (s.indexOf('"') === -1) {
return `"${s}"`;
} else if (s.indexOf("'") === -1) {
return `'${s}'`;
}
return `'${s.replace(/'/g, "\\'")}'`;
}
module.exports = {
version: '0.0.6',
version: '0.1.0',
// emit headers
header: function ($, opt) {
......@@ -227,91 +236,16 @@ module.exports = {
},
process: function ($, opt) {
// map iDevice theme and type to local WP icon
var icons = {
line: {
activity: 'Icon_activity',
activities: 'Icon_activity',
aim: 'Icon_objectives',
aims: 'Icon_objectives',
portfolio_activity: 'Icon_activity',
extension_exercise: 'Icon_activity',
assignment: 'Icon_assess',
example: 'Icon_casestudy',
case_study: 'Icon_casestudy',
assessment: 'Icon_qmark',
self_assessment: 'Icon_qmark',
question: 'Icon_qmark',
did_you_know: 'Icon_qmark',
did_you_notice: 'Icon_qmark',
definition: 'Icon_define',
definitions: 'Icon_define',
discussion: 'Icon_discussion',
tell_us_a_story: 'Icon_discussion',
objective: 'Icon_objectives',
objectives: 'Icon_objectives',
outcomes: 'Icon_objectives',
key_point: 'Icon_key_points',
key_points: 'Icon_key_points',
media_required: 'Icon_multimedia',
media: 'Icon_multimedia',
reading: 'Icon_reading',
competency: 'Icon_review',
competencies: 'Icon_review',
summary: 'Icon_summary',
reflection: 'Icon_reflection',
preknowledge: 'Icon_preknowledge',
web_resources: 'Icon_inter'
},
'ind': {
activity: 'ind/Icon_learning_activity',
activities: 'ind/Icon_learning_activity',
aim: 'ind/Icon_learning_objectives',
aims: 'ind/Icon_learning_objectives',
portfolio_activity: 'ind/Icon_learning_activity',
extension_exercise: 'ind/Icon_learning_activity',
assignment: 'ind/Icon_unknown',
example: 'ind/Icon_unknown',
case_study: 'ind/Icon_unknown',
assessment: 'ind/Icon_unknown',
self_assessment: 'ind/Icon_unknown',
question: 'ind/Icon_unknown',
did_you_know: 'ind/Icon_unknown',
did_you_notice: 'ind/Icon_unknown',
definition: 'Icon_define',
definitions: 'Icon_define',
discussion: 'Icon_discussion',
tell_us_a_story: 'Icon_discussion',
objective: 'ind/Icon_learning_objectives',
objectives: 'ind/Icon_learning_objectives',
outcomes: 'ind/Icon_learning_objectives',
key_point: 'ind/Icon_key_idea',
key_points: 'ind/Icon_key_idea',
media_required: 'Icon_multimedia',
media: 'Icon_multimedia',
reading: 'ind/Icon_reading_activity',
competency: 'Icon_review',
competencies: 'Icon_review',
summary: 'Icon_summary',
reflection: 'ind/Icon_reflection',
preknowledge: 'Icon_preknowledge',
web_resources: 'Icon_inter'
}
};
$('script[src*="wikieducator.org/load.php"]').remove();
$('#top').remove();
// restyle iDevices
$('.eXe-iDevice').each(function(){
var classes, $tloc, $inner, body, icon,
p = '/wp-content/themes/oeru_course/idevices/',
var classes, $tloc, $inner,
idtype = $(this).data('iDevice'),
idtheme = $(this).data('theme') || 'line';
idtheme = $(this).data('theme') || 'line',
idtitle, idbody;
idtheme = idtheme.toLowerCase();
if (!icons.hasOwnProperty(idtheme)) {
idtheme = 'line';
}
if (!idtype) {
classes = $(this).attr('class').split(' ');
idtype = classes.filter(function(e) {
......@@ -319,59 +253,27 @@ module.exports = {
})[0];
}
icon = 'activity';
if (icons[idtheme].hasOwnProperty(idtype)) {
icon = icons[idtheme][idtype];
}
// process new style Template:IDevice separately
if ($(this).hasClass('iDevice')) {
$(this).removeAttr('style').addClass('panel');
// remove old icon, add new (works for both line and wikieducator)
$(this).find('.iDevice-icon').remove();
$tloc = $(this).find('.iDevice-title');
$tloc.first().parent()
.removeAttr('style')
.addClass('panel-heading')
.addClass('idevice-heading');
$tloc.wrapInner('<h2 />');
$tloc.removeAttr('style')
.before('<div><img class="pedagogicalicon" alt="' + idtype + ' icon" src="' + p + icon + '.png"></div>');
body = $(this).find('.iDevice-body').addClass('panel-body')
.removeAttr('style');
idtitle = $(this).find('.iDevice-title').html();
idbody = $(this).find('.iDevice-body').html();
} else {
// there are (at least) three places where the title might be
// in old iDevices there are (at least) three places where the title might be
$inner = $(this).children('div:eq(0)');
if ($inner.children('div:eq(1)').length > 0) {
title = $inner.children('div:eq(1)').text();
$tloc = $inner.children('div:eq(1)');
idtitle = $inner.children('div:eq(1)').html();
} else if ($inner.find('h1:first').length > 0) {
title = $inner.find('h1:first').text();
$tloc = $inner.find('h1:first').parent();
idtitle = $inner.find('h1:first').html();
} else {
title = $(this).children('div:eq(1)').text();
$tloc = $(this).children('div:eq(1)');
idtitle = $(this).children('div:eq(1)').html();
}
title = $.trim(title);
$(this).children('div').removeAttr('style');
$(this).removeAttr('style');
body = $(this).find('table:first tr td').html();
icon = 'qmark';
if (icons['line'].hasOwnProperty(idtype)) {
icon = icons.line[idtype];
}
$(this).prepend('<div class="panel-heading">\n\
<div>\n\
<img class="pedagogicalicon" src="' + p + icon + '.png">\n\
</div>\n\
<div>\n\
<h2>' + title + '</h2>\n\
</div>\n\
</div>\n' + body);
$(this).find('table').remove();
$tloc.remove();
$(this).find('.floatleft').remove();
idtitle = $.trim(idtitle);
idbody = $(this).find('table:first tr td').html();
}
$(this).replaceWith(`[oeru_idevice type='${idtype}' title=${quotedWPstring(idtitle)}]
${idbody}
[/oeru_idevice]
`);
});
// restyle boxes into panels
......
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