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

Changeset 6751


Ignore:
Timestamp:
Apr 26, 2008, 7:25:56 PM (11 years ago)
Author:
ebihara
Message:

#2306:ポップアップ版でもSelection.jsを使うよう修正

Location:
OpenPNE/trunk/public_html/js/pc_emoji_palet
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE/trunk/public_html/js/pc_emoji_palet/pc_emoji_palet.html

    r5037 r6751  
    88<script src="./pc_emoji_palet.js"></script>
    99<script src="./pc_emoji_palet_popup.js"></script>
     10<script src="../Selection.js"></script>
    1011</body>
    1112</html>
  • OpenPNE/trunk/public_html/js/pc_emoji_palet/pc_emoji_palet_popup.js

    r6750 r6751  
    4949// 絵文字コードを親画面のテキストエリアに入力
    5050function putEmojiToParent(emoji) {
    51     opener.document.getElementsByName("body")[0].focus();
     51    var elm = opener.document.getElementsByName("body")[0];
     52    elm.focus();
    5253
    53     // selectionStart対応の場合、選択位置に絵文字挿入
    54     if (opener.document.getElementsByName("body")[0].selectionStart) {
    55         var position = opener.document.getElementsByName("body")[0].selectionStart;
    56         var emojiPosition = opener.position + emoji.length;
    57         var body = opener.document.getElementsByName("body")[0].value.substring(0, position) + emoji + opener.document.getElementsByName("body")[0].value.substring(position, opener.document.getElementsByName("body")[0].value.length);
    58         opener.document.getElementsByName("body")[0].value = body;   
    59         opener.document.getElementsByName("body")[0].setSelectionRange(emojiPosition, emojiPosition);
    60     } else {
    61         // IEの場合(selection対応)
    62         if (opener.document.selection) {
    63             var sel = opener.document.selection.createRange();
    64             sel.text = emoji;
    65             sel.move('character', emoji.length+4);
    66         // その他の場合は入力済み文章の末尾に絵文字を追加
    67         } else {
    68             var body = opener.document.getElementsByName("body")[0].value + emoji;
    69             opener.document.getElementsByName("body")[0].value = body;
    70         }
    71     }
     54    var selection = new Selection(elm);
     55    var pos = selection.create();
     56
     57    var head = elm.value.substring(0, pos.start);
     58    var tail = elm.value.substring(pos.end, elm.value.length);
     59    elm.value =  head + emoji + tail;
    7260}
Note: See TracChangeset for help on using the changeset viewer.