Atto Plugin Icons ..where do they go?

Atto Plugin Icons ..where do they go?

by Justin Hunt -
Number of replies: 5
Picture of Particularly helpful Moodlers Picture of Plugin developers

Hi there, I am porting my TinyMCE plugin, PoodLL Anwhere , to Atto. 

So far so good. But I can't seem to make Atto load my PoodLL Anywhere icon for the toolbar. The button appears, and does what it is supposed to when I click it. But the icon doesn't load from the pix folder in the sub-Plugins directory. The core Atto sub-plugins all pull their icons from the [moodle]/pix/e .

Can anyone tell me where I should put the icons for the Atto toolbar?

 

*Update: I found the code in button.js that looks like this:

initializer: function() {
// Add the poodll button first.
this.addButton({
icon: 'e/insert_edit_poodll',
callback: this._displayDialogue,
tags: 'a'
});

 

So I guess I need to build the button as a YUI module. I think that means I have to install "shifter." I will play with that from now, but would the correct path then be:

insert_edit_poodll

or 

lib/editor/atto/plugins/poodll/pix/insert_edit_poodll

 

?

Average of ratings: -
In reply to Justin Hunt

Re: Atto Plugin Icons ..where do they go?

by Andrew Lyons -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Hi Justin,

Firstly yay - I like that you're writing your first Atto plugin. We've worked hard to try and produce a friendly API so any feedback you have would be gratefully appreciated.

There's actually a whole set of API docs for atto, but the relevant one for what you want is at http://apidocs.moodle.org/js/master/classes/M.editor_atto.EditorPlugin.html#method_addButton

When you call addButton, you just need to specify the iconComponent key. Here's an example:

initializer: function() {
    // Add the poodll button first.
this.addButton({
icon: 'e/insert_edit_poodll',
iconComponent: 'atto_poodll',
callback: this._displayDialogue,
tags: 'a'
});
}

The reason that all of the core plugins use the standard core component is because we wanted to help encourage use of the same icons for core functionality of all editors - that's to say that changing the icon for one editor should change all editors by default so all editors have the same Bold, Italic, Underline, etc... icons.

For contrib plugins you'll then need to put your icon image into the following folder:

lib/editor/atto/plugins/poodll/pix/e

You don't *have* to use Shifter - you can use the fallback method, but it's advisable that you do use Shifter as this handles things like minification, linting, dependency seeding, and a few other bits and pieces. If you don't want to use Shifter, then you can put the JS in (I think, but haven't tested):

lib/editor/atto/yui/button/button.js

Hope that this helps and good luck,

Andrew

Average of ratings: Useful (1)
In reply to Andrew Lyons

Re: Atto Plugin Icons ..where do they go?

by Justin Hunt -
Picture of Particularly helpful Moodlers Picture of Plugin developers

Cool. That worked. And thanks for the documentation tip. I was stepping through the source code.

Is there any reason to put the icon on pix/e and not simply pix ?

In reply to Justin Hunt

Re: Atto Plugin Icons ..where do they go?

by Andrew Lyons -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Nope - none what-so-ever - it's entirely up to you how you organise your pix folder.

If you run:

sudo npm install yuidocjs -g

Then you should be able to run yuidoc from the root folder of Moodle to generate documentation which includes your own JS modules (Shifted YUI only I'm afraid). You can also run yuidoc -s and it will run in a server mode so that you can inspect the documentation as you go.

Best wishes,

Andrew

In reply to Andrew Lyons

Re: Atto Plugin Icons ..where do they go?

by Justin Hunt -
Picture of Particularly helpful Moodlers Picture of Plugin developers

I did install shifter. (t and f are too close on the keyboard) And it is pretty easy to use. I am keeping some notes on this as I go, so hopefully I can post a tutorial on dev.moodle.org or somewhere. 

I am pretty sure I will have some more questions but I will try and post them in separate threads.

In reply to Justin Hunt

Re: Atto Plugin Icons ..where do they go?

by Andrew Lyons -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Hi Justin,

That'd be great! If you haven't already seen, there are some related docs at:

We've also recently approved a new JS coding style guideline too: http://docs.moodle.org/dev/Javascript/Coding_style

I found that f/t problem too - I now have a bash alias for shifter:

alias s='shifter'

All the best,

Andrew