[ Index ]
 

Code source de CMS made simple 1.0.5

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/filemanager/ImageManager/assets/ -> dialog.js (source)

   1  // Dialog v3.0 - Copyright (c) 2003-2004 interactivetools.com, inc.
   2  // This copyright notice MUST stay intact for use (see license.txt).
   3  //
   4  // Portions (c) dynarch.com, 2003-2004
   5  //
   6  // A free WYSIWYG editor replacement for <textarea> fields.
   7  // For full source code and docs, visit http://www.interactivetools.com/
   8  //
   9  // Version 3.0 developed by Mihai Bazon.
  10  //   http://dynarch.com/mishoo
  11  //
  12  // $Id: dialog.js 26 2004-03-31 02:35:21Z Wei Zhuo $
  13  
  14  // Though "Dialog" looks like an object, it isn't really an object.  Instead
  15  // it's just namespace for protecting global symbols.
  16  
  17  function Dialog(url, action, init) {
  18      if (typeof init == "undefined") {
  19          init = window;    // pass this window object by default
  20      }
  21      Dialog._geckoOpenModal(url, action, init);
  22  };
  23  
  24  Dialog._parentEvent = function(ev) {
  25      setTimeout( function() { if (Dialog._modal && !Dialog._modal.closed) { Dialog._modal.focus() } }, 50);
  26      if (Dialog._modal && !Dialog._modal.closed) {
  27          Dialog._stopEvent(ev);
  28      }
  29  };
  30  
  31  
  32  // should be a function, the return handler of the currently opened dialog.
  33  Dialog._return = null;
  34  
  35  // constant, the currently opened dialog
  36  Dialog._modal = null;
  37  
  38  // the dialog will read it's args from this variable
  39  Dialog._arguments = null;
  40  
  41  Dialog._geckoOpenModal = function(url, action, init) {
  42      //var urlLink = "hadialog"+url.toString();
  43      var myURL = "hadialog"+url;
  44      var regObj = /\W/g;
  45      myURL = myURL.replace(regObj,'_');
  46      var dlg = window.open(url, myURL,
  47                    "toolbar=no,menubar=no,personalbar=no,width=10,height=10," +
  48                    "scrollbars=no,resizable=yes,modal=yes,dependable=yes");
  49      Dialog._modal = dlg;
  50      Dialog._arguments = init;
  51  
  52      // capture some window's events
  53  	function capwin(w) {
  54          Dialog._addEvent(w, "click", Dialog._parentEvent);
  55          Dialog._addEvent(w, "mousedown", Dialog._parentEvent);
  56          Dialog._addEvent(w, "focus", Dialog._parentEvent);
  57      };
  58      // release the captured events
  59  	function relwin(w) {
  60          Dialog._removeEvent(w, "click", Dialog._parentEvent);
  61          Dialog._removeEvent(w, "mousedown", Dialog._parentEvent);
  62          Dialog._removeEvent(w, "focus", Dialog._parentEvent);
  63      };
  64      capwin(window.document);
  65      // capture other frames
  66      for (var i = 0; i < window.frames.length; capwin(window.frames[i++].document));
  67      // make up a function to be called when the Dialog ends.
  68      Dialog._return = function (val) {
  69          if (val && action) {
  70              action(val);
  71          }
  72          relwin(window.document);
  73          // capture other frames
  74          for (var i = 0; i < window.frames.length; relwin(window.frames[i++].document));
  75          Dialog._modal = null;
  76      };
  77  };
  78  
  79  
  80  // event handling
  81  
  82  Dialog._addEvent = function(el, evname, func) {
  83      if (Dialog.is_ie) {
  84          el.attachEvent("on" + evname, func);
  85      } else {        
  86          el.addEventListener(evname, func, true);
  87      }
  88  };
  89  
  90  
  91  Dialog._removeEvent = function(el, evname, func) {
  92      if (Dialog.is_ie) {
  93          el.detachEvent("on" + evname, func);
  94      } else {
  95          el.removeEventListener(evname, func, true);
  96      }
  97  };
  98  
  99  
 100  Dialog._stopEvent = function(ev) {
 101      if (Dialog.is_ie) {
 102          ev.cancelBubble = true;
 103          ev.returnValue = false;
 104      } else {
 105          ev.preventDefault();
 106          ev.stopPropagation();
 107      }
 108  };
 109  
 110  Dialog.agt = navigator.userAgent.toLowerCase();
 111  Dialog.is_ie       = ((Dialog.agt.indexOf("msie") != -1) && (Dialog.agt.indexOf("opera") == -1));


Généré le : Tue Apr 3 18:50:37 2007 par Balluche grâce à PHPXref 0.7