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

Changeset 6307


Ignore:
Timestamp:
Apr 4, 2008, 5:33:07 PM (12 years ago)
Author:
ebihara
Message:

#333:テキストモードのタグ挿入のクロスブラウザ対応(Cross Browser selectionStart/selectionEnd の導入)(thanks KOSEKI Kengo)

Location:
OpenPNE/branches/work/ebihara/prj_deco_diary
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE/branches/work/ebihara/prj_deco_diary/public_html/js/pne.js

    r6167 r6307  
    4949{
    5050    var elm = document.getElementById(id);
     51    var selection = new Selection(elm);
    5152
    52     if (elm.selectionStart != undefined) {  // for Mozilla
    53         var start = elm.selectionStart;
    54         var end = elm.selectionEnd;
     53    var pos = selection.create();
    5554
    56         var replace = "<" + tagname + ">" + elm.value.substring(start, end) + "</" + tagname + ">";
    57         var head = elm.value.substring(0, start);
    58         var tail = elm.value.substring(end, elm.value.length);
    59         elm.value =  head + replace + tail;
    60     } else {  // for Others
    61         elm.value = elm.value + "<" + tagname + "></" + tagname + ">";
    62     }
     55    var replace = "<" + tagname + ">" + elm.value.substring(pos.start, pos.end) + "</" + tagname + ">";
     56    var head = elm.value.substring(0, pos.start);
     57    var tail = elm.value.substring(pos.end, elm.value.length);
     58    elm.value =  head + replace + tail;
    6359}
    6460
  • OpenPNE/branches/work/ebihara/prj_deco_diary/webapp/modules/pc/templates/inc_header.tpl

    r5809 r6307  
    1111<link rel="stylesheet" href="./css/default.css" type="text/css">
    1212<script type="text/javascript" src="./js/prototype.js"></script>
     13<script type="text/javascript" src="./js/Selection.js"></script>
    1314<script type="text/javascript" src="./js/pne.js"></script>
    1415<script type="text/javascript" src="./js/tiny_mce/tiny_mce.js"></script>
Note: See TracChangeset for help on using the changeset viewer.