anvc / scalar

Born-digital, open source, media-rich scholarly publishing that’s as easy as blogging.
Other
231 stars 73 forks source link

Changing "Begin with 'X'" path button #160

Closed hesperidium closed 3 years ago

hesperidium commented 3 years ago

Attempting to customize "Begin with 'X'" button to say "Enter".

I've been starting with the script for customizing the relationships headers...

$(document).ready(function() {
  $('body').on('pageLoadComplete',function() {
    $('.path_of').prev().text('NEW TEXT');
  });
}); 

...and trying different updates to the last line/adding lines based on the HTML description of the button in question (.path_begin.nav_btn.primary and variations on this) and the '// "begin with" button' section of the scalarpage.jquery.js (below), but unsurprisingly these all-but-uneducated guesses have not led to any effects.

Thanks in advance for any assistance!!

// "begin with" button
                        if ((pathOptionCount == 0) && options.showChildNav) {
                            nodes = currentNode.getRelatedNodes('path', 'outgoing');
                            if (nodes.length > 0) {
                                button = $('<p><a class="path_begin nav_btn" href="' + nodes[0].url + '?path=' +
                                    currentNode.slug + '">Begin with &ldquo;' + nodes[0].getDisplayTitle() +
                                    '&rdquo; THIS SECTION IS WHAT I'D LIKE TO CHANGE!</a></p>').appendTo(pathContents);
                                button.find('a').addClass('primary');
                                pathOptionCount++;
                                //page.addPathButton('down', nodes[0], currentNode);
                            }
                        }

                    }
                });
craigdietrich commented 3 years ago

Hi @hesperidium,

The first code snippet you posted, that works, correct? Ie, it changes the path button's text to 'NEW TEXT'?

If so, I'm not 100% sure what you're trying to do in the next snippet. Why can't 'NEW TEXT' simply say, 'Enter'?

hesperidium commented 3 years ago

Hi again, Craig, thanks for all your help!

So the first snippet is what I've been using to change the standard "Contents" path header (text only, not a link) to say something else. I've also used that same format to change the "Is tagged by" and "Has tags" defaults to custom text.

What I'm looking to do now is to customize the "Begin with 'X'" button that appears underneath the path via the line .appendTo(pathContents);. The second snippet is the default code for the the "Begin with" button, but I'm not sure what pieces of that to integrate into the pageLoadComplete function, or if I am totally off on this strategy.

craigdietrich commented 3 years ago

Would this work?

$(document).ready(function() {
  $('body').on('pageLoadComplete',function() {
    $('.path_of').prev().text('NEW TEXT');
    $('.path_of').next().find('a').text('Enter');
  });
}); 
hesperidium commented 3 years ago

That's IT! .next() was the key. Thanks a million!