? ? Pending

User tests: Successful: Unsuccessful:

avatar brianteeman
brianteeman
27 Feb 2019

Initial commit - still a work in progress

@dgrammatiko Please advise/help on the addScriptOptions

avatar brianteeman brianteeman - open - 27 Feb 2019
avatar brianteeman brianteeman - change - 27 Feb 2019
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 27 Feb 2019
Category Administration Language & Strings Repository Libraries NPM Change Front End Plugins
avatar C-Lodder
C-Lodder - comment - 27 Feb 2019

Try the following:

const SkipToConfig = {
    "settings": {
        "skipTo": {
            // config options for text
            "buttonLabel"  : Joomla.Text._('PLG_SYSTEM_SKIPTO_SKIP_TO'),
            buttonLabel    : 'Skip To...',
            menuLabel      : 'Skip To and Page Outline',
            landmarksLabel : 'Skip To',
            headingsLabel  : 'Page Outline',
        }
    }
};

Of course replacing the other static text strings with Joomla.Text._('xxx')

avatar brianteeman
brianteeman - comment - 27 Feb 2019

awesome thanks @C-Lodder

avatar dgrammatiko
dgrammatiko - comment - 27 Feb 2019
            Factory::getDocument()->addScriptOptions(
	                'settings', 
	                array (
	                    'buttonLabel:'      => Text::_('PLG_SYSTEM_SKIPTO_SKIP_TO'),
	                    'buttonDivTitle:'   => Text::_('PLG_SYSTEM_SKIPTO_SKIP_TO_KEYBOARD'),
	                    'menuLabel:'        => Text::_('PLG_SYSTEM_SKIPTO_SKIP_TO_AND_PAGE_OUTLINE'),
	                    'landmarksLabel:'   => Text::_('PLG_SYSTEM_SKIPTO_SKIP_TO'),
	                    'headingsLabel:'    => Text::_('PLG_SYSTEM_SKIPTO_PAGE_OUTLINE'),
	                    'contentLabel:'     => Text::_('PLG_SYSTEM_SKIPTO_CONTENT'),
	                )
	             );
avatar brianteeman brianteeman - change - 27 Feb 2019
Labels Added: ? NPM Resource Changed ?
avatar brianteeman
brianteeman - comment - 27 Feb 2019

