Skip to content
This repository was archived by the owner on Apr 19, 2019. It is now read-only.

Conversation

@dgrammatiko
Copy link
Contributor

Pull Request for Issue # .

Summary of Changes

  • Added one more layout for toolbar apply button
  • Added needed code in core.js to support mapping key press to save

Testing Instructions

Documentation Changes Required

@C-Lodder
Copy link
Member

Could u please test on windows @DGT41.

Just tested and it's not working

*
* @return string JavaScript command string
*
* @since 3.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3.0 ? Should this not be __DEPLOY_VERSION__ or 4.0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup

@wilsonge
Copy link
Contributor

Doesn't work for me on macbook either

@dgrammatiko
Copy link
Contributor Author

dgrammatiko commented Oct 15, 2016

For mac is command+s

By the way which view did you try? (article edit)

@C-Lodder
Copy link
Member

yes i did that (george here) - it tried to save html contents of the page. i did also read your js :P

// Initiate the listener for the combo key
document.addEventListener( 'DOMContentLoaded', function() {
if (Joomla.getOptions( 'keySave' ) ) {
Joomla.keysave( Joomla.getOptions( 'keySave' ).task );
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you insert a console.log(Joomla.getOptions( 'keySave' ).task); before this line?
what it is in the console?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

article.apply

if (e.keyCode == 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) {
e.preventDefault();
Joomla.submitbutton.call(button)
}
Copy link
Contributor Author

@dgrammatiko dgrammatiko Oct 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Joomla.submitbutton(button);

@C-Lodder try with the above code

Dimitri Grammatikogianni added 2 commits October 15, 2016 20:11
@C-Lodder
Copy link
Member

Ok I know the issue now.

You can't be focused on the editor when using CTRL + S. You need to click outside the editor for it to work.

This only happens with TinyMCE.

*/
Joomla.keysave = function ( button ) {
document.addEventListener("keydown", function(e) {
if (e.keyCode == 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a console.log(''pressed: ' + e.keyCode + ' and ' + e.ctrlKey );
What happens when you press keys?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or try

if (String.fromCharCode(e.which).toLowerCase() == 's' && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

British keyboards, I guess your s is mapped to some other keyCode 😄

@C-Lodder
Copy link
Member

Tiny mce loads in an iframe so i guess the iframe doesn't load the keybindings (george)

@dgrammatiko
Copy link
Contributor Author

Ahh, crap, I didn;t try it with focus in tiny window (?)

@C-Lodder
Copy link
Member

xD

@dgrammatiko
Copy link
Contributor Author

}
else
{
JHtml::_('behavior.core');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

behaviour core is being loaded in the if and the else can we just load it outside the if and then remove the else?

@wilsonge
Copy link
Contributor

Go for it then :)

@C-Lodder
Copy link
Member

C-Lodder commented Oct 17, 2016

@DGT41 - Forget the research, already solved it:

tinymce-init.js (line 62 directly above tinyMCE.init(options);), add the following:

options.plugins = 'save';
options.toolbar = 'save';
options.save_onsavecallback = function() { Joomla.submitbutton('article.apply'); }

This is the only bit of code you need, so you can revert all the other changes you've made.

@dgrammatiko
Copy link
Contributor Author

The only problem is that article.apply will work only in articles, so it needs something more...

@dgrammatiko
Copy link
Contributor Author

dgrammatiko commented Oct 17, 2016

last commit:

  • remove tiny close script (mootools modal thingy)
  • make tinyMCE init script vanilla
  • add support for ctrl+s

NOTE: if you haven't change anything in the editor area (no new text, etc) the save will not initiate!

With this ctrl+s works on all editors that comes with Joomla

@C-Lodder
Copy link
Member

All working now :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants