/////////////////////////////////
//  Componet "toolbar" v2.0
//  Author: Artiom Vendelev
//  Create: 31 Jul 2006
//  Modified: 24 Apr 2007
//  Types of control: button, separator, input, select, lastbutton, text
//  Notes: Don't rename this file!
/////////////////////////////////

function Toolbar(container, userImgPath, callback) {
  var me = this;

  if (eDefault instanceof Function) {
    eDefault.call(me);
  } else return _badInit();

  if (eEvent instanceof Function) {
    me.EV = new eEvent();
  } else return _badInit();
  
  me.container   = container;
  me.defaultData = {};
  me.callback    = callback;
  me.userImgPath = userImgPath + '/';
  me.imgPath  = '';
  me.prefix   = 'tb_';
  me.fileName = 'toolbar2.js';
  me.body = null;

/////////////////////////////////
  _init();
  
/////////////////////////////////
  me.update = _update;
  me.remove = _remove;
  me.hide   = _hide;
  me.show   = _show;
  me.kill   = _kill;

/////////////////////////////////
  function _init() {
    var con = me.container;
    var ii, _scripts = document.getElementsByTagName('SCRIPT');
    var len = _scripts.length;
    if (len) {
      for (ii=0; ii',
        '
', '
', '
', '
' ].join(''); me.body = document.getElementById('con_' + me.container.id); var bl = document.createElement('DIV'); bl.className = me.prefix + 'begin_line'; bl.style.backgroundImage = 'url('+ me.imgPath + me.prefix + 'beginline.gif)'; var b2 = document.createElement('DIV'); b2.className = me.prefix + 'end_line'; b2.style.backgroundImage = 'url('+ me.imgPath + me.prefix + 'beginline.gif)'; b2.innerHTML = ' '; me.body.appendChild(bl); me.body.appendChild(b2); bl = b2 = con = style = null; } else return _badInit(); _scripts = null; } function _badInit() { me.container.innerHTML = "
Bad initialization
"; return false; } function _update(data) { if (!me.imgPath) return; var obj = me.copyObj(data); if (obj instanceof Object) { var ii, element; for (ii in obj) { if (obj[ii] instanceof Object) { obj[ii].id = ii; me.tmp = ii; if (me.defaultData[ii]) { _updateData(me.defaultData[ii].element, obj[ii]); me.defaultData[ii].element = null } else _insertData(obj[ii]); me.defaultData[ii] = obj[ii]; } } } obj = null; } function _prepareData(obj) { switch(obj.type) { case 'separator': obj.elementType = 'DIV'; _createSeparator(obj); break; case 'lastbutton': case 'button': obj.elementType = 'DIV'; _createButton(obj); break; case 'text': obj.elementType = 'DIV'; _createText(obj); break; case 'input': obj.elementType = 'INPUT'; _createInput(obj); break; case 'select': obj.elementType = 'SELECT'; _createSelect(obj); break; case 'date': obj.elementType = 'INPUT'; _createDate(obj) break; } } //Separator function _createSeparator(obj) { obj.element = document.createElement(obj.elementType); obj.element.className = me.prefix + 'sep'; obj.element.id = obj.id; for (var ii in obj) _defaultUpdate(obj.element, ii, obj[ii]) } //Button function _createButton(obj) { obj.element = document.createElement(obj.elementType); obj.element.id = obj.id; obj.element.className = me.prefix + obj.type; obj.element.onmouseover = _onButtonMouseOver; obj.element.onmouseout = _onButtonMouseOut; obj.element.onmousedown = _onButtonMouseDown; obj.element.onmouseup = _onButtonMouseUp; obj.element.onclick = _onButtonClick; _createChildImage(obj); _createChildText(obj); _updateButtonProperty(obj); } function _updateButtonProperty(obj) { for (var ii in obj) { switch (ii) { case 'status': obj.element.status = obj.status; switch (obj.status) { case 'selected': _setStyleMouseOver(obj.element); break; } break; case 'disabled': obj.element.disabled = obj.disabled; if (obj.disabled) obj.element.style.filter = 'progid:DXImageTransform.Microsoft.BasicImage(grayScale=1)'; break; default: _defaultUpdate(obj.element, ii, obj[ii]); break; } } } function _onButtonClick(e) { var el = _getButtonElement(e); if (el && !el.disabled && typeof(me.callback)=='function') me.callback(me.defaultData[el.id]); } function _getButtonElement(e) { var res = me.EV.get(e); var el = null; if (res.el) { if (res.el.tagName=='IMG') { el = res.el.parentNode; } else if (res.el.tagName=='DIV' && res.el.className==(me.prefix + 'button')) { el = res.el; } } return el; } function _onButtonMouseDown(e) { var el = _getButtonElement(e); if (el && !el.disabled) _setStyleMouseDown(el); el = null; } function _onButtonMouseUp(e) { var el = _getButtonElement(e); if (el && !el.disabled) _setStyleMouseUp(el) el = null; } function _onButtonMouseOver(e) { var el = _getButtonElement(e); if (el && !el.disabled) _setStyleMouseOver(el); el = null; } function _onButtonMouseOut(e) { var el = _getButtonElement(e); if (el) { if (el.status=='selected' || el.disabled) return; _onButtonMouseUp(e); _setStyleMouseOut(el); } el = null; } function _setStyleMouseDown(par) { par.style.backgroundColor = '#8592B5'; par.style.paddingTop = '2px'; par.style.paddingLeft = '2px'; par.style.paddingRight = '0px'; par.style.paddingBottom = '0px'; //par.style.color = ''; } function _setStyleMouseUp(par) { par.style.backgroundColor = '#D4D5D8'; par.style.padding = '1px'; // par.style.color = ''; } function _setStyleMouseOver(par) { par.style.border = '1px solid #0A246A'; par.style.backgroundColor = '#D4D5D8'; par.style.marginTop = '2px'; par.style.marginLeft = '1px'; par.style.marginRight = '1px'; } function _setStyleMouseOut(par) { par.style.border = ''; par.style.backgroundColor = ''; par.style.marginTop = '3px'; par.style.marginLeft = '2px'; par.style.marginRight = '2px'; } //Text function _createText(obj) { obj.element = document.createElement(obj.elementType); obj.element.className = me.prefix + 'text'; obj.element.id = obj.id; _createChildImage(obj); _createChildText(obj); for (var ii in obj) _defaultUpdate(obj.element, ii, obj[ii]); } //Input function _createInput(obj) { obj.element = document.createElement(obj.elementType); obj.element.className = me.prefix + 'input'; obj.element.id = obj.id; obj.element.onfocus = function () { obj.onSelectstartBack = me.container.onselectstart; me.container.onselectstart = null; } obj.element.onblur = function () { me.container.onselectstart = obj.onSelectstartBack; if (typeof(me.callback)=='function') me.callback(obj) obj.onSelectstartBack = null; } for (var ii in obj) _defaultUpdate(obj.element, ii, obj[ii]); } //Select function _createSelect(obj) { obj.element = document.createElement(obj.elementType); obj.element.className = me.prefix + 'select'; obj.element.id = obj.id; obj.element.onchange = _onChangeSelect; _updateSelectProperty(obj); } function _updateSelectProperty(obj) { for (var ii in obj) { switch (ii) { case 'options': var len = obj.options.length obj.element.options.length = len; var elo, obo; for (var kk=0; kk