It looks from the code it should be

 	"settings": {
		"skipTo": {

???

avatar dgrammatiko
dgrammatiko - comment - 27 Feb 2019

@brianteeman since that script is outdated (es5 unmaintained) I'll propose to just port it directly yo Joomla with the appropriate attributes in the doc block. If that is something people are ok I'll do the porting

avatar dgrammatiko
dgrammatiko - comment - 27 Feb 2019

@brianteeman what @C-Lodder posted is JS you need to pass the values from the PHP, use the code I provided

avatar brianteeman
brianteeman - comment - 27 Feb 2019

@dgrammatiko they accepted a pr from @wilsonge and someone else this year ;)

avatar brianteeman
brianteeman - comment - 27 Feb 2019

But if you were to create a dedicated joomla version then it would be awesome if it had the extra features that the facebook skipto has.

avatar dgrammatiko
dgrammatiko - comment - 27 Feb 2019

@brianteeman sorry I've missed that. Here is my approach to this:
screenshot 2019-02-27 at 20 49 02

Create a PR in their repo and just add next to window.wordpress, the value || (window.Joomla && typeof window.Joomla.getOptions === 'function' && window.Joomla.getOptions('skipto-settings'))
Also change the 'settings' in the php needs to be renamed to 'skipto-settings'

avatar dgrammatiko
dgrammatiko - comment - 27 Feb 2019

if it had the extra features that the facebook skipto has

Do you have a link for that?

avatar brianteeman
brianteeman - comment - 27 Feb 2019

The facebook code is not available - you can see it by typing Alt /

avatar dgrammatiko
dgrammatiko - comment - 27 Feb 2019

wow cool:
screenshot 2019-02-27 at 21 05 50

So the only difference I see id that FB also has another menu with some routes (urls) some help links. Am I reading this correctly?

avatar zwiastunsw
zwiastunsw - comment - 27 Feb 2019

Am I doing something wrong? I can't install the plugin. I see it in Discovery. The Install command causes an error:
error

avatar brianteeman
brianteeman - comment - 27 Feb 2019

It is still a work in progress

avatar brianteeman
brianteeman - comment - 28 Feb 2019

@dgrammatiko yes thats about it

avatar zwiastunsw
zwiastunsw - comment - 28 Feb 2019

If it is not a plugin from the "system" group, but from the "skipto" group, maybe the language strings should be changed as well? (PLG_SYSTEM_SKIPTO_SKIP_TO , etc.),

avatar brianteeman
brianteeman - comment - 28 Feb 2019

@zwiastunsw at the moment I cant get the script or css to load at all :(

@dgrammatiko I must be doing something obviously wrong but I cant see why this isn't doing anything

			HTMLHelper::_('script', 'vendor/skipto/js/skipTo.js', ['version' => 'auto', 'relative' => true]);
			HTMLHelper::_('stylesheet', 'vendor/skipto/css/SkipTo.css', ['version' => 'auto', 'relative' => true], ['defer' => true]);
avatar brianteeman
brianteeman - comment - 28 Feb 2019

@zwiastunsw the language string constants are correct. Look at the other system plugin language files and you will see they follow the PLG_SYSTEM_NAME_ convention

avatar zwiastunsw
zwiastunsw - comment - 28 Feb 2019

I've already noticed - I understood the change in the xml file, sory

avatar dgrammatiko
dgrammatiko - comment - 28 Feb 2019

@brianteeman you need to init the script, try:

Factory::getDocument()->addScriptDeclaration(
"
window.skipToMenuInit(Joomla.getOptions('skipto-settings'));
"
);

Also you need to change the settings part in https://github.com/joomla/joomla-cms/pull/24042/files#diff-da83472045fbc26e0c9e98f68224eeedR56
to 'skipto-settings'. That should do it

avatar brianteeman
brianteeman - comment - 28 Feb 2019

@dgrammatiko that may work - I dont know. the problem is that the two lines that should load the css and js are just not doing anything. no 404, nothing, nada, zilch

Must be something obvious but I cant see it

avatar dgrammatiko
dgrammatiko - comment - 28 Feb 2019

@brianteeman try this:

			// Add strings for translations in Javascript.
			Factory::getDocument()->addScriptOptions(
				'skipto-settings',
					[
						'settings' => [
							'skipTo' => [
								'buttonLabel:'      => Text::_('PLG_SYSTEM_SKIPTO_SKIP_TO'),
								'buttonDivTitle:'   => Text::_('PLG_SYSTEM_SKIPTO_SKIP_TO_KEYBOARD'),
								'menuLabel:'        => Text::_('PLG_SYSTEM_SKIPTO_SKIP_TO_AND_PAGE_OUTLINE'),
								'landmarksLabel:'   => Text::_('PLG_SYSTEM_SKIPTO_SKIP_TO'),
								'headingsLabel:'    => Text::_('PLG_SYSTEM_SKIPTO_PAGE_OUTLINE'),
								'contentLabel:'     => Text::_('PLG_SYSTEM_SKIPTO_CONTENT'),
							]
						]
					]
			);
			HTMLHelper::_('script', 'vendor/skipto/skipTo.js', ['version' => 'auto', 'relative' => true]);
			HTMLHelper::_('stylesheet', 'vendor/skipto/SkipTo.css', ['version' => 'auto', 'relative' => true]);

			$document->addScriptDeclaration("window.skipToMenuInit(Joomla.getOptions('skipto-settings'));");
avatar C-Lodder
C-Lodder - comment - 28 Feb 2019

@brianteeman silly question, but did you run npm i?

avatar brianteeman
brianteeman - comment - 28 Feb 2019

@C-Lodder yes and it created
media/vendor/skipto/js/skipTo.js
media/vendor/skipto/css/SkipTo.css

if the files were not there then I would have expected to get a 404 or something. but the css and js are not even in the source of the generated page

avatar dgrammatiko
dgrammatiko - comment - 28 Feb 2019

@brianteeman @C-Lodder the error is on the relative path and the fact that the path given was absolute. The snippet above should fix that

Eg. HTMLHelper::_('script', 'vendor/skipto/skipTo.js', ['version' => 'auto', 'relative' => true]);
whenever you use 'relative' => true you shouldn't have the path with the js or css in it or the file will not get served

avatar brianteeman
brianteeman - comment - 28 Feb 2019

yes - looks like progress. - thanks

I will carry on working on this now

avatar C-Lodder
C-Lodder - comment - 28 Feb 2019

@dgrammatiko ah yes, didn't even notice the js/css in the path

avatar C-Lodder
C-Lodder - comment - 28 Feb 2019

@brianteeman - Just seen you've added a dropdown menu script. Would you be able to try using the Custom Element, as I've done here: https://github.com/joomla/joomla-cms/pull/23665/files ?

Only thing missing from my PR is fetching it via NPM

avatar brianteeman
brianteeman - comment - 28 Feb 2019

@C-Lodder I added it because I realised the paypal script came with it. They combine it into the skipto.js file in their build tools but we arent using the tools so I assumed I needed to do it this way.

More than happy to use anything you want me to use.

But right now I am still getting js errors

Uncaught TypeError: Cannot read property 'nodeType' of null
Uncaught TypeError: window.skipToMenuInit is not a function

As you can tell I really dont have a clue with js

avatar C-Lodder
C-Lodder - comment - 28 Feb 2019

I'm more than happy to help when I get back from work in a couple of hours

avatar brianteeman
brianteeman - comment - 28 Feb 2019

Thanks - I am out this evening but you can always do a pr on my branch

avatar C-Lodder
C-Lodder - comment - 28 Feb 2019

In the mean time, it looks like you're missing some config options:

https://github.com/paypal/skipto#configuring-skipto-options

such as the ID's. So that would probably explain the first error above.

avatar brianteeman
brianteeman - comment - 28 Feb 2019

From what I can tell the defaults are being used which should be ok - anyway moving on to work on something else for now

avatar brianteeman
brianteeman - comment - 4 Mar 2019

Fixed one of the errors
Uncaught TypeError: Cannot read property 'nodeType' of null
by adding defer

The skipto toolbar now loads and works
But the second problem still exists which prevents customisation
Uncaught TypeError: window.skipToMenuInit is not a function

avatar dgrammatiko
dgrammatiko - comment - 4 Mar 2019

@brianteeman if you type skipToMenuInit() in the browser's console what are you getting?

avatar brianteeman
brianteeman - comment - 4 Mar 2019

undefined

avatar brianteeman
brianteeman - comment - 6 Mar 2019

@zwiastunsw although it is not completely working yet (the changes to make language strings work) you can test the functionality right now. It requires a composer install and a npm install.

You can find out more about the plugin here http://paypal.github.io/skipto/

avatar zwiastunsw
zwiastunsw - comment - 8 Mar 2019

I tested it. It works well.
My questions:

  • Will the add-on be configurable?
  • Will it be able to be enabled on the front page?
  • Also, are you considering adding accessibility help links (just like on Facebook)?
avatar brianteeman
brianteeman - comment - 8 Mar 2019

Will the add-on be configurable?

Once someone helps me work out why the current options isnt working

Will it be able to be enabled on the front page?

It could be. I was thinking - admin - on by default, site on by option

Also, are you considering adding accessibility help links (just like on Facebook)?

would love to but that would require creating our own version of the script

avatar zwiastunsw
zwiastunsw - comment - 8 Mar 2019

My suggestion: merge the plugins as it is now, to work on its usefulness (adding landmarks, adding headers on backend pages, etc.).

avatar brianteeman
brianteeman - comment - 8 Mar 2019

I really don't want to merge it until at least the translation is working

avatar brianteeman
brianteeman - comment - 9 Mar 2019

thanks to @wilsonge we dont get any javascript errors now.

still dont get the settings being used though :(

I will take another look tomorrow

avatar wilsonge
wilsonge - comment - 9 Mar 2019

Sorry I edited my code to fix that. Then the settings are used

avatar wilsonge
wilsonge - comment - 9 Mar 2019

Btw. How do you actually activate this thing. I can see it in the dom. just can't see any way to visually get it on screen. Or is that the idea?

avatar brianteeman
brianteeman - comment - 9 Mar 2019

Hit the tab key or alt 0

On Sat, 9 Mar 2019, 00:19 George Wilson, notifications@github.com wrote:

Btw. How do you actually activate this thing. I can see it in the dom.
just can't see any way to visually get it on screen. Or is that the idea?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#24042 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABPH8SMa1ZdRUfdGo1cmWu8VipQEZ4kAks5vUv34gaJpZM4bVRRy
.

avatar dgrammatiko
dgrammatiko - comment - 9 Mar 2019

@brianteeman try

$document->addScriptDeclaration("document.addEventListener('DOMContentLoaded', function() {
    window.skipToMenuInit(Joomla.getOptions('skipto-settings'));
});");
avatar wilsonge
wilsonge - comment - 9 Mar 2019

Hit the tab key or alt 0

OK. Either way - make the javascript change I suggested - @dgrammatiko 's is wrong (that function doesn't take an options argument)

$document->addScriptDeclaration("document.addEventListener('DOMContentLoaded', function() {
    window.SkipToConfig = Joomla.getOptions('skipto-settings');
    window.skipToMenuInit();
});");

Then see if the strings translate for you or not

avatar brianteeman
brianteeman - comment - 9 Mar 2019

I will do after the rugby #priorities

avatar wilsonge
wilsonge - comment - 9 Mar 2019

It's only important if scotland manage to upset :D :D

avatar brianteeman
brianteeman - comment - 9 Mar 2019

@wilsonge Thanks!!!!

The javascript is now working and like you I have had to add the $this->loadLanguage()

I am going to work on adding options etc in the plugin now

avatar joomla-cms-bot joomla-cms-bot - change - 9 Mar 2019
Category Administration Language & Strings Repository Libraries NPM Change Front End Plugins Unit Tests Repository Administration com_admin
avatar brianteeman brianteeman - change - 9 Mar 2019
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2019-03-09 19:40:27
Closed_By brianteeman
Labels Added: ?
Removed: ? NPM Resource Changed
avatar brianteeman brianteeman - close - 9 Mar 2019
avatar brianteeman
brianteeman - comment - 9 Mar 2019

See #24142

avatar dgrammatiko
dgrammatiko - comment - 9 Mar 2019

@wilsonge yeah for sure I'm wrong:
Screenshot 2019-03-09 at 22 21 03

Add a Comment

Login with GitHub to post a comment