src/cm/media/js/client/c_selection.js
changeset 556 69503659fe8f
parent 532 0bad3613f59d
child 558 5ba711a2bd06
equal deleted inserted replaced
554:8e116b8ddbc3 556:69503659fe8f
    24 // 'end': ....}
    24 // 'end': ....}
    25 // the text attribute is informational having it empty doesn't mean selection is empty !!
    25 // the text attribute is informational having it empty doesn't mean selection is empty !!
    26 
    26 
    27 // when selection starts/ends in/on a non textual element (<hr/> for example) we very often have anchorNode/focusNode == body elt
    27 // when selection starts/ends in/on a non textual element (<hr/> for example) we very often have anchorNode/focusNode == body elt
    28 // TODO adapt this body case by considering offset ( cf. http://www.w3.org/TR/DOM-Level-2-Traversal-Range/ranges.html)
    28 // TODO adapt this body case by considering offset ( cf. http://www.w3.org/TR/DOM-Level-2-Traversal-Range/ranges.html)
       
    29 
    29 getSelectionInfo  = function () {
    30 getSelectionInfo  = function () {
    30   var startNode = null, endNode = null, startOffset = 0, endOffset = 0, text = '' ;
    31   var startNode = null, endNode = null, startOffset = 0, endOffset = 0, text = '' ;
    31   
    32   
    32   if (window.getSelection) { // everything else than IE
    33   if (window.getSelection) { // everything else than IE
    33     var userSelection = window.getSelection();
    34     var userSelection = safari_mobile ? storedSelection : window.getSelection ();
    34 
    35 
    35     if (userSelection.rangeCount > 0) {
    36     if (userSelection.rangeCount > 0) {
    36       var range = userSelection.getRangeAt(0) ;
    37       var range = userSelection.getRangeAt(0) ;
    37       text = range.toString() ;
    38       text = range.toString() ;
    38       if (text != "")  {
    39       if (text != "")  {
   164         r2.detach() ;
   165         r2.detach() ;
   165       }
   166       }
   166       else 
   167       else 
   167         return null ;
   168         return null ;
   168     }
   169     }
   169     else 
   170     else
   170       return null ;
   171       return null ;
   171     
   172     
   172   }
   173   }
   173   else if (document.selection) { // IE case
   174   else if (document.selection) { // IE case
   174     var rng = document.selection.createRange();
   175     var rng = document.selection.createRange();