Brak opisu

AddFileBrowser.js 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. var FileBrowser = {
  2. // this is set automatically
  3. admin_media_prefix: '',
  4. // change this
  5. thumb_prefix: 'thumb_',
  6. no_thumb: 'filebrowser/img/no_thumb.gif',
  7. init: function() {
  8. // Deduce admin_media_prefix by looking at the <script>s in the
  9. // current document and finding the URL of *this* module.
  10. var scripts = document.getElementsByTagName('script');
  11. for (var i=0; i<scripts.length; i++) {
  12. if (scripts[i].src.match(/AddFileBrowser/)) {
  13. var idx = scripts[i].src.indexOf('filebrowser/js/AddFileBrowser');
  14. FileBrowser.admin_media_prefix = scripts[i].src.substring(0, idx);
  15. break;
  16. }
  17. }
  18. },
  19. // show FileBrowser
  20. show: function(id, href, close_func) {
  21. // var id2=String(id).split(".").join("___");
  22. var id2=String(id).replace(/\-/g,"____").split(".").join("___");
  23. FBWindow = window.open(href, String(id2), 'height=600,width=1000,resizable=yes,scrollbars=yes');
  24. FBWindow.focus();
  25. if (close_func) {
  26. FBWindow.onbeforeunload = close_func;
  27. }
  28. }
  29. }
  30. function addEvent( obj, type, fn ) {
  31. if ( obj.attachEvent ) {
  32. obj['e'+type+fn] = fn;
  33. obj[type+fn] = function(){obj['e'+type+fn]( window.event );}
  34. obj.attachEvent( 'on'+type, obj[type+fn] );
  35. } else
  36. obj.addEventListener( type, fn, false );
  37. }
  38. addEvent(window, 'load', FileBrowser.init);