[ Index ]
 

Code source de eGroupWare 1.2.106-2

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

title

Body

[fermer]

/phpgwapi/js/jsapi/ -> egwCategories-plugin.js (source)

   1    /***************************************************************************\
   2    * eGroupWare - Javascript API                                               *
   3    * http://www.egroupware.org                                                 *
   4    * Written by:                                                               *
   5    *  - Raphael Derosso Pereira <raphaelpereira@users.sourceforge.net>         *
   6    *  - Vinicius Cubas Brand <viniciuscb@users.sourceforge.net>                *
   7    *  sponsored by Think.e - http://www.think-e.com.br                         *
   8    * ------------------------------------------------------------------------- *
   9    *  This program is free software; you can redistribute it and/or modify it  *
  10    *  under the terms of the GNU General Public License as published by the    *
  11    *  Free Software Foundation; either version 2 of the License, or (at your   *
  12    *  option) any later version.                                               *
  13    \***************************************************************************/
  14  
  15      /*
  16       * eGroupWare Global API - Categories Handling Floating Window
  17       *
  18       */
  19  
  20  	function egwCategoriesPlugin()
  21      {
  22          this.window = null;
  23          this.selectedCategories = new Array();
  24          this.categories = new Array();
  25          this.postURL = GLOBALS['serverRoot']+'/xmlrpc.php';
  26      
  27          //user-defined method to execute when window closes
  28          this.onCloseHandler = null;
  29  
  30          //user-defined method to execute when window changes
  31          this.onChangeHandler = null;
  32  
  33          this.DOM = new Object();
  34  
  35          // Initialization
  36          this.DOM.egw_categories = Element("egw_categories");
  37          this.DOM.egw_categories_change = Element("egw_categories_change");
  38          this.DOM.egw_categories_w_form = Element("egw_categories_w_form");
  39          this.DOM.egw_categories_wcontent = Element("egw_categories_wcontent");
  40          this.DOM.egw_categories_title = Element("egw_categories_title");
  41          
  42          this.window = new dJSWin(
  43          {            'id': 'egwCategories',
  44                      'content_id': 'egw_categories_wcontent',
  45                      'win_class': 'row_off',
  46                      'width': '200px',
  47                      'height': '120px',
  48                      'title_color': '#3978d6',
  49                      'title': this.DOM.egw_categories_title.value,
  50                      'title_text_color': 'white',
  51                      'button_x_img': GLOBALS['egw_img_dir']+'/winclose.gif',
  52                      'border': true});
  53      }
  54  
  55      //receives an object with keys=keys of select, vals=vals to show
  56      egwCategoriesPlugin.prototype.populate = function(population)
  57      {
  58          this.categories = population;
  59          clearSelectBox(this.DOM.egw_categories,0);
  60          fillSelectBox(this.DOM.egw_categories,this.categories);
  61          this.selectedCategories = new Array();
  62      }
  63  
  64      //receives array or object with values=categories ids, fetch categories
  65      //from egw via rpc call
  66      egwCategoriesPlugin.prototype.setCategories = function(categories)
  67      {
  68  
  69      }
  70      
  71      egwCategoriesPlugin.prototype.selectCategories = function(selected)
  72      {
  73          this.selectedCategories = selected;
  74          selectOptions(this.DOM.egw_categories,this.selectedCategories);
  75          
  76      }
  77  
  78      //gets all selected categories values
  79      egwCategoriesPlugin.prototype.getSelectedIDs = function()
  80      {
  81          return this.selectedCategories;
  82      }
  83  
  84      //gets all selected categories values
  85      egwCategoriesPlugin.prototype.getSelectedNames = function()
  86      {
  87          var ret = new Array();
  88          for (var i in this.selectedCategories)
  89          {
  90              ret.push(this.categories[this.selectedCategories[i]]);
  91          }
  92  
  93          return ret;
  94      }
  95      
  96      //gets all selected categories values
  97      egwCategoriesPlugin.prototype.getSelectedCategories = function()
  98      {
  99          var ret = new Object();
 100          for (var i in this.selectedCategories)
 101          {
 102              ret[this.selectedCategories[i]] = (this.categories[this.selectedCategories[i]]);
 103          }
 104  
 105          return ret;
 106      }    
 107  
 108      egwCategoriesPlugin.prototype.close = function ()
 109      {
 110          this.window.close();
 111      }
 112  
 113      egwCategoriesPlugin.prototype.open = function ()
 114      {
 115          this.window.open();
 116      }
 117      
 118      egwCategoriesPlugin.prototype.setOnChangeHandler = function(func)
 119      {
 120          this.onChangeHandler = func;    
 121      }
 122  
 123      /*********************************************************************\
 124       *                          Private Methods                          *
 125      \*********************************************************************/
 126  
 127  
 128      //method to execute when window closes without saving
 129      egwCategoriesPlugin.prototype._onClose = function()
 130      {
 131          if (typeof(this.onCloseHandler) == 'function')
 132          {
 133              this.onCloseHandler();
 134          }
 135      }
 136  
 137      //method to execute when window changes its value
 138      egwCategoriesPlugin.prototype._changeCategories = function(handler)
 139      {
 140          this.selectedCategories = getSelectedOptions(this.DOM.egw_categories);
 141          if (typeof(this.onChangeHandler) == 'function')
 142          {
 143              this.onChangeHandler();
 144          }
 145          this.window.close();
 146      }
 147  
 148      egwCategoriesPlugin.prototype._clearAll = function ()
 149      {
 150          // Clear information container 
 151          this.selectedCategories = new Array();
 152  
 153          // Clear Fields 
 154          this.DOM.egw_categories_w_form.reset();
 155      }
 156          
 157      egwCategoriesPlugin.prototype._disableAll = function ()
 158      {
 159      }
 160  
 161      //just in the end of tpl
 162      //egwCategories = new egwCategoriesPlugin();
 163      
 164  


Généré le : Sun Feb 25 17:20:01 2007 par Balluche grâce à PHPXref 0.7