/**
 * MindCMS 3
 *
 * msPlugin
 *
 * JS Plugin object definition
 *
 * @package CMS3
 * @author Gabriel PREDA <gabriel.preda@mindbench.nl>
 * @author Raluca NECHITA <raluca.nechita@mindbench.nl>
 * @author Francisc Ungureanu <francisc.ungureanu@mindbench.nl> 
 * @copyright Mindbench Active Media B.V.
 * @version $Id: msPlugin.js 6464 2008-11-28 12:38:15Z gpr $
 *
 * Details:
 * This container will present all active plug-ins with their respective modules for 
 * the application (or user, if the user has access to fewer plug-ins/modules that 
 * defined in the application).
 * 
 * <li> <a onlick href accesskey > ICON TEXT </a> <ol>[ MODULES COLLECTION ]<ol> </li>
 * - color full stuff (active, inactive, mouseover, mouseout)
 * - by option: accesskey, icon/text, 
 * - display style(future method if time permitts)
 * 
 *  - metoda apelata de msPlugin este DRAW care intoarce HTML
 *  - metoda de micsorare este shrink(to) unde "to" reprezinta max de spatiu disponibil
 *  
 *  new msPlugin(config)
 *   
 *   pluginData
 *   {
 *    icon: '', // src to icon
 *    name: '', // text to be displayed in the link
 *    link: '', // href attribute
 *    accesskey: '', // one character used as shortcut
 *   }
 *   
 *   modules - an array of Module JS objects
 *   
 *   options
 *   {
 *    accesskey: native | js
 *   }
 *   
 */

msPlugin = Class.create(msTabContainer, {
  xtype : 'plugin',
  
  initialize: function ($super, config)
  {
    if (!config.items || config.items.lenght == 0)
    {
      alert('No items for this plugin. Cannot initialize.');
      return;
    }
    
    $super(config);
    
    this.config = {
      icon: '', // src to icon
      name: 'Unnamed Plugin', // text to be displayed in the link
      link: '', // href attribute
      accesskey: 'native'
    };
    Object.extend(this.config, config || {});
    
    this.build();
  },

  build: function($super)
  {
    var THIS = this;
    
    this.el = new Element('LI');
    
    this.linkElement = new Element('A', { 'href' : '#' });
      
    if (this.config.accesskey.strip() !== "")
    {
      this.linkElement.accesskey = this.config.accesskey;
    }

    this.linkElement.insert( this.config.name );
    this.el.appendChild(this.linkElement);

    if(this.isActive) {
      this.tabs = new Element('ul');
      this.el.appendChild(this.tabs);
    } else {
      this.tabs = false;
    }
    
    $super();
    
    if (this.config.link == "")
    {
      this.linkElement.href = this.items[0].link;
    }
  }
});
