Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TinyMCE: uglify the inline XTD-btns script #19731

Merged
merged 5 commits into from
Feb 26, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 17 additions & 3 deletions plugins/editors/tinymce/tinymce.php
Original file line number Diff line number Diff line change
Expand Up @@ -794,36 +794,50 @@ private function tinyButtons($name, $excluded)
}

// Now we can built the script
// AddButton starts here
$tempConstructor[] = 'editor.addButton("' . $name . '",{';
$tempConstructor[] = 'text:"' . $title . '",';
$tempConstructor[] = 'title:"' . $title . '",';
$tempConstructor[] = 'icon:"' . $icon . '",';

// Onclick starts here
$tempConstructor[] = 'onclick:function(){';

if ($href || $button->get('modal'))
{
// TinyMCE standard modal options
$tempConstructor[] = 'var modalOptions={';
$tempConstructor[] = 'title:"' . $title . '",';
$tempConstructor[] = 'url:"' . $href . '",';
$tempConstructor[] = 'buttons:[{text: "Close",onclick:"close"}]};';
$tempConstructor[] = 'buttons:[{text: "Close",onclick:"close"}]';
$tempConstructor[] = '};';

// Set width/height
$tempConstructor[] = 'modalOptions.width=parseInt(' . intval($options["width"]) . ', 10);';
$tempConstructor[] = 'modalOptions.height=parseInt(' . intval($options["height"]) . ', 10);';
$tempConstructor[] = 'if(modalWidth){modalOptions.width=modalWidth;} ';
$tempConstructor[] = 'if(modalHeight){modalOptions.height = modalHeight;} ';
$tempConstructor[] = 'if(modalWidth){modalOptions.width=modalWidth;}';
$tempConstructor[] = 'if(modalHeight){modalOptions.height = modalHeight;}';
$tempConstructor[] = 'editor.windowManager.open(modalOptions);';

if ($onclick && ($button->get('modal') || $href))
{
// Adds callback for close button
$tempConstructor[] = $onclick . ';';
}
}
else
{
// Adds callback for the button, eg: readmore
$tempConstructor[] = $onclick . ';';
}

// Onclick ends here
$tempConstructor[] = '}';

// AddButton ends here
$tempConstructor[] = '});';

// IIFE ends here
$tempConstructor[] = '})();';
Copy link
Contributor

Choose a reason for hiding this comment

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

IIFE ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Immediately Invoked Function Expression

Basically an anonymous function that is immediately executed.

Copy link
Contributor

Choose a reason for hiding this comment

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

It ends there but where does it start?


// The array with the toolbar buttons
Expand Down