- LSinfosBox : Création de la classe gérant une boîte d'affichage de messsages
authorBenjamin Renard <brenard@easter-eggs.com>
Tue, 14 Apr 2009 18:00:10 +0000 (18:00 +0000)
committerBenjamin Renard <brenard@easter-eggs.com>
Tue, 14 Apr 2009 18:00:10 +0000 (18:00 +0000)
- LSdefault : Utilisation de la classe LSinfosBox pour LSdebug, LSerror et LSinfos

trunk/conf/config.inc.php
trunk/css/default/LSdefault.css
trunk/includes/js/LSdefault.js
trunk/templates/default/LSdefault.tpl

index e3be78d..d175554 100644 (file)
@@ -189,7 +189,8 @@ $GLOBALS['defaultJSscipts']=array(
   'mootools-core.js',
   'mootools-more.js',
   'functions.js',
-  'LSdefault.js'
+  'LSdefault.js',
+  'LSinfosBox.js'
 );
 
 ?>
index ac00282..22137dc 100644 (file)
@@ -1,71 +1,58 @@
-#LSerror {
-  width:                    50%;
+/* LSinfoBox */
+div.LSinfosBox {
   position:                 absolute;
-  top:                      10px;
-  left:                     10px;
-  background-color:         #f00;
+  width:                    50%;
+  left:                     25%;
+  background-color:         #b5e4f6;
+  border:                   1px solid #4096b8;
   visibility:               hidden;
-  color:                    #fff;
+  color:                    #4096b8;
   z-index:                  100;
+  top:                      10px;
+  font-weight:              bold;
 }
 
-#LSerror_txt {
-  display:                  none;
-}
-
-#LSlang_select {
-  display:                  none;
-  background-color:         #000;
-  -moz-border-radius:       8px;
-  position:                 absolute;
-  max-width:                200px;
-  padding:                  5px;
+span.LSinfosBox {
+  float:                    right;
+  cursor:                   pointer;
+  font-family:              sans-serif;
+  padding:                  2px;
 }
 
-#LSlang_select img {
-  vertical-align:           middle;
-}
 
-#LSdebug {
-  width:                    50%;
-  position:                 absolute;
+div.LSdebug {
   top:                      10px;
   left:                     50%;
   background-color:         #84ff6a;
-  visibility:               hidden;
+  border:                   1px solid #84ff6a;
   color:                    #fff;
-  z-index:                  100;
 }
 
-#LSdebug_txt {
-  display:                  none;
+div.LSerror {
+  top:                      10px;
+  left:                     10px;
+  background-color:         #f00;
+  border:                   1px solid #f00;
+  color:                    #fff;
 }
 
-#LSjsConfig {
+#LSdebug_txt, #LSerror_txt, #LSinfos_txt, #LSjsConfig  {
   display:                  none;
 }
 
-#LSdebug_hidden {
-  float:                    right;
-  color:                    #fff;
-  text-decoration:          none;
-  font-weight:              bold;
-  cursor:                   pointer;
-}
-
-#LSinfos {
+/* LSlang */
+#LSlang_select {
+  display:                  none;
+  background-color:         #000;
+  -moz-border-radius:       8px;
   position:                 absolute;
-  width:                    50%;
-  left:                     25%;
-  background-color:         #b5e4f6;
-  border:                   1px solid #4096b8;
-  visibility:               hidden;
-  color:                    #4096b8;
-  z-index:                  100;
-  top:                      10px;
-  font-weight:              bold;
+  max-width:                200px;
+  padding:                  5px;
 }
 
+#LSlang_select img {
+  vertical-align:           middle;
+}
 
 /* Tips */
 .tip-top {
@@ -86,3 +73,5 @@
   max-width:        500px;
   text-align:       justify;
 }
