Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 61 additions & 16 deletions latex2edx/latex2edx.css
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
.hideshowbox h4 {
background-color: #F0F0F0;
color: black;
padding: 2px 4px 3px 6px;
margin: 0px;
border-top-right-radius: 5px;
border-top-left-radius: 5px;
font-size: 1.05em;
font-weight: 600;
line-height: 1.4em;
cursor: pointer;
.hideshowarrow {
border: solid black;
border-width: 0 3px 3px 0;
display: inline-block;
padding: 3px;
}
.hideshowarrow.down {
transform: rotate(-45deg);
-webkit-transform: rotate(-45deg);
}
.hideshowarrow.up {
transform: rotate(45deg);
-webkit-transform: rotate(45deg);
}

.hideshowbox .hideshowbottom {
Expand All @@ -25,11 +27,6 @@
cursor: pointer;
}

.hideshowbox .toggleimage {
padding: 0px 4px 0px 4px;
float: right;
}

.hideshowcontent p {
margin: 0px 0px 7px 0px;
}
Expand All @@ -46,3 +43,51 @@
margin: 22px 5px;
border-radius: 6px;
}

.xmodule_display.xmodule_HtmlBlock .hideshowh3 {
display: inline-block;
margin: 0px 0px 0px 5px;
font-family: inherit;
font-size: 1.05em;
font-weight: 600;
}

button.hideshowheader {
/* Some "none"s needed to override edX defaults */
display: block;
width: 100%;
margin: 0px;

font-size: 1.05em;
font-weight: 600;

text-align: left;
background-image: none;
background-color: #F0F0F0;
color: black;

padding: 2px 4px 3px 6px;

border: 0px solid black;
border-top-right-radius: 5px;
border-top-left-radius: 5px;
border-radius: 6px 6px 0px 0px; /* affects background-color radius. Should match the containing div */
box-shadow: none;

cursor: pointer;
font-family: inherit;
}

button.hideshowheader:hover {
border: 0px solid black;
background-color: #F0F0F0;
background-image: none;
box-shadow: none;
}

button.hideshowheader:active, button.hideshowheader:focus {
border: 0px solid black;
background-color: #F0F0F0;
background-image: none;
box-shadow: none;
}
24 changes: 5 additions & 19 deletions latex2edx/latex2edx.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,32 @@
* The MIT Licence (MIT)

* Copyright (c) 2014-2015 Jolyon Bloomfield and Eric Heubel
* Modifed 2021 by Duncan Levear and Rich Calogerro

* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

function hideshow(object) {
// Check to ensure that an attempt has been made
submissions = $(object).parents('.problem').find('.submission_feedback');
showanswerbutton = $(object).parents('.problem').find('.show');
if ($(submissions) && !$(showanswerbutton)) {
submissiontext = $(submissions).text().trim();
poscut = parseInt(submissiontext.indexOf("of"));
if (submissiontext.substring(14, poscut) == '0') {
alert('You must make an attempt before viewing the solution.');
return false;
}
}

// If checks succeed proceed with show/hide
hideshownocheck(object);
}

function hideshownocheck(object) {
// Do the show/hide business
stuff = $(object).parents('.hideshowbox').find('.hideshowcontent');
text = $(object).parents('.hideshowbox').find('.hideshowbottom');
arrow = $(object).parents('.hideshowbox').find('.toggleimage');
arrow = $(object).parents('.hideshowbox').find('.hideshowarrow');
button = $(object).parents('.hideshowbox').find('.hideshowheader')
arrowclass = $(arrow).attr('class');
if ($(stuff).css('display') != 'none') {
$(stuff).slideUp('slow');
$(text).html('<a href="javascript: {return false;}">Show</a>');
newclass = arrowclass.replace('up', 'down');
$(button).attr('aria-expanded','false');
$(arrow).attr('class', newclass);
} else {
$(stuff).slideDown('slow');
$(text).html('<a href="javascript: {return false;}">Hide</a>');
newclass = arrowclass.replace('down', 'up');
$(button).attr('aria-expanded','true');
$(arrow).attr('class', newclass);
}
}
23 changes: 14 additions & 9 deletions latex2edx/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1410,24 +1410,28 @@ def process_showhide(self, tree):
desc = showhide.get('description', '')
oneup = showhide.getparent()
newsh = etree.SubElement(oneup, 'div', {'class': 'hideshowbox'})
sub1 = etree.SubElement(newsh, 'h4',
{'onclick': 'hideshow(this);',
'style': 'margin: 0px'})
sub1.text = desc
etree.SubElement(sub1, 'span',
{'class': 'icon-caret-down toggleimage'})
sub0 = etree.SubElement(newsh, 'button',
{'aria-expanded':'false',
'class':'hideshowheader',
'onclick': 'hideshow(this);'})
sub1 = etree.SubElement(sub0, 'span',
{'class': 'hideshowarrow down'})
sub1.text = ' '
sub2 = etree.SubElement(sub0, 'h3',
{'class':'hideshowh3'})
sub2.text = ' ' + desc
newsh.append(showhide)
showhide.tag = 'div' # change edxshowhide tag
if 'description' in showhide.attrib:
showhide.attrib.pop('description') # remove description
showhide.set('class', 'hideshowcontent')
sub2 = etree.SubElement(newsh, 'p',
sub3 = etree.SubElement(newsh, 'p',
{'class': 'hideshowbottom',
'onclick': 'hideshow(this);',
'style': 'margin: 0px'})
subsub2 = etree.SubElement(sub2, 'a',
subsub3 = etree.SubElement(sub3, 'a',
{'href': 'javascript: {return false;}'})
subsub2.text = 'Show'
subsub3.text = 'Show'
try:
par = self.find_container_root(newsh, "showhide")
except Exception as err:
Expand All @@ -1437,6 +1441,7 @@ def process_showhide(self, tree):
scriptforsh = etree.Element('SCRIPT',
{'type': 'text/javascript',
'src': '/static/latex2edx.js'})
scriptforsh.text = " "
styleforsh = etree.Element('LINK',
{'type': 'text/css',
'rel': 'stylesheet',
Expand Down