DokuWiki

It's better when it's simple

User Tools

Site Tools


tips:media_attached

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
tips:media_attached [2014-06-09 12:15] – [5. edit] 62.231.235.7tips:media_attached [2014-06-09 18:04] (current) – old revision restored (2013-03-21 13:15) 2001:4dd0:ff00:8eb9:fc80:1329:b7d9:1c50
Line 431: Line 431:
 </code> </code>
  
 +==== 5. edit ====
 +lib/scripts/script.js -- after function mediaSelect(file)
 +<code javascript>
  
 +function mediaSelect_attached(file){
 +  insertAtCarret_attached(window.parent.document.editform.wikitext,'{{'+file+'}}');
 +  window.close(); 
 +}
 +
 +function insertAtCarret_attached(field,value){
 +  //IE support
 +  if (document.selection) {
 +    field.focus();
 +
 +      sel = window.parent.document.selection.createRange();
 +
 +    sel.text = value;
 +  //MOZILLA/NETSCAPE support
 +  }else if (field.selectionStart || field.selectionStart == '0') {
 +    var startPos  = field.selectionStart;
 +    var endPos    = field.selectionEnd;
 +    var scrollTop = field.scrollTop;
 +    field.value = field.value.substring(0, startPos)
 +                  + value
 +                  + field.value.substring(endPos);
 +
 +    field.focus();
 +    var cPos=startPos+(value.length);
 +    field.selectionStart=cPos;
 +    field.selectionEnd=cPos;
 +    field.scrollTop=scrollTop;
 +  } else {
 +    field.value += "\n"+value;
 +  }
 +  // reposition cursor if possible
 +  if (field.createTextRange) field.caretPos = window.parent.document.selection.createRange().duplicate();
 +}
 +</code>
tips/media_attached.txt · Last modified: 2014-06-09 18:04 by 2001:4dd0:ff00:8eb9:fc80:1329:b7d9:1c50

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki