Skip to content

Instantly share code, notes, and snippets.

Created July 28, 2016 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/7cce8fde7eba7d43b56d94df0271d64d to your computer and use it in GitHub Desktop.
Save anonymous/7cce8fde7eba7d43b56d94df0271d64d to your computer and use it in GitHub Desktop.
(function($) {
// Define the hello button
$.cleditor.buttons.strong = {
name: "strong",
image: "hello.gif",
title: "Hello World",
command: "inserthtml",
/*
popupName: "hello",
popupClass: "cleditorPrompt",
popupContent: "Enter your name:<br><input type=text size=10><br><input type=button value=Submit>",
*/
buttonClick: strongClick
};
// Add the button to the default controls before the bold button
/*
$.cleditor.defaultOptions.controls = $.cleditor.defaultOptions.controls
.replace("bold", "strong bold");
*/
// Handle the hello button click event
function strongClick(e, data) {
var editor = data.editor;
var selectedText = editor.selectedText(editor.$area);
//console.log(selectedText);
//console.log(data.button);
var html = "<strong>" + $.trim(selectedText) + "</strong>";
// editor, command, value, useCSS, button
editor.execCommand(data.command, html, null, data.button);
editor.focus();
/*
// Wire up the submit button click event
$(data.popup).children(":button")
.unbind("click")
.bind("click", function(e) {
// Get the editor
var editor = data.editor;
// Get the entered name
var name = $(data.popup).find(":text").val();
// Insert some html into the document
var html = "<strong>" + name + "</strong>";
editor.execCommand(data.command, html, null, data.button);
// Hide the popup and set focus back to the editor
editor.hidePopups();
editor.focus();
});
*/
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment