summaryrefslogtreecommitdiff
path: root/static-files/journal/wymeditor/plugins/list/jquery.wymeditor.list.js
blob: b009e2587ba7c98fac4bec0ff567c13c1a59ebb9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
 * Copyright (c) 2011 PolicyStat LLC.
 * MIT licensed (MIT-license.txt)
 *
 * This plugin adds the ability to use tab and shift+tab to indent/outdent
 * lists, mimicking a user's expected behavior when inside an editor.
 *
 * @author Wes Winham (winhamwr@gmail.com)
 */

function ListPlugin(options, wym) {
    var listPlugin = this;
    ListPlugin._options = jQuery.extend({}, options);
    listPlugin._wym = wym;

    listPlugin.init();
}

ListPlugin.prototype.init = function() {
    var listPlugin = this;
    listPlugin._wym.listPlugin = listPlugin;

    listPlugin.bindEvents();
};

ListPlugin.prototype.bindEvents = function() {
    var listPlugin = this,
        wym = listPlugin._wym;

    wym.keyboard.combokeys.bind(
        "tab",
        function () {
            wym.indent();
            return false;
        }
    );
    wym.keyboard.combokeys.bind(
        "shift+tab",
        function () {
            wym.outdent();
            return false;
        }
    );
};