Solved

CSS class to a Lectora-group

Hello,

Lectora input fields can be assigned a CSS class using Javascript. The HTML object ID is supplemented with the abbreviation “id” and then it works. Is there a way to assign a CSS class to a Lectora group using Javascript? With the Lectora HTML object ID for groups (og...) I tried using the two letters "id" at the end, but somehow that doesn't work. On the other hand, in Lectora an entire group can e.g. hidden with a transition. The contents of the group are not selected individually; I only have to assign the transition to the group once. Maybe someone knows a solution. Thank you.

ekmud

(translated with Google)

Solution

You can call any group ( with an action in it ) by using this syntax.

og123456.issueActions(1001); 

Where the og123456 number ofcourse is the groups HTMLName.

It is ofcourse annoying to note all HTMLNames for groups..so to overcome that quite a while ago this script was made.


Add this Javascript code at start of a page/project ( i use Lectora Online, there are some differences in Publisher ) will give any group ( og ) in Lectora a prefix so it can be easily selected... and acted upon.


// set whatever prefix you want to use for object names that will map to their HTML object
var objectPrefix = "EDU";

var chlds = getDisplayDocument().head.childNodes;
for (var i=0;i<chlds.length;i++)
{
	if (chlds[i].tagName && chlds[i].tagName.toLowerCase().indexOf('script')>-1 && 
	  chlds[i].innerHTML && chlds[i].innerHTML.indexOf('trivWeb20Popups')>-1 )
	{
	  var re = new RegExp("var\\s*([^\\s]*).*//("+objectPrefix+"[^\\s]*)",'g');
    var s = chlds[i].innerHTML;
    s.replace(re, function(match, g1, g2) { 
      eval("window."+g2+"="+g1); 
    });
	}
}

Give your groups proper names with the prefix in it.

Then you can call...

EDU_myGroup1.issueActions(1001); 


Discussion (2)

mmh now I'll find an answer about CSS and Lectora groups afterwards. Well, better twice than never. Thanks.

You can call any group ( with an action in it ) by using this syntax.

og123456.issueActions(1001); 

Where the og123456 number ofcourse is the groups HTMLName.

It is ofcourse annoying to note all HTMLNames for groups..so to overcome that quite a while ago this script was made.


Add this Javascript code at start of a page/project ( i use Lectora Online, there are some differences in Publisher ) will give any group ( og ) in Lectora a prefix so it can be easily selected... and acted upon.


// set whatever prefix you want to use for object names that will map to their HTML object
var objectPrefix = "EDU";

var chlds = getDisplayDocument().head.childNodes;
for (var i=0;i<chlds.length;i++)
{
	if (chlds[i].tagName && chlds[i].tagName.toLowerCase().indexOf('script')>-1 && 
	  chlds[i].innerHTML && chlds[i].innerHTML.indexOf('trivWeb20Popups')>-1 )
	{
	  var re = new RegExp("var\\s*([^\\s]*).*//("+objectPrefix+"[^\\s]*)",'g');
    var s = chlds[i].innerHTML;
    s.replace(re, function(match, g1, g2) { 
      eval("window."+g2+"="+g1); 
    });
	}
}

Give your groups proper names with the prefix in it.

Then you can call...

EDU_myGroup1.issueActions(1001);