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 revision Previous revision
tips:media_attached [2014-06-09 12:15]
62.231.235.7 [5. edit]
tips:media_attached [2014-06-09 18:04] (current)
2001:4dd0:ff00:8eb9:fc80:1329:b7d9:1c50 old revision restored (2013-03-21 13:15)
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