ここの情報は古いです。ご理解頂いた上でお取り扱いください。

source: OpenPNE/branches/stable-2.12.x/public_html/js/pne_decoration.js.src @ 7290

Last change on this file since 7290 was 7290, checked in by ebihara, 11 years ago

#2338:TinyMCEが用意するアンドゥ・リドゥの機能を無効にした

File size: 6.0 KB
Line 
1function pne_toggle_mce_editor(id)
2{
3    var textmode_checked = document.getElementById("mce_editor_mode_changer_1").checked;
4    var previewmode_checked = document.getElementById("mce_editor_mode_changer_2").checked;
5
6    var editor = tinyMCE.get(id);
7    if (!editor && previewmode_checked) {
8        tinyMCE.execCommand('mceAddControl', 0, id);
9        document.getElementById('mce_editor_buttonmenu').style.display = "none";
10        return true;
11    }
12
13    if (editor.isHidden() && previewmode_checked) {
14        editor.show();
15        document.getElementById('mce_editor_buttonmenu').style.display = "none";
16    } else if (!editor.isHidden() && textmode_checked) {
17        editor.hide();
18        document.getElementById('mce_editor_buttonmenu').style.display = "block";
19    }
20}
21
22function pne_mce_editor_init()
23{
24    tinyMCE.init({
25        mode : "textareas",
26        theme : "advanced",
27        editor_selector : "mceEditor_dummy_selector",
28        plugins : "openpne",
29        theme_advanced_toolbar_location : "top",
30        theme_advanced_toolbar_align : "left",
31        theme_advanced_buttons1 : "op_b,op_u,op_s,op_i,op_large,op_small,op_color,op_image,op_emoji_docomo,op_emoji_au,op_emoji_softbank,|,op_cmd",
32        theme_advanced_buttons2 : "",
33        theme_advanced_buttons3 : "",
34        valid_elements : "b/strong,u,s/strike,i,font[color|size],br",
35        forced_root_block : false,
36        force_p_newlines : false,
37        force_br_newlines : true,
38        inline_styles : false,
39        language : "ja",
40        entity_encoding : "raw",
41        remove_linebreaks : false,
42        custom_undo_redo_levels : 0,
43        custom_undo_redo : false
44    });
45
46    var textmode_checkbox = document.getElementById("mce_editor_mode_changer_1");
47    var previewmode_checkbox = document.getElementById("mce_editor_mode_changer_2");
48    if (previewmode_checkbox.checked) {
49        textmode_checkbox.checked = true;
50        previewmode_checkbox.checked = false;
51    }
52}
53
54function pne_mce_insert_tagname(id, tagname, opt)
55{
56    var opt = opt || "";
57
58    var elm = document.getElementById(id);
59    var selection = new Selection(elm);
60
61    var pos = selection.create();
62
63    if (tagname == "op:color" && !opt) {
64        pne_mce_show_color_table(id, tagname);
65        return;
66    }
67
68    var replace = "<" + tagname + opt + ">" + elm.value.substring(pos.start, pos.end) + "</" + tagname + ">";
69    var head = elm.value.substring(0, pos.start);
70    var tail = elm.value.substring(pos.end, elm.value.length);
71    elm.value =  head + replace + tail;
72}
73
74function pne_mce_show_color_table(id, tagname)
75{
76    var table = document.getElementById("mce_editor_color_table")
77    if (table) {
78        if (table.style.display == 'none') {
79            table.style.display = 'block';
80            Event.observe(document, 'mousedown', pne_mce_hide_color_table);
81        } else {
82            pne_mce_hide_color_table();
83        }
84        return;
85    }
86
87    Event.observe(document, 'mousedown', pne_mce_hide_color_table);
88
89    var color = null;
90    var settings = {
91        colors : ["000000","993300","333300","003300","003366","000080","333399","333333","800000","FF6600","808000","008000","008080","0000FF","666699","808080","FF0000","FF9900","99CC00","339966","33CCCC","3366FF","800080","999999","FF00FF","FFCC00","FFFF00","00FF00","00FFFF","00CCFF","993366","C0C0C0","FF99CC","FFCC99","FFFF99","CCFFCC","CCFFFF","99CCFF","CC99FF","FFFFFF"],
92        grid_width : 8,
93        default_color : "#888888"
94    };
95
96    var button = document.getElementById("mce_textmode_button_op_color");
97
98    var button_container = document.getElementById("mce_editor_buttonmenu");
99
100    var tbody = document.createElement("tbody");
101    Element.addClassName(tbody, 'disabledHideColorTable');
102
103    var tr;
104 
105    for (var i = 0; i < settings.colors.length; i++) {
106        var code = "#" + settings.colors[i];
107
108        if (i == 0 || i % settings.grid_width == 0) {
109            tr = document.createElement("tr");
110            Element.addClassName(tr, 'disabledHideColorTable');
111            tbody.appendChild(tr);
112        }
113
114        var td = document.createElement("td");
115        td.style.border = "0 none";
116        td.style.width = "12px";
117        td.style.padding = "2px";
118        td.style.margin = "0";
119        Element.addClassName(td, 'disabledHideColorTable');
120
121        var a = document.createElement("a");
122        a.setAttribute("href", "#");
123        a.colorCode = code;
124        a.style.width = "9px";
125        a.style.height = "9px";
126        a.style.display = "block";
127        a.style.overflow = "hidden";
128        a.style.border = "1px solid #808080";
129        a.style.backgroundColor = "#" + settings.colors[i];
130        Element.addClassName(a, 'disabledHideColorTable');
131        a.onmousedown = function() {
132            pne_mce_insert_tagname(id, tagname, ' code="' + this.colorCode + '"');
133            pne_mce_hide_color_table();
134        };
135
136        var span = document.createElement("span");
137        span.style.display = "none";
138        span.appendChild(document.createTextNode(code));
139
140        a.appendChild(span);
141        td.appendChild(a);
142        tr.appendChild(td);
143    }
144
145    var table = document.createElement("table");
146    table.id = "mce_editor_color_table";
147    table.style.width = "auto";
148    table.style.position = "absolute";
149    table.style.zIndex = 150;
150    table.style.border = "1px solid gray";
151    table.style.backgroundColor = "#fff";
152    table.appendChild(tbody);
153    Element.addClassName(table, 'disabledHideColorTable');
154
155    button_container.appendChild(table);
156
157    if (Prototype.Browser.IE) {
158        table.style.left = button.parentNode.offsetWidth + button.offsetWidth + "px";
159        table.style.top = table.offsetTop + button.offsetHeight;
160    } else {
161        table.style.left = button.offsetLeft + table.offsetLeft + "px";
162    }
163}
164
165function pne_mce_hide_color_table(e)
166{
167    if (e && Element.hasClassName(e.element(), 'disabledHideColorTable')) {
168        return;
169    }
170
171    var table = document.getElementById("mce_editor_color_table")
172    table.style.display = 'none';
173    Event.stopObserving(document, 'mousedown', pne_mce_hide_color_table);
174}
175
Note: See TracBrowser for help on using the repository browser.