+
+
index cd86da8..667ccb0 100644 (file)
@@ -1,31 +1,26 @@
 var LSdefault = new Class({
     initialize: function(){
       // LSdebug
-      this.LSdebug = $('LSdebug');
-      this.LSdebug.addEvent('dblclick',this.hideLSdebug.bind(this));
-      this.LSdebugInfos = $('LSdebug_infos');
-      this.LSdebug.setOpacity(0);
-      this.LSdebug_open = 0;
-
-      this.LSdebugHidden = $('LSdebug_hidden');
-      this.LSdebugHidden.addEvent('click',this.hideLSdebug.bind(this));
+      this.LSdebug = new LSinfosBox({
+        name: 'LSdebug',
+        fxDuration: 600,
+        closeBtn: 1,
+        autoClose: 0
+      });
+      this.LSdebugInfos = $('LSdebug_txt');
       
       // LSerror
-      this.LSerror = $('LSerror');
-      this.LSerror.setOpacity(0);
-      this.LSerror_open = 0;
-      this.LSerror.addEvent('dblclick',this.hideLSerror.bind(this,0));
+      this.LSerror = new LSinfosBox({
+        name: 'LSerror',
+        opacity: 0.9,
+        autoClose: 10000
+      });
+      this.LSerror_div = $('LSerror_txt');
       
       // LSinfos
-      this.LSinfos = $('LSinfos');
+      this.LSinfos = new LSinfosBox({name: 'LSinfos'});
+      this.LSinfos_div = $('LSinfos_txt');
 
-      // FX
-      this.fx = {
-        LSdebug:  new Fx.Tween(this.LSdebug,{property: 'opacity',duration:600, fps:30}),
-        LSerror:  new Fx.Tween(this.LSerror,{property: 'opacity',duration:500, fps:30}),
-        LSinfos:  new Fx.Tween(this.LSinfos,{property: 'opacity',duration:500, fps:30})
-      };
-      
       // LSjsConfig
       this.LSjsConfigEl = $('LSjsConfig');
       if ($type(this.LSjsConfigEl)) {
@@ -46,15 +41,15 @@ var LSdefault = new Class({
       
       // Display Infos
       if (this.LSdebugInfos.innerHTML != '') {
-        this.displayDebugBox();
+        this.LSdebug.display(this.LSdebugInfos.innerHTML);
       }
       
-      if (this.LSerror.innerHTML != '') {
-        this.displayErrorBox();
+      if (this.LSerror_div.innerHTML != '') {
+        this.LSerror.display(this.LSerror_div.innerHTML);
       }
       
-      if (this.LSinfos.innerHTML != '') {
-        this.displayInfosBox();
+      if (this.LSinfos_div.innerHTML != '') {
+        this.LSinfos.display(this.LSinfos_div.innerHTML);
       }
       
       // :)
@@ -121,21 +116,8 @@ var LSdefault = new Class({
     },
 
     moo: function() {
-      var mooTxt = "         (__)     .ooooooooooooooooooo.\n         (oo) °°°°0 I love LdapSaisie 0\n   /------\\\/      °ooooooooooooooooooo°\n  / |    ||\n *  /\---/\\\n    ~~   ~~";
-      var ulMoo = this.LSinfos.getElement('ul'); 
-      var preMoo = new Element('pre');
-      preMoo.set('html',mooTxt);
-      if ($type(ulMoo)) {
-        ulMoo.empty();
-        var liMoo = new Element('li');
-        liMoo.injectInside(ulMoo);
-        preMoo.injectInside(liMoo);
-      }
-      else {
-        this.LSinfos.empty();
-        preMoo.injectInside(this.LSinfos);
-      }
-      this.displayInfosBox();
+      var mooTxt = "<pre>         (__)     .ooooooooooooooooooo.\n         (oo) °°°°0 I love LdapSaisie 0\n   /------\\\/      °ooooooooooooooooooo°\n  / |    ||\n *  /\---/\\\n    ~~   ~~</pre>";
+      this.LSinfos.addInfo(mooTxt);
     },
 
     onLSsession_topDnChange: function() {
@@ -143,7 +125,7 @@ var LSdefault = new Class({
     },
 
     checkAjaxReturn: function(data) {
-      this.hideLSerror(0);
+      this.LSerror.close(0);
       if ($type(data) == 'object') {
         if (($type(data.LSredirect)) && (!$type(data.LSdebug)) ) {
           document.location = data.LSredirect;
@@ -159,15 +141,15 @@ var LSdefault = new Class({
         
         if ($type(data.LSdebug)) {
           LSdebug(data.LSdebug);
-          this.displayDebug(data.LSdebug);
+          this.LSdebug.display(data.LSdebug);
         }
         
         if ($type(data.LSinfos)) {
-          this.displayInfos(data.LSinfos);
+          this.LSinfos.display(data.LSinfos);
         }
         
         if ($type(data.LSerror)) {
-          this.displayError(data.LSerror);
+          this.LSerror.display(data.LSerror);
           return;
         }
         return true;
@@ -179,73 +161,6 @@ var LSdefault = new Class({
       }
     },
 
-    /*
-     * Set and Display Methods
-     */
-    displayError: function(html) {
-      this.LSerror.set('html',html);
-      this.displayErrorBox();
-    },
-
-    displayDebug: function(html) {
-      this.LSdebugInfos.set('html',html);
-      this.displayDebugBox();
-    },
-    
-    displayInfos: function(html) {
-      this.LSinfos.set('html',html);
-      this.displayInfosBox();
-    },
-    
-    /*
-     * Display Methods
-     */
-    displayErrorBox: function() {
-      this.LSerror.setStyle('top',getScrollTop()+10);
-      if (this.LSerror_open) {
-        return true;
-      }
-      this.fx.LSerror.start(0,0.8);
-      this.LSerror_open = 1;
-    },
-    
-    displayDebugBox: function() {
-      this.LSdebug.setStyle('top',getScrollTop()+10);
-      if (this.LSdebug_open) {
-        return true;
-      }
-      this.fx.LSdebug.start(0,0.8);
-      this.LSdebug_open = 1;
-    },
-    
-    /*
-     * Hide Methods
-     */
-    hideLSdebug: function(){
-      if (this.LSdebug_open) {
-        this.fx.LSdebug.start(0.8,0);
-        this.LSdebug_open = 0;
-      }
-    },
-    
-    hideLSerror: function(withoutEffect){
-      if (this.LSerror_open) {
-        this.LSerror_open = 0;
-        if (withoutEffect==0) {
-          this.fx.LSerror.start(0.9,0);
-        }
-        else {
-          this.fx.LSerror.set(0);
-        }
-      }
-    },
-
-    displayInfosBox: function() {
-      this.LSinfos.setStyle('top',getScrollTop()+10);
-      this.fx.LSinfos.start(0,0.9);
-      (function(){this.fx.LSinfos.start(0.9,0);}).delay(5000, this);
-    },
-
     loadingImgDisplay: function(el,position,size) {
       this.loading_img_id++;
       this.loading_img[this.loading_img_id] = new Element('img');
@@ -268,7 +183,7 @@ var LSdefault = new Class({
     loadingImgHide: function(id) {
       if (isNaN(id)) {
         this.loading_img.each(function(el)  {
-          if (typeof(el) != 'undefined')
+          if ($type(el))
             el.destroy();
         },this);
         this.loading_img_id=-1;
@@ -283,7 +198,7 @@ var LSdefault = new Class({
       if (LSdebug_txt) {
         var debug = LSdebug_txt.innerHTML;
         if (debug) {
-          this.displayDebug(debug.toString());
+          this.LSdebug.display(debug.toString());
         }
       }
       
@@ -291,7 +206,7 @@ var LSdefault = new Class({
       if (LSerror_txt) {
         var error=LSerror_txt.innerHTML;
         if (error) {
-          this.displayError(error.toString());
+          this.LSerror.display(error.toString());
         }
       }
     },
index 2a0caab..4c9e4b5 100644 (file)
@@ -2,14 +2,11 @@
 {$LSjsConfig}
 </div>
 
-<div id='LSinfos'>{$LSinfos}</div>
+<div id='LSinfos_txt'>{$LSinfos}</div>
 
-<div id='LSerror'>{$LSerrors}</div>
+<div id='LSerror_txt'>{$LSerrors}</div>
 
-<div id='LSdebug'>
-  <span id='LSdebug_hidden'>X</span> 
-  <div id='LSdebug_infos'>{if $LSdebug != ''}{$LSdebug}{/if}</div>
-</div>
+<div id='LSdebug_txt'>{if $LSdebug != ''}{$LSdebug}{/if}</div>
 
 <div id='LSlang_select'>
 {foreach from=$LSlanguages item=lang}