Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

63 lines (45 sloc) 1.591 kb

Plugins

Name your plugin as wysiwyg.plugin_name.js and place it under plugins directory.

Sample

(function($) {

    // Check that jWYSIWYG was loaded
    if (undefined === $.wysiwyg) {
        throw "wysiwyg.plugin_name.js depends on $.wysiwyg";
    }

    // plugin
    var PluginName = {
        name: "PluginName",

        // plugin defaults
        defaults: {},

        somePluginMethod: function(text) {
            // do something
        },

        methodThatWorksWithJqueryObjects: function(object, arg1, arg2) {
                            // jQuery chain
            return object.each(function() {
                    // standard operations
                var Wysiwyg = $(this).data("wysiwyg");

                if (!Wysiwyg) {
                    return this;
                }

                // Plugin code
                // do something
            });
        }
    };

    // Register your plugin
    $.wysiwyg.plugin.register(PluginName);

})(jQuery);

There are two methods to run your plugin:

$("textarea").wysiwyg("PluginName.somePluginMethod", "some text")
$("textarea").wysiwyg("PluginName.methodThatWorksWithJqueryObjects", "arg1", "arg2")

or

$.wysiwyg.PluginName.somePluginMethod("some text")
$.wysiwyg.PluginName.methodThatWorksWithJqueryObjects($("textarea"), "arg1", "arg2")

See also help/examples/12-writing-plugins.html

Jump to Line
Something went wrong with that request. Please try again.