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

Changeset 7024


Ignore:
Timestamp:
May 7, 2008, 10:46:56 PM (12 years ago)
Author:
ebihara
Message:

#2370:pne.jsで定義している文字装飾関連処理をpne_decoration.jsに分離し、必要な場面でのみ読み込むよう修正

Location:
OpenPNE/branches/stable-2.12.x
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE/branches/stable-2.12.x/public_html/js/pne.js

    r7014 r7024  
    77    document.write('<a href="'+url+'" target="_blank">'+urlstr+'</a>');
    88}
    9 
    10 function pne_toggle_mce_editor(id)
    11 {
    12     var textmode_checked = document.getElementById("mce_editor_mode_changer_1").checked;
    13     var previewmode_checked = document.getElementById("mce_editor_mode_changer_2").checked;
    14 
    15     var editor = tinyMCE.get(id);
    16     if (!editor && previewmode_checked) {
    17         tinyMCE.execCommand('mceAddControl', 0, id);
    18         document.getElementById('mce_editor_buttonmenu').style.display = "none";
    19         return true;
    20     }
    21 
    22     if (editor.isHidden() && previewmode_checked) {
    23         editor.show();
    24         document.getElementById('mce_editor_buttonmenu').style.display = "none";
    25     } else if (!editor.isHidden() && textmode_checked) {
    26         editor.hide();
    27         document.getElementById('mce_editor_buttonmenu').style.display = "block";
    28     }
    29 }
    30 
    31 function pne_mce_editor_init()
    32 {
    33     tinyMCE.init({
    34         mode : "textareas",
    35         theme : "advanced",
    36         editor_selector : "mceEditor_dummy_selector",
    37         plugins : "openpne",
    38         theme_advanced_toolbar_location : "top",
    39         theme_advanced_toolbar_align : "left",
    40         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",
    41         theme_advanced_buttons2 : "",
    42         theme_advanced_buttons3 : "",
    43         valid_elements : "b/strong,u,s/strike,i,font[color|size],br",
    44         forced_root_block : false,
    45         force_p_newlines : false,
    46         force_br_newlines : true,
    47         inline_styles : false,
    48         language : "ja",
    49         entity_encoding : "raw"
    50     });
    51 
    52     var textmode_checkbox = document.getElementById("mce_editor_mode_changer_1");
    53     var previewmode_checkbox = document.getElementById("mce_editor_mode_changer_2");
    54     if (previewmode_checkbox.checked) {
    55         textmode_checkbox.checked = true;
    56         previewmode_checkbox.checked = false;
    57     }
    58 }
    59 
    60 function pne_mce_insert_tagname(id, tagname, opt)
    61 {
    62     var opt = opt || "";
    63 
    64     var elm = document.getElementById(id);
    65     var selection = new Selection(elm);
    66 
    67     var pos = selection.create();
    68 
    69     if (tagname == "op:color" && !opt) {
    70         pne_mce_show_color_table(id, tagname);
    71         return;
    72     }
    73 
    74     var replace = "<" + tagname + opt + ">" + elm.value.substring(pos.start, pos.end) + "</" + tagname + ">";
    75     var head = elm.value.substring(0, pos.start);
    76     var tail = elm.value.substring(pos.end, elm.value.length);
    77     elm.value =  head + replace + tail;
    78 }
    79 
    80 function pne_mce_show_color_table(id, tagname)
    81 {
    82     var table = document.getElementById("mce_editor_color_table")
    83     if (table) {
    84         table.parentNode.removeChild(table);
    85         return;
    86     }
    87 
    88     var color = null;
    89     var settings = {
    90         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"],
    91         grid_width : 8,
    92         default_color : "#888888"
    93     };
    94 
    95     var button = document.getElementById("mce_textmode_button_op_color");
    96 
    97     var button_container = document.getElementById("mce_editor_buttonmenu");
    98 
    99     var tbody = document.createElement("tbody");
    100 
    101     var tr;
    102  
    103     for (var i = 0; i < settings.colors.length; i++) {
    104         var code = "#" + settings.colors[i];
    105 
    106         if (i == 0 || i % settings.grid_width == 0) {
    107             tr = document.createElement("tr");
    108             tbody.appendChild(tr);
    109         }
    110 
    111         var td = document.createElement("td");
    112         td.style.border = "0 none";
    113         td.style.width = "12px";
    114         td.style.padding = "2px";
    115         td.style.margin = "0";
    116 
    117         var a = document.createElement("a");
    118         a.setAttribute("href", "#");
    119         a.colorCode = code;
    120         a.style.width = "9px";
    121         a.style.height = "9px";
    122         a.style.display = "block";
    123         a.style.overflow = "hidden";
    124         a.style.border = "1px solid #808080";
    125         a.style.backgroundColor = "#" + settings.colors[i];
    126         a.onclick = function() {
    127             pne_mce_insert_tagname(id, tagname, ' code="' + this.colorCode + '"');
    128             var table = document.getElementById("mce_editor_color_table")
    129             table.parentNode.removeChild(table);
    130         };
    131 
    132         var span = document.createElement("span");
    133         span.style.display = "none";
    134         span.appendChild(document.createTextNode(code));
    135 
    136         a.appendChild(span);
    137         td.appendChild(a);
    138         tr.appendChild(td);
    139     }
    140 
    141     var table = document.createElement("table");
    142     table.id = "mce_editor_color_table";
    143     table.style.width = "auto";
    144     table.style.position = "absolute";
    145     table.style.zIndex = 150;
    146     table.style.border = "1px solid gray";
    147     table.style.backgroundColor = "#fff";
    148     table.appendChild(tbody);
    149 
    150     button_container.appendChild(table);
    151 
    152     if (Prototype.Browser.IE) {
    153         table.style.left = button.parentNode.offsetWidth + button.offsetWidth + "px";
    154         table.style.top = table.offsetTop + button.offsetHeight;
    155     } else {
    156         table.style.left = button.offsetLeft + table.offsetLeft + "px";
    157     }
    158 }
    159 
  • OpenPNE/branches/stable-2.12.x/webapp/modules/pc/templates/h_diary_add.tpl

    r6808 r7024  
    9191
    9292({if $smarty.const.OPENPNE_USE_DECORATION})
     93<script type="text/javascript" src="./js/pne_decoration.js"></script>
    9394<script type="text/javascript" src="./js/pc_emoji_palet/pc_emoji_palet.js"></script>
    9495<input type="radio" name="mce_editor_mode_changer" id="mce_editor_mode_changer_1" onclick="pne_toggle_mce_editor('mce_editor_textarea')" checked="checked" /><label for="mce_editor_mode_changer_1">テキストモード</label>&nbsp;<input type="radio" name="mce_editor_mode_changer" id="mce_editor_mode_changer_2" onclick="pne_toggle_mce_editor('mce_editor_textarea')" /><label for="mce_editor_mode_changer_2">プレビューモード</label>
  • OpenPNE/branches/stable-2.12.x/webapp/modules/pc/templates/h_diary_edit.tpl

    r6808 r7024  
    9393
    9494({if $smarty.const.OPENPNE_USE_DECORATION})
     95<script type="text/javascript" src="./js/pne_decoration.js"></script>
    9596<script type="text/javascript" src="./js/pc_emoji_palet/pc_emoji_palet.js"></script>
    9697<input type="radio" name="mce_editor_mode_changer" id="mce_editor_mode_changer_1" onclick="pne_toggle_mce_editor('mce_editor_textarea')" checked="checked" /><label for="mce_editor_mode_changer_1">テキストモード</label>&nbsp;<input type="radio" name="mce_editor_mode_changer" id="mce_editor_mode_changer_2" onclick="pne_toggle_mce_editor('mce_editor_textarea')" /><label for="mce_editor_mode_changer_2">プレビューモード</label>
Note: See TracChangeset for help on using the changeset viewer.