[ Index ]
 

Code source de eZ Publish 3.9.0

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

title

Body

[fermer]

/design/standard/javascript/lib/ -> ezjslibimagepreloader.js (source)

   1  //
   2  // Created on: <12-Oct-2004 14:18:58 dl>
   3  //
   4  // SOFTWARE NAME: eZ publish
   5  // SOFTWARE RELEASE: 3.9.0
   6  // BUILD VERSION: 17785
   7  // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS
   8  // SOFTWARE LICENSE: GNU General Public License v2.0
   9  // NOTICE: >
  10  //   This program is free software; you can redistribute it and/or
  11  //   modify it under the terms of version 2.0  of the GNU General
  12  //   Public License as published by the Free Software Foundation.
  13  //
  14  //   This program is distributed in the hope that it will be useful,
  15  //   but WITHOUT ANY WARRANTY; without even the implied warranty of
  16  //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17  //   GNU General Public License for more details.
  18  //
  19  //   You should have received a copy of version 2.0 of the GNU General
  20  //   Public License along with this program; if not, write to the Free
  21  //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  22  //   MA 02110-1301, USA.
  23  //
  24  //
  25  
  26  /*! \file ezjslibimagepreloader.js
  27  */
  28  
  29  /*!
  30      \brief
  31  */
  32  
  33  function eZImagePreloader()
  34  {
  35      this.setupEventHandlers( eZImagePreloader.prototype.onImageLoad,
  36                               eZImagePreloader.prototype.onImageError,
  37                               eZImagePreloader.prototype.onImageAbort );
  38  }
  39  
  40  eZImagePreloader.prototype.preloadImageList = function( imageList )
  41  {
  42      this.nImagesCount           = imageList.length;
  43      this.nProcessedImagesCount  = 0;
  44      this.nLoadedImagesCount     = 0;
  45      this.bPreloadDone           = false;
  46  
  47      for( var i = 0; i < imageList.length; i++ )
  48          this.preload( imageList[i] );
  49  }
  50  
  51  eZImagePreloader.prototype.preload = function( imageFilePath )
  52  {
  53      var image = new Image;
  54  
  55      image.onload  = this.onImageLoadEvent;
  56      image.onerror = this.onImageErrorEvent;
  57      image.onabort = this.onImageAbortEvent;
  58  
  59      image.preloader = this;
  60  
  61      image.bLoaded = false;
  62      image.bError  = false;
  63      image.bAbort  = false;
  64  
  65      image.src = imageFilePath;
  66  
  67  }
  68  
  69  eZImagePreloader.prototype.setupEventHandlers = function( onLoad, onError, onAbort )
  70  {
  71      this.onImageLoadEvent = onLoad;
  72      this.onImageErrorEvent = onError;
  73      this.onImageAbortEvent = onAbort;
  74  }
  75  
  76  eZImagePreloader.prototype.onImageLoad = function()
  77  {
  78      this.bLoaded = true;
  79      this.preloader.nLoadedImagesCount++;
  80      this.preloader.onComplete();
  81  }
  82  
  83  eZImagePreloader.prototype.onImageError = function()
  84  {
  85      this.bError = true;
  86      this.preloader.onComplete();
  87  }
  88  
  89  eZImagePreloader.prototype.onImageAbort = function()
  90  {
  91      this.bAbort = true;
  92      this.preloader.onComplete();
  93  }
  94  
  95  eZImagePreloader.prototype.onComplete = function( imageList )
  96  {
  97      this.nProcessedImagesCount++;
  98      if( this.nProcessedImagesCount == this.nImagesCount )
  99      {
 100          this.bPreloadDone = true;
 101      }
 102  }
 103  
 104  function ezjslib_preloadImageList( filepathList )
 105  {
 106      var preloader = new eZImagePreloader();
 107      preloader.preloadImageList( filepathList );
 108  }
 109  
 110  


Généré le : Sat Feb 24 10:30:04 2007 par Balluche grâce à PHPXref 0.7