/*
Product Name: dhtmlxSuite
Version: 4.0.3
Edition: Professional
License: content of this file is covered by DHTMLX Commercial or Enterprise license. Usage without proper license is prohibited. To obtain it contact sales@dhtmlx.com
Copyright UAB Dinamenta http://www.dhtmlx.com
*/
function dhtmlXRibbon(struct) {
var that = this, _skin, cont;
this.conf = {
type: "ribbon",
icons_path: (struct && struct.icons_path)?struct.icons_path:"",
skin: "dhx_skyblue"
};
this._eventHandlers = {};
this._base = null;
this._items = {};
this._tabbar = null;
this.childIds = [];
if (typeof(struct) == "string") {
cont = struct;
} else if (struct && struct.tagName) {
cont = struct;
} else if (struct && struct.parent) {
if (struct.parent.tagName || typeof(struct.parent) == "string") {
cont = struct.parent;
}
}
/*** ***/
this._doOnHighlight0 = function(e) {
e = e || event;
var target = e.target || e.srcElement;
var el = that._findItemByNode(target);
var item = that._items[el._dhx_ribbonId];
if (item.conf.disable) {
return;
}
if (that.items[item.type] && typeof(that.items[item.type].mouseover) == "function") {
if (that.items[item.type].mouseover(item, that, e) != true) {
return false;
}
}
if (!/dhxrb_highlight0/.test(el.className)) {
el.className += " dhxrb_highlight0";
}
};
this._doOffHighlight0 = function(e) {
e = e || event;
var target = e.target || e.srcElement;
var el = that._findItemByNode(target);
var item = that._items[el._dhx_ribbonId];
if (item.conf.disable) {
return;
}
if (that.items[item.type] && typeof(that.items[item.type].mouseout) == "function") {
if (that.items[item.type].mouseout(item, that, e) != true) {
return false;
}
}
if (/dhxrb_highlight1/.test(el.className)) {
el.className = el.className.replace(/\s?dhxrb_highlight1/, "");
}
if (/dhxrb_highlight0/.test(el.className)) {
el.className = el.className.replace(/\s?dhxrb_highlight0/, "");
}
};
this._doOnHighlight1 = function (e) {
e = e || event;
var target = e.target || e.srcElement;
var el = that._findItemByNode(target);
var item = that._items[el._dhx_ribbonId];
if (item.conf.disable) {
return;
}
that.callEvent("_showPopup",[item.id]);
if (that.items[item.type] && typeof(that.items[item.type].mousedown) == "function") {
if (that.items[item.type].mousedown(item, that, e) != true) {
return false;
}
}
if (!/dhxrb_highlight1/.test(el.className)) {
el.className += " dhxrb_highlight1";
}
};
this._doOffHighlight1 = function (e) {
e = e || event;
var target = e.target || e.srcElement;
var el = that._findItemByNode(target);
var item = that._items[el._dhx_ribbonId];
if (item.conf.disable) {
return;
}
if (that.items[item.type] && typeof(that.items[item.type].mouseup) == "function") {
if (that.items[item.type].mouseup(item, that, e) != true) {
return false;
}
}
if (/dhxrb_highlight1/.test(el.className)) {
el.className = el.className.replace(/\s?dhxrb_highlight1/, "");
}
};
this._doOnClick = function(e) {
e = e || event;
var target = e.target || e.srcElement;
var el = that._findItemByNode(target);
var item = that._items[el._dhx_ribbonId];
if (item.conf.disable) {
return;
}
if (that.items[item.type] && typeof(that.items[item.type].click) == "function") {
that.items[item.type].click(item, that, e);
}
};
this._doOnFocus = function(e) {
e = e || event;
var target = e.target || e.srcElement;
var el = that._findItemByNode(target);
var item = that._items[el._dhx_ribbonId];
if (item.conf.disable) {
return;
}
that.callEvent("_showPopup",[item.id]);
if (that.items[item.type] && typeof(that.items[item.type].focus) == "function") {
that.items[item.type].focus(item, that, e);
}
};
this._doOnBlur = function(e) {
e = e || event;
var target = e.target || e.srcElement;
var el = that._findItemByNode(target);
var item = that._items[el._dhx_ribbonId];
if (item.conf.disable) {
return;
}
if (that.items[item.type] && typeof(that.items[item.type].blur) == "function") {
that.items[item.type].blur(item, that, e);
}
};
this._doOnChange = function(e) {
e = e || event;
var target = e.target || e.srcElement;
var el = that._findItemByNode(target);
var item = that._items[el._dhx_ribbonId];
if (item.conf.disable) {
return;
}
if (that.items[item.type] && typeof(that.items[item.type].change) == "function") {
that.items[item.type].change(item, that, e);
}
};
this._doOnKeydown = function(e) {
e = e || event;
var target = e.target || e.srcElement;
var el = that._findItemByNode(target);
var item = that._items[el._dhx_ribbonId];
if (item.conf.disable) {
return;
}
if (that.items[item.type] && typeof(that.items[item.type].keydown) == "function") {
that.items[item.type].keydown(item, that, e);
}
};
/*** ***/
this._tabCustomApi = {
enable: function(actvId, isCall) {
/* @var this dhtmlXCellObject */
var item = null, key = null;
isCall = isCall || false;
if (isCall != true) {
item = that._items[this._idd];
for(key in item.childIds) {
key = parseInt(key);
that.enable(item.childIds[key]);
}
}
return that._tabOriginalApi.enable.apply(this,[actvId]);
},
disable: function(actvId, isCall) {
/* @var this dhtmlXCellObject */
var item = null, key = null;
if (isCall != false) {
item = that._items[this._idd];
for(key in item.childIds) {
key = parseInt(key);
that.disable(item.childIds[key]);
}
}
return that._tabOriginalApi.disable.apply(this,[actvId]);
},
close: function(actvId) {
/* @var this dhtmlXCellObject */
var item = that._items[this._idd], key;
that._removeTab(item);
that._tabOriginalApi.close.apply(this,[actvId]);
for(key in that._tabOriginalApi) {
this[key] = null;
}
}
};
/*** ***/
this._attachEventTabbar = function() {
this._tabbar.attachEvent("onSelect",function() {
return that.callEvent("onSelect",arguments);
});
this._tabbar.attachEvent("onTabClick",function() {
return that.callEvent("onTabClick",arguments);
});
this._tabbar.attachEvent("onTabClose",function() {
return that.callEvent("onTabClose",arguments);
});
};
if (typeof(cont) == "string") {
this._base = document.getElementById(cont);
} else if (cont && cont.tagName) {
this._base = cont;
} else {
this._base = document.createElement('div');
this._base._dhx_remove = true;
if (document.body.firstChild) {
document.body.insertBefore(this._base,document.body.firstChild);
} else {
document.body.appendChild(this._base);
}
}
_skin = dhx4.skin || (typeof(dhtmlx)!="undefined"?dhtmlx.skin:null) || dhx4.skinDetect("dhtmlxribbon") || "dhx_skyblue";
if (typeof(struct) == "object" && struct.skin) {
_skin = struct.skin;
}
this.setSkin(_skin);
dhx4._eventable(this);
dhx4._enableDataLoading(this, "_renderData", "_xmlToJson", "ribbon", {struct:true});
this.attachEvent("_onHeightChanged", function() {
this.conf.inited = true;
});
this._base.className += " dhxrb_without_tabbar";
this._base.innerHTML = "
";
if (struct != null) {
if (struct.json) {
this.loadStruct(struct.json, struct.onload);
} else if (struct.xml) {
this.loadStruct(struct.xml, struct.onload);
} else {
this._renderData(struct);
}
}
this.unload = function() {
var ind = null, chs = [];
for (ind in this.childIds) {
ind = parseInt(ind);
chs.push(this.childIds[ind]);
}
dhx4._enableDataLoading(this, null, null, null, "clear");
dhx4._eventable(this, "clear");
for(ind in chs) {
ind = parseInt(ind);
if (this._items[chs[ind]].type == "tab") {
this.tabs(chs[ind]).close(false);
} else {
this.removeItem(chs[ind]);
}
}
if (this._tabbar) {
this._tabbar.unload();
this._tabbar = null;
}
this._base.innerHTML = "";
if (this._base._dhx_remove) {
this._base.parentNode.removeChild(this._base);
} else {
this._base.className = this._base.className.replace(/\s?(dhtmlx|dhxrb)(\S*)/ig,"");
}
for(ind in this) {
this[ind] = null;
}
that = null;
};
}
dhtmlXRibbon.prototype.setSizes = function() {
if (this._tabbar != null && typeof(this.setSizes) == "function") {
this._tabbar.setSizes();
}
};
dhtmlXRibbon.prototype._renderData = function(data) {
var cont = this._base.firstChild;
// var data = null;
// if (_data instanceof Object) {
// data = dhx4._copyObj(_data);
// }
if (data != null) {
this.conf.icons_path = data.icons_path || this.conf.icons_path;
if (data.tabs instanceof Array) {
this._base.className = this._base.className.replace(/\s?dhxrb_without_tabbar/i, "");
cont.className = "dhxrb_with_tabbar";
this._tabbar = new dhtmlXTabBar(cont);
this._attachEventTabbar();
this._tabbar.setSkin(this.conf.skin);
this.childIds = this._appendTabs(data.tabs);
} else if (data.items instanceof Array) {
if (!/\s?dhxrb_without_tabbar/i.test(this._base.className)) {
this._base.className += " dhxrb_without_tabbar";
}
if (/\s?dhxrb_background_area/i.test(cont.className)) {
cont.className = "dhxrb_background_area";
}
cont.innerHTML = "";
this.childIds = this._appendBlocks(data.items,cont.firstChild);
}
this.callEvent("_onHeightChanged",[]);
}
};
dhtmlXRibbon.prototype._xmlToJson = function(xml) {
var root = xml.lastChild || null,
answer = {}, list = [];
if (root && root.tagName == "ribbon") {
list = this._convertXmlNodeListIntoObject(root.childNodes);
}
if (list[0] && list[0].type && list[0].type.toLowerCase() == 'block') {
answer.items = list;
} else {
answer.tabs = list;
}
return answer;
};
dhtmlXRibbon.prototype._convertXmlNodeListIntoObject = function(nodeList) {
var i, l, answer = [], item;
l = nodeList.length;
for (i=0; i"+
""+item.conf.text+"
";
if (typeof(this.afterRender) == "function") {
this.afterRender(item);
}
if (item.conf.disable) {
this.disable(item);
}
return item;
},
getText: function(item) {
return item.conf.text;
},
setText: function(item, text) {
var contForText = item.base.childNodes[1];
item.conf.text = text;
contForText.innerHTML = text;
},
mousedown: function(item,rb,e) {
return true;
},
click: function(item,ribbon,e) {
if (e.button != 0) {
return false;
}
ribbon._callHandler(item.id, [item.id]);
item.callEvent("onClick",[item.id]);
return false;
},
disable: function(item) {
var contForImage = item.base.childNodes[0],
contForText = item.base.childNodes[1];
if (item.conf.imgdis) {
contForImage.src = item.conf.icons_path+item.conf.imgdis;
if (/\s?dhxrb_invisible/i.test(contForImage.className)) {
contForImage.className = contForImage.className.replace(/\s?dhxrb_invisible/i, "");
}
}
if (!/\s?dhxrb_disable_text_style/i.test(contForText.className)) {
contForText.className += " dhxrb_disable_text_style";
}
return true;
},
enable: function(item) {
var contForImage = item.base.childNodes[0],
contForText = item.base.childNodes[1];
if (item.conf.img) {
contForImage.src = item.conf.icons_path+item.conf.img;
} else {
if (!/\s?dhxrb_invisible/i.test(contForImage.className)) {
contForImage.className += " dhxrb_invisible";
}
}
if (/\s?dhxrb_disable_text_style/i.test(contForText.className)) {
contForText.className = contForText.className.replace(/\s?dhxrb_disable_text_style/i, "");
}
return true;
}
};
dhtmlXRibbon.prototype.items.buttonTwoState = {
click: function(item, rb, e) {
return false;
},
afterRender: function(item) {
if (item.conf.state) {
this.setState(item, item.conf.state);
}
},
mouseover: function(item) {
if (!/dhxrb_highlight0/.test(item.base.className)) {
item.base.className += " dhxrb_highlight0";
}
return false;
},
mouseout: function(item) {
if (/dhxrb_highlight0/.test(item.base.className)) {
item.base.className = item.base.className.replace(/\s?dhxrb_highlight0/, "");
}
return false;
},
mousedown: function(item, rb, e) {
rb._callHandler(item.id,[item.id,!item.conf.state]);
this.setState(item, !item.conf.state, true);
return false;
},
mouseup: function(item) {
return false;
},
setState: function(item, value, callEvent) {
callEvent = callEvent || false;
value = dhx4.s2b(value);
if (value) {
if (!/dhxrb_highlight1/.test(item.base.className)) {
item.base.className += " dhxrb_highlight1";
}
} else {
if (/dhxrb_highlight1/.test(item.base.className)) {
item.base.className = item.base.className.replace(/\s?dhxrb_highlight1/, "");
}
}
item.conf.state = value;
if (callEvent) {
item.callEvent("onStateChange",[item.id, item.conf.state]);
}
}
};
dhtmlXRibbon.prototype.items.buttonSegment = {
click: function(item, rb, e) {
return false;
},
mousedown: function(item, rb, e) {
this.setState(item, rb, true);
return false;
},
callAfterInit: function(item) {
/* @var this dhtmlXRibbon */
if (item.conf.state || dhtmlXRibbon.prototype.items.buttonSegment._getSelectedNeighbor(item, this) == null) {
if (item.conf.state) {
item.conf.state = false;
}
dhtmlXRibbon.prototype.items.buttonSegment.setState(item, this, false);
}
},
afterRender: function() {},
setState: function(item, rb, callEvent) {
callEvent = callEvent || false;
var oldItem = null, state = dhx4.s2b(item.conf.state);
if (state == false) {
oldItem = this._getSelectedNeighbor(item,rb);
if (oldItem != null) {
this._unSelect(oldItem);
}
if (!/dhxrb_highlight1/.test(item.base.className)) {
item.base.className += " dhxrb_highlight1";
}
item.conf.state = true;
if (callEvent) {
rb._callHandler(item.id,[item.id,(oldItem?oldItem.id:null)]);
rb.callEvent("onStateChange", [item.id, (oldItem?oldItem.id:null)]);
}
}
},
remove: function(item, rb) {
var state = dhx4.s2b(item.conf.state),
firstItem = null, i=0, parent = rb._items[item.parentId],
tempItem;
if (state) {
while (parent.childIds[i] && firstItem == null) {
tempItem = rb._items[parent.childIds[i]];
if (tempItem.type == "buttonSegment" && tempItem != item) {
firstItem = tempItem;
}
i++;
}
if (firstItem) this.setState(firstItem, rb);
}
},
_unSelect: function(item) {
var state = dhx4.s2b(item.conf.state);
if (state) {
if (/dhxrb_highlight1/.test(item.base.className)) {
item.base.className = item.base.className.replace(/\s?dhxrb_highlight1/, "");
}
item.conf.state = false;
}
},
_getSelectedNeighbor: function(item, rb) {
var parent = rb._items[item.parentId], i, l, neighbor, answer = null;
l = parent.childIds.length;
for (i=0; i ";
item.menu = null;
this.itemCollection.push(item);
this._attachEventToWindow();
label = null;
},
setText: function(item,text) {
var arrow = item.base.childNodes[1].lastChild;
item.conf.text = text;
item.base.childNodes[1].innerHTML = text;
item.base.childNodes[1].appendChild(arrow);
},
_attachEventToWindow: function() {
if (this._isAttachedEventInWindow == false) {
if (typeof(window.addEventListener) == "function") {
document.body.addEventListener("mousedown",this._hideAllMenus, false);
} else {
document.body.attachEvent("onmousedown",this._hideAllMenus);
}
this._isAttachedEventInWindow = true;
}
},
_detachEventFromWindow: function() {
if (typeof(window.addEventListener) == "function") {
document.body.removeEventListener("mousedown", this._hideAllMenus, false);
} else {
document.body.detachEvent("onmousedown", this._hideAllMenus);
}
this._isAttachedEventInWindow = false;
},
_hideAllMenus: function(e) {
e = e || event;
var t = e.target||e.srcElement;
var m = true;
while (t != null && m == true) {
if (t.className != null && /SubLevelArea_Polygon/i.test(t.className)) {
m = false;
} else {
t = t.parentNode;
}
}
if (m == false) {
return;
}
var items = dhtmlXRibbon.prototype.items.buttonSelect.itemCollection;
for (var itemId in items) {
var item = items[itemId];
if (item.menu instanceof dhtmlXMenuObject) {
if (item._skipHiding) {
item._skipHiding = false;
} else {
dhtmlXRibbon.prototype.items.buttonSelect.hideMenu(item);
}
}
}
},
mousedown: function(item,rb,e) {
item._skipHiding = true;
this.showMenu(item);
return false;
},
mouseup: function(item) {
return false;
},
click: function() {},
setState: function() {},
showMenu: function(item) {
var x = dhx4.absLeft(item.base),
y = dhx4.absTop(item.base)+item.base.offsetHeight;
if (!(item.menu instanceof dhtmlXMenuObject)) {
item.menu = new dhtmlXMenuObject({
parent: item.base,
icons_path: item.conf.icons_path,
context: true,
items: item.conf.items,
skin: item.conf.skin
});
if (item.conf.data) {
item.menu.loadStruct(item.conf.data);
delete item.conf.data;
}
item.menu.setAutoHideMode(false);
item.menu.attachEvent("onHide",function(id) {
if (id == null) dhtmlXRibbon.prototype.items.buttonSelect._doOnHideMenu(item);
});
item.menu.attachEvent("onShow",function(id) {
if (id == null) dhtmlXRibbon.prototype.items.buttonSelect._doOnShowMenu(item);
});
item.menu.attachEvent("onClick", function(id) {
item.callEvent("onClick",[id]);
});
item.base.oncontextmenu = function() { return false; };
dhtmlXRibbon.prototype.items.buttonSelect.showMenu(item);
} else {
item.menu.showContextMenu(x,y);
}
},
hideMenu: function(item) {
if (item.menu instanceof dhtmlXMenuObject) {
item.menu.hideContextMenu();
}
},
remove: function(item) {
var itemId, l;
if (item.menu instanceof dhtmlXMenuObject) {
item.menu.unload();
item.menu = null;
}
item.base.oncontextmenu = null;
itemId = dhtmlXRibbon.prototype._indexOf(dhtmlXRibbon.prototype.items.buttonSelect.itemCollection, item);
if (itemId != -1) {
dhtmlXRibbon.prototype.items.buttonSelect.itemCollection.splice(itemId,1);
}
if (dhtmlXRibbon.prototype.items.buttonSelect.itemCollection.length == 0) {
this._detachEventFromWindow();
}
},
setSkin: function(item, skin) {
if (item.menu instanceof dhtmlXMenuObject) {
item.menu.setSkin(skin);
}
},
_doOnHideMenu: function(item) {
if (item._skipHiding) {
item._skipHiding = false;
} else {
if (/dhxrb_highlight1/.test(item.base.className)) {
item.base.className = item.base.className.replace(/\s?dhxrb_highlight1/, "");
}
}
},
_doOnShowMenu: function(item) {
if (!/dhxrb_highlight1/.test(item.base.className)) {
item.base.className += " dhxrb_highlight1";
}
}
};
dhtmlXRibbon.prototype.items.group = {
render: function(cont, itemData) {
var key, item;
item = {
base: cont,
id: itemData.id,
type: itemData.type,
conf: {
disable: false,
skin: itemData.skin
},
childIds: []
};
cont.className = "dhxrb_group";
for (key in itemData) {
if (key == "id" || key == "onclick" || key == "type") {
continue;
}
item.conf[key] = itemData[key];
}
return item;
},
callAfterInit: function(item) {
/* @var this dhtmlXRibbon */
this._detachEventFromItem(item.base);
var i,l, list = item.conf.list, child, label, sep;
l = (list)?list.length:0;
for (i=0; i";
if (typeof(this.afterRender) == "function") {
this.afterRender(item);
}
if (item.conf.disable) {
this.disable(item);
}
if (item.conf.width) {
this.setWidth(item, item.conf.width);
}
if (item.conf.value) {
this.setValue(item, item.conf.value);
}
return item;
},
callAfterInit: function(item) {
/* @var this dhtmlXRibbon */
var contForInput = item.base.childNodes[0];
this._detachEventFromItem(item.base);
this._attachEventsToInput(contForInput);
},
setText: dhtmlXRibbon.prototype.items.button.setText,
getText: dhtmlXRibbon.prototype.items.button.getText,
change: function(item) {
var contForInput = item.base.childNodes[0];
item.conf.value = contForInput.value;
},
keydown: function(item, rb, e) {
if (e.keyCode == 13) {
var contForInput = item.base.childNodes[0];
item.conf.value = contForInput.value;
rb.callEvent("onEnter",[item.id, item.conf.value]);
}
},
remove: function(item, rb) {
var contForInput = item.base.childNodes[0];
rb._detachEventsFromInput(contForInput);
},
getValue: function(item) {
var contForInput = item.base.childNodes[0], value;
value = contForInput.value;
contForInput = undefined;
return value;
},
setValue: function(item, value) {
var contForInput = item.base.childNodes[0], value;
contForInput.value = value;
item.conf.value = value;
},
setWidth: function(item, value) {
var contForInput = item.base.childNodes[0];
contForInput.style.width = parseInt(value)+"px";
},
disable: function(item) {
var contForInput = item.base.childNodes[0],
contForText = item.base.childNodes[1];
contForInput.disabled = true;
if (!/\s?dhxrb_disable_text_style/i.test(contForText.className)) {
contForText.className += " dhxrb_disable_text_style";
}
return true;
},
enable: function(item) {
var contForInput = item.base.childNodes[0],
contForText = item.base.childNodes[1];
contForInput.disabled = false;
if (/\s?dhxrb_disable_text_style/i.test(contForText.className)) {
contForText.className = contForText.className.replace(/\s?dhxrb_disable_text_style/i, "");
}
return true;
}
};
dhtmlXRibbon.prototype.items.checkbox = {
render: function (cont, itemData) {
var key, item;
item = {
base: cont,
id: itemData.id,
type: itemData.type,
conf: {
text: "",
text_pos: (itemData.isbig)?"bottom":"right",
disable: false,
checked: false
}
};
for (key in itemData) {
if (key == "id" || key == "onclick" || key == "type") {
continue;
}
item.conf[key] = itemData[key];
}
cont.innerHTML = ""+item.conf.text+"
";
if (typeof(this.afterRender) == "function") {
this.afterRender(item);
}
if (item.conf.checked) {
this.check(item);
}
return item;
},
callAfterInit: function(item) {
/* @var this dhtmlXRibbon */
if (item.conf.disable) {
this.disable(item.id);
}
},
setText: dhtmlXRibbon.prototype.items.button.setText,
getText: dhtmlXRibbon.prototype.items.button.getText,
mousedown: function(item) {
return false;
},
mouseup: function(item) {
return false;
},
click: function(item, rb, e) {
if (e.button != 0) {
return false;
}
if (item.type == "checkbox") {
if (item.conf.checked) {
this.uncheck(item, true);
} else {
this.check(item, true);
}
}
},
check: function(item, callEvent) {
callEvent = callEvent || false;
if (item.type != "checkbox") {
return;
}
item.conf.checked = true;
if (!/\s?dhxrb_checked/i.test(item.base.className)) {
item.base.className += " dhxrb_checked";
}
if (callEvent) {
item.callEvent("onCheck",[item.id, item.conf.checked]);
}
},
uncheck: function(item, callEvent) {
callEvent = callEvent || false;
if (item.type != "checkbox") {
return;
}
item.conf.checked = false;
if (/\s?dhxrb_checked/i.test(item.base.className)) {
item.base.className = item.base.className.replace(/\s?dhxrb_checked/i,"");
}
if (callEvent) {
item.callEvent("onCheck",[item.id, item.conf.checked]);
}
},
disable: function(item) {
return true;
},
enable: function(item) {
return true;
}
};
dhtmlXRibbon.prototype.items.text = {
render: function(cont, data) {
var item = {
base: cont,
id: data.id,
type: data.type,
conf: {
text: ""
}
};
for (var key in data) {
if (key == "id" || key == "type") {
continue;
}
item.conf[key] = data[key];
}
cont.innerHTML = ""+item.conf.text+"
";
if (typeof(this.afterRender) == "function") {
this.afterRender(item);
}
return item;
},
callAfterInit: function(item) {
/* @var this dhtmlXRibbon */
this._detachEventFromItem(item.base);
},
getText: function(item) {
return item.conf.text;
},
setText: function(item, text) {
item.conf.text = text;
item.base.innerHTML = text;
}
};
dhtmlXRibbon.prototype.items.buttonCombo = {
render: function(cont, dataItem) {
var key, item, comboConf={};
item = {
base: cont,
id: dataItem.id,
type: dataItem.type,
conf: {
text: "",
text_pos: "right",
width: 140,
skin: dataItem.skin
}
};
for (key in dataItem) {
if (key == "id" || key == "onclick" || key == "type") {
continue;
}
item.conf[key] = dataItem[key];
}
for (key in item.conf) {
if (key == "text" || key == "text_pos" || key == "disable" || key == "data") {
continue;
}
comboConf[key] = item.conf[key];
}
item.base.className += " dhxrb_buttoncombo_cont";
item.base.innerHTML = ""+item.conf.text+"
";
comboConf.parent = item.base.firstChild;
item.combo = new dhtmlXCombo(comboConf);
item.combo.setSkin(comboConf.skin); // deprecated;
item.combo.attachEvent("onChange", function(value, text) {
item._callHandler(item.id, [value, text]);
item.callEvent("onSelectOption", [item.id, value, text]);
});
if (item.conf.data) {
item.combo.load(item.conf.data);
delete item.conf.data;
}
if (typeof(this.afterRender) == "function") {
this.afterRender(item);
}
if (item.conf.disable) {
this.disable(item);
}
return item;
},
callAfterInit: function(item) {
/* @var this dhtmlXRibbon */
this._detachEventFromItem(item.base);
},
disable: function(item) {
var contForText = item.base.lastChild;
if (item.combo instanceof dhtmlXCombo) {
item.combo.disable();
}
if (!/\s?dhxrb_disable_text_style/i.test(contForText.className)) {
contForText.className += " dhxrb_disable_text_style";
}
return true;
},
enable: function(item) {
var contForText = item.base.lastChild;
if (item.combo instanceof dhtmlXCombo) {
item.combo.enable();
}
if (/\s?dhxrb_disable_text_style/i.test(contForText.className)) {
contForText.className = contForText.className.replace(/\s?dhxrb_disable_text_style/i, "");
}
return true;
},
remove: function(item) {
if (item.combo instanceof dhtmlXCombo) {
item.combo.unload();
item.combo = null;
}
},
getValue: function(item) {
var answer = null;
if (item.combo instanceof dhtmlXCombo) {
answer = item.combo.getSelectedValue();
}
return answer;
},
setValue: function(item,value) {
if (item.combo instanceof dhtmlXCombo) {
item.combo.setComboValue(value);
}
},
setSkin: function(item, skin) {
if (item.combo instanceof dhtmlXCombo) {
item.combo.setSkin(skin);
}
}
};
dhtmlXRibbon.prototype.items.slider = {
render: function(cont, data) {
var key, item, sliderConf={};
item = {
base: cont,
id: data.id,
type: data.type,
conf: {
text: "",
text_pos: "right",
size: 150,
vertical: false,
min: 0,
max: 99,
value: 0,
step: 1,
margin: 10,
disabled: false,
enableTooltip: false
}
};
for (key in data) {
if (key == "id" || key == "onclick" || key == "type") {
continue;
}
item.conf[key] = data[key];
}
for (key in item.conf) {
if (key == "text" || key == "text_pos" || key == "isbig") {
continue;
}
sliderConf[key] = item.conf[key];
}
item.base.innerHTML = ""+item.conf.text+"
";
sliderConf.parent = item.base.firstChild.firstChild;
item.slider = new dhtmlXSlider(sliderConf);
if (typeof(this.afterRender) == "function") {
this.afterRender(item);
}
if (item.conf.disable) {
this.disable(item);
}
item.slider.attachEvent("onChange", function(value) {
item._callHandler(item.id, [value]);
item.callEvent("onValueChange", [item.id, value]);
});
return item;
},
callAfterInit: function(item) {
/* @var this dhtmlXRibbon */
this._detachEventFromItem(item.base);
},
setSkin: function(item, skin) {
if (item.slider instanceof dhtmlXSlider) {
item.slider.setSkin(skin);
}
},
disable: function(item) {
var contForText = item.base.childNodes[1];
if (item.slider instanceof dhtmlXSlider) {
item.slider.disable();
}
if (!/\s?dhxrb_disable_text_style/i.test(contForText.className)) {
contForText.className += " dhxrb_disable_text_style";
}
return true;
},
enable: function(item) {
var contForText = item.base.childNodes[1];
if (item.slider instanceof dhtmlXSlider) {
item.slider.enable();
}
if (/\s?dhxrb_disable_text_style/i.test(contForText.className)) {
contForText.className = contForText.className.replace(/\s?dhxrb_disable_text_style/i, "");
}
return true;
},
remove: function(item) {
if (item.slider instanceof dhtmlXSlider) {
item.slider.unload();
item.slider = null;
}
},
getValue: function(item) {
var answer = null;
if (item.slider instanceof dhtmlXSlider) {
answer = item.slider.getValue();
}
return answer;
},
setValue: function(item,value) {
if (item.slider instanceof dhtmlXSlider) {
item.slider.setValue(value);
}
}
};
/******************************************************/
dhtmlXRibbon.prototype.items._extends = function(item,parent) {
var key;
for (key in parent) {
item[key] = item[key] || parent[key];
}
return item;
};
dhtmlXRibbon.prototype._addNewLevel = function (block) {
var lastNode,cont;
if (block.conf.mode == 'rows') {
lastNode = block.contForItems.lastChild;
if (lastNode && /dhxrb_block_rows/i.test(lastNode.className) && (lastNode.childNodes.length < 3)) {
cont = document.createElement('div');
cont.className = "dhxrb_block_row";
lastNode.appendChild(cont);
} else {
lastNode = document.createElement('div');
lastNode.className = "dhxrb_block_rows";
block.contForItems.appendChild(lastNode);
cont = document.createElement('div');
cont.className = "dhxrb_block_row";
lastNode.appendChild(cont);
}
} else {
var cont = document.createElement("div");
cont.className = "dhxrb_3rows_block";
block.contForItems.appendChild(cont);
}
};
dhtmlXRibbon.prototype._attachEventForItem = function(cont) {
if (typeof(window.addEventListener) == "function") {
cont.addEventListener("mouseover", this._doOnHighlight0, false);
cont.addEventListener("mouseout", this._doOffHighlight0, false);
cont.addEventListener("mousedown", this._doOnHighlight1, false);
cont.addEventListener("mouseup", this._doOffHighlight1, false);
cont.addEventListener("click", this._doOnClick, false);
} else {
cont.attachEvent("onmouseover", this._doOnHighlight0);
cont.attachEvent("onmouseout", this._doOffHighlight0);
cont.attachEvent("onmousedown", this._doOnHighlight1);
cont.attachEvent("onmouseup", this._doOffHighlight1);
cont.attachEvent("onclick", this._doOnClick);
}
};
dhtmlXRibbon.prototype._detachEventFromItem = function(cont) {
if (typeof(window.addEventListener) == "function") {
cont.removeEventListener("mouseover", this._doOnHighlight0, false);
cont.removeEventListener("mouseout", this._doOffHighlight0, false);
cont.removeEventListener("mousedown", this._doOnHighlight1, false);
cont.removeEventListener("mouseup", this._doOffHighlight1, false);
cont.removeEventListener("click", this._doOnClick, false);
} else {
cont.detachEvent("onmouseover", this._doOnHighlight0);
cont.detachEvent("onmouseout", this._doOffHighlight0);
cont.detachEvent("onmousedown", this._doOnHighlight1);
cont.detachEvent("onmouseup", this._doOffHighlight1);
cont.detachEvent("onclick", this._doOnClick);
}
};
dhtmlXRibbon.prototype._attachEventsToInput = function(cont) {
if (typeof(window.addEventListener) == "function") {
cont.addEventListener("focus", this._doOnFocus, false);
cont.addEventListener("blur", this._doOnBlur, false);
cont.addEventListener("change", this._doOnChange, false);
cont.addEventListener("keydown", this._doOnKeydown, false);
} else {
cont.attachEvent("onfocus", this._doOnFocus);
cont.attachEvent("onblur", this._doOnBlur);
cont.attachEvent("onchange", this._doOnChange);
cont.attachEvent("onkeydown", this._doOnKeydown);
}
};
dhtmlXRibbon.prototype._detachEventsFromInput = function(cont) {
if (typeof(window.addEventListener) == "function") {
cont.removeEventListener("focus", this._doOnFocus, false);
cont.removeEventListener("blur", this._doOnBlur, false);
cont.removeEventListener("change", this._doOnChange, false);
cont.removeEventListener("keydown", this._doOnKeydown, false);
} else {
cont.detachEvent("onfocus", this._doOnFocus);
cont.detachEvent("onblur", this._doOnBlur);
cont.detachEvent("onchange", this._doOnChange);
cont.detachEvent("onkeydown", this._doOnKeydown);
}
};
dhtmlXRibbon.prototype._getContainerForSmallItem = function(parent) {
var last_el = parent.contForItems.lastChild, cont = null;
if (parent.conf.mode == "rows") {
if (last_el && /\s?dhxrb_block_rows/i.test(last_el.className)) {
cont = last_el.lastChild;
if (!cont) {
cont = document.createElement('div');
cont.className = "dhxrb_block_row";
last_el.appendChild(cont);
}
} else {
last_el = document.createElement('div');
last_el.className = "dhxrb_block_rows";
parent.contForItems.appendChild(last_el);
cont = document.createElement('div');
cont.className = "dhxrb_block_row";
last_el.appendChild(cont);
}
} else {
if (last_el && /dhxrb_3rows_block/i.test(last_el.className) && (last_el.childNodes.length < 3)) {
cont = last_el;
} else {
cont = document.createElement("div");
cont.className = "dhxrb_3rows_block";
parent.contForItems.appendChild(cont);
}
}
return cont;
};
dhtmlXRibbon.prototype._findItemByNode = function(el) {
while (el && !el._dhx_ribbonId) {
el = el.parentNode;
}
return el;
};
dhtmlXRibbon.prototype._indexOf = function(arr,item) {
var i,l;
l = arr.length;
for (i=0